pub const STACK_GRAPHS_TSG_SOURCE: &str = ";;;;;;;;;;;;;;;;;;;\n;; Global Variables\n\nglobal FILE_PATH ; project relative path of this file\nglobal PROJECT_NAME = \"\" ; project name, used to isolate different projects in the same stack graph\n\nglobal JUMP_TO_SCOPE_NODE\nglobal ROOT_NODE\n\n;;;;;;;;;;;;;;;;;;;;;;;\n;; Attribute Shorthands\n\nattribute node_definition = node => type = \"pop_symbol\", node_symbol = node, is_definition\nattribute node_reference = node => type = \"push_symbol\", node_symbol = node, is_reference\nattribute pop_node = node => type = \"pop_symbol\", node_symbol = node\nattribute pop_scoped_node = node => type = \"pop_scoped_symbol\", node_symbol = node\nattribute pop_scoped_symbol = symbol => type = \"pop_scoped_symbol\", symbol = symbol\nattribute pop_symbol = symbol => type = \"pop_symbol\", symbol = symbol\nattribute push_node = node => type = \"push_symbol\", node_symbol = node\nattribute push_scoped_node = node => type = \"push_scoped_symbol\", node_symbol = node\nattribute push_scoped_symbol = symbol => type = \"push_scoped_symbol\", symbol = symbol\nattribute push_symbol = symbol => type = \"push_symbol\", symbol = symbol\nattribute scoped_node_definition = node => type = \"pop_scoped_symbol\", node_symbol = node, is_definition\nattribute scoped_node_reference = node => type = \"push_scoped_symbol\", node_symbol = node, is_reference\nattribute symbol_definition = symbol => type = \"pop_symbol\", symbol = symbol, is_definition\nattribute symbol_reference = symbol => type = \"push_symbol\", symbol = symbol, is_reference\n\nattribute node_symbol = node => symbol = (source-text node), source_node = node\n\n; ######\n; # # ##### #### #### ##### ## # # ####\n; # # # # # # # # # # # # ## ## #\n; ###### # # # # # # # # # # ## # ####\n; # ##### # # # ### ##### ###### # # #\n; # # # # # # # # # # # # # # #\n; # # # #### #### # # # # # # ####\n;\n; ########################################################\n\n(program)@prog {\n node @prog.defs\n node @prog.lexical_scope\n edge @prog.lexical_scope -> ROOT_NODE\n edge @prog.lexical_scope -> @prog.defs\n}\n\n(program (_)@declaration)@prog {\n edge @prog.defs -> @declaration.defs\n edge @declaration.lexical_scope -> @prog.lexical_scope\n}\n\n\n;; =======================\n;; Top level declarations\n;; =======================\n\n[\n (module_declaration)\n (package_declaration)\n (import_declaration)\n] @decl\n{\n node @decl.defs\n node @decl.lexical_scope\n}\n\n(program\n (package_declaration\n (identifier)@pkg_name)? @package) @prog {\n if none @package {\n edge ROOT_NODE -> @prog.defs\n } else {\n node pkg_def\n attr (pkg_def) node_definition = @pkg_name\n edge pkg_def -> @prog.defs\n edge ROOT_NODE -> pkg_def\n }\n}\n\n(import_declaration (_) @ref) @import {\n edge @ref.lexical_scope -> @import.lexical_scope\n}\n\n;; X\n(identifier) @name {\n node @name.lexical_scope\n node @name.type\n\n node @name.ref\n attr (@name.ref) node_reference = @name\n edge @name.ref -> @name.lexical_scope\n}\n\n;; _.X\n(scoped_identifier scope: (_) @scope name: (_) @name) @scoped_name {\n node @scoped_name.lexical_scope\n\n edge @scope.lexical_scope -> @scoped_name.lexical_scope\n\n edge @name.lexical_scope -> @scope.ref\n\n node @scoped_name.ref\n edge @scoped_name.ref -> @name.ref\n}\n\n[\n (import_declaration (identifier) @_scope @name)\n (import_declaration (scoped_identifier scope: (_) @_scope name: (identifier) @name))\n] @import {\n node def\n attr (def) node_definition = @name\n edge def -> @name.ref\n\n edge @import.defs -> def\n}\n\n;;;;;;;;;;;;;;;;;;;;\n;; Class Expressions\n\n; Classes (and other declarations with members, e.g. records, enums, interfaces) define a name in their enclosing scope as well as names belonging to the class itself (i.e. statics) and instances of the class.\n;\n; They additionally implicitly define `this` available in the bodies of instance methods, and subclasses further define `super`. The nodes defining these point at the types of the class and superclass, respectively.\n\n(class_declaration\n name: (identifier) @name\n body: (class_body) @class_body) @class {\n\n node def\n attr (def) node_definition = @name\n\n node ref\n attr (ref) node_reference = @name\n edge ref -> @class.lexical_scope\n edge @class_body.lexical_scope -> ref\n\n edge @class_body.lexical_scope -> @class.lexical_scope\n\n edge @class_body.lexical_scope -> @class_body.defs\n attr (@class_body.lexical_scope -> @class_body.defs) precedence = 1\n edge @class.defs -> def\n edge def -> @class_body.defs\n edge def -> @class_body.static_defs\n\n node this__expr_def\n node @class.type\n\n edge @class.lexical_scope -> this__expr_def\n\n attr (this__expr_def) pop_symbol = \"this\", source_node = @name, empty_source_span\n edge this__expr_def -> @class.type\n\n attr (@class.type) pop_symbol = \":\"\n\n node def__typeof\n attr (def__typeof) pop_symbol = \":\"\n edge def -> def__typeof\n edge def__typeof -> @class_body.static_defs\n\n edge @class.type -> ref\n attr (@class.type -> ref) precedence = 1\n}\n\n(class_declaration\n superclass: (superclass\n (_) @superclass_name)\n body: (class_body) @class_body) @class {\n\n node ref\n attr (ref) node_reference = @superclass_name\n\n edge @superclass_name.lexical_scope -> @class.lexical_scope\n\n edge ref -> @class.lexical_scope\n edge @class_body.lexical_scope -> ref\n\n node super__expr_def\n node super__expr_def__typeof\n\n edge @class.lexical_scope -> super__expr_def\n\n attr (super__expr_def) pop_symbol = \"super\", source_node = @superclass_name, empty_source_span\n edge super__expr_def -> super__expr_def__typeof\n\n attr (super__expr_def__typeof) pop_symbol = \":\"\n\n edge super__expr_def__typeof -> ref\n edge @class.type -> ref\n}\n\n(class_declaration (type_parameters)) @class {\n node @class.type_parameters\n edge @class.lexical_scope -> @class.type_parameters\n}\n\n(class_declaration (type_parameters (type_parameter) @param)) @class {\n edge @class.type_parameters -> @param.def\n edge @param.lexical_scope -> @class.lexical_scope\n}\n\n(type_parameter (type_identifier) @name) @this {\n node @this.def\n node @this.lexical_scope\n\n edge @name.lexical_scope -> @this.lexical_scope\n\n attr (@this.def) node_definition = @name\n}\n\n(spread_parameter) @spread_param {\n node @spread_param.lexical_scope\n node @spread_param.def\n}\n\n(class_declaration interfaces: (super_interfaces (type_list (_) @type))) @this {\n edge @type.lexical_scope -> @this.lexical_scope\n}\n\n(class_body) @class_body {\n node @class_body.lexical_scope\n node @class_body.defs\n node @class_body.static_defs\n}\n\n(class_body (_)@declaration)@class_body {\n edge @class_body.defs -> @declaration.defs\n edge @class_body.static_defs -> @declaration.static_defs\n edge @declaration.lexical_scope -> @class_body.lexical_scope\n}\n\n(class_body (block) @block) {\n node @block.defs\n node @block.static_defs\n node @block.lexical_scope\n edge @block.lexical_scope -> @block.before_scope\n}\n\n;; =====================\n;; Member Declarations\n;; =====================\n\n; Member declarations can occur as members of classes, enums, etc. They propagate lexical scope and usually define one or more names, available in `defs`.\n\n[\n (class_declaration)\n (enum_declaration)\n (field_declaration)\n (interface_declaration)\n (method_declaration)\n (constructor_declaration)\n (annotation_type_declaration)\n (constant_declaration)\n (record_declaration)\n] @decl\n{\n ; FIXME: can we get away with defining one and only one thing for each of these, and therefore having a `.def` node instead of `.defs`?\n node @decl.defs\n node @decl.lexical_scope\n node @decl.static_defs\n}\n\n(annotation_type_declaration\n name: (identifier) @name) @annotation {\n\n node def\n attr (def) node_definition = @name\n edge def -> @annotation.lexical_scope\n edge @annotation.defs -> def\n}\n\n(constructor_declaration body: (constructor_body) @body) @this {\n edge @body.lexical_scope -> @this.lexical_scope\n}\n\n(constructor_body) @this {\n node @this.lexical_scope\n}\n\n(constructor_body . (_) @first) @this {\n edge @first.before_scope -> @this.lexical_scope\n}\n\n(constructor_body (_) @a . (_) @b) {\n edge @b.before_scope -> @a.after_scope\n}\n\n(explicit_constructor_invocation) @this {\n node @this.before_scope\n node @this.after_scope\n}\n\n(explicit_constructor_invocation constructor: (_) @constructor) @this {\n edge @constructor.lexical_scope -> @this.before_scope\n}\n\n(explicit_constructor_invocation object: (_) @object) @this {\n edge @object.lexical_scope -> @this.before_scope\n}\n\n(explicit_constructor_invocation arguments: (argument_list (_) @arg)) @this {\n edge @arg.lexical_scope -> @this.before_scope\n}\n\n(enum_declaration name: (_) @name) @this {\n node def\n attr (def) node_definition = @name\n edge @this.defs -> def\n\n node @this.constants\n attr (@this.constants) pop_symbol = \".\"\n edge def -> @this.constants\n\n ; allow A.X field accesses to resolve constants\n node def__typeof\n attr (def__typeof) pop_symbol = \":\"\n edge def -> def__typeof\n edge def__typeof -> @this.constants\n}\n\n(enum_declaration (enum_body (enum_constant name: (_) @name))) @this {\n node def\n attr (def) node_definition = @name\n edge @this.constants -> def\n}\n\n(field_declaration\n type: (_) @type\n declarator: (variable_declarator\n name: (_) @name\n )\n) @field_decl\n{\n edge @type.lexical_scope -> @field_decl.lexical_scope\n\n node member\n edge @field_decl.defs -> member\n\n attr (member) pop_symbol = \".\"\n\n node def\n attr (def) node_definition = @name\n edge member -> def\n\n node def__typeof\n attr (def__typeof) pop_symbol = \":\"\n edge def__typeof -> @type.type\n\n edge def -> def__typeof\n}\n\n(modifiers) @this {\n node @this.lexical_scope\n}\n\n(modifiers (_) @annotation) @this {\n edge @annotation.ref -> @this.lexical_scope\n}\n\n(marker_annotation name: (_) @name) @this {\n node @this.ref\n attr (@this.ref) node_reference = @name\n}\n\n(annotation name: (_) @name) @this {\n node @this.ref\n node @this.lexical_scope\n attr (@this.ref) node_reference = @name\n}\n\n(modifiers (annotation arguments: (annotation_argument_list (_) @value))) @this {\n edge @value.lexical_scope -> @this.lexical_scope\n}\n\n(element_value_array_initializer) @this {\n node @this.def\n node @this.lexical_scope\n}\n\n(element_value_pair value: (_) @value) @this {\n node @this.lexical_scope\n edge @value.lexical_scope -> @this.lexical_scope\n}\n\n(field_declaration (modifiers) @modifiers) @decl {\n edge @modifiers.lexical_scope -> @decl.lexical_scope\n}\n\n(interface_declaration name: (_) @name body: (_) @body) @this {\n node def\n attr (def) node_definition = @name\n edge @this.defs -> def\n\n edge def -> @body.defs\n edge @body.lexical_scope -> @this.lexical_scope\n}\n\n(interface_declaration (extends_interfaces (type_list (_) @type))) @this {\n edge @type.lexical_scope -> @this.lexical_scope\n}\n\n(interface_declaration\n type_parameters: (type_parameters\n (type_parameter\n (type_identifier) @type_identifier))\n body: (_) @body) @_this {\n node type_ident\n attr (type_ident) node_definition = @type_identifier\n edge @body.lexical_scope -> type_ident\n}\n\n(interface_body) @this {\n node @this.defs\n node @this.lexical_scope\n}\n\n(interface_body (_) @child) @this {\n edge @this.defs -> @child.defs\n edge @child.lexical_scope -> @this.lexical_scope\n}\n\n(method_declaration\n (modifiers \"static\"?@is_static)?\n type: (_) @type\n name: (identifier) @name\n body: (block) @_block) @method\n{\n edge @type.lexical_scope -> @method.lexical_scope\n\n node member\n\n if none @is_static {\n edge @method.defs -> member\n } else {\n edge @method.static_defs -> member\n }\n\n attr (member) pop_symbol = \".\"\n\n node def\n attr (def) node_definition = @name\n edge member -> def\n}\n\n(method_declaration (formal_parameters (_) @param)) @method\n{\n edge @param.lexical_scope -> @method.lexical_scope\n edge @method.lexical_scope -> @param.def\n edge @method.defs -> @param.def\n}\n\n(formal_parameter type: (_) @type (_) @name) @param\n{\n node @param.def\n node @param.lexical_scope\n node def__typeof\n\n edge @type.lexical_scope -> @param.lexical_scope\n\n attr (@param.def) node_definition = @name\n\n attr (def__typeof) pop_symbol = \":\"\n edge def__typeof -> @type.type\n\n edge @param.def -> def__typeof\n}\n\n(formal_parameter (modifiers) @modifiers) @this {\n edge @modifiers.lexical_scope -> @this.lexical_scope\n}\n\n(method_declaration\n (modifiers) @modifiers) @this {\n edge @modifiers.lexical_scope -> @this.lexical_scope\n}\n\n(method_declaration\n body: (_) @stmt) @method\n{\n edge @stmt.before_scope -> @method.lexical_scope\n}\n\n(record_declaration name: (_) @name body: (_) @body) @this {\n node def\n attr (def) node_definition = @name\n edge @this.defs -> def\n\n edge @body.lexical_scope -> @this.lexical_scope\n}\n\n(record_declaration parameters: (formal_parameters (_) @param)) @this {\n edge @param.lexical_scope -> @this.lexical_scope\n edge @this.lexical_scope -> @param.def\n edge @this.defs -> @param.def\n}\n\n;; ============\n;; Statements\n;; ============\n\n; Statements are sequenced one after the next, and some (local variable declarations) bring names into scope/shadow existing names for subsequent statements. Thus, instead of having a lexical scope, they have before and after scopes; the before scope points to the previous statement, or the parent scope for the first statement in a sequence, while the after scope points either at the before scope (if no variable is bound) or at a node referencing any variables the statement binds.\n\n[\n (assert_statement)\n (block)\n (break_statement)\n (continue_statement)\n (declaration)\n (do_statement)\n (expression_statement)\n (enhanced_for_statement)\n (for_statement)\n (if_statement)\n (labeled_statement)\n (local_variable_declaration)\n (return_statement)\n (switch_expression)\n (synchronized_statement)\n (throw_statement)\n (try_statement)\n (try_with_resources_statement)\n (while_statement)\n (yield_statement)\n] @stmt\n{\n node @stmt.before_scope\n node @stmt.after_scope\n}\n\n(assert_statement) @stmt {\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n(assert_statement (expression) @expr) @stmt {\n edge @expr.lexical_scope -> @stmt.before_scope\n}\n\n(block\n (_) @left\n .\n (_) @right\n)\n{\n edge @right.before_scope -> @left.after_scope\n}\n\n(block\n .\n (_) @first) @block {\n edge @first.before_scope -> @block.before_scope\n}\n\n(block\n (_) @last\n . ) @block {\n edge @block.after_scope -> @last.after_scope\n}\n\n(break_statement (identifier) @_name) @this {\n edge @this.after_scope -> @this.before_scope\n}\n\n(break_statement (identifier) @name) @stmt {\n node ref\n node ns\n\n attr (ref) node_reference = @name\n edge ref -> ns\n\n attr (ns) push_symbol = \"%Label\"\n\n edge ns -> @stmt.before_scope\n}\n\n(continue_statement) @this {\n edge @this.after_scope -> @this.before_scope\n}\n\n(continue_statement (identifier) @name) @this {\n node ref\n node ns\n\n attr (ref) node_reference = @name\n edge ref -> ns\n\n attr (ns) push_symbol = \"%Label\"\n\n edge ns -> @this.before_scope\n}\n\n(declaration) @_decl {}\n\n(do_statement body: (_) @body condition: (_) @cond) @stmt {\n edge @body.before_scope -> @stmt.before_scope\n edge @stmt.after_scope -> @stmt.before_scope\n edge @cond.lexical_scope -> @stmt.before_scope\n}\n\n(expression_statement (_) @expr) @expr_stmt\n{\n edge @expr.lexical_scope -> @expr_stmt.before_scope\n edge @expr_stmt.after_scope -> @expr_stmt.before_scope\n}\n\n(enhanced_for_statement type: (_) @type (_) @name value: (_) @value body: (_) @body) @stmt {\n edge @type.lexical_scope -> @stmt.before_scope\n edge @value.lexical_scope -> @stmt.before_scope\n node def\n node defs\n attr (def) node_definition = @name\n edge defs -> @stmt.before_scope\n edge defs -> def\n edge @body.before_scope -> defs\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n(for_statement) @this {\n edge @this.after_scope -> @this.before_scope\n}\n\n(for_statement !init !condition !update body: (_) @body) @this {\n edge @body.before_scope -> @this.before_scope\n}\n\n(for_statement init: (expression) @init condition: (_) @condition update: (_) @update body: (_) @body) @stmt {\n edge @init.lexical_scope -> @stmt.before_scope\n edge @condition.lexical_scope -> @stmt.before_scope\n edge @update.lexical_scope -> @stmt.before_scope\n edge @body.before_scope -> @stmt.before_scope\n}\n\n(for_statement init: (local_variable_declaration) @init condition: (_) @condition update: (_) @update body: (_) @body) @stmt {\n edge @init.before_scope -> @stmt.before_scope\n edge @condition.lexical_scope -> @init.after_scope\n edge @update.lexical_scope -> @init.after_scope\n edge @body.before_scope -> @init.after_scope\n}\n\n(if_statement condition: (_) @condition consequence: (_) @consequence) @stmt {\n edge @condition.lexical_scope -> @stmt.before_scope\n edge @consequence.before_scope -> @stmt.before_scope\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n(if_statement alternative: (_) @alternative) @stmt {\n edge @alternative.before_scope -> @stmt.before_scope\n}\n\n(labeled_statement (identifier) @name (statement) @child) @stmt {\n edge @child.before_scope -> @stmt.before_scope\n edge @stmt.after_scope -> @child.after_scope\n\n node def\n attr (def) node_definition = @name\n node ns\n attr (ns) pop_symbol = \"%Label\"\n edge ns -> def\n\n edge @stmt.before_scope -> ns\n}\n\n(local_variable_declaration\n type: (_) @type\n declarator: (variable_declarator) @var_decl\n) @_local_var\n{\n edge @var_decl.def__typeof -> @type.type\n}\n\n(local_variable_declaration\n type: (_) @type) @local_var {\n edge @type.lexical_scope -> @local_var.before_scope\n}\n\n(variable_declarator value: (_) @value) @this {\n edge @value.lexical_scope -> @this.before_scope\n}\n\n(local_variable_declaration\n declarator: (_) @last\n . ) @local_var {\n edge @local_var.after_scope -> @last.after_scope\n attr (@local_var.after_scope -> @last.after_scope) precedence = 1\n}\n\n(local_variable_declaration\n type: (_)\n .\n declarator: (_) @first) @local_var {\n edge @first.before_scope -> @local_var.before_scope\n}\n\n(local_variable_declaration\n declarator: (_) @left\n .\n declarator: (_) @right\n ) @_local_var {\n edge @right.before_scope -> @left.after_scope\n}\n\n(variable_declarator\n name: (_) @name) @var_decl {\n node @var_decl.before_scope\n node @var_decl.after_scope\n node @var_decl.def__typeof\n attr (@var_decl.def__typeof) pop_symbol = \":\"\n\n node def\n attr (def) node_definition = @name\n edge @var_decl.after_scope -> def\n edge @var_decl.after_scope -> @var_decl.before_scope\n\n edge def -> @var_decl.def__typeof\n}\n\n(return_statement (_) @expr) @stmt\n{\n edge @expr.lexical_scope -> @stmt.before_scope\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n(switch_expression condition: (_) @condition body: (_) @body) @stmt {\n edge @condition.lexical_scope -> @stmt.before_scope\n edge @body.lexical_scope -> @stmt.before_scope\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n(method_declaration\n parameters:\n (formal_parameters\n (formal_parameter\n type: (generic_type\n (type_arguments\n (type_identifier) @type))))\n body:\n (block\n (switch_expression\n condition: (_)\n body: (switch_block\n (switch_block_statement_group\n (switch_label\n (identifier))\n @label))\n )) @stmt) {\n\n node ident\n attr (ident) node_reference = @type\n\n node ref__typeof\n attr(ref__typeof) push_symbol = \".\"\n node implicit_this__typeof\n attr(implicit_this__typeof) push_symbol = \":\"\n\n edge implicit_this__typeof -> @label.lexical_scope\n edge @label.lexical_scope -> ref__typeof\n edge ref__typeof -> implicit_this__typeof\n edge implicit_this__typeof -> ident\n\n edge ident -> @stmt.after_scope\n}\n\n\n(switch_block) @this {\n node @this.lexical_scope\n}\n\n(switch_block (switch_block_statement_group (switch_label) @label)) @this {\n edge @label.lexical_scope -> @this.lexical_scope\n}\n\n(switch_block (switch_block_statement_group (switch_label)+ . (statement) @first)) @this {\n edge @first.before_scope -> @this.lexical_scope\n}\n\n(switch_block (switch_block_statement_group (switch_label)+ (statement) @a . (statement) @b)) @_this {\n edge @b.before_scope -> @a.after_scope\n}\n\n(switch_block (switch_rule (switch_label) @label (_) @body)) @this {\n edge @label.lexical_scope -> @this.lexical_scope\n edge @body.before_scope -> @this.lexical_scope\n}\n\n(switch_label) @label {\n node @label.lexical_scope\n}\n\n(switch_label (expression) @expr) @label {\n edge @expr.lexical_scope -> @label.lexical_scope\n}\n\n(synchronized_statement (_) @expr body: (_) @body) @stmt {\n edge @expr.lexical_scope -> @stmt.before_scope\n edge @body.before_scope -> @stmt.before_scope\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n(try_statement body: (_) @body) @stmt {\n edge @body.before_scope -> @stmt.before_scope\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n(try_statement (catch_clause (catch_formal_parameter (catch_type) @type (_) @name) body: (_) @body)) @stmt {\n node def\n node defs\n attr (def) node_definition = @name\n edge defs -> def\n edge @body.before_scope -> defs\n edge defs -> @stmt.before_scope\n\n edge @type.lexical_scope -> @stmt.before_scope\n\n node def__typeof\n attr (def__typeof) pop_symbol = \":\"\n\n edge def -> def__typeof\n\n edge def__typeof -> @type.type\n}\n\n(catch_type) @catch_type {\n node @catch_type.type\n node @catch_type.lexical_scope\n}\n\n(catch_type (_) @type) @catch_type {\n edge @catch_type.type -> @type.type\n edge @type.lexical_scope -> @catch_type.lexical_scope\n}\n\n(try_statement (finally_clause (_) @finally)) @stmt {\n edge @finally.before_scope -> @stmt.before_scope\n}\n\n(try_with_resources_statement) @stmt {\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n(try_with_resources_statement resources: (resource_specification . (resource) @first)) @stmt {\n edge @first.before_scope -> @stmt.before_scope\n}\n\n(try_with_resources_statement resources: (resource_specification (resource) @a . (resource) @b)) @_stmt {\n edge @b.before_scope -> @a.after_scope\n}\n\n(try_with_resources_statement resources: (resource_specification (resource) @last .) body: (_) @body) @_stmt {\n edge @body.before_scope -> @last.after_scope\n}\n\n(resource) @this {\n node @this.before_scope\n node @this.after_scope\n}\n\n(resource type: (_) @type (_) @name value: (_) @value) @this {\n edge @type.lexical_scope -> @this.before_scope\n edge @value.lexical_scope -> @this.before_scope\n\n node def\n attr (def) node_definition = @name\n\n node def__typeof\n attr (def__typeof) pop_symbol = \":\"\n\n edge def -> def__typeof\n\n edge def__typeof -> @type.type\n\n edge @this.after_scope -> def\n edge @this.after_scope -> @this.before_scope\n}\n\n(resource . (identifier) @name .) @this {\n node ref\n node ref__typeof\n\n attr (ref) node_reference = @name\n\n edge ref -> @name.lexical_scope\n edge @name.lexical_scope -> @this.before_scope\n\n edge @name.type -> ref__typeof\n\n attr (ref__typeof) push_symbol = \":\"\n edge ref__typeof -> ref\n\n edge @this.after_scope -> @this.before_scope\n}\n\n(resource (field_access) @field_access) @this {\n edge @field_access.lexical_scope -> @this.before_scope\n edge @this.after_scope -> @this.before_scope\n}\n\n(try_with_resources_statement (catch_clause (catch_formal_parameter (catch_type) @type (_) @name) body: (_) @body)) @stmt {\n node def\n node defs\n attr (def) node_definition = @name\n edge defs -> def\n edge @body.before_scope -> defs\n edge defs -> @stmt.before_scope\n\n edge @type.lexical_scope -> @stmt.before_scope\n\n node def__typeof\n attr (def__typeof) pop_symbol = \":\"\n\n edge def -> def__typeof\n\n edge def__typeof -> @type.type\n}\n\n(try_with_resources_statement (finally_clause (_) @finally)) @stmt {\n edge @finally.before_scope -> @stmt.before_scope\n}\n\n(while_statement condition: (_) @condition body: (_) @body) @stmt {\n edge @condition.lexical_scope -> @stmt.before_scope\n edge @body.before_scope -> @stmt.before_scope\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n(yield_statement (_) @expr) @stmt {\n edge @expr.lexical_scope -> @stmt.before_scope\n edge @stmt.after_scope -> @stmt.before_scope\n}\n\n;; =====================\n;; Primary Expressions\n;; =====================\n\n(array_access (primary_expression) @array (expression) @index) @this {\n edge @array.lexical_scope -> @this.lexical_scope\n edge @index.lexical_scope -> @this.lexical_scope\n}\n\n(array_creation_expression type: (_) @type) @this {\n edge @type.lexical_scope -> @this.lexical_scope\n}\n\n(array_creation_expression (dimensions_expr (_) @expr)) @this {\n edge @expr.lexical_scope -> @this.lexical_scope\n}\n\n(array_initializer (_) @expr) @this {\n edge @expr.lexical_scope -> @this.lexical_scope\n}\n\n(class_literal (_) @type) @this {\n edge @type.lexical_scope -> @this.lexical_scope\n}\n\n(primary_expression/identifier) @name\n{\n node member\n node implicit_this\n node implicit_this__typeof\n\n node object__typeof\n\n attr (implicit_this) symbol_reference = \"this\", empty_source_span\n edge implicit_this__typeof -> implicit_this\n attr (implicit_this__typeof) push_symbol = \":\"\n edge implicit_this -> @name.lexical_scope\n\n node ref\n attr (ref) node_reference = @name\n edge ref -> @name.lexical_scope\n attr (ref -> @name.lexical_scope) precedence = 1\n edge ref -> member\n\n attr (member) push_symbol = \".\"\n\n edge member -> object__typeof\n edge object__typeof -> implicit_this__typeof\n\n node ref__typeof\n edge @name.type -> ref__typeof\n\n attr (ref__typeof) push_symbol = \":\"\n edge ref__typeof -> ref\n}\n\n(field_access\n object: (_) @object\n field: (identifier) @name) @field_access {\n node member\n\n edge @object.lexical_scope -> @field_access.lexical_scope\n\n node ref\n attr (ref) node_reference = @name\n edge ref -> member\n\n attr (member) push_symbol = \".\"\n edge member -> @object.type\n\n node ref__typeof\n edge @field_access.type -> ref__typeof\n\n attr (ref__typeof) push_symbol = \":\"\n edge ref__typeof -> ref\n}\n\n(method_invocation) @method_invocation\n{\n node @method_invocation.before_scope\n node @method_invocation.after_scope\n}\n\n(method_invocation arguments: (argument_list (expression) @expr)) @method_invocation {\n edge @expr.lexical_scope -> @method_invocation.lexical_scope\n}\n\n; method calls with implicit receiver\n(method_invocation\n !object\n name: (identifier) @method_name) @method_invocation {\n node member\n node implicit_this\n node implicit_this__typeof\n\n node object__typeof\n\n ; attr (implicit_this) node_reference = @method_invocation\n attr (implicit_this) symbol_reference = \"this\", empty_source_span\n\n ; receiver is implicitly \"this\"\n edge implicit_this__typeof -> implicit_this\n attr (implicit_this__typeof) push_symbol = \":\"\n edge implicit_this -> @method_invocation.lexical_scope\n\n node expr_ref\n attr (expr_ref) node_reference = @method_name\n edge expr_ref -> member\n\n attr (member) push_symbol = \".\"\n\n edge member -> object__typeof\n edge object__typeof -> implicit_this__typeof\n\n node expr_ref__typeof\n edge @method_invocation.type -> expr_ref__typeof\n\n attr (expr_ref__typeof) push_symbol = \":\"\n edge expr_ref__typeof -> expr_ref\n}\n\n(method_reference . (_) @lhs) @this {\n edge @lhs.lexical_scope -> @this.lexical_scope\n}\n\n(method_reference . (_) @lhs (identifier) @name) @this {\n node @this.member\n\n node expr_ref\n attr (expr_ref) node_reference = @name\n edge expr_ref -> @this.member\n\n attr (@this.member) push_symbol = \".\"\n edge @this.member -> @lhs.type\n\n node expr_ref__typeof\n ; edge @this.type -> expr_ref__typeof ; FIXME: function types\n\n attr (expr_ref__typeof) push_symbol = \":\"\n edge expr_ref__typeof -> expr_ref\n}\n\n(method_reference . (identifier) @lhs (identifier) @_name) @this {\n ; @lhs could be a type name\n node ref\n attr (ref) node_reference = @lhs\n edge @this.member -> ref\n edge ref -> @this.lexical_scope\n}\n\n(parenthesized_expression (_) @child) @expr {\n edge @child.lexical_scope -> @expr.lexical_scope\n}\n\n;; =============\n;; Expressions\n;; =============\n\n; Expressions have a lexical scope (propagated to child expressions) and a type. The lexical scope is used for lexical name lookup, while types enable type-based name lookup (for field accesses, method lookup, and so forth).\n\n[\n (array_initializer)\n (assignment_expression)\n (binary_expression)\n (instanceof_expression)\n (lambda_expression)\n (ternary_expression)\n (update_expression)\n (decimal_integer_literal)\n (hex_integer_literal)\n (octal_integer_literal)\n (binary_integer_literal)\n (decimal_floating_point_literal)\n (hex_floating_point_literal)\n (true)\n (false)\n (character_literal)\n (string_literal)\n (null_literal)\n (class_literal)\n (this)\n ; (identifier)\n (parenthesized_expression)\n (object_creation_expression)\n (field_access)\n (array_access)\n (method_invocation)\n (method_reference)\n (array_creation_expression)\n (unary_expression)\n (cast_expression)\n (switch_expression)\n (super)\n] @expr\n{\n node @expr.type\n node @expr.lexical_scope\n}\n\n(assignment_expression left: (identifier) @name) @this {\n node member\n node implicit_this\n node implicit_this__typeof\n\n node object__typeof\n\n attr (implicit_this) symbol_reference = \"this\", empty_source_span\n edge implicit_this__typeof -> implicit_this\n attr (implicit_this__typeof) push_symbol = \":\"\n edge implicit_this -> @name.lexical_scope\n\n node ref\n attr (ref) node_reference = @name\n edge ref -> @name.lexical_scope\n attr (ref -> @name.lexical_scope) precedence = 1\n edge ref -> member\n\n attr (member) push_symbol = \".\"\n\n edge member -> object__typeof\n edge object__typeof -> implicit_this__typeof\n\n node ref__typeof\n edge @name.type -> ref__typeof\n\n attr (ref__typeof) push_symbol = \":\"\n edge ref__typeof -> ref\n\n edge @name.lexical_scope -> @this.lexical_scope\n}\n\n(assignment_expression left: (field_access) @access) @this {\n edge @access.lexical_scope -> @this.lexical_scope\n}\n\n(assignment_expression right: (_) @right) @this {\n edge @right.lexical_scope -> @this.lexical_scope\n}\n\n(binary_expression left: (_) @lhs right: (_) @rhs) @this {\n edge @lhs.lexical_scope -> @this.lexical_scope\n edge @rhs.lexical_scope -> @this.lexical_scope\n}\n\n(cast_expression type: (_) @type) @this {\n edge @type.lexical_scope -> @this.lexical_scope\n}\n\n(cast_expression value: (_) @expr) @this {\n edge @expr.lexical_scope -> @this.lexical_scope\n}\n\n(instanceof_expression left: (_) @expr right: (_) @type) @this {\n edge @expr.lexical_scope -> @this.lexical_scope\n edge @type.lexical_scope -> @this.lexical_scope\n}\n\n(lambda_expression) @this {\n node @this.params\n}\n\n(lambda_expression body: (expression) @body) @this {\n edge @body.lexical_scope -> @this.lexical_scope\n edge @body.lexical_scope -> @this.params\n}\n\n(lambda_expression body: (block) @body) @this {\n edge @body.before_scope -> @this.lexical_scope\n edge @body.before_scope -> @this.params\n}\n\n(lambda_expression parameters: (_) @param) @this {\n node param\n attr (param) node_definition = @param\n\n edge @this.params -> param\n}\n\n[\n (super)\n (this)\n] @expr\n{\n node expr_ref\n node expr_ref__typeof\n\n attr (expr_ref) node_reference = @expr\n edge expr_ref -> @expr.lexical_scope\n\n edge @expr.type -> expr_ref__typeof\n\n attr (expr_ref__typeof) push_symbol = \":\"\n edge expr_ref__typeof -> expr_ref\n}\n\n(method_invocation\n object: (_) @object\n name: (identifier) @method_name) @method_invocation {\n node member\n\n edge @object.lexical_scope -> @method_invocation.lexical_scope\n\n node expr_ref\n attr (expr_ref) node_reference = @method_name\n edge expr_ref -> member\n\n attr (member) push_symbol = \".\"\n edge member -> @object.type\n\n node expr_ref__typeof\n edge @method_invocation.type -> expr_ref__typeof\n\n attr (expr_ref__typeof) push_symbol = \":\"\n edge expr_ref__typeof -> expr_ref\n}\n\n(object_creation_expression (primary_expression) @child) @this {\n edge @child.lexical_scope -> @this.lexical_scope\n}\n\n(object_creation_expression type_arguments: (type_arguments (_) @type)) @this {\n edge @type.lexical_scope -> @this.lexical_scope\n}\n\n(object_creation_expression type: (_) @type) @this {\n edge @type.lexical_scope -> @this.lexical_scope\n}\n\n(object_creation_expression arguments: (argument_list (expression) @expr)) @this {\n edge @expr.lexical_scope -> @this.lexical_scope\n}\n\n(ternary_expression (expression) @expr) @this {\n edge @expr.lexical_scope -> @this.lexical_scope\n}\n\n(unary_expression (expression) @expr) @this {\n edge @expr.lexical_scope -> @this.lexical_scope\n}\n\n(update_expression (expression) @expr) @this {\n edge @expr.lexical_scope -> @this.lexical_scope\n}\n\n;; ==========\n;; Types\n;; ==========\n\n; Types have a lexical scope for type name lookup.\n\n[\n (annotated_type)\n (array_type)\n (boolean_type)\n (floating_point_type)\n (generic_type)\n (integral_type)\n (scoped_type_identifier)\n (type_identifier)\n (void_type)\n] @type\n{\n node @type.lexical_scope\n node @type.type ; FIXME: is this actually needed?\n}\n\n[\n (boolean_type)\n (floating_point_type)\n (integral_type)\n (type_identifier)\n (void_type)\n] @type\n{\n attr (@type.type) node_reference = @type\n}\n\n(array_type element: (_) @child) @this {\n edge @child.lexical_scope -> @this.lexical_scope\n ; FIXME: use some sort of subscripting relation for .type\n}\n\n(generic_type . (_) @name) @this {\n edge @name.lexical_scope -> @this.lexical_scope\n}\n\n(generic_type (type_arguments (_) @type)) @this {\n edge @type.lexical_scope -> @this.lexical_scope\n}\n\n(scoped_type_identifier . (_) @name) @this {\n edge @name.lexical_scope -> @this.lexical_scope\n}\n\n(wildcard) @this\n{\n node @this.lexical_scope\n}\n\n(type_identifier) @this\n{\n edge @this.type -> @this.lexical_scope\n}\n\n(scoped_type_identifier\n (type_identifier) @imported_class_name (type_identifier) @method_name) {\n\n node member\n attr (member) push_symbol = \".\"\n\n edge @method_name.type -> member\n edge member -> @imported_class_name.type\n}\n\n;; ==========\n;; Comments\n;; ==========\n\n(line_comment)@line_comment {\n node @line_comment.before_scope\n node @line_comment.after_scope\n node @line_comment.lexical_defs\n node @line_comment.lexical_scope\n node @line_comment.defs\n node @line_comment.ref\n node @line_comment.static_defs\n\n edge @line_comment.after_scope -> @line_comment.before_scope\n}\n\n(block_comment)@block_comment {\n node @block_comment.before_scope\n node @block_comment.after_scope\n node @block_comment.defs\n node @block_comment.ref\n node @block_comment.static_defs\n node @block_comment.lexical_scope\n\n edge @block_comment.after_scope -> @block_comment.before_scope\n}\n";
Expand description
The stack graphs tsg source for this language.