├── .github ├── CODEOWNERS └── workflows │ ├── ci.yml │ ├── perf.yml │ ├── publish-lsp-positions.yml │ ├── publish-stack-graphs.yml │ ├── publish-tree-sitter-stack-graphs-java.yml │ ├── publish-tree-sitter-stack-graphs-javascript.yml │ ├── publish-tree-sitter-stack-graphs-python.yml │ ├── publish-tree-sitter-stack-graphs-typescript.yml │ └── publish-tree-sitter-stack-graphs.yml ├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── .zenodo.json ├── AUTHORS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── SECURITY.md ├── data ├── typescript_benchmark.md ├── typescript_benchmark.zip └── typescript_minimal_project.zip ├── languages ├── README.md ├── tree-sitter-stack-graphs-java │ ├── .gitignore │ ├── CHANGELOG.md │ ├── Cargo.toml │ ├── README.md │ ├── rust │ │ ├── bin.rs │ │ ├── lib.rs │ │ └── test.rs │ ├── src │ │ ├── builtins.cfg │ │ ├── builtins.java │ │ └── stack-graphs.tsg │ └── test │ │ ├── decl │ │ ├── annotation_type_body.java │ │ ├── class_extension.java │ │ ├── class_parameters.java │ │ ├── collection_import.java │ │ ├── duplicate_type_identifier.java │ │ ├── enum.java │ │ ├── enum_switches.java │ │ ├── field_declaration.java │ │ ├── field_modifiers.java │ │ ├── import_statement.java │ │ ├── interface.java │ │ ├── method_arguments.java │ │ ├── method_overriding.java │ │ ├── method_return.java │ │ ├── record.java │ │ ├── super_variable_declaration.java │ │ └── type_identifier.java │ │ ├── expression │ │ ├── array_access.java │ │ ├── array_creation.java │ │ ├── assignment.java │ │ ├── binary.java │ │ ├── cast.java │ │ ├── class_literal.java │ │ ├── instanceof.java │ │ ├── lambda.java │ │ ├── method_call.java │ │ ├── method_reference.java │ │ ├── object_creation_expression.java │ │ ├── ternary.java │ │ ├── unary.java │ │ └── update.java │ │ ├── imports_and_exports │ │ ├── import_method.java │ │ ├── imports.java │ │ ├── no_package.java │ │ ├── no_package_method.java │ │ └── no_package_not_leaking_method.java │ │ ├── statement │ │ ├── assert_statement.java │ │ ├── break.java │ │ ├── continue.java │ │ ├── do_statement.java │ │ ├── enhanced_for_statement.java │ │ ├── for_statement.java │ │ ├── getter_method.java │ │ ├── if_statement.java │ │ ├── labeled_statement.java │ │ ├── return_statement.java │ │ ├── switch_expression.java │ │ ├── synchronized_statement.java │ │ ├── try_statement.java │ │ ├── try_with_resources_statement.java │ │ ├── while_statement.java │ │ └── yield_statement.java │ │ ├── type │ │ ├── array.java │ │ ├── generic.java │ │ └── named.java │ │ └── variable_declaration.java ├── tree-sitter-stack-graphs-javascript │ ├── .gitignore │ ├── CHANGELOG.md │ ├── Cargo.toml │ ├── README.md │ ├── docs │ │ ├── package-structure.md │ │ └── package-structure │ │ │ ├── example.js │ │ │ └── example.png │ ├── rust │ │ ├── bin.rs │ │ ├── lib.rs │ │ ├── npm_package.rs │ │ ├── test.rs │ │ └── util.rs │ ├── src │ │ ├── builtins.cfg │ │ ├── builtins.js │ │ └── stack-graphs.tsg │ └── test │ │ ├── base_syntax.js │ │ ├── computation_flow │ │ ├── array_index_flow.js │ │ ├── assignment_destructuring_array_pattern.js │ │ ├── assignment_destructuring_object_pattern.js │ │ ├── class_declaration_constructor_field.js │ │ ├── class_declaration_field_definitions.js │ │ ├── class_declaration_fields_and_methods_not_visible_outside_class.js │ │ ├── class_declaration_fields_and_methods_visible_in_other_methods.js │ │ ├── class_declaration_method_call_argument_flow.js │ │ ├── class_declaration_method_call_arguments_variable_flow.js │ │ ├── class_declaration_method_call_closure_flow.js │ │ ├── class_declaration_method_call_constant_flow.js │ │ ├── class_declaration_methods_visible_on_instances.js │ │ ├── class_declaration_super_reference_to_method.js.skip │ │ ├── class_declaration_superclass_field_definition.js │ │ ├── class_declaration_superclass_methods_visible_on_instances.js │ │ ├── class_declaration_this_field_and_method.js.skip │ │ ├── class_expression_constructor_field.js │ │ ├── class_expression_field_definition.js │ │ ├── class_expression_fields_and_methods_not_visible_outside_class.js │ │ ├── class_expression_method_call_argument_flow.js │ │ ├── class_expression_method_call_arguments_variable_flow.js │ │ ├── class_expression_method_call_closure_flow.js │ │ ├── class_expression_method_call_constant_flow.js │ │ ├── class_expression_methods_visible_on_instances.js │ │ ├── class_expression_super_reference_to_method.js.skip │ │ ├── class_expression_superclass_field_definition.js │ │ ├── class_expression_superclass_methods_visible_on_instances.js │ │ ├── class_expression_this_field_and_method.js.skip │ │ ├── function_call_argument_flow.js │ │ ├── function_call_arguments_variable_flow.js │ │ ├── function_call_closure_flow.js │ │ ├── function_call_constant_flow.js │ │ ├── function_call_this_flow.js.skip │ │ ├── function_call_this_keyword_flow.js │ │ ├── function_closure_mutation.js │ │ ├── member_object_flow.js │ │ ├── object_computed_property_name_flow.js │ │ ├── object_shorthand_property_identifier_flow.js │ │ ├── subscript_array_flow.js │ │ ├── subscript_object_flow.js │ │ ├── with_statement_binding_flow.js │ │ └── with_statement_scope_shadowing_flow.js │ │ ├── expressions │ │ ├── array.js │ │ ├── arrow_function.js │ │ ├── assignment_expression.js │ │ ├── augmented_assignment_expression.js │ │ ├── await.js │ │ ├── binary_expression.js │ │ ├── booleans.js │ │ ├── call_expression.js │ │ ├── class.js │ │ ├── comma.js │ │ ├── function.js │ │ ├── generator_function.js │ │ ├── member_expression.js │ │ ├── new_expression.js │ │ ├── null.js │ │ ├── number.js │ │ ├── object.js │ │ ├── parenthesized_expression.js │ │ ├── regex.js │ │ ├── string.js │ │ ├── subscript_expression.js │ │ ├── super.js │ │ ├── template_strings.js │ │ ├── ternary_expression.js │ │ ├── this.js │ │ ├── unary_expression.js │ │ ├── undefined.js │ │ ├── update_expression.js │ │ ├── variable.js │ │ └── yield_expression.js │ │ ├── jsx │ │ ├── jsx_core.js │ │ ├── jsx_fragment.js │ │ ├── jsx_namespace_name.js │ │ ├── jsx_self_closing_element.js │ │ └── jsx_text.js │ │ ├── old │ │ ├── binding │ │ │ ├── default_arguments_from_enclosing_scope.js │ │ │ ├── default_arguments_from_other_arguments.js │ │ │ ├── destructuring_assignments.js │ │ │ ├── destructuring_assignments_with_defaults_from_enclosing_scope.js │ │ │ ├── destructuring_assignments_with_defaults_from_other_variables.js │ │ │ ├── destructuring_parameters.js │ │ │ └── object_assignment_patterns.js │ │ ├── bug_regressions │ │ │ ├── 2141.js │ │ │ ├── 2227.js │ │ │ ├── 2291.js │ │ │ ├── CommonJS_default_export_with_ES6_default_import.js │ │ │ ├── CommonJS_default_import_of_functions.js │ │ │ ├── CommonJS_imports_and_exports_using_defaults │ │ │ │ ├── export_with_name_default_alias_default.js │ │ │ │ ├── export_with_name_default_alias_nondefault.js │ │ │ │ ├── export_with_name_nondefault_alias_default.js │ │ │ │ └── import_with_name_default_alias_nondefault.js │ │ │ ├── ES6_imports_and_exports_using_the_name_or_alias_default │ │ │ │ ├── export_function_with_name_default_alias_default.js │ │ │ │ ├── export_with_name_default_alias_default.js │ │ │ │ ├── export_with_name_default_alias_nondefault.js │ │ │ │ ├── export_with_name_nondefault_alias_default.js │ │ │ │ ├── export_with_unaliased_name_default.js │ │ │ │ └── import_with_name_default_alias_nondefault.js │ │ │ ├── array_assignment_interrupts_scope.js │ │ │ ├── if_statement_path_blowup.js │ │ │ ├── string_property_interrupts_scope.js │ │ │ ├── ternary_expression_path_blowup.js │ │ │ └── variable_resolves_to_module.js │ │ ├── classes_and_instances │ │ │ ├── class_declaration.js │ │ │ ├── class_expression.js │ │ │ ├── class_expression_superclasses.js │ │ │ ├── class_expression_this_field_access.js │ │ │ ├── field_declaration.js │ │ │ ├── function_class_this_field_access.js │ │ │ ├── method_call_this_argument.js │ │ │ ├── method_definition.js │ │ │ ├── superclasses.js │ │ │ └── this_field_access.js │ │ ├── compound_literals │ │ │ ├── arrays.js │ │ │ ├── object_extend_method.js │ │ │ └── objects.js │ │ ├── control_flow_statements │ │ │ ├── dowhile.js │ │ │ ├── for.js │ │ │ ├── forin.js │ │ │ ├── if.js │ │ │ ├── try.js │ │ │ ├── while.js │ │ │ └── with.js │ │ ├── functions_and_calls │ │ │ ├── arguments_variable.js │ │ │ ├── arrow_function_values_with_param_lists_and_block_bodies.js │ │ │ ├── arrow_function_values_with_param_lists_and_expr_bodies.js │ │ │ ├── arrow_function_values_with_single_param_and_block_bodies.js │ │ │ ├── arrow_function_values_with_single_param_and_expr_bodies.js │ │ │ ├── call_arguments.js │ │ │ ├── function_declarations.js │ │ │ ├── function_values.js │ │ │ ├── generator_function_declarations.js │ │ │ └── generator_function_values.js │ │ ├── hoisting │ │ │ ├── basic_functions.js │ │ │ ├── functions_in_subscopes.js │ │ │ └── imports.js │ │ ├── imports_and_exports │ │ │ ├── CommonJS_import_ES6_export │ │ │ │ ├── export_with_name_default.js │ │ │ │ ├── export_with_name_nondefault.js │ │ │ │ ├── field_on_default_object_import_of_exported_default_object.js │ │ │ │ ├── field_on_default_object_import_of_exported_nondefault_name.js │ │ │ │ ├── import_with_name_default_alias_nondefault.js │ │ │ │ ├── reexport_with_name_default_alias_default.js │ │ │ │ ├── reexport_with_name_default_alias_nondefault.js │ │ │ │ ├── reexport_with_name_nondefault_alias_default.js │ │ │ │ ├── reexport_with_name_nondefault_alias_nondefault.js │ │ │ │ └── reexport_with_unaliased_name.js │ │ │ ├── CommonJS_import_export │ │ │ │ ├── field_on_default_object_import_of_exported_default_object.js │ │ │ │ ├── field_on_default_object_import_of_exported_default_object_field.js │ │ │ │ └── field_on_default_object_import_of_exported_nondefault_name.js │ │ │ ├── ES6_import_CommonJS_export │ │ │ │ ├── export_with_name_default.js │ │ │ │ ├── export_with_name_nondefault.js │ │ │ │ ├── field_on_default_object_import_of_exported_default_object.js │ │ │ │ ├── field_on_default_object_import_of_exported_default_object_field.js │ │ │ │ ├── field_on_default_object_import_of_exported_nondefault_name.js │ │ │ │ ├── import_with_name_default_alias_nondefault.js │ │ │ │ ├── reexport_with_name_default_alias_default.js │ │ │ │ ├── reexport_with_name_default_alias_nondefault.js │ │ │ │ ├── reexport_with_name_nondefault_alias_default.js │ │ │ │ ├── reexport_with_name_nondefault_alias_nondefault.js │ │ │ │ └── reexport_with_unaliased_name.js │ │ │ ├── ES6_import_export │ │ │ │ ├── field_on_default_object_import_of_exported_default_object.js │ │ │ │ └── field_on_default_object_import_of_exported_nondefault_name.js │ │ │ ├── commonjs_imports_and_exports.js │ │ │ ├── es6_imports_and_exports.js │ │ │ ├── import_function.js │ │ │ └── variable_visible_through_nonbinding_import.js │ │ ├── packages │ │ │ ├── can-access-package-non-main-explicilty.js │ │ │ ├── package-does-not-export-non-main.js │ │ │ ├── package-exports-explicit-main.js │ │ │ └── package-main-defaults-to-index.js │ │ └── simple_expressions │ │ │ ├── comma.js │ │ │ ├── template_strings.js │ │ │ ├── ternary.js │ │ │ └── variables.js │ │ ├── patterns │ │ ├── array_pattern.js │ │ ├── assignment_pattern.js │ │ ├── function_declaration_formal_parameter_patterns.js │ │ ├── method_declaration_formal_parameter_patterns.js │ │ └── object_pattern.js │ │ └── statements │ │ ├── class_declaration.js │ │ ├── debugger_statement.js │ │ ├── do_statement.js │ │ ├── empty_statement.js │ │ ├── export_statement.js │ │ ├── for_in_statement.js │ │ ├── for_statement.js │ │ ├── function_declaration.js │ │ ├── generator_function_declaration.js │ │ ├── hash_bang_line.js │ │ ├── if_statement.js │ │ ├── import_statement.js │ │ ├── label_continue_break_statements.js │ │ ├── label_statement.js │ │ ├── lexical_declaration_basic_no_destructuring.js │ │ ├── return_statement.js │ │ ├── statement_block.js │ │ ├── switch_statement.js │ │ ├── throw_statement.js │ │ ├── try_statement.js │ │ ├── variable_declaration_basic_no_destructuring.js │ │ ├── while_statement.js │ │ └── with_statement.js ├── tree-sitter-stack-graphs-python │ ├── .gitignore │ ├── CHANGELOG.md │ ├── Cargo.toml │ ├── README.md │ ├── rust │ │ ├── bin.rs │ │ ├── lib.rs │ │ └── test.rs │ ├── src │ │ ├── builtins.cfg │ │ ├── builtins.py │ │ ├── stack-graphs.scm │ │ └── stack-graphs.tsg │ └── test │ │ ├── aliased_imports.py │ │ ├── attributes.py │ │ ├── blocks.py │ │ ├── chained_functions.py │ │ ├── chained_methods.py.skip │ │ ├── class_members.py │ │ ├── decorators.py │ │ ├── exceptions.py │ │ ├── functions.py │ │ ├── imported_functions.py │ │ ├── imports.py │ │ ├── imports │ │ ├── import_from_module_a_submodule.py │ │ ├── import_from_module_a_value.py │ │ ├── import_from_module_a_value_aliased.py │ │ ├── import_from_module_wildcard.py │ │ ├── import_from_submodule_a_value.py │ │ ├── import_from_super_package_a_value.py │ │ ├── import_from_super_package_submodule_a_value.py │ │ ├── import_from_this_package_a_value.py │ │ ├── import_from_this_package_submodule_a_value.py │ │ ├── import_module.py │ │ ├── import_module_aliased.py │ │ ├── import_submodule.py │ │ ├── import_submodule_aliased.py │ │ ├── relative_import_resolves_to_itself.py.skip │ │ └── require_explicit_submodule_import.py.skip │ │ ├── instance_members.py │ │ ├── lambdas.py │ │ ├── loops.py │ │ ├── many_definitions.py │ │ ├── nested_functions.py │ │ ├── not_a_method.py │ │ ├── pattern_matching.py │ │ ├── redundant_reexport.py │ │ ├── relative_imports.py │ │ ├── root_path.py │ │ ├── self.py │ │ ├── statement_bindings.py │ │ ├── superclasses.py │ │ ├── test.py │ │ ├── tuples.py │ │ └── wildcard_import.py └── tree-sitter-stack-graphs-typescript │ ├── .gitignore │ ├── CHANGELOG.md │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── rust │ ├── bin.rs │ ├── lib.rs │ ├── npm_package.rs │ ├── test.rs │ ├── tsconfig.rs │ └── util.rs │ ├── src │ ├── builtins.cfg │ ├── builtins.ts │ └── stack-graphs.tsg │ ├── test │ ├── base │ │ ├── cannot-resolve-field-in-shadowed-object.ts.skip │ │ ├── for-var-scoped-in-file-and-visible-inside-function.ts │ │ ├── for-var-scoped-in-function.ts │ │ ├── mutually-recursive-functions.ts │ │ ├── nested-for-var-scoped-in-function.ts │ │ ├── var-reference-before-def.ts │ │ └── var-scoped-in-function.ts │ ├── builtins │ │ ├── async-arrow-function.ts │ │ ├── async-function-definition.ts │ │ ├── async-function-expression.ts │ │ ├── async-function-inferred-return-type-not-directly-accessible.ts │ │ ├── async-method-with-inferred-return-type.ts │ │ ├── await-async-function-with-inferred-return-type.ts │ │ ├── await-function-with-explicit-return-type.ts │ │ ├── await-variable.ts │ │ ├── builtin-Array-type.ts │ │ ├── builtin-Map-type.ts │ │ └── builtin-Set-type.ts │ ├── expressions │ │ ├── access-property-in-abstract-super-class.ts │ │ ├── arrow-function.ts │ │ ├── asserts-condition.ts │ │ ├── asserts-type.ts │ │ ├── call-class-abstract-super-class-method.ts │ │ ├── call-class-super-interface-method.ts │ │ ├── call-declared-function.ts │ │ ├── call-function-literal.ts │ │ ├── call-function-type.ts │ │ ├── call-generic-function-signature.ts │ │ ├── call-generic-function-type.ts │ │ ├── call-generic-function-with-concrete-return-type-without-type-arguments.ts │ │ ├── call-generic-function-with-default-without-type-arguments.ts │ │ ├── call-generic-function.ts │ │ ├── call-interface-generic-function.ts │ │ ├── call-interface-method.ts │ │ ├── call-interface-super-interface-method.ts │ │ ├── call-let-bound-function-literal.ts │ │ ├── call-object-function-property.ts │ │ ├── call-object-method.ts │ │ ├── call-object-overloaded-method.ts │ │ ├── call-object-with-call-signature.ts │ │ ├── call-with-template-string.ts │ │ ├── index-getter-property.ts │ │ ├── index-into-array.ts │ │ ├── index-into-object-with-index-signature.ts │ │ ├── index-named-property.ts │ │ ├── index-on-variable.ts │ │ ├── index-setter-property.ts │ │ ├── new-from-construct-signature.ts │ │ ├── new-on-aliased-class-object.ts │ │ ├── new-on-expr-with-constructor-type.ts │ │ ├── new-target-property.ts │ │ ├── object-literal-type.ts │ │ ├── rest-array-attern.ts │ │ ├── satisfies-type.ts │ │ └── undefined-pattern.ts │ ├── jsx │ │ ├── jsx_core.tsx │ │ ├── jsx_fragment.tsx │ │ ├── jsx_namespace_name.tsx │ │ ├── jsx_self_closing_element.tsx │ │ └── jsx_text.tsx │ ├── modules │ │ ├── default-export-declaration-is-locally-visible.ts │ │ ├── default-exported-declaration-is-not-a-named-export.ts │ │ ├── export-as-namespace.ts │ │ ├── import-as-namespace.ts │ │ ├── import-default-class-definition-type-and-expression.ts │ │ ├── import-default-class-reference-type-and-expression.ts │ │ ├── import-default-enum-reference-type-and-expression.ts │ │ ├── import-default-expression.ts │ │ ├── import-default-interface.ts │ │ ├── import-default-type.ts │ │ ├── import-directly-exported-variable.ts │ │ ├── import-exports-class.ts │ │ ├── import-exports-object.ts │ │ ├── import-exports-of-indirect-class.ts.skip │ │ ├── import-extension-js.ts │ │ ├── import-extension-none.ts │ │ ├── import-extension-ts.ts │ │ ├── import-from-ambient-module-declaration.ts │ │ ├── import-from-own-direcotry-in-index.ts │ │ ├── import-from-own-project-subdirectory.ts │ │ ├── import-from-subdirectory.ts │ │ ├── import-from-superdirectory.ts │ │ ├── import-indirectly-exported-variable.ts │ │ ├── import-reexports-from-subdirectory-index.ts │ │ ├── import-reexports-from-superdirectory-index.ts │ │ ├── import-relative-to-project-root.ts.skip │ │ ├── import-via-index.ts │ │ ├── import-via-superdirectory.ts │ │ ├── import-via-two-reexports.ts │ │ ├── module-declaration-not-visible-in-other-module.ts │ │ ├── namespace-type-export.ts │ │ ├── namespace-variable-export.ts │ │ ├── reexport-as-object.ts │ │ ├── refer-to-separately-defined-subnamespace-from-supernamespace.ts.skip │ │ ├── refer-to-type-in-aprent-namespace-from-split-qualified-namespace.ts.skip │ │ ├── refer-to-type-in-nested-namespace-from-parent-namespace-with-partially-qualified-name.ts.skip │ │ ├── refer-to-type-in-nested-namespace-from-qualified-namespace.ts.skip │ │ ├── rename-imported-directly-exported-variable.ts │ │ ├── rename-imported-indirectly-exported-variable.ts │ │ ├── script-declaration-visible-in-other-module.ts │ │ ├── split-namespace-can-only-see-exports.ts │ │ ├── split-namespace-can-see-all-exports.ts.skip │ │ └── very-deep-namespace.ts │ ├── packages │ │ ├── can-access-package-non-main-explicilty.ts │ │ ├── package-does-not-export-non-main.ts │ │ ├── package-exports-explicit-main.ts │ │ ├── package-invisible-without-dependency.ts │ │ └── package-main-defaults-to-index.ts │ ├── projects │ │ ├── baseurl-to-subdir.ts │ │ ├── composite-project.ts │ │ ├── declarations-are-ignored.ts │ │ ├── empty-project-config.ts │ │ ├── exclude-second-subdir.ts │ │ ├── explicit-root-dir.ts │ │ ├── import-from-rootdirs-subdir.ts │ │ ├── import-from-rootdirs.ts │ │ ├── import-with-own-project-baseurl.ts │ │ ├── include-one-subdir.ts │ │ ├── invalid-paths-mappings.ts │ │ ├── js-sources-are-ignored.ts.skip │ │ ├── js-sources-can-be-allowed.ts.skip │ │ ├── non-relative-single-module-remap.ts │ │ ├── non-relative-star-remap.ts │ │ ├── non-relative-star-remaps.ts │ │ ├── one-file-in-subdir.ts │ │ ├── package-dependency-with-nested-source-root.ts │ │ ├── projects-are-isolated.ts │ │ ├── relative-import.ts │ │ ├── relative-single-module-remap.ts │ │ ├── relative-star-remap.ts │ │ ├── remap-with-baseurl.ts │ │ ├── sources-in-multiple-subdirs.ts │ │ └── sources-in-one-subdir.ts │ ├── statements │ │ ├── abstract-class-with-constructor.ts │ │ ├── ambient-module-declaration.ts │ │ ├── call-argument-type-shadows-type-parameter-default.ts.skip │ │ ├── class-static-block.ts │ │ ├── class-with-constructor.ts │ │ ├── const-with-value.ts │ │ ├── coverage.ts │ │ ├── deconstruct-tuple.ts │ │ ├── decorators.ts │ │ ├── define-after-use.ts │ │ ├── destructuring-var-defs.ts │ │ ├── enum-constant-not-a-type-member.ts │ │ ├── enum-object.ts │ │ ├── enum.ts │ │ ├── expression-statement.ts │ │ ├── for-let-initializer-scoping.ts │ │ ├── for-of-destructuring-var.ts │ │ ├── for-of-var-type.ts │ │ ├── for-var-initializer-scoping.ts │ │ ├── function-declaration.ts │ │ ├── function-type-inferred-from-deeply-nested-return.ts │ │ ├── function-type-inferred-from-direct-return.ts │ │ ├── function-type-inferred-from-nested-return.ts │ │ ├── getter-not-accessible-as-method.ts.skip │ │ ├── infer-arrow-function-literal-parameter-type-from-use-site.ts │ │ ├── infer-function-literal-parameter-type-from-let-type-annotation.ts │ │ ├── infer-function-literal-parameter-type-from-use-site.ts │ │ ├── let-and-var-with-type-annotation.ts │ │ ├── let-bound-variable-has-value-type.ts │ │ ├── let-with-value.ts │ │ ├── let-without-value.ts │ │ ├── member-and-subscript-expression-in-assignment-pattern.ts │ │ ├── multi-let.ts │ │ ├── new-on-class-expression.ts │ │ ├── qualified-decorators.ts │ │ ├── reexport-of-variable.ts │ │ ├── refer-to-class-in-nested-namespace-by-qualified-name.ts │ │ ├── refer-to-interface-in-nested-namespace-by-fully-qualified-name.ts │ │ ├── refer-to-interface-in-qualified-namespace-by-fully-qualified-name.ts │ │ ├── rename-imported-default.ts │ │ ├── renamed-reexport-of-default.ts │ │ ├── renamed-reexport-of-variable.ts │ │ ├── separate-expression-and-type-identifiers.ts │ │ ├── shadowing.ts │ │ ├── var-and-let-hoisting.ts │ │ ├── var-in-for-body-escapes.ts │ │ ├── var-with-value.ts │ │ ├── var-without-value.ts │ │ └── with.ts │ └── types │ │ ├── call-generic-function-with-generic-return-type-without-type-arguments.ts.skip │ │ ├── class-and-interface-inheritance.ts │ │ ├── class-extends-alias-of-generic-class.ts.skip │ │ ├── class-extends-and-implements.ts │ │ ├── class-extends-class-returned-from-function.ts.skip │ │ ├── class-extends-instance-of-generic-constructor-type.ts.skip │ │ ├── class-extends-via-alias.ts │ │ ├── class-implements-multiple-interfaces.ts │ │ ├── generic-interface-with-generic-field.ts.bug │ │ ├── generic-interface-with-generic-method.ts.skip │ │ ├── generic-interface-with-generic-super-type.ts.bug │ │ ├── generic-interface.ts │ │ ├── generic-type-alias.ts │ │ ├── indexed-lookup-type.ts.skip │ │ ├── indexed-type.ts.skip │ │ ├── interface-extends-multiple-interfaces.ts │ │ ├── interface-extends.ts │ │ ├── mixins.ts.skip │ │ ├── qualified-type-query.ts │ │ ├── tuple-type.ts │ │ ├── type-refs-in-type-expressions.ts │ │ ├── typeof-call.ts │ │ ├── typeof-member.ts │ │ └── typeof-variable.ts │ └── vscode │ ├── .gitignore │ ├── package-lock.json │ ├── package.json │ ├── src │ └── extension.ts │ └── tsconfig.json ├── lsp-positions ├── CHANGELOG.md ├── Cargo.toml ├── README.md ├── src │ └── lib.rs └── tests │ └── it │ └── main.rs ├── script ├── cbindgen ├── ci-comment-json ├── ci-perf-summary-md ├── ci-test-init └── ci-test-valgrind ├── stack-graphs ├── CHANGELOG.md ├── Cargo.toml ├── README.md ├── cbindgen.toml ├── include │ └── stack-graphs.h ├── src │ ├── arena.rs │ ├── assert.rs │ ├── c.rs │ ├── cycles.rs │ ├── debugging.rs │ ├── graph.rs │ ├── lib.rs │ ├── partial.rs │ ├── paths.rs │ ├── serde │ │ ├── filter.rs │ │ ├── graph.rs │ │ ├── mod.rs │ │ ├── partial.rs │ │ └── stitching.rs │ ├── stats.rs │ ├── stitching.rs │ ├── storage.rs │ ├── utils.rs │ ├── visualization.rs │ └── visualization │ │ ├── d3-dag.min.js │ │ ├── d3.min.js │ │ ├── visualization.css │ │ └── visualization.js └── tests │ └── it │ ├── arena.rs │ ├── c │ ├── can_create_graph.rs │ ├── can_find_local_nodes.rs │ ├── can_find_partial_paths_in_file.rs │ ├── can_find_qualified_definitions_with_phased_partial_path_stitching.rs │ ├── can_jump_to_definition.rs │ ├── can_jump_to_definition_with_phased_partial_path_stitching.rs │ ├── files.rs │ ├── mod.rs │ ├── nodes.rs │ ├── partial.rs │ ├── strings.rs │ ├── symbols.rs │ └── test_graph.rs │ ├── can_create_graph.rs │ ├── can_find_local_nodes.rs │ ├── can_find_node_partial_paths_in_database.rs │ ├── can_find_partial_paths_in_file.rs │ ├── can_find_root_partial_paths_in_database.rs │ ├── can_jump_to_definition.rs │ ├── can_jump_to_definition_with_forward_partial_path_stitching.rs │ ├── cycles.rs │ ├── graph.rs │ ├── main.rs │ ├── partial.rs │ ├── serde.rs │ ├── stats.rs │ ├── stitching.rs │ ├── storage.rs │ ├── test_graphs │ ├── class_field_through_function_parameter.rs │ ├── cyclic_imports_python.rs │ ├── cyclic_imports_rust.rs │ ├── mod.rs │ ├── sequenced_import_star.rs │ └── simple.rs │ └── util.rs ├── tree-sitter-stack-graphs ├── CHANGELOG.md ├── Cargo.toml ├── README.md ├── examples │ ├── .gitignore │ ├── README.md │ ├── bootstrap │ ├── modules │ │ ├── stack-graphs.tsg │ │ └── tests │ │ │ ├── import-all-definitions-from-nested-module.py │ │ │ ├── import-all-definitions-from-toplevel-module.py │ │ │ ├── import-single-definition-from-nested-module.py │ │ │ └── import-single-definition-from-toplevel-module.py │ ├── nested-scope │ │ ├── stack-graphs.tsg │ │ └── tests │ │ │ ├── nested-def.py │ │ │ ├── shadowing.py │ │ │ └── top-level-defs.py │ ├── parse │ ├── run │ └── sequential-definitions │ │ ├── stack-graphs.tsg │ │ └── tests │ │ └── shadow-previous-def.py ├── src │ ├── bin │ │ └── tree-sitter-stack-graphs │ │ │ └── main.rs │ ├── ci.rs │ ├── cli.rs │ ├── cli │ │ ├── clean.rs │ │ ├── database.rs │ │ ├── index.rs │ │ ├── init.rs │ │ ├── init │ │ │ └── license.rs │ │ ├── load.rs │ │ ├── lsp.rs │ │ ├── match.rs │ │ ├── parse.rs │ │ ├── query.rs │ │ ├── status.rs │ │ ├── test.rs │ │ ├── util.rs │ │ ├── util │ │ │ └── reporter.rs │ │ └── visualize.rs │ ├── functions.rs │ ├── lib.rs │ ├── loader.rs │ ├── test.rs │ └── util.rs └── tests │ └── it │ ├── builder.rs │ ├── edges.rs │ ├── loader.rs │ ├── main.rs │ ├── nodes.rs │ └── test.rs └── valgrind.supp /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @github/semantic-code @github/blackbird 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Rust build stuff 2 | Cargo.lock 3 | /target/ 4 | */target/ 5 | 6 | # Locally installed binaries 7 | /.crates.toml 8 | /.crates2.json 9 | /bin/ 10 | 11 | # MacOS stuff 12 | .DS_Store -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile tree-sitter-stack-graphs-typescript LSP extension", 6 | "type": "npm", 7 | "script": "build", 8 | "group": { 9 | "kind": "build" 10 | }, 11 | "options": { 12 | "cwd": "${workspaceFolder}/languages/tree-sitter-stack-graphs-typescript/vscode", 13 | }, 14 | "presentation": { 15 | "panel": "dedicated", 16 | "reveal": "always" 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.zenodo.json: -------------------------------------------------------------------------------- 1 | { 2 | "creators": [ 3 | { 4 | "orcid": "0000-0003-1100-4894", 5 | "name": "Creager, Douglas A.", 6 | "affiliation": "GitHub" 7 | }, 8 | { 9 | "orcid": "0000-0001-5117-0921", 10 | "name": "van Antwerpen, Hendrik", 11 | "affiliation": "GitHub" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Douglas Creager 2 | Hendrik van Antwerpen 3 | Akshay 4 | blusk 5 | William Manley 6 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "1" 3 | members = [ 4 | # library projects 5 | "lsp-positions", 6 | "stack-graphs", 7 | "tree-sitter-stack-graphs", 8 | "languages/*", 9 | ] 10 | default-members = [ 11 | "lsp-positions", 12 | "stack-graphs", 13 | "tree-sitter-stack-graphs", 14 | ] 15 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | If you discover a security issue in this repo, please submit it through the [GitHub Security Bug Bounty](https://hackerone.com/github) 2 | 3 | Thanks for helping make our code safe for everyone. 4 | -------------------------------------------------------------------------------- /data/typescript_benchmark.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/stack-graphs/d0b59479b92fc29e9f56cfc20efdfba7a9b6443c/data/typescript_benchmark.zip -------------------------------------------------------------------------------- /data/typescript_minimal_project.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/stack-graphs/d0b59479b92fc29e9f56cfc20efdfba7a9b6443c/data/typescript_minimal_project.zip -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/.gitignore: -------------------------------------------------------------------------------- 1 | /Cargo.lock 2 | *.html 3 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/src/builtins.cfg: -------------------------------------------------------------------------------- 1 | [globals] 2 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/src/builtins.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/stack-graphs/d0b59479b92fc29e9f56cfc20efdfba7a9b6443c/languages/tree-sitter-stack-graphs-java/src/builtins.java -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/annotation_type_body.java: -------------------------------------------------------------------------------- 1 | import java.io.File; 2 | @interface FileQualifier {} 3 | 4 | class Foo { 5 | public void main(@FileQualifier File someFile) { 6 | // ^ defined: 2 7 | return; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/class_extension.java: -------------------------------------------------------------------------------- 1 | class String { 2 | public int length() {} 3 | }; 4 | 5 | class HashMap { 6 | public Set> entrySet() {} 7 | // ^ defined: 5 8 | } 9 | 10 | class LRUCache 11 | extends HashMap { 12 | // ^ defined: 5 13 | // ^ defined: 10 14 | // ^ defined: 10 15 | } 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/class_parameters.java: -------------------------------------------------------------------------------- 1 | class A { 2 | T t; 3 | //^ defined: 1 4 | } 5 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/collection_import.java: -------------------------------------------------------------------------------- 1 | import test.Item; 2 | 3 | import java.util.Collection; 4 | 5 | public class CollectionImport { 6 | public void main() { 7 | Collection items = new ArrayList<>(); 8 | // ^ defined: 3 9 | // ^ defined: 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/duplicate_type_identifier.java: -------------------------------------------------------------------------------- 1 | // TODO: this triggers a Duplicate variable error 2 | // Caused by: Duplicate variable [syntax node type_identifier (3, 5)].value set at (553, 14) and (553, 14) 3 | // Unclear to me why it lists that line/row twice? 4 | public class RepairScanner implements MessageStateProcessor { 5 | private Map fetchRelayOffsets() { 6 | Map offsets = Collections.emptyMap(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/enum.java: -------------------------------------------------------------------------------- 1 | enum A { 2 | X, Y, Z 3 | } 4 | 5 | class B { 6 | void f() { 7 | f(A.X); 8 | //^ defined: 1 9 | // ^ defined: 2 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/enum_switches.java: -------------------------------------------------------------------------------- 1 | enum Level { 2 | LOW, 3 | MEDIUM, 4 | HIGH 5 | } 6 | 7 | class Supplier { 8 | T get() {} 9 | } 10 | 11 | class App { 12 | boolean isSufficient(Supplier level_supplier) { 13 | switch (level_supplier.get()) { 14 | case LOW: return false; 15 | // ^ defined: 2 16 | case MEDIUM: return false; 17 | // ^ defined: 3 18 | case Level.HIGH: return true; 19 | // ^ defined: 1 20 | // ^ defined: 4 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/field_declaration.java: -------------------------------------------------------------------------------- 1 | class TestClass { 2 | int x = 5; 3 | 4 | public static void test() { 5 | x; 6 | // ^ defined: 2 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/field_modifiers.java: -------------------------------------------------------------------------------- 1 | class A { 2 | @A @A(true) @A(k = true) A x; 3 | // ^ defined: 1 4 | // ^ defined: 1 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | } 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/import_statement.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | class Foo { 4 | public static void main() { 5 | Scanner myScanner = new Scanner(System.in); 6 | // ^ defined: 1 7 | // ^ defined: 1 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/interface.java: -------------------------------------------------------------------------------- 1 | interface I { 2 | void f(); 3 | } 4 | class A implements I {} 5 | // ^ defined: 1 6 | interface J extends I {} 7 | // ^ defined: 1 8 | 9 | interface Iterator { 10 | public E next() {} 11 | // ^ defined: 9 12 | } 13 | 14 | interface Set { 15 | public Iterator iterator() {} 16 | } 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/method_arguments.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f(int x) { 3 | f(x); 4 | //^defined: 2 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/method_overriding.java: -------------------------------------------------------------------------------- 1 | class TestClass extends SecondTestClass { 2 | // ^ defined: 14 3 | public static void main(String[] args){ 4 | foo(); 5 | // ^ defined: 10 6 | bar(); 7 | // ^ defined: 15 8 | } 9 | 10 | public void foo() { 11 | } 12 | } 13 | 14 | class SecondTestClass { 15 | public void bar() { 16 | System.out.println("Hello"); 17 | foo(); 18 | // ^ defined: 21 19 | } 20 | 21 | public void foo() { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/method_return.java: -------------------------------------------------------------------------------- 1 | class A { 2 | A f() {} 3 | //^ defined: 1 4 | } 5 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/record.java: -------------------------------------------------------------------------------- 1 | record A(int x) { 2 | A a; 3 | //^ defined: 1 4 | void f() { 5 | x; 6 | //^ defined: 1 7 | } 8 | } 9 | class B { 10 | A b; 11 | //^ defined: 1 12 | } 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/super_variable_declaration.java: -------------------------------------------------------------------------------- 1 | class TestClass extends SecondTestClass { 2 | public static void main(String[] args){ 3 | int foo = 10; 4 | super.foo; 5 | // ^ defined: 10 6 | } 7 | } 8 | 9 | class SecondTestClass { 10 | int foo = 5; 11 | } 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/decl/type_identifier.java: -------------------------------------------------------------------------------- 1 | public class TypeIdentifierTest { 2 | public boolean checkVersion(String app, int version) { 3 | Map keys = vaultClient.getSecrets(API_KEYS_FILTER); 4 | return true; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/array_access.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | A[] a; 4 | int i; 5 | a[i]; 6 | //^ defined: 3 7 | // ^ defined: 4 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/array_creation.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | int x; 4 | new A[x][x]; 5 | // ^ defined: 1 6 | // ^ defined: 3 7 | // ^ defined: 3 8 | A[] as = { x, x }; 9 | // ^ defined: 3 10 | // ^ defined: 3 11 | A[] as = new A[x][]; 12 | // ^ defined: 1 13 | // ^ defined: 3 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/assignment.java: -------------------------------------------------------------------------------- 1 | class A { 2 | A x; 3 | void f() { 4 | x = x; 5 | //^ defined: 2 6 | // ^ defined: 2 7 | x.x = x; 8 | //^ defined: 2 9 | // ^ defined: 2 10 | // ^ defined: 2 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/binary.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | return f() + f(); 4 | // ^ defined: 2 5 | // ^ defined: 2 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/cast.java: -------------------------------------------------------------------------------- 1 | class A { 2 | A f() { 3 | return (A)(f()); 4 | // ^ defined: 1 5 | // ^ defined: 2 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/class_literal.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | A.class; 4 | //^ defined: 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/instanceof.java: -------------------------------------------------------------------------------- 1 | class A { 2 | boolean f(A x) { 3 | return x instanceof A; 4 | // ^ defined: 2 5 | // ^ defined: 1 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/lambda.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | x -> f(x); 4 | // ^ defined: 2 5 | // ^ defined: 3 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/method_call.java: -------------------------------------------------------------------------------- 1 | class TestClass { 2 | public static void main(String[] args){ 3 | hello(); 4 | // ^ defined: 7 5 | } 6 | 7 | public static void hello() { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/method_reference.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | A::f; 4 | //^ defined: 1 5 | // ^ defined: 2 6 | A::new; 7 | //^ defined: 1 8 | A a = new A(); 9 | a::f; 10 | //^ defined: 8 11 | // ^ defined: 2 12 | } 13 | } 14 | class B extends A { 15 | void g() { 16 | super::f; 17 | // ^ defined: 2 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/object_creation_expression.java: -------------------------------------------------------------------------------- 1 | class Outer 2 | { 3 | public Outer() 4 | { 5 | Inner i = new Inner(); 6 | // ^ defined: 8 7 | } 8 | class Inner 9 | { 10 | class Inner2 11 | { 12 | class Inner3 13 | { 14 | public Inner3() 15 | { 16 | Inner2 i2 = new Inner2(); 17 | // ^ defined: 10 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/ternary.java: -------------------------------------------------------------------------------- 1 | class A { 2 | boolean x; 3 | void f() { 4 | x ? x : x; 5 | //^ defined: 2 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/unary.java: -------------------------------------------------------------------------------- 1 | class A { 2 | A x; 3 | void f() { 4 | !x; 5 | //^defined: 2 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/expression/update.java: -------------------------------------------------------------------------------- 1 | class A { 2 | A x; 3 | void f() { 4 | ++x; 5 | //^ defined: 2 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/imports_and_exports/import_method.java: -------------------------------------------------------------------------------- 1 | /*--- path: Importer.java ---*/ 2 | import foo.Foo; 3 | 4 | public class Importer { 5 | public static void main(String[] args) { 6 | Foo.bar(); 7 | // ^ defined: 16 8 | 9 | } 10 | } 11 | 12 | /* --- path: foo/Foo.java ---*/ 13 | package foo; 14 | 15 | public class Foo { 16 | public static void bar() { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/imports_and_exports/imports.java: -------------------------------------------------------------------------------- 1 | /*--- path: Importer.java ---*/ 2 | import foo.Foo; 3 | // ^ defined: 14 4 | 5 | public class Importer { 6 | public Foo test() { 7 | // ^ defined: 2, 14 8 | } 9 | } 10 | 11 | /* --- path: foo/Foo.java ---*/ 12 | package foo; 13 | 14 | public class Foo { 15 | } 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/imports_and_exports/no_package.java: -------------------------------------------------------------------------------- 1 | /*--- path: Importer.java ---*/ 2 | public class Importer { 3 | public Foo test() { 4 | // ^ defined: 9 5 | } 6 | } 7 | 8 | /* --- path: Foo.java ---*/ 9 | public class Foo { 10 | } 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/imports_and_exports/no_package_method.java: -------------------------------------------------------------------------------- 1 | /*--- path: Importer.java ---*/ 2 | public class Importer { 3 | public static void main(String[] args) { 4 | Foo.bar(); 5 | // ^ defined: 12 6 | 7 | } 8 | } 9 | 10 | /* --- path: Foo.java ---*/ 11 | public class Foo { 12 | public static void bar() { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/imports_and_exports/no_package_not_leaking_method.java: -------------------------------------------------------------------------------- 1 | /*--- path: Importer.java ---*/ 2 | public class Importer { 3 | public static void main(String[] args) { 4 | bar(); 5 | // ^ defined: 6 | } 7 | } 8 | 9 | /* --- path: Foo.java ---*/ 10 | public class Foo { 11 | public static void bar() { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/assert_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | assert f(); 4 | // ^ defined: 2 5 | assert f(): f(); 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/break.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | foo: for(;;) { 4 | for(;;) { 5 | break foo; 6 | // ^ defined: 3 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/continue.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | foo: for(;;) { 4 | for(;;) { 5 | continue foo; 6 | // ^ defined: 3 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/do_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | int f(int x, boolean y) { 3 | do return x; while(y); 4 | // ^ defined: 2 5 | // ^ defined: 2 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/enhanced_for_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | A[] f() { 3 | for (A x : f()) { 4 | // ^ defined: 1 5 | // ^ defined: 2 6 | return x; 7 | // ^ defined: 3 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/getter_method.java: -------------------------------------------------------------------------------- 1 | class Foo { 2 | String bar; 3 | 4 | void setBar(String b) { 5 | bar = b; 6 | } 7 | } 8 | 9 | class Baz { 10 | public static void main(String[] args) { 11 | Foo f = new Foo(); 12 | //^ defined: 1 13 | // ^ defined: 1 14 | f.setBar("high"); 15 | // ^ defined: 11 16 | // ^ defined: 4 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/if_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | boolean x; 4 | if (x) { 5 | //^ defined: 3 6 | f(); 7 | //^ defined: 2 8 | } 9 | if (true) {} else { 10 | f(); 11 | //^ defined: 2 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/labeled_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | x: f(); 4 | // ^ defined: 2 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/return_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | boolean f(boolean x) { 3 | return x; 4 | // ^ defined: 2 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/switch_expression.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | int x; 4 | switch (x) { 5 | // ^ defined: 3 6 | case x: 7 | // ^ defined: 3 8 | default: 9 | f(); 10 | //^ defined: 2 11 | } 12 | switch (x) { 13 | // ^ defined: 3 14 | case x -> { 15 | // ^ defined: 3 16 | f(); 17 | //^ defined: 2 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/synchronized_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | synchronized (f()) { 4 | // ^ defined: 2 5 | f(); 6 | //^ defined: 2 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/try_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | try { 4 | f(); 5 | //^ defined: 2 6 | } catch (A e) { 7 | e; 8 | //^ defined: 6 9 | f(); 10 | //^ defined: 2 11 | } finally { 12 | f(); 13 | //^ defined: 2 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/try_with_resources_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | A b; 4 | try (A a = f(); a; b.x) { 5 | // ^ defined: 2 6 | // ^ defined: 4 7 | // ^ defined: 3 8 | f(a); 9 | //^ defined: 2 10 | // ^ defined: 4 11 | } catch (A e) { 12 | e; 13 | //^ defined: 11 14 | f(); 15 | //^ defined: 2 16 | } finally { 17 | f(); 18 | //^ defined: 2 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/while_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | while (f()) { 4 | // ^ defined: 2 5 | f(); 6 | //^ defined: 2 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/statement/yield_statement.java: -------------------------------------------------------------------------------- 1 | class A { 2 | void f() { 3 | yield f(); 4 | // ^ defined: 2 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/type/array.java: -------------------------------------------------------------------------------- 1 | class A { 2 | A[] x; 3 | //^ defined: 1 4 | } 5 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/type/generic.java: -------------------------------------------------------------------------------- 1 | class A { 2 | A x; 3 | //^ defined: 1 4 | // ^ defined: 1 5 | } 6 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-java/test/type/named.java: -------------------------------------------------------------------------------- 1 | class A {} 2 | class B { 3 | A a; 4 | //^ defined: 1 5 | } 6 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | /Cargo.lock 3 | /node_modules 4 | /package-lock.json 5 | /target 6 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/docs/package-structure/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/stack-graphs/d0b59479b92fc29e9f56cfc20efdfba7a9b6443c/languages/tree-sitter-stack-graphs-javascript/docs/package-structure/example.png -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/src/builtins.cfg: -------------------------------------------------------------------------------- 1 | [globals] 2 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/src/builtins.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/stack-graphs/d0b59479b92fc29e9f56cfc20efdfba7a9b6443c/languages/tree-sitter-stack-graphs-javascript/src/builtins.js -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/array_index_flow.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | let arr = [0, x]; 3 | let y = arr[0]; 4 | let z = arr[1]; 5 | 6 | /**/ y; 7 | // ^ defined: 3 8 | 9 | /**/ z; 10 | // ^ defined: 1, 4 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/assignment_destructuring_array_pattern.js: -------------------------------------------------------------------------------- 1 | let arr = [ 2 | 1, 3 | { 4 | x: 2 5 | } 6 | ]; 7 | let [num, obj] = arr; 8 | 9 | obj.x; 10 | // ^ defined: 4 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/assignment_destructuring_object_pattern.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | x: 1, 3 | y: { 4 | x: 2 5 | } 6 | }; 7 | let { 8 | x: num, 9 | y: obj2 10 | } = obj; 11 | 12 | /**/ obj2; 13 | // ^ defined: 3, 9 14 | 15 | obj2.x; 16 | // ^ defined: 4 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_constructor_field.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | constructor() { 3 | this.bar = 5; 4 | } 5 | }; 6 | 7 | let x = new Foo(); 8 | x.bar; 9 | // ^ defined: 3 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_field_definitions.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar; 3 | baz = 1; 4 | static quux; 5 | static doo = 1; 6 | } 7 | 8 | let obj = new Foo(); 9 | 10 | obj.bar; 11 | // ^ defined: 2 12 | 13 | obj.baz; 14 | // ^ defined: 3 15 | 16 | obj.quux; 17 | // ^ defined: 4 18 | 19 | obj.doo; 20 | // ^ defined: 5 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_fields_and_methods_not_visible_outside_class.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar = 1; 3 | baz() { 4 | 5 | } 6 | } 7 | 8 | Foo.bar; 9 | // ^ defined: 10 | // bar should not be visible here 11 | 12 | Foo.baz; 13 | // ^ defined: 14 | // baz should not be visible here -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_fields_and_methods_visible_in_other_methods.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar = 1; 3 | baz() { } 4 | quux() { 5 | this.bar; 6 | // ^ defined: 2 7 | 8 | this.baz(); 9 | // ^ defined: 3 10 | } 11 | } 12 | 13 | (class { 14 | bar = 1; 15 | baz() { } 16 | quux() { 17 | this.bar; 18 | // ^ defined: 14 19 | 20 | this.baz(); 21 | // ^ defined: 15 22 | } 23 | }); -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_method_call_argument_flow.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | x: 1 3 | }; 4 | 5 | 6 | 7 | class Foo { 8 | // method declaration 9 | meth_1(o) { 10 | return o; 11 | } 12 | 13 | // generator method declaration 14 | * gen_meth_1(o) { 15 | yield o; 16 | } 17 | } 18 | 19 | let foo = new Foo(); 20 | 21 | foo.meth_1(obj).x; 22 | // ^ defined: 2 23 | 24 | foo.gen_meth_1(obj).x; 25 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_method_call_arguments_variable_flow.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | x: 1 3 | }; 4 | 5 | 6 | 7 | class Foo { 8 | // method declaration 9 | meth_1() { 10 | return arguments; 11 | } 12 | 13 | // generator method declaration 14 | * gen_meth_1() { 15 | yield arguments; 16 | } 17 | } 18 | 19 | let foo = new Foo(); 20 | 21 | foo.meth_1(obj)[0].x; 22 | // ^ defined: 2 23 | 24 | foo.gen_meth_1(obj)[0].x; 25 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_method_call_closure_flow.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | x: 1 3 | }; 4 | 5 | 6 | 7 | class Foo { 8 | // method declaration 9 | meth_1() { 10 | return obj; 11 | } 12 | 13 | // generator method declaration 14 | * gen_meth_1() { 15 | yield obj; 16 | } 17 | } 18 | 19 | let foo = new Foo(); 20 | 21 | foo.meth_1().x; 22 | // ^ defined: 2 23 | 24 | foo.gen_meth_1().x; 25 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_method_call_constant_flow.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | // method declaration 3 | meth_1() { 4 | return { 5 | x: 1 6 | }; 7 | } 8 | 9 | // generator method declaration 10 | * gen_meth_1() { 11 | yield { 12 | x: 1 13 | }; 14 | } 15 | } 16 | 17 | let foo = new Foo(); 18 | 19 | foo.meth_1().x; 20 | // ^ defined: 5 21 | 22 | foo.gen_meth_1().x; 23 | // ^ defined: 12 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_methods_visible_on_instances.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar() { 3 | 4 | } 5 | } 6 | 7 | let obj = new Foo(); 8 | obj.bar; 9 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_super_reference_to_method.js.skip: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar() { 3 | 4 | } 5 | } 6 | 7 | class Baz extends Foo { 8 | bar() { 9 | 10 | } 11 | quux() { 12 | super.bar; 13 | // ^ defined: 2 14 | } 15 | } -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_superclass_field_definition.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar; 3 | baz = 1; 4 | static quux; 5 | static doo = 1; 6 | } 7 | 8 | class Garply extends Foo { } 9 | 10 | let obj = new Garply(); 11 | 12 | obj.bar; 13 | // ^ defined: 2 14 | 15 | obj.baz; 16 | // ^ defined: 3 17 | 18 | obj.quux; 19 | // ^ defined: 4 20 | 21 | obj.doo; 22 | // ^ defined: 5 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_superclass_methods_visible_on_instances.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar() { 3 | 4 | } 5 | } 6 | 7 | class Baz extends Foo { } 8 | 9 | let obj = new Baz(); 10 | obj.bar; 11 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_declaration_this_field_and_method.js.skip: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar; 3 | baz() { 4 | 5 | } 6 | quux() { 7 | this.bar; 8 | // ^ defined: 2 9 | this.baz; 10 | // ^ defined: 3 11 | } 12 | } -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_constructor_field.js: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | constructor() { 3 | this.bar = 5; 4 | } 5 | }; 6 | 7 | let x = new Foo(); 8 | x.bar; 9 | // ^ defined: 3 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_field_definition.js: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | bar; 3 | baz = 1; 4 | static quux; 5 | static doo = 1; 6 | }; 7 | 8 | let obj = new Foo(); 9 | 10 | obj.bar; 11 | // ^ defined: 2 12 | 13 | obj.baz; 14 | // ^ defined: 3 15 | 16 | obj.quux; 17 | // ^ defined: 4 18 | 19 | obj.doo; 20 | // ^ defined: 5 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_fields_and_methods_not_visible_outside_class.js: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | bar = 1; 3 | baz() { 4 | 5 | } 6 | }; 7 | 8 | Foo.bar; 9 | // ^ defined: 10 | // bar should not be visible here 11 | 12 | Foo.baz; 13 | // ^ defined: 14 | // baz should not be visible here -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_method_call_argument_flow.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | x: 1 3 | }; 4 | 5 | 6 | 7 | let Foo = class { 8 | // method declaration 9 | meth_1(o) { 10 | return o; 11 | } 12 | 13 | // generator method declaration 14 | * gen_meth_1(o) { 15 | yield o; 16 | } 17 | }; 18 | 19 | let foo = new Foo(); 20 | 21 | foo.meth_1(obj).x; 22 | // ^ defined: 2 23 | 24 | foo.gen_meth_1(obj).x; 25 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_method_call_arguments_variable_flow.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | x: 1 3 | }; 4 | 5 | 6 | 7 | let Foo = class { 8 | // method declaration 9 | meth_1() { 10 | return arguments; 11 | } 12 | 13 | // generator method declaration 14 | * gen_meth_1() { 15 | yield arguments; 16 | } 17 | }; 18 | 19 | let foo = new Foo(); 20 | 21 | foo.meth_1(obj)[0].x; 22 | // ^ defined: 2 23 | 24 | foo.gen_meth_1(obj)[0].x; 25 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_method_call_closure_flow.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | x: 1 3 | }; 4 | 5 | 6 | 7 | let Foo = class { 8 | // method declaration 9 | meth_1() { 10 | return obj; 11 | } 12 | 13 | // generator method declaration 14 | * gen_meth_1() { 15 | yield obj; 16 | } 17 | }; 18 | 19 | let foo = new Foo(); 20 | 21 | foo.meth_1().x; 22 | // ^ defined: 2 23 | 24 | foo.gen_meth_1().x; 25 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_method_call_constant_flow.js: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | // method declaration 3 | meth_1() { 4 | return { 5 | x: 1 6 | }; 7 | } 8 | 9 | // generator method declaration 10 | * gen_meth_1() { 11 | yield { 12 | x: 1 13 | }; 14 | } 15 | }; 16 | 17 | let foo = new Foo(); 18 | 19 | foo.meth_1().x; 20 | // ^ defined: 5 21 | 22 | foo.gen_meth_1().x; 23 | // ^ defined: 12 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_methods_visible_on_instances.js: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | bar() { 3 | 4 | } 5 | }; 6 | 7 | let obj = new Foo(); 8 | obj.bar; 9 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_super_reference_to_method.js.skip: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | bar() { 3 | 4 | } 5 | }; 6 | 7 | let Bar = class extends Foo { 8 | bar() { 9 | 10 | } 11 | quux() { 12 | super.bar; 13 | // ^ defined: 2 14 | } 15 | }; -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_superclass_field_definition.js: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | bar; 3 | baz = 1; 4 | static quux; 5 | static doo = 1; 6 | }; 7 | 8 | let Garply = class extends Foo { }; 9 | 10 | let obj = new Garply(); 11 | 12 | obj.bar; 13 | // ^ defined: 2 14 | 15 | obj.baz; 16 | // ^ defined: 3 17 | 18 | obj.quux; 19 | // ^ defined: 4 20 | 21 | obj.doo; 22 | // ^ defined: 5 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_superclass_methods_visible_on_instances.js: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | bar() { 3 | 4 | } 5 | }; 6 | 7 | let Baz = class extends Foo { }; 8 | 9 | let obj = new Baz(); 10 | obj.bar; 11 | // ^ defined: 2 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/class_expression_this_field_and_method.js.skip: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | bar; 3 | baz() { 4 | 5 | } 6 | quux() { 7 | this.bar; 8 | // ^ defined: 2 9 | this.baz; 10 | // ^ defined: 3 11 | } 12 | }; -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/function_call_this_flow.js.skip: -------------------------------------------------------------------------------- 1 | function foo() { 2 | return this; 3 | } 4 | 5 | foo().x; 6 | // ^ defined: 7 | 8 | foo.apply({ 9 | x: 1 10 | }).x 11 | // ^ defined: 9 12 | 13 | foo.call({ 14 | x: 1 15 | }).x 16 | // ^ defined: 14 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/function_call_this_keyword_flow.js: -------------------------------------------------------------------------------- 1 | function foo() { 2 | this.x = 1; 3 | } 4 | 5 | let obj = new foo(); 6 | 7 | obj.x; 8 | // ^ defined: 2 9 | 10 | 11 | 12 | function bar(y) { 13 | this.z = y; 14 | } 15 | 16 | let obj_2 = new bar({ 17 | w: 1 18 | }); 19 | 20 | obj_2.z.w; 21 | // ^ defined: 17 22 | // ^ defined: 12, 13 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/member_object_flow.js: -------------------------------------------------------------------------------- 1 | let x = 0; 2 | let obj = { 3 | foo: x 4 | }; 5 | 6 | obj.foo; 7 | // ^ defined: 1, 3 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/object_computed_property_name_flow.js: -------------------------------------------------------------------------------- 1 | let x = 0; 2 | let obj = { 3 | ["foo"]: x 4 | }; 5 | let y = obj["foo"]; 6 | 7 | /**/ y; 8 | // TODO defined: 1, 3, 5 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/object_shorthand_property_identifier_flow.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | let obj = { 4 | x 5 | }; 6 | 7 | obj.x; 8 | // ^ defined: 1, 4 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/subscript_array_flow.js: -------------------------------------------------------------------------------- 1 | let x = 0; 2 | let arr = [0, x]; 3 | let x2 = arr[1]; 4 | 5 | /**/ x2; 6 | // ^ defined: 1, 3 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/subscript_object_flow.js: -------------------------------------------------------------------------------- 1 | let x = 0; 2 | let obj = { 3 | foo: x 4 | }; 5 | let y = obj["foo"]; 6 | 7 | /**/ y; 8 | // ^ defined: 1, 3, 5 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/with_statement_binding_flow.js: -------------------------------------------------------------------------------- 1 | with ({ x: 1 }) { 2 | /**/ x; 3 | // ^ defined: 1 4 | } -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/computation_flow/with_statement_scope_shadowing_flow.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | with ({ x: 2 }) { 4 | /**/ x; 5 | // ^ defined: 3 6 | } 7 | 8 | /**/ x; 9 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/array.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | [0, x]; 6 | // ^ defined: 1 7 | 8 | // Flow out 9 | 10 | [y = 1, 11 | 0, y]; 12 | // ^ defined: 10 13 | 14 | /**/ y; 15 | // ^ defined: 10 16 | 17 | // Flow around 18 | 19 | /**/ x; 20 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/arrow_function.js: -------------------------------------------------------------------------------- 1 | // 2 | // READ ME 3 | // 4 | // This test does NOT test complex arguments. See the `binding` test dir. 5 | // 6 | 7 | let x = 1; 8 | 9 | // Flow In 10 | 11 | () => x; 12 | // ^ defined: 7 13 | 14 | () => { x }; 15 | // ^ defined: 7 16 | 17 | // Flow Out 18 | 19 | () => y = 1; 20 | 21 | /**/ y; 22 | // ^ defined: 23 | // y should not be defined here 24 | 25 | // Flow Around 26 | 27 | /**/ x; 28 | // ^ defined: 7 29 | 30 | // Flow In from Arg 31 | y => 32 | y + 1; 33 | // ^ defined: 31 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/assignment_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | let y = 2; 3 | let z = 3; 4 | 5 | // Flow in 6 | z = x; 7 | // ^ defined: 1 8 | 9 | // Flow around, update, and out 10 | 11 | x = (y = 3); 12 | 13 | /**/ x; 14 | // ^ defined: 1, 11 15 | 16 | /****/ y; 17 | // ^ defined: 2, 11 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/augmented_assignment_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | let y = 2; 3 | let z = 3; 4 | 5 | // Flow in 6 | z += x; 7 | // ^ defined: 1 8 | 9 | // Flow around and out 10 | 11 | y += 1; 12 | 13 | /**/ y; 14 | // ^ defined: 2, 11 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/await.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | await x; 5 | // ^ defined: 1 6 | 7 | // Flow around 8 | 9 | /**/ x; 10 | // ^ defined: 1 11 | 12 | // Flow out 13 | 14 | await y = 1; 15 | 16 | /**/ y; 17 | // ^ defined: 14 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/binary_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | /**/ x + x; 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | 8 | // Flow around 9 | 10 | /**/ x; 11 | // ^ defined: 1 12 | 13 | // Flow out 14 | 15 | x + (y = 1); 16 | 17 | /**/ y; 18 | // ^ defined: 15 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/booleans.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow around 4 | 5 | true; 6 | false; 7 | 8 | /**/ x; 9 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/call_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | let f = 2; 3 | 4 | // Flow in 5 | /**/ f(x); 6 | // ^ defined: 1 7 | // ^ defined: 2 8 | 9 | // Flow around 10 | 11 | /**/ x; 12 | // ^ defined: 1 13 | 14 | // Flow out 15 | 16 | (y = 1)( 17 | z = 2 18 | ); 19 | 20 | /**/ y; 21 | // ^ defined: 16 22 | 23 | /**/ z; 24 | // ^ defined: 17 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/comma.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | (1, x); 6 | // ^ defined: 1 7 | 8 | (y = 1, y); 9 | // ^ defined: 8 10 | 11 | // Flow out 12 | 13 | (1, z = 5); 14 | 15 | /**/ y; 16 | // ^ defined: 8 17 | /**/ z; 18 | // ^ defined: 13 19 | 20 | // Flow around 21 | 22 | /**/ x; 23 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/function.js: -------------------------------------------------------------------------------- 1 | // 2 | // READ ME 3 | // 4 | // This test does NOT test complex arguments. See the `binding` test dir. 5 | // 6 | 7 | let x = 1; 8 | 9 | // Flow In 10 | 11 | (function () { x; }); 12 | // ^ defined: 7 13 | 14 | // Flow Out 15 | 16 | (function () { y = 1; }); 17 | 18 | /**/ y; 19 | // ^ defined: 20 | // y should not be defined here 21 | 22 | // Flow Around 23 | 24 | /**/ x; 25 | // ^ defined: 7 26 | 27 | // Flow In from Arg 28 | (function (y) { 29 | /**/ y; 30 | // ^ defined: 28 31 | }); -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/member_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | /**/ x.foo; 6 | // ^ defined: 1 7 | 8 | // Flow out 9 | 10 | (y = 1).foo; 11 | 12 | /**/ y; 13 | // ^ defined: 10 14 | 15 | // Flow around 16 | 17 | /**/ x; 18 | // ^ defined: 1 19 | 20 | // Optional chain 21 | /**/ x?.foo 22 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/new_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | let f = 2; 3 | 4 | // Flow in 5 | /**/ new f(x); 6 | // ^ defined: 1 7 | // ^ defined: 2 8 | 9 | // Flow around 10 | 11 | /**/ x; 12 | // ^ defined: 1 13 | 14 | // Flow out 15 | 16 | new (y = 1)( 17 | z = 2 18 | ); 19 | 20 | /**/ y; 21 | // ^ defined: 16 22 | 23 | /**/ z; 24 | // ^ defined: 17 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/null.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow around 4 | 5 | null; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/number.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow around 4 | 5 | 5; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/object.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | { 6 | /**/[x]: x 7 | // ^ defined: 1 8 | // ^ defined: 1 9 | }; 10 | 11 | // Flow out 12 | 13 | { 14 | [y = 0]: 15 | /**/ (y, z = 0) 16 | // ^ defined: 14 17 | }; 18 | 19 | /**/ y; 20 | // ^ defined: 14 21 | 22 | /**/ z; 23 | // ^ defined: 15 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/parenthesized_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | /**/ (x); 5 | // ^ defined: 1 6 | 7 | // Flow out 8 | 9 | (y = 1); 10 | 11 | /**/ y; 12 | // ^ defined: 9 13 | 14 | // Flow around 15 | 16 | /**/ x; 17 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/regex.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow around 4 | 5 | /foo/; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/string.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow around 4 | 5 | "foo"; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/subscript_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | /**/ x[x]; 6 | // ^ defined: 1 7 | // ^ defined: 1 8 | 9 | // Flow out 10 | 11 | (y = 1)[ 12 | z = 1 13 | ]; 14 | 15 | /**/ y; 16 | // ^ defined: 11 17 | 18 | /**/ z; 19 | // ^ defined: 12 20 | 21 | // Flow around 22 | 23 | /**/ x; 24 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/super.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow around 4 | 5 | super; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/template_strings.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | `template ${x} string`; 6 | // ^ defined: 1 7 | 8 | `template ${y = 1} ${y} string`; 9 | // ^ defined: 8 10 | 11 | 12 | // Flow out 13 | 14 | /**/ y; 15 | // ^ defined: 8 16 | 17 | // Flow around 18 | 19 | /**/ x; 20 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/ternary_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | /**/ x ? x : x; 6 | // ^ defined: 1 7 | // ^ defined: 1 8 | // ^ defined: 1 9 | 10 | // Flow out 11 | 12 | (y = 1) ? 13 | /**/ (y, z = 1) : 14 | // ^ defined: 12 15 | /**/ (y, w = 1); 16 | // ^ defined: 12 17 | 18 | 19 | /**/ y; 20 | // ^ defined: 12 21 | 22 | /**/ z; 23 | // ^ defined: 13 24 | 25 | /**/ w; 26 | // ^ defined: 15 27 | 28 | // Flow around 29 | 30 | /**/ x; 31 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/this.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow around 4 | 5 | this; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/unary_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | /**/ -x; 6 | // ^ defined: 1 7 | 8 | // Flow out 9 | 10 | -(y = 1); 11 | 12 | /**/ y; 13 | // ^ defined: 10 14 | 15 | // Flow around 16 | 17 | /**/ x; 18 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/undefined.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow around 4 | 5 | undefined; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/update_expression.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | /**/ x++; 6 | // ^ defined: 1 7 | 8 | // Flow out 9 | 10 | --(y = 1); 11 | 12 | /**/ y; 13 | // ^ defined: 10 14 | 15 | // Flow around and update 16 | 17 | /**/ x; 18 | // ^ defined: 1, 5 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/variable.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | /**/ x; 6 | // ^ defined: 1 7 | 8 | // Flow around 9 | 10 | /**/ x; 11 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/expressions/yield_expression.js: -------------------------------------------------------------------------------- 1 | function* f() { 2 | let x = 1; 3 | 4 | // Flow in 5 | 6 | yield x; 7 | // ^ defined: 2 8 | 9 | // Flow out 10 | 11 | yield y = 1; 12 | 13 | /**/ y; 14 | // ^ defined: 11 15 | 16 | // Flow around 17 | 18 | /**/ x; 19 | // ^ defined: 2 20 | } -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/jsx/jsx_fragment.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow Around 4 | 5 | const el = <>; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/jsx/jsx_namespace_name.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow Around 4 | 5 | const el = ; 6 | 7 | /**/ x; 8 | // ^ defined: 1 9 | 10 | // Flow In 11 | 12 | let foo = { 13 | bar: { 14 | baz: 1 15 | } 16 | }; 17 | 18 | const el2 = ; 19 | // ^ defined: 12 20 | // ^ defined: 13 21 | // ^ defined: 14 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/jsx/jsx_text.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow Around 4 | 5 | const el = bar; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/binding/default_arguments_from_enclosing_scope.js: -------------------------------------------------------------------------------- 1 | let x = { bar: 0 }; 2 | 3 | function foo(y = x) { 4 | return y; 5 | } 6 | 7 | foo({ bar: 1 }).bar; 8 | // ^ defined: 1, 7 9 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/binding/default_arguments_from_other_arguments.js: -------------------------------------------------------------------------------- 1 | function foo(x, y = x) { 2 | return y; 3 | } 4 | 5 | foo({ bar: 1 }).bar; 6 | // ^ defined: 5 7 | 8 | foo({}, 9 | { bar: 2 }).bar; 10 | // ^ defined: 9 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/binding/destructuring_assignments.js: -------------------------------------------------------------------------------- 1 | let obj = { x: 1, y: { z: 2 } }; 2 | let { x: xval, y: yval } = obj; 3 | let x = xval; 4 | // ^ defined: 1, 2 5 | 6 | let y = yval; 7 | // ^ defined: 1, 2 8 | 9 | y.z; 10 | // ^ defined: 1 11 | 12 | let [w, 13 | q] = [1,2]; 14 | 15 | w; 16 | // ^ defined: 12 17 | 18 | q; 19 | // ^ defined: 13 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/binding/destructuring_assignments_with_defaults_from_enclosing_scope.js: -------------------------------------------------------------------------------- 1 | let x = { foo: 0 }; 2 | let [y, z = x] = [1]; 3 | 4 | z.foo; 5 | // ^ defined: 1 6 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/binding/destructuring_assignments_with_defaults_from_other_variables.js: -------------------------------------------------------------------------------- 1 | let [x, y = x] = [ // newline here distinguishes the object value from the vars 2 | { foo: 2 } 3 | ]; 4 | 5 | y.foo; 6 | // ^ defined: 2 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/binding/destructuring_parameters.js: -------------------------------------------------------------------------------- 1 | function foo({ x: xval }) { 2 | return xval; 3 | // ^ defined: 1 4 | } 5 | 6 | foo({ x: { y: 1 } }).y; 7 | // ^ defined: 6 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/binding/object_assignment_patterns.js: -------------------------------------------------------------------------------- 1 | let { x = 1 } = { "x": 5 }; 2 | 3 | x; 4 | // ^ defined: 1, 1 5 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/2141.js: -------------------------------------------------------------------------------- 1 | function bark() { 2 | console.log("Bark!"); 3 | } 4 | 5 | function meow() { 6 | console.log("Meow!"); 7 | } 8 | 9 | function speak() { 10 | bark(); 11 | // ^ defined: 1 12 | meow(); 13 | // ^ defined: 5 14 | } -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/2227.js: -------------------------------------------------------------------------------- 1 | class Cat { 2 | constructor(name, age) { 3 | this.name = name; 4 | this.age = age; 5 | } 6 | 7 | name() { 8 | return this.name; 9 | } 10 | 11 | age() { 12 | return this.age 13 | } 14 | } 15 | 16 | Cat; 17 | //^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/CommonJS_default_export_with_ES6_default_import.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | const f = 5; 4 | 5 | module.exports = f; 6 | 7 | /*--- path: b.js ---*/ 8 | 9 | import g from './a.js'; 10 | 11 | /**/ g; 12 | // ^ defined: 3, 5, 9 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/CommonJS_default_import_of_functions.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | module.exports = function () { 3 | 4 | }; 5 | 6 | /*--- path: b.js ---*/ 7 | let mod = require("./a.js"); 8 | 9 | /**/ mod; 10 | // ^ defined: 2, 7 11 | 12 | class Quux { 13 | bar() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/CommonJS_imports_and_exports_using_defaults/export_with_name_default_alias_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | module.exports = 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | module.exports = require("./a.js"); 8 | 9 | /*--- path: c.js ---*/ 10 | 11 | let bar = require("./b.js"); 12 | 13 | /**/ bar; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/CommonJS_imports_and_exports_using_defaults/export_with_name_default_alias_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | module.exports = 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | exports.foo = require("./a.js"); 8 | 9 | /*--- path: c.js ---*/ 10 | 11 | let { foo } = require("./b.js"); 12 | 13 | /**/ foo; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/CommonJS_imports_and_exports_using_defaults/export_with_name_nondefault_alias_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | exports.foo = 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | let { foo } = require("./a.js"); 8 | module.exports = foo; 9 | 10 | /*--- path: c.js ---*/ 11 | 12 | let bar = require("./b.js"); 13 | 14 | /**/ bar; 15 | // ^ defined: 3, 7, 8, 12 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/CommonJS_imports_and_exports_using_defaults/import_with_name_default_alias_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | module.exports = 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | let foo = require("./a.js"); 8 | 9 | /**/ foo; 10 | // ^ defined: 3, 7 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/ES6_imports_and_exports_using_the_name_or_alias_default/export_function_with_name_default_alias_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export default function foo() { }; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | export { default as default } from "./a.js"; 8 | 9 | /*--- path: c.js ---*/ 10 | 11 | import bar from "./b.js"; 12 | 13 | /**/ bar; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/ES6_imports_and_exports_using_the_name_or_alias_default/export_with_name_default_alias_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export default 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | export { default as default } from "./a.js"; 8 | 9 | /*--- path: c.js ---*/ 10 | 11 | import bar from "./b.js"; 12 | 13 | /**/ bar; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/ES6_imports_and_exports_using_the_name_or_alias_default/export_with_name_default_alias_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export default 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | export { default as foo } from "./a.js"; 8 | 9 | /*--- path: c.js ---*/ 10 | 11 | import { foo } from "./b.js"; 12 | 13 | /**/ foo; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/ES6_imports_and_exports_using_the_name_or_alias_default/export_with_name_nondefault_alias_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export let foo = 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | export { foo as default } from "./a.js"; 8 | 9 | /*--- path: c.js ---*/ 10 | 11 | import bar from "./b.js"; 12 | 13 | /**/ bar; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/ES6_imports_and_exports_using_the_name_or_alias_default/export_with_unaliased_name_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export default 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | export { default } from "./a.js"; 8 | 9 | /*--- path: c.js ---*/ 10 | 11 | import foo from "./b.js"; 12 | 13 | /**/ foo; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/ES6_imports_and_exports_using_the_name_or_alias_default/import_with_name_default_alias_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export default 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | import { default as foo } from "./a.js"; 8 | 9 | /**/ foo; 10 | // ^ defined: 3, 7 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/array_assignment_interrupts_scope.js: -------------------------------------------------------------------------------- 1 | let bar = {}; 2 | 3 | /**/ bar; 4 | // ^ defined: 1 5 | 6 | /**/ bar["one"] = 1; 7 | // ^ defined: 1 8 | 9 | /**/ bar; 10 | // ^ defined: 1 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/string_property_interrupts_scope.js: -------------------------------------------------------------------------------- 1 | let x = 42; 2 | 3 | let foo = { "strict": true }; 4 | 5 | /**/ x; 6 | // ^ defined: 1 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/bug_regressions/variable_resolves_to_module.js: -------------------------------------------------------------------------------- 1 | /* --- path: debug.js --- */ 2 | 3 | /**/ debug(42); 4 | // ^ defined: 5 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/class_declaration.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | 3 | } 4 | 5 | Foo; 6 | // ^ defined: 1 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/class_expression.js: -------------------------------------------------------------------------------- 1 | let Bar = 2 | class Foo { 3 | constructor() { 4 | Foo; 5 | // ^ defined: 2 6 | } 7 | }; 8 | 9 | Bar; 10 | // ^ defined: 1 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/class_expression_superclasses.js: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | constructor() { 3 | this.x = 5; 4 | } 5 | } 6 | 7 | let Bar = class extends Foo { 8 | constructor() { 9 | 10 | } 11 | } 12 | 13 | let bar = new Bar(); 14 | bar.x 15 | // ^ defined: 3 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/class_expression_this_field_access.js: -------------------------------------------------------------------------------- 1 | let Foo = class { 2 | constructor() { 3 | this.bar = 5; 4 | } 5 | }; 6 | 7 | let x = new Foo(); 8 | x.bar; 9 | // ^ defined: 3 10 | 11 | let Bar = class { 12 | constructor(x) { 13 | this.field = x; 14 | } 15 | } 16 | 17 | let bar = new Bar({ baz: 5 }); 18 | bar.field.baz 19 | // ^ defined: 17 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/field_declaration.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar; 3 | baz = 5; 4 | } 5 | 6 | let x = new Foo(); 7 | x.bar; 8 | // ^ defined: 2 9 | x.baz; 10 | // ^ defined: 3 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/function_class_this_field_access.js: -------------------------------------------------------------------------------- 1 | function Foo() { 2 | this.bar = 5; 3 | } 4 | 5 | let x = new Foo(); 6 | x.bar; 7 | // ^ defined: 2 8 | 9 | function Bar(x) { 10 | this.field = x; 11 | } 12 | 13 | let bar = new Bar({ baz: 5 }); 14 | bar.field.baz 15 | // ^ defined: 13 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/method_call_this_argument.js: -------------------------------------------------------------------------------- 1 | let x = { 2 | foo: { baz: 5 }, 3 | bar: function () { 4 | return this.foo; 5 | } 6 | }; 7 | 8 | x.bar().baz; 9 | // ^ defined: 2 10 | 11 | x["bar"]().baz; 12 | // ^ defined: 2 13 | 14 | let y = [ 15 | { baz: 5 }, 16 | function () { 17 | return this[0]; 18 | } 19 | ]; 20 | 21 | y[1]().baz; 22 | // ^ defined: 15 23 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/method_definition.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar(x) { 3 | return x; 4 | } 5 | } 6 | 7 | let obj = { field: 5 }; 8 | let y = new Foo(); 9 | y.bar; 10 | // ^ defined: 2 11 | y.bar(obj).field 12 | // ^ defined: 7 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/superclasses.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | constructor() { 3 | this.x = 5; 4 | } 5 | } 6 | 7 | class Bar extends Foo { 8 | constructor() { 9 | 10 | } 11 | } 12 | 13 | let bar = new Bar(); 14 | bar.x 15 | // ^ defined: 3 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/classes_and_instances/this_field_access.js: -------------------------------------------------------------------------------- 1 | class Foo { 2 | constructor() { 3 | this.bar = 5; 4 | } 5 | } 6 | 7 | let x = new Foo(); 8 | x.bar; 9 | // ^ defined: 3 10 | 11 | class Bar { 12 | constructor(x) { 13 | this.field = x; 14 | } 15 | } 16 | 17 | let bar = new Bar({ baz: 5 }); 18 | bar.field.baz 19 | // ^ defined: 17 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/compound_literals/arrays.js: -------------------------------------------------------------------------------- 1 | let arr = [{ x: 1 }, 2 | { x: 2 }]; 3 | let one = arr[1].x; 4 | // ^ defined: 1 5 | // ^ defined: 2 6 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/compound_literals/object_extend_method.js: -------------------------------------------------------------------------------- 1 | var obj = { 2 | x: 1, 3 | y: 2 4 | }; 5 | 6 | obj.extend({ 7 | z: 3 8 | }); 9 | 10 | let x = obj.x; 11 | // ^ defined: 2 12 | let y = obj.y; 13 | // ^ defined: 3 14 | let z = obj.z; 15 | // ^ defined: 7 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/control_flow_statements/dowhile.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | do { 4 | x = x * 2; 5 | // ^ defined: 1, 4, 6 6 | } while (x--); 7 | // ^ defined: 1, 4, 6 8 | 9 | const y = x; 10 | // ^ defined: 1, 4, 6 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/control_flow_statements/for.js: -------------------------------------------------------------------------------- 1 | var x = 1; 2 | 3 | for (let y = 2; 4 | x + y < 2; 5 | //^ defined: 1, 7, 13 6 | // ^ defined: 3, 7, 14 7 | y++, x--) { 8 | //^ defined: 3, 7, 14 9 | // ^ defined: 1, 7, 13 10 | alert(x + y); 11 | // ^ defined: 1, 7, 13 12 | // ^ defined: 3, 7, 14 13 | x = 2; 14 | y = 3; 15 | } 16 | 17 | const z = x - y; 18 | // ^ defined: 1, 7, 13 19 | // ^ defined: 3, 7, 14 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/control_flow_statements/forin.js: -------------------------------------------------------------------------------- 1 | var xs = [0,1,2]; 2 | 3 | for (x in xs) { 4 | // ^ defined: 1 5 | alert(x); 6 | // ^ defined: 1, 3 7 | var y = 0; 8 | } 9 | 10 | let z = y; 11 | // ^ defined: 7 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/control_flow_statements/if.js: -------------------------------------------------------------------------------- 1 | let x = 0; 2 | 3 | if (true) { 4 | var y = x; 5 | // ^ defined: 1 6 | } else if (true) { 7 | var y = x+1; 8 | // ^ defined: 1 9 | } else { 10 | var y = x-2; 11 | } 12 | 13 | const z = y; 14 | // ^ defined: 1, 4, 7, 10 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/control_flow_statements/try.js: -------------------------------------------------------------------------------- 1 | var x = 1; 2 | 3 | try { 4 | var y = 2; 5 | alert(x); 6 | // ^ defined: 1 7 | } catch (e) { 8 | const z = 3; 9 | alert(x, y, e); 10 | // ^ defined: 1 11 | // ^ defined: 4 12 | // ^ defined: 7 13 | } finally { 14 | let w = 4; 15 | alert(x, y, z); 16 | // ^ defined: 1 17 | // ^ defined: 4 18 | // ^ defined: 8 19 | } 20 | 21 | alert(w); 22 | // ^ defined: 14 23 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/control_flow_statements/while.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | while (x--) { 4 | // ^ defined: 1, 3, 5 5 | x = x * 2; 6 | // ^ defined: 1, 3, 5 7 | } 8 | 9 | const y = x; 10 | // ^ defined: 1, 3, 5 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/control_flow_statements/with.js: -------------------------------------------------------------------------------- 1 | with ({ x: 1, y: 2 }) { 2 | x + y; 3 | // ^ defined: 1 4 | // ^ defined: 1 5 | } 6 | 7 | let obj = { z: 3, 8 | w: 4 }; 9 | with (obj) { 10 | z + w; 11 | // ^ defined: 7 12 | // ^ defined: 8 13 | } 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/arguments_variable.js: -------------------------------------------------------------------------------- 1 | let x = { foo: 1 }; 2 | 3 | function f() { 4 | return arguments; 5 | } 6 | 7 | f(x)[0].foo; 8 | // ^ defined: 1 9 | 10 | function* g() { 11 | return arguments; 12 | } 13 | 14 | g(x)[0].foo; 15 | // ^ defined: 1 16 | 17 | let h = function () { 18 | return arguments; 19 | }; 20 | 21 | h(x)[0].foo; 22 | // ^ defined: 1 23 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/arrow_function_values_with_param_lists_and_block_bodies.js: -------------------------------------------------------------------------------- 1 | let a = { bar: 1 }; 2 | let b = { quux: 2 }; 3 | 4 | let foo = (x) => { 5 | b.quux; 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | return x; 9 | // ^ defined: 4 10 | }; 11 | 12 | foo(a).bar; 13 | // ^ defined: 1 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/arrow_function_values_with_param_lists_and_expr_bodies.js: -------------------------------------------------------------------------------- 1 | let a = { bar: 1 }; 2 | let b = { quux: 2 }; 3 | 4 | let foo = (x) => 5 | (b.quux, x); 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | // ^ defined: 4 9 | 10 | foo(a).bar; 11 | // ^ defined: 1 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/arrow_function_values_with_single_param_and_block_bodies.js: -------------------------------------------------------------------------------- 1 | let a = { bar: 1 }; 2 | let b = { quux: 2 }; 3 | 4 | let foo = x => { 5 | b.quux; 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | return x; 9 | // ^ defined: 4 10 | }; 11 | 12 | foo(a).bar; 13 | // ^ defined: 1 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/arrow_function_values_with_single_param_and_expr_bodies.js: -------------------------------------------------------------------------------- 1 | let a = { bar: 1 }; 2 | let b = { quux: 2 }; 3 | 4 | let foo = x => 5 | (b.quux, x); 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | // ^ defined: 4 9 | 10 | foo(a).bar; 11 | // ^ defined: 1 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/call_arguments.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | let y = 2; 3 | 4 | let z = foo(x, y++, y); 5 | // ^ defined: 1 6 | // ^ defined: 2 7 | // ^ defined: 2, 4 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/function_declarations.js: -------------------------------------------------------------------------------- 1 | let a = { bar: 1 }; 2 | let b = { quux: 2 }; 3 | 4 | function foo(x) { 5 | b.quux; 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | return x; 9 | // ^ defined: 4 10 | } 11 | 12 | foo(a).bar; 13 | // ^ defined: 1 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/function_values.js: -------------------------------------------------------------------------------- 1 | let a = { bar: 1 }; 2 | let b = { quux: 2 }; 3 | 4 | let foo = function bar(x) { 5 | b.quux; 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | bar; 9 | // ^ defined: 4 10 | return x; 11 | // ^ defined: 4 12 | }; 13 | 14 | foo(a).bar; 15 | // ^ defined: 1 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/generator_function_declarations.js: -------------------------------------------------------------------------------- 1 | let a = { bar: 1 }; 2 | let b = { quux: 2 }; 3 | 4 | function* foo(x) { 5 | b.quux; 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | yield x; 9 | // ^ defined: 4 10 | } 11 | 12 | foo(a).bar; 13 | // ^ defined: 1 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/functions_and_calls/generator_function_values.js: -------------------------------------------------------------------------------- 1 | let a = { bar: 1 }; 2 | let b = { quux: 2 }; 3 | 4 | let foo = function* bar(x) { 5 | b.quux; 6 | // ^ defined: 2 7 | // ^ defined: 2 8 | bar; 9 | // ^ defined: 4 10 | yield x; 11 | // ^ defined: 4 12 | }; 13 | 14 | foo(a).bar; 15 | // ^ defined: 1 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/hoisting/basic_functions.js: -------------------------------------------------------------------------------- 1 | /**/ foo; 2 | // ^ defined: 7 3 | 4 | /**/ bar; 5 | // ^ defined: 8 6 | 7 | function foo() { } 8 | function* bar() { } -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/hoisting/imports.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export let foo = 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | /**/ bar; 8 | // ^ defined: 3, 10 9 | 10 | import { foo as bar } from "./a.js"; -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/export_with_name_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | export default function foo() { } 4 | 5 | /*--- path: index2.js ---*/ 6 | 7 | let bar = await import("./index.js"); 8 | 9 | /**/ bar.default; 10 | // ^ defined: 7 11 | // ^ defined: 3 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/export_with_name_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | export function foo() { } 4 | 5 | /*--- path: index2.js ---*/ 6 | 7 | let { foo } = await import("./index.js"); 8 | 9 | /**/ foo; 10 | // ^ defined: 3, 7 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/field_on_default_object_import_of_exported_default_object.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | export default { 4 | foo: 1 5 | }; 6 | 7 | /*--- path: index2.js ---*/ 8 | 9 | let mod = await import("./index.js"); 10 | 11 | mod.default.foo; 12 | // ^ defined: 4 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/field_on_default_object_import_of_exported_nondefault_name.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | export function foo() { } 4 | 5 | /*--- path: index2.js ---*/ 6 | 7 | let mod = await import("./index.js"); 8 | 9 | mod.foo; 10 | // ^ defined: 3 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/import_with_name_default_alias_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export default function foo() { } 4 | 5 | /*--- path: index.js ---*/ 6 | 7 | import { default as bar } from "./a.js"; 8 | 9 | export { bar }; 10 | 11 | /*--- path: index2.js ---*/ 12 | 13 | let { bar } = await import("./index.js"); 14 | 15 | /**/ bar; 16 | // ^ defined: 3, 7, 9, 13 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/reexport_with_name_default_alias_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export default function foo() { } 4 | 5 | /*--- path: index.js ---*/ 6 | 7 | export { default as default } from "./a.js"; 8 | 9 | /*--- path: index2.js ---*/ 10 | 11 | let bar = await import("./index.js"); 12 | 13 | /**/ bar.default; 14 | // ^ defined: 11 15 | // ^ defined: 3, 7 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/reexport_with_name_default_alias_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export default function foo() { } 4 | 5 | /*--- path: index.js ---*/ 6 | 7 | export { default as bar } from "./a.js"; 8 | 9 | /*--- path: index2.js ---*/ 10 | 11 | let { bar } = await import("./index.js"); 12 | 13 | /**/ bar; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/reexport_with_name_nondefault_alias_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export function foo() { } 4 | 5 | /*--- path: index.js ---*/ 6 | 7 | export { foo as default } from "./a.js"; 8 | 9 | /*--- path: index2.js ---*/ 10 | 11 | let bar = await import("./index.js"); 12 | 13 | /**/ bar.default; 14 | // ^ defined: 11 15 | // ^ defined: 3, 7 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/reexport_with_name_nondefault_alias_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export function foo() { } 4 | 5 | /*--- path: index.js ---*/ 6 | 7 | export { foo as bar } from "./a.js"; 8 | 9 | /*--- path: index2.js ---*/ 10 | 11 | let { bar } = await import("./index.js"); 12 | 13 | /**/ bar; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_ES6_export/reexport_with_unaliased_name.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | export function foo() { } 4 | 5 | /*--- path: index.js ---*/ 6 | 7 | export { foo } from "./a.js"; 8 | 9 | /*--- path: index2.js ---*/ 10 | 11 | let { foo } = await import("./index.js"); 12 | 13 | /**/ foo; 14 | // ^ defined: 3, 7, 11 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_export/field_on_default_object_import_of_exported_default_object.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | module.exports = { 4 | foo: 1 5 | }; 6 | 7 | /*--- path: index2.js ---*/ 8 | 9 | let mod = require("./index.js"); 10 | 11 | mod.foo; 12 | // ^ defined: 4 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_export/field_on_default_object_import_of_exported_default_object_field.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | module.exports.foo = 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | let mod = require("./a.js"); 8 | 9 | mod.foo; 10 | // ^ defined: 3 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/CommonJS_import_export/field_on_default_object_import_of_exported_nondefault_name.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | exports.foo = function () { }; 4 | 5 | /*--- path: index2.js ---*/ 6 | 7 | let mod = require("./index.js"); 8 | 9 | mod.foo; 10 | // ^ defined: 3 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_CommonJS_export/export_with_name_default.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | module.exports = function foo() { }; 4 | 5 | /*--- path: index2.js ---*/ 6 | 7 | import bar from "./index.js"; 8 | 9 | /**/ bar; 10 | // ^ defined: 3, 7 11 | 12 | /*--- path: index3.js ---*/ 13 | 14 | let bar = await import("./index.js"); 15 | 16 | /**/ bar.default; 17 | // ^ defined: 14 18 | // ^ defined: 3 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_CommonJS_export/export_with_name_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | exports.foo = function () { }; 4 | 5 | /*--- path: index2.js ---*/ 6 | 7 | import { foo } from "./index.js"; 8 | 9 | /**/ foo; 10 | // ^ defined: 3, 7 11 | 12 | /*--- path: index3.js ---*/ 13 | 14 | let { foo } = await import("./index.js"); 15 | 16 | /**/ foo; 17 | // ^ defined: 3, 14 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_CommonJS_export/field_on_default_object_import_of_exported_default_object.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | module.exports = { 4 | foo: 1 5 | }; 6 | 7 | /*--- path: index2.js ---*/ 8 | 9 | import mod from "./index.js"; 10 | 11 | mod.foo; 12 | // ^ defined: 4 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_CommonJS_export/field_on_default_object_import_of_exported_default_object_field.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | module.exports.foo = 1; 4 | 5 | /*--- path: b.js ---*/ 6 | 7 | import { foo } from "./a.js"; 8 | 9 | /**/ foo; 10 | // ^ defined: 3, 7 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_CommonJS_export/field_on_default_object_import_of_exported_nondefault_name.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | exports.foo = function () { }; 4 | 5 | /*--- path: index2.js ---*/ 6 | 7 | import mod from "./index.js"; 8 | 9 | mod.foo; 10 | // ^ defined: 3 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_CommonJS_export/import_with_name_default_alias_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | module.exports = function foo() { }; 4 | 5 | /*--- path: index.js ---*/ 6 | 7 | let mod = require("./a.js"); 8 | exports.bar = mod; 9 | 10 | /*--- path: index2.js ---*/ 11 | 12 | import { bar } from "./index.js"; 13 | 14 | /**/ bar; 15 | // ^ defined: 3, 7, 8, 12 16 | 17 | /*--- path: index3.js ---*/ 18 | 19 | let { bar } = await import("./index.js"); 20 | 21 | /**/ bar; 22 | // ^ defined: 3, 7, 8, 19 23 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_CommonJS_export/reexport_with_name_nondefault_alias_nondefault.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | exports.foo = function () { }; 4 | 5 | /*--- path: index.js ---*/ 6 | 7 | let mod = require("./a.js"); 8 | exports.bar = mod.foo; 9 | 10 | /*--- path: index2.js ---*/ 11 | 12 | import { bar } from "./index.js"; 13 | 14 | /**/ bar; 15 | // ^ defined: 3, 8, 12 16 | 17 | /*--- path: index3.js ---*/ 18 | 19 | let { bar } = await import("./index.js"); 20 | 21 | /**/ bar; 22 | // ^ defined: 3, 8, 19 23 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_CommonJS_export/reexport_with_unaliased_name.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | exports.foo = function () { }; 4 | /*--- path: index.js ---*/ 5 | 6 | let mod = require("./a.js"); 7 | exports.foo = mod.foo; 8 | 9 | /*--- path: index2.js ---*/ 10 | 11 | import { foo } from "./index.js"; 12 | 13 | /**/ foo; 14 | // ^ defined: 3, 7, 11 15 | 16 | /*--- path: index3.js ---*/ 17 | 18 | let { foo } = await import("./index.js"); 19 | 20 | /**/ foo; 21 | // ^ defined: 3, 7, 18 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_export/field_on_default_object_import_of_exported_default_object.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | export default { 4 | foo: 1 5 | }; 6 | 7 | /*--- path: index2.js ---*/ 8 | 9 | import mod from "./index.js"; 10 | 11 | mod.foo; 12 | // ^ defined: 4 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/ES6_import_export/field_on_default_object_import_of_exported_nondefault_name.js: -------------------------------------------------------------------------------- 1 | /*--- path: index.js ---*/ 2 | 3 | export function foo() { } 4 | 5 | /*--- path: index2.js ---*/ 6 | 7 | import mod from "./index.js"; 8 | 9 | mod.foo; 10 | // ^ defined: 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/commonjs_imports_and_exports.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | exports.foo = 1; 4 | 5 | module.exports = { 6 | /**/ bar: 2 7 | }; 8 | 9 | /*--- path: b.js ---*/ 10 | 11 | const mod1 = require("./a.js"); 12 | 13 | mod1.foo; 14 | // ^ defined: 3 15 | 16 | mod1.bar; 17 | // ^ defined: 6 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/import_function.js: -------------------------------------------------------------------------------- 1 | /*--- path: a.js ---*/ 2 | 3 | exports.foo = 2; 4 | module.exports = 1; 5 | 6 | /*--- path: b.js ---*/ 7 | 8 | let mod = await import("./a.js"); 9 | 10 | mod.foo; 11 | // ^ defined: 3 12 | 13 | mod.default; 14 | // ^ defined: 3, 4 15 | // !!!! TODO 3 is here because the `exports.foo` on line 3 also defines 16 | // the default object. this is a current limitation of the import/export 17 | // system to support CommonJS behavior 18 | 19 | mod.default.foo; 20 | // ^ defined: 3 21 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/imports_and_exports/variable_visible_through_nonbinding_import.js: -------------------------------------------------------------------------------- 1 | let x = 42; 2 | 3 | import "./foo"; 4 | 5 | /**/ x; 6 | // ^ defined: 1 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/simple_expressions/comma.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | let y = (1, x); 3 | // ^ defined: 1 4 | 5 | let y = (1, x = 5); 6 | let z = x; 7 | // ^ defined: 1, 5 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/simple_expressions/template_strings.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | let y = `template ${ x } string`; 4 | // ^ defined: 1 5 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/simple_expressions/ternary.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | let y = true ? x++ : 2; 3 | let z = x; 4 | // ^ defined: 1, 2 5 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/old/simple_expressions/variables.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | const y = 2; 3 | 4 | var z = x + y; 5 | // ^ defined: 1 6 | // ^ defined: 2 7 | 8 | let w = z; 9 | // ^ defined: 1, 2, 4 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/patterns/function_declaration_formal_parameter_patterns.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow In and Out To Body 4 | 5 | function foo(y = x, [z] = arr) { 6 | // ^ defined: 1 7 | /**/ y; 8 | // ^ defined: 5, 1 9 | /**/ z; 10 | // ^ defined: 5 11 | } 12 | 13 | // Flow Out 14 | 15 | /**/ z; 16 | // ^ defined: -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/patterns/method_declaration_formal_parameter_patterns.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow In and Out To Body 4 | 5 | class Foo { 6 | foo(y = x, [z] = arr) { 7 | // ^ defined: 1 8 | /**/ y; 9 | // ^ defined: 6, 1 10 | /**/ z; 11 | // ^ defined: 6 12 | } 13 | } 14 | 15 | // Flow Out 16 | 17 | /**/ z; 18 | // ^ defined: -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/debugger_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | debugger; 4 | 5 | // Flow around 6 | 7 | /**/ x; 8 | // ^ defined: 1 9 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/do_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | do { 6 | /**/ x; 7 | // ^ defined: 1 8 | /**/ y; 9 | // ^ defined: 11 10 | z = 1; 11 | } while ((x, y = 5)); 12 | // ^ defined: 1 13 | 14 | // Flow out 15 | 16 | /**/ y; 17 | // ^ defined: 11 18 | 19 | /**/ z; 20 | // ^ defined: 10 21 | 22 | // Flow around 23 | 24 | /**/ x; 25 | // ^ defined: 1 26 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/empty_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | ; 4 | 5 | // Flow around 6 | 7 | /**/ x; 8 | // ^ defined: 1 9 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/for_in_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | for (let y in (x, 1)) { 6 | // ^ defined: 1 7 | /**/ x; 8 | // ^ defined: 1 9 | /**/ y; 10 | // ^ defined: 5 11 | z = 1; 12 | } 13 | 14 | // Flow out 15 | 16 | /**/ y; 17 | // ^ defined: 5 18 | 19 | /**/ z; 20 | // ^ defined: 11 21 | 22 | // Flow around 23 | 24 | /**/ x; 25 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/hash_bang_line.js: -------------------------------------------------------------------------------- 1 | #! foo 2 | let x = 1; 3 | 4 | /**/ x; 5 | // ^ defined: 2 6 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/if_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | // TODO NOW add flow into the condition too 6 | if (/**/ x) { 7 | // ^ defined: 1 8 | /**/ x; 9 | // ^ defined: 1 10 | y = 2; 11 | } else if (x) { 12 | // ^ defined: 1 13 | /**/ x; 14 | // ^ defined: 1 15 | y = 2; 16 | } else { 17 | /**/ x; 18 | // ^ defined: 1 19 | y = 2; 20 | } 21 | 22 | // Flow out 23 | 24 | /**/ y; 25 | // ^ defined: 10, 15, 19 26 | 27 | // Flow around 28 | 29 | /**/ x; 30 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/import_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow Out 4 | 5 | import * as y from "mod"; 6 | import { z } from "mod"; 7 | import { y as w } from "mod"; 8 | import q from "mod"; 9 | 10 | /**/ y; 11 | // ^ defined: 5 12 | 13 | /**/ z; 14 | // defined: 6 15 | 16 | /**/ w; 17 | // defined: 7 18 | 19 | /**/ q; 20 | // defined: 8 21 | 22 | // Flow Around 23 | 24 | /**/ x; 25 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/label_continue_break_statements.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | outer: while (t) { 4 | while (t) { 5 | break outer; 6 | // ^ defined: 3 7 | } 8 | continue outer; 9 | // ^ defined: 3 10 | } 11 | 12 | // Flow around 13 | 14 | /**/ x; 15 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/label_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | label: x, y = 1; 6 | // ^ defined: 1 7 | 8 | // Flow out 9 | 10 | /**/ y; 11 | // ^ defined: 5 12 | 13 | // Flow around 14 | 15 | /**/ x; 16 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/lexical_declaration_basic_no_destructuring.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | /**/ x; 3 | // ^ defined: 1 4 | 5 | // Flow in 6 | let y = x; 7 | // ^ defined: 1 8 | 9 | // Flow around 10 | 11 | /**/ x; 12 | // ^ defined: 1 13 | 14 | // Shadowing 15 | 16 | let x = 2; 17 | /**/ x; 18 | // ^ defined: 16 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/return_statement.js: -------------------------------------------------------------------------------- 1 | function* f() { 2 | let x = 1; 3 | 4 | // Flow in 5 | 6 | return x; 7 | // ^ defined: 2 8 | 9 | // Flow out 10 | 11 | return y = 1; 12 | 13 | /**/ y; 14 | // ^ defined: 11 15 | 16 | // Flow around 17 | 18 | /**/ x; 19 | // ^ defined: 2 20 | } -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/statement_block.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | { 5 | /**/ x; 6 | // ^ defined: 1 7 | } 8 | 9 | // Flow around 10 | 11 | /**/ x; 12 | // ^ defined: 1 13 | 14 | // Flow out 15 | 16 | { 17 | let y = 1; 18 | } 19 | 20 | /**/ y; 21 | // ^ defined: 17 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/switch_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | switch (x) { 6 | // ^ defined: 1 7 | case 0: 8 | /**/ x; 9 | // ^ defined: 1 10 | y = 2; 11 | default: 12 | /**/ x; 13 | // ^ defined: 1 14 | y = 2; 15 | } 16 | 17 | // Flow out 18 | 19 | /**/ y; 20 | // ^ defined: 10, 14 21 | 22 | // Flow around 23 | 24 | /**/ x; 25 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/throw_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow In 4 | throw x, y = 1; 5 | // ^ defined: 1 6 | 7 | // Flow Out 8 | 9 | /**/ y; 10 | // ^ defined: 4 11 | 12 | // Flow around 13 | 14 | /**/ x; 15 | // ^ defined: 1 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/try_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | try { 6 | /**/ x; 7 | // ^ defined: 1 8 | y = 1; 9 | } catch (e) { 10 | /**/ e 11 | // ^ defined: 9 12 | /**/ y; 13 | // ^ defined: 8 14 | y = 1; 15 | } finally { 16 | /**/ x; 17 | // ^ defined: 1 18 | /**/ y; 19 | // ^ defined: 8, 14 20 | y = 1; 21 | } 22 | 23 | // Flow out 24 | 25 | /**/ y; 26 | // ^ defined: 8, 14, 20 27 | 28 | // Flow around 29 | 30 | /**/ x; 31 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/variable_declaration_basic_no_destructuring.js: -------------------------------------------------------------------------------- 1 | var x = 1; 2 | /**/ x; 3 | // ^ defined: 1 4 | 5 | // Flow in 6 | var y = x; 7 | // ^ defined: 1 8 | 9 | // Flow around 10 | 11 | /**/ x; 12 | // ^ defined: 1 13 | 14 | // Shadowing 15 | 16 | var x = 2; 17 | /**/ x; 18 | // ^ defined: 16 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/while_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | while ((x, y = 5)) { 6 | // ^ defined: 1 7 | /**/ x; 8 | // ^ defined: 1 9 | /**/ y; 10 | // ^ defined: 5 11 | z = 1; 12 | } 13 | 14 | // Flow out 15 | 16 | /**/ y; 17 | // ^ defined: 5 18 | 19 | /**/ z; 20 | // ^ defined: 11 21 | 22 | // Flow around 23 | 24 | /**/ x; 25 | // ^ defined: 1 26 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-javascript/test/statements/with_statement.js: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow in 4 | 5 | with ((y = 1, x)) { 6 | // ^ defined: 1 7 | /**/ x; 8 | // ^ defined: 1 9 | /**/ y; 10 | // ^ defined: 5 11 | z = 1; 12 | } 13 | 14 | // Flow out 15 | 16 | /**/ y; 17 | // ^ defined: 5 18 | 19 | /**/ z; 20 | // ^ defined: 11 21 | 22 | // Flow around 23 | 24 | /**/ x; 25 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | /Cargo.lock 3 | /target 4 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/src/builtins.cfg: -------------------------------------------------------------------------------- 1 | [globals] 2 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/src/builtins.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/stack-graphs/d0b59479b92fc29e9f56cfc20efdfba7a9b6443c/languages/tree-sitter-stack-graphs-python/src/builtins.py -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/attributes.py: -------------------------------------------------------------------------------- 1 | a = 1 2 | 3 | a.b = 2 4 | 5 | a.c.d = 5 6 | 7 | print a.b 8 | # ^ defined: 1 9 | # ^ defined: 3 10 | 11 | print a.c, a.c.d 12 | # ^ defined: 1 13 | # ^ defined: 14 | # ^ defined: 5 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/blocks.py: -------------------------------------------------------------------------------- 1 | def f(): 2 | if a: 3 | b = 1 4 | else: 5 | c = 2 6 | 7 | print b, c 8 | # ^ defined: 3 9 | # ^ defined: 5 10 | 11 | class G: 12 | if d: 13 | e = 1 14 | 15 | print e 16 | # ^ defined: 13 17 | 18 | print b, c, e 19 | # ^ defined: 20 | # ^ defined: 21 | # ^ defined: 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/chained_functions.py: -------------------------------------------------------------------------------- 1 | class A: 2 | w = 1 3 | x = 2 4 | y = 3 5 | z = 4 6 | 7 | def get_a(): 8 | return A 9 | def get_b(): 10 | return get_a() 11 | def get_c(): 12 | return get_b() 13 | def get_d(): 14 | return get_c() 15 | def get_e(): 16 | return get_d() 17 | def get_f(): 18 | return get_e() 19 | 20 | g = get_f(A) 21 | print g.x, g.y 22 | # ^ defined: 3 23 | # ^ defined: 4 24 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/class_members.py: -------------------------------------------------------------------------------- 1 | a = 1 2 | 3 | class B: 4 | c = a 5 | # ^ defined: 1 6 | 7 | def d(self): 8 | return self.c 9 | 10 | class E: 11 | f = a 12 | # ^ defined: 1 13 | 14 | print B.c 15 | # ^ defined: 3 16 | # ^ defined: 1, 4 17 | 18 | print B.d(1) 19 | # ^ defined: 7 20 | 21 | print B.a, E.a 22 | # ^ defined: 23 | # ^ defined: 24 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/decorators.py: -------------------------------------------------------------------------------- 1 | from a import deprecated 2 | from b import ignore_warnings 3 | 4 | class A: 5 | @deprecated 6 | # ^ defined: 1 7 | @ignore_warnings.all 8 | # ^ defined: 2 9 | def b(self): 10 | pass 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/exceptions.py: -------------------------------------------------------------------------------- 1 | try: 2 | print() 3 | except Exception as e: 4 | x = e 5 | # ^ defined: 3 6 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imported_functions.py: -------------------------------------------------------------------------------- 1 | #------ path: a.py ------# 2 | 3 | def foo(x): 4 | return x 5 | 6 | #------ path: b.py ------# 7 | 8 | class A: 9 | bar = 1 10 | 11 | #------ path: main.py ---------# 12 | 13 | from a import * 14 | from b import * 15 | 16 | foo(A).bar 17 | # ^ defined: 9 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_from_module_a_submodule.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/bar.py --- 2 | 3 | BAR = 42 4 | 5 | # --- path: test.py --- 6 | 7 | from foo import bar 8 | 9 | bar.BAR 10 | # ^ defined: 7, 3 11 | # ^ defined: 3 12 | 13 | foo 14 | # ^ defined: 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_from_module_a_value.py: -------------------------------------------------------------------------------- 1 | # --- path: foo.py --- 2 | 3 | FOO = 42 4 | 5 | # --- path: test.py --- 6 | 7 | from foo import FOO 8 | 9 | FOO 10 | # ^ defined: 7, 3 11 | 12 | foo 13 | # ^ defined: 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_from_module_a_value_aliased.py: -------------------------------------------------------------------------------- 1 | # --- path: foo.py --- 2 | 3 | FOO = 42 4 | 5 | # --- path: test.py --- 6 | 7 | from foo import FOO as QUX 8 | 9 | QUX 10 | # ^ defined: 7, 3 11 | 12 | FOO 13 | # ^ defined: 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_from_module_wildcard.py: -------------------------------------------------------------------------------- 1 | # --- path: foo.py --- 2 | 3 | FOO = 42 4 | 5 | # --- path: test.py --- 6 | 7 | from foo import * 8 | 9 | FOO 10 | # ^ defined: 3 11 | 12 | foo 13 | # ^ defined: 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_from_submodule_a_value.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/bar.py --- 2 | 3 | BAR = 42 4 | 5 | # --- path: test.py --- 6 | 7 | from foo.bar import BAR 8 | 9 | BAR 10 | # ^ defined: 7, 3 11 | 12 | foo 13 | # ^ defined: 14 | 15 | bar 16 | # ^ defined: 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_from_super_package_a_value.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/__init__.py --- 2 | 3 | FOO = 42 4 | 5 | # --- path: foo/bar/test.py --- 6 | 7 | from .. import FOO 8 | 9 | FOO 10 | # ^ defined: 7, 3 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_from_super_package_submodule_a_value.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/bar.py --- 2 | 3 | BAR = 42 4 | 5 | # --- path: foo/baz/test.py --- 6 | 7 | from ..bar import BAR 8 | 9 | BAR 10 | # ^ defined: 7, 3 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_from_this_package_a_value.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/__init__.py --- 2 | 3 | FOO = 42 4 | 5 | # --- path: foo/test.py --- 6 | 7 | from . import FOO 8 | 9 | FOO 10 | # ^ defined: 7, 3 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_from_this_package_submodule_a_value.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/bar.py --- 2 | 3 | BAR = 42 4 | 5 | # --- path: foo/test.py --- 6 | 7 | from .bar import BAR 8 | 9 | BAR 10 | # ^ defined: 7, 3 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_module.py: -------------------------------------------------------------------------------- 1 | # --- path: foo.py --- 2 | 3 | FOO = 42 4 | 5 | # --- path: test.py --- 6 | 7 | import foo 8 | 9 | foo.FOO 10 | # ^ defined: 7, 3 11 | # ^ defined: 3 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_module_aliased.py: -------------------------------------------------------------------------------- 1 | # --- path: foo.py --- 2 | 3 | FOO = 42 4 | 5 | # --- path: test.py --- 6 | 7 | import foo as qux 8 | 9 | qux.FOO 10 | # ^ defined: 7, 3 11 | # ^ defined: 3 12 | 13 | foo 14 | # ^ defined: 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_submodule.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/bar.py --- 2 | 3 | BAR = 42 4 | 5 | # --- path: test.py --- 6 | 7 | import foo.bar 8 | 9 | foo.bar.BAR 10 | # ^ defined: 7 11 | # ^ defined: 7, 3 12 | # ^ defined: 3 13 | 14 | bar 15 | # ^ defined: 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/import_submodule_aliased.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/bar.py --- 2 | 3 | BAR = 42 4 | 5 | # --- path: test.py --- 6 | 7 | import foo.bar as qux 8 | 9 | qux.BAR 10 | # ^ defined: 7, 3 11 | # ^ defined: 3 12 | 13 | foo 14 | # ^ defined: 15 | 16 | bar 17 | # ^ defined: 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/relative_import_resolves_to_itself.py.skip: -------------------------------------------------------------------------------- 1 | # --- path: foo/__init__.py --- 2 | from . import bar 3 | # ^ defined: 6 4 | 5 | # --- path: foo/bar/__init__.py --- 6 | BAR = 'b' 7 | 8 | # --- path: main.py --- 9 | from foo import bar 10 | # ^ defined: 6 11 | 12 | bar.BAR 13 | # ^ defined: 9, 6 14 | # ^ defined: 6 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/imports/require_explicit_submodule_import.py.skip: -------------------------------------------------------------------------------- 1 | # --- path: foo/__init__.py --- 2 | 3 | FOO = 42 4 | 5 | # --- path: foo/bar.py --- 6 | 7 | BAR = 42 8 | 9 | # --- path: test.py --- 10 | 11 | import foo 12 | 13 | foo.FOO 14 | # ^ defined: 11, 3 15 | # ^ defined: 3 16 | 17 | foo.bar 18 | # ^ defined: 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/lambdas.py: -------------------------------------------------------------------------------- 1 | sorted([1, 2, 3], key=lambda x: x) 2 | # ^ defined: 1 3 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/loops.py: -------------------------------------------------------------------------------- 1 | class Node3: 2 | value = 3 3 | class Node2: 4 | value = 2 5 | next = Node3 6 | class Node1: 7 | value = 1 8 | next = Node2 9 | 10 | def linked_list_search(l, item): 11 | node = l 12 | while node: 13 | if node.value == item: 14 | return node 15 | # ^ defined: 10, 11, 16 16 | node = node.next 17 | 18 | linked_list_search(Node1, 5).value 19 | # ^ defined: 6 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/nested_functions.py: -------------------------------------------------------------------------------- 1 | def outer(a): 2 | def inner(b): 3 | pass 4 | 5 | inner(1) 6 | # ^ defined: 2 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/not_a_method.py: -------------------------------------------------------------------------------- 1 | class Foo: 2 | a = 1 3 | 4 | def first_method(self): 5 | self.a 6 | # ^ defined: 2 7 | 8 | def second_method(self): 9 | self.a 10 | # ^ defined: 2 11 | 12 | # First argument here is not self 13 | def not_a_method(not_self): 14 | return not_self.a 15 | # ^ defined: 16 | 17 | 18 | def function(self): 19 | self.a 20 | # ^ defined: 21 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/redundant_reexport.py: -------------------------------------------------------------------------------- 1 | #--- path: a/__init__.py ---# 2 | 3 | from . import child 4 | 5 | #--- path: a/child.py ---- 6 | 7 | def f(): 8 | pass 9 | 10 | #--- path: main.py ---# 11 | 12 | import a 13 | 14 | print a.child.f() 15 | # ^ defined: 7 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/root_path.py: -------------------------------------------------------------------------------- 1 | # ------ path: foo/bar/module.py -----------# 2 | # ------ global: ROOT_PATH=foo/bar -----------# 3 | 4 | foo = 42 5 | 6 | # ------ path: foo/bar/baz/module.py -----------# 7 | # ------ global: ROOT_PATH=foo/bar -----------# 8 | 9 | bar = "hello" 10 | 11 | # ------ path: foo/bar/main.py -------------# 12 | # ------ global: ROOT_PATH=foo/bar -----------# 13 | 14 | from module import foo 15 | from baz.module import bar 16 | 17 | print(foo) 18 | # ^ defined: 4, 14 19 | 20 | print(bar) 21 | # ^ defined: 9, 15 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/self.py: -------------------------------------------------------------------------------- 1 | class Foo: 2 | a = 1 3 | 4 | def mathod_1(self): 5 | return self.a 6 | # ^ defined: 2 7 | 8 | # Self can be named anything 9 | def method_2(actually_self): 10 | return actually_self.a 11 | # ^ defined: 2 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/statement_bindings.py: -------------------------------------------------------------------------------- 1 | import a.b 2 | import c.d 3 | 4 | with a as x, c as y: 5 | print x.b, y.d 6 | # ^ defined: 1, 4 7 | # ^ defined: 1 8 | # ^ defined: 2, 4 9 | # ^ defined: 2 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/superclasses.py: -------------------------------------------------------------------------------- 1 | class A: 2 | def __init__(self): 3 | self.some_attr = 2 4 | 5 | def some_method(self): 6 | print self 7 | 8 | class B(A): 9 | def method2(self): 10 | print self.some_attr, self.some_method() 11 | # ^ defined: 3 12 | # ^ defined: 5, 14 13 | 14 | def some_method(self): 15 | pass 16 | 17 | def other(self): 18 | super().some_method() 19 | # ^ defined: 5 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/test.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/github/stack-graphs/d0b59479b92fc29e9f56cfc20efdfba7a9b6443c/languages/tree-sitter-stack-graphs-python/test/test.py -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-python/test/wildcard_import.py: -------------------------------------------------------------------------------- 1 | #------ path: one/two.py ------# 2 | 3 | a = 1 4 | b = 2 5 | 6 | #------ path: one/three.py ------# 7 | 8 | b = 3 9 | c = 4 10 | 11 | #------ path: main.py ---------# 12 | 13 | from one.two import * 14 | from one.three import * 15 | 16 | print a 17 | # ^ defined: 3 18 | print b 19 | # ^ defined: 8 20 | print c 21 | # ^ defined: 9 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/.gitignore: -------------------------------------------------------------------------------- 1 | /*.html 2 | /Cargo.lock 3 | /node_modules 4 | /package-lock.json 5 | /target 6 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/src/builtins.cfg: -------------------------------------------------------------------------------- 1 | [globals] 2 | PROJECT_NAME= 3 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/base/cannot-resolve-field-in-shadowed-object.ts.skip: -------------------------------------------------------------------------------- 1 | let x = { 2 | f: 11 3 | }; 4 | 5 | { 6 | let x = { 7 | }; 8 | 9 | x.f; 10 | //^ defined: 6 11 | // ^ defined: 12 | } 13 | 14 | export {}; 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/base/for-var-scoped-in-file-and-visible-inside-function.ts: -------------------------------------------------------------------------------- 1 | for(var x = 0; x < 42; x++) { 2 | let f = function() { 3 | x = 2; 4 | //^ defined: 1 5 | }; 6 | } 7 | 8 | x = 1; 9 | //^ defined: 1 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/base/for-var-scoped-in-function.ts: -------------------------------------------------------------------------------- 1 | function f() { 2 | x = 2; 3 | //^ defined: 4 4 | for(var x = 0; x < 42; x++) { 5 | // ^ defined: 4 6 | // ^ defined: 4 7 | } 8 | } 9 | 10 | x = 1; // tsc: error: Cannot find name 'x'. 11 | //^ defined: 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/base/mutually-recursive-functions.ts: -------------------------------------------------------------------------------- 1 | function odd(x) { 2 | return x > 1 ? even(x - 1) : x === 1; 3 | // ^ defined: 5 4 | } 5 | function even(x) { 6 | return x > 1 ? odd(x - 1) : x === 0; 7 | // ^ defined: 1 8 | } 9 | 10 | export {}; 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/base/nested-for-var-scoped-in-function.ts: -------------------------------------------------------------------------------- 1 | function f() { 2 | x = 2; 3 | //^ defined: 5 4 | while(true) { 5 | for(var x = 0; x < 42; x++) { 6 | // ^ defined: 5 7 | // ^ defined: 5 8 | } 9 | } 10 | } 11 | 12 | x = 1; // tsc: error: Cannot find name 'x'. 13 | //^ defined: 14 | 15 | export {}; 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/base/var-reference-before-def.ts: -------------------------------------------------------------------------------- 1 | x = 1; 2 | //^ defined: 4 3 | 4 | var x; 5 | 6 | 7 | export {}; 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/base/var-scoped-in-function.ts: -------------------------------------------------------------------------------- 1 | function f() { 2 | x = 2; 3 | //^ defined: 4 4 | var x; 5 | } 6 | 7 | x = 1; // tsc: error: Cannot find name 'x'. 8 | //^ defined: 9 | 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/async-arrow-function.ts: -------------------------------------------------------------------------------- 1 | let f = async () => ({ v: 42 }); 2 | 3 | async function test() { 4 | (await f()).v; 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | } 8 | 9 | export {}; 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/async-function-definition.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | async function f(): Promise { return { v: 42 } }; 6 | // ^ defined: 1 7 | 8 | async function test() { 9 | (await f()).v; 10 | // ^ defined: 5 11 | // ^ defined: 2 12 | } 13 | 14 | export {}; 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/async-function-expression.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | let f = async function(): Promise { return { v: 42 } }; 6 | // ^ defined: 1 7 | 8 | async function test() { 9 | (await f()).v; 10 | // ^ defined: 5 11 | // ^ defined: 2 12 | } 13 | 14 | export {}; 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/async-function-inferred-return-type-not-directly-accessible.ts: -------------------------------------------------------------------------------- 1 | async function f() { 2 | return { v: 42 }; 3 | } 4 | 5 | async function test() { 6 | f().v; 7 | // ^ defined: 8 | } 9 | 10 | export {}; 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/async-method-with-inferred-return-type.ts: -------------------------------------------------------------------------------- 1 | class A { 2 | async m() { 3 | return { v: 42 }; 4 | } 5 | } 6 | 7 | declare let x:A; 8 | 9 | async function test() { 10 | (await x.m()).v; 11 | // ^ defined: 7 12 | // ^ defined: 2 13 | // ^ defined: 3 14 | } 15 | 16 | export {}; 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/await-async-function-with-inferred-return-type.ts: -------------------------------------------------------------------------------- 1 | async function f() { 2 | return { v: 42 }; 3 | }; 4 | 5 | async function test() { 6 | (await f()).v; 7 | // ^ defined: 1 8 | // ^ defined: 2 9 | }; 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/await-function-with-explicit-return-type.ts: -------------------------------------------------------------------------------- 1 | interface V { v: number; } 2 | 3 | declare function f(): Promise; 4 | // ^ defined: 1 5 | 6 | async function test() { 7 | (await f()).v; 8 | // ^ defined: 3 9 | // ^ defined: 1 10 | } 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/await-variable.ts: -------------------------------------------------------------------------------- 1 | interface V { v: number; } 2 | 3 | declare let x: Promise; 4 | // ^ defined: 1 5 | 6 | (await x).v; 7 | // ^ defined: 3 8 | // ^ defined: 1 9 | 10 | export {}; 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/builtin-Array-type.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | declare let xs: Array; 6 | // ^ defined: 1 7 | 8 | xs[0].v; 9 | //^ defined: 5 10 | // ^ defined: 2 11 | 12 | xs.find((x) => x.v === 42).v; 13 | //^ defined: 5 14 | // ^ defined: 12 15 | // ^ defined: 2 16 | // ^ defined: 2 17 | 18 | export {}; 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/builtin-Map-type.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | declare let kv: Map; 6 | // ^ defined: 1 7 | 8 | kv.get("fortytwo")?.v; 9 | //^ defined: 5 10 | // ^ defined: 2 11 | 12 | kv.forEach((v, k, kv) => { 13 | kv.get(k)?.v === v.v; 14 | //^ defined: 12 15 | // ^ defined: 12 16 | // ^ defined: 2 17 | // ^ defined: 12 18 | // ^ defined: 2 19 | }); 20 | 21 | export {}; 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/builtins/builtin-Set-type.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | declare let xs: Set; 6 | // ^ defined: 1 7 | 8 | xs.forEach((x1, x2) => { 9 | x1.v; 10 | //^ defined: 8 11 | // ^ defined: 2 12 | x2.v; 13 | //^ defined: 8 14 | // ^ defined: 2 15 | }); 16 | 17 | export {}; 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/access-property-in-abstract-super-class.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | abstract class A { 4 | f: V; 5 | // ^ defined: 1 6 | } 7 | 8 | class C extends A { 9 | // ^ defined: 3 10 | } 11 | 12 | let x:C; 13 | // ^ defined: 8 14 | 15 | x.f; 16 | //^ defined: 12 17 | // ^ defined: 4 18 | 19 | export {}; 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/arrow-function.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | let f = x => x; 6 | // ^ defined: 5 7 | 8 | let g = (y:V) => y; 9 | // ^ defined: 1 10 | // ^ defined: 8 11 | 12 | g(null).v; 13 | //^ defined: 8 14 | // ^ defined: 2 15 | 16 | let h = (x):V => x; 17 | // ^ defined: 1 18 | // ^ defined: 16 19 | 20 | export {}; 21 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/asserts-condition.ts: -------------------------------------------------------------------------------- 1 | function assert( 2 | condition: any, 3 | ): asserts condition { 4 | // ^ defined: 2 5 | } 6 | 7 | export {} 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/asserts-type.ts: -------------------------------------------------------------------------------- 1 | function assertIsString( 2 | val: any 3 | ): asserts val is string { 4 | // ^ defined: 2 5 | } 6 | 7 | export {} 8 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-class-abstract-super-class-method.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | abstract class A { 4 | m(x: V): V { return x; }; 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | } 8 | 9 | class C extends A { 10 | // ^ defined: 3 11 | } 12 | 13 | let foo: C; 14 | // ^ defined: 9 15 | 16 | foo.m(null).value; 17 | //^ defined: 13 18 | // ^ defined: 4 19 | // ^ defined: 1 20 | 21 | export {}; 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-class-super-interface-method.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | interface I { 4 | m(x: V): V; 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | } 8 | 9 | class C implements I { 10 | m(x:V) { return x; } 11 | } 12 | 13 | let foo: C; 14 | // ^ defined: 9 15 | 16 | foo.m(null).value; 17 | //^ defined: 13 18 | // ^ defined: 10 19 | // ^ defined: 1 20 | 21 | export {}; 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-declared-function.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | function foo(x:V): V { 4 | // ^ defined: 1 5 | return null; 6 | } 7 | 8 | 9 | foo(null).value; 10 | //^ defined: 3 11 | // ^ defined: 1 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-function-literal.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | (function foo(x:V): V { 4 | // ^ defined: 1 5 | return null; 6 | })(null).value; 7 | // ^ defined: 1 8 | 9 | export {}; 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-function-type.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | let foo: (x:V) => V; 4 | // ^ defined: 1 5 | // ^ defined: 1 6 | 7 | foo(null).value; 8 | //^ defined: 3 9 | // ^ defined: 1 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-generic-function-signature.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | function id(x: X): X; // tsc: error TS2391: Function implementation is missing or not immediately following the declaration. 4 | 5 | id(null).value; 6 | //^ defined: 3 7 | // ^ defined: 1 8 | 9 | export {}; 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-generic-function-type.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | let id: (x: X) => X; 4 | 5 | id(null).value; 6 | //^ defined: 3 7 | // ^ defined: 1 8 | 9 | export {}; 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-generic-function-with-concrete-return-type-without-type-arguments.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | value: number; 3 | } 4 | 5 | let id: (x: X) => V; 6 | // ^ defined: 5 7 | // ^ defined: 1 8 | 9 | let v: number; 10 | 11 | id(v).value; 12 | //^ defined: 5 13 | // ^ defined: 9 14 | // ^ defined: 2 15 | 16 | export {}; 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-generic-function-with-default-without-type-arguments.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | let id: (x: X) => X; 6 | // ^ defined: 5 7 | // ^ defined: 5 8 | 9 | id(null).v; 10 | //^ defined: 5 11 | // ^ defined: 2 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-generic-function.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | function id(x: X): X { 4 | return x; 5 | } 6 | 7 | id(null).value; 8 | //^ defined: 3 9 | // ^ defined: 1 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-interface-generic-function.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | interface I { 4 | id(x: X): X; 5 | } 6 | 7 | let x:I; 8 | 9 | x.id(null).value; 10 | //^ defined: 7 11 | // ^ defined: 4 12 | // ^ defined: 1 13 | 14 | export {}; 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-interface-method.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | interface I { 4 | m(x: V): V; 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | } 8 | 9 | let foo: I; 10 | // ^ defined: 3 11 | 12 | foo.m(null).value; 13 | //^ defined: 9 14 | // ^ defined: 4 15 | // ^ defined: 1 16 | 17 | export {}; 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-interface-super-interface-method.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | interface I { 4 | m(x: V): V; 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | } 8 | 9 | interface J extends I {} 10 | 11 | let foo: J; 12 | // ^ defined: 9 13 | 14 | foo.m(null).value; 15 | //^ defined: 11 16 | // ^ defined: 4 17 | // ^ defined: 1 18 | 19 | export {}; 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-let-bound-function-literal.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | let foo = function(x:V): V { 4 | // ^ defined: 1 5 | return null; 6 | } 7 | 8 | foo(null).value; 9 | //^ defined: 3 10 | // ^ defined: 1 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-object-function-property.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | type O = { 4 | m: (x:V) => V; 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | }; 8 | 9 | let foo: O; 10 | // ^ defined: 3 11 | 12 | foo.m(null).value; 13 | //^ defined: 9 14 | // ^ defined: 4 15 | // ^ defined: 1 16 | 17 | export {}; 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-object-method.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | type O = { 4 | m(x:V): V; 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | }; 8 | 9 | let foo: O; 10 | // ^ defined: 3 11 | 12 | foo.m(null).value; 13 | //^ defined: 9 14 | // ^ defined: 4 15 | // ^ defined: 1 16 | 17 | export {}; 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-object-overloaded-method.ts: -------------------------------------------------------------------------------- 1 | class Super { 2 | bar() { } 3 | } 4 | 5 | class Sub extends Super { 6 | main() { 7 | this.bar(); 8 | // ^ defined: 13 9 | super.bar(); 10 | // ^ defined: 2 11 | } 12 | 13 | bar() { } 14 | } 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-object-with-call-signature.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | let foo: { 4 | (x:V): V; 5 | // ^ defined: 1 6 | // ^ defined: 1 7 | }; 8 | 9 | foo(null).value; 10 | //^ defined: 3 11 | // ^ defined: 1 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/call-with-template-string.ts: -------------------------------------------------------------------------------- 1 | function id(x) { 2 | return x; 3 | } 4 | 5 | let y = "world" 6 | 7 | id`x${y}` 8 | //^ defined: 1 9 | // ^ defined: 5 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/index-getter-property.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | class C { 4 | get p(): V { return null; } 5 | // ^ defined: 1 6 | } 7 | 8 | let x:C; 9 | 10 | x.p.value; 11 | //^ defined: 8 12 | // ^ defined: 4 13 | // ^ defined: 1 14 | 15 | x['p'].value; 16 | //^ defined: 8 17 | // ^ defined: 4 18 | // ^ defined: 1 19 | 20 | export {}; 21 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/index-into-array.ts: -------------------------------------------------------------------------------- 1 | interface V { v: number; } 2 | interface N { n: number; } 3 | 4 | let xs = [{ v: 42 }, { n: 42 }]; 5 | 6 | xs[0].v; 7 | //^ defined: 4 8 | // ^ defined: 4 9 | 10 | xs[0].n; 11 | //^ defined: 4 12 | // ^ defined: 4 13 | 14 | declare let i: number; 15 | 16 | xs[i].n; 17 | //^ defined: 4 18 | // ^ defined: 4 19 | 20 | export {}; 21 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/index-into-object-with-index-signature.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | let foo: { 4 | [index:number]: V; 5 | }; 6 | 7 | foo[1].value; 8 | //^ defined: 3 9 | // ^ defined: 1 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/index-named-property.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | let foo: { 4 | bar: V; 5 | }; 6 | 7 | foo["bar"].value; 8 | //^ defined: 3 9 | // ^ defined: 1 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/index-on-variable.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | declare let ys: V[]; 6 | // ^ defined: 1 7 | 8 | declare let i: number; 9 | 10 | const y = ys[i]; 11 | // ^ defined: 5 12 | // ^ defined: 8 13 | 14 | y.v; 15 | //^ defined: 10 16 | // ^ defined: 2 17 | 18 | export {}; 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/index-setter-property.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | class C { 4 | set p(v: V) {} 5 | // ^ defined: 1 6 | } 7 | 8 | let x:C; 9 | 10 | x.p = null; 11 | //^ defined: 8 12 | // ^ defined: 4 13 | 14 | x['p'] = null; 15 | //^ defined: 8 16 | // ^ defined: 4 17 | 18 | export {}; 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/new-from-construct-signature.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | new () : V; 4 | // ^ defined: 1 5 | } 6 | 7 | let x: V; 8 | // ^ defined: 1 9 | 10 | new x().v; 11 | // ^ defined: 7 12 | // ^ defined: 2 13 | 14 | export {}; 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/new-on-aliased-class-object.ts: -------------------------------------------------------------------------------- 1 | class V { 2 | value: number = 1; 3 | } 4 | 5 | let VV = V; 6 | // ^ defined: 1 7 | 8 | new VV().value; 9 | // ^ defined: 5 10 | // ^ defined: 2 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/new-on-expr-with-constructor-type.ts: -------------------------------------------------------------------------------- 1 | class V { 2 | value: number = 1; 3 | } 4 | 5 | declare let c: new() => V; 6 | 7 | new c().value; 8 | // ^ defined: 5 9 | // ^ defined: 2 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/new-target-property.ts: -------------------------------------------------------------------------------- 1 | // this test has no assertions and only exists to ensure coverage 2 | 3 | function Foo() { 4 | if (!new.target) { throw 'Foo() must be called with new'; } 5 | } 6 | export {}; 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/object-literal-type.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | let p: V; 6 | // ^ defined: 1 7 | 8 | let x = { 9 | p, 10 | // ^ defined: 5 11 | q: p, 12 | // ^ defined: 5 13 | "r": p, 14 | // ^ defined: 5 15 | }; 16 | 17 | x.p.v; 18 | //^ defined: 8 19 | // ^ defined: 9 20 | // ^ defined: 2 21 | 22 | x.q.v; 23 | //^ defined: 8 24 | // ^ defined: 11 25 | // ^ defined: 2 26 | 27 | x.r.v; 28 | //^ defined: 8 29 | // ^ defined: 13 30 | // ^ defined: 2 31 | 32 | export {}; 33 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/rest-array-attern.ts: -------------------------------------------------------------------------------- 1 | function foo(...[bar]) { 2 | bar; 3 | // ^ defined: 1 4 | } 5 | 6 | export {} -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/satisfies-type.ts: -------------------------------------------------------------------------------- 1 | type Foo = { foo: number }; 2 | 3 | let x = { foo: 42 } satisfies Foo; 4 | 5 | x.foo 6 | // ^ defined: 3, 1 7 | 8 | export {} 9 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/expressions/undefined-pattern.ts: -------------------------------------------------------------------------------- 1 | interface Foo { 2 | bar(undefined?: any): any; 3 | } 4 | 5 | export {} -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/jsx/jsx_fragment.tsx: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow Around 4 | 5 | const el = <>; 6 | 7 | /**/ x; 8 | // ^ defined: 1 9 | 10 | // Children 11 | ({x}); 12 | // ^ defined: 1 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/jsx/jsx_text.tsx: -------------------------------------------------------------------------------- 1 | let x = 1; 2 | 3 | // Flow Around 4 | 5 | const el = bar; 6 | 7 | /**/ x; 8 | // ^ defined: 1 -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/default-export-declaration-is-locally-visible.ts: -------------------------------------------------------------------------------- 1 | export default class T { 2 | v = 42; 3 | }; 4 | 5 | declare let x: T; 6 | // ^ defined: 1 7 | 8 | x.v; 9 | //^ defined: 5 10 | // ^ defined: 2 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/default-exported-declaration-is-not-a-named-export.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export default class T { 4 | v = 42; 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | import { T } from "./ModA" // tsc: Module '"./ModA"' has no exported member 'T'. 10 | // ^ defined: 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/export-as-namespace.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export let x = { 4 | v: 42 5 | }; 6 | 7 | export as namespace A; 8 | 9 | /*--- path: ModB.ts ---*/ 10 | 11 | A.x.v; 12 | //^ defined: 7 13 | // ^ defined: 3 14 | // ^ defined: 4 15 | 16 | export {}; 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-as-namespace.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export let x = { 4 | v: 42 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | import * as A from "./ModA"; 10 | 11 | A.x.v; 12 | //^ defined: 9 13 | // ^ defined: 3 14 | // ^ defined: 4 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-default-class-definition-type-and-expression.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export default class T { 4 | v = 42; 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | import T from "./ModA"; 10 | 11 | let x = T; 12 | // ^ defined: 9, 3 13 | 14 | declare let a: T; 15 | // ^ defined: 9, 3 16 | 17 | a.v; 18 | //^ defined: 14 19 | // ^ defined: 4 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-default-class-reference-type-and-expression.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | class T { 4 | v = 42; 5 | }; 6 | 7 | export default T; 8 | 9 | /*--- path: ModB.ts ---*/ 10 | 11 | import T from "./ModA"; 12 | 13 | let x = T; 14 | // ^ defined: 11, 7 15 | 16 | declare let a: T; 17 | // ^ defined: 11, 7, 3 18 | 19 | a.v; 20 | //^ defined: 16 21 | // ^ defined: 4 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-default-enum-reference-type-and-expression.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | enum E { 4 | C 5 | }; 6 | 7 | export default E; 8 | 9 | /*--- path: ModB.ts ---*/ 10 | 11 | import E from "./ModA"; 12 | 13 | let x: E = E.C; 14 | // ^ defined: 11, 7, 3 15 | // ^ defined: 11, 7 16 | // ^ defined: 4 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-default-expression.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export default { 4 | v: 42 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | import a from "./ModA"; 10 | 11 | a.v; 12 | //^ defined: 9, 3 13 | // ^ defined: 4 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-default-interface.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export default interface T { 4 | v: number; 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | import T from "./ModA" 10 | 11 | declare let x: T; 12 | // ^ defined: 9, 3 13 | 14 | x.v; 15 | //^ defined: 11 16 | // ^ defined: 4 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-default-type.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export default T; 4 | // ^ defined: 6 5 | 6 | type T = { 7 | v: number; 8 | }; 9 | 10 | /*--- path: ModB.ts ---*/ 11 | 12 | import T from "./ModA"; 13 | 14 | declare let a: T; 15 | // ^ defined: 12, 3, 6 16 | 17 | a.v; 18 | //^ defined: 14 19 | // ^ defined: 7 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-directly-exported-variable.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export let a = { 4 | v: 42 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | import { a } from "./ModA"; 10 | // ^ defined: 3 11 | 12 | a.v; 13 | //^ defined: 9, 3 14 | // ^ defined: 4 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-exports-class.ts: -------------------------------------------------------------------------------- 1 | /* --- path: A.ts --- */ 2 | 3 | export = A; 4 | 5 | class A { 6 | f = 42; 7 | } 8 | 9 | /* --- path: B.ts --- */ 10 | 11 | import C = require("./A"); 12 | 13 | let c: C = new C(); 14 | // ^ defined: 11, 3, 5 15 | // ^ defined: 11, 3 16 | 17 | c.f; 18 | //^ defined: 13 19 | // ^ defined: 6 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-exports-object.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export = A; 4 | 5 | let A = { 6 | f: 42 7 | }; 8 | 9 | /*--- path: ModB.ts ---*/ 10 | 11 | import a = require('./ModA'); 12 | 13 | a.f; 14 | //^ defined: 11, 3 15 | // ^ defined: 6 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-exports-of-indirect-class.ts.skip: -------------------------------------------------------------------------------- 1 | /* --- path: A.ts --- */ 2 | 3 | export = A; 4 | 5 | class B { 6 | f = 42; 7 | } 8 | 9 | const A = B; 10 | 11 | /* --- path: B.ts --- */ 12 | 13 | import C = require("./A"); 14 | 15 | let c: C = new C(); 16 | // ^ defined: 17 | // ^ defined: 13 18 | 19 | c.f; 20 | //^ defined: 15 21 | // ^ defined: 6 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-extension-js.ts: -------------------------------------------------------------------------------- 1 | /* --- path: src/foo.ts --- */ 2 | export const bar = 42; 3 | 4 | /* --- path: src/index.ts --- */ 5 | import { bar } from "./foo.js"; 6 | // ^ defined: 2 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-extension-none.ts: -------------------------------------------------------------------------------- 1 | /* --- path: src/foo.ts --- */ 2 | export const bar = 42; 3 | 4 | /* --- path: src/index.ts --- */ 5 | import { bar } from "./foo"; 6 | // ^ defined: 2 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-extension-ts.ts: -------------------------------------------------------------------------------- 1 | /* --- path: src/foo.ts --- */ 2 | export const bar = 42; 3 | 4 | /* --- path: src/index.ts --- */ 5 | import { bar } from "./foo.ts"; 6 | // ^ defined: 2 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-from-ambient-module-declaration.ts: -------------------------------------------------------------------------------- 1 | /* --- path: index.ts --- */ 2 | import { foo } from "@my/lib"; 3 | // ^ defined: 8 4 | 5 | /* --- path: mod.ts --- */ 6 | 7 | declare module "@my/lib" { 8 | export const foo = 42; 9 | } 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-from-own-direcotry-in-index.ts: -------------------------------------------------------------------------------- 1 | /*--- path: foo/index.ts ---*/ 2 | 3 | import { FOO } from "./bar"; 4 | // ^ defined: 8 5 | 6 | /*--- path: foo/bar.ts ---*/ 7 | 8 | export const FOO = 42; 9 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-from-own-project-subdirectory.ts: -------------------------------------------------------------------------------- 1 | /*--- path: A/ModA.ts ---*/ 2 | /*--- global: PROJECT_NAME=foo/bar ---*/ 3 | 4 | export let a = { 5 | v: 42 6 | }; 7 | 8 | /*--- path: ModB.ts ---*/ 9 | /*--- global: PROJECT_NAME=foo/bar ---*/ 10 | 11 | import { a } from "./A/ModA"; 12 | // ^ defined: 4 13 | 14 | a.v; 15 | //^ defined: 11, 4 16 | // ^ defined: 5 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-from-subdirectory.ts: -------------------------------------------------------------------------------- 1 | /*--- path: A/ModA.ts ---*/ 2 | 3 | export let a = { 4 | v: 42 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | import { a } from "./A/ModA"; 10 | // ^ defined: 3 11 | 12 | a.v; 13 | //^ defined: 9, 3 14 | // ^ defined: 4 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-from-superdirectory.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export let a = { 4 | v: 42 5 | }; 6 | 7 | /*--- path: B/ModB.ts ---*/ 8 | 9 | import { a } from "../ModA"; 10 | // ^ defined: 3 11 | 12 | a.v; 13 | //^ defined: 9, 3 14 | // ^ defined: 4 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-indirectly-exported-variable.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | let a = { 4 | v: 42 5 | }; 6 | 7 | export { a }; 8 | // ^ defined: 3 9 | 10 | /*--- path: ModB.ts ---*/ 11 | 12 | import { a } from "./ModA"; 13 | // ^ defined: 7, 3 14 | 15 | a.v; 16 | //^ defined: 12, 7, 3 17 | // ^ defined: 4 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-reexports-from-subdirectory-index.ts: -------------------------------------------------------------------------------- 1 | /* --- path: foo/index.ts --- */ 2 | 3 | export * from './bar' 4 | 5 | /* --- path: foo/bar.ts --- */ 6 | 7 | export let baz = 42 8 | 9 | /* --- path: qux.ts --- */ 10 | 11 | import { baz } from './foo' 12 | // ^ defined: 7 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-reexports-from-superdirectory-index.ts: -------------------------------------------------------------------------------- 1 | /* --- path: index.ts --- */ 2 | 3 | export * from './bar' 4 | 5 | /* --- path: bar.ts --- */ 6 | 7 | export let baz = 42 8 | 9 | /* --- path: foo/qux.ts --- */ 10 | 11 | import { baz } from '..' 12 | // ^ defined: 7 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-relative-to-project-root.ts.skip: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export const a = 42; 4 | 5 | /*--- path: B/ModB.ts ---*/ 6 | 7 | import { a } from "./ModA"; 8 | // ^ defined: -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-via-index.ts: -------------------------------------------------------------------------------- 1 | /*--- path: A/index.ts ---*/ 2 | 3 | export let a = { 4 | v: 42 5 | }; 6 | 7 | /*--- path: B/ModB.ts ---*/ 8 | 9 | import { a } from "../A"; 10 | // ^ defined: 3 11 | 12 | a.v; 13 | //^ defined: 9, 3 14 | // ^ defined: 4 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-via-superdirectory.ts: -------------------------------------------------------------------------------- 1 | /*--- path: A/ModA.ts ---*/ 2 | 3 | export let a = { 4 | v: 42 5 | }; 6 | 7 | /*--- path: B/ModB.ts ---*/ 8 | 9 | import { a } from "../A/ModA"; 10 | // ^ defined: 3 11 | 12 | a.v; 13 | //^ defined: 9, 3 14 | // ^ defined: 4 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/import-via-two-reexports.ts: -------------------------------------------------------------------------------- 1 | /* --- path: src/foo/index.ts --- */ 2 | 3 | export * from "../bar"; 4 | 5 | /* --- path: src/bar/index.ts --- */ 6 | 7 | export * from "./quz"; 8 | 9 | /* --- path: src/bar/quz.ts --- */ 10 | 11 | export const QUZ = 42; 12 | 13 | /* --- path: src/test.ts --- */ 14 | 15 | import { QUZ } from "./foo"; 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/module-declaration-not-visible-in-other-module.ts: -------------------------------------------------------------------------------- 1 | // --- path: a.ts --- 2 | 3 | let x = 42; 4 | 5 | export {} 6 | 7 | // --- path: b.ts --- 8 | 9 | let y = x; 10 | // ^ defined: 11 | 12 | export {} 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/namespace-type-export.ts: -------------------------------------------------------------------------------- 1 | namespace A { 2 | export type T = { 3 | v: number; 4 | }; 5 | }; 6 | 7 | let x: A.T; 8 | // ^ defined: 1 9 | // ^ defined: 2 10 | 11 | x.v; 12 | //^ defined: 7 13 | // ^ defined: 3 14 | 15 | export {}; 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/namespace-variable-export.ts: -------------------------------------------------------------------------------- 1 | namespace A { 2 | export let b = { v: 42 }; 3 | }; 4 | 5 | A.b.v; 6 | //^ defined: 1 7 | // ^ defined: 2 8 | // ^ defined: 2 9 | 10 | export {}; 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/reexport-as-object.ts: -------------------------------------------------------------------------------- 1 | /* --- path: foo.ts --- */ 2 | 3 | export const FOO = 42; 4 | 5 | /* --- path: bar.ts --- */ 6 | 7 | export * as quz from "./foo"; 8 | 9 | /* --- path: test.ts --- */ 10 | 11 | import { quz } from "./bar"; 12 | 13 | quz.FOO 14 | // ^ defined: 11, 7 15 | // ^ defined: 3 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/refer-to-separately-defined-subnamespace-from-supernamespace.ts.skip: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | namespace M.N.O.P { 4 | export interface A {} 5 | } 6 | 7 | namespace M.N.O { 8 | interface B extends P.A {} 9 | // ^ defined: 3 10 | // ^ defined: 4 11 | } 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/refer-to-type-in-aprent-namespace-from-split-qualified-namespace.ts.skip: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | namespace M { 4 | export interface A {}; 5 | export namespace N { 6 | }; 7 | }; 8 | 9 | namespace M.N { 10 | interface B extends A {}; 11 | // ^ defined: 5 12 | } 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/refer-to-type-in-nested-namespace-from-parent-namespace-with-partially-qualified-name.ts.skip: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | namespace M { 4 | export namespace N { 5 | export interface A {}; 6 | }; 7 | }; 8 | 9 | namespace M { 10 | interface B extends N.A {}; 11 | // ^ defined: 4 12 | // ^ defined: 5 13 | } 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/refer-to-type-in-nested-namespace-from-qualified-namespace.ts.skip: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | namespace M { 4 | export namespace N { 5 | export interface A {}; 6 | }; 7 | }; 8 | 9 | namespace M.N { 10 | interface B extends A {}; 11 | // ^ defined: 5 12 | } 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/rename-imported-directly-exported-variable.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export let a = { 4 | v: 42 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | import { a as b } from "./ModA"; 10 | // ^ defined: 3 11 | 12 | b.v; 13 | //^ defined: 9, 3 14 | // ^ defined: 4 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/rename-imported-indirectly-exported-variable.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | let a = { 4 | v: 42 5 | }; 6 | 7 | export { a }; 8 | // ^ defined: 3 9 | 10 | /*--- path: ModB.ts ---*/ 11 | 12 | import { a as b } from "./ModA"; 13 | // ^ defined: 7, 3 14 | 15 | b.v; 16 | //^ defined: 12, 7, 3 17 | // ^ defined: 4 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/script-declaration-visible-in-other-module.ts: -------------------------------------------------------------------------------- 1 | // --- path: a.ts --- 2 | 3 | let x = 42; 4 | 5 | // --- path: b.ts --- 6 | 7 | let y = x; 8 | // ^ defined: 3 9 | 10 | export {} 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/split-namespace-can-only-see-exports.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | namespace N { 4 | let x = 42; 5 | } 6 | 7 | namespace N { 8 | export let y = x; // tsc: Cannot find name 'x'. 9 | // ^ defined: 10 | } 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/split-namespace-can-see-all-exports.ts.skip: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | namespace N { 4 | export let x = 42; 5 | } 6 | 7 | namespace N { 8 | export let y = x; 9 | // ^ defined: 4 10 | } 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/modules/very-deep-namespace.ts: -------------------------------------------------------------------------------- 1 | namespace a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y { 2 | export const Z = 42; 3 | } 4 | 5 | a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.Z 6 | // ^ defined: 2 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/baseurl-to-subdir.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "composite": true, 5 | "baseUrl": "./src/", 6 | } 7 | } 8 | 9 | /* --- path: src/foo.ts --- */ 10 | export const bar = 42; 11 | 12 | /* --- path: src/index.ts --- */ 13 | import { bar } from "foo"; 14 | // ^ defined: 10 15 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/composite-project.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "composite": true, 5 | } 6 | } 7 | 8 | /* --- path: src/foo.ts --- */ 9 | export const bar = 42; 10 | 11 | /* --- path: src/index.ts --- */ 12 | import { bar } from "./foo"; 13 | // ^ defined: 9 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/declarations-are-ignored.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | } 4 | 5 | /* --- path: src/foo.ts --- */ 6 | export const bar = 42; 7 | 8 | /* --- path: src/index.ts --- */ 9 | import { bar } from "./foo"; 10 | // ^ defined: 6 11 | 12 | /* --- path: types/index.d.ts --- */ 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/empty-project-config.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | } 4 | 5 | /* --- path: src/index.ts --- */ 6 | export const foo = 42; 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/exclude-second-subdir.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "exclude": ["test/**/*"] 4 | } 5 | 6 | /* --- path: src/foo.ts --- */ 7 | export const bar = 42; 8 | 9 | /* --- path: src/index.ts --- */ 10 | import { bar } from "./foo"; 11 | // ^ defined: 7 12 | 13 | /* --- path: test/index.ts --- */ 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/explicit-root-dir.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "rootDir": "." 5 | } 6 | } 7 | 8 | /* --- path: core/foo.ts --- */ 9 | export const bar = 42; 10 | 11 | /* --- path: core/index.ts --- */ 12 | import { bar } from "./foo"; 13 | // ^ defined: 9 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/import-from-rootdirs-subdir.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "rootDirs": [ 5 | "src/core", 6 | "src/util" 7 | ] 8 | } 9 | } 10 | 11 | /* --- path: src/core/index.ts --- */ 12 | import { bar } from "./foo/baz"; 13 | // ^ defined: 16 14 | 15 | /* --- path: src/util/foo/baz.ts --- */ 16 | export const bar = 42; 17 | 18 | /* --- path: src/util/index.ts --- */ 19 | 20 | /* --- path: src/index.ts --- */ 21 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/import-from-rootdirs.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "rootDirs": [ 5 | "src/core", 6 | "src/util" 7 | ] 8 | } 9 | } 10 | 11 | /* --- path: src/core/index.ts --- */ 12 | import { bar } from "./foo"; 13 | // ^ defined: 16 14 | 15 | /* --- path: src/util/foo.ts --- */ 16 | export const bar = 42; 17 | 18 | /* --- path: src/util/index.ts --- */ 19 | 20 | /* --- path: src/index.ts --- */ 21 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/import-with-own-project-baseurl.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | /* --- global: PROJECT_NAME=a --- */ 3 | { 4 | "compilerOptions": { 5 | "composite": true, 6 | "baseUrl": "./src/", 7 | } 8 | } 9 | 10 | /* --- path: src/foo.ts --- */ 11 | /* --- global: PROJECT_NAME=a --- */ 12 | export const bar = 42; 13 | 14 | /* --- path: src/index.ts --- */ 15 | /* --- global: PROJECT_NAME=a --- */ 16 | import { bar } from "foo"; 17 | // ^ defined: 12 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/include-one-subdir.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "include": ["src/**/*"] 4 | } 5 | 6 | /* --- path: src/foo.ts --- */ 7 | export const bar = 42; 8 | 9 | /* --- path: src/index.ts --- */ 10 | import { bar } from "./foo"; 11 | // ^ defined: 7 12 | 13 | /* --- path: test/index.ts --- */ 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/invalid-paths-mappings.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "paths": { 5 | ".": ["."], 6 | "a/": ["b/"], 7 | "c/*": ["d"], 8 | "e": ["f/*"], 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/js-sources-are-ignored.ts.skip: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | } 4 | 5 | /* --- path: lib/index.js --- */ 6 | 7 | /* --- path: src/foo.ts --- */ 8 | export const bar = 42; 9 | 10 | /* --- path: src/index.ts --- */ 11 | import { bar } from "./foo"; 12 | // ^ defined: 8 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/js-sources-can-be-allowed.ts.skip: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "allowJs": true 5 | } 6 | } 7 | 8 | /* --- path: lib/index.js --- */ 9 | 10 | /* --- path: src/foo.ts --- */ 11 | export const bar = 42; 12 | 13 | /* --- path: src/index.ts --- */ 14 | import { bar } from "./foo"; 15 | // ^ defined: 11 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/non-relative-single-module-remap.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "composite": true, 5 | "baseUrl": "./", 6 | "paths": { 7 | "foo": ["lib/the_foo"] 8 | }, 9 | } 10 | } 11 | 12 | /* --- path: lib/the_foo.ts --- */ 13 | export const bar = 42; 14 | 15 | /* --- path: src/index.ts --- */ 16 | import { bar } from "foo"; 17 | // ^ defined: 13 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/non-relative-star-remap.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "composite": true, 5 | "baseUrl": "./", 6 | "paths": { 7 | "*": ["lib/*"] 8 | }, 9 | } 10 | } 11 | 12 | /* --- path: lib/foo.ts --- */ 13 | export const bar = 42; 14 | 15 | /* --- path: src/index.ts --- */ 16 | import { bar } from "foo"; 17 | // ^ defined: 13 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/non-relative-star-remaps.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "composite": true, 5 | "baseUrl": "./", 6 | "paths": { 7 | "*": ["lib/*", "ext/*"] 8 | }, 9 | } 10 | } 11 | 12 | /* --- path: ext/foo.ts --- */ 13 | export const bar = 42; 14 | 15 | /* --- path: src/index.ts --- */ 16 | import { bar } from "foo"; 17 | // ^ defined: 13 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/one-file-in-subdir.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "files": ["src/index.ts"] 4 | } 5 | 6 | /* --- path: src/foo.ts --- */ 7 | export const bar = 42; 8 | 9 | /* --- path: src/index.ts --- */ 10 | import { bar } from "./foo"; 11 | // ^ defined: 7 12 | 13 | /* --- path: test/index.ts --- */ 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/projects-are-isolated.ts: -------------------------------------------------------------------------------- 1 | /* --- path: a/foo.ts --- */ 2 | /* --- global: FILE_PATH=foo.ts */ 3 | /* --- global: PROJECT_NAME=a */ 4 | 5 | export const baz = 42; 6 | 7 | /* --- path: b/bar.ts --- */ 8 | /* --- global: FILE_PATH=bar.ts */ 9 | /* --- global: PROJECT_NAME=b */ 10 | 11 | import { baz } from "./foo"; 12 | // ^ defined: 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/relative-import.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "composite": true 5 | } 6 | } 7 | 8 | /* --- path: src/foo.ts --- */ 9 | export const bar = 42; 10 | 11 | /* --- path: src/index.ts --- */ 12 | import { bar } from "./foo"; 13 | // ^ defined: 9 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/relative-single-module-remap.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "composite": true, 5 | "paths": { 6 | "foo": ["./lib/the_foo"] 7 | }, 8 | } 9 | } 10 | 11 | /* --- path: lib/the_foo.ts --- */ 12 | export const bar = 42; 13 | 14 | /* --- path: src/index.ts --- */ 15 | import { bar } from "foo"; 16 | // ^ defined: 12 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/relative-star-remap.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "composite": true, 5 | "paths": { 6 | "*": ["./lib/*"] 7 | }, 8 | } 9 | } 10 | 11 | /* --- path: lib/foo.ts --- */ 12 | export const bar = 42; 13 | 14 | /* --- path: src/index.ts --- */ 15 | import { bar } from "foo"; 16 | // ^ defined: 12 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/remap-with-baseurl.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | "compilerOptions": { 4 | "composite": true, 5 | "baseUrl": "./src", 6 | "paths": { 7 | "util/*": ["util_impl/*"] 8 | }, 9 | } 10 | } 11 | 12 | /* --- path: src/util_impl/foo.ts --- */ 13 | export const bar = 42; 14 | 15 | /* --- path: src/index.ts --- */ 16 | import { bar } from "util/foo"; 17 | // ^ defined: 13 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/sources-in-multiple-subdirs.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | } 4 | 5 | /* --- path: src/foo.ts --- */ 6 | export const bar = 42; 7 | 8 | /* --- path: src/index.ts --- */ 9 | import { bar } from "./foo"; 10 | // ^ defined: 6 11 | 12 | /* --- path: test/index.ts --- */ 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/projects/sources-in-one-subdir.ts: -------------------------------------------------------------------------------- 1 | /* --- path: tsconfig.json --- */ 2 | { 3 | } 4 | 5 | /* --- path: src/foo.ts --- */ 6 | export const bar = 42; 7 | 8 | /* --- path: src/index.ts --- */ 9 | import { bar } from "./foo"; 10 | // ^ defined: 6 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/ambient-module-declaration.ts: -------------------------------------------------------------------------------- 1 | declare module "*.ts" { 2 | export {}; 3 | } 4 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/call-argument-type-shadows-type-parameter-default.ts.skip: -------------------------------------------------------------------------------- 1 | interface V { 2 | val: number; 3 | } 4 | interface N { 5 | num: number; 6 | } 7 | 8 | let id: (x: X) => X; 9 | // ^ defined: 8 10 | // ^ defined: 8 11 | 12 | let n: N; 13 | 14 | id(n).num; 15 | //^ defined: 8 16 | // ^ defined: 12 17 | // ^ defined: 5 18 | 19 | id(n).val; 20 | //^ defined: 8 21 | // ^ defined: 12 22 | // ^ defined: 23 | 24 | export {} 25 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/class-static-block.ts: -------------------------------------------------------------------------------- 1 | let bar = 42; 2 | 3 | class Foo { 4 | static foo: number; 5 | static { 6 | this.foo = bar; 7 | // ^ defined: 4 8 | // ^ defined: 1 9 | } 10 | } 11 | 12 | export {} 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/const-with-value.ts: -------------------------------------------------------------------------------- 1 | interface T { 2 | f: number; 3 | } 4 | 5 | const a:T = { f: 42 } as T; 6 | // ^ defined: 1 7 | // ^ defined: 1 8 | 9 | a.f; 10 | //^ defined: 5 11 | // ^ defined: 2 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/deconstruct-tuple.ts: -------------------------------------------------------------------------------- 1 | interface V { v: number; } 2 | interface N { n: number; } 3 | 4 | type T = [V, N]; 5 | 6 | declare let t: T; 7 | 8 | let [x, y] = t; 9 | 10 | x.v; 11 | //^ defined: 8 12 | // ^ defined: 1 13 | 14 | y.n; 15 | //^ defined: 8 16 | // ^ defined: 2 17 | 18 | export {}; 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/decorators.ts: -------------------------------------------------------------------------------- 1 | function Id(x, ignored) { 2 | return x; 3 | } 4 | 5 | @Id 6 | // ^ defined: 1 7 | class A { 8 | } 9 | 10 | @Id() 11 | // ^ defined: 1 12 | class B { 13 | } 14 | 15 | let y = 42; 16 | 17 | @Id(y) 18 | // ^ defined: 1 19 | // ^ defined: 15 20 | class C { 21 | } 22 | 23 | class D { 24 | @Id 25 | // ^ defined: 1 26 | @Id() 27 | // ^ defined: 1 28 | @Id(y) 29 | // ^ defined: 1 30 | // ^ defined: 15 31 | f: int; 32 | } 33 | 34 | export {}; 35 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/define-after-use.ts: -------------------------------------------------------------------------------- 1 | var x: T; 2 | // ^ defined: 15 3 | 4 | { 5 | var i: U; 6 | // ^ defined: 8 7 | 8 | type U = T; 9 | // ^ defined: 15 10 | 11 | var j: U; 12 | // ^ defined: 8 13 | } 14 | 15 | type T = number; 16 | 17 | var y: T; 18 | // ^ defined: 15 19 | 20 | var z: U; // tsc: Cannot find name 'U' 21 | // ^ defined: 22 | 23 | export {}; 24 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/destructuring-var-defs.ts: -------------------------------------------------------------------------------- 1 | interface N { 2 | n: number; 3 | } 4 | interface V { 5 | v: N; 6 | }; 7 | 8 | var x: V; 9 | // ^ defined: 4 10 | 11 | var { v } = x; 12 | // ^ defined: 8 13 | 14 | v.n; 15 | //^ defined: 11 16 | // ^ defined: 2 17 | 18 | var { v: w } = x; 19 | // ^ defined: 8 20 | 21 | w.n; 22 | //^ defined: 18 23 | // ^ defined: 2 24 | 25 | var { "v": p } = x; 26 | // ^ defined: 8 27 | 28 | p.n; 29 | //^ defined: 25 30 | // ^ defined: 2 31 | 32 | export {}; 33 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/enum-constant-not-a-type-member.ts: -------------------------------------------------------------------------------- 1 | enum E { 2 | C 3 | } 4 | 5 | var x: E; 6 | // ^ defined: 1 7 | 8 | x.C; // tsc: Property 'C' does not exist on type 'E'. 9 | //^ defined: 5 10 | // ^ defined: 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/enum-object.ts: -------------------------------------------------------------------------------- 1 | enum E { 2 | C 3 | } 4 | 5 | let y = E; 6 | // ^ defined: 1 7 | 8 | y.C; 9 | //^ defined: 5 10 | // ^ defined: 2 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/enum.ts: -------------------------------------------------------------------------------- 1 | enum E { 2 | C1 = 1, 3 | C2, 4 | } 5 | 6 | let h:E = true ? E.C2 : E.C1; 7 | // ^ defined: 1 8 | // ^ defined: 1 9 | // ^ defined: 3 10 | // ^ defined: 1 11 | // ^ defined: 2 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/expression-statement.ts: -------------------------------------------------------------------------------- 1 | type T = number; 2 | 3 | 1 as T; 4 | // ^ defined: 1 5 | 6 | export {}; 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/for-let-initializer-scoping.ts: -------------------------------------------------------------------------------- 1 | for(let x = 1; x < 42; x++) { 2 | // ^ defined: 1 3 | // ^ defined: 1 4 | x; 5 | //^ defined: 1 6 | } 7 | 8 | x; // tsc: Cannot find name 'x'. 9 | //^ defined: 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/for-of-destructuring-var.ts: -------------------------------------------------------------------------------- 1 | interface N { 2 | n: number; 3 | } 4 | interface V { 5 | v: N; 6 | // ^ defined: 1 7 | } 8 | 9 | let xs: V[]; 10 | // ^ defined: 4 11 | 12 | for(let { v } of xs) { 13 | // ^ defined: 9 14 | v.n; 15 | //^ defined: 12 16 | // ^ defined: 2 17 | } 18 | 19 | export {}; 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/for-of-var-type.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | let xs: V[]; 6 | // ^ defined: 1 7 | 8 | for(let x of xs) { 9 | // ^ defined: 5 10 | x.v; 11 | //^ defined: 8 12 | // ^ defined: 2 13 | } 14 | 15 | export {}; 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/for-var-initializer-scoping.ts: -------------------------------------------------------------------------------- 1 | for(var x = 1; x < 42; x++) { 2 | // ^ defined: 1 3 | // ^ defined: 1 4 | x; 5 | //^ defined: 1 6 | } 7 | 8 | x; 9 | //^ defined: 1 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/function-declaration.ts: -------------------------------------------------------------------------------- 1 | type T = { f: number } 2 | 3 | function foo(x: T): T { 4 | // ^ defined: 1 5 | return { f: x.f } as T; 6 | // ^ defined: 3 7 | // ^ defined: 1 8 | // ^ defined: 1 9 | } 10 | 11 | foo; 12 | //^ defined: 3 13 | 14 | foo(null).f; 15 | //^ defined: 3 16 | // ^ defined: 1 17 | 18 | export {}; 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/function-type-inferred-from-deeply-nested-return.ts: -------------------------------------------------------------------------------- 1 | function f() { 2 | try { 3 | if(true) { 4 | return { v: 42 }; 5 | } 6 | } finally { 7 | return { e: -1 }; 8 | } 9 | } 10 | 11 | f().v; 12 | //^ defined: 1 13 | // ^ defined: 4 14 | 15 | f().e; 16 | //^ defined: 1 17 | // ^ defined: 7 18 | 19 | export {}; 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/function-type-inferred-from-direct-return.ts: -------------------------------------------------------------------------------- 1 | function f() { 2 | return { v: 42 }; 3 | } 4 | 5 | f().v; 6 | //^ defined: 1 7 | // ^ defined: 2 8 | 9 | export {}; 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/function-type-inferred-from-nested-return.ts: -------------------------------------------------------------------------------- 1 | function f() { 2 | if(true) { 3 | return { v: 42 }; 4 | } 5 | } 6 | 7 | f().v; 8 | //^ defined: 1 9 | // ^ defined: 3 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/getter-not-accessible-as-method.ts.skip: -------------------------------------------------------------------------------- 1 | interface I { 2 | get p(): { v: number } 3 | } 4 | 5 | declare let x: I; 6 | // ^ defined: 1 7 | 8 | x.p().v; 9 | //^ defined: 5 10 | // ^ defined: 2 11 | // ^ defined: 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/infer-arrow-function-literal-parameter-type-from-use-site.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | declare function g(f: (v:V) => number): number; 6 | 7 | g(v => { 8 | return v.v; 9 | // ^ defined: 7 10 | // ^ defined: 2 11 | }); 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/infer-function-literal-parameter-type-from-let-type-annotation.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | let g: (_:V) => any = function(x) { 6 | // ^ defined: 1 7 | x.v; 8 | //^ defined: 5 9 | // ^ defined: 2 10 | }; 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/infer-function-literal-parameter-type-from-use-site.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | declare function g(f: (v:V) => number): number; 6 | 7 | g(function(v) { 8 | return v.v; 9 | // ^ defined: 7 10 | // ^ defined: 2 11 | }); 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/let-and-var-with-type-annotation.ts: -------------------------------------------------------------------------------- 1 | type my_number = number; 2 | 3 | let x1:my_number = 42; 4 | // ^ defined: 1 5 | 6 | let x2:my_number; 7 | // ^ defined: 1 8 | 9 | var x3:my_number = 42; 10 | // ^ defined: 1 11 | 12 | var x4:my_number; 13 | // ^ defined: 1 14 | 15 | x1 + x2 + x3 + x4; 16 | // ^ defined: 3 17 | // ^ defined: 6 18 | // ^ defined: 9 19 | // ^ defined: 12 20 | 21 | export {}; 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/let-bound-variable-has-value-type.ts: -------------------------------------------------------------------------------- 1 | type V = { value: number; } 2 | 3 | let x = null as V; 4 | 5 | x.value; 6 | //^ defined: 3 7 | // ^ defined: 1 8 | 9 | export {}; 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/let-with-value.ts: -------------------------------------------------------------------------------- 1 | interface T { 2 | f: number; 3 | } 4 | 5 | let a:T = { f: 42 } as T; 6 | // ^ defined: 1 7 | // ^ defined: 1 8 | 9 | a.f; 10 | //^ defined: 5 11 | // ^ defined: 2 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/let-without-value.ts: -------------------------------------------------------------------------------- 1 | interface T { 2 | f: number; 3 | } 4 | 5 | let a:T; 6 | // ^ defined: 1 7 | 8 | a.f; 9 | //^ defined: 5 10 | // ^ defined: 2 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/member-and-subscript-expression-in-assignment-pattern.ts: -------------------------------------------------------------------------------- 1 | let x = { 2 | y: 0 3 | }; 4 | 5 | [ x.y, x["y"] ] = [ 42, 42 ]; 6 | // ^ defined: 1 7 | // ^ defined: 2 8 | // ^ defined: 1 9 | // ^ defined: 2 10 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/multi-let.ts: -------------------------------------------------------------------------------- 1 | interface T { 2 | f: number; 3 | } 4 | 5 | let a:T, b:T = { f: 42 } as T; 6 | // ^ defined: 1 7 | // ^ defined: 1 8 | // ^ defined: 1 9 | 10 | a.f; 11 | //^ defined: 5 12 | // ^ defined: 2 13 | 14 | b.f; 15 | //^ defined: 5 16 | // ^ defined: 2 17 | 18 | export {}; 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/new-on-class-expression.ts: -------------------------------------------------------------------------------- 1 | let x = class { 2 | declare f: { 3 | v: number 4 | }; 5 | } 6 | 7 | let y = new x(); 8 | // ^ defined: 1 9 | 10 | y.f.v; 11 | //^ defined: 7 12 | // ^ defined: 2 13 | // ^ defined: 3 14 | 15 | export {}; 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/qualified-decorators.ts: -------------------------------------------------------------------------------- 1 | let D = { 2 | Id: function(x, ignored) { 3 | return x; 4 | } 5 | }; 6 | 7 | @D.Id 8 | // ^ defined: 1 9 | // ^ defined: 2 10 | class A {} 11 | 12 | @D.Id() 13 | // ^ defined: 1 14 | // ^ defined: 2 15 | class B {} 16 | 17 | let y = 42; 18 | 19 | @D.Id(y) 20 | // ^ defined: 1 21 | // ^ defined: 2 22 | class C {} 23 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/reexport-of-variable.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export let a = { 4 | f: 42 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | export { a } from "./ModA"; 10 | 11 | /*--- path: ModC.ts ---*/ 12 | 13 | import { a } from "./ModB"; 14 | 15 | a.f; 16 | //^ defined: 13, 9, 3 17 | // ^ defined: 4 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/refer-to-class-in-nested-namespace-by-qualified-name.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | namespace M { 4 | export namespace N { 5 | export class A { 6 | f = 42; 7 | } 8 | } 9 | } 10 | 11 | (new M.N.A()).f; 12 | // ^ defined: 3 13 | // ^ defined: 4 14 | // ^ defined: 5 15 | // ^ defined: 6 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/refer-to-interface-in-nested-namespace-by-fully-qualified-name.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | namespace M { 4 | export namespace N { 5 | export interface A {} 6 | }; 7 | }; 8 | 9 | interface B extends M.N.A {}; 10 | // ^ defined: 3 11 | // ^ defined: 4 12 | // ^ defined: 5 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/refer-to-interface-in-qualified-namespace-by-fully-qualified-name.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | 3 | namespace M.N { 4 | export interface A {} 5 | }; 6 | 7 | interface B extends M.N.A {}; 8 | // ^ defined: 3 9 | // ^ defined: 3 10 | // ^ defined: 4 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/rename-imported-default.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export default { 4 | f: 42 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | import { default as b } from "./ModA"; 10 | 11 | b.f; 12 | //^ defined: 9, 3 13 | // ^ defined: 4 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/renamed-reexport-of-default.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export default { 4 | f: 42 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | export { default as b } from "./ModA"; 10 | 11 | /*--- path: ModC.ts ---*/ 12 | 13 | import { b } from "./ModB"; 14 | 15 | b.f; 16 | //^ defined: 13, 9, 3 17 | // ^ defined: 4 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/renamed-reexport-of-variable.ts: -------------------------------------------------------------------------------- 1 | /*--- path: ModA.ts ---*/ 2 | 3 | export let a = { 4 | f: 42 5 | }; 6 | 7 | /*--- path: ModB.ts ---*/ 8 | 9 | export { a as b } from "./ModA"; 10 | 11 | /*--- path: ModC.ts ---*/ 12 | 13 | import { b } from "./ModB"; 14 | 15 | b.f; 16 | //^ defined: 13, 9, 3 17 | // ^ defined: 4 18 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/separate-expression-and-type-identifiers.ts: -------------------------------------------------------------------------------- 1 | type my_number = number; 2 | 3 | let x1:my_number = 42; 4 | // ^ defined: 1 5 | 6 | let x2 = my_number; 7 | // ^ defined: 8 | 9 | let x3:x2 = 42; 10 | // ^ defined: 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/shadowing.ts: -------------------------------------------------------------------------------- 1 | type T = number; 2 | 3 | declare let x: T; 4 | 5 | class A { 6 | m(x: T) { 7 | // ^ defined: 5 8 | x; 9 | //^ defined: 6 10 | } 11 | } 12 | 13 | function f(x) { 14 | x; 15 | //^ defined: 13 16 | }; 17 | 18 | { 19 | type T = number; 20 | let x: T; 21 | // ^ defined: 19 22 | x; 23 | //^ defined: 20 24 | } 25 | 26 | function(x) { 27 | x; 28 | //^ defined: 26 29 | }; 30 | 31 | export {}; 32 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/var-and-let-hoisting.ts: -------------------------------------------------------------------------------- 1 | x + y; 2 | //^ defined: 5 3 | // ^ defined: 6 4 | 5 | var x = 2; 6 | let y = 1; // hoisted, but only here initialized 7 | 8 | export {}; 9 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/var-in-for-body-escapes.ts: -------------------------------------------------------------------------------- 1 | for(;;) var x = 42; 2 | 3 | x; 4 | //^ defined: 1 5 | 6 | export {}; 7 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/var-with-value.ts: -------------------------------------------------------------------------------- 1 | interface T { 2 | f: number; 3 | } 4 | 5 | var a:T = { f: 42 } as T; 6 | // ^ defined: 1 7 | // ^ defined: 1 8 | 9 | a.f; 10 | //^ defined: 5 11 | // ^ defined: 2 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/var-without-value.ts: -------------------------------------------------------------------------------- 1 | interface T { 2 | f: number; 3 | } 4 | 5 | var a:T; 6 | // ^ defined: 1 7 | 8 | a.f; 9 | //^ defined: 5 10 | // ^ defined: 2 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/statements/with.ts: -------------------------------------------------------------------------------- 1 | let x = { 2 | f: { 3 | v: 42 4 | } 5 | } 6 | 7 | with(x) { 8 | f.v; 9 | // ^ defined: 2 10 | // ^ defined: 3 11 | } 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/call-generic-function-with-generic-return-type-without-type-arguments.ts.skip: -------------------------------------------------------------------------------- 1 | interface V { 2 | value: number; 3 | } 4 | 5 | let id: (x: X) => X; 6 | // ^ defined: 5 7 | // ^ defined: 5 8 | 9 | let v: V; 10 | // ^ defined: 1 11 | 12 | 13 | id(v).value; 14 | //^ defined: 5 15 | // ^ defined: 9 16 | // ^ defined: 2 17 | 18 | export {} 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/class-extends-alias-of-generic-class.ts.skip: -------------------------------------------------------------------------------- 1 | interface V { v: number; } 2 | 3 | class A { declare f: X; }; 4 | // ^ defined: 3 5 | 6 | let a = A; 7 | // ^ defined: 3 8 | 9 | class B extends a {} 10 | // ^ defined: 6 11 | // ^ defined: 1 12 | 13 | declare let b: B; 14 | // ^ defined: 9 15 | 16 | b.f.v; 17 | //^ defined: 13 18 | // ^ defined: 3 19 | // ^ defined: 1 20 | 21 | export {}; 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/class-extends-and-implements.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | class A { 5 | f: number = 42; 6 | } 7 | 8 | 9 | 10 | 11 | class B extends A implements V {} 12 | // ^ defined: 4 13 | // ^ defined: 1 14 | 15 | let b: B; 16 | // ^ defined: 11 17 | 18 | b.v; 19 | //^ defined: 15 20 | // ^ defined: 2 21 | 22 | b.f; 23 | //^ defined: 15 24 | // ^ defined: 5 25 | 26 | 27 | export {}; 28 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/class-extends-class-returned-from-function.ts.skip: -------------------------------------------------------------------------------- 1 | interface V { v: number; } 2 | 3 | function f() { 4 | return class A { declare f: X; }; 5 | } 6 | // ^ defined: 3 7 | 8 | class B extends f() {} 9 | // ^ defined: 6 10 | // ^ defined: 1 11 | 12 | declare let b: B; 13 | // ^ defined: 9 14 | 15 | b.f.v; 16 | //^ defined: 13 17 | // ^ defined: 3 18 | // ^ defined: 1 19 | 20 | export {}; 21 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/class-extends-instance-of-generic-constructor-type.ts.skip: -------------------------------------------------------------------------------- 1 | interface V { v: number; } 2 | 3 | type A = new() => { f: X; }; 4 | // ^ defined: 3 5 | 6 | declare let a: A; 7 | // ^ defined: 3 8 | 9 | class B extends a {} 10 | // ^ defined: 6 11 | // ^ defined: 1 12 | 13 | declare let b: B; 14 | // ^ defined: 9 15 | 16 | b.f.v; 17 | //^ defined: 13 18 | // ^ defined: 3 19 | // ^ defined: 1 20 | 21 | export {}; 22 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/class-extends-via-alias.ts: -------------------------------------------------------------------------------- 1 | class A { 2 | f: number = 42; 3 | } 4 | 5 | let a = A; 6 | // ^ defined: 1 7 | 8 | class B extends a {} 9 | // ^ defined: 5 10 | 11 | let b: B; 12 | // ^ defined: 8 13 | 14 | b.f; 15 | //^ defined: 11 16 | // ^ defined: 2 17 | 18 | export {}; 19 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/class-implements-multiple-interfaces.ts: -------------------------------------------------------------------------------- 1 | interface A { 2 | f: number; 3 | } 4 | 5 | interface B { 6 | g: number; 7 | } 8 | 9 | abstract class C 10 | implements A, B 11 | // ^ defined: 1 12 | // ^ defined: 5 13 | { 14 | test() { 15 | return this.f + this.g; 16 | // ^ defined: 2 17 | // ^ defined: 6 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/generic-interface-with-generic-field.ts.bug: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | interface I { 6 | f: T; 7 | // ^ defined: 5 8 | } 9 | 10 | interface J { 11 | g: I; 12 | // ^ defined: 5 13 | // ^ defined: 10 14 | } 15 | 16 | var x: J; 17 | // ^ defined: 10 18 | // ^ defined: 1 19 | 20 | x.g.f.v; 21 | //^ defined: 16 22 | // ^ defined: 11 23 | // ^ defined: 6 24 | // ^ defined: 2 25 | 26 | export {}; 27 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/generic-interface-with-generic-super-type.ts.bug: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | interface I { 6 | f: T; 7 | // ^ defined: 5 8 | } 9 | 10 | interface J extends I { 11 | // ^ defined: 5 12 | // ^ defined: 10 13 | } 14 | 15 | var x: J; 16 | // ^ defined: 10 17 | // ^ defined: 1 18 | 19 | x.f.v; 20 | //^ defined: 15 21 | // ^ defined: 6 22 | // ^ defined: 2 23 | 24 | export {}; 25 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/generic-type-alias.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | 5 | type Id = T; 6 | 7 | declare let x: Id; 8 | // ^ defined: 5 9 | // ^ defined: 1 10 | 11 | x.v; 12 | //^ defined: 7 13 | // ^ defined: 2 14 | 15 | export {}; 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/indexed-lookup-type.ts.skip: -------------------------------------------------------------------------------- 1 | type T = { X: number }; 2 | 3 | type U = { X: { f: number } }; 4 | 5 | let x: U[keyof T]; 6 | // ^ defined: 3 7 | // ^ defined: 1 8 | 9 | x.f; 10 | //^ defined: 5 11 | // ^ defined: 3 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/indexed-type.ts.skip: -------------------------------------------------------------------------------- 1 | type T = "T"; 2 | 3 | type U = { T: { f: number } }; 4 | 5 | let x: U[T]; 6 | // ^ defined: 3 7 | // ^ defined: 1 8 | 9 | x.f; 10 | //^ defined: 5 11 | // ^ defined: 3 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/interface-extends-multiple-interfaces.ts: -------------------------------------------------------------------------------- 1 | interface A { 2 | f: number; 3 | } 4 | 5 | interface B { 6 | g: number; 7 | } 8 | 9 | interface C 10 | extends A, B {} 11 | // ^ defined: 1 12 | // ^ defined: 5 13 | 14 | function test(c: C) { 15 | return c.f + c.g; 16 | // ^ defined: 2 17 | // ^ defined: 6 18 | } 19 | 20 | export {}; 21 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/interface-extends.ts: -------------------------------------------------------------------------------- 1 | interface V { 2 | v: number; 3 | } 4 | interface I extends V {} 5 | 6 | let x: I; 7 | // ^ defined: 4 8 | 9 | x.v; 10 | //^ defined: 6 11 | // ^ defined: 2 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/qualified-type-query.ts: -------------------------------------------------------------------------------- 1 | let x = { 2 | y: { 3 | z: number 4 | } 5 | }; 6 | 7 | function test(a: typeof x.y.z) { 8 | // ^ defined: 1 9 | // ^ defined: 2 10 | // ^ defined: 3 11 | } 12 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/tuple-type.ts: -------------------------------------------------------------------------------- 1 | interface V { v: number; } 2 | interface N { n: number; } 3 | 4 | type T = [V, N]; 5 | 6 | declare let t: T; 7 | 8 | t[0].v; 9 | //^ defined: 6 10 | // ^ defined: 1 11 | 12 | t[1].n; 13 | //^ defined: 6 14 | // ^ defined: 2 15 | 16 | export {}; 17 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/typeof-call.ts: -------------------------------------------------------------------------------- 1 | function x(): { g: number } { 2 | return { g: 42 }; 3 | } 4 | 5 | let y: typeof x(); 6 | // ^ defined: 1 7 | 8 | y.g; 9 | //^ defined: 5 10 | // ^ defined: 1 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/typeof-member.ts: -------------------------------------------------------------------------------- 1 | let x: { 2 | f: { 3 | g: number; 4 | } 5 | }; 6 | 7 | let y: typeof x.f; 8 | // ^ defined: 1 9 | // ^ defined: 2 10 | 11 | y.g; 12 | //^ defined: 7 13 | // ^ defined: 3 14 | 15 | export {}; 16 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/test/types/typeof-variable.ts: -------------------------------------------------------------------------------- 1 | let x: { f: string }; 2 | 3 | let y: typeof x = { f: "fortytwo" }; 4 | // ^ defined: 1 5 | 6 | y.f; 7 | //^ defined: 3 8 | // ^ defined: 1 9 | 10 | export {}; 11 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/vscode/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /out/ 3 | /target/ 4 | -------------------------------------------------------------------------------- /languages/tree-sitter-stack-graphs-typescript/vscode/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "CommonJS", 4 | "target": "ES2021", 5 | "outDir": "out", 6 | "rootDir": "src" 7 | }, 8 | "include": [ "src" ], 9 | "exclude": [ "node_modules" ] 10 | } 11 | -------------------------------------------------------------------------------- /script/ci-comment-json: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eu 4 | 5 | printf '{"body":"' 6 | cat | awk -v ORS='\\n' '1' 7 | printf '"}' 8 | -------------------------------------------------------------------------------- /script/ci-test-init: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eu 4 | 5 | cargo run --bin tree-sitter-stack-graphs --features cli -- init \ 6 | --language-name InitTest \ 7 | --language-id init_test \ 8 | --language-file-extension it \ 9 | --grammar-crate-name tree-sitter-python \ 10 | --grammar-crate-version 0.23.2 \ 11 | --internal \ 12 | --non-interactive 13 | 14 | cargo check -p tree-sitter-stack-graphs-init_test --all-features 15 | 16 | cargo test -p tree-sitter-stack-graphs-init_test 17 | 18 | cargo run -p tree-sitter-stack-graphs-init_test --features cli -- -V 19 | -------------------------------------------------------------------------------- /stack-graphs/cbindgen.toml: -------------------------------------------------------------------------------- 1 | language = "C" 2 | include_guard = "STACK_GRAPHS_H_" 3 | autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */" 4 | 5 | documentation = true 6 | documentation_style = "c99" 7 | cpp_compat = true 8 | no_includes = false 9 | style = "tag" 10 | tab_width = 4 11 | usize_is_size_t = true 12 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/.gitignore: -------------------------------------------------------------------------------- 1 | /.tree-sitter-python@* 2 | /**/tests/*.html 3 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/bootstrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -eu 4 | 5 | dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) 6 | 7 | py_pkg="tree-sitter-python@0.20.1" 8 | py_dir="$dir/.$py_pkg" 9 | 10 | if [ ! -e "$py_dir" ]; then 11 | mkdir "$py_dir" 12 | curl -s "$(npm v "$py_pkg" dist.tarball)" | tar -xz --strip-components=1 --directory "$py_dir" 13 | fi 14 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/modules/tests/import-all-definitions-from-nested-module.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/bar.py --- 2 | 3 | def baz(): 4 | pass 5 | 6 | # --- path: test.py --- 7 | 8 | from foo.bar import * 9 | 10 | baz() 11 | # ^ defined: 3 12 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/modules/tests/import-all-definitions-from-toplevel-module.py: -------------------------------------------------------------------------------- 1 | # --- path: foo.py --- 2 | 3 | def bar(): 4 | pass 5 | 6 | # --- path: test.py --- 7 | 8 | from foo import * 9 | 10 | bar() 11 | # ^ defined: 3 12 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/modules/tests/import-single-definition-from-nested-module.py: -------------------------------------------------------------------------------- 1 | # --- path: foo/bar.py --- 2 | 3 | def baz(): 4 | pass 5 | 6 | # --- path: test.py --- 7 | 8 | from foo.bar import baz 9 | 10 | baz() 11 | # ^ defined: 3 12 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/modules/tests/import-single-definition-from-toplevel-module.py: -------------------------------------------------------------------------------- 1 | # --- path: foo.py --- 2 | 3 | def bar(): 4 | pass 5 | 6 | # --- path: test.py --- 7 | 8 | from foo import bar 9 | 10 | bar() 11 | # ^ defined: 3 12 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/nested-scope/tests/nested-def.py: -------------------------------------------------------------------------------- 1 | def foo(): 2 | def bar(): 3 | pass 4 | bar() 5 | # ^ defined: 2 6 | 7 | foo() 8 | # ^ defined: 1 9 | 10 | bar() 11 | # ^ defined: 12 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/nested-scope/tests/shadowing.py: -------------------------------------------------------------------------------- 1 | def foo(): 2 | pass 3 | 4 | def bar(): 5 | def foo(): 6 | pass 7 | foo() 8 | # ^ defined: 5 9 | 10 | foo() 11 | # ^ defined: 1 12 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/nested-scope/tests/top-level-defs.py: -------------------------------------------------------------------------------- 1 | def foo(): 2 | bar() 3 | # ^ defined: 5 4 | 5 | def bar(): 6 | pass 7 | 8 | foo() 9 | # ^ defined: 1 10 | -------------------------------------------------------------------------------- /tree-sitter-stack-graphs/examples/sequential-definitions/tests/shadow-previous-def.py: -------------------------------------------------------------------------------- 1 | def foo(): 2 | pass 3 | 4 | bar() 5 | # ^ defined: 6 | 7 | def bar(): 8 | pass 9 | 10 | foo() 11 | # ^ defined: 1 12 | 13 | def foo(): 14 | pass 15 | 16 | foo() 17 | # ^ defined: 13 18 | -------------------------------------------------------------------------------- /valgrind.supp: -------------------------------------------------------------------------------- 1 | { 2 | rust-1.83-false-positive-1 3 | Memcheck:Leak 4 | match-leak-kinds: possible 5 | fun:malloc 6 | ... 7 | fun:main 8 | } 9 | --------------------------------------------------------------------------------