@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
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
1
|
import path from "node:path";
|
|
3
2
|
import { supportForFileWithoutHeaderSample } from "../languages.js";
|
|
4
|
-
import { languageHasDeclarationVisibility } from "./declaration-visibility.js";
|
|
5
|
-
import {
|
|
3
|
+
import { isJvmPackageSymbolVisible, languageHasDeclarationVisibility } from "./declaration-visibility.js";
|
|
4
|
+
import { isJvmStaticWildcardMember, isJvmTypeWildcardMember, jvmWildcardTypeOwner } from "./expand-star-imports.js";
|
|
5
|
+
import { foldPhpIdentifierCase, normalizeCsharpIdentifier, normalizeCsharpQualifiedName } from "../util/identifiers.js";
|
|
6
6
|
import { fileIdentityKey, normalizePath } from "../util/paths.js";
|
|
7
|
+
import { getCompilationUnitPeers, IMPLICIT_UNIT_LANGUAGES, isUnitBareNameVisible } from "./compilation-units.js";
|
|
8
|
+
import { phpNamedImportRole } from "./import-types.js";
|
|
9
|
+
import { resolvePythonSubmoduleExact } from "../util/resolution/python.js";
|
|
10
|
+
import { PHP_CLASS_LIKE_KINDS } from "./php-namespace-symbols.js";
|
|
11
|
+
import { coalesceEquivalentCsharpPartialExports } from "./shared-owner-identity.js";
|
|
7
12
|
import { SymbolKind, } from "./types.js";
|
|
8
|
-
const GO_PACKAGE_PATTERN = new RegExp(String.raw `^\s*package\s+(${GO_IDENTIFIER_SOURCE})`, "mu");
|
|
9
|
-
const JAVA_PACKAGE_NAME_PATTERN = new RegExp(String.raw `^\s*package\s+(${JAVA_IDENTIFIER_SOURCE}(?:\.${JAVA_IDENTIFIER_SOURCE})*)\s*;`, "mu");
|
|
10
|
-
const KOTLIN_PACKAGE_NAME_PATTERN = new RegExp(String.raw `^\s*package\s+(${KOTLIN_IDENTIFIER_SOURCE}(?:\.${KOTLIN_IDENTIFIER_SOURCE})*)`, "mu");
|
|
11
|
-
/**
|
|
12
|
-
* Files that can carry the package declaration each lookup language searches for. Java and Kotlin
|
|
13
|
-
* stay one group because they share a JVM package namespace and each pattern already accepts the
|
|
14
|
-
* other's declaration; every other language is skipped instead of read for a keyword it never uses.
|
|
15
|
-
*/
|
|
16
|
-
const PACKAGE_DECLARING_LANGUAGE_IDS = {
|
|
17
|
-
go: new Set(["go"]),
|
|
18
|
-
java: new Set(["java", "kotlin"]),
|
|
19
|
-
kotlin: new Set(["java", "kotlin"]),
|
|
20
|
-
};
|
|
21
13
|
function cacheKey(file, canonicalName) {
|
|
22
14
|
return `${fileIdentityKey(file)}::canonical::${canonicalName}`;
|
|
23
15
|
}
|
|
24
16
|
const moduleNameLookups = new WeakMap();
|
|
25
|
-
const packageDirectoryLookups = new WeakMap();
|
|
26
|
-
const packageNameCaches = new WeakMap();
|
|
27
17
|
function moduleFor(index, file) {
|
|
28
18
|
return index.byFile.get(fileIdentityKey(file));
|
|
29
19
|
}
|
|
@@ -123,175 +113,191 @@ function sameResolvedExport(index, left, right) {
|
|
|
123
113
|
}
|
|
124
114
|
return false;
|
|
125
115
|
}
|
|
126
|
-
function packageNameCacheFor(index) {
|
|
127
|
-
let caches = packageNameCaches.get(index);
|
|
128
|
-
if (!caches) {
|
|
129
|
-
caches = { go: new Map(), jvm: new Map() };
|
|
130
|
-
packageNameCaches.set(index, caches);
|
|
131
|
-
}
|
|
132
|
-
return caches;
|
|
133
|
-
}
|
|
134
116
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
117
|
+
* Unique same-compilation-unit match for a bare name. Go, the JVM languages, C#, and Swift can
|
|
118
|
+
* name top-level declarations of their package, namespace, or module without an import;
|
|
119
|
+
* candidates come from the same proven unit relation used for reference-candidate discovery
|
|
120
|
+
* (`getCompilationUnitPeers`), never from a project-wide name scan. A name matching more than
|
|
121
|
+
* one unit declaration is ambiguous and stays unresolved, except proven-equivalent C# `partial`
|
|
122
|
+
* type parts, which collapse to one representative before uniqueness is judged. Members are
|
|
123
|
+
* excluded because they resolve through receiver/owner identity rather than as bare unit names.
|
|
138
124
|
*/
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
125
|
+
function resolveImplicitUnitExport(index, file, exportedName, matchesOptions, namespace, useIndex, qualification) {
|
|
126
|
+
// Only the implicit compilation-unit languages have bare-name unit visibility. C and C++
|
|
127
|
+
// keep their include-scope tag precedence and PHP its case-folded namespaces; the unit
|
|
128
|
+
// lookup must not preempt those established fallbacks.
|
|
129
|
+
const languageId = supportForFileWithoutHeaderSample(file, index.languageExtensions)?.id;
|
|
130
|
+
if (!languageId || !IMPLICIT_UNIT_LANGUAGES[languageId])
|
|
147
131
|
return null;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function readGoPackageName(index, filePath) {
|
|
151
|
-
const cache = packageNameCacheFor(index).go;
|
|
152
|
-
const key = fileIdentityKey(filePath);
|
|
153
|
-
const cached = cache.get(key);
|
|
154
|
-
if (cached !== undefined)
|
|
155
|
-
return cached;
|
|
156
|
-
const source = packageDeclarationSource(index, filePath, key);
|
|
157
|
-
if (source === null) {
|
|
158
|
-
cache.set(key, null);
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
const packageName = GO_PACKAGE_PATTERN.exec(source)?.[1] ?? null;
|
|
162
|
-
cache.set(key, packageName);
|
|
163
|
-
return packageName;
|
|
164
|
-
}
|
|
165
|
-
function resolveGoPackageExport(index, file, exportedName) {
|
|
166
|
-
if (supportForFileWithoutHeaderSample(file, index.languageExtensions)?.id !== "go")
|
|
167
|
-
return null;
|
|
168
|
-
const directory = packageDirectoryLookup(index, "go").get(fileIdentityKey(path.dirname(file)));
|
|
169
|
-
if (!directory)
|
|
170
|
-
return null;
|
|
171
|
-
const sourcePackage = readGoPackageName(index, file);
|
|
172
|
-
const candidates = sourcePackage ? (directory.byName.get(sourcePackage) ?? []) : directory.all;
|
|
173
132
|
const matches = [];
|
|
174
|
-
|
|
175
|
-
|
|
133
|
+
const peers = getCompilationUnitPeers(index, file, languageId === "csharp" && qualification !== undefined ? { csharpQualifiedName: true } : undefined);
|
|
134
|
+
for (const peerFile of peers.files) {
|
|
135
|
+
const names = moduleNameLookup(index, peerFile);
|
|
176
136
|
if (!names)
|
|
177
137
|
continue;
|
|
178
138
|
for (const target of names.localExports.get(names.normalizeIdentifier(exportedName)) ?? []) {
|
|
139
|
+
if (target.isMember || !matchesOptions(target, namespace))
|
|
140
|
+
continue;
|
|
141
|
+
if (!isUnitBareNameVisible({
|
|
142
|
+
index,
|
|
143
|
+
declarationFile: target.file,
|
|
144
|
+
declaration: target.range,
|
|
145
|
+
useFile: file,
|
|
146
|
+
...(useIndex !== undefined ? { useIndex } : {}),
|
|
147
|
+
...(qualification !== undefined ? { qualification } : {}),
|
|
148
|
+
})) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
179
151
|
if (!matches.some((candidate) => sameSymbolDef(index, candidate, target))) {
|
|
180
152
|
matches.push(target);
|
|
181
153
|
}
|
|
182
154
|
}
|
|
183
155
|
}
|
|
184
|
-
|
|
156
|
+
const unique = languageId === "csharp" ? coalesceEquivalentCsharpPartialExports(index, matches) : matches;
|
|
157
|
+
return unique.length === 1 ? (unique[0] ?? null) : null;
|
|
185
158
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
195
|
-
cache.set(key, null);
|
|
196
|
-
return null;
|
|
197
|
-
}
|
|
198
|
-
const pattern = languageId === "kotlin" ? KOTLIN_PACKAGE_NAME_PATTERN : JAVA_PACKAGE_NAME_PATTERN;
|
|
199
|
-
const packageName = pattern.exec(source)?.[1] ?? null;
|
|
200
|
-
cache.set(key, packageName);
|
|
201
|
-
return packageName;
|
|
202
|
-
}
|
|
203
|
-
function packageDirectoryLookup(index, languageId) {
|
|
204
|
-
let byLanguage = packageDirectoryLookups.get(index);
|
|
205
|
-
if (!byLanguage) {
|
|
206
|
-
byLanguage = new Map();
|
|
207
|
-
packageDirectoryLookups.set(index, byLanguage);
|
|
208
|
-
}
|
|
209
|
-
const cached = byLanguage.get(languageId);
|
|
210
|
-
if (cached)
|
|
211
|
-
return cached;
|
|
212
|
-
const directories = new Map();
|
|
213
|
-
for (const moduleEntry of index.byFile.values()) {
|
|
214
|
-
const directoryKey = fileIdentityKey(path.dirname(moduleEntry.file));
|
|
215
|
-
let directory = directories.get(directoryKey);
|
|
216
|
-
if (!directory) {
|
|
217
|
-
directory = { all: [], byName: new Map() };
|
|
218
|
-
directories.set(directoryKey, directory);
|
|
219
|
-
}
|
|
220
|
-
directory.all.push(moduleEntry);
|
|
221
|
-
const moduleLanguageId = supportForFileWithoutHeaderSample(moduleEntry.file, index.languageExtensions)?.id;
|
|
222
|
-
if (!moduleLanguageId || !PACKAGE_DECLARING_LANGUAGE_IDS[languageId].has(moduleLanguageId))
|
|
223
|
-
continue;
|
|
224
|
-
const packageName = languageId === "go"
|
|
225
|
-
? readGoPackageName(index, moduleEntry.file)
|
|
226
|
-
: readPackageNameForLanguage(index, moduleEntry.file, languageId);
|
|
227
|
-
if (!packageName)
|
|
228
|
-
continue;
|
|
229
|
-
const entries = directory.byName.get(packageName) ?? [];
|
|
230
|
-
entries.push(moduleEntry);
|
|
231
|
-
directory.byName.set(packageName, entries);
|
|
232
|
-
}
|
|
233
|
-
byLanguage.set(languageId, directories);
|
|
234
|
-
return directories;
|
|
235
|
-
}
|
|
236
|
-
function resolveSiblingPackageExport(index, targetFile, exportedName, languageId) {
|
|
237
|
-
const packageName = readPackageNameForLanguage(index, targetFile, languageId);
|
|
238
|
-
if (!packageName)
|
|
239
|
-
return null;
|
|
240
|
-
const directory = packageDirectoryLookup(index, languageId).get(fileIdentityKey(path.dirname(targetFile)));
|
|
241
|
-
if (!directory)
|
|
159
|
+
/**
|
|
160
|
+
* Same-package Java/Kotlin export that the bare-name unit scan does not answer (a member, for
|
|
161
|
+
* example). Peers come from `getCompilationUnitPeers`, so Java and Kotlin share one package
|
|
162
|
+
* rule. An incomplete set (an unreadable peer, or the same package outside this directory)
|
|
163
|
+
* is not a proven unique answer.
|
|
164
|
+
*/
|
|
165
|
+
function resolveSiblingPackageExport(index, targetFile, exportedName) {
|
|
166
|
+
const peers = getCompilationUnitPeers(index, targetFile);
|
|
167
|
+
if (!peers.complete)
|
|
242
168
|
return null;
|
|
243
169
|
const targetFileKey = fileIdentityKey(targetFile);
|
|
244
170
|
const matches = [];
|
|
245
|
-
for (const
|
|
246
|
-
if (fileIdentityKey(
|
|
171
|
+
for (const peerFile of peers.files) {
|
|
172
|
+
if (fileIdentityKey(peerFile) === targetFileKey)
|
|
247
173
|
continue;
|
|
248
|
-
const hit = resolveExport(index,
|
|
174
|
+
const hit = resolveExport(index, peerFile, exportedName);
|
|
249
175
|
if (hit && !matches.some((candidate) => sameResolvedExport(index, candidate, hit))) {
|
|
250
176
|
matches.push(hit);
|
|
251
177
|
}
|
|
252
178
|
}
|
|
253
179
|
return matches.length === 1 ? (matches[0] ?? null) : null;
|
|
254
180
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
else {
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
catch {
|
|
181
|
+
function declaresMemberKind(def) {
|
|
182
|
+
return def.kind === SymbolKind.Class || def.kind === SymbolKind.Interface || def.kind === SymbolKind.TypeAlias;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* One function from an overload set, or null when the count is not accepted by exactly one.
|
|
186
|
+
* Only indexed `callable.arity` is consulted: a missing arity does not accept, and a count
|
|
187
|
+
* two overloads both accept stays unresolved.
|
|
188
|
+
*/
|
|
189
|
+
function selectFunctionOverloadByArity(candidates, argumentCount) {
|
|
190
|
+
if (candidates.length < 2 || candidates.some((candidate) => candidate.kind !== SymbolKind.Function))
|
|
270
191
|
return null;
|
|
192
|
+
const accepting = candidates.filter((candidate) => {
|
|
193
|
+
const arity = candidate.callable?.arity;
|
|
194
|
+
return !!arity && argumentCount >= arity.minArgs && (arity.maxArgs === null || argumentCount <= arity.maxArgs);
|
|
195
|
+
});
|
|
196
|
+
return accepting.length === 1 ? (accepting[0] ?? null) : null;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* `def` is one function of a Java or Kotlin overload set exported as `exportedName`.
|
|
200
|
+
* A call chooses among them by argument count; the import itself names the whole set, so
|
|
201
|
+
* reference search must still treat the import as able to reach each overload.
|
|
202
|
+
*/
|
|
203
|
+
export function javaKotlinFunctionOverloadIncludes(index, file, exportedName, def) {
|
|
204
|
+
if (def.kind !== SymbolKind.Function)
|
|
205
|
+
return false;
|
|
206
|
+
const languageId = supportForFileWithoutHeaderSample(file, index.languageExtensions)?.id;
|
|
207
|
+
if (languageId !== "java" && languageId !== "kotlin")
|
|
208
|
+
return false;
|
|
209
|
+
const moduleEntry = moduleFor(index, file);
|
|
210
|
+
if (!moduleEntry)
|
|
211
|
+
return false;
|
|
212
|
+
const names = moduleNameLookup(index, moduleEntry.file);
|
|
213
|
+
if (!names)
|
|
214
|
+
return false;
|
|
215
|
+
const exported = names.localExports.get(names.normalizeIdentifier(exportedName)) ?? [];
|
|
216
|
+
if (exported.length < 2 || exported.some((candidate) => candidate.kind !== SymbolKind.Function))
|
|
217
|
+
return false;
|
|
218
|
+
return exported.some((candidate) => sameSymbolDef(index, candidate, def));
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* A default-export wrapper keeps `SymbolKind.Default` so the export name stays `default`.
|
|
222
|
+
* Member lookup needs the class, interface, or type alias that wrapper was copied from.
|
|
223
|
+
*/
|
|
224
|
+
export function memberContainerForDefinition(index, def) {
|
|
225
|
+
if (declaresMemberKind(def))
|
|
226
|
+
return def;
|
|
227
|
+
if (def.kind !== SymbolKind.Default)
|
|
228
|
+
return undefined;
|
|
229
|
+
const moduleEntry = index.byFile.get(fileIdentityKey(def.file));
|
|
230
|
+
if (!moduleEntry)
|
|
231
|
+
return undefined;
|
|
232
|
+
const sameRange = moduleEntry.locals.filter((local) => declaresMemberKind(local) &&
|
|
233
|
+
local.range.start.line === def.range.start.line &&
|
|
234
|
+
local.range.start.column === def.range.start.column);
|
|
235
|
+
if (sameRange.length === 1)
|
|
236
|
+
return sameRange[0];
|
|
237
|
+
}
|
|
238
|
+
/** The export entry that proves a direct CommonJS or TypeScript module value, whatever its public name. */
|
|
239
|
+
export function directModuleValueEntry(moduleEntry) {
|
|
240
|
+
return moduleEntry.exports.find((entry) => entry.type === "local" && (entry.mechanism === "cjs-module-value" || entry.mechanism === "ts-export-assignment"));
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* `require()` and `import x = require()` return a proven direct `module.exports = X` or
|
|
244
|
+
* TypeScript `export = X` value. A default export accompanied by named exports instead returns
|
|
245
|
+
* a namespace object, including non-local and star re-exports.
|
|
246
|
+
*/
|
|
247
|
+
export function cjsRequireValueBinding(index, targetFile) {
|
|
248
|
+
const moduleEntry = index.byFile.get(fileIdentityKey(targetFile));
|
|
249
|
+
const directValue = moduleEntry && directModuleValueEntry(moduleEntry);
|
|
250
|
+
if (directValue)
|
|
251
|
+
return memberContainerForDefinition(index, directValue.target) ?? directValue.target;
|
|
252
|
+
const resolved = resolveExport(index, targetFile, "default");
|
|
253
|
+
if (resolved?.kind !== "resolved")
|
|
254
|
+
return undefined;
|
|
255
|
+
const hasNamedExport = moduleEntry?.exports.some((entry) => {
|
|
256
|
+
if (entry.type === "exportStar")
|
|
257
|
+
return !entry.typeOnly;
|
|
258
|
+
if (entry.type === "local")
|
|
259
|
+
return entry.exportedAs !== "default" && !entry.target.isMember;
|
|
260
|
+
return entry.exportedAs !== "default" && !entry.typeOnly;
|
|
261
|
+
});
|
|
262
|
+
if (hasNamedExport)
|
|
263
|
+
return undefined;
|
|
264
|
+
return memberContainerForDefinition(index, resolved.def) ?? resolved.def;
|
|
265
|
+
}
|
|
266
|
+
const fileEdgeTargetsCache = new WeakMap();
|
|
267
|
+
/** First resolved file target per importer and raw specifier; rebuilt when the edge list changes. */
|
|
268
|
+
function fileEdgeTargetsFor(index) {
|
|
269
|
+
const edges = index.graph.edges;
|
|
270
|
+
const cached = fileEdgeTargetsCache.get(index);
|
|
271
|
+
if (cached && cached.edges === edges && cached.length === edges.length)
|
|
272
|
+
return cached.targets;
|
|
273
|
+
const targets = new Map();
|
|
274
|
+
for (const edge of edges) {
|
|
275
|
+
if (edge.to.type !== "file")
|
|
276
|
+
continue;
|
|
277
|
+
const key = `${fileIdentityKey(edge.from)}\0${edge.raw}`;
|
|
278
|
+
if (!targets.has(key))
|
|
279
|
+
targets.set(key, edge.to.path);
|
|
271
280
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
// The next candidate can still be a real submodule.
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return null;
|
|
281
|
+
fileEdgeTargetsCache.set(index, { edges, length: edges.length, targets });
|
|
282
|
+
return targets;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* A member of the module a `typeof import("spec")` receiver holds, resolved through the file
|
|
286
|
+
* dependency edge the index recorded for that specifier.
|
|
287
|
+
*/
|
|
288
|
+
export function resolveImportTypeMember(index, fromFile, specifier, member) {
|
|
289
|
+
const target = fileEdgeTargetsFor(index).get(`${fileIdentityKey(fromFile)}\0${specifier}`);
|
|
290
|
+
if (!target)
|
|
291
|
+
return null;
|
|
292
|
+
const hit = resolveExport(index, target, member);
|
|
293
|
+
return hit?.kind === "resolved" ? hit.def : null;
|
|
289
294
|
}
|
|
290
295
|
export function resolveExport(index, file, exportedName, opts) {
|
|
291
296
|
const visited = new Set();
|
|
292
|
-
const
|
|
297
|
+
const matchesOptions = (def, namespace) => (!opts?.preferredKind || def.kind === opts.preferredKind) &&
|
|
298
|
+
(namespace === undefined || (def.cTag ? "tag" : "ordinary") === namespace);
|
|
293
299
|
const allowLocalFallback = opts?.allowLocalFallback ?? true;
|
|
294
|
-
function resolveFromFile(fileInner, name) {
|
|
300
|
+
function resolveFromFile(fileInner, name, namespace = opts?.cNamespace) {
|
|
295
301
|
const moduleEntry = moduleFor(index, fileInner);
|
|
296
302
|
if (!moduleEntry)
|
|
297
303
|
return null;
|
|
@@ -299,29 +305,82 @@ export function resolveExport(index, file, exportedName, opts) {
|
|
|
299
305
|
if (!names)
|
|
300
306
|
return null;
|
|
301
307
|
const normalizedFile = normalizePath(moduleEntry.file);
|
|
302
|
-
const
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
308
|
+
const referenceIndex = fileIdentityKey(fileInner) === fileIdentityKey(file) ? opts?.referenceIndex : undefined;
|
|
309
|
+
const languageId = supportForFileWithoutHeaderSample(normalizedFile, index.languageExtensions)?.id;
|
|
310
|
+
const csharpFile = languageId === "csharp";
|
|
311
|
+
// A dotted name is a namespace path even when the caller has no source position
|
|
312
|
+
// (`using PT = N.Inner.Point` resolves through the bound file, not a use site).
|
|
313
|
+
// A bare name still needs a source position before namespace visibility applies.
|
|
314
|
+
const filtersUseNamespace = csharpFile && (referenceIndex !== undefined || name.includes(".") || name.startsWith("global::"));
|
|
315
|
+
const separator = filtersUseNamespace ? name.lastIndexOf(".") : -1;
|
|
316
|
+
let qualification;
|
|
317
|
+
let unqualifiedName = name;
|
|
318
|
+
if (separator >= 0) {
|
|
319
|
+
// `@P.Target` and `P.Target` name the same namespace path.
|
|
320
|
+
qualification = normalizeCsharpQualifiedName(name.slice(0, separator));
|
|
321
|
+
unqualifiedName = name.slice(separator + 1);
|
|
322
|
+
}
|
|
323
|
+
else if (filtersUseNamespace && name.startsWith("global::")) {
|
|
324
|
+
qualification = "global::";
|
|
325
|
+
unqualifiedName = name.slice("global::".length);
|
|
326
|
+
}
|
|
327
|
+
const canonicalName = names.normalizeIdentifier(unqualifiedName);
|
|
328
|
+
const argumentCountKey = opts?.argumentCount === undefined ? "" : String(opts.argumentCount);
|
|
329
|
+
const key = `${cacheKey(normalizedFile, names.normalizeIdentifier(name))}::${opts?.preferredKind ?? ""}::${namespace ?? ""}::${allowLocalFallback ? "local" : "export"}::${referenceIndex ?? ""}::${argumentCountKey}`;
|
|
306
330
|
if (index.exportCache.has(key))
|
|
307
331
|
return index.exportCache.get(key);
|
|
308
|
-
const cycleKey = cacheKey(normalizedFile, canonicalName)
|
|
332
|
+
const cycleKey = `${cacheKey(normalizedFile, canonicalName)}::${namespace ?? ""}`;
|
|
309
333
|
if (visited.has(cycleKey))
|
|
310
334
|
return null;
|
|
311
335
|
visited.add(cycleKey);
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
314
|
-
const result = { kind: "resolved", def:
|
|
336
|
+
const implicitUnitExport = resolveImplicitUnitExport(index, normalizedFile, canonicalName, matchesOptions, namespace, referenceIndex, qualification);
|
|
337
|
+
if (implicitUnitExport) {
|
|
338
|
+
const result = { kind: "resolved", def: implicitUnitExport };
|
|
315
339
|
index.exportCache.set(key, result);
|
|
316
340
|
return result;
|
|
317
341
|
}
|
|
318
342
|
const localCandidates = [];
|
|
319
343
|
for (const target of names.localExports.get(canonicalName) ?? []) {
|
|
320
|
-
if (
|
|
344
|
+
if (matchesOptions(target, namespace) &&
|
|
345
|
+
// Nested types resolve through their owner, not as bare namespace names.
|
|
346
|
+
(!filtersUseNamespace ||
|
|
347
|
+
(!target.isMember &&
|
|
348
|
+
isUnitBareNameVisible({
|
|
349
|
+
index,
|
|
350
|
+
declarationFile: target.file,
|
|
351
|
+
declaration: target.range,
|
|
352
|
+
useFile: file,
|
|
353
|
+
...(referenceIndex !== undefined ? { useIndex: referenceIndex } : {}),
|
|
354
|
+
...(qualification !== undefined ? { qualification } : {}),
|
|
355
|
+
}))) &&
|
|
321
356
|
!localCandidates.some((candidate) => sameSymbolDef(index, candidate, target))) {
|
|
322
357
|
localCandidates.push(target);
|
|
323
358
|
}
|
|
324
359
|
}
|
|
360
|
+
// A bodyless C tag use can introduce an incomplete tag, but must reuse a tag
|
|
361
|
+
// already brought into scope by an include. Do not let that use hide its header.
|
|
362
|
+
if (namespace &&
|
|
363
|
+
(!localCandidates.length ||
|
|
364
|
+
localCandidates.every((candidate) => candidate.cTag === "reference" || candidate.cTag === "forward"))) {
|
|
365
|
+
const included = [];
|
|
366
|
+
for (const imp of moduleEntry.imports) {
|
|
367
|
+
if (typeof imp.resolved !== "string")
|
|
368
|
+
continue;
|
|
369
|
+
if (imp.kind !== "star" && !(imp.kind === "named" && imp.local === name))
|
|
370
|
+
continue;
|
|
371
|
+
if (imp.kind === "named" && (imp.cNamespace ?? "ordinary") !== namespace)
|
|
372
|
+
continue;
|
|
373
|
+
const downstream = resolveFromFile(imp.resolved, imp.kind === "named" ? imp.imported : name, namespace);
|
|
374
|
+
if (downstream && !included.some((candidate) => sameResolvedExport(index, candidate, downstream))) {
|
|
375
|
+
included.push(downstream);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (included.length) {
|
|
379
|
+
const result = included.length === 1 ? included[0] : null;
|
|
380
|
+
index.exportCache.set(key, result);
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
325
384
|
if (localCandidates.length === 1) {
|
|
326
385
|
const target = localCandidates[0];
|
|
327
386
|
const result = { kind: "resolved", def: target };
|
|
@@ -329,6 +388,16 @@ export function resolveExport(index, file, exportedName, opts) {
|
|
|
329
388
|
return result;
|
|
330
389
|
}
|
|
331
390
|
if (localCandidates.length) {
|
|
391
|
+
// Several same-named functions are an overload set, not a failed lookup. Java static
|
|
392
|
+
// imports and Kotlin package imports both land here; arity picks the unique acceptor.
|
|
393
|
+
const selected = opts?.argumentCount !== undefined && (languageId === "java" || languageId === "kotlin")
|
|
394
|
+
? selectFunctionOverloadByArity(localCandidates, opts.argumentCount)
|
|
395
|
+
: null;
|
|
396
|
+
if (selected) {
|
|
397
|
+
const result = { kind: "resolved", def: selected };
|
|
398
|
+
index.exportCache.set(key, result);
|
|
399
|
+
return result;
|
|
400
|
+
}
|
|
332
401
|
index.exportCache.set(key, null);
|
|
333
402
|
return null;
|
|
334
403
|
}
|
|
@@ -348,8 +417,9 @@ export function resolveExport(index, file, exportedName, opts) {
|
|
|
348
417
|
}
|
|
349
418
|
const reexportCandidates = [];
|
|
350
419
|
for (const entry of names.reexports.get(canonicalName) ?? []) {
|
|
351
|
-
const downstream = resolveFromFile(entry.fromModule, entry.sourceSpecifier || canonicalName) ??
|
|
352
|
-
|
|
420
|
+
const downstream = resolveFromFile(entry.fromModule, entry.sourceSpecifier || canonicalName, namespace) ??
|
|
421
|
+
// A qualified using target cannot fall back to an unrelated bare export.
|
|
422
|
+
(entry.sourceSpecifier.includes("::") ? null : resolveFromFile(entry.fromModule, canonicalName, namespace));
|
|
353
423
|
if (downstream && !reexportCandidates.some((candidate) => sameResolvedExport(index, candidate, downstream))) {
|
|
354
424
|
reexportCandidates.push(downstream);
|
|
355
425
|
}
|
|
@@ -367,7 +437,7 @@ export function resolveExport(index, file, exportedName, opts) {
|
|
|
367
437
|
for (const entry of moduleEntry.exports) {
|
|
368
438
|
if (entry.type !== "exportStar")
|
|
369
439
|
continue;
|
|
370
|
-
const downstream = resolveFromFile(entry.fromModule, canonicalName);
|
|
440
|
+
const downstream = resolveFromFile(entry.fromModule, canonicalName, namespace);
|
|
371
441
|
if (downstream && !starCandidates.some((candidate) => sameResolvedExport(index, candidate, downstream))) {
|
|
372
442
|
starCandidates.push(downstream);
|
|
373
443
|
}
|
|
@@ -382,21 +452,44 @@ export function resolveExport(index, file, exportedName, opts) {
|
|
|
382
452
|
return null;
|
|
383
453
|
}
|
|
384
454
|
const localFallbackCandidates = [];
|
|
385
|
-
|
|
455
|
+
// C# lexical bindings have already been checked. Only namespace-level types
|
|
456
|
+
// can remain visible from another region without a shared lexical scope.
|
|
457
|
+
if (allowLocalFallback && (filtersUseNamespace || !shouldSkipVisibilityLocalFallback(index, moduleEntry))) {
|
|
386
458
|
for (const local of names.locals.get(canonicalName) ?? []) {
|
|
387
|
-
if (
|
|
459
|
+
if (filtersUseNamespace &&
|
|
460
|
+
(local.isMember ||
|
|
461
|
+
(local.kind !== SymbolKind.Class &&
|
|
462
|
+
local.kind !== SymbolKind.Interface &&
|
|
463
|
+
local.kind !== SymbolKind.TypeAlias) ||
|
|
464
|
+
!isUnitBareNameVisible({
|
|
465
|
+
index,
|
|
466
|
+
declarationFile: local.file,
|
|
467
|
+
declaration: local.range,
|
|
468
|
+
useFile: file,
|
|
469
|
+
...(referenceIndex !== undefined ? { useIndex: referenceIndex } : {}),
|
|
470
|
+
...(qualification !== undefined ? { qualification } : {}),
|
|
471
|
+
}))) {
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
if (matchesOptions(local, namespace) &&
|
|
388
475
|
!localFallbackCandidates.some((candidate) => sameSymbolDef(index, candidate, local))) {
|
|
389
476
|
localFallbackCandidates.push(local);
|
|
390
477
|
}
|
|
391
478
|
}
|
|
392
479
|
}
|
|
393
|
-
|
|
394
|
-
|
|
480
|
+
// Hidden same-file C# types are omitted from exports, so equivalent internal
|
|
481
|
+
// `partial` parts both land here. Collapse them with the same shared-owner
|
|
482
|
+
// identity used for exported candidates before uniqueness is judged.
|
|
483
|
+
const uniqueLocalFallback = filtersUseNamespace
|
|
484
|
+
? coalesceEquivalentCsharpPartialExports(index, localFallbackCandidates)
|
|
485
|
+
: localFallbackCandidates;
|
|
486
|
+
if (uniqueLocalFallback.length === 1) {
|
|
487
|
+
const local = uniqueLocalFallback[0];
|
|
395
488
|
const result = { kind: "resolved", def: local };
|
|
396
489
|
index.exportCache.set(key, result);
|
|
397
490
|
return result;
|
|
398
491
|
}
|
|
399
|
-
if (
|
|
492
|
+
if (uniqueLocalFallback.length) {
|
|
400
493
|
index.exportCache.set(key, null);
|
|
401
494
|
return null;
|
|
402
495
|
}
|
|
@@ -405,6 +498,63 @@ export function resolveExport(index, file, exportedName, opts) {
|
|
|
405
498
|
}
|
|
406
499
|
return resolveFromFile(file, exportedName);
|
|
407
500
|
}
|
|
501
|
+
function resolvePhpCaseInsensitiveExport(index, targetFile, exportedName, preferredKind) {
|
|
502
|
+
const exactExport = resolveExport(index, targetFile, exportedName, { preferredKind, allowLocalFallback: false });
|
|
503
|
+
if (exactExport)
|
|
504
|
+
return exactExport;
|
|
505
|
+
const moduleEntry = moduleFor(index, targetFile);
|
|
506
|
+
if (!moduleEntry)
|
|
507
|
+
return null;
|
|
508
|
+
const foldedName = foldPhpIdentifierCase(exportedName);
|
|
509
|
+
const resolveUnique = (sourceSpellings, allowLocalFallback) => {
|
|
510
|
+
const matches = [];
|
|
511
|
+
for (const sourceSpelling of sourceSpellings) {
|
|
512
|
+
const hit = resolveExport(index, targetFile, sourceSpelling, { preferredKind, allowLocalFallback });
|
|
513
|
+
if (hit && !matches.some((candidate) => sameResolvedExport(index, candidate, hit))) {
|
|
514
|
+
matches.push(hit);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return matches.length === 1 ? matches[0] : null;
|
|
518
|
+
};
|
|
519
|
+
const exportSpellings = new Set();
|
|
520
|
+
for (const entry of moduleEntry.exports) {
|
|
521
|
+
if (entry.type === "local" &&
|
|
522
|
+
entry.target.kind === preferredKind &&
|
|
523
|
+
foldPhpIdentifierCase(entry.exportedAs) === foldedName) {
|
|
524
|
+
exportSpellings.add(entry.exportedAs);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (exportSpellings.size)
|
|
528
|
+
return resolveUnique(exportSpellings, false);
|
|
529
|
+
const exactLocal = resolveExport(index, targetFile, exportedName, { preferredKind });
|
|
530
|
+
if (exactLocal)
|
|
531
|
+
return exactLocal;
|
|
532
|
+
const localSpellings = new Set();
|
|
533
|
+
for (const local of moduleEntry.locals) {
|
|
534
|
+
if (local.kind === preferredKind && foldPhpIdentifierCase(local.localName) === foldedName) {
|
|
535
|
+
localSpellings.add(local.localName);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return resolveUnique(localSpellings, true);
|
|
539
|
+
}
|
|
540
|
+
/** Resolves a PHP symbol through its separate class, function, or constant import namespace. */
|
|
541
|
+
export function resolvePhpExportByImportType(index, targetFile, exportedName, importType) {
|
|
542
|
+
if (importType === "class") {
|
|
543
|
+
for (const preferredKind of PHP_CLASS_LIKE_KINDS) {
|
|
544
|
+
const hit = resolvePhpCaseInsensitiveExport(index, targetFile, exportedName, preferredKind);
|
|
545
|
+
if (hit)
|
|
546
|
+
return hit;
|
|
547
|
+
}
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
550
|
+
if (importType === "function") {
|
|
551
|
+
return resolvePhpCaseInsensitiveExport(index, targetFile, exportedName, SymbolKind.Function);
|
|
552
|
+
}
|
|
553
|
+
if (importType === "const") {
|
|
554
|
+
return resolveExport(index, targetFile, exportedName, { preferredKind: SymbolKind.Variable });
|
|
555
|
+
}
|
|
556
|
+
return resolveExport(index, targetFile, exportedName);
|
|
557
|
+
}
|
|
408
558
|
function collectExportedNames(index, file, includeLocalFallback, names, visited) {
|
|
409
559
|
const fileKey = fileIdentityKey(file);
|
|
410
560
|
if (visited.has(fileKey))
|
|
@@ -439,41 +589,297 @@ export function resolveModuleExports(index, file, opts) {
|
|
|
439
589
|
}
|
|
440
590
|
return resolved;
|
|
441
591
|
}
|
|
442
|
-
|
|
592
|
+
/**
|
|
593
|
+
* Qualified name a C# using-alias binds. `from` is either the namespace (`N.Inner`
|
|
594
|
+
* for `using PT = N.Inner.Point`) or the full dotted type when an earlier resolver
|
|
595
|
+
* already kept it (`Utils.UtilsClass`). A bare imported name must not be searched on
|
|
596
|
+
* its own: compilation-unit lookup would accept a same-named type in another namespace.
|
|
597
|
+
*/
|
|
598
|
+
function csharpNamedImportLookupName(from, exportedName) {
|
|
599
|
+
if (!exportedName || exportedName.includes(".") || exportedName.startsWith("global::"))
|
|
600
|
+
return exportedName;
|
|
601
|
+
const normalizedFrom = from.trim();
|
|
602
|
+
if (!normalizedFrom)
|
|
603
|
+
return exportedName;
|
|
604
|
+
const parts = normalizedFrom.split(".").filter(Boolean);
|
|
605
|
+
const tail = parts[parts.length - 1];
|
|
606
|
+
if (!tail)
|
|
607
|
+
return exportedName;
|
|
608
|
+
if (normalizeCsharpIdentifier(tail) === normalizeCsharpIdentifier(exportedName))
|
|
609
|
+
return normalizedFrom;
|
|
610
|
+
return `${normalizedFrom}.${exportedName}`;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* The name a C# binding looks up. A named binding qualifies with its alias target. A `using N;`
|
|
614
|
+
* star binding qualifies with `N`: its resolved file is one of the files that declare `N`, and
|
|
615
|
+
* the qualified lookup reaches exactly the types of `N` in every declaring file, not types of
|
|
616
|
+
* other namespaces the bound file also declares.
|
|
617
|
+
*/
|
|
618
|
+
function csharpImportLookupName(imp, exportedName) {
|
|
619
|
+
if (imp.kind === "named")
|
|
620
|
+
return csharpNamedImportLookupName(imp.from, exportedName);
|
|
621
|
+
if (imp.kind !== "star" || imp.staticMembersOf)
|
|
622
|
+
return exportedName;
|
|
623
|
+
if (!exportedName || exportedName.includes(".") || exportedName.startsWith("global::"))
|
|
624
|
+
return exportedName;
|
|
625
|
+
const namespaceName = imp.from.trim();
|
|
626
|
+
return namespaceName ? `${namespaceName}.${exportedName}` : exportedName;
|
|
627
|
+
}
|
|
628
|
+
const csharpNamespaceImportDirectoryFiles = new WeakMap();
|
|
629
|
+
/**
|
|
630
|
+
* For each C# `using N;` binding, one declaring file per directory. The file graph links each
|
|
631
|
+
* directive to every file that declares `N` within the importer's own project, so the set is
|
|
632
|
+
* kept per binding: two importers in different projects never share one. A qualified lookup from
|
|
633
|
+
* one file reaches the rest of its directory, so one file per directory covers every declaration
|
|
634
|
+
* of `N`. Built once per index.
|
|
635
|
+
*/
|
|
636
|
+
function csharpNamespaceImportDirectories(index) {
|
|
637
|
+
const cached = csharpNamespaceImportDirectoryFiles.get(index);
|
|
638
|
+
if (cached)
|
|
639
|
+
return cached;
|
|
640
|
+
const edgesByImporter = new Map();
|
|
641
|
+
for (const edge of index.graph.edges) {
|
|
642
|
+
if (edge.to.type !== "file")
|
|
643
|
+
continue;
|
|
644
|
+
if (supportForFileWithoutHeaderSample(edge.to.path, index.languageExtensions)?.id !== "csharp")
|
|
645
|
+
continue;
|
|
646
|
+
const importerKey = fileIdentityKey(edge.from);
|
|
647
|
+
let byRaw = edgesByImporter.get(importerKey);
|
|
648
|
+
if (!byRaw)
|
|
649
|
+
edgesByImporter.set(importerKey, (byRaw = new Map()));
|
|
650
|
+
const raw = normalizeCsharpQualifiedName(edge.raw);
|
|
651
|
+
let byDirectory = byRaw.get(raw);
|
|
652
|
+
if (!byDirectory)
|
|
653
|
+
byRaw.set(raw, (byDirectory = new Map()));
|
|
654
|
+
const directoryKey = fileIdentityKey(path.posix.dirname(normalizePath(edge.to.path)));
|
|
655
|
+
if (!byDirectory.has(directoryKey))
|
|
656
|
+
byDirectory.set(directoryKey, edge.to.path);
|
|
657
|
+
}
|
|
658
|
+
const result = new Map();
|
|
659
|
+
for (const mod of index.byFile.values()) {
|
|
660
|
+
for (const imp of mod.imports) {
|
|
661
|
+
if (imp.kind !== "star" || imp.staticMembersOf || typeof imp.resolved !== "string")
|
|
662
|
+
continue;
|
|
663
|
+
if (supportForFileWithoutHeaderSample(imp.resolved, index.languageExtensions)?.id !== "csharp")
|
|
664
|
+
continue;
|
|
665
|
+
const files = new Map([
|
|
666
|
+
[fileIdentityKey(path.posix.dirname(normalizePath(imp.resolved))), imp.resolved],
|
|
667
|
+
]);
|
|
668
|
+
const targets = edgesByImporter.get(fileIdentityKey(mod.file))?.get(normalizeCsharpQualifiedName(imp.from));
|
|
669
|
+
for (const [directoryKey, file] of targets ?? [])
|
|
670
|
+
if (!files.has(directoryKey))
|
|
671
|
+
files.set(directoryKey, file);
|
|
672
|
+
result.set(imp, [...files.values()]);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
csharpNamespaceImportDirectoryFiles.set(index, result);
|
|
676
|
+
return result;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* A name imported by C# `using N;`, looked up as `N.Name` from one declaring file per
|
|
680
|
+
* directory. Distinct declarations (other than parts of one partial type) are ambiguous. Only
|
|
681
|
+
* exported types count: local fallback would expose an `internal` type the exports omit, for
|
|
682
|
+
* both the bare name and the qualified `N.Name` form.
|
|
683
|
+
*/
|
|
684
|
+
function resolveCsharpNamespaceImport(index, imp, boundFile, lookupName, opts) {
|
|
685
|
+
// A binding that is not one of the index's own (a copy) falls back to the bound file's directory.
|
|
686
|
+
const files = csharpNamespaceImportDirectories(index).get(imp) ?? [boundFile];
|
|
687
|
+
const matches = [];
|
|
688
|
+
let namespaceHit;
|
|
689
|
+
for (const file of files) {
|
|
690
|
+
const hit = resolveExport(index, file, lookupName, { ...opts, allowLocalFallback: false });
|
|
691
|
+
if (hit?.kind === "namespace")
|
|
692
|
+
namespaceHit ??= hit.file;
|
|
693
|
+
if (hit?.kind !== "resolved" || matches.some((candidate) => sameSymbolDef(index, candidate, hit.def)))
|
|
694
|
+
continue;
|
|
695
|
+
matches.push(hit.def);
|
|
696
|
+
}
|
|
697
|
+
const unique = coalesceEquivalentCsharpPartialExports(index, matches);
|
|
698
|
+
if (unique.length === 1)
|
|
699
|
+
return unique[0];
|
|
700
|
+
if (unique.length)
|
|
701
|
+
return null;
|
|
702
|
+
return namespaceHit ? { namespace: namespaceHit } : null;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* A C# namespace-qualified type name (`N.Type`) used in `mod`. Qualified export lookup from the
|
|
706
|
+
* use file covers its own directory; a `using N;` in the file also reaches every other directory
|
|
707
|
+
* that declares `N`, as the unqualified name does.
|
|
708
|
+
*/
|
|
709
|
+
export function resolveCsharpQualifiedName(index, mod, qualifiedName, referenceIndex) {
|
|
710
|
+
const direct = resolveExport(index, mod.file, qualifiedName, { referenceIndex });
|
|
711
|
+
if (direct)
|
|
712
|
+
return direct;
|
|
713
|
+
const separator = qualifiedName.lastIndexOf(".");
|
|
714
|
+
if (separator <= 0)
|
|
715
|
+
return null;
|
|
716
|
+
const namespaceName = normalizeCsharpQualifiedName(qualifiedName.slice(0, separator)).replace(/^global::/u, "");
|
|
717
|
+
const typeName = qualifiedName.slice(separator + 1);
|
|
718
|
+
for (const imp of mod.imports) {
|
|
719
|
+
if (imp.kind !== "star" || imp.staticMembersOf || typeof imp.resolved !== "string")
|
|
720
|
+
continue;
|
|
721
|
+
if (normalizeCsharpQualifiedName(imp.from).replace(/^global::/u, "") !== namespaceName)
|
|
722
|
+
continue;
|
|
723
|
+
const hit = resolveImported(index, imp, typeName);
|
|
724
|
+
if (!hit)
|
|
725
|
+
return null;
|
|
726
|
+
return "namespace" in hit ? { kind: "namespace", file: hit.namespace } : { kind: "resolved", def: hit };
|
|
727
|
+
}
|
|
728
|
+
return null;
|
|
729
|
+
}
|
|
730
|
+
/** Select from the entire wildcard package before any representative file can win. */
|
|
731
|
+
function resolveJvmPackageExport(index, files, name, argumentCount, importerLanguageId, samePackage) {
|
|
732
|
+
const candidates = [];
|
|
733
|
+
for (const file of files) {
|
|
734
|
+
const targetLanguage = supportForFileWithoutHeaderSample(file, index.languageExtensions)?.id;
|
|
735
|
+
if (targetLanguage !== "java" && targetLanguage !== "kotlin")
|
|
736
|
+
continue;
|
|
737
|
+
const names = moduleNameLookup(index, file);
|
|
738
|
+
if (!names)
|
|
739
|
+
continue;
|
|
740
|
+
for (const target of names.localExports.get(names.normalizeIdentifier(name)) ?? []) {
|
|
741
|
+
if (target.isMember ||
|
|
742
|
+
!isJvmPackageSymbolVisible(target, targetLanguage, importerLanguageId ?? targetLanguage, !!samePackage) ||
|
|
743
|
+
candidates.some((candidate) => sameSymbolDef(index, candidate, target)))
|
|
744
|
+
continue;
|
|
745
|
+
candidates.push(target);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (candidates.length === 1)
|
|
749
|
+
return candidates[0];
|
|
750
|
+
return argumentCount === undefined ? null : selectFunctionOverloadByArity(candidates, argumentCount);
|
|
751
|
+
}
|
|
752
|
+
/** Whether a Java named static import can expose this exact direct member. */
|
|
753
|
+
export function javaStaticNamedImportIncludes(index, imp, def) {
|
|
754
|
+
if (imp.kind !== "named" || !imp.jvmStaticWildcardName)
|
|
755
|
+
return false;
|
|
756
|
+
const targetFile = typeof imp.resolved === "string" ? imp.resolved : undefined;
|
|
757
|
+
if (!targetFile || fileIdentityKey(targetFile) !== fileIdentityKey(def.file))
|
|
758
|
+
return false;
|
|
759
|
+
const target = moduleFor(index, targetFile);
|
|
760
|
+
if (!target)
|
|
761
|
+
return false;
|
|
762
|
+
const owner = jvmWildcardTypeOwner(target, imp.jvmStaticWildcardName, "java");
|
|
763
|
+
if (!owner || owner.range.start.index === undefined || (owner.javaPackagePrivate && !imp.jvmSamePackage))
|
|
764
|
+
return false;
|
|
765
|
+
if (!isJvmStaticWildcardMember(def, owner.range.start.index) || (def.javaPackagePrivate && !imp.jvmSamePackage))
|
|
766
|
+
return false;
|
|
767
|
+
const names = moduleNameLookup(index, targetFile);
|
|
768
|
+
if (!names || names.normalizeIdentifier(imp.imported) !== names.normalizeIdentifier(def.localName))
|
|
769
|
+
return false;
|
|
770
|
+
return (names.localExports
|
|
771
|
+
.get(names.normalizeIdentifier(imp.imported))
|
|
772
|
+
?.some((candidate) => sameSymbolDef(index, candidate, def)) ?? false);
|
|
773
|
+
}
|
|
774
|
+
export function resolveImported(index, imp, exportedName, opts) {
|
|
443
775
|
const targetFile = typeof imp.resolved === "string" ? imp.resolved : undefined;
|
|
444
776
|
if (!targetFile)
|
|
445
777
|
return null;
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
778
|
+
if (imp.kind === "star" && imp.jvmPackageFiles) {
|
|
779
|
+
return resolveJvmPackageExport(index, imp.jvmPackageFiles, exportedName, opts?.argumentCount, imp.jvmPackageLanguageId, imp.jvmSamePackage);
|
|
780
|
+
}
|
|
781
|
+
if ((imp.kind === "star" && (imp.jvmTypeWildcardName || imp.jvmStaticWildcardName)) ||
|
|
782
|
+
(imp.kind === "named" && (imp.jvmTypeOwnerStartIndex !== undefined || imp.jvmStaticWildcardName !== undefined))) {
|
|
783
|
+
const target = moduleFor(index, targetFile);
|
|
784
|
+
if (!target)
|
|
785
|
+
return null;
|
|
786
|
+
const targetLanguageId = supportForFileWithoutHeaderSample(targetFile, index.languageExtensions)?.id;
|
|
787
|
+
let ownerStartIndex;
|
|
788
|
+
if (imp.kind === "star" || imp.jvmTypeOwnerStartIndex === undefined) {
|
|
789
|
+
const ownerName = imp.kind === "star" ? (imp.jvmTypeWildcardName ?? imp.jvmStaticWildcardName) : imp.jvmStaticWildcardName;
|
|
790
|
+
const owner = ownerName && jvmWildcardTypeOwner(target, ownerName, targetLanguageId);
|
|
791
|
+
if (!owner || (owner.javaPackagePrivate && !imp.jvmSamePackage))
|
|
792
|
+
return null;
|
|
793
|
+
ownerStartIndex = owner.range.start.index;
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
ownerStartIndex = imp.jvmTypeOwnerStartIndex;
|
|
450
797
|
}
|
|
451
|
-
|
|
452
|
-
|
|
798
|
+
if (ownerStartIndex === undefined)
|
|
799
|
+
return null;
|
|
800
|
+
const names = moduleNameLookup(index, targetFile);
|
|
801
|
+
if (!names)
|
|
802
|
+
return null;
|
|
803
|
+
let match;
|
|
804
|
+
let overloads;
|
|
805
|
+
for (const candidate of names.localExports.get(names.normalizeIdentifier(exportedName)) ?? []) {
|
|
806
|
+
if ((imp.jvmStaticWildcardName
|
|
807
|
+
? !isJvmStaticWildcardMember(candidate, ownerStartIndex)
|
|
808
|
+
: !isJvmTypeWildcardMember(candidate, ownerStartIndex, targetLanguageId)) ||
|
|
809
|
+
(candidate.javaPackagePrivate && !imp.jvmSamePackage))
|
|
810
|
+
continue;
|
|
811
|
+
if (match && !sameSymbolDef(index, candidate, match)) {
|
|
812
|
+
if (imp.kind !== "named" || !imp.jvmStaticWildcardName || opts?.argumentCount === undefined)
|
|
813
|
+
return null;
|
|
814
|
+
if (!overloads)
|
|
815
|
+
overloads = [match];
|
|
816
|
+
overloads.push(candidate);
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
match = candidate;
|
|
820
|
+
}
|
|
453
821
|
}
|
|
454
|
-
|
|
455
|
-
|
|
822
|
+
if (overloads && opts?.argumentCount !== undefined)
|
|
823
|
+
return selectFunctionOverloadByArity(overloads, opts.argumentCount);
|
|
824
|
+
if (match && imp.kind === "named" && imp.jvmStaticWildcardName && opts?.argumentCount !== undefined) {
|
|
825
|
+
const arity = match.callable?.arity;
|
|
826
|
+
if (arity &&
|
|
827
|
+
(opts.argumentCount < arity.minArgs || (arity.maxArgs !== null && opts.argumentCount > arity.maxArgs)))
|
|
828
|
+
return null;
|
|
456
829
|
}
|
|
830
|
+
return match ?? null;
|
|
457
831
|
}
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
832
|
+
const namespace = opts?.cNamespace ?? (imp.kind === "named" ? imp.cNamespace : undefined);
|
|
833
|
+
if (opts?.cNamespace && imp.kind === "named" && (imp.cNamespace ?? "ordinary") !== opts.cNamespace)
|
|
834
|
+
return null;
|
|
835
|
+
const phpRole = phpNamedImportRole(imp);
|
|
836
|
+
// A C# `using PT = N.Inner.Point` stores the namespace in `from` and the type in
|
|
837
|
+
// `imported`. A bare `Point` lookup is an implicit compilation-unit search, so a peer
|
|
838
|
+
// `N.Point` is the only bare-visible match when this file also declares outer `N`.
|
|
839
|
+
// The alias names one namespace, and that qualified name is what every consumer resolves.
|
|
840
|
+
const support = supportForFileWithoutHeaderSample(targetFile, index.languageExtensions);
|
|
841
|
+
const lookupName = support?.id === "csharp" ? csharpImportLookupName(imp, exportedName) : exportedName;
|
|
842
|
+
if (support?.id === "csharp" && imp.kind === "star" && !imp.staticMembersOf) {
|
|
843
|
+
return resolveCsharpNamespaceImport(index, imp, targetFile, lookupName, {
|
|
844
|
+
...opts,
|
|
845
|
+
...(namespace ? { cNamespace: namespace } : {}),
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
const hit = phpRole
|
|
849
|
+
? resolvePhpExportByImportType(index, targetFile, exportedName, phpRole)
|
|
850
|
+
: resolveExport(index, targetFile, lookupName, {
|
|
851
|
+
...opts,
|
|
852
|
+
...(namespace ? { cNamespace: namespace } : {}),
|
|
853
|
+
});
|
|
854
|
+
if (hit?.kind === "resolved") {
|
|
855
|
+
if (imp.kind === "named" && hit.def.javaPackagePrivate && !imp.jvmSamePackage)
|
|
856
|
+
return null;
|
|
462
857
|
return hit.def;
|
|
858
|
+
}
|
|
463
859
|
if (hit?.kind === "namespace")
|
|
464
860
|
return { namespace: hit.file };
|
|
861
|
+
if (imp.kind === "default" && exportedName === "default") {
|
|
862
|
+
const moduleEntry = moduleFor(index, targetFile);
|
|
863
|
+
const directValue = moduleEntry && directModuleValueEntry(moduleEntry);
|
|
864
|
+
if (directValue)
|
|
865
|
+
return directValue.target;
|
|
866
|
+
}
|
|
465
867
|
// Only Java, Kotlin, and Python matter below, so a `.h` target never needs its sample read.
|
|
466
|
-
const support = supportForFileWithoutHeaderSample(targetFile, index.languageExtensions);
|
|
467
868
|
if (support?.id === "java" || support?.id === "kotlin") {
|
|
468
|
-
const siblingHit = resolveSiblingPackageExport(index, targetFile, exportedName
|
|
469
|
-
if (siblingHit?.kind === "resolved")
|
|
869
|
+
const siblingHit = resolveSiblingPackageExport(index, targetFile, exportedName);
|
|
870
|
+
if (siblingHit?.kind === "resolved") {
|
|
871
|
+
if (imp.kind === "named" && siblingHit.def.javaPackagePrivate && !imp.jvmSamePackage)
|
|
872
|
+
return null;
|
|
470
873
|
return siblingHit.def;
|
|
874
|
+
}
|
|
471
875
|
if (siblingHit?.kind === "namespace") {
|
|
472
876
|
return { namespace: siblingHit.file };
|
|
473
877
|
}
|
|
474
878
|
}
|
|
475
|
-
|
|
476
|
-
|
|
879
|
+
// A named `from pkg import child` may load child as a submodule. A plain
|
|
880
|
+
// namespace import of pkg cannot gain child solely because child.py exists.
|
|
881
|
+
if (support?.id === "python" && imp.kind === "named" && imp.mechanism === "python") {
|
|
882
|
+
const submodule = resolvePythonSubmoduleExact(targetFile, exportedName);
|
|
477
883
|
if (submodule)
|
|
478
884
|
return { namespace: submodule };
|
|
479
885
|
}
|