@lzehrung/codegraph 2.3.31 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -141
- package/codegraph-skill/codegraph/SKILL.md +8 -6
- package/dist/agent/artifact.d.ts +2 -0
- package/dist/agent/artifact.d.ts.map +1 -1
- package/dist/agent/artifact.js.map +1 -1
- package/dist/agent/call-hierarchy.js +2 -4
- package/dist/agent/call-hierarchy.js.map +1 -1
- package/dist/agent/explore.d.ts +1 -1
- package/dist/agent/explore.d.ts.map +1 -1
- package/dist/agent/explore.js +3 -2
- package/dist/agent/explore.js.map +1 -1
- package/dist/agent/refactor-plan.js +2 -4
- package/dist/agent/refactor-plan.js.map +1 -1
- package/dist/agent/rename-preview.d.ts.map +1 -1
- package/dist/agent/rename-preview.js +4 -3
- package/dist/agent/rename-preview.js.map +1 -1
- package/dist/agent/search.d.ts.map +1 -1
- package/dist/agent/search.js +5 -3
- package/dist/agent/search.js.map +1 -1
- package/dist/agent/semantic-symbols.d.ts.map +1 -1
- package/dist/agent/semantic-symbols.js +2 -3
- package/dist/agent/semantic-symbols.js.map +1 -1
- package/dist/agent/session.d.ts +3 -0
- package/dist/agent/session.d.ts.map +1 -1
- package/dist/agent/session.js +10 -2
- package/dist/agent/session.js.map +1 -1
- package/dist/agent/type-hierarchy.js +2 -4
- package/dist/agent/type-hierarchy.js.map +1 -1
- package/dist/agent/workspace-symbols.d.ts.map +1 -1
- package/dist/agent/workspace-symbols.js +2 -3
- package/dist/agent/workspace-symbols.js.map +1 -1
- package/dist/agent-tools.d.ts +0 -4
- package/dist/agent-tools.d.ts.map +1 -1
- package/dist/agent-tools.js +3 -6
- package/dist/agent-tools.js.map +1 -1
- package/dist/analysis-summary.d.ts +8 -4
- package/dist/analysis-summary.d.ts.map +1 -1
- package/dist/analysis-summary.js +15 -66
- package/dist/analysis-summary.js.map +1 -1
- package/dist/bin/cli.js +51145 -41770
- package/dist/bin/query-index-worker.js +122 -82
- package/dist/cli/affected.d.ts.map +1 -1
- package/dist/cli/affected.js +4 -1
- package/dist/cli/affected.js.map +1 -1
- package/dist/cli/command-catalog.js +1 -1
- package/dist/cli/command-catalog.js.map +1 -1
- package/dist/cli/command-table.d.ts.map +1 -1
- package/dist/cli/command-table.js +9 -17
- package/dist/cli/command-table.js.map +1 -1
- package/dist/cli/context.js +10 -10
- package/dist/cli/context.js.map +1 -1
- package/dist/cli/drift.d.ts +0 -2
- package/dist/cli/drift.d.ts.map +1 -1
- package/dist/cli/drift.js +0 -1
- package/dist/cli/drift.js.map +1 -1
- package/dist/cli/graph-delta.d.ts +0 -2
- package/dist/cli/graph-delta.d.ts.map +1 -1
- package/dist/cli/graph-delta.js +0 -4
- package/dist/cli/graph-delta.js.map +1 -1
- package/dist/cli/graph-queries.d.ts.map +1 -1
- package/dist/cli/graph-queries.js +27 -1
- package/dist/cli/graph-queries.js.map +1 -1
- package/dist/cli/graph.d.ts +0 -3
- package/dist/cli/graph.d.ts.map +1 -1
- package/dist/cli/graph.js +4 -14
- package/dist/cli/graph.js.map +1 -1
- package/dist/cli/help.d.ts +34 -34
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +9 -14
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/impact.d.ts +0 -2
- package/dist/cli/impact.d.ts.map +1 -1
- package/dist/cli/impact.js +0 -1
- package/dist/cli/impact.js.map +1 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +5 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/inspect.d.ts +0 -2
- package/dist/cli/inspect.d.ts.map +1 -1
- package/dist/cli/inspect.js +5 -8
- package/dist/cli/inspect.js.map +1 -1
- package/dist/cli/invocation-context.d.ts +0 -3
- package/dist/cli/invocation-context.d.ts.map +1 -1
- package/dist/cli/invocation-context.js +4 -16
- package/dist/cli/invocation-context.js.map +1 -1
- package/dist/cli/navigation.d.ts +0 -2
- package/dist/cli/navigation.d.ts.map +1 -1
- package/dist/cli/navigation.js +0 -1
- package/dist/cli/navigation.js.map +1 -1
- package/dist/cli/options.d.ts.map +1 -1
- package/dist/cli/options.js +4 -14
- package/dist/cli/options.js.map +1 -1
- package/dist/cli/review.d.ts +0 -2
- package/dist/cli/review.d.ts.map +1 -1
- package/dist/cli/review.js +0 -5
- package/dist/cli/review.js.map +1 -1
- package/dist/cli/root-policy.d.ts +0 -2
- package/dist/cli/root-policy.d.ts.map +1 -1
- package/dist/cli/root-policy.js +0 -8
- package/dist/cli/root-policy.js.map +1 -1
- package/dist/cli/server.d.ts.map +1 -1
- package/dist/cli/server.js +0 -2
- package/dist/cli/server.js.map +1 -1
- package/dist/drift/artifact.d.ts.map +1 -1
- package/dist/drift/artifact.js +15 -18
- package/dist/drift/artifact.js.map +1 -1
- package/dist/drift/compare.js +1 -1
- package/dist/drift/compare.js.map +1 -1
- package/dist/drift/git.d.ts.map +1 -1
- package/dist/drift/git.js +0 -1
- package/dist/drift/git.js.map +1 -1
- package/dist/drift/snapshot.d.ts.map +1 -1
- package/dist/drift/snapshot.js +5 -7
- package/dist/drift/snapshot.js.map +1 -1
- package/dist/drift/types.d.ts +2 -2
- package/dist/drift/types.d.ts.map +1 -1
- package/dist/drift/types.js.map +1 -1
- package/dist/duplicates/unit-cache.d.ts +0 -1
- package/dist/duplicates/unit-cache.d.ts.map +1 -1
- package/dist/duplicates/unit-cache.js +3 -11
- package/dist/duplicates/unit-cache.js.map +1 -1
- package/dist/duplicates/units.d.ts +5 -5
- package/dist/duplicates/units.d.ts.map +1 -1
- package/dist/duplicates/units.js +25 -88
- package/dist/duplicates/units.js.map +1 -1
- package/dist/graph-builder.d.ts +0 -6
- package/dist/graph-builder.d.ts.map +1 -1
- package/dist/graph-builder.js +6 -11
- package/dist/graph-builder.js.map +1 -1
- package/dist/graph-edge-collector.d.ts +4 -6
- package/dist/graph-edge-collector.d.ts.map +1 -1
- package/dist/graph-edge-collector.js +31 -26
- package/dist/graph-edge-collector.js.map +1 -1
- package/dist/graphs/angularjs.d.ts.map +1 -1
- package/dist/graphs/angularjs.js +2 -1
- package/dist/graphs/angularjs.js.map +1 -1
- package/dist/graphs/edge-resolution.d.ts +4 -1
- package/dist/graphs/edge-resolution.d.ts.map +1 -1
- package/dist/graphs/edge-resolution.js +24 -76
- package/dist/graphs/edge-resolution.js.map +1 -1
- package/dist/graphs/specifiers.d.ts +4 -13
- package/dist/graphs/specifiers.d.ts.map +1 -1
- package/dist/graphs/specifiers.js +80 -173
- package/dist/graphs/specifiers.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/ast.d.ts +20 -0
- package/dist/graphs/symbol-graph-detailed/ast.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/ast.js +154 -15
- package/dist/graphs/symbol-graph-detailed/ast.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts +60 -8
- package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/edge-passes.js +997 -168
- package/dist/graphs/symbol-graph-detailed/edge-passes.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/import-aliases.d.ts +2 -1
- package/dist/graphs/symbol-graph-detailed/import-aliases.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/import-aliases.js +150 -7
- package/dist/graphs/symbol-graph-detailed/import-aliases.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/member-chains.d.ts +1 -0
- package/dist/graphs/symbol-graph-detailed/member-chains.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/member-chains.js +3 -1
- package/dist/graphs/symbol-graph-detailed/member-chains.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts +141 -25
- package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/receiver-calls.js +1015 -166
- package/dist/graphs/symbol-graph-detailed/receiver-calls.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed.js +449 -46
- package/dist/graphs/symbol-graph-detailed.js.map +1 -1
- package/dist/graphs/symbol-graph.d.ts +2 -0
- package/dist/graphs/symbol-graph.d.ts.map +1 -1
- package/dist/graphs/symbol-graph.js +34 -16
- package/dist/graphs/symbol-graph.js.map +1 -1
- package/dist/graphs/types.d.ts +0 -4
- package/dist/graphs/types.d.ts.map +1 -1
- package/dist/graphs.d.ts +1 -1
- package/dist/graphs.d.ts.map +1 -1
- package/dist/impact/call-compatibility/providers/index.d.ts +4 -4
- package/dist/impact/call-compatibility/providers/index.d.ts.map +1 -1
- package/dist/impact/call-compatibility/providers/index.js +6 -6
- package/dist/impact/call-compatibility/providers/index.js.map +1 -1
- package/dist/impact/call-compatibility/providers/types.d.ts +2 -0
- package/dist/impact/call-compatibility/providers/types.d.ts.map +1 -1
- package/dist/impact/call-compatibility/types.d.ts +6 -0
- package/dist/impact/call-compatibility/types.d.ts.map +1 -1
- package/dist/impact/call-compatibility.d.ts.map +1 -1
- package/dist/impact/call-compatibility.js +316 -526
- package/dist/impact/call-compatibility.js.map +1 -1
- package/dist/impact/map.js +1 -0
- package/dist/impact/map.js.map +1 -1
- package/dist/impact/reference-cache.d.ts.map +1 -1
- package/dist/impact/reference-cache.js +2 -2
- package/dist/impact/reference-cache.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/indexer/ambiguous-resolution.d.ts +11 -0
- package/dist/indexer/ambiguous-resolution.d.ts.map +1 -0
- package/dist/indexer/ambiguous-resolution.js +19 -0
- package/dist/indexer/ambiguous-resolution.js.map +1 -0
- package/dist/indexer/build-cache/module-cache.d.ts +39 -1
- package/dist/indexer/build-cache/module-cache.d.ts.map +1 -1
- package/dist/indexer/build-cache/module-cache.js +218 -21
- package/dist/indexer/build-cache/module-cache.js.map +1 -1
- package/dist/indexer/build-cache/options.d.ts +30 -44
- package/dist/indexer/build-cache/options.d.ts.map +1 -1
- package/dist/indexer/build-cache/options.js +32 -71
- package/dist/indexer/build-cache/options.js.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.d.ts +3 -3
- package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.js +164 -84
- package/dist/indexer/build-cache/project-snapshot.js.map +1 -1
- package/dist/indexer/build-cache/reports.d.ts +0 -2
- package/dist/indexer/build-cache/reports.d.ts.map +1 -1
- package/dist/indexer/build-cache/reports.js +0 -97
- package/dist/indexer/build-cache/reports.js.map +1 -1
- package/dist/indexer/build-cache/resolver-environment.d.ts.map +1 -1
- package/dist/indexer/build-cache/resolver-environment.js +32 -2
- package/dist/indexer/build-cache/resolver-environment.js.map +1 -1
- package/dist/indexer/build-cache.d.ts +2 -2
- package/dist/indexer/build-cache.d.ts.map +1 -1
- package/dist/indexer/build-cache.js +2 -2
- package/dist/indexer/build-cache.js.map +1 -1
- package/dist/indexer/build-index.d.ts.map +1 -1
- package/dist/indexer/build-index.js +656 -71
- package/dist/indexer/build-index.js.map +1 -1
- package/dist/indexer/build-workers.d.ts.map +1 -1
- package/dist/indexer/build-workers.js +9 -9
- package/dist/indexer/build-workers.js.map +1 -1
- package/dist/indexer/call-hierarchy.js +1 -1
- package/dist/indexer/call-hierarchy.js.map +1 -1
- package/dist/indexer/callable-identity.d.ts +24 -0
- package/dist/indexer/callable-identity.d.ts.map +1 -0
- package/dist/indexer/callable-identity.js +111 -0
- package/dist/indexer/callable-identity.js.map +1 -0
- package/dist/indexer/compilation-units.d.ts +103 -0
- package/dist/indexer/compilation-units.d.ts.map +1 -0
- package/dist/indexer/compilation-units.js +607 -0
- package/dist/indexer/compilation-units.js.map +1 -0
- package/dist/indexer/cpp-callables.d.ts +25 -0
- package/dist/indexer/cpp-callables.d.ts.map +1 -0
- package/dist/indexer/cpp-callables.js +562 -0
- package/dist/indexer/cpp-callables.js.map +1 -0
- package/dist/indexer/declaration-visibility.d.ts +43 -2
- package/dist/indexer/declaration-visibility.d.ts.map +1 -1
- package/dist/indexer/declaration-visibility.js +158 -2
- package/dist/indexer/declaration-visibility.js.map +1 -1
- package/dist/indexer/expand-star-imports.d.ts +6 -1
- package/dist/indexer/expand-star-imports.d.ts.map +1 -1
- package/dist/indexer/expand-star-imports.js +131 -37
- package/dist/indexer/expand-star-imports.js.map +1 -1
- package/dist/indexer/finalize.d.ts.map +1 -1
- package/dist/indexer/finalize.js +0 -1
- package/dist/indexer/finalize.js.map +1 -1
- package/dist/indexer/import-resolution-tables.d.ts +72 -0
- package/dist/indexer/import-resolution-tables.d.ts.map +1 -0
- package/dist/indexer/import-resolution-tables.js +137 -0
- package/dist/indexer/import-resolution-tables.js.map +1 -0
- package/dist/indexer/import-types.d.ts +54 -0
- package/dist/indexer/import-types.d.ts.map +1 -1
- package/dist/indexer/import-types.js +24 -1
- package/dist/indexer/import-types.js.map +1 -1
- package/dist/indexer/imports/context.d.ts +16 -1
- package/dist/indexer/imports/context.d.ts.map +1 -1
- package/dist/indexer/imports/import-binding-tables.d.ts +13 -1
- package/dist/indexer/imports/import-binding-tables.d.ts.map +1 -1
- package/dist/indexer/imports/import-binding-tables.js +149 -30
- package/dist/indexer/imports/import-binding-tables.js.map +1 -1
- package/dist/indexer/imports/js-text-imports.js +4 -4
- package/dist/indexer/imports/js-text-imports.js.map +1 -1
- package/dist/indexer/imports/native-captures.d.ts.map +1 -1
- package/dist/indexer/imports/native-captures.js +24 -6
- package/dist/indexer/imports/native-captures.js.map +1 -1
- package/dist/indexer/imports/python.d.ts +10 -2
- package/dist/indexer/imports/python.d.ts.map +1 -1
- package/dist/indexer/imports/python.js +128 -112
- package/dist/indexer/imports/python.js.map +1 -1
- package/dist/indexer/imports/text-import-extractors.d.ts.map +1 -1
- package/dist/indexer/imports/text-import-extractors.js +68 -19
- package/dist/indexer/imports/text-import-extractors.js.map +1 -1
- package/dist/indexer/imports.d.ts +3 -4
- package/dist/indexer/imports.d.ts.map +1 -1
- package/dist/indexer/imports.js +116 -72
- package/dist/indexer/imports.js.map +1 -1
- package/dist/indexer/incremental-plan.d.ts +33 -0
- package/dist/indexer/incremental-plan.d.ts.map +1 -1
- package/dist/indexer/incremental-plan.js +203 -1
- package/dist/indexer/incremental-plan.js.map +1 -1
- package/dist/indexer/locals-and-exports.d.ts +3 -2
- package/dist/indexer/locals-and-exports.d.ts.map +1 -1
- package/dist/indexer/locals-and-exports.js +659 -78
- package/dist/indexer/locals-and-exports.js.map +1 -1
- package/dist/indexer/member-selection.d.ts +46 -0
- package/dist/indexer/member-selection.d.ts.map +1 -0
- package/dist/indexer/member-selection.js +169 -0
- package/dist/indexer/member-selection.js.map +1 -0
- package/dist/indexer/name-lookup-policies/c-family.d.ts +7 -0
- package/dist/indexer/name-lookup-policies/c-family.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/c-family.js +137 -0
- package/dist/indexer/name-lookup-policies/c-family.js.map +1 -0
- package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts +11 -0
- package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/csharp-using-static.js +136 -0
- package/dist/indexer/name-lookup-policies/csharp-using-static.js.map +1 -0
- package/dist/indexer/name-lookup-policies/implicit-self.d.ts +10 -0
- package/dist/indexer/name-lookup-policies/implicit-self.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/implicit-self.js +119 -0
- package/dist/indexer/name-lookup-policies/implicit-self.js.map +1 -0
- package/dist/indexer/name-lookup-policies/index.d.ts +3 -0
- package/dist/indexer/name-lookup-policies/index.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/index.js +132 -0
- package/dist/indexer/name-lookup-policies/index.js.map +1 -0
- package/dist/indexer/name-lookup-policies/php.d.ts +3 -0
- package/dist/indexer/name-lookup-policies/php.d.ts.map +1 -0
- package/dist/indexer/name-lookup-policies/php.js +82 -0
- package/dist/indexer/name-lookup-policies/php.js.map +1 -0
- package/dist/indexer/name-resolution-types.d.ts +101 -0
- package/dist/indexer/name-resolution-types.d.ts.map +1 -0
- package/dist/indexer/name-resolution-types.js +2 -0
- package/dist/indexer/name-resolution-types.js.map +1 -0
- package/dist/indexer/name-resolution.d.ts +57 -0
- package/dist/indexer/name-resolution.d.ts.map +1 -0
- package/dist/indexer/name-resolution.js +204 -0
- package/dist/indexer/name-resolution.js.map +1 -0
- package/dist/indexer/navigation-cpp.d.ts +58 -0
- package/dist/indexer/navigation-cpp.d.ts.map +1 -0
- package/dist/indexer/navigation-cpp.js +935 -0
- package/dist/indexer/navigation-cpp.js.map +1 -0
- package/dist/indexer/navigation-goto.d.ts +115 -3
- package/dist/indexer/navigation-goto.d.ts.map +1 -1
- package/dist/indexer/navigation-goto.js +2469 -190
- package/dist/indexer/navigation-goto.js.map +1 -1
- package/dist/indexer/navigation-local.d.ts +21 -2
- package/dist/indexer/navigation-local.d.ts.map +1 -1
- package/dist/indexer/navigation-local.js +520 -63
- package/dist/indexer/navigation-local.js.map +1 -1
- package/dist/indexer/navigation-php.d.ts +66 -0
- package/dist/indexer/navigation-php.d.ts.map +1 -1
- package/dist/indexer/navigation-php.js +287 -4
- package/dist/indexer/navigation-php.js.map +1 -1
- package/dist/indexer/navigation-provenance.d.ts +1 -1
- package/dist/indexer/navigation-provenance.d.ts.map +1 -1
- package/dist/indexer/navigation-provenance.js +4 -13
- package/dist/indexer/navigation-provenance.js.map +1 -1
- package/dist/indexer/navigation-references.d.ts +73 -6
- package/dist/indexer/navigation-references.d.ts.map +1 -1
- package/dist/indexer/navigation-references.js +661 -67
- package/dist/indexer/navigation-references.js.map +1 -1
- package/dist/indexer/navigation-resolve.d.ts +46 -2
- package/dist/indexer/navigation-resolve.d.ts.map +1 -1
- package/dist/indexer/navigation-resolve.js +599 -193
- package/dist/indexer/navigation-resolve.js.map +1 -1
- package/dist/indexer/navigation.d.ts +29 -2
- package/dist/indexer/navigation.d.ts.map +1 -1
- package/dist/indexer/navigation.js +1092 -153
- package/dist/indexer/navigation.js.map +1 -1
- package/dist/indexer/parse-context.d.ts +2 -3
- package/dist/indexer/parse-context.d.ts.map +1 -1
- package/dist/indexer/parse-context.js +8 -21
- package/dist/indexer/parse-context.js.map +1 -1
- package/dist/indexer/php-namespace-symbols.d.ts +66 -0
- package/dist/indexer/php-namespace-symbols.d.ts.map +1 -0
- package/dist/indexer/php-namespace-symbols.js +342 -0
- package/dist/indexer/php-namespace-symbols.js.map +1 -0
- package/dist/indexer/reference-candidates.d.ts.map +1 -1
- package/dist/indexer/reference-candidates.js +13 -7
- package/dist/indexer/reference-candidates.js.map +1 -1
- package/dist/indexer/reference-context.d.ts +2 -0
- package/dist/indexer/reference-context.d.ts.map +1 -1
- package/dist/indexer/reference-context.js +4 -0
- package/dist/indexer/reference-context.js.map +1 -1
- package/dist/indexer/scope-nodes.d.ts +92 -13
- package/dist/indexer/scope-nodes.d.ts.map +1 -1
- package/dist/indexer/scope-nodes.js +212 -20
- package/dist/indexer/scope-nodes.js.map +1 -1
- package/dist/indexer/scope-types.d.ts +29 -1
- package/dist/indexer/scope-types.d.ts.map +1 -1
- package/dist/indexer/scope.d.ts +2 -3
- package/dist/indexer/scope.d.ts.map +1 -1
- package/dist/indexer/scope.js +968 -47
- package/dist/indexer/scope.js.map +1 -1
- package/dist/indexer/shared-owner-identity.d.ts +53 -0
- package/dist/indexer/shared-owner-identity.d.ts.map +1 -0
- package/dist/indexer/shared-owner-identity.js +460 -0
- package/dist/indexer/shared-owner-identity.js.map +1 -0
- package/dist/indexer/shared.d.ts +1 -1
- package/dist/indexer/shared.d.ts.map +1 -1
- package/dist/indexer/shared.js +1 -1
- package/dist/indexer/shared.js.map +1 -1
- package/dist/indexer/star-import-precedence.d.ts +113 -0
- package/dist/indexer/star-import-precedence.d.ts.map +1 -0
- package/dist/indexer/star-import-precedence.js +402 -0
- package/dist/indexer/star-import-precedence.js.map +1 -0
- package/dist/indexer/symbols.d.ts +3 -1
- package/dist/indexer/symbols.d.ts.map +1 -1
- package/dist/indexer/symbols.js +58 -18
- package/dist/indexer/symbols.js.map +1 -1
- package/dist/indexer/ts-callables.d.ts +42 -0
- package/dist/indexer/ts-callables.d.ts.map +1 -0
- package/dist/indexer/ts-callables.js +233 -0
- package/dist/indexer/ts-callables.js.map +1 -0
- package/dist/indexer/types.d.ts +41 -26
- package/dist/indexer/types.d.ts.map +1 -1
- package/dist/indexer/unused-exports.d.ts +13 -0
- package/dist/indexer/unused-exports.d.ts.map +1 -0
- package/dist/indexer/unused-exports.js +159 -0
- package/dist/indexer/unused-exports.js.map +1 -0
- package/dist/indexer/workspace-symbols.d.ts.map +1 -1
- package/dist/indexer/workspace-symbols.js +3 -2
- package/dist/indexer/workspace-symbols.js.map +1 -1
- package/dist/indexer.d.ts +3 -8
- package/dist/indexer.d.ts.map +1 -1
- package/dist/indexer.js +1 -1
- package/dist/indexer.js.map +1 -1
- package/dist/languages/callable-arity.d.ts +223 -0
- package/dist/languages/callable-arity.d.ts.map +1 -0
- package/dist/languages/callable-arity.js +1199 -0
- package/dist/languages/callable-arity.js.map +1 -0
- package/dist/languages/definitions/c-family.d.ts.map +1 -1
- package/dist/languages/definitions/c-family.js +30 -1
- package/dist/languages/definitions/c-family.js.map +1 -1
- package/dist/languages/definitions/c.d.ts +4 -0
- package/dist/languages/definitions/c.d.ts.map +1 -1
- package/dist/languages/definitions/c.js +19 -0
- package/dist/languages/definitions/c.js.map +1 -1
- package/dist/languages/definitions/cpp.d.ts.map +1 -1
- package/dist/languages/definitions/cpp.js +12 -0
- package/dist/languages/definitions/cpp.js.map +1 -1
- package/dist/languages/definitions/csharp.d.ts.map +1 -1
- package/dist/languages/definitions/csharp.js +2 -8
- package/dist/languages/definitions/csharp.js.map +1 -1
- package/dist/languages/definitions/go.d.ts.map +1 -1
- package/dist/languages/definitions/go.js +3 -0
- package/dist/languages/definitions/go.js.map +1 -1
- package/dist/languages/definitions/javascript.d.ts.map +1 -1
- package/dist/languages/definitions/javascript.js +10 -1
- package/dist/languages/definitions/javascript.js.map +1 -1
- package/dist/languages/definitions/js-family.d.ts +1 -1
- package/dist/languages/definitions/js-family.d.ts.map +1 -1
- package/dist/languages/definitions/js-family.js +7 -1
- package/dist/languages/definitions/js-family.js.map +1 -1
- package/dist/languages/definitions/php.d.ts.map +1 -1
- package/dist/languages/definitions/php.js +5 -1
- package/dist/languages/definitions/php.js.map +1 -1
- package/dist/languages/definitions/typescript.d.ts.map +1 -1
- package/dist/languages/definitions/typescript.js +8 -1
- package/dist/languages/definitions/typescript.js.map +1 -1
- package/dist/languages/definitions/zig.d.ts.map +1 -1
- package/dist/languages/definitions/zig.js +8 -0
- package/dist/languages/definitions/zig.js.map +1 -1
- package/dist/lifecycle/manifest.d.ts.map +1 -1
- package/dist/lifecycle/manifest.js +0 -1
- package/dist/lifecycle/manifest.js.map +1 -1
- package/dist/mcp/handlers.js +14 -7
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/native/byte-index.d.ts +6 -0
- package/dist/native/byte-index.d.ts.map +1 -1
- package/dist/native/byte-index.js +11 -6
- package/dist/native/byte-index.js.map +1 -1
- package/dist/native/contracts.d.ts +2 -3
- package/dist/native/contracts.d.ts.map +1 -1
- package/dist/native/execution.d.ts +9 -9
- package/dist/native/execution.d.ts.map +1 -1
- package/dist/native/execution.js +37 -77
- package/dist/native/execution.js.map +1 -1
- package/dist/native/js-bridge.d.ts +2 -15
- package/dist/native/js-bridge.d.ts.map +1 -1
- package/dist/native/js-bridge.js +2 -15
- package/dist/native/js-bridge.js.map +1 -1
- package/dist/native/query-results.js +2 -2
- package/dist/native/query-results.js.map +1 -1
- package/dist/native/runtime.d.ts +12 -12
- package/dist/native/runtime.d.ts.map +1 -1
- package/dist/native/runtime.js +24 -69
- package/dist/native/runtime.js.map +1 -1
- package/dist/native/tree-sitter-native.d.ts +3 -3
- package/dist/native/tree-sitter-native.d.ts.map +1 -1
- package/dist/native/tree-sitter-native.js +2 -2
- package/dist/native/tree-sitter-native.js.map +1 -1
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +0 -4
- package/dist/presets.js.map +1 -1
- package/dist/review/candidates.d.ts.map +1 -1
- package/dist/review/candidates.js +1 -1
- package/dist/review/candidates.js.map +1 -1
- package/dist/review/deleted.d.ts +3 -3
- package/dist/review/deleted.d.ts.map +1 -1
- package/dist/review/deleted.js +82 -32
- package/dist/review/deleted.js.map +1 -1
- package/dist/review/report.d.ts +1 -0
- package/dist/review/report.d.ts.map +1 -1
- package/dist/review/report.js +1 -1
- package/dist/review/report.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +3 -20
- package/dist/review.js.map +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +0 -5
- package/dist/session.js.map +1 -1
- package/dist/sql/navigation.d.ts.map +1 -1
- package/dist/sql/navigation.js +2 -1
- package/dist/sql/navigation.js.map +1 -1
- package/dist/sql/source-graph.d.ts.map +1 -1
- package/dist/sql/source-graph.js +2 -2
- package/dist/sql/source-graph.js.map +1 -1
- package/dist/sqlite/schema.d.ts +1 -1
- package/dist/sqlite/schema.d.ts.map +1 -1
- package/dist/sqlite/schema.js +8 -2
- package/dist/sqlite/schema.js.map +1 -1
- package/dist/sqlite/write.js +2 -2
- package/dist/sqlite/write.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/util/bloom-filter.d.ts +8 -1
- package/dist/util/bloom-filter.d.ts.map +1 -1
- package/dist/util/bloom-filter.js +15 -2
- package/dist/util/bloom-filter.js.map +1 -1
- package/dist/util/glob.d.ts +32 -0
- package/dist/util/glob.d.ts.map +1 -0
- package/dist/util/glob.js +137 -0
- package/dist/util/glob.js.map +1 -0
- package/dist/util/graph-edges.d.ts +19 -1
- package/dist/util/graph-edges.d.ts.map +1 -1
- package/dist/util/graph-edges.js +30 -4
- package/dist/util/graph-edges.js.map +1 -1
- package/dist/util/identifiers.d.ts +15 -0
- package/dist/util/identifiers.d.ts.map +1 -1
- package/dist/util/identifiers.js +35 -0
- package/dist/util/identifiers.js.map +1 -1
- package/dist/util/member-access-tables.d.ts +61 -4
- package/dist/util/member-access-tables.d.ts.map +1 -1
- package/dist/util/member-access-tables.js +139 -19
- package/dist/util/member-access-tables.js.map +1 -1
- package/dist/util/member-access.d.ts +17 -0
- package/dist/util/member-access.d.ts.map +1 -1
- package/dist/util/member-access.js +98 -3
- package/dist/util/member-access.js.map +1 -1
- package/dist/util/project-files.d.ts +2 -10
- package/dist/util/project-files.d.ts.map +1 -1
- package/dist/util/project-files.js +29 -51
- package/dist/util/project-files.js.map +1 -1
- package/dist/util/python-type-checking.d.ts +18 -0
- package/dist/util/python-type-checking.d.ts.map +1 -0
- package/dist/util/python-type-checking.js +160 -0
- package/dist/util/python-type-checking.js.map +1 -0
- package/dist/util/resolution/cargo-targets.d.ts +11 -0
- package/dist/util/resolution/cargo-targets.d.ts.map +1 -1
- package/dist/util/resolution/cargo-targets.js +174 -13
- package/dist/util/resolution/cargo-targets.js.map +1 -1
- package/dist/util/resolution/csharp.d.ts +33 -1
- package/dist/util/resolution/csharp.d.ts.map +1 -1
- package/dist/util/resolution/csharp.js +145 -30
- package/dist/util/resolution/csharp.js.map +1 -1
- package/dist/util/resolution/jvm.d.ts +7 -3
- package/dist/util/resolution/jvm.d.ts.map +1 -1
- package/dist/util/resolution/jvm.js +56 -38
- package/dist/util/resolution/jvm.js.map +1 -1
- package/dist/util/resolution/php.d.ts.map +1 -1
- package/dist/util/resolution/php.js +35 -8
- package/dist/util/resolution/php.js.map +1 -1
- package/dist/util/resolution/python.d.ts +9 -0
- package/dist/util/resolution/python.d.ts.map +1 -1
- package/dist/util/resolution/python.js +46 -0
- package/dist/util/resolution/python.js.map +1 -1
- package/dist/util/resolution/rust.d.ts +0 -1
- package/dist/util/resolution/rust.d.ts.map +1 -1
- package/dist/util/resolution/rust.js +95 -35
- package/dist/util/resolution/rust.js.map +1 -1
- package/dist/util/resolution/specifier-targets.d.ts +44 -0
- package/dist/util/resolution/specifier-targets.d.ts.map +1 -0
- package/dist/util/resolution/specifier-targets.js +152 -0
- package/dist/util/resolution/specifier-targets.js.map +1 -0
- package/dist/util/resolution-candidates.d.ts +5 -0
- package/dist/util/resolution-candidates.d.ts.map +1 -1
- package/dist/util/resolution-candidates.js +16 -3
- package/dist/util/resolution-candidates.js.map +1 -1
- package/dist/util/resolution.d.ts +2 -1
- package/dist/util/resolution.d.ts.map +1 -1
- package/dist/util/resolution.js +101 -15
- package/dist/util/resolution.js.map +1 -1
- package/dist/util/specifiers.d.ts +29 -1
- package/dist/util/specifiers.d.ts.map +1 -1
- package/dist/util/specifiers.js +56 -8
- package/dist/util/specifiers.js.map +1 -1
- package/dist/util/trivia.d.ts.map +1 -1
- package/dist/util/trivia.js +49 -30
- package/dist/util/trivia.js.map +1 -1
- package/dist/util/workspace.d.ts.map +1 -1
- package/dist/util/workspace.js +32 -4
- package/dist/util/workspace.js.map +1 -1
- package/docs/mcp.md +3 -2
- package/package.json +5 -7
- package/dist/impact/call-compatibility/providers/profiles.d.ts +0 -80
- package/dist/impact/call-compatibility/providers/profiles.d.ts.map +0 -1
- package/dist/impact/call-compatibility/providers/profiles.js +0 -164
- package/dist/impact/call-compatibility/providers/profiles.js.map +0 -1
package/dist/indexer/scope.js
CHANGED
|
@@ -1,12 +1,67 @@
|
|
|
1
1
|
import { sliceText, toRange } from "../util/ast.js";
|
|
2
2
|
import { getNativeSyntaxTreeExecution } from "../native/tree-sitter-native.js";
|
|
3
3
|
import { ProjectedSyntaxTree } from "../native/projected-tree.js";
|
|
4
|
+
import { getMemberAccessParts, isMemberAccessNode } from "../util/member-access.js";
|
|
4
5
|
import { declarationKindToBindingKind } from "./declarations.js";
|
|
5
|
-
import {
|
|
6
|
+
import { callableIdentityForDeclaration } from "./callable-identity.js";
|
|
7
|
+
import { cppSelectCallableBinding } from "./cpp-callables.js";
|
|
8
|
+
import { typescriptCallableCandidatesInContainer } from "./ts-callables.js";
|
|
9
|
+
import { cppQualifiedNameSegments, importTypeQuerySpecifier, typescriptImportTypeQuery, } from "../graphs/symbol-graph-detailed/receiver-calls.js";
|
|
10
|
+
import { phpConstructorPromotedVariable } from "./navigation-php.js";
|
|
11
|
+
import { cScopeName, cTagRole } from "../languages/definitions/c.js";
|
|
12
|
+
import { bindingCoversUse, isExplicitMethodCall, laterLocalBlocksOuterUse, scopeAllowsUse, scopeIdentifierKey, scopeNodesFor, } from "./scope-nodes.js";
|
|
13
|
+
import { isJsTsLanguage } from "../languages/js-family.js";
|
|
14
|
+
import { SymbolKind } from "./types.js";
|
|
15
|
+
const FUNCTION_DECLARATOR_NAME_TYPES = {
|
|
16
|
+
identifier: true,
|
|
17
|
+
field_identifier: true,
|
|
18
|
+
destructor_name: true,
|
|
19
|
+
operator_name: true,
|
|
20
|
+
};
|
|
21
|
+
function nestedFunctionDeclaratorName(node) {
|
|
22
|
+
let current = node;
|
|
23
|
+
for (let depth = 0; current && depth < 8; depth += 1) {
|
|
24
|
+
if (FUNCTION_DECLARATOR_NAME_TYPES[current.type])
|
|
25
|
+
return current;
|
|
26
|
+
current = current.childForFieldName("name");
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
function declaredNameNode(node, row) {
|
|
31
|
+
const directName = node.childForFieldName("name");
|
|
32
|
+
if (directName)
|
|
33
|
+
return directName;
|
|
34
|
+
if (!row.functionNameTypes?.has(node.type))
|
|
35
|
+
return null;
|
|
36
|
+
let current = node.childForFieldName("declarator");
|
|
37
|
+
for (let depth = 0; current && depth < 8; depth += 1) {
|
|
38
|
+
const name = current.childForFieldName("name");
|
|
39
|
+
const declaredName = name ? nestedFunctionDeclaratorName(name) : nestedFunctionDeclaratorName(current);
|
|
40
|
+
if (declaredName)
|
|
41
|
+
return declaredName;
|
|
42
|
+
current =
|
|
43
|
+
current.childForFieldName("declarator") ??
|
|
44
|
+
(current.type === "reference_declarator" ? (current.namedChildren[0] ?? null) : null);
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
function qualifiedCppIdentifierForName(nameNode, boundary) {
|
|
49
|
+
let current = nameNode.parent;
|
|
50
|
+
while (current && current !== boundary) {
|
|
51
|
+
if (current.type === "qualified_identifier") {
|
|
52
|
+
const memberName = current.childForFieldName("name");
|
|
53
|
+
const containsName = memberName && memberName.startIndex <= nameNode.startIndex && memberName.endIndex >= nameNode.endIndex;
|
|
54
|
+
if (containsName && current.parent?.type !== "qualified_identifier")
|
|
55
|
+
return current;
|
|
56
|
+
}
|
|
57
|
+
current = current.parent;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
6
61
|
export function buildScopeIndexFromSource(file, source, support, imports = [], opts) {
|
|
7
62
|
let tree = opts?.tree ?? null;
|
|
8
63
|
if (!tree) {
|
|
9
|
-
const nativeTreeExecution = getNativeSyntaxTreeExecution(source, support
|
|
64
|
+
const nativeTreeExecution = getNativeSyntaxTreeExecution(source, support);
|
|
10
65
|
if (nativeTreeExecution.tree) {
|
|
11
66
|
tree = new ProjectedSyntaxTree(source, nativeTreeExecution.tree);
|
|
12
67
|
}
|
|
@@ -22,15 +77,60 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
22
77
|
};
|
|
23
78
|
const stack = [rootScope];
|
|
24
79
|
const allScopes = [rootScope];
|
|
80
|
+
const cppNamespaceMaps = new Map();
|
|
81
|
+
const cppNamespaceScopes = new Map();
|
|
82
|
+
const cppNamespacePath = [];
|
|
83
|
+
const cppNamespacePathByMap = new WeakMap();
|
|
25
84
|
const extraBindings = [];
|
|
85
|
+
const cppQualifiedMemberBindings = new Map();
|
|
86
|
+
const cppQualifiedMemberOccurrences = new Map();
|
|
87
|
+
const cppFunctionCollisionGroups = new Set();
|
|
88
|
+
const cppFunctionOccurrences = [];
|
|
89
|
+
// Retain imported C tag forwards only when a later same-file declaration completes the tag.
|
|
90
|
+
let cImportedForwardTags;
|
|
91
|
+
const extraBindingSpans = new Set();
|
|
92
|
+
const bindingSpanKey = (binding) => {
|
|
93
|
+
const start = binding.def?.start.index;
|
|
94
|
+
const end = binding.def?.end.index;
|
|
95
|
+
return `${binding.canonicalName}:${start ?? ""}:${end ?? ""}`;
|
|
96
|
+
};
|
|
97
|
+
const preserveExtraBinding = (binding) => {
|
|
98
|
+
const key = bindingSpanKey(binding);
|
|
99
|
+
if (extraBindingSpans.has(key))
|
|
100
|
+
return;
|
|
101
|
+
extraBindingSpans.add(key);
|
|
102
|
+
extraBindings.push(binding);
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Name nodes already registered before their construct's own scope was pushed. Keyed by source
|
|
106
|
+
* span rather than `node.id`, which the projected tree leaves optional.
|
|
107
|
+
*/
|
|
108
|
+
const preRegisteredNameSpans = new Set();
|
|
109
|
+
const nameSpanKey = (node) => `${node.startIndex}:${node.endIndex}`;
|
|
26
110
|
const normalizeIdentifier = support.normalizeIdentifier;
|
|
111
|
+
const indexedCallables = opts?.locals ? new Map() : undefined;
|
|
112
|
+
if (indexedCallables && opts?.locals) {
|
|
113
|
+
for (const local of opts.locals) {
|
|
114
|
+
if (local.kind === SymbolKind.Function && local.callable) {
|
|
115
|
+
indexedCallables.set(`${local.range.start.index}:${local.range.end.index}`, local.callable);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
27
119
|
const buildBinding = (nameNode, kind) => {
|
|
28
120
|
const name = sliceText(nameNode, source);
|
|
121
|
+
const def = toRange(nameNode);
|
|
122
|
+
const callable = kind === "function"
|
|
123
|
+
? (indexedCallables?.get(`${nameNode.startIndex}:${nameNode.endIndex}`) ??
|
|
124
|
+
callableIdentityForDeclaration({ file, name, range: def, languageId: support.id, source, node: nameNode }))
|
|
125
|
+
: undefined;
|
|
126
|
+
const heldModuleSpecifier = kind === "local" && isJsTsLanguage(support.id) ? heldModuleSpecifierForDeclaration(nameNode) : undefined;
|
|
29
127
|
return {
|
|
30
128
|
name,
|
|
31
|
-
canonicalName:
|
|
129
|
+
canonicalName: scopeIdentifierKey(row, name, nameNode, normalizeIdentifier),
|
|
32
130
|
kind,
|
|
33
|
-
def
|
|
131
|
+
def,
|
|
132
|
+
...(callable ? { callable } : {}),
|
|
133
|
+
...(heldModuleSpecifier !== undefined ? { heldModuleSpecifier } : {}),
|
|
34
134
|
node: nameNode,
|
|
35
135
|
occurrences: [],
|
|
36
136
|
};
|
|
@@ -43,7 +143,10 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
43
143
|
occurrences: [],
|
|
44
144
|
import: importBinding,
|
|
45
145
|
};
|
|
46
|
-
|
|
146
|
+
const key = support.id === "c" && importBinding.kind === "named" && importBinding.cNamespace === "tag"
|
|
147
|
+
? cScopeName(binding.canonicalName, "tag")
|
|
148
|
+
: binding.canonicalName;
|
|
149
|
+
rootScope.map.set(key, binding);
|
|
47
150
|
};
|
|
48
151
|
for (const imp of imports) {
|
|
49
152
|
if (imp.kind === "default") {
|
|
@@ -57,6 +160,28 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
57
160
|
}
|
|
58
161
|
}
|
|
59
162
|
const row = scopeNodesFor(support.id);
|
|
163
|
+
/** Covering-declaration names collected before a scope's body is walked, keyed by syntax node id. */
|
|
164
|
+
const pendingNamesByNodeId = new Map();
|
|
165
|
+
/**
|
|
166
|
+
* JS and TS record let/const/class/type names during the existing hoist walk. A use defers only
|
|
167
|
+
* when one of those names is still ahead, so the queue stays the forward references.
|
|
168
|
+
*/
|
|
169
|
+
const tracksLexicalNames = !!(row.hoistedFunctionTypes || row.hoistedVariableDeclarationTypes);
|
|
170
|
+
const canDeferForward = !tracksLexicalNames &&
|
|
171
|
+
(!!row.wholeScopeKinds?.size ||
|
|
172
|
+
!!row.wholeScopeDeclarationTypes?.size ||
|
|
173
|
+
!!row.variableTargetScopeKinds?.size ||
|
|
174
|
+
!!row.laterLocalBlocksOuterKinds?.size ||
|
|
175
|
+
!!row.moduleBindingsAtFunctionRuntime);
|
|
176
|
+
const nodeById = (id) => tree instanceof ProjectedSyntaxTree ? tree.nodeById(id) : undefined;
|
|
177
|
+
const attachPendingNames = (scope) => {
|
|
178
|
+
const nodeId = scope.node.id;
|
|
179
|
+
if (nodeId === undefined)
|
|
180
|
+
return;
|
|
181
|
+
const names = pendingNamesByNodeId.get(nodeId);
|
|
182
|
+
if (names && names.size > 0)
|
|
183
|
+
scope.pendingCoveringNames = names;
|
|
184
|
+
};
|
|
60
185
|
const idSet = new Set([...support.nodeTypes.identifier, ...(support.nodeTypes.shorthandPropertyIdentifier ?? [])]);
|
|
61
186
|
const scopeDeclarationNames = support.scopeDeclarationNames;
|
|
62
187
|
const isParamNode = (node) => {
|
|
@@ -68,9 +193,216 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
68
193
|
}
|
|
69
194
|
return false;
|
|
70
195
|
};
|
|
196
|
+
const declarationCoversScope = (nameNode) => {
|
|
197
|
+
const types = row.wholeScopeDeclarationTypes;
|
|
198
|
+
const memberTypes = row.wholeScopeMemberDeclarationTypes;
|
|
199
|
+
if (!types && !memberTypes)
|
|
200
|
+
return false;
|
|
201
|
+
let current = nameNode.parent;
|
|
202
|
+
for (let depth = 0; current && depth < 8; depth += 1) {
|
|
203
|
+
const functionScope = support.createsFunctionScope(current);
|
|
204
|
+
if (functionScope) {
|
|
205
|
+
const declaredName = current.childForFieldName("name");
|
|
206
|
+
if (!declaredName ||
|
|
207
|
+
declaredName.startIndex !== nameNode.startIndex ||
|
|
208
|
+
declaredName.endIndex !== nameNode.endIndex)
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
if (types?.has(current.type))
|
|
212
|
+
return true;
|
|
213
|
+
if (memberTypes?.has(current.type) && current.parent && row.memberContainerTypes?.has(current.parent.type)) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
if (current.type === "variable_declarator" && current.parent && types?.has(current.parent.type))
|
|
217
|
+
return true;
|
|
218
|
+
// A local inside a function is not the function's own declaration.
|
|
219
|
+
if (functionScope || support.createsBlockScope(current))
|
|
220
|
+
break;
|
|
221
|
+
current = current.parent;
|
|
222
|
+
}
|
|
223
|
+
return false;
|
|
224
|
+
};
|
|
225
|
+
const stealCoveredOccurrences = (target, binding, key) => {
|
|
226
|
+
if (!binding.coversEnclosingScope)
|
|
227
|
+
return;
|
|
228
|
+
const sources = [];
|
|
229
|
+
const pushChain = (found) => {
|
|
230
|
+
let current = found;
|
|
231
|
+
while (current && current !== binding) {
|
|
232
|
+
sources.push(current);
|
|
233
|
+
current = current.earlierSameScope;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
// A same-scope redeclaration keeps its own uses. Only an outer binding can be shadowed.
|
|
237
|
+
let parent = target.parent;
|
|
238
|
+
while (parent) {
|
|
239
|
+
const found = parent.map.get(key);
|
|
240
|
+
if (found) {
|
|
241
|
+
pushChain(found);
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
parent = parent.parent;
|
|
245
|
+
}
|
|
246
|
+
const start = target.node.startIndex;
|
|
247
|
+
const end = target.node.endIndex;
|
|
248
|
+
const seen = new Set();
|
|
249
|
+
for (const source of sources) {
|
|
250
|
+
if (seen.has(source.occurrences))
|
|
251
|
+
continue;
|
|
252
|
+
seen.add(source.occurrences);
|
|
253
|
+
const occurrences = source.occurrences;
|
|
254
|
+
let write = 0;
|
|
255
|
+
let moved = 0;
|
|
256
|
+
for (let index = 0; index < occurrences.length; index += 1) {
|
|
257
|
+
const occurrence = occurrences[index];
|
|
258
|
+
const occurrenceStart = occurrence.start.index;
|
|
259
|
+
const occurrenceEnd = occurrence.end.index;
|
|
260
|
+
if (occurrenceStart !== undefined &&
|
|
261
|
+
occurrenceEnd !== undefined &&
|
|
262
|
+
occurrenceStart >= start &&
|
|
263
|
+
occurrenceEnd <= end) {
|
|
264
|
+
binding.occurrences.push(occurrence);
|
|
265
|
+
moved += 1;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
occurrences[write++] = occurrence;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (moved > 0)
|
|
272
|
+
occurrences.length = write;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
71
275
|
const addBinding = (target, nameNode, kind) => {
|
|
72
276
|
const binding = buildBinding(nameNode, kind);
|
|
73
|
-
|
|
277
|
+
if (row.wholeScopeKinds?.has(target.kind) || declarationCoversScope(nameNode)) {
|
|
278
|
+
binding.coversEnclosingScope = true;
|
|
279
|
+
}
|
|
280
|
+
const tagRole = support.id === "c" ? cTagRole(nameNode) : undefined;
|
|
281
|
+
const key = tagRole ? cScopeName(binding.canonicalName, "tag") : binding.canonicalName;
|
|
282
|
+
if (tagRole === "reference") {
|
|
283
|
+
const visible = lookup(binding.name, nameNode);
|
|
284
|
+
if (visible) {
|
|
285
|
+
visible.occurrences.push(binding.def);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const existing = target.map.get(key);
|
|
290
|
+
if (tagRole === "forward" && existing?.import) {
|
|
291
|
+
existing.occurrences.push(binding.def);
|
|
292
|
+
cImportedForwardTags ??= new Map();
|
|
293
|
+
if (!cImportedForwardTags.has(existing))
|
|
294
|
+
cImportedForwardTags.set(existing, binding);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (tagRole === "declaration" && existing?.import) {
|
|
298
|
+
binding.occurrences = existing.occurrences;
|
|
299
|
+
const forward = cImportedForwardTags?.get(existing);
|
|
300
|
+
if (forward) {
|
|
301
|
+
forward.occurrences = binding.occurrences;
|
|
302
|
+
binding.earlierSameScope = forward;
|
|
303
|
+
}
|
|
304
|
+
binding.occurrences.push(binding.def);
|
|
305
|
+
preserveExtraBinding(existing);
|
|
306
|
+
}
|
|
307
|
+
if (tagRole && existing?.def) {
|
|
308
|
+
if (existing.def.start.index === binding.def?.start.index)
|
|
309
|
+
return;
|
|
310
|
+
binding.occurrences = existing.occurrences;
|
|
311
|
+
if (tagRole === "declaration" && existing.node && cTagRole(existing.node) !== "declaration") {
|
|
312
|
+
binding.occurrences.push(existing.def);
|
|
313
|
+
preserveExtraBinding(existing);
|
|
314
|
+
// The forward tag remains visible from its declaration until this completion.
|
|
315
|
+
binding.earlierSameScope = existing;
|
|
316
|
+
target.map.set(key, binding);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
binding.occurrences.push(binding.def);
|
|
320
|
+
preserveExtraBinding(binding);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (kind === "function" && existing?.kind === "function") {
|
|
324
|
+
if (support.id === "c") {
|
|
325
|
+
// C prototypes and their definitions are declarations of one function. Keep each
|
|
326
|
+
// declaration addressable while sharing the occurrence list collected for that name.
|
|
327
|
+
binding.occurrences = existing.occurrences;
|
|
328
|
+
preserveExtraBinding(binding);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (support.id === "cpp") {
|
|
332
|
+
const collisions = existing.sameScopeFunctionBindings ?? [existing];
|
|
333
|
+
collisions.push(binding);
|
|
334
|
+
for (const collision of collisions)
|
|
335
|
+
collision.sameScopeFunctionBindings = collisions;
|
|
336
|
+
cppFunctionCollisionGroups.add(collisions);
|
|
337
|
+
preserveExtraBinding(existing);
|
|
338
|
+
}
|
|
339
|
+
if (support.id === "ts" || support.id === "tsx") {
|
|
340
|
+
const candidates = existing.sameScopeFunctionBindings ?? [existing];
|
|
341
|
+
const collisions = typescriptCallableCandidatesInContainer(candidates, (candidate) => candidate.callable, binding.callable?.key);
|
|
342
|
+
if (collisions.includes(existing)) {
|
|
343
|
+
let grouped = candidates;
|
|
344
|
+
if (collisions !== candidates)
|
|
345
|
+
grouped = [...collisions];
|
|
346
|
+
grouped.push(binding);
|
|
347
|
+
for (const collision of grouped)
|
|
348
|
+
collision.sameScopeFunctionBindings = grouped;
|
|
349
|
+
const existingRole = existing.callable?.role ?? "other";
|
|
350
|
+
const nextRole = binding.callable?.role ?? "other";
|
|
351
|
+
if (existingRole === "implementation" && nextRole === "signature") {
|
|
352
|
+
preserveExtraBinding(binding);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (existingRole === "signature" && nextRole === "implementation") {
|
|
356
|
+
preserveExtraBinding(existing);
|
|
357
|
+
}
|
|
358
|
+
else if (existingRole === "signature" && nextRole === "signature") {
|
|
359
|
+
preserveExtraBinding(binding);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const sameSpan = !!existing?.def &&
|
|
366
|
+
!!binding.def &&
|
|
367
|
+
existing.def.start.index === binding.def.start.index &&
|
|
368
|
+
existing.def.end.index === binding.def.end.index;
|
|
369
|
+
// Pattern walks can register one name node twice. A second pass with a different kind is the
|
|
370
|
+
// real classification (`module` is pre-registered as a class, then as a type) and replaces it.
|
|
371
|
+
if (sameSpan && existing?.kind === kind)
|
|
372
|
+
return;
|
|
373
|
+
// A second local in a whole-scope scope is the same binding (Python assignments). Keep the
|
|
374
|
+
// first declaration and record the later one as an occurrence so an earlier use does not get
|
|
375
|
+
// attached only to the textually last declaration.
|
|
376
|
+
if (!sameSpan &&
|
|
377
|
+
existing &&
|
|
378
|
+
kind === "local" &&
|
|
379
|
+
existing.kind === "local" &&
|
|
380
|
+
!tagRole &&
|
|
381
|
+
!!row.variableTargetScopeKinds &&
|
|
382
|
+
row.wholeScopeKinds?.has(target.kind)) {
|
|
383
|
+
if (binding.def)
|
|
384
|
+
existing.occurrences.push(binding.def);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
// Preserving an overload as an extra binding must not hide it from earlier C++ uses.
|
|
388
|
+
if (!sameSpan &&
|
|
389
|
+
existing &&
|
|
390
|
+
(!extraBindingSpans.has(bindingSpanKey(existing)) ||
|
|
391
|
+
(support.id === "cpp" && kind === "function" && existing.kind === "function"))) {
|
|
392
|
+
binding.earlierSameScope = existing;
|
|
393
|
+
}
|
|
394
|
+
target.map.set(key, binding);
|
|
395
|
+
if (binding.coversEnclosingScope)
|
|
396
|
+
target.pendingCoveringNames?.delete(binding.canonicalName);
|
|
397
|
+
if (!tracksLexicalNames)
|
|
398
|
+
stealCoveredOccurrences(target, binding, key);
|
|
399
|
+
const cppNamespace = cppNamespacePathByMap.get(target.map);
|
|
400
|
+
if (support.id === "cpp" && kind === "function" && cppNamespace) {
|
|
401
|
+
const qualifiedKey = `${cppNamespace}::${binding.name}`;
|
|
402
|
+
const qualifiedBindings = cppQualifiedMemberBindings.get(qualifiedKey) ?? [];
|
|
403
|
+
qualifiedBindings.push(binding);
|
|
404
|
+
cppQualifiedMemberBindings.set(qualifiedKey, qualifiedBindings);
|
|
405
|
+
}
|
|
74
406
|
};
|
|
75
407
|
const addDecl = (nameNode, kind) => {
|
|
76
408
|
const target = stack[stack.length - 1];
|
|
@@ -89,26 +421,119 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
89
421
|
// type parameter: Go struct fields are accessed through a receiver from
|
|
90
422
|
// anywhere in the file, unlike a type parameter, which is scoped to its own
|
|
91
423
|
// declaration.
|
|
424
|
+
const variableDeclarationScope = () => {
|
|
425
|
+
const current = stack[stack.length - 1] ?? rootScope;
|
|
426
|
+
const targetKinds = row.variableTargetScopeKinds;
|
|
427
|
+
if (!targetKinds)
|
|
428
|
+
return current;
|
|
429
|
+
const boundary = row.variableScopeBoundaryTypes;
|
|
430
|
+
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
431
|
+
const scope = stack[index];
|
|
432
|
+
if (boundary) {
|
|
433
|
+
const parentType = scope.node.parent?.type;
|
|
434
|
+
if (boundary.has(scope.node.type) || (parentType !== undefined && boundary.has(parentType)))
|
|
435
|
+
return scope;
|
|
436
|
+
}
|
|
437
|
+
if (targetKinds.has(scope.kind))
|
|
438
|
+
return scope;
|
|
439
|
+
}
|
|
440
|
+
return current;
|
|
441
|
+
};
|
|
442
|
+
const addVariableDecl = (nameNode, kind) => {
|
|
443
|
+
addBinding(variableDeclarationScope(), nameNode, kind);
|
|
444
|
+
};
|
|
92
445
|
const addDeclSkippingTypeScope = (nameNode, kind) => {
|
|
446
|
+
if (kind === "local" && row.variableTargetScopeKinds) {
|
|
447
|
+
addVariableDecl(nameNode, kind);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
93
450
|
const target = [...stack].reverse().find((scope) => scope.kind !== "type") ?? rootScope;
|
|
94
451
|
addBinding(target, nameNode, kind);
|
|
95
452
|
};
|
|
96
|
-
const lookup = (name) => {
|
|
97
|
-
const
|
|
453
|
+
const lookup = (name, node) => {
|
|
454
|
+
const normalizedName = node ? scopeIdentifierKey(row, name, node, normalizeIdentifier) : normalizeIdentifier(name);
|
|
455
|
+
const canonicalName = support.id === "c" && node && cTagRole(node) ? cScopeName(normalizedName, "tag") : normalizedName;
|
|
456
|
+
const methodCall = !!node && isExplicitMethodCall(row, node);
|
|
98
457
|
for (let index = stack.length - 1; index >= 0; index--) {
|
|
99
|
-
const
|
|
458
|
+
const scope = stack[index];
|
|
459
|
+
if (node && !scopeAllowsUse(row, scope, node))
|
|
460
|
+
continue;
|
|
461
|
+
let hit = scope.map.get(canonicalName);
|
|
462
|
+
while (methodCall && hit?.kind === "local")
|
|
463
|
+
hit = hit.earlierSameScope;
|
|
464
|
+
if (hit)
|
|
465
|
+
return hit;
|
|
466
|
+
}
|
|
467
|
+
let root = rootScope.map.get(canonicalName);
|
|
468
|
+
while (methodCall && root?.kind === "local")
|
|
469
|
+
root = root.earlierSameScope;
|
|
470
|
+
return root;
|
|
471
|
+
};
|
|
472
|
+
const lookupOutsideFunctions = (name) => {
|
|
473
|
+
const canonicalName = `$${normalizeIdentifier(name)}`;
|
|
474
|
+
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
475
|
+
const scope = stack[index];
|
|
476
|
+
if (scope.kind === "function")
|
|
477
|
+
continue;
|
|
478
|
+
const hit = scope.map.get(canonicalName);
|
|
100
479
|
if (hit)
|
|
101
480
|
return hit;
|
|
102
481
|
}
|
|
103
482
|
return rootScope.map.get(canonicalName);
|
|
104
483
|
};
|
|
484
|
+
const isPhpThisPropertyName = (nameNode) => {
|
|
485
|
+
const parent = nameNode.parent;
|
|
486
|
+
if (!parent || parent.type !== "member_access_expression")
|
|
487
|
+
return false;
|
|
488
|
+
const property = parent.childForFieldName("name") ?? parent.namedChildren.find((child) => child.type === "name") ?? null;
|
|
489
|
+
if (!property || property.startIndex !== nameNode.startIndex || property.endIndex !== nameNode.endIndex) {
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
const object = parent.childForFieldName("object") ?? parent.namedChildren[0] ?? null;
|
|
493
|
+
if (!object || object.startIndex === property.startIndex)
|
|
494
|
+
return false;
|
|
495
|
+
return sliceText(object, source) === "$this";
|
|
496
|
+
};
|
|
497
|
+
const promotedVariablesInClass = (classNode) => {
|
|
498
|
+
const variables = [];
|
|
499
|
+
const visit = (current) => {
|
|
500
|
+
if (current !== classNode &&
|
|
501
|
+
(current.type === "class_declaration" ||
|
|
502
|
+
current.type === "trait_declaration" ||
|
|
503
|
+
current.type === "enum_declaration" ||
|
|
504
|
+
current.type === "function_definition")) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
if (current.type === "method_declaration") {
|
|
508
|
+
const name = current.childForFieldName("name");
|
|
509
|
+
if (!name || sliceText(name, source) !== "__construct")
|
|
510
|
+
return;
|
|
511
|
+
const params = current.childForFieldName("parameters");
|
|
512
|
+
for (const child of params?.namedChildren ?? []) {
|
|
513
|
+
const variable = phpConstructorPromotedVariable(child, source);
|
|
514
|
+
if (variable)
|
|
515
|
+
variables.push(variable);
|
|
516
|
+
}
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
for (const child of current.namedChildren)
|
|
520
|
+
visit(child);
|
|
521
|
+
};
|
|
522
|
+
visit(classNode);
|
|
523
|
+
return variables;
|
|
524
|
+
};
|
|
105
525
|
const addPatternDecls = (pattern, kind, addBindingToScope = addDecl) => {
|
|
526
|
+
if (pattern.type === "property_promotion_parameter" && phpConstructorPromotedVariable(pattern, source)) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
106
529
|
if (idSet.has(pattern.type)) {
|
|
107
530
|
addBindingToScope(pattern, kind);
|
|
108
531
|
return;
|
|
109
532
|
}
|
|
110
|
-
// Parameter nodes put names and types as siblings. Walking the whole subtree
|
|
111
|
-
// would register type-position identifiers (`int`, `T`, package qualifiers)
|
|
533
|
+
// Parameter nodes put names and types as siblings. Walking the whole subtree for bindings
|
|
534
|
+
// would register type-position identifiers (`int`, `T`, package qualifiers) as new locals;
|
|
535
|
+
// `walk` still visits the type field so a proven declaration (e.g. a struct name used as a
|
|
536
|
+
// parameter type) records this position as one of its occurrences.
|
|
112
537
|
if (row.destructuringTypeFieldTypes?.has(pattern.type)) {
|
|
113
538
|
const typeNode = pattern.childForFieldName("type");
|
|
114
539
|
for (const child of pattern.namedChildren) {
|
|
@@ -116,6 +541,8 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
116
541
|
continue;
|
|
117
542
|
addPatternDecls(child, kind, addBindingToScope);
|
|
118
543
|
}
|
|
544
|
+
if (typeNode)
|
|
545
|
+
walk(typeNode);
|
|
119
546
|
return;
|
|
120
547
|
}
|
|
121
548
|
if (row.destructuringPairPatternTypes?.has(pattern.type)) {
|
|
@@ -129,6 +556,15 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
129
556
|
addPatternDecls(child, kind, addBindingToScope);
|
|
130
557
|
}
|
|
131
558
|
};
|
|
559
|
+
const isAwaitedDynamicImport = (node) => {
|
|
560
|
+
if (!node || node.type !== "await_expression")
|
|
561
|
+
return false;
|
|
562
|
+
const call = node.namedChildren.find((child) => child.type === "call_expression");
|
|
563
|
+
if (!call)
|
|
564
|
+
return false;
|
|
565
|
+
const callee = call.childForFieldName("function") ?? call.child(0);
|
|
566
|
+
return callee?.type === "import";
|
|
567
|
+
};
|
|
132
568
|
const isStaticRequireCall = (node) => {
|
|
133
569
|
const requireCall = row.requireCall;
|
|
134
570
|
if (!node || !requireCall?.callTypes.has(node.type))
|
|
@@ -139,6 +575,43 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
139
575
|
const args = node.childForFieldName("arguments");
|
|
140
576
|
return !!args && requireCall.argumentsPattern.test(sliceText(args, source));
|
|
141
577
|
};
|
|
578
|
+
const moduleSpecifierFromCall = (call) => {
|
|
579
|
+
const args = call?.childForFieldName("arguments");
|
|
580
|
+
if (args?.namedChildren.length !== 1)
|
|
581
|
+
return null;
|
|
582
|
+
const literal = args.namedChildren[0];
|
|
583
|
+
if (literal?.type !== "string" || literal.namedChildren.length !== 1)
|
|
584
|
+
return null;
|
|
585
|
+
const fragment = literal.namedChildren[0];
|
|
586
|
+
return fragment?.type === "string_fragment" ? sliceText(fragment, source) : null;
|
|
587
|
+
};
|
|
588
|
+
const moduleSpecifierFromValue = (value) => {
|
|
589
|
+
let current = value;
|
|
590
|
+
while (current?.type === "parenthesized_expression")
|
|
591
|
+
current = current.namedChildren[0] ?? null;
|
|
592
|
+
if (isAwaitedDynamicImport(current)) {
|
|
593
|
+
const call = current.namedChildren.find((child) => child.type === "call_expression") ?? null;
|
|
594
|
+
return moduleSpecifierFromCall(call);
|
|
595
|
+
}
|
|
596
|
+
return isStaticRequireCall(current) ? moduleSpecifierFromCall(current) : null;
|
|
597
|
+
};
|
|
598
|
+
const heldModuleSpecifierForDeclaration = (nameNode) => {
|
|
599
|
+
const declaration = nameNode.parent;
|
|
600
|
+
const declaredName = declaration?.childForFieldName("name");
|
|
601
|
+
if (declaration?.type !== "variable_declarator" || declaredName?.startIndex !== nameNode.startIndex) {
|
|
602
|
+
return undefined;
|
|
603
|
+
}
|
|
604
|
+
const annotation = declaration.childForFieldName("type");
|
|
605
|
+
const query = annotation ? typescriptImportTypeQuery(annotation) : null;
|
|
606
|
+
const typedSpecifier = query ? importTypeQuerySpecifier(query) : null;
|
|
607
|
+
const value = declaration.childForFieldName("value");
|
|
608
|
+
if (!value)
|
|
609
|
+
return typedSpecifier ?? undefined;
|
|
610
|
+
const initializedSpecifier = moduleSpecifierFromValue(value);
|
|
611
|
+
if (!initializedSpecifier || (typedSpecifier && typedSpecifier !== initializedSpecifier))
|
|
612
|
+
return null;
|
|
613
|
+
return initializedSpecifier;
|
|
614
|
+
};
|
|
142
615
|
const hasImportBinding = (nameNode) => {
|
|
143
616
|
const name = normalizeIdentifier(sliceText(nameNode, source));
|
|
144
617
|
const binding = rootScope.map.get(name);
|
|
@@ -209,13 +682,19 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
209
682
|
const name = child.childForFieldName("name");
|
|
210
683
|
const value = child.childForFieldName("value");
|
|
211
684
|
if (name) {
|
|
212
|
-
if (isStaticRequireCall(value))
|
|
685
|
+
if (isStaticRequireCall(value) || isAwaitedDynamicImport(value)) {
|
|
213
686
|
addUnsupportedRequirePatternDecls(name, addBindingToScope);
|
|
687
|
+
}
|
|
214
688
|
else
|
|
215
689
|
addPatternDecls(name, "local", addBindingToScope);
|
|
216
690
|
}
|
|
217
691
|
}
|
|
218
692
|
else if (row.assignmentIdentifierTypes?.has(child.type) && row.assignmentDeclarationTypes?.has(node.type)) {
|
|
693
|
+
const left = node.childForFieldName("left");
|
|
694
|
+
// `y = x` names both identifiers. Only the left-hand side declares; the right-hand side
|
|
695
|
+
// is a use and must not become a same-scope binding that hides the real declaration.
|
|
696
|
+
if (left && (left.startIndex !== child.startIndex || left.endIndex !== child.endIndex))
|
|
697
|
+
continue;
|
|
219
698
|
addBindingToScope(child, "local");
|
|
220
699
|
}
|
|
221
700
|
else if (row.patternBindingTypes?.has(node.type)) {
|
|
@@ -225,11 +704,55 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
225
704
|
}
|
|
226
705
|
}
|
|
227
706
|
};
|
|
707
|
+
const rememberPatternNames = (pattern, names) => {
|
|
708
|
+
if (idSet.has(pattern.type)) {
|
|
709
|
+
names.add(normalizeIdentifier(sliceText(pattern, source)));
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
if (row.destructuringTypeFieldTypes?.has(pattern.type)) {
|
|
713
|
+
const typeNode = pattern.childForFieldName("type");
|
|
714
|
+
for (const child of pattern.namedChildren) {
|
|
715
|
+
if (typeNode && child.startIndex === typeNode.startIndex && child.endIndex === typeNode.endIndex)
|
|
716
|
+
continue;
|
|
717
|
+
rememberPatternNames(child, names);
|
|
718
|
+
}
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
if (row.destructuringPairPatternTypes?.has(pattern.type)) {
|
|
722
|
+
const value = pattern.childForFieldName("value");
|
|
723
|
+
if (value)
|
|
724
|
+
rememberPatternNames(value, names);
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
for (const child of pattern.namedChildren)
|
|
728
|
+
rememberPatternNames(child, names);
|
|
729
|
+
};
|
|
730
|
+
const rememberLexicalNames = (declaration, names) => {
|
|
731
|
+
for (const child of declaration.namedChildren) {
|
|
732
|
+
if (!row.variableDeclaratorTypes?.has(child.type))
|
|
733
|
+
continue;
|
|
734
|
+
const name = child.childForFieldName("name");
|
|
735
|
+
if (name)
|
|
736
|
+
rememberPatternNames(name, names);
|
|
737
|
+
}
|
|
738
|
+
};
|
|
228
739
|
const collectHoistedDeclarations = (scopeNode) => {
|
|
229
740
|
if (!row.hoistedFunctionTypes && !row.hoistedVariableDeclarationTypes)
|
|
230
741
|
return;
|
|
742
|
+
let pending;
|
|
743
|
+
const ensurePending = () => {
|
|
744
|
+
if (!pending) {
|
|
745
|
+
pending = new Set();
|
|
746
|
+
if (scopeNode.id !== undefined)
|
|
747
|
+
pendingNamesByNodeId.set(scopeNode.id, pending);
|
|
748
|
+
}
|
|
749
|
+
return pending;
|
|
750
|
+
};
|
|
751
|
+
const addPending = (nameNode) => {
|
|
752
|
+
ensurePending().add(normalizeIdentifier(sliceText(nameNode, source)));
|
|
753
|
+
};
|
|
231
754
|
const visit = (node) => {
|
|
232
|
-
if (support.createsFunctionScope(node)) {
|
|
755
|
+
if (node !== scopeNode && support.createsFunctionScope(node)) {
|
|
233
756
|
if (row.hoistedFunctionTypes?.has(node.type)) {
|
|
234
757
|
const name = node.childForFieldName("name");
|
|
235
758
|
if (name)
|
|
@@ -237,16 +760,40 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
237
760
|
}
|
|
238
761
|
return;
|
|
239
762
|
}
|
|
763
|
+
if (node !== scopeNode &&
|
|
764
|
+
!row.moduleRootTypes?.has(node.type) &&
|
|
765
|
+
(support.createsBlockScope(node) || !!row.typeScopeTypes?.has(node.type))) {
|
|
766
|
+
collectHoistedDeclarations(node);
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
240
769
|
if (row.hoistedVariableDeclarationTypes?.has(node.type)) {
|
|
241
770
|
addVariableDeclarations(node, addHoistedDecl);
|
|
242
771
|
}
|
|
243
|
-
|
|
244
|
-
|
|
772
|
+
else if (row.variableDeclarationTypes?.has(node.type)) {
|
|
773
|
+
rememberLexicalNames(node, ensurePending());
|
|
774
|
+
}
|
|
775
|
+
if (row.classNameTypes?.has(node.type) || row.typeNameTypes?.has(node.type)) {
|
|
776
|
+
const name = node.childForFieldName("name");
|
|
777
|
+
if (name)
|
|
778
|
+
addPending(name);
|
|
779
|
+
}
|
|
780
|
+
if (row.enumAssignmentTypes?.has(node.type)) {
|
|
781
|
+
const name = node.childForFieldName("name");
|
|
782
|
+
if (name)
|
|
783
|
+
addPending(name);
|
|
245
784
|
}
|
|
785
|
+
else if (row.enumBodyMemberTypes?.has(node.type) &&
|
|
786
|
+
node.parent &&
|
|
787
|
+
row.enumBodyParentTypes?.has(node.parent.type)) {
|
|
788
|
+
addPending(node);
|
|
789
|
+
}
|
|
790
|
+
if (idSet.has(node.type) && scopeDeclarationNames(node))
|
|
791
|
+
addPending(node);
|
|
792
|
+
for (const child of node.namedChildren)
|
|
793
|
+
visit(child);
|
|
246
794
|
};
|
|
247
|
-
for (const child of scopeNode.namedChildren)
|
|
795
|
+
for (const child of scopeNode.namedChildren)
|
|
248
796
|
visit(child);
|
|
249
|
-
}
|
|
250
797
|
};
|
|
251
798
|
const isMemberFunction = (node) => {
|
|
252
799
|
if (row.memberFunctionTypes?.has(node.type)) {
|
|
@@ -261,18 +808,188 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
261
808
|
}
|
|
262
809
|
return false;
|
|
263
810
|
};
|
|
811
|
+
const canonicalUseName = (name, node) => {
|
|
812
|
+
const normalized = scopeIdentifierKey(row, name, node, normalizeIdentifier);
|
|
813
|
+
if (support.id === "php" && isPhpThisPropertyName(node))
|
|
814
|
+
return `$${normalized}`;
|
|
815
|
+
return support.id === "c" && cTagRole(node) ? cScopeName(normalized, "tag") : normalized;
|
|
816
|
+
};
|
|
817
|
+
const scopeOwnsBinding = (scope, canonical, binding) => {
|
|
818
|
+
let current = scope.map.get(canonical);
|
|
819
|
+
while (current) {
|
|
820
|
+
if (current === binding)
|
|
821
|
+
return true;
|
|
822
|
+
current = current.earlierSameScope;
|
|
823
|
+
}
|
|
824
|
+
return false;
|
|
825
|
+
};
|
|
826
|
+
const deferToScope = (canonical, binding) => {
|
|
827
|
+
if (row.variableTargetScopeKinds) {
|
|
828
|
+
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
829
|
+
const scope = stack[index];
|
|
830
|
+
if (binding && scopeOwnsBinding(scope, canonical, binding))
|
|
831
|
+
return undefined;
|
|
832
|
+
if (row.variableTargetScopeKinds.has(scope.kind))
|
|
833
|
+
return scope;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
if (row.laterLocalBlocksOuterKinds) {
|
|
837
|
+
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
838
|
+
const scope = stack[index];
|
|
839
|
+
if (binding && scopeOwnsBinding(scope, canonical, binding))
|
|
840
|
+
return undefined;
|
|
841
|
+
if (row.laterLocalBlocksOuterKinds.has(scope.kind))
|
|
842
|
+
return scope;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
if (tracksLexicalNames) {
|
|
846
|
+
const current = stack[stack.length - 1] ?? rootScope;
|
|
847
|
+
// A covering declaration still ahead in this scope shadows an outer binding (TDZ, hoisting).
|
|
848
|
+
if (current.pendingCoveringNames?.has(canonical))
|
|
849
|
+
return current;
|
|
850
|
+
if (binding && current.map.get(canonical) === binding)
|
|
851
|
+
return undefined;
|
|
852
|
+
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
853
|
+
const scope = stack[index];
|
|
854
|
+
if (binding && scopeOwnsBinding(scope, canonical, binding))
|
|
855
|
+
return undefined;
|
|
856
|
+
if (scope.pendingCoveringNames?.has(canonical))
|
|
857
|
+
return scope;
|
|
858
|
+
}
|
|
859
|
+
return undefined;
|
|
860
|
+
}
|
|
861
|
+
if (!binding && canDeferForward) {
|
|
862
|
+
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
863
|
+
const scope = stack[index];
|
|
864
|
+
if (scopeCanGainCoveringBinding(scope))
|
|
865
|
+
return scope;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
return undefined;
|
|
869
|
+
};
|
|
870
|
+
const scopeCanGainCoveringBinding = (scope) => !!row.wholeScopeKinds?.has(scope.kind) ||
|
|
871
|
+
!!row.variableTargetScopeKinds?.has(scope.kind) ||
|
|
872
|
+
!!row.laterLocalBlocksOuterKinds?.has(scope.kind) ||
|
|
873
|
+
!!row.wholeScopeDeclarationTypes?.size ||
|
|
874
|
+
(scope.kind === "module" && !!row.moduleBindingsAtFunctionRuntime);
|
|
875
|
+
const moduleBindingAtFunctionRuntime = (useNode) => {
|
|
876
|
+
if (!row.moduleBindingsAtFunctionRuntime)
|
|
877
|
+
return false;
|
|
878
|
+
for (let current = useNode.parent; current; current = current.parent) {
|
|
879
|
+
if (!support.createsFunctionScope(current))
|
|
880
|
+
continue;
|
|
881
|
+
const body = current.childForFieldName("body");
|
|
882
|
+
return !!body && useNode.startIndex >= body.startIndex && useNode.endIndex <= body.endIndex;
|
|
883
|
+
}
|
|
884
|
+
return false;
|
|
885
|
+
};
|
|
886
|
+
const lookupCovering = (start, useNode, canonical, phpThis) => {
|
|
887
|
+
const useStart = useNode.startIndex;
|
|
888
|
+
const methodCall = isExplicitMethodCall(row, useNode);
|
|
889
|
+
let scope = start;
|
|
890
|
+
while (scope) {
|
|
891
|
+
if (!scopeAllowsUse(row, scope, useNode)) {
|
|
892
|
+
scope = scope.parent;
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
if (!(phpThis && scope.kind === "function")) {
|
|
896
|
+
let binding = scope.map.get(canonical);
|
|
897
|
+
const atModuleRuntime = scope.kind === "module" && moduleBindingAtFunctionRuntime(useNode);
|
|
898
|
+
while (binding &&
|
|
899
|
+
((methodCall && binding.kind === "local") ||
|
|
900
|
+
(!atModuleRuntime && !bindingCoversUse(row, scope.kind, binding, useStart)))) {
|
|
901
|
+
binding = binding.earlierSameScope;
|
|
902
|
+
}
|
|
903
|
+
if (binding)
|
|
904
|
+
return binding;
|
|
905
|
+
}
|
|
906
|
+
if (laterLocalBlocksOuterUse(row, scope, canonical, useStart))
|
|
907
|
+
return undefined;
|
|
908
|
+
scope = scope.parent;
|
|
909
|
+
}
|
|
910
|
+
return undefined;
|
|
911
|
+
};
|
|
912
|
+
const attachOccurrence = (binding, useNode) => {
|
|
913
|
+
const range = toRange(useNode);
|
|
914
|
+
if (support.id === "cpp" && binding.kind === "function") {
|
|
915
|
+
cppFunctionOccurrences.push({ binding, node: useNode, range });
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
binding.occurrences.push(range);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
const queueUse = (scope, id) => {
|
|
922
|
+
let queued = scope.queuedUseIds;
|
|
923
|
+
if (!queued)
|
|
924
|
+
scope.queuedUseIds = queued = [];
|
|
925
|
+
queued.push(id);
|
|
926
|
+
};
|
|
927
|
+
const closeScope = (scope) => {
|
|
928
|
+
const queued = scope.queuedUseIds;
|
|
929
|
+
if (!queued)
|
|
930
|
+
return;
|
|
931
|
+
delete scope.queuedUseIds;
|
|
932
|
+
let receiver;
|
|
933
|
+
if (!tracksLexicalNames) {
|
|
934
|
+
receiver = scope.parent;
|
|
935
|
+
while (receiver && !scopeCanGainCoveringBinding(receiver))
|
|
936
|
+
receiver = receiver.parent;
|
|
937
|
+
}
|
|
938
|
+
for (let index = 0; index < queued.length; index += 1) {
|
|
939
|
+
const id = queued[index];
|
|
940
|
+
const useNode = nodeById(id);
|
|
941
|
+
if (!useNode)
|
|
942
|
+
continue;
|
|
943
|
+
const phpThis = support.id === "php" && isPhpThisPropertyName(useNode);
|
|
944
|
+
const canonical = canonicalUseName(sliceText(useNode, source), useNode);
|
|
945
|
+
const binding = lookupCovering(scope, useNode, canonical, phpThis);
|
|
946
|
+
if (!binding) {
|
|
947
|
+
if (laterLocalBlocksOuterUse(row, scope, canonical, useNode.startIndex))
|
|
948
|
+
continue;
|
|
949
|
+
if (receiver)
|
|
950
|
+
queueUse(receiver, id);
|
|
951
|
+
continue;
|
|
952
|
+
}
|
|
953
|
+
if (receiver && !scopeOwnsBinding(scope, canonical, binding)) {
|
|
954
|
+
queueUse(receiver, id);
|
|
955
|
+
continue;
|
|
956
|
+
}
|
|
957
|
+
attachOccurrence(binding, useNode);
|
|
958
|
+
}
|
|
959
|
+
};
|
|
264
960
|
const walk = (node) => {
|
|
961
|
+
let scopedFunctionName = null;
|
|
962
|
+
let qualifiedNamespaceScope;
|
|
265
963
|
// A name-registering node puts its name in the *current* (enclosing) scope before the push
|
|
266
964
|
// below creates the node's own scope. C# local functions need that: they are callable from
|
|
267
965
|
// sibling statements in the enclosing method, unlike a JS named function expression's
|
|
268
966
|
// self-only visibility, which the language's `scopeDeclarationNames` hook handles instead.
|
|
269
967
|
if (row.functionNameTypes?.has(node.type)) {
|
|
270
|
-
const name = node
|
|
968
|
+
const name = declaredNameNode(node, row);
|
|
271
969
|
if (name && (support.membersAreImplicitlyInScope || !isMemberFunction(node))) {
|
|
272
|
-
|
|
970
|
+
// The declarator chain that carries a C-family function name also carries its parameter
|
|
971
|
+
// list, so the child walk must still descend into it. Remember the exact name node instead
|
|
972
|
+
// and skip only that node below, which keeps one binding per function without hiding
|
|
973
|
+
// `function_declarator > parameter_list` from parameter registration.
|
|
974
|
+
preRegisteredNameSpans.add(nameSpanKey(name));
|
|
975
|
+
const qualifiedName = support.id === "cpp" ? qualifiedCppIdentifierForName(name, node) : null;
|
|
976
|
+
if (qualifiedName) {
|
|
977
|
+
const qualifiedKey = cppQualifiedNameSegments(qualifiedName, source).join("::");
|
|
978
|
+
const ownerKey = qualifiedKey.slice(0, qualifiedKey.lastIndexOf("::"));
|
|
979
|
+
qualifiedNamespaceScope = cppNamespaceScopes.get(ownerKey);
|
|
980
|
+
if (qualifiedNamespaceScope) {
|
|
981
|
+
addBinding(qualifiedNamespaceScope, name, "function");
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
984
|
+
scopedFunctionName = { node: name, qualifiedKey };
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
else if (row.hoistedFunctionTypes?.has(node.type)) {
|
|
273
988
|
addHoistedDecl(name, "function");
|
|
274
|
-
|
|
989
|
+
}
|
|
990
|
+
else {
|
|
275
991
|
addDecl(name, "function");
|
|
992
|
+
}
|
|
276
993
|
}
|
|
277
994
|
}
|
|
278
995
|
if (row.classNameTypes?.has(node.type)) {
|
|
@@ -305,32 +1022,78 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
305
1022
|
addDecl(node, "local");
|
|
306
1023
|
}
|
|
307
1024
|
let pushed = false;
|
|
308
|
-
|
|
1025
|
+
let pushedScopeCount = 0;
|
|
1026
|
+
const namespacePathStart = cppNamespacePath.length;
|
|
1027
|
+
const cppNamespaceName = support.id === "cpp" && node.type === "namespace_definition" ? node.childForFieldName("name") : null;
|
|
1028
|
+
const cppNamespaceIsInline = !!cppNamespaceName && /^\s*inline\s+namespace\b/u.test(sliceText(node, source));
|
|
1029
|
+
const createsCppNamespaceScope = !!cppNamespaceName && !cppNamespaceIsInline;
|
|
1030
|
+
const createsMemberScope = !!row.memberScopeTypes?.has(node.type);
|
|
1031
|
+
if (createsCppNamespaceScope) {
|
|
1032
|
+
const name = cppNamespaceName;
|
|
1033
|
+
const segments = sliceText(name, source).replace(/\s+/gu, "").split("::").filter(Boolean);
|
|
1034
|
+
for (const segment of segments) {
|
|
1035
|
+
cppNamespacePath.push(segment);
|
|
1036
|
+
const key = cppNamespacePath.join("::");
|
|
1037
|
+
const map = cppNamespaceMaps.get(key) ?? new Map();
|
|
1038
|
+
cppNamespaceMaps.set(key, map);
|
|
1039
|
+
cppNamespacePathByMap.set(map, key);
|
|
1040
|
+
const scope = {
|
|
1041
|
+
kind: "block",
|
|
1042
|
+
map,
|
|
1043
|
+
node,
|
|
1044
|
+
parent: stack[stack.length - 1],
|
|
1045
|
+
};
|
|
1046
|
+
stack.push(scope);
|
|
1047
|
+
allScopes.push(scope);
|
|
1048
|
+
if (!cppNamespaceScopes.has(key))
|
|
1049
|
+
cppNamespaceScopes.set(key, scope);
|
|
1050
|
+
pushed = true;
|
|
1051
|
+
pushedScopeCount += 1;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
else if (support.createsFunctionScope(node)) {
|
|
309
1055
|
const scope = {
|
|
310
1056
|
kind: "function",
|
|
311
1057
|
map: new Map(),
|
|
312
1058
|
node,
|
|
313
|
-
parent: stack[stack.length - 1],
|
|
1059
|
+
parent: qualifiedNamespaceScope ?? stack[stack.length - 1],
|
|
314
1060
|
};
|
|
315
1061
|
stack.push(scope);
|
|
316
1062
|
allScopes.push(scope);
|
|
317
1063
|
pushed = true;
|
|
1064
|
+
pushedScopeCount = 1;
|
|
1065
|
+
if (scopedFunctionName) {
|
|
1066
|
+
addDecl(scopedFunctionName.node, "function");
|
|
1067
|
+
const binding = scope.map.get(normalizeIdentifier(sliceText(scopedFunctionName.node, source)));
|
|
1068
|
+
if (binding) {
|
|
1069
|
+
const bindings = cppQualifiedMemberBindings.get(scopedFunctionName.qualifiedKey) ?? [];
|
|
1070
|
+
bindings.push(binding);
|
|
1071
|
+
cppQualifiedMemberBindings.set(scopedFunctionName.qualifiedKey, bindings);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
318
1074
|
const params = node.childForFieldName("parameters");
|
|
319
1075
|
if (params)
|
|
320
1076
|
addPatternDecls(params, "param");
|
|
321
1077
|
collectHoistedDeclarations(node);
|
|
1078
|
+
attachPendingNames(scope);
|
|
322
1079
|
}
|
|
323
|
-
else if (support.createsBlockScope(node)) {
|
|
1080
|
+
else if (support.createsBlockScope(node) || createsMemberScope) {
|
|
324
1081
|
if (!row.moduleRootTypes?.has(node.type)) {
|
|
325
1082
|
const scope = {
|
|
326
|
-
kind: "block",
|
|
1083
|
+
kind: createsMemberScope ? "member" : "block",
|
|
327
1084
|
map: new Map(),
|
|
328
1085
|
node,
|
|
329
1086
|
parent: stack[stack.length - 1],
|
|
330
1087
|
};
|
|
1088
|
+
attachPendingNames(scope);
|
|
331
1089
|
stack.push(scope);
|
|
332
1090
|
allScopes.push(scope);
|
|
333
1091
|
pushed = true;
|
|
1092
|
+
pushedScopeCount = 1;
|
|
1093
|
+
const blockParams = node.childForFieldName("parameters");
|
|
1094
|
+
if (blockParams && (blockParams.type === "block_parameters" || blockParams.type === "lambda_parameters")) {
|
|
1095
|
+
addPatternDecls(blockParams, "param");
|
|
1096
|
+
}
|
|
334
1097
|
}
|
|
335
1098
|
}
|
|
336
1099
|
else if (row.typeScopeTypes?.has(node.type)) {
|
|
@@ -345,12 +1108,30 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
345
1108
|
node,
|
|
346
1109
|
parent: stack[stack.length - 1],
|
|
347
1110
|
};
|
|
1111
|
+
attachPendingNames(scope);
|
|
348
1112
|
stack.push(scope);
|
|
349
1113
|
allScopes.push(scope);
|
|
350
1114
|
pushed = true;
|
|
1115
|
+
pushedScopeCount = 1;
|
|
351
1116
|
}
|
|
352
1117
|
if (row.variableDeclarationTypes?.has(node.type)) {
|
|
353
|
-
addVariableDeclarations(node, row.hoistedVariableDeclarationTypes?.has(node.type) ? addHoistedDecl :
|
|
1118
|
+
addVariableDeclarations(node, row.hoistedVariableDeclarationTypes?.has(node.type) ? addHoistedDecl : addVariableDecl);
|
|
1119
|
+
}
|
|
1120
|
+
if (isJsTsLanguage(support.id) &&
|
|
1121
|
+
(node.type === "assignment_expression" || node.type === "augmented_assignment_expression")) {
|
|
1122
|
+
const left = node.childForFieldName("left");
|
|
1123
|
+
if (left && idSet.has(left.type)) {
|
|
1124
|
+
const binding = lookup(sliceText(left, source), left);
|
|
1125
|
+
if (binding?.kind === "local" && binding.heldModuleSpecifier !== null) {
|
|
1126
|
+
const assigned = node.type === "assignment_expression" ? moduleSpecifierFromValue(node.childForFieldName("right")) : null;
|
|
1127
|
+
if (!assigned || (binding.heldModuleSpecifier && binding.heldModuleSpecifier !== assigned)) {
|
|
1128
|
+
binding.heldModuleSpecifier = null;
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
binding.heldModuleSpecifier = assigned;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
354
1135
|
}
|
|
355
1136
|
if (row.declarationPatternTypes?.has(node.type)) {
|
|
356
1137
|
// C# is-pattern bound variable: `if (o is string text)`. The walker registers the bound name
|
|
@@ -369,54 +1150,194 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
|
|
|
369
1150
|
if (name)
|
|
370
1151
|
addDecl(name, "type");
|
|
371
1152
|
}
|
|
1153
|
+
let declarationName = idSet.has(node.type) && support.isDeclarationName(node);
|
|
1154
|
+
if (declarationName && row.shortVariableDeclarationTypes) {
|
|
1155
|
+
for (let current = node.parent; current; current = current.parent) {
|
|
1156
|
+
if (row.shortVariableDeclarationTypes.has(current.type)) {
|
|
1157
|
+
const left = current.childForFieldName("left");
|
|
1158
|
+
declarationName = !!left && node.startIndex >= left.startIndex && node.endIndex <= left.endIndex;
|
|
1159
|
+
break;
|
|
1160
|
+
}
|
|
1161
|
+
if (support.createsFunctionScope(current) || support.createsBlockScope(current))
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
372
1165
|
if (scopeDeclarationNames(node) &&
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
!
|
|
1166
|
+
declarationName &&
|
|
1167
|
+
!isScopedEnumeratorName(node) &&
|
|
1168
|
+
!preRegisteredNameSpans.has(nameSpanKey(node))) {
|
|
376
1169
|
const kind = isParamNode(node) ? "param" : declarationKindToBindingKind(support.classifyDefinition(node));
|
|
377
1170
|
addDeclSkippingTypeScope(node, kind);
|
|
378
1171
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
1172
|
+
const nestedIdentifier = node.parent && idSet.has(node.parent.type) && row.childSkipNameTypes?.has(node.type);
|
|
1173
|
+
if (idSet.has(node.type) && !declarationName && !nestedIdentifier) {
|
|
1174
|
+
const qualifiedName = support.id === "cpp" ? qualifiedCppIdentifierForName(node) : null;
|
|
1175
|
+
if (qualifiedName) {
|
|
1176
|
+
const key = cppQualifiedNameSegments(qualifiedName, source).join("::");
|
|
1177
|
+
const occurrences = cppQualifiedMemberOccurrences.get(key) ?? [];
|
|
1178
|
+
const fallback = lookup(sliceText(node, source));
|
|
1179
|
+
occurrences.push({ node, range: toRange(node), ...(fallback ? { fallback } : {}) });
|
|
1180
|
+
cppQualifiedMemberOccurrences.set(key, occurrences);
|
|
1181
|
+
}
|
|
1182
|
+
else {
|
|
1183
|
+
const parent = node.parent;
|
|
1184
|
+
const memberProperty = parent &&
|
|
1185
|
+
(row.nonLexicalMemberPropertyTypes?.has(parent.type) ||
|
|
1186
|
+
(support.id === "cpp" && isMemberAccessNode(support, parent)))
|
|
1187
|
+
? getMemberAccessParts(support, parent).property
|
|
1188
|
+
: null;
|
|
1189
|
+
const isMemberProperty = !!memberProperty && memberProperty.startIndex <= node.startIndex && memberProperty.endIndex >= node.endIndex;
|
|
1190
|
+
if (!isMemberProperty) {
|
|
1191
|
+
const phpThis = support.id === "php" && isPhpThisPropertyName(node);
|
|
1192
|
+
const name = sliceText(node, source);
|
|
1193
|
+
const binding = phpThis ? lookupOutsideFunctions(name) : lookup(name, node);
|
|
1194
|
+
const canonical = canonicalUseName(name, node);
|
|
1195
|
+
const deferred = deferToScope(canonical, binding);
|
|
1196
|
+
const useId = node.id;
|
|
1197
|
+
if (deferred && useId !== undefined)
|
|
1198
|
+
queueUse(deferred, useId);
|
|
1199
|
+
else if (binding)
|
|
1200
|
+
attachOccurrence(binding, node);
|
|
1201
|
+
}
|
|
383
1202
|
}
|
|
384
1203
|
}
|
|
1204
|
+
if (support.id === "php" && node.type === "class_declaration") {
|
|
1205
|
+
const target = stack[stack.length - 1] ?? rootScope;
|
|
1206
|
+
for (const variable of promotedVariablesInClass(node))
|
|
1207
|
+
addBinding(target, variable, "local");
|
|
1208
|
+
}
|
|
385
1209
|
for (const child of node.namedChildren) {
|
|
386
1210
|
if (pushed) {
|
|
387
1211
|
const params = node.childForFieldName("parameters");
|
|
388
1212
|
const skipsFunctionParameters = support.createsFunctionScope(node) && params?.id === child.id;
|
|
1213
|
+
const skipsBlockParameters = support.createsBlockScope(node) &&
|
|
1214
|
+
(child.type === "block_parameters" || child.type === "lambda_parameters") &&
|
|
1215
|
+
params?.startIndex === child.startIndex &&
|
|
1216
|
+
params.endIndex === child.endIndex;
|
|
389
1217
|
const skipsNameOrParameters = (row.functionNameTypes?.has(node.type) || row.classNameTypes?.has(node.type)) &&
|
|
390
1218
|
row.childSkipNameTypes?.has(child.type);
|
|
391
|
-
|
|
1219
|
+
const skipsCppNamespaceName = createsCppNamespaceScope && node.childForFieldName("name")?.id === child.id;
|
|
1220
|
+
if (skipsFunctionParameters || skipsBlockParameters || skipsNameOrParameters || skipsCppNamespaceName) {
|
|
392
1221
|
continue;
|
|
393
1222
|
}
|
|
394
1223
|
}
|
|
395
1224
|
walk(child);
|
|
396
1225
|
}
|
|
397
|
-
|
|
1226
|
+
for (let index = 0; index < pushedScopeCount; index += 1) {
|
|
1227
|
+
const closed = stack[stack.length - 1];
|
|
1228
|
+
if (closed)
|
|
1229
|
+
closeScope(closed);
|
|
398
1230
|
stack.pop();
|
|
1231
|
+
}
|
|
1232
|
+
cppNamespacePath.length = namespacePathStart;
|
|
1233
|
+
};
|
|
1234
|
+
const prepareCppCallableBindings = (bindings) => {
|
|
1235
|
+
const bySignature = new Map();
|
|
1236
|
+
for (const binding of bindings) {
|
|
1237
|
+
const callable = binding.callable;
|
|
1238
|
+
if (!callable?.signature || !callable.arity) {
|
|
1239
|
+
for (const candidate of bindings)
|
|
1240
|
+
candidate.occurrencesComplete = false;
|
|
1241
|
+
return false;
|
|
1242
|
+
}
|
|
1243
|
+
const entity = bySignature.get(callable.key) ?? [];
|
|
1244
|
+
entity.push(binding);
|
|
1245
|
+
bySignature.set(callable.key, entity);
|
|
1246
|
+
}
|
|
1247
|
+
for (const entity of bySignature.values()) {
|
|
1248
|
+
const occurrences = entity.flatMap((binding) => (binding.def ? [binding.def] : []));
|
|
1249
|
+
for (const binding of entity) {
|
|
1250
|
+
binding.occurrences = occurrences;
|
|
1251
|
+
delete binding.occurrencesComplete;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
return true;
|
|
1255
|
+
};
|
|
1256
|
+
const assignCppCallableOccurrence = (bindings, node, range) => {
|
|
1257
|
+
const selected = cppSelectCallableBinding(bindings, node, source, file, file);
|
|
1258
|
+
if (selected) {
|
|
1259
|
+
selected.occurrences.push(range);
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
for (const binding of bindings)
|
|
1263
|
+
binding.occurrencesComplete = false;
|
|
1264
|
+
};
|
|
1265
|
+
const cppOccurrenceBindings = (binding) => {
|
|
1266
|
+
const collisions = binding.sameScopeFunctionBindings ?? [binding];
|
|
1267
|
+
if (collisions.length > 1 || binding.callable?.signature)
|
|
1268
|
+
return collisions;
|
|
1269
|
+
return null;
|
|
399
1270
|
};
|
|
400
1271
|
collectHoistedDeclarations(tree.rootNode);
|
|
1272
|
+
attachPendingNames(rootScope);
|
|
401
1273
|
walk(tree.rootNode);
|
|
1274
|
+
closeScope(rootScope);
|
|
1275
|
+
for (const collisions of cppFunctionCollisionGroups)
|
|
1276
|
+
prepareCppCallableBindings(collisions);
|
|
1277
|
+
const cppQualifiedCallableBindings = new Map();
|
|
1278
|
+
for (const [key, memberBindings] of cppQualifiedMemberBindings) {
|
|
1279
|
+
const callableBindings = [
|
|
1280
|
+
...new Set(memberBindings.flatMap((binding) => binding.sameScopeFunctionBindings ?? [binding])),
|
|
1281
|
+
];
|
|
1282
|
+
if (prepareCppCallableBindings(callableBindings))
|
|
1283
|
+
cppQualifiedCallableBindings.set(key, callableBindings);
|
|
1284
|
+
}
|
|
1285
|
+
for (const occurrence of cppFunctionOccurrences) {
|
|
1286
|
+
const group = cppOccurrenceBindings(occurrence.binding);
|
|
1287
|
+
if (group) {
|
|
1288
|
+
assignCppCallableOccurrence(group, occurrence.node, occurrence.range);
|
|
1289
|
+
}
|
|
1290
|
+
else {
|
|
1291
|
+
occurrence.binding.occurrences.push(occurrence.range);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
for (const [key, callableBindings] of cppQualifiedCallableBindings) {
|
|
1295
|
+
for (const occurrence of cppQualifiedMemberOccurrences.get(key) ?? []) {
|
|
1296
|
+
assignCppCallableOccurrence(callableBindings, occurrence.node, occurrence.range);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
for (const [key, occurrences] of cppQualifiedMemberOccurrences) {
|
|
1300
|
+
if (cppQualifiedCallableBindings.has(key))
|
|
1301
|
+
continue;
|
|
1302
|
+
for (const occurrence of occurrences) {
|
|
1303
|
+
const fallback = occurrence.fallback;
|
|
1304
|
+
if (!fallback)
|
|
1305
|
+
continue;
|
|
1306
|
+
const group = cppOccurrenceBindings(fallback);
|
|
1307
|
+
if (group) {
|
|
1308
|
+
assignCppCallableOccurrence(group, occurrence.node, occurrence.range);
|
|
1309
|
+
}
|
|
1310
|
+
else {
|
|
1311
|
+
fallback.occurrences.push(occurrence.range);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
402
1315
|
const bindings = new Map();
|
|
403
1316
|
const all = [];
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
for (const scope of allScopes)
|
|
413
|
-
flush(scope);
|
|
414
|
-
for (const binding of extraBindings) {
|
|
1317
|
+
const flushedMaps = new Set();
|
|
1318
|
+
const seenBindings = new Set();
|
|
1319
|
+
const pushBinding = (binding) => {
|
|
1320
|
+
if (seenBindings.has(binding))
|
|
1321
|
+
return;
|
|
1322
|
+
seenBindings.add(binding);
|
|
415
1323
|
if (!bindings.has(binding.canonicalName))
|
|
416
1324
|
bindings.set(binding.canonicalName, []);
|
|
417
1325
|
bindings.get(binding.canonicalName).push(binding);
|
|
418
1326
|
all.push(binding);
|
|
419
|
-
|
|
420
|
-
|
|
1327
|
+
if (binding.earlierSameScope)
|
|
1328
|
+
pushBinding(binding.earlierSameScope);
|
|
1329
|
+
};
|
|
1330
|
+
const flush = (scope) => {
|
|
1331
|
+
if (flushedMaps.has(scope.map))
|
|
1332
|
+
return;
|
|
1333
|
+
flushedMaps.add(scope.map);
|
|
1334
|
+
for (const binding of scope.map.values())
|
|
1335
|
+
pushBinding(binding);
|
|
1336
|
+
};
|
|
1337
|
+
for (const scope of allScopes)
|
|
1338
|
+
flush(scope);
|
|
1339
|
+
for (const binding of extraBindings)
|
|
1340
|
+
pushBinding(binding);
|
|
1341
|
+
return { bindings, all, allScopes, cppQualifiedFunctionBindings: cppQualifiedCallableBindings };
|
|
421
1342
|
}
|
|
422
1343
|
//# sourceMappingURL=scope.js.map
|