@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
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
import { supportForFileWithoutHeaderSample } from "../languages.js";
|
|
2
|
+
import { cppOutOfLineOwnerPath, cppQualifiedNameSegments } from "../graphs/symbol-graph-detailed/receiver-calls.js";
|
|
3
|
+
import { sliceText } from "../util/ast.js";
|
|
4
|
+
import { fileIdentityKey } from "../util/paths.js";
|
|
5
|
+
import { ensureParsedContext } from "./parse-context.js";
|
|
6
|
+
import { cppEquivalentCallableBindings, cppSelectCallableByCallArity, cppSelectCallableBinding, } from "./cpp-callables.js";
|
|
7
|
+
import { getOrBuildScopeIndex } from "./navigation-local.js";
|
|
8
|
+
import { fileScopeDefinitionCoversUse } from "./scope-nodes.js";
|
|
9
|
+
import { definitionIdentityKey } from "./reference-context.js";
|
|
10
|
+
import { SymbolKind } from "./types.js";
|
|
11
|
+
const CPP_MEMBER_CONTAINER_TYPES = new Set(["class_specifier", "struct_specifier", "union_specifier"]);
|
|
12
|
+
const resolutionCache = new WeakMap();
|
|
13
|
+
function cppBindingDefinition(file, binding) {
|
|
14
|
+
if (!binding.def)
|
|
15
|
+
return null;
|
|
16
|
+
return {
|
|
17
|
+
file,
|
|
18
|
+
localName: binding.name,
|
|
19
|
+
kind: SymbolKind.Function,
|
|
20
|
+
range: binding.def,
|
|
21
|
+
...(binding.callable ? { callable: binding.callable } : {}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function resolveCppCallableBindings(file, bindings, node, source) {
|
|
25
|
+
const target = cppSelectCallableBinding(bindings, node, source, file, file);
|
|
26
|
+
return target ? cppBindingDefinition(file, target) : null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Undefined means the lexical binding is not a C++ callable that needs arity
|
|
30
|
+
* selection. Null means no unique target after declaration-site and known-call-arity checks.
|
|
31
|
+
*/
|
|
32
|
+
export function resolveCppCollidingBinding(file, binding, node, source) {
|
|
33
|
+
if (binding.kind !== "function")
|
|
34
|
+
return undefined;
|
|
35
|
+
const collisions = binding.sameScopeFunctionBindings ?? [binding];
|
|
36
|
+
if (collisions.length < 2 && !binding.callable?.signature)
|
|
37
|
+
return undefined;
|
|
38
|
+
return resolveCppCallableBindings(file, collisions, node, source);
|
|
39
|
+
}
|
|
40
|
+
/** A using-declaration introduces its target, not a new local definition. */
|
|
41
|
+
export function cppUsingDeclarationTarget(binding, source) {
|
|
42
|
+
const qualified = binding.node?.parent;
|
|
43
|
+
if (qualified?.type !== "qualified_identifier" || qualified.parent?.type !== "using_declaration") {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return cppQualifiedNameSegments(qualified, source).join("::") || undefined;
|
|
47
|
+
}
|
|
48
|
+
function addCppFunctionExportTargets(index, moduleEntry, name, defs, seen) {
|
|
49
|
+
const moduleKey = `${fileIdentityKey(moduleEntry.file)}\0${name}`;
|
|
50
|
+
if (seen.has(moduleKey))
|
|
51
|
+
return;
|
|
52
|
+
seen.add(moduleKey);
|
|
53
|
+
for (const entry of moduleEntry.exports) {
|
|
54
|
+
if (entry.type === "exportStar" || entry.exportedAs !== name)
|
|
55
|
+
continue;
|
|
56
|
+
if (entry.type === "local" && entry.target.kind === SymbolKind.Function) {
|
|
57
|
+
const key = definitionIdentityKey(entry.target);
|
|
58
|
+
if (seen.has(key))
|
|
59
|
+
continue;
|
|
60
|
+
seen.add(key);
|
|
61
|
+
defs.push(entry.target);
|
|
62
|
+
}
|
|
63
|
+
else if (entry.type === "reexport") {
|
|
64
|
+
const target = index.byFile.get(fileIdentityKey(entry.fromModule));
|
|
65
|
+
if (target)
|
|
66
|
+
addCppFunctionExportTargets(index, target, entry.sourceSpecifier, defs, seen);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const imp of moduleEntry.imports) {
|
|
70
|
+
if (imp.kind !== "star" || typeof imp.resolved !== "string")
|
|
71
|
+
continue;
|
|
72
|
+
const target = index.byFile.get(fileIdentityKey(imp.resolved));
|
|
73
|
+
if (target)
|
|
74
|
+
addCppFunctionExportTargets(index, target, name, defs, seen);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Function exports visible as `name` in this module, including include and using-alias targets. */
|
|
78
|
+
export function collectVisibleCppFunctionExports(index, sourceModule, name) {
|
|
79
|
+
const defs = [];
|
|
80
|
+
const seen = new Set();
|
|
81
|
+
addCppFunctionExportTargets(index, sourceModule, name, defs, seen);
|
|
82
|
+
for (const imp of sourceModule.imports) {
|
|
83
|
+
const targetFile = typeof imp.resolved === "string" ? imp.resolved : undefined;
|
|
84
|
+
if (!targetFile)
|
|
85
|
+
continue;
|
|
86
|
+
const targetModule = index.byFile.get(fileIdentityKey(targetFile));
|
|
87
|
+
if (!targetModule)
|
|
88
|
+
continue;
|
|
89
|
+
if (imp.kind === "named") {
|
|
90
|
+
if (imp.local === name || imp.imported === name) {
|
|
91
|
+
addCppFunctionExportTargets(index, targetModule, imp.imported, defs, seen);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return defs;
|
|
96
|
+
}
|
|
97
|
+
/** A same-file overload enters the visible set at its first declaration, not its definition. */
|
|
98
|
+
function visibleCppFunctionExportsAt(index, sourceModule, defs, node, loadParsedFile) {
|
|
99
|
+
const sourceKey = fileIdentityKey(sourceModule.file);
|
|
100
|
+
const useStart = node.startIndex;
|
|
101
|
+
const laterInFile = (def) => fileIdentityKey(def.file) === sourceKey && !fileScopeDefinitionCoversUse("cpp", def.range, useStart);
|
|
102
|
+
if (!defs.some(laterInFile))
|
|
103
|
+
return defs;
|
|
104
|
+
const parsed = loadParsedFile(sourceModule.file);
|
|
105
|
+
const support = parsed?.sup ?? supportForFileWithoutHeaderSample(sourceModule.file, index.languageExtensions);
|
|
106
|
+
const scopeIndex = parsed && support
|
|
107
|
+
? getOrBuildScopeIndex(index, sourceModule.file, parsed.source, support, sourceModule, parsed.tree)
|
|
108
|
+
: null;
|
|
109
|
+
return defs.filter((def) => {
|
|
110
|
+
if (!laterInFile(def))
|
|
111
|
+
return true;
|
|
112
|
+
const binding = scopeIndex?.all.find((candidate) => candidate.kind === "function" &&
|
|
113
|
+
candidate.def?.start.index === def.range.start.index &&
|
|
114
|
+
candidate.def?.end.index === def.range.end.index);
|
|
115
|
+
return (!!binding &&
|
|
116
|
+
cppEquivalentCallableBindings(binding).some((equivalent) => !!equivalent.def && fileScopeDefinitionCoversUse("cpp", equivalent.def, useStart)));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function localDefForBinding(index, file, binding) {
|
|
120
|
+
const synthesized = cppBindingDefinition(file, binding);
|
|
121
|
+
if (!synthesized)
|
|
122
|
+
return null;
|
|
123
|
+
const moduleEntry = index.byFile.get(fileIdentityKey(file));
|
|
124
|
+
return (moduleEntry?.locals.find((candidate) => candidate.kind === SymbolKind.Function &&
|
|
125
|
+
candidate.range.start.index === binding.def?.start.index &&
|
|
126
|
+
candidate.range.end.index === binding.def?.end.index) ?? synthesized);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Selects among already-collected C++ function definitions by known call arity,
|
|
130
|
+
* without treating a consumer's source position as a declaration site.
|
|
131
|
+
*/
|
|
132
|
+
export function resolveCppExportedCallables(index, defs, node, source, loadParsedFile, canonicalNameForDef) {
|
|
133
|
+
const ownedBindings = [];
|
|
134
|
+
const handled = new Set();
|
|
135
|
+
const canonicalNames = new Map();
|
|
136
|
+
const defsByFile = new Map();
|
|
137
|
+
for (const def of defs) {
|
|
138
|
+
const fileKey = fileIdentityKey(def.file);
|
|
139
|
+
const group = defsByFile.get(fileKey);
|
|
140
|
+
if (group)
|
|
141
|
+
group.defs.push(def);
|
|
142
|
+
else
|
|
143
|
+
defsByFile.set(fileKey, { file: def.file, defs: [def] });
|
|
144
|
+
}
|
|
145
|
+
for (const { file, defs: fileDefs } of defsByFile.values()) {
|
|
146
|
+
const moduleEntry = index.byFile.get(fileIdentityKey(file));
|
|
147
|
+
const parsed = loadParsedFile(file);
|
|
148
|
+
const support = parsed?.sup ?? supportForFileWithoutHeaderSample(file, index.languageExtensions);
|
|
149
|
+
if (!moduleEntry || !parsed || !support)
|
|
150
|
+
return null;
|
|
151
|
+
const scopeIndex = getOrBuildScopeIndex(index, file, parsed.source, support, moduleEntry, parsed.tree);
|
|
152
|
+
for (const def of fileDefs) {
|
|
153
|
+
const binding = scopeIndex.all.find((candidate) => candidate.kind === "function" &&
|
|
154
|
+
candidate.def?.start.index === def.range.start.index &&
|
|
155
|
+
candidate.def?.end.index === def.range.end.index);
|
|
156
|
+
if (!binding)
|
|
157
|
+
return null;
|
|
158
|
+
const explicitName = canonicalNameForDef?.(def);
|
|
159
|
+
let canonicalName = explicitName ?? binding.canonicalName;
|
|
160
|
+
if (!explicitName) {
|
|
161
|
+
for (const [qualifiedName, bindings] of scopeIndex.cppQualifiedFunctionBindings) {
|
|
162
|
+
if (!bindings.includes(binding))
|
|
163
|
+
continue;
|
|
164
|
+
canonicalName = qualifiedName;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
for (const equivalent of cppEquivalentCallableBindings(binding)) {
|
|
169
|
+
if (handled.has(equivalent))
|
|
170
|
+
continue;
|
|
171
|
+
handled.add(equivalent);
|
|
172
|
+
canonicalNames.set(equivalent, canonicalName);
|
|
173
|
+
ownedBindings.push({ file, binding: equivalent });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (!ownedBindings.length)
|
|
178
|
+
return null;
|
|
179
|
+
// Bindings may come from included headers; the query node is in the consumer.
|
|
180
|
+
// Skip the declaration-site shortcut so coincident offsets cannot bypass arity.
|
|
181
|
+
const selected = cppSelectCallableByCallArity(ownedBindings.map((entry) => entry.binding), node, source, canonicalNames);
|
|
182
|
+
if (!selected)
|
|
183
|
+
return null;
|
|
184
|
+
const owner = ownedBindings.find((entry) => entry.binding === selected);
|
|
185
|
+
return owner ? localDefForBinding(index, owner.file, selected) : null;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Undefined means this name has no visible C++ function exports. Null means no
|
|
189
|
+
* unique target remains after known-call-arity checks.
|
|
190
|
+
*/
|
|
191
|
+
export function resolveVisibleCppCallableName(index, sourceModule, name, node, source, loadParsedFile) {
|
|
192
|
+
const defs = collectVisibleCppFunctionExports(index, sourceModule, name);
|
|
193
|
+
if (!defs.length)
|
|
194
|
+
return undefined;
|
|
195
|
+
const visibleDefs = visibleCppFunctionExportsAt(index, sourceModule, defs, node, loadParsedFile);
|
|
196
|
+
if (!visibleDefs.length)
|
|
197
|
+
return undefined;
|
|
198
|
+
return resolveCppExportedCallables(index, visibleDefs, node, source, loadParsedFile);
|
|
199
|
+
}
|
|
200
|
+
const CPP_USING_DIRECTIVE_NAME_TYPES = {
|
|
201
|
+
identifier: true,
|
|
202
|
+
namespace_identifier: true,
|
|
203
|
+
type_identifier: true,
|
|
204
|
+
qualified_identifier: true,
|
|
205
|
+
nested_namespace_specifier: true,
|
|
206
|
+
};
|
|
207
|
+
const CPP_USING_DIRECTIVE_REJECT_SCOPES = {
|
|
208
|
+
function_definition: true,
|
|
209
|
+
lambda_expression: true,
|
|
210
|
+
class_specifier: true,
|
|
211
|
+
struct_specifier: true,
|
|
212
|
+
union_specifier: true,
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Directives belong to the parsed tree. The star-import closure belongs to the
|
|
216
|
+
* index and module. Bare-name lookup filters those lists per use. Both maps
|
|
217
|
+
* disappear with their key, the same way the per-index WeakMaps in
|
|
218
|
+
* navigation-references.ts do.
|
|
219
|
+
*/
|
|
220
|
+
const cppUsingDirectivesByTree = new WeakMap();
|
|
221
|
+
const cppStarImportClosureCache = new WeakMap();
|
|
222
|
+
export function cppStarImportClosure(index, sourceModule) {
|
|
223
|
+
let byModule = cppStarImportClosureCache.get(index);
|
|
224
|
+
if (!byModule) {
|
|
225
|
+
byModule = new Map();
|
|
226
|
+
cppStarImportClosureCache.set(index, byModule);
|
|
227
|
+
}
|
|
228
|
+
const moduleKey = fileIdentityKey(sourceModule.file);
|
|
229
|
+
const cached = byModule.get(moduleKey);
|
|
230
|
+
if (cached)
|
|
231
|
+
return cached;
|
|
232
|
+
const modules = [];
|
|
233
|
+
const pending = [sourceModule];
|
|
234
|
+
const seen = new Set();
|
|
235
|
+
while (pending.length) {
|
|
236
|
+
const current = pending.pop();
|
|
237
|
+
const key = fileIdentityKey(current.file);
|
|
238
|
+
if (seen.has(key))
|
|
239
|
+
continue;
|
|
240
|
+
seen.add(key);
|
|
241
|
+
modules.push(current);
|
|
242
|
+
for (const imp of current.imports) {
|
|
243
|
+
if (imp.kind !== "star" || typeof imp.resolved !== "string")
|
|
244
|
+
continue;
|
|
245
|
+
const target = index.byFile.get(fileIdentityKey(imp.resolved));
|
|
246
|
+
if (target)
|
|
247
|
+
pending.push(target);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
byModule.set(moduleKey, modules);
|
|
251
|
+
return modules;
|
|
252
|
+
}
|
|
253
|
+
function cppUsingDirectiveIsFileOrNamespaceScope(node) {
|
|
254
|
+
let current = node.parent;
|
|
255
|
+
while (current) {
|
|
256
|
+
if (CPP_USING_DIRECTIVE_REJECT_SCOPES[current.type])
|
|
257
|
+
return false;
|
|
258
|
+
current = current.parent;
|
|
259
|
+
}
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
function cppEnclosingNamespace(node, source, fileKey) {
|
|
263
|
+
const nested = [];
|
|
264
|
+
let current = node.parent;
|
|
265
|
+
while (current) {
|
|
266
|
+
if (current.type === "namespace_definition") {
|
|
267
|
+
const name = current.childForFieldName("name");
|
|
268
|
+
if (name) {
|
|
269
|
+
const segments = cppQualifiedNameSegments(name, source);
|
|
270
|
+
if (segments.length)
|
|
271
|
+
nested.push(segments);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
nested.push([`\0anon:${fileKey}:${current.startIndex}`]);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
current = current.parent;
|
|
278
|
+
}
|
|
279
|
+
const path = [];
|
|
280
|
+
for (let index = nested.length - 1; index >= 0; index -= 1)
|
|
281
|
+
path.push(...nested[index]);
|
|
282
|
+
return path;
|
|
283
|
+
}
|
|
284
|
+
function cppNamespaceIsPrefix(prefix, path) {
|
|
285
|
+
if (prefix.length > path.length)
|
|
286
|
+
return false;
|
|
287
|
+
for (let index = 0; index < prefix.length; index += 1) {
|
|
288
|
+
if (prefix[index] !== path[index])
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
function cppUsingDirectiveFromNode(node, source, fileKey) {
|
|
294
|
+
if (node.type !== "using_declaration")
|
|
295
|
+
return null;
|
|
296
|
+
let hasNamespaceKeyword = false;
|
|
297
|
+
let target = null;
|
|
298
|
+
for (let index = 0;; index += 1) {
|
|
299
|
+
const child = node.child(index);
|
|
300
|
+
if (!child)
|
|
301
|
+
break;
|
|
302
|
+
if (child.type === "namespace")
|
|
303
|
+
hasNamespaceKeyword = true;
|
|
304
|
+
else if (CPP_USING_DIRECTIVE_NAME_TYPES[child.type]) {
|
|
305
|
+
if (!target || child.type === "qualified_identifier" || child.type === "nested_namespace_specifier") {
|
|
306
|
+
target = child;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (!hasNamespaceKeyword || !target || !cppUsingDirectiveIsFileOrNamespaceScope(node))
|
|
311
|
+
return null;
|
|
312
|
+
const namespacePath = target.type === "identifier" || target.type === "namespace_identifier" || target.type === "type_identifier"
|
|
313
|
+
? [target.text.trim()]
|
|
314
|
+
: cppQualifiedNameSegments(target, source);
|
|
315
|
+
if (!namespacePath.length || namespacePath.some((segment) => segment.length === 0))
|
|
316
|
+
return null;
|
|
317
|
+
return {
|
|
318
|
+
fileKey,
|
|
319
|
+
startIndex: node.startIndex,
|
|
320
|
+
namespacePath,
|
|
321
|
+
enclosing: cppEnclosingNamespace(node, source, fileKey),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function collectCppUsingDirectives(root, source, fileKey, out) {
|
|
325
|
+
const visit = (node) => {
|
|
326
|
+
if (node.type === "using_declaration") {
|
|
327
|
+
const directive = cppUsingDirectiveFromNode(node, source, fileKey);
|
|
328
|
+
if (directive)
|
|
329
|
+
out.push(directive);
|
|
330
|
+
}
|
|
331
|
+
for (const child of node.namedChildren)
|
|
332
|
+
visit(child);
|
|
333
|
+
};
|
|
334
|
+
visit(root);
|
|
335
|
+
}
|
|
336
|
+
function cppUsingDirectivesForFile(tree, source, fileKey) {
|
|
337
|
+
const cached = cppUsingDirectivesByTree.get(tree);
|
|
338
|
+
if (cached?.fileKey === fileKey)
|
|
339
|
+
return cached.directives;
|
|
340
|
+
const directives = [];
|
|
341
|
+
collectCppUsingDirectives(tree.rootNode, source, fileKey, directives);
|
|
342
|
+
cppUsingDirectivesByTree.set(tree, { fileKey, directives });
|
|
343
|
+
return directives;
|
|
344
|
+
}
|
|
345
|
+
function addCppNamedExportTargets(index, moduleEntry, name, defs, seen) {
|
|
346
|
+
const moduleKey = `${fileIdentityKey(moduleEntry.file)}\0${name}`;
|
|
347
|
+
if (seen.has(moduleKey))
|
|
348
|
+
return;
|
|
349
|
+
seen.add(moduleKey);
|
|
350
|
+
for (const entry of moduleEntry.exports) {
|
|
351
|
+
if (entry.type === "exportStar" || entry.exportedAs !== name)
|
|
352
|
+
continue;
|
|
353
|
+
if (entry.type === "local") {
|
|
354
|
+
const key = definitionIdentityKey(entry.target);
|
|
355
|
+
if (seen.has(key))
|
|
356
|
+
continue;
|
|
357
|
+
seen.add(key);
|
|
358
|
+
defs.push(entry.target);
|
|
359
|
+
}
|
|
360
|
+
else if (entry.type === "reexport") {
|
|
361
|
+
const target = index.byFile.get(fileIdentityKey(entry.fromModule));
|
|
362
|
+
if (target)
|
|
363
|
+
addCppNamedExportTargets(index, target, entry.sourceSpecifier, defs, seen);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
for (const imp of moduleEntry.imports) {
|
|
367
|
+
if (imp.kind !== "star" || typeof imp.resolved !== "string")
|
|
368
|
+
continue;
|
|
369
|
+
const target = index.byFile.get(fileIdentityKey(imp.resolved));
|
|
370
|
+
if (target)
|
|
371
|
+
addCppNamedExportTargets(index, target, name, defs, seen);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function collectVisibleCppExportTargets(index, sourceModule, name) {
|
|
375
|
+
const defs = [];
|
|
376
|
+
const seen = new Set();
|
|
377
|
+
addCppNamedExportTargets(index, sourceModule, name, defs, seen);
|
|
378
|
+
for (const imp of sourceModule.imports) {
|
|
379
|
+
if (imp.kind !== "named" || typeof imp.resolved !== "string")
|
|
380
|
+
continue;
|
|
381
|
+
if (imp.local !== name && imp.imported !== name)
|
|
382
|
+
continue;
|
|
383
|
+
const targetModule = index.byFile.get(fileIdentityKey(imp.resolved));
|
|
384
|
+
if (targetModule)
|
|
385
|
+
addCppNamedExportTargets(index, targetModule, imp.imported, defs, seen);
|
|
386
|
+
}
|
|
387
|
+
return defs;
|
|
388
|
+
}
|
|
389
|
+
function cppIncludeSpec(pathNode) {
|
|
390
|
+
const raw = pathNode.text.trim();
|
|
391
|
+
if (pathNode.type === "string_literal" && raw.length >= 2)
|
|
392
|
+
return { text: raw.slice(1, -1), form: "literal" };
|
|
393
|
+
if (pathNode.type === "system_lib_string" && raw.length >= 2)
|
|
394
|
+
return { text: raw.slice(1, -1), form: "angle" };
|
|
395
|
+
return undefined;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* The earliest offset in the use file at which each file enters the translation unit through
|
|
399
|
+
* an `#include`, directly or transitively. A file reached only through an include whose target
|
|
400
|
+
* cannot be read from the source (a macro include) is absent.
|
|
401
|
+
*/
|
|
402
|
+
function cppIncludeEntryOffsets(index, sourceModule, node) {
|
|
403
|
+
let root = node;
|
|
404
|
+
while (root.parent)
|
|
405
|
+
root = root.parent;
|
|
406
|
+
const offsets = new Map();
|
|
407
|
+
const visit = (current) => {
|
|
408
|
+
if (current.type === "preproc_include") {
|
|
409
|
+
const pathNode = current.childForFieldName("path");
|
|
410
|
+
const spec = pathNode ? cppIncludeSpec(pathNode) : undefined;
|
|
411
|
+
if (!spec)
|
|
412
|
+
return;
|
|
413
|
+
for (const imp of sourceModule.imports) {
|
|
414
|
+
if (imp.kind !== "star" || imp.from !== spec.text || typeof imp.resolved !== "string")
|
|
415
|
+
continue;
|
|
416
|
+
if (imp.includeForm && imp.includeForm !== spec.form)
|
|
417
|
+
continue;
|
|
418
|
+
const target = index.byFile.get(fileIdentityKey(imp.resolved));
|
|
419
|
+
if (!target)
|
|
420
|
+
continue;
|
|
421
|
+
// Document order: the first include to reach a file is its earliest entry.
|
|
422
|
+
for (const reached of cppStarImportClosure(index, target)) {
|
|
423
|
+
const key = fileIdentityKey(reached.file);
|
|
424
|
+
if (!offsets.has(key))
|
|
425
|
+
offsets.set(key, current.startIndex);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
for (const child of current.namedChildren)
|
|
431
|
+
visit(child);
|
|
432
|
+
};
|
|
433
|
+
visit(root);
|
|
434
|
+
return offsets;
|
|
435
|
+
}
|
|
436
|
+
const cppNamespaceAliasesByTree = new WeakMap();
|
|
437
|
+
function cppNamespaceAliasTargetSegments(node, source) {
|
|
438
|
+
const name = node.childForFieldName("name");
|
|
439
|
+
for (const child of node.namedChildren) {
|
|
440
|
+
if (name && child.startIndex === name.startIndex && child.endIndex === name.endIndex)
|
|
441
|
+
continue;
|
|
442
|
+
if (child.type !== "namespace_identifier" &&
|
|
443
|
+
child.type !== "nested_namespace_specifier" &&
|
|
444
|
+
child.type !== "splice_specifier") {
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
const segments = cppQualifiedNameSegments(child, source);
|
|
448
|
+
if (segments.length)
|
|
449
|
+
return segments;
|
|
450
|
+
}
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
function collectCppNamespaceAliases(root, source, fileKey) {
|
|
454
|
+
const aliases = [];
|
|
455
|
+
const visit = (node) => {
|
|
456
|
+
if (node.type === "namespace_alias_definition") {
|
|
457
|
+
const nameNode = node.childForFieldName("name");
|
|
458
|
+
const name = nameNode ? sliceText(nameNode, source) : "";
|
|
459
|
+
const target = cppNamespaceAliasTargetSegments(node, source);
|
|
460
|
+
if (name && target) {
|
|
461
|
+
aliases.push({
|
|
462
|
+
startIndex: node.startIndex,
|
|
463
|
+
name,
|
|
464
|
+
target,
|
|
465
|
+
enclosing: cppEnclosingNamespace(node, source, fileKey),
|
|
466
|
+
namespaceScope: cppUsingDirectiveIsFileOrNamespaceScope(node),
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
for (const child of node.namedChildren)
|
|
471
|
+
visit(child);
|
|
472
|
+
};
|
|
473
|
+
visit(root);
|
|
474
|
+
return aliases;
|
|
475
|
+
}
|
|
476
|
+
function cppNamespaceAliasesForTree(tree, source, fileKey) {
|
|
477
|
+
const cached = cppNamespaceAliasesByTree.get(tree);
|
|
478
|
+
if (cached?.fileKey === fileKey)
|
|
479
|
+
return cached.aliases;
|
|
480
|
+
const aliases = collectCppNamespaceAliases(tree.rootNode, source, fileKey);
|
|
481
|
+
cppNamespaceAliasesByTree.set(tree, { fileKey, aliases });
|
|
482
|
+
return aliases;
|
|
483
|
+
}
|
|
484
|
+
function sameNamespacePath(left, right) {
|
|
485
|
+
return left.length === right.length && left.every((segment, index) => segment === right[index]);
|
|
486
|
+
}
|
|
487
|
+
/** A block-scope alias hides namespace aliases. The innermost preceding alias wins. */
|
|
488
|
+
function cppBlockNamespaceAliasTarget(node, source, name, useStart) {
|
|
489
|
+
for (let current = node.parent; current; current = current.parent) {
|
|
490
|
+
if (current.type !== "compound_statement")
|
|
491
|
+
continue;
|
|
492
|
+
let found;
|
|
493
|
+
for (const child of current.namedChildren) {
|
|
494
|
+
if (child.type !== "namespace_alias_definition" || child.startIndex >= useStart)
|
|
495
|
+
continue;
|
|
496
|
+
const nameNode = child.childForFieldName("name");
|
|
497
|
+
if (!nameNode || sliceText(nameNode, source) !== name)
|
|
498
|
+
continue;
|
|
499
|
+
const target = cppNamespaceAliasTargetSegments(child, source);
|
|
500
|
+
if (target)
|
|
501
|
+
found = target;
|
|
502
|
+
}
|
|
503
|
+
if (found)
|
|
504
|
+
return found;
|
|
505
|
+
}
|
|
506
|
+
return undefined;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Latest visible namespace-scope alias of `name` in `enclosing`. A later declaration in the
|
|
510
|
+
* translation unit wins; two aliases at the same position with different targets are ambiguous.
|
|
511
|
+
*/
|
|
512
|
+
function cppNamespaceScopeAliasTarget(files, enclosing, name) {
|
|
513
|
+
let best;
|
|
514
|
+
let ambiguous = false;
|
|
515
|
+
for (const file of files) {
|
|
516
|
+
for (const alias of file.aliases) {
|
|
517
|
+
if (!alias.namespaceScope || alias.name !== name || !sameNamespacePath(alias.enclosing, enclosing))
|
|
518
|
+
continue;
|
|
519
|
+
const position = file.positionOf(alias.startIndex);
|
|
520
|
+
if (position === undefined)
|
|
521
|
+
continue;
|
|
522
|
+
if (!best || position > best.position || (position === best.position && alias.startIndex > best.tie)) {
|
|
523
|
+
best = { position, tie: alias.startIndex, target: alias.target };
|
|
524
|
+
ambiguous = false;
|
|
525
|
+
}
|
|
526
|
+
else if (position === best.position &&
|
|
527
|
+
alias.startIndex === best.tie &&
|
|
528
|
+
alias.target.join("::") !== best.target.join("::")) {
|
|
529
|
+
ambiguous = true;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (ambiguous)
|
|
534
|
+
return null;
|
|
535
|
+
return best?.target;
|
|
536
|
+
}
|
|
537
|
+
/** A namespace or type declared in this scope hides names in every outer namespace. */
|
|
538
|
+
function cppNamespaceScopeOwnerPath(files, enclosing, name) {
|
|
539
|
+
const path = [...enclosing, name];
|
|
540
|
+
const qualified = path.join("::");
|
|
541
|
+
for (const file of files) {
|
|
542
|
+
for (const entry of file.module.exports) {
|
|
543
|
+
if (entry.type !== "local" || entry.exportedAs !== qualified)
|
|
544
|
+
continue;
|
|
545
|
+
if (entry.target.kind !== SymbolKind.Class && entry.target.kind !== SymbolKind.TypeAlias)
|
|
546
|
+
continue;
|
|
547
|
+
const start = entry.target.range.start.index;
|
|
548
|
+
if (start !== undefined && file.positionOf(start) !== undefined)
|
|
549
|
+
return path;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return undefined;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Find the first qualifier where it is used: a block alias, then namespace aliases,
|
|
556
|
+
* nested namespaces, and type names in the enclosing namespaces, innermost first.
|
|
557
|
+
* Undefined means no binding was found; null means an ambiguous or cyclic alias.
|
|
558
|
+
*/
|
|
559
|
+
export function cppQualifiedNameThroughVisiblePrefix(index, sourceModule, name, node, source, tree, loadParsedFile) {
|
|
560
|
+
if (!name.includes("::"))
|
|
561
|
+
return undefined;
|
|
562
|
+
let qualifiedNode = node;
|
|
563
|
+
while (qualifiedNode.parent?.type === "qualified_identifier")
|
|
564
|
+
qualifiedNode = qualifiedNode.parent;
|
|
565
|
+
const absolute = name.startsWith("::") ||
|
|
566
|
+
(qualifiedNode.type === "qualified_identifier" && source.startsWith("::", qualifiedNode.startIndex));
|
|
567
|
+
const segments = name.split("::").filter(Boolean);
|
|
568
|
+
if (segments.length < 2)
|
|
569
|
+
return undefined;
|
|
570
|
+
const useFileKey = fileIdentityKey(sourceModule.file);
|
|
571
|
+
const useStart = node.startIndex;
|
|
572
|
+
const useNamespace = cppEnclosingNamespace(node, source, useFileKey);
|
|
573
|
+
const files = [
|
|
574
|
+
{
|
|
575
|
+
module: sourceModule,
|
|
576
|
+
aliases: cppNamespaceAliasesForTree(tree, source, useFileKey),
|
|
577
|
+
positionOf: (startIndex) => (startIndex < useStart ? startIndex : undefined),
|
|
578
|
+
},
|
|
579
|
+
];
|
|
580
|
+
let entryOffsets;
|
|
581
|
+
for (const moduleEntry of cppStarImportClosure(index, sourceModule)) {
|
|
582
|
+
const fileKey = fileIdentityKey(moduleEntry.file);
|
|
583
|
+
if (fileKey === useFileKey)
|
|
584
|
+
continue;
|
|
585
|
+
const parsed = loadParsedFile(moduleEntry.file);
|
|
586
|
+
if (!parsed?.tree)
|
|
587
|
+
continue;
|
|
588
|
+
entryOffsets ??= cppIncludeEntryOffsets(index, sourceModule, node);
|
|
589
|
+
const entry = entryOffsets.get(fileKey);
|
|
590
|
+
files.push({
|
|
591
|
+
module: moduleEntry,
|
|
592
|
+
aliases: cppNamespaceAliasesForTree(parsed.tree, parsed.source, fileKey),
|
|
593
|
+
positionOf: () => (entry !== undefined && entry < useStart ? entry : undefined),
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
const firstBinding = (segment) => {
|
|
597
|
+
if (!absolute) {
|
|
598
|
+
const block = cppBlockNamespaceAliasTarget(node, source, segment, useStart);
|
|
599
|
+
if (block)
|
|
600
|
+
return { path: block, alias: true };
|
|
601
|
+
}
|
|
602
|
+
for (let length = absolute ? 0 : useNamespace.length; length >= 0; length -= 1) {
|
|
603
|
+
const enclosing = useNamespace.slice(0, length);
|
|
604
|
+
const alias = cppNamespaceScopeAliasTarget(files, enclosing, segment);
|
|
605
|
+
if (alias === null)
|
|
606
|
+
return null;
|
|
607
|
+
if (alias)
|
|
608
|
+
return { path: alias, alias: true };
|
|
609
|
+
const owner = cppNamespaceScopeOwnerPath(files, enclosing, segment);
|
|
610
|
+
if (owner)
|
|
611
|
+
return { path: owner, alias: false };
|
|
612
|
+
}
|
|
613
|
+
return undefined;
|
|
614
|
+
};
|
|
615
|
+
const expandPrefix = (prefix, seen) => {
|
|
616
|
+
let resolved = [];
|
|
617
|
+
let bound = false;
|
|
618
|
+
for (const segment of prefix) {
|
|
619
|
+
let alias;
|
|
620
|
+
if (!resolved.length) {
|
|
621
|
+
const first = firstBinding(segment);
|
|
622
|
+
if (first === null)
|
|
623
|
+
return null;
|
|
624
|
+
if (first && !first.alias) {
|
|
625
|
+
resolved = [...first.path];
|
|
626
|
+
bound = true;
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
alias = first?.path;
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
alias = cppNamespaceScopeAliasTarget(files, resolved, segment);
|
|
633
|
+
}
|
|
634
|
+
if (alias === null)
|
|
635
|
+
return null;
|
|
636
|
+
if (!alias) {
|
|
637
|
+
resolved.push(segment);
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
const key = `${resolved.join("::")}\0${segment}`;
|
|
641
|
+
if (seen.has(key))
|
|
642
|
+
return null;
|
|
643
|
+
seen.add(key);
|
|
644
|
+
bound = true;
|
|
645
|
+
const nested = expandPrefix(alias, seen);
|
|
646
|
+
if (nested === null)
|
|
647
|
+
return null;
|
|
648
|
+
resolved = [...(nested ?? alias)];
|
|
649
|
+
}
|
|
650
|
+
return bound ? resolved : undefined;
|
|
651
|
+
};
|
|
652
|
+
const expanded = expandPrefix(segments.slice(0, -1), new Set());
|
|
653
|
+
if (expanded === null)
|
|
654
|
+
return null;
|
|
655
|
+
if (!expanded)
|
|
656
|
+
return undefined;
|
|
657
|
+
return [...expanded, segments[segments.length - 1]].join("::");
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Bare lookup through `using namespace`. Undefined means no directive nominates
|
|
661
|
+
* this name. Null means more than one viable candidate, or the candidate could
|
|
662
|
+
* not be proved unique. Block-scope directives are ignored.
|
|
663
|
+
*/
|
|
664
|
+
export function resolveCppUsingDirectiveName(index, sourceModule, name, node, source, loadParsedFile) {
|
|
665
|
+
if (!name || name.includes("::"))
|
|
666
|
+
return undefined;
|
|
667
|
+
const useFileKey = fileIdentityKey(sourceModule.file);
|
|
668
|
+
const useNamespace = cppEnclosingNamespace(node, source, useFileKey);
|
|
669
|
+
const directives = [];
|
|
670
|
+
for (const moduleEntry of cppStarImportClosure(index, sourceModule)) {
|
|
671
|
+
const parsed = loadParsedFile(moduleEntry.file);
|
|
672
|
+
if (!parsed?.tree)
|
|
673
|
+
continue;
|
|
674
|
+
directives.push(...cppUsingDirectivesForFile(parsed.tree, parsed.source, fileIdentityKey(moduleEntry.file)));
|
|
675
|
+
}
|
|
676
|
+
let entryOffsets;
|
|
677
|
+
const unordered = [];
|
|
678
|
+
const applicable = directives.filter((directive) => {
|
|
679
|
+
if (!cppNamespaceIsPrefix(directive.enclosing, useNamespace))
|
|
680
|
+
return false;
|
|
681
|
+
if (directive.fileKey === useFileKey)
|
|
682
|
+
return directive.startIndex < node.startIndex;
|
|
683
|
+
// A header's directive is in scope only after the `#include` that brings it in.
|
|
684
|
+
entryOffsets ??= cppIncludeEntryOffsets(index, sourceModule, node);
|
|
685
|
+
const entry = entryOffsets.get(directive.fileKey);
|
|
686
|
+
if (entry === undefined) {
|
|
687
|
+
unordered.push(directive);
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
return entry < node.startIndex;
|
|
691
|
+
});
|
|
692
|
+
// A directive whose include position cannot be read (a macro include) may or may not be
|
|
693
|
+
// in scope. When it would nominate this name, the use stays unresolved.
|
|
694
|
+
const unorderedNominates = unordered.some((directive) => collectVisibleCppExportTargets(index, sourceModule, `${directive.namespacePath.join("::")}::${name}`).length);
|
|
695
|
+
if (unorderedNominates)
|
|
696
|
+
return null;
|
|
697
|
+
if (!applicable.length)
|
|
698
|
+
return undefined;
|
|
699
|
+
const functionDefs = [];
|
|
700
|
+
const otherDefs = [];
|
|
701
|
+
const seen = new Set();
|
|
702
|
+
const qualifiedByDef = new Map();
|
|
703
|
+
for (const directive of applicable) {
|
|
704
|
+
const qualified = `${directive.namespacePath.join("::")}::${name}`;
|
|
705
|
+
for (const def of collectVisibleCppExportTargets(index, sourceModule, qualified)) {
|
|
706
|
+
const key = definitionIdentityKey(def);
|
|
707
|
+
if (seen.has(key))
|
|
708
|
+
continue;
|
|
709
|
+
seen.add(key);
|
|
710
|
+
qualifiedByDef.set(key, qualified);
|
|
711
|
+
if (def.kind === SymbolKind.Function)
|
|
712
|
+
functionDefs.push(def);
|
|
713
|
+
else
|
|
714
|
+
otherDefs.push(def);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (!functionDefs.length && !otherDefs.length)
|
|
718
|
+
return undefined;
|
|
719
|
+
if (functionDefs.length) {
|
|
720
|
+
return resolveCppExportedCallables(index, functionDefs, node, source, loadParsedFile, (def) => qualifiedByDef.get(definitionIdentityKey(def)));
|
|
721
|
+
}
|
|
722
|
+
if (otherDefs.length === 1)
|
|
723
|
+
return otherDefs[0];
|
|
724
|
+
return null;
|
|
725
|
+
}
|
|
726
|
+
function cppMemberContainerForDefinition(tree, def) {
|
|
727
|
+
const position = {
|
|
728
|
+
row: Math.max(0, def.range.start.line - 1),
|
|
729
|
+
column: Math.max(0, def.range.start.column - 1),
|
|
730
|
+
};
|
|
731
|
+
let current = tree.rootNode.descendantForPosition(position, position);
|
|
732
|
+
while (current) {
|
|
733
|
+
if (CPP_MEMBER_CONTAINER_TYPES.has(current.type)) {
|
|
734
|
+
const name = current.childForFieldName("name");
|
|
735
|
+
if (name && name.startPosition.row === position.row && name.startPosition.column === position.column) {
|
|
736
|
+
return current;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
current = current.parent;
|
|
740
|
+
}
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
function cppMemberContainerPath(container, source) {
|
|
744
|
+
const nested = [];
|
|
745
|
+
let current = container;
|
|
746
|
+
while (current) {
|
|
747
|
+
if (CPP_MEMBER_CONTAINER_TYPES.has(current.type) || current.type === "namespace_definition") {
|
|
748
|
+
const name = current.childForFieldName("name");
|
|
749
|
+
if (name) {
|
|
750
|
+
const segments = cppQualifiedNameSegments(name, source);
|
|
751
|
+
if (segments.length)
|
|
752
|
+
nested.push(segments);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
current = current.parent;
|
|
756
|
+
}
|
|
757
|
+
const path = [];
|
|
758
|
+
for (let index = nested.length - 1; index >= 0; index -= 1)
|
|
759
|
+
path.push(...nested[index]);
|
|
760
|
+
return path;
|
|
761
|
+
}
|
|
762
|
+
function sameCppPath(left, right) {
|
|
763
|
+
return left.length === right.length && left.every((segment, index) => segment === right[index]);
|
|
764
|
+
}
|
|
765
|
+
async function resolveCppQualifiedMemberContainerUncached(index, sourceModule, ownerPath, loadParsedFile) {
|
|
766
|
+
const ownerName = ownerPath.at(-1);
|
|
767
|
+
if (!ownerName)
|
|
768
|
+
return null;
|
|
769
|
+
const reachable = [];
|
|
770
|
+
const pending = [sourceModule];
|
|
771
|
+
const visited = new Set();
|
|
772
|
+
while (pending.length) {
|
|
773
|
+
const module = pending.pop();
|
|
774
|
+
const moduleKey = fileIdentityKey(module.file);
|
|
775
|
+
if (visited.has(moduleKey))
|
|
776
|
+
continue;
|
|
777
|
+
visited.add(moduleKey);
|
|
778
|
+
reachable.push(module);
|
|
779
|
+
for (const imp of module.imports) {
|
|
780
|
+
if (typeof imp.resolved !== "string")
|
|
781
|
+
continue;
|
|
782
|
+
const imported = index.byFile.get(fileIdentityKey(imp.resolved));
|
|
783
|
+
if (imported)
|
|
784
|
+
pending.push(imported);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
const matches = [];
|
|
788
|
+
const seen = new Set();
|
|
789
|
+
for (const module of reachable) {
|
|
790
|
+
for (const candidate of module.locals) {
|
|
791
|
+
if (candidate.localName !== ownerName)
|
|
792
|
+
continue;
|
|
793
|
+
const key = `${fileIdentityKey(candidate.file)}:${candidate.range.start.index ?? ""}:${candidate.range.end.index ?? ""}`;
|
|
794
|
+
if (seen.has(key))
|
|
795
|
+
continue;
|
|
796
|
+
seen.add(key);
|
|
797
|
+
let parsed;
|
|
798
|
+
if (loadParsedFile) {
|
|
799
|
+
parsed = await loadParsedFile(candidate.file);
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
parsed = await ensureParsedContext(candidate.file, index.parsed?.get(fileIdentityKey(candidate.file)), index.languageExtensions).catch(() => null);
|
|
803
|
+
}
|
|
804
|
+
if (!parsed)
|
|
805
|
+
continue;
|
|
806
|
+
const container = cppMemberContainerForDefinition(parsed.tree, candidate);
|
|
807
|
+
if (!container || !sameCppPath(cppMemberContainerPath(container, parsed.source), ownerPath))
|
|
808
|
+
continue;
|
|
809
|
+
matches.push({ def: candidate, complete: !!container.childForFieldName("body") });
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
const completeMatches = matches.filter((match) => match.complete);
|
|
813
|
+
if (completeMatches.length === 1)
|
|
814
|
+
return completeMatches[0].def;
|
|
815
|
+
return matches.length === 1 ? matches[0].def : null;
|
|
816
|
+
}
|
|
817
|
+
/** Resolves one reachable C++ class/struct/union by its exact namespace and nesting path. */
|
|
818
|
+
export function resolveCppQualifiedMemberContainer(index, sourceModule, ownerPath, loadParsedFile) {
|
|
819
|
+
let byPath = resolutionCache.get(index);
|
|
820
|
+
if (!byPath) {
|
|
821
|
+
byPath = new Map();
|
|
822
|
+
resolutionCache.set(index, byPath);
|
|
823
|
+
}
|
|
824
|
+
const key = `${fileIdentityKey(sourceModule.file)}\0${ownerPath.join("::")}`;
|
|
825
|
+
let pending = byPath.get(key);
|
|
826
|
+
if (!pending) {
|
|
827
|
+
pending = resolveCppQualifiedMemberContainerUncached(index, sourceModule, ownerPath, loadParsedFile);
|
|
828
|
+
byPath.set(key, pending);
|
|
829
|
+
}
|
|
830
|
+
return pending;
|
|
831
|
+
}
|
|
832
|
+
function hasStaticStorageClass(node) {
|
|
833
|
+
return node.namedChildren.some((child) => child.type === "storage_class_specifier" && child.text === "static");
|
|
834
|
+
}
|
|
835
|
+
/** Select a proven static class member named through a namespace-qualified type. */
|
|
836
|
+
export function resolveCppVisibleStaticCallableName(index, sourceModule, qualifiedName, node, source, loadParsedFile) {
|
|
837
|
+
const separator = qualifiedName.lastIndexOf("::");
|
|
838
|
+
if (separator < 0)
|
|
839
|
+
return undefined;
|
|
840
|
+
const owner = qualifiedName.slice(0, separator);
|
|
841
|
+
const member = qualifiedName.slice(separator + 2);
|
|
842
|
+
const ownerPath = owner.split("::");
|
|
843
|
+
const useFileKey = fileIdentityKey(sourceModule.file);
|
|
844
|
+
let entryOffsets;
|
|
845
|
+
const defs = [];
|
|
846
|
+
for (const moduleEntry of cppStarImportClosure(index, sourceModule)) {
|
|
847
|
+
const fileKey = fileIdentityKey(moduleEntry.file);
|
|
848
|
+
let parsed;
|
|
849
|
+
let includeVisible;
|
|
850
|
+
for (const def of moduleEntry.locals) {
|
|
851
|
+
if (def.kind !== SymbolKind.Function || def.localName !== member || def.callable?.owner !== owner)
|
|
852
|
+
continue;
|
|
853
|
+
if (fileKey !== useFileKey) {
|
|
854
|
+
if (includeVisible === undefined) {
|
|
855
|
+
entryOffsets ??= cppIncludeEntryOffsets(index, sourceModule, node);
|
|
856
|
+
const entry = entryOffsets.get(fileKey);
|
|
857
|
+
includeVisible = entry !== undefined && entry < node.startIndex;
|
|
858
|
+
}
|
|
859
|
+
if (!includeVisible)
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
const start = def.range.start.index;
|
|
863
|
+
if (start === undefined || (fileKey === useFileKey && start >= node.startIndex))
|
|
864
|
+
continue;
|
|
865
|
+
if (parsed === undefined)
|
|
866
|
+
parsed = loadParsedFile(moduleEntry.file);
|
|
867
|
+
if (!parsed)
|
|
868
|
+
break;
|
|
869
|
+
const position = { row: def.range.start.line - 1, column: def.range.start.column - 1 };
|
|
870
|
+
let current = parsed.tree.rootNode.descendantForPosition(position, position);
|
|
871
|
+
let staticMember = false;
|
|
872
|
+
while (current && !CPP_MEMBER_CONTAINER_TYPES.has(current.type)) {
|
|
873
|
+
if (current.type === "function_definition" || current.type === "declaration") {
|
|
874
|
+
staticMember = hasStaticStorageClass(current);
|
|
875
|
+
break;
|
|
876
|
+
}
|
|
877
|
+
current = current.parent;
|
|
878
|
+
}
|
|
879
|
+
if (!staticMember)
|
|
880
|
+
continue;
|
|
881
|
+
while (current && !CPP_MEMBER_CONTAINER_TYPES.has(current.type))
|
|
882
|
+
current = current.parent;
|
|
883
|
+
if (current && sameCppPath(cppMemberContainerPath(current, parsed.source), ownerPath))
|
|
884
|
+
defs.push(def);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
if (!defs.length)
|
|
888
|
+
return undefined;
|
|
889
|
+
return resolveCppExportedCallables(index, defs, node, source, loadParsedFile, () => qualifiedName);
|
|
890
|
+
}
|
|
891
|
+
/** The name a member declarator declares: `f` in `int f(int)`, `int A::f(int)`, or `int* f()`. */
|
|
892
|
+
function cppDeclaredMemberName(declaration, source) {
|
|
893
|
+
let declarator = declaration.childForFieldName("declarator");
|
|
894
|
+
while (declarator && declarator.type !== "function_declarator") {
|
|
895
|
+
declarator = declarator.childForFieldName("declarator");
|
|
896
|
+
}
|
|
897
|
+
const name = declarator?.childForFieldName("declarator");
|
|
898
|
+
if (!name)
|
|
899
|
+
return null;
|
|
900
|
+
return cppQualifiedNameSegments(name, source).at(-1) ?? null;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Whether code inside a C++ function definition has an implicit `this`: the function is a
|
|
904
|
+
* non-static member function, defined in its class body or out of line as `Owner::f`. A free
|
|
905
|
+
* function (including a namespace-qualified one) and a static member function have none, so an
|
|
906
|
+
* instance member cannot be named without an object there. Mixed static and non-static
|
|
907
|
+
* declarations of the same name are not proven either way and count as static.
|
|
908
|
+
*/
|
|
909
|
+
export async function cppFunctionHasImplicitThis(index, sourceModule, definition, source, sup, loadParsedFile) {
|
|
910
|
+
if (sup.id !== "cpp" || definition.type !== "function_definition")
|
|
911
|
+
return false;
|
|
912
|
+
if (hasStaticStorageClass(definition))
|
|
913
|
+
return false;
|
|
914
|
+
const ownerPath = cppOutOfLineOwnerPath(definition, source, sup);
|
|
915
|
+
if (!ownerPath) {
|
|
916
|
+
for (let current = definition.parent; current; current = current.parent) {
|
|
917
|
+
if (CPP_MEMBER_CONTAINER_TYPES.has(current.type))
|
|
918
|
+
return true;
|
|
919
|
+
}
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
const owner = await resolveCppQualifiedMemberContainer(index, sourceModule, ownerPath, loadParsedFile);
|
|
923
|
+
if (!owner)
|
|
924
|
+
return false;
|
|
925
|
+
const parsed = loadParsedFile
|
|
926
|
+
? await loadParsedFile(owner.file)
|
|
927
|
+
: await ensureParsedContext(owner.file, undefined, index.languageExtensions);
|
|
928
|
+
const body = parsed ? cppMemberContainerForDefinition(parsed.tree, owner)?.childForFieldName("body") : null;
|
|
929
|
+
const memberName = cppDeclaredMemberName(definition, source);
|
|
930
|
+
if (!body || !parsed || !memberName)
|
|
931
|
+
return false;
|
|
932
|
+
const declarations = body.namedChildren.filter((child) => cppDeclaredMemberName(child, parsed.source) === memberName);
|
|
933
|
+
return declarations.length > 0 && declarations.every((declaration) => !hasStaticStorageClass(declaration));
|
|
934
|
+
}
|
|
935
|
+
//# sourceMappingURL=navigation-cpp.js.map
|