@lzehrung/codegraph 2.3.31 → 2.4.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 +30 -137
- package/codegraph-skill/codegraph/SKILL.md +5 -3
- 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/search.d.ts.map +1 -1
- package/dist/agent/search.js +3 -0
- package/dist/agent/search.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/bin/cli.js +42243 -29202
- package/dist/bin/query-index-worker.js +73 -11
- 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/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/help.d.ts +2 -2
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +4 -2
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/options.js +2 -2
- package/dist/cli/options.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/snapshot.d.ts.map +1 -1
- package/dist/drift/snapshot.js +5 -6
- package/dist/drift/snapshot.js.map +1 -1
- package/dist/drift/types.d.ts +2 -0
- package/dist/drift/types.d.ts.map +1 -1
- package/dist/drift/types.js.map +1 -1
- package/dist/graph-builder.d.ts.map +1 -1
- package/dist/graph-builder.js +4 -6
- package/dist/graph-builder.js.map +1 -1
- package/dist/graph-edge-collector.d.ts +3 -0
- package/dist/graph-edge-collector.d.ts.map +1 -1
- package/dist/graph-edge-collector.js +8 -5
- 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 +26 -2
- package/dist/graphs/edge-resolution.js.map +1 -1
- package/dist/graphs/specifiers.d.ts.map +1 -1
- package/dist/graphs/specifiers.js +6 -2
- 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 +51 -8
- package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/edge-passes.js +823 -132
- 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 +139 -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 +128 -15
- package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/receiver-calls.js +873 -93
- 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 +434 -40
- 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/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 +310 -516
- 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 +1 -1
- 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 +38 -0
- package/dist/indexer/build-cache/module-cache.d.ts.map +1 -1
- package/dist/indexer/build-cache/module-cache.js +151 -9
- package/dist/indexer/build-cache/module-cache.js.map +1 -1
- package/dist/indexer/build-cache/options.d.ts +16 -43
- package/dist/indexer/build-cache/options.d.ts.map +1 -1
- package/dist/indexer/build-cache/options.js +16 -43
- package/dist/indexer/build-cache/options.js.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.d.ts +1 -0
- package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.js +117 -24
- package/dist/indexer/build-cache/project-snapshot.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 +1 -1
- package/dist/indexer/build-cache.d.ts.map +1 -1
- package/dist/indexer/build-cache.js +1 -1
- 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 +593 -22
- package/dist/indexer/build-index.js.map +1 -1
- package/dist/indexer/call-hierarchy.js +1 -1
- package/dist/indexer/call-hierarchy.js.map +1 -1
- package/dist/indexer/compilation-units.d.ts +101 -0
- package/dist/indexer/compilation-units.d.ts.map +1 -0
- package/dist/indexer/compilation-units.js +605 -0
- package/dist/indexer/compilation-units.js.map +1 -0
- package/dist/indexer/cpp-callables.d.ts +20 -0
- package/dist/indexer/cpp-callables.d.ts.map +1 -0
- package/dist/indexer/cpp-callables.js +554 -0
- package/dist/indexer/cpp-callables.js.map +1 -0
- package/dist/indexer/declaration-visibility.d.ts +36 -2
- package/dist/indexer/declaration-visibility.d.ts.map +1 -1
- package/dist/indexer/declaration-visibility.js +136 -2
- package/dist/indexer/declaration-visibility.js.map +1 -1
- package/dist/indexer/expand-star-imports.d.ts.map +1 -1
- package/dist/indexer/expand-star-imports.js +28 -6
- package/dist/indexer/expand-star-imports.js.map +1 -1
- package/dist/indexer/import-types.d.ts +37 -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 +11 -1
- package/dist/indexer/imports/context.d.ts.map +1 -1
- package/dist/indexer/imports/import-binding-tables.d.ts +12 -1
- package/dist/indexer/imports/import-binding-tables.d.ts.map +1 -1
- package/dist/indexer/imports/import-binding-tables.js +144 -19
- 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 +18 -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 +91 -40
- 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 +51 -12
- package/dist/indexer/imports/text-import-extractors.js.map +1 -1
- package/dist/indexer/imports.d.ts.map +1 -1
- package/dist/indexer/imports.js +23 -4
- 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 +187 -1
- package/dist/indexer/incremental-plan.js.map +1 -1
- package/dist/indexer/locals-and-exports.d.ts +2 -0
- package/dist/indexer/locals-and-exports.d.ts.map +1 -1
- package/dist/indexer/locals-and-exports.js +565 -54
- package/dist/indexer/locals-and-exports.js.map +1 -1
- 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 +117 -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 +113 -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 +106 -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 +75 -0
- package/dist/indexer/name-lookup-policies/php.js.map +1 -0
- package/dist/indexer/name-resolution-types.d.ts +99 -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 +52 -0
- package/dist/indexer/name-resolution.d.ts.map +1 -0
- package/dist/indexer/name-resolution.js +189 -0
- package/dist/indexer/name-resolution.js.map +1 -0
- package/dist/indexer/navigation-cpp.d.ts +50 -0
- package/dist/indexer/navigation-cpp.d.ts.map +1 -0
- package/dist/indexer/navigation-cpp.js +654 -0
- package/dist/indexer/navigation-cpp.js.map +1 -0
- package/dist/indexer/navigation-goto.d.ts +106 -3
- package/dist/indexer/navigation-goto.d.ts.map +1 -1
- package/dist/indexer/navigation-goto.js +2074 -137
- package/dist/indexer/navigation-goto.js.map +1 -1
- package/dist/indexer/navigation-local.d.ts +18 -2
- package/dist/indexer/navigation-local.d.ts.map +1 -1
- package/dist/indexer/navigation-local.js +498 -61
- 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-references.d.ts +72 -5
- package/dist/indexer/navigation-references.d.ts.map +1 -1
- package/dist/indexer/navigation-references.js +620 -54
- package/dist/indexer/navigation-references.js.map +1 -1
- package/dist/indexer/navigation-resolve.d.ts +33 -2
- package/dist/indexer/navigation-resolve.d.ts.map +1 -1
- package/dist/indexer/navigation-resolve.js +446 -193
- package/dist/indexer/navigation-resolve.js.map +1 -1
- package/dist/indexer/navigation.d.ts +28 -2
- package/dist/indexer/navigation.d.ts.map +1 -1
- package/dist/indexer/navigation.js +1082 -151
- package/dist/indexer/navigation.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-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 +25 -1
- package/dist/indexer/scope-types.d.ts.map +1 -1
- package/dist/indexer/scope.d.ts.map +1 -1
- package/dist/indexer/scope.js +894 -45
- 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 +114 -0
- package/dist/indexer/star-import-precedence.d.ts.map +1 -0
- package/dist/indexer/star-import-precedence.js +396 -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 +51 -0
- package/dist/indexer/ts-callables.d.ts.map +1 -0
- package/dist/indexer/ts-callables.js +264 -0
- package/dist/indexer/ts-callables.js.map +1 -0
- package/dist/indexer/types.d.ts +23 -1
- 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 +2 -2
- 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 +202 -0
- package/dist/languages/callable-arity.d.ts.map +1 -0
- package/dist/languages/callable-arity.js +1182 -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 +2 -0
- package/dist/languages/definitions/zig.js.map +1 -1
- package/dist/mcp/handlers.js +14 -7
- package/dist/mcp/handlers.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 +1 -0
- package/dist/review.js.map +1 -1
- package/dist/sql/navigation.d.ts.map +1 -1
- package/dist/sql/navigation.js +1 -0
- 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 +7 -1
- package/dist/util/bloom-filter.d.ts.map +1 -1
- package/dist/util/bloom-filter.js +12 -2
- package/dist/util/bloom-filter.js.map +1 -1
- 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 +137 -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 +95 -3
- package/dist/util/member-access.js.map +1 -1
- 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/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.map +1 -1
- package/dist/util/resolution/rust.js +95 -26
- package/dist/util/resolution/rust.js.map +1 -1
- 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 +96 -5
- package/dist/util/resolution.js.map +1 -1
- package/dist/util/specifiers.d.ts +20 -0
- package/dist/util/specifiers.d.ts.map +1 -1
- package/dist/util/specifiers.js +29 -0
- package/dist/util/specifiers.js.map +1 -1
- package/docs/mcp.md +3 -2
- package/package.json +3 -3
- 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,17 +1,38 @@
|
|
|
1
|
+
import { cTagRole } from "../languages/definitions/c.js";
|
|
1
2
|
import { isGraphOnlyLanguage } from "../document-links.js";
|
|
2
3
|
import { capturesByName, capturesNamed, rangeFromNativeCapture } from "../native/query-results.js";
|
|
3
4
|
import { buildByteToStringIndexMap } from "../native/byte-index.js";
|
|
4
5
|
import { ProjectedSyntaxTree } from "../native/projected-tree.js";
|
|
5
6
|
import { assertNativeRequiredAvailable, getNativeSyntaxTreeExecution, isNativeRequiredUnavailableError, } from "../native/tree-sitter-native.js";
|
|
6
|
-
import { maskJsLikeCommentsAndStrings } from "../util/comments.js";
|
|
7
|
+
import { maskJsLikeCommentsAndStrings, maskJsLikeCommentsStringsAndRegex } from "../util/comments.js";
|
|
7
8
|
import { sliceText, toRange, unquote } from "../util/ast.js";
|
|
8
9
|
import { bindingKindToSymbolKind } from "./declarations.js";
|
|
9
10
|
import { buildScopeIndexFromSource } from "./scope.js";
|
|
11
|
+
import { findClosestScopeBinding } from "./navigation-local.js";
|
|
10
12
|
import { SymbolKind } from "./types.js";
|
|
11
13
|
import { isPythonInstanceAttributeDeclaration } from "../languages/definitions/python.js";
|
|
14
|
+
import { phpConstructorPromotedVariable, phpPropertyPromotionParameter } from "./navigation-php.js";
|
|
12
15
|
import { importCapture } from "../languages/graph-captures.js";
|
|
13
16
|
import { ECMASCRIPT_IDENTIFIER_SOURCE, XID_IDENTIFIER_SOURCE } from "../util/identifiers.js";
|
|
14
17
|
import { isExportedDeclaration } from "./declaration-visibility.js";
|
|
18
|
+
import { cppQualifiedNameSegments } from "../graphs/symbol-graph-detailed/receiver-calls.js";
|
|
19
|
+
import { cppCallableIsDefinition, cppCallableShapeForNode } from "./cpp-callables.js";
|
|
20
|
+
import { typescriptCollapsedOverloadTarget, typescriptCallableContainerKey, typescriptCallableRoleAt, } from "./ts-callables.js";
|
|
21
|
+
// Missing captured comments prove missing documentation only for these languages.
|
|
22
|
+
// Python captures # comments but not triple-quoted function/class docstrings.
|
|
23
|
+
/** Languages whose parsers capture docstrings onto local definitions. */
|
|
24
|
+
export const DOCSTRING_CAPTURE_LANGUAGES = new Set([
|
|
25
|
+
"ts",
|
|
26
|
+
"tsx",
|
|
27
|
+
"js",
|
|
28
|
+
"go",
|
|
29
|
+
"java",
|
|
30
|
+
"csharp",
|
|
31
|
+
"kotlin",
|
|
32
|
+
"rust",
|
|
33
|
+
"zig",
|
|
34
|
+
"scss",
|
|
35
|
+
]);
|
|
15
36
|
/**
|
|
16
37
|
* Matches one `exportScopeBlockers` entry against an ancestor node. A plain entry compares the
|
|
17
38
|
* node type; a `parent>node` entry also requires that parent type, which is how Python separates a
|
|
@@ -30,6 +51,9 @@ const JS_FALLBACK_REEXPORT_SPECIFIER_PATTERN = new RegExp(String.raw `^(?:type\s
|
|
|
30
51
|
const JS_FALLBACK_REEXPORT_TYPE_SPECIFIER_PATTERN = new RegExp(String.raw `^type\s+(${ECMASCRIPT_IDENTIFIER_SOURCE})(?:\s+as\s+(${ECMASCRIPT_IDENTIFIER_SOURCE}))?$`, "u");
|
|
31
52
|
const JS_FALLBACK_REEXPORT_NAMESPACE_PATTERN = new RegExp(String.raw `\bexport\s*\*\s+as\s+(${ECMASCRIPT_IDENTIFIER_SOURCE})\s+from\s*("|')([^"']*)\2`, "gu");
|
|
32
53
|
const JS_FALLBACK_CJS_FUNCTION_PATTERN = new RegExp(String.raw `(?:^|[;\n\r])\s*(?:exports|module\.exports)\.(${ECMASCRIPT_IDENTIFIER_SOURCE})\s*=\s*(function\b|\([^)]*\)\s*=>)`, "gu");
|
|
54
|
+
const JS_FALLBACK_CJS_MODULE_FUNCTION_PATTERN = new RegExp(String.raw `(?:^|[;\n\r])\s*module\.exports\s*=\s*(?:async\s+)?(?:function\b\s*\*?\s*(${ECMASCRIPT_IDENTIFIER_SOURCE})?\s*\(|\([^)]*\)\s*=>|${ECMASCRIPT_IDENTIFIER_SOURCE}\s*=>)`, "gu");
|
|
55
|
+
const JS_FALLBACK_CJS_MODULE_IDENTIFIER_PATTERN = new RegExp(String.raw `(?:^|[;\n\r])\s*module\.exports\s*=\s*(${ECMASCRIPT_IDENTIFIER_SOURCE})(?![$_\p{ID_Continue}\u200c\u200d])(?=\s*(?:;|$|\r|\n))`, "gu");
|
|
56
|
+
const JS_FALLBACK_TOP_LEVEL_LOCAL_PATTERN = new RegExp(String.raw `(?:^|[;{}\n\r])\s*(?:export\s+)?(?:default\s+)?(?:declare\s+)?((?:abstract\s+)?class|(?:async\s+)?function|const|let|var)\s+(${ECMASCRIPT_IDENTIFIER_SOURCE})(?![$_\p{ID_Continue}\u200c\u200d])`, "gu");
|
|
33
57
|
const JS_FALLBACK_CJS_OBJECT_FUNCTION_PATTERN = new RegExp(String.raw `(${ECMASCRIPT_IDENTIFIER_SOURCE})\s*:\s*(function\b|\([^)]*\)\s*=>)`, "gu");
|
|
34
58
|
const JS_DEFAULT_FUNCTION_PATTERN = new RegExp(String.raw `\bexport\s+default\s+(?:async\s+)?function\b\s*\*?\s*(${ECMASCRIPT_IDENTIFIER_SOURCE})`, "u");
|
|
35
59
|
const JS_DEFAULT_CLASS_PATTERN = new RegExp(String.raw `\bexport\s+default\s+(?:abstract\s+)?class\s+(${ECMASCRIPT_IDENTIFIER_SOURCE})`, "u");
|
|
@@ -57,12 +81,21 @@ const MEMBER_CONTAINER_NODE_TYPES = {
|
|
|
57
81
|
class_declaration: true,
|
|
58
82
|
abstract_class_declaration: true,
|
|
59
83
|
class_definition: true,
|
|
84
|
+
class_specifier: true,
|
|
85
|
+
struct_specifier: true,
|
|
86
|
+
union_specifier: true,
|
|
60
87
|
class: true,
|
|
61
88
|
interface_declaration: true,
|
|
62
89
|
impl_item: true,
|
|
63
90
|
trait_item: true,
|
|
64
91
|
enum_declaration: true,
|
|
65
92
|
enum_item: true,
|
|
93
|
+
// Zig has no implicit member scope of its own; a function nested in one of these container
|
|
94
|
+
// forms is a method, matching the receiver-call detection in receiver-calls.ts's
|
|
95
|
+
// MEMBER_CONTAINER_TYPES, which already lists all three.
|
|
96
|
+
struct_declaration: true,
|
|
97
|
+
union_declaration: true,
|
|
98
|
+
opaque_declaration: true,
|
|
66
99
|
};
|
|
67
100
|
const CALLABLE_DECLARATION_NODE_TYPES = {
|
|
68
101
|
function_declaration: true,
|
|
@@ -77,6 +110,8 @@ const CALLABLE_DECLARATION_NODE_TYPES = {
|
|
|
77
110
|
function isTypeMemberDeclaration(node) {
|
|
78
111
|
if (isPythonInstanceAttributeDeclaration(node))
|
|
79
112
|
return true;
|
|
113
|
+
if (phpConstructorPromotedVariable(node))
|
|
114
|
+
return true;
|
|
80
115
|
let current = node.parent?.parent ?? null;
|
|
81
116
|
while (current) {
|
|
82
117
|
if (MEMBER_CONTAINER_NODE_TYPES[current.type])
|
|
@@ -87,6 +122,104 @@ function isTypeMemberDeclaration(node) {
|
|
|
87
122
|
}
|
|
88
123
|
return false;
|
|
89
124
|
}
|
|
125
|
+
function cppQualifiedExportName(nameNode, source, name, omitInlineNamespaces = false) {
|
|
126
|
+
const namespaceSegments = [];
|
|
127
|
+
let qualifiedSegments = null;
|
|
128
|
+
let current = nameNode;
|
|
129
|
+
while (current) {
|
|
130
|
+
if (!qualifiedSegments && current.type === "qualified_identifier") {
|
|
131
|
+
// `a::C::run` nests `C::run` inside `a::(...)`; the outermost node carries the full path.
|
|
132
|
+
while (current.parent?.type === "qualified_identifier")
|
|
133
|
+
current = current.parent;
|
|
134
|
+
if (current.parent?.type !== "using_declaration") {
|
|
135
|
+
const segments = cppQualifiedNameSegments(current, source);
|
|
136
|
+
if (segments.length > 1)
|
|
137
|
+
qualifiedSegments = segments;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (current.type === "namespace_definition") {
|
|
141
|
+
const namespaceName = current.childForFieldName("name");
|
|
142
|
+
if (!namespaceName) {
|
|
143
|
+
current = current.parent;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const declaresNamespaceSegment = namespaceName.startIndex <= nameNode.startIndex && namespaceName.endIndex >= nameNode.endIndex;
|
|
147
|
+
if (declaresNamespaceSegment) {
|
|
148
|
+
qualifiedSegments =
|
|
149
|
+
namespaceName.type === "nested_namespace_specifier"
|
|
150
|
+
? namespaceName.namedChildren
|
|
151
|
+
.filter((child) => child.type === "namespace_identifier" && child.endIndex <= nameNode.endIndex)
|
|
152
|
+
.map((child) => sliceText(child, source))
|
|
153
|
+
: [name];
|
|
154
|
+
}
|
|
155
|
+
else if (!omitInlineNamespaces || current.child(0)?.type !== "inline") {
|
|
156
|
+
namespaceSegments.unshift(cppQualifiedNameSegments(namespaceName, source));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
current = current.parent;
|
|
160
|
+
}
|
|
161
|
+
return [...namespaceSegments.flat(), ...(qualifiedSegments ?? [name])].join("::");
|
|
162
|
+
}
|
|
163
|
+
const RUBY_CONTAINER_TYPES = new Set(["class", "module"]);
|
|
164
|
+
/** Whether `container`'s own body (not a nested class or module) declares `name`. */
|
|
165
|
+
function rubyContainerDeclares(container, name, source) {
|
|
166
|
+
const visit = (node) => {
|
|
167
|
+
for (const child of node.namedChildren) {
|
|
168
|
+
if (RUBY_CONTAINER_TYPES.has(child.type)) {
|
|
169
|
+
const childName = child.childForFieldName("name");
|
|
170
|
+
if (childName && sliceText(childName, source) === name)
|
|
171
|
+
return true;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (visit(child))
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
};
|
|
179
|
+
return visit(container);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Nested Ruby constants are not top-level names. `module Outer; class Base`
|
|
183
|
+
* exports as `Outer::Base`, so a `require` cannot bind bare `Base`. A `scope_resolution`
|
|
184
|
+
* name (`class Inner::Tool`) looks up its first segment lexically, as Ruby does: the
|
|
185
|
+
* innermost enclosing class or module that declares `Inner` in this file supplies the
|
|
186
|
+
* prefix (`Outer::Inner::Tool`); otherwise the path is top-level. A leading `::` is absolute.
|
|
187
|
+
*/
|
|
188
|
+
function rubyQualifiedExportName(nameNode, source, name) {
|
|
189
|
+
if (name.startsWith("::"))
|
|
190
|
+
return name.slice(2);
|
|
191
|
+
const containers = [];
|
|
192
|
+
for (let current = nameNode.parent; current; current = current.parent) {
|
|
193
|
+
if (!RUBY_CONTAINER_TYPES.has(current.type))
|
|
194
|
+
continue;
|
|
195
|
+
const containerName = current.childForFieldName("name");
|
|
196
|
+
if (!containerName)
|
|
197
|
+
continue;
|
|
198
|
+
const ownsExport = containerName.startIndex <= nameNode.startIndex && containerName.endIndex >= nameNode.endIndex;
|
|
199
|
+
if (ownsExport)
|
|
200
|
+
continue;
|
|
201
|
+
const text = sliceText(containerName, source);
|
|
202
|
+
if (text)
|
|
203
|
+
containers.push({ node: current, text });
|
|
204
|
+
}
|
|
205
|
+
// `containers` is innermost first. A plain constant is owned by the innermost container; a
|
|
206
|
+
// scope-resolution name by the innermost container that declares its first segment.
|
|
207
|
+
let ownerIndex = 0;
|
|
208
|
+
if (nameNode.type === "scope_resolution") {
|
|
209
|
+
const firstSegment = name.split("::")[0] ?? name;
|
|
210
|
+
ownerIndex = containers.findIndex((container) => rubyContainerDeclares(container.node, firstSegment, source));
|
|
211
|
+
if (ownerIndex < 0)
|
|
212
|
+
return name;
|
|
213
|
+
}
|
|
214
|
+
else if (nameNode.type !== "constant") {
|
|
215
|
+
return name;
|
|
216
|
+
}
|
|
217
|
+
const prefix = containers
|
|
218
|
+
.slice(ownerIndex)
|
|
219
|
+
.reverse()
|
|
220
|
+
.map((container) => container.text);
|
|
221
|
+
return prefix.length ? `${prefix.join("::")}::${name}` : name;
|
|
222
|
+
}
|
|
90
223
|
const C_DECLARATOR_IDENTIFIER_PATTERN = new RegExp(`^${XID_IDENTIFIER_SOURCE}`, "u");
|
|
91
224
|
const C_DECLARATOR_QUALIFIER_PATTERN = /^(?:const|volatile|restrict|_Atomic)\b/;
|
|
92
225
|
function cDeclaratorDeclaredName(text) {
|
|
@@ -128,40 +261,92 @@ function declaratorNameNode(node) {
|
|
|
128
261
|
}
|
|
129
262
|
return undefined;
|
|
130
263
|
}
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
264
|
+
// C function and tag redeclarations share an identity. Tags remain separate from
|
|
265
|
+
// typedefs and other ordinary names, even when both are classified as TypeAlias.
|
|
266
|
+
function localExportDedupeKey(entry, languageId) {
|
|
267
|
+
if (languageId === "c") {
|
|
268
|
+
if (entry.target.kind === SymbolKind.Function)
|
|
269
|
+
return `${entry.exportedAs}\0function`;
|
|
270
|
+
if (entry.target.cTag) {
|
|
271
|
+
return `${entry.exportedAs}\0tag`;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
140
274
|
return `${entry.exportedAs}\0${entry.target.localName}\0${entry.target.range.start.index ?? 0}\0${entry.target.range.end.index ?? 0}`;
|
|
141
275
|
}
|
|
142
|
-
function
|
|
143
|
-
|
|
276
|
+
function collapseTypeScriptCallableExports(exports, tree, languageId) {
|
|
277
|
+
if ((languageId !== "ts" && languageId !== "tsx") || !tree)
|
|
278
|
+
return exports;
|
|
279
|
+
const groups = new Map();
|
|
280
|
+
for (const entry of exports) {
|
|
281
|
+
if (entry.type !== "local" || entry.target.kind !== SymbolKind.Function)
|
|
282
|
+
continue;
|
|
283
|
+
const start = entry.target.range.start.index ?? 0;
|
|
284
|
+
const end = entry.target.range.end.index ?? start;
|
|
285
|
+
const role = typescriptCallableRoleAt(tree, start, end);
|
|
286
|
+
if (role === "other")
|
|
287
|
+
continue;
|
|
288
|
+
const key = `${typescriptCallableContainerKey(tree, start, end)}\0${entry.exportedAs}`;
|
|
289
|
+
const group = groups.get(key) ?? [];
|
|
290
|
+
group.push(entry);
|
|
291
|
+
groups.set(key, group);
|
|
292
|
+
}
|
|
293
|
+
const drop = new Set();
|
|
294
|
+
for (const group of groups.values()) {
|
|
295
|
+
if (group.length < 2)
|
|
296
|
+
continue;
|
|
297
|
+
const canonical = typescriptCollapsedOverloadTarget(group, tree, (entry) => entry.target);
|
|
298
|
+
if (!canonical)
|
|
299
|
+
continue;
|
|
300
|
+
if (!canonical.target.docstring?.trim()) {
|
|
301
|
+
const documented = group.find((entry) => entry.target.docstring?.trim());
|
|
302
|
+
if (documented?.target.docstring)
|
|
303
|
+
canonical.target.docstring = documented.target.docstring;
|
|
304
|
+
}
|
|
305
|
+
for (const entry of group) {
|
|
306
|
+
if (entry !== canonical)
|
|
307
|
+
drop.add(entry);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (drop.size === 0)
|
|
311
|
+
return exports;
|
|
312
|
+
return exports.filter((entry) => !drop.has(entry));
|
|
313
|
+
}
|
|
314
|
+
function dedupeExportEntries(entries, languageId) {
|
|
315
|
+
const seen = new Map();
|
|
144
316
|
const out = [];
|
|
145
317
|
for (const entry of entries) {
|
|
146
318
|
if (entry.type !== "local") {
|
|
147
319
|
out.push(entry);
|
|
148
320
|
continue;
|
|
149
321
|
}
|
|
150
|
-
const key = localExportDedupeKey(entry);
|
|
151
|
-
|
|
322
|
+
const key = localExportDedupeKey(entry, languageId);
|
|
323
|
+
const previousIndex = seen.get(key);
|
|
324
|
+
if (previousIndex !== undefined) {
|
|
325
|
+
const previous = out[previousIndex];
|
|
326
|
+
if (languageId === "c" &&
|
|
327
|
+
entry.target.cTag === "declaration" &&
|
|
328
|
+
previous?.type === "local" &&
|
|
329
|
+
previous.target.cTag &&
|
|
330
|
+
previous.target.cTag !== "declaration") {
|
|
331
|
+
out[previousIndex] = entry;
|
|
332
|
+
}
|
|
152
333
|
continue;
|
|
153
|
-
|
|
334
|
+
}
|
|
335
|
+
seen.set(key, out.length);
|
|
154
336
|
out.push(entry);
|
|
155
337
|
}
|
|
156
338
|
return out;
|
|
157
339
|
}
|
|
158
|
-
function appendJsLikeRegexFallbackExports(file, source, locals, exports) {
|
|
340
|
+
function appendJsLikeRegexFallbackExports(file, source, locals, exports, leadingDocstringAt, tree) {
|
|
159
341
|
const maskedSource = maskJsLikeCommentsAndStrings(source);
|
|
160
342
|
JS_FALLBACK_DECLARATION_PATTERN.lastIndex = 0;
|
|
161
343
|
JS_FALLBACK_DEFAULT_PATTERN.lastIndex = 0;
|
|
162
344
|
JS_FALLBACK_EXPORT_ASSIGN_PATTERN.lastIndex = 0;
|
|
163
345
|
JS_FALLBACK_REEXPORT_NAMESPACE_PATTERN.lastIndex = 0;
|
|
164
346
|
JS_FALLBACK_CJS_FUNCTION_PATTERN.lastIndex = 0;
|
|
347
|
+
JS_FALLBACK_CJS_MODULE_FUNCTION_PATTERN.lastIndex = 0;
|
|
348
|
+
JS_FALLBACK_CJS_MODULE_IDENTIFIER_PATTERN.lastIndex = 0;
|
|
349
|
+
JS_FALLBACK_TOP_LEVEL_LOCAL_PATTERN.lastIndex = 0;
|
|
165
350
|
JS_FALLBACK_CJS_OBJECT_FUNCTION_PATTERN.lastIndex = 0;
|
|
166
351
|
const reDecl = JS_FALLBACK_DECLARATION_PATTERN;
|
|
167
352
|
const reDefault = JS_FALLBACK_DEFAULT_PATTERN;
|
|
@@ -170,8 +355,67 @@ function appendJsLikeRegexFallbackExports(file, source, locals, exports) {
|
|
|
170
355
|
const reReexportNs = JS_FALLBACK_REEXPORT_NAMESPACE_PATTERN;
|
|
171
356
|
const reStar = /\bexport\s*\*\s*from\s*("|')([^"']*)\1/gu;
|
|
172
357
|
const reCjsFn = JS_FALLBACK_CJS_FUNCTION_PATTERN;
|
|
358
|
+
const reCjsModuleFn = JS_FALLBACK_CJS_MODULE_FUNCTION_PATTERN;
|
|
359
|
+
const reCjsModuleIdentifier = JS_FALLBACK_CJS_MODULE_IDENTIFIER_PATTERN;
|
|
360
|
+
const reTopLevelLocal = JS_FALLBACK_TOP_LEVEL_LOCAL_PATTERN;
|
|
173
361
|
const reCjsObjFn = JS_FALLBACK_CJS_OBJECT_FUNCTION_PATTERN;
|
|
174
362
|
const moduleExportsObject = /module\.exports\s*=\s*\{([^}]*)\}/su;
|
|
363
|
+
const capturedCommonJsFunctionAt = (exportedAs, propertyIndex) => {
|
|
364
|
+
const root = tree?.rootNode;
|
|
365
|
+
if (!root || propertyIndex < 0 || propertyIndex >= source.length)
|
|
366
|
+
return undefined;
|
|
367
|
+
let node = root.descendantForIndex(propertyIndex, propertyIndex + 1);
|
|
368
|
+
while (node && node !== root && node.type !== "assignment_expression" && node.type !== "pair") {
|
|
369
|
+
node = node.parent;
|
|
370
|
+
}
|
|
371
|
+
if (!node || node === root)
|
|
372
|
+
return undefined;
|
|
373
|
+
const value = node.childForFieldName(node.type === "pair" ? "value" : "right");
|
|
374
|
+
if (!value)
|
|
375
|
+
return undefined;
|
|
376
|
+
const headerEnd = value.childForFieldName("body")?.startIndex ?? value.endIndex;
|
|
377
|
+
// A native function export points into this RHS header, not at an earlier same-named local.
|
|
378
|
+
return exports.find((entry) => {
|
|
379
|
+
if (entry.type !== "local" || entry.exportedAs !== exportedAs || entry.target.file !== file)
|
|
380
|
+
return false;
|
|
381
|
+
if (entry.target.kind !== SymbolKind.Function)
|
|
382
|
+
return false;
|
|
383
|
+
const start = entry.target.range.start.index;
|
|
384
|
+
return start !== undefined && start >= value.startIndex && start < headerEnd;
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
const appendCommonJsFunction = (exportedAs, propertyIndex, moduleValue = false) => {
|
|
388
|
+
const docstring = leadingDocstringAt(propertyIndex);
|
|
389
|
+
const existing = capturedCommonJsFunctionAt(exportedAs, propertyIndex);
|
|
390
|
+
if (existing) {
|
|
391
|
+
if (docstring && !existing.target.docstring)
|
|
392
|
+
existing.target.docstring = docstring;
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (moduleValue && exports.some((entry) => entry.type === "local" && entry.mechanism === "cjs-module-value")) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
let line = 1;
|
|
399
|
+
let lineStart = 0;
|
|
400
|
+
for (let offset = 0; offset < propertyIndex; offset++) {
|
|
401
|
+
if (source.charCodeAt(offset) === 10) {
|
|
402
|
+
line++;
|
|
403
|
+
lineStart = offset + 1;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const start = { line, column: propertyIndex - lineStart + 1, index: propertyIndex };
|
|
407
|
+
const end = { ...start, column: start.column + exportedAs.length, index: propertyIndex + exportedAs.length };
|
|
408
|
+
const target = { file, localName: exportedAs, kind: SymbolKind.Function, range: { start, end } };
|
|
409
|
+
if (docstring)
|
|
410
|
+
target.docstring = docstring;
|
|
411
|
+
locals.push(target);
|
|
412
|
+
if (moduleValue) {
|
|
413
|
+
exports.push({ type: "local", exportedAs, target, mechanism: "cjs-module-value" });
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
exports.push({ type: "local", exportedAs, target });
|
|
417
|
+
}
|
|
418
|
+
};
|
|
175
419
|
let match;
|
|
176
420
|
while ((match = reDecl.exec(maskedSource))) {
|
|
177
421
|
const name = match[1];
|
|
@@ -203,6 +447,7 @@ function appendJsLikeRegexFallbackExports(file, source, locals, exports) {
|
|
|
203
447
|
type: "local",
|
|
204
448
|
exportedAs: "default",
|
|
205
449
|
target: { ...local, kind: SymbolKind.Default },
|
|
450
|
+
mechanism: "ts-export-assignment",
|
|
206
451
|
});
|
|
207
452
|
}
|
|
208
453
|
}
|
|
@@ -263,20 +508,97 @@ function appendJsLikeRegexFallbackExports(file, source, locals, exports) {
|
|
|
263
508
|
}
|
|
264
509
|
while ((match = reCjsFn.exec(maskedSource))) {
|
|
265
510
|
const exportedAs = match[1];
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
511
|
+
const propertyIndex = match.index + match[0].indexOf(exportedAs);
|
|
512
|
+
appendCommonJsFunction(exportedAs, propertyIndex);
|
|
513
|
+
}
|
|
514
|
+
while ((match = reCjsModuleFn.exec(maskedSource))) {
|
|
515
|
+
const propertyIndex = match.index + match[0].indexOf("exports");
|
|
516
|
+
appendCommonJsFunction("exports", propertyIndex, true);
|
|
517
|
+
}
|
|
518
|
+
let identifierMatch = reCjsModuleIdentifier.exec(maskedSource);
|
|
519
|
+
if (identifierMatch && !exports.some((entry) => entry.type === "local" && entry.exportedAs === "default")) {
|
|
520
|
+
const identifierAssignments = [identifierMatch];
|
|
521
|
+
while ((identifierMatch = reCjsModuleIdentifier.exec(maskedSource)))
|
|
522
|
+
identifierAssignments.push(identifierMatch);
|
|
523
|
+
// Only a single module-scope declaration can prove the value behind module.exports.
|
|
524
|
+
// The comments/strings/regex mask preserves offsets while keeping nested declarations out.
|
|
525
|
+
const scopeSource = maskJsLikeCommentsStringsAndRegex(source);
|
|
526
|
+
let scanIndex = 0;
|
|
527
|
+
let scanLine = 1;
|
|
528
|
+
let lastLineBreak = -1;
|
|
529
|
+
let scopeDepth = 0;
|
|
530
|
+
const depthAt = (index) => {
|
|
531
|
+
while (scanIndex < index) {
|
|
532
|
+
const ch = scopeSource[scanIndex++];
|
|
533
|
+
if (ch === "{")
|
|
534
|
+
scopeDepth++;
|
|
535
|
+
if (ch === "\n") {
|
|
536
|
+
scanLine++;
|
|
537
|
+
lastLineBreak = scanIndex - 1;
|
|
538
|
+
}
|
|
539
|
+
if (ch === "}")
|
|
540
|
+
scopeDepth--;
|
|
541
|
+
}
|
|
542
|
+
return scopeDepth;
|
|
543
|
+
};
|
|
544
|
+
const declarations = new Map();
|
|
545
|
+
const valueNames = new Set(identifierAssignments.map((assignment) => assignment[1]));
|
|
546
|
+
let declarationMatch;
|
|
547
|
+
while ((declarationMatch = reTopLevelLocal.exec(scopeSource))) {
|
|
548
|
+
const name = declarationMatch[2];
|
|
549
|
+
if (!valueNames.has(name))
|
|
550
|
+
continue;
|
|
551
|
+
const startIndex = declarationMatch.index + declarationMatch[0].lastIndexOf(name);
|
|
552
|
+
if (depthAt(startIndex))
|
|
553
|
+
continue;
|
|
554
|
+
const declaration = declarationMatch[1];
|
|
555
|
+
let kind = SymbolKind.Variable;
|
|
556
|
+
if (declaration.endsWith("function"))
|
|
557
|
+
kind = SymbolKind.Function;
|
|
558
|
+
if (declaration.endsWith("class"))
|
|
559
|
+
kind = SymbolKind.Class;
|
|
560
|
+
const start = { line: scanLine, column: startIndex - lastLineBreak, index: startIndex };
|
|
561
|
+
const local = locals.find((def) => def.localName === name && def.range.start.index === startIndex) ?? {
|
|
271
562
|
file,
|
|
272
|
-
localName:
|
|
273
|
-
kind
|
|
274
|
-
range: { start:
|
|
563
|
+
localName: name,
|
|
564
|
+
kind,
|
|
565
|
+
range: { start, end: { ...start, column: start.column + name.length, index: startIndex + name.length } },
|
|
275
566
|
};
|
|
276
|
-
|
|
567
|
+
const namedDeclarations = declarations.get(name) ?? [];
|
|
568
|
+
const docstring = leadingDocstringAt(startIndex);
|
|
569
|
+
if (docstring && !local.docstring)
|
|
570
|
+
local.docstring = docstring;
|
|
571
|
+
namedDeclarations.push(local);
|
|
572
|
+
declarations.set(name, namedDeclarations);
|
|
277
573
|
}
|
|
278
|
-
|
|
279
|
-
|
|
574
|
+
scanIndex = 0;
|
|
575
|
+
scopeDepth = 0;
|
|
576
|
+
const provenValue = (assignment) => {
|
|
577
|
+
const name = assignment[1];
|
|
578
|
+
const rhsIndex = assignment.index + assignment[0].lastIndexOf(name);
|
|
579
|
+
if (depthAt(rhsIndex))
|
|
580
|
+
return undefined;
|
|
581
|
+
// A line break before .method, [key] or a call still belongs to the RHS.
|
|
582
|
+
let afterRhs = rhsIndex + name.length;
|
|
583
|
+
while (/\s/u.test(maskedSource[afterRhs] ?? ""))
|
|
584
|
+
afterRhs++;
|
|
585
|
+
if (maskedSource[afterRhs] === "." || maskedSource[afterRhs] === "[" || maskedSource[afterRhs] === "(") {
|
|
586
|
+
return undefined;
|
|
587
|
+
}
|
|
588
|
+
const candidates = declarations.get(name);
|
|
589
|
+
return candidates?.length === 1 ? candidates[0] : undefined;
|
|
590
|
+
};
|
|
591
|
+
// As in the native path, a reassigned module.exports has no single proven value.
|
|
592
|
+
const selected = identifierAssignments.length === 1 ? provenValue(identifierAssignments[0]) : undefined;
|
|
593
|
+
if (selected) {
|
|
594
|
+
if (!locals.includes(selected))
|
|
595
|
+
locals.push(selected);
|
|
596
|
+
exports.push({
|
|
597
|
+
type: "local",
|
|
598
|
+
exportedAs: "default",
|
|
599
|
+
target: { ...selected, kind: SymbolKind.Default },
|
|
600
|
+
mechanism: "cjs-module-value",
|
|
601
|
+
});
|
|
280
602
|
}
|
|
281
603
|
}
|
|
282
604
|
const moduleExportsObjMatch = moduleExportsObject.exec(maskedSource);
|
|
@@ -284,24 +606,12 @@ function appendJsLikeRegexFallbackExports(file, source, locals, exports) {
|
|
|
284
606
|
return;
|
|
285
607
|
}
|
|
286
608
|
const objContent = moduleExportsObjMatch[1];
|
|
609
|
+
const objectStart = moduleExportsObjMatch.index + moduleExportsObjMatch[0].indexOf("{") + 1;
|
|
287
610
|
let objectMatch;
|
|
288
611
|
while ((objectMatch = reCjsObjFn.exec(objContent))) {
|
|
289
612
|
const exportedAs = objectMatch[1];
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const idx = moduleExportsObjMatch.index + moduleExportsObjMatch[0].indexOf(exportedAs);
|
|
293
|
-
const pos = { line: 1, column: 1, index: idx };
|
|
294
|
-
local = {
|
|
295
|
-
file,
|
|
296
|
-
localName: exportedAs,
|
|
297
|
-
kind: SymbolKind.Function,
|
|
298
|
-
range: { start: pos, end: pos },
|
|
299
|
-
};
|
|
300
|
-
locals.push(local);
|
|
301
|
-
}
|
|
302
|
-
if (!exports.some((entry) => entry.type === "local" && entry.exportedAs === exportedAs)) {
|
|
303
|
-
exports.push({ type: "local", exportedAs, target: local });
|
|
304
|
-
}
|
|
613
|
+
const propertyIndex = objectStart + objectMatch.index + objectMatch[0].indexOf(exportedAs);
|
|
614
|
+
appendCommonJsFunction(exportedAs, propertyIndex);
|
|
305
615
|
}
|
|
306
616
|
}
|
|
307
617
|
export function collectLocalsAndExportsFromSource(file, source, support, imports = [], opts) {
|
|
@@ -406,6 +716,11 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
406
716
|
};
|
|
407
717
|
if (node && isTypeMemberDeclaration(node))
|
|
408
718
|
base.isMember = true;
|
|
719
|
+
if (support.id === "c" && node) {
|
|
720
|
+
const tagRole = cTagRole(node);
|
|
721
|
+
if (tagRole)
|
|
722
|
+
base.cTag = tagRole;
|
|
723
|
+
}
|
|
409
724
|
if (docstring)
|
|
410
725
|
base.docstring = docstring;
|
|
411
726
|
if (lineSpan)
|
|
@@ -437,6 +752,22 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
437
752
|
}
|
|
438
753
|
return tree;
|
|
439
754
|
};
|
|
755
|
+
const leadingDocstringAt = (index) => {
|
|
756
|
+
const root = ensureTree()?.rootNode;
|
|
757
|
+
if (!root || index < 0 || index >= source.length)
|
|
758
|
+
return undefined;
|
|
759
|
+
let node = root.descendantForIndex(index, index + 1);
|
|
760
|
+
if (node === root)
|
|
761
|
+
return undefined;
|
|
762
|
+
// Comments attach to the assignment statement or object member, not its function expression.
|
|
763
|
+
while (node.parent &&
|
|
764
|
+
node.parent.type !== "program" &&
|
|
765
|
+
node.parent.type !== "statement_block" &&
|
|
766
|
+
node.parent.type !== "object") {
|
|
767
|
+
node = node.parent;
|
|
768
|
+
}
|
|
769
|
+
return extractLeadingDocstring(node);
|
|
770
|
+
};
|
|
440
771
|
// Lazily build once: converts every native capture's UTF-8 byte offsets to UTF-16
|
|
441
772
|
// string indexes in O(1) per capture instead of rescanning the source per offset.
|
|
442
773
|
// `ensureTree()` builds the same map internally when native mode is active, so route
|
|
@@ -522,6 +853,13 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
522
853
|
}
|
|
523
854
|
}
|
|
524
855
|
}
|
|
856
|
+
else if (node && phpPropertyPromotionParameter(node)) {
|
|
857
|
+
const promoted = phpConstructorPromotedVariable(node, source);
|
|
858
|
+
if (promoted) {
|
|
859
|
+
pushLocal(sliceText(promoted, source), SymbolKind.Variable, toRange(promoted), promoted);
|
|
860
|
+
capturedLocals = true;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
525
863
|
else {
|
|
526
864
|
pushLocal(capture.text, classifyLocalCapture(node), nativeRange, node);
|
|
527
865
|
}
|
|
@@ -536,12 +874,13 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
536
874
|
return false;
|
|
537
875
|
}
|
|
538
876
|
};
|
|
877
|
+
let scopeIndexForExports;
|
|
539
878
|
const usedQueryLocals = extractLocalsFromNativeQueries();
|
|
540
879
|
if (!usedQueryLocals) {
|
|
541
880
|
const scopeTree = ensureTree();
|
|
542
881
|
if (scopeTree) {
|
|
543
|
-
|
|
544
|
-
for (const b of
|
|
882
|
+
scopeIndexForExports = buildScopeIndexFromSource(file, source, support, imports, { tree: scopeTree });
|
|
883
|
+
for (const b of scopeIndexForExports.all) {
|
|
545
884
|
if (!b.def)
|
|
546
885
|
continue;
|
|
547
886
|
const kind = bindingKindToSymbolKind(b.kind);
|
|
@@ -622,12 +961,27 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
622
961
|
const range = rangeFromNativeCapture(capture, ensureByteIndexMap());
|
|
623
962
|
return treeForEnrichment.rootNode.descendantForIndex(range.start.index ?? 0, range.end.index ?? 0) ?? undefined;
|
|
624
963
|
};
|
|
964
|
+
const localVisibleAtCapture = (capture) => {
|
|
965
|
+
const node = nodeForCapture(capture);
|
|
966
|
+
if (!node || !treeForEnrichment)
|
|
967
|
+
return undefined;
|
|
968
|
+
scopeIndexForExports ??= buildScopeIndexFromSource(file, source, support, imports, { tree: treeForEnrichment });
|
|
969
|
+
const binding = findClosestScopeBinding(scopeIndexForExports, capture.text, node, support);
|
|
970
|
+
const definition = binding?.def;
|
|
971
|
+
if (!definition)
|
|
972
|
+
return undefined;
|
|
973
|
+
return locals.find((local) => local.localName === binding.name &&
|
|
974
|
+
local.range.start.index === definition.start.index &&
|
|
975
|
+
local.range.end.index === definition.end.index);
|
|
976
|
+
};
|
|
625
977
|
const defaultDeclarationNameNode = (node) => {
|
|
626
978
|
if (!node)
|
|
627
979
|
return undefined;
|
|
628
980
|
return (node.childForFieldName("name") ?? node.childForFieldName("declaration")?.childForFieldName("name") ?? undefined);
|
|
629
981
|
};
|
|
630
982
|
const hasDefaultExport = () => exports.some((entry) => entry.type === "local" && entry.exportedAs === "default");
|
|
983
|
+
// A second `module.exports = X` makes the required value depend on control flow.
|
|
984
|
+
let cjsModuleValueSeen = false;
|
|
631
985
|
const excludedCaptures = [];
|
|
632
986
|
for (const match of matches) {
|
|
633
987
|
for (const capture of match.captures) {
|
|
@@ -800,6 +1154,25 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
800
1154
|
});
|
|
801
1155
|
continue;
|
|
802
1156
|
}
|
|
1157
|
+
if (map["cjs_module_value"]) {
|
|
1158
|
+
if (cjsModuleValueSeen) {
|
|
1159
|
+
const previous = exports.findIndex((entry) => entry.type === "local" && entry.exportedAs === "default" && entry.mechanism === "cjs-module-value");
|
|
1160
|
+
if (previous >= 0)
|
|
1161
|
+
exports.splice(previous, 1);
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
cjsModuleValueSeen = true;
|
|
1165
|
+
const local = localVisibleAtCapture(map["cjs_module_value"]);
|
|
1166
|
+
if (local && !hasDefaultExport()) {
|
|
1167
|
+
exports.push({
|
|
1168
|
+
type: "local",
|
|
1169
|
+
exportedAs: "default",
|
|
1170
|
+
target: { ...local, kind: SymbolKind.Default },
|
|
1171
|
+
mechanism: "cjs-module-value",
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
continue;
|
|
1175
|
+
}
|
|
803
1176
|
if (map["cjs_shorthand"]) {
|
|
804
1177
|
const nameText = map["cjs_shorthand"].text;
|
|
805
1178
|
const local = locals.find((def) => def.localName === nameText);
|
|
@@ -823,9 +1196,19 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
823
1196
|
if (map["cjs_export_name"] && map["cjs_fn"]) {
|
|
824
1197
|
const exportedAs = map["cjs_export_name"].text;
|
|
825
1198
|
const fnNode = nodeForCapture(map["cjs_fn"]);
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
1199
|
+
const nameNode = fnNode?.childForFieldName("name");
|
|
1200
|
+
const range = nameNode ? toRange(nameNode) : rangeFromNativeCapture(map["cjs_fn"], ensureByteIndexMap());
|
|
1201
|
+
const existing = locals.find((def) => def.localName === exportedAs && def.range.start.index === range.start.index);
|
|
1202
|
+
const sym = existing ?? buildSymbolDef(exportedAs, SymbolKind.Function, range, nameNode ?? fnNode);
|
|
1203
|
+
if (!existing)
|
|
1204
|
+
locals.push(sym);
|
|
1205
|
+
const directModuleValue = exportedAs === "exports" && !!map["mod"] && !map["prop"];
|
|
1206
|
+
exports.push({
|
|
1207
|
+
type: "local",
|
|
1208
|
+
exportedAs,
|
|
1209
|
+
target: sym,
|
|
1210
|
+
...(directModuleValue ? { mechanism: "cjs-module-value" } : {}),
|
|
1211
|
+
});
|
|
829
1212
|
continue;
|
|
830
1213
|
}
|
|
831
1214
|
if (map["default"]) {
|
|
@@ -875,6 +1258,7 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
875
1258
|
type: "local",
|
|
876
1259
|
exportedAs: "default",
|
|
877
1260
|
target: { ...local, kind: SymbolKind.Default },
|
|
1261
|
+
mechanism: "ts-export-assignment",
|
|
878
1262
|
});
|
|
879
1263
|
}
|
|
880
1264
|
continue;
|
|
@@ -886,20 +1270,56 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
886
1270
|
const visibilityNameNode = nodeForCapture(nameCapture);
|
|
887
1271
|
if (visibilityNameNode && !isExportedDeclaration(support.id, visibilityNameNode))
|
|
888
1272
|
continue;
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1273
|
+
let nameText = nameCapture.text;
|
|
1274
|
+
let nameRange = rangeFromNativeCapture(nameCapture, ensureByteIndexMap());
|
|
1275
|
+
if (map["declarator"]) {
|
|
1276
|
+
const namedNode = declaratorNameNode(visibilityNameNode);
|
|
1277
|
+
if (namedNode) {
|
|
1278
|
+
nameText = namedNode.text;
|
|
1279
|
+
nameRange = toRange(namedNode);
|
|
1280
|
+
}
|
|
1281
|
+
else {
|
|
1282
|
+
const extracted = cDeclaratorDeclaredName(nameCapture.text);
|
|
1283
|
+
if (!extracted)
|
|
1284
|
+
continue;
|
|
1285
|
+
nameText = extracted.name;
|
|
1286
|
+
const captureStart = nameRange.start.index ?? 0;
|
|
1287
|
+
nameRange = rangeFromOffsets(captureStart + extracted.start, captureStart + extracted.end);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
892
1290
|
if (!nameText)
|
|
893
1291
|
continue;
|
|
894
|
-
const local = locals.find((def) => def.localName === nameText
|
|
1292
|
+
const local = locals.find((def) => def.localName === nameText &&
|
|
1293
|
+
def.range.start.index === nameRange.start.index &&
|
|
1294
|
+
def.range.end.index === nameRange.end.index) ?? locals.find((def) => def.localName === nameText);
|
|
895
1295
|
if (local) {
|
|
896
1296
|
const isDefaultExport = /^\s*export\s+default\b/.test(stmtText);
|
|
1297
|
+
const qualifiedExportName = () => {
|
|
1298
|
+
if (!visibilityNameNode)
|
|
1299
|
+
return nameText;
|
|
1300
|
+
if (support.id === "cpp")
|
|
1301
|
+
return cppQualifiedExportName(visibilityNameNode, source, nameText);
|
|
1302
|
+
if (support.id === "ruby")
|
|
1303
|
+
return rubyQualifiedExportName(visibilityNameNode, source, nameText);
|
|
1304
|
+
return nameText;
|
|
1305
|
+
};
|
|
1306
|
+
const exportedName = qualifiedExportName();
|
|
897
1307
|
if (!isDefaultExport) {
|
|
898
1308
|
exports.push({
|
|
899
1309
|
type: "local",
|
|
900
|
-
exportedAs:
|
|
1310
|
+
exportedAs: exportedName,
|
|
901
1311
|
target: local,
|
|
902
1312
|
});
|
|
1313
|
+
if (support.id === "cpp" && visibilityNameNode && exportedName !== nameText) {
|
|
1314
|
+
const visibleAs = cppQualifiedExportName(visibilityNameNode, source, nameText, true);
|
|
1315
|
+
if (visibleAs !== exportedName) {
|
|
1316
|
+
exports.push({
|
|
1317
|
+
type: "local",
|
|
1318
|
+
exportedAs: visibleAs,
|
|
1319
|
+
target: local,
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
903
1323
|
}
|
|
904
1324
|
if (isDefaultExport && !hasDefaultExport()) {
|
|
905
1325
|
exports.push({
|
|
@@ -950,12 +1370,97 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
950
1370
|
throw error;
|
|
951
1371
|
}
|
|
952
1372
|
}
|
|
1373
|
+
if (support.id === "cpp") {
|
|
1374
|
+
const treeForUsingDeclarations = ensureTree();
|
|
1375
|
+
if (treeForUsingDeclarations) {
|
|
1376
|
+
const callableExports = new Map();
|
|
1377
|
+
let retainedCount = 0;
|
|
1378
|
+
for (const entry of exports) {
|
|
1379
|
+
if (entry.type === "local" && entry.target.kind === SymbolKind.Function) {
|
|
1380
|
+
const { start, end } = entry.target.range;
|
|
1381
|
+
const nameNode = treeForUsingDeclarations.rootNode.descendantForPosition({ row: start.line - 1, column: start.column - 1 }, { row: end.line - 1, column: end.column - 1 });
|
|
1382
|
+
const shape = cppCallableShapeForNode(nameNode);
|
|
1383
|
+
if (shape) {
|
|
1384
|
+
const key = `${entry.exportedAs}\0${shape.signature}`;
|
|
1385
|
+
const isDefinition = cppCallableIsDefinition(nameNode);
|
|
1386
|
+
const existing = callableExports.get(key);
|
|
1387
|
+
if (existing) {
|
|
1388
|
+
if (isDefinition && !existing.isDefinition) {
|
|
1389
|
+
exports[existing.index] = entry;
|
|
1390
|
+
existing.isDefinition = true;
|
|
1391
|
+
}
|
|
1392
|
+
continue;
|
|
1393
|
+
}
|
|
1394
|
+
callableExports.set(key, { index: retainedCount, isDefinition });
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
exports[retainedCount++] = entry;
|
|
1398
|
+
}
|
|
1399
|
+
exports.length = retainedCount;
|
|
1400
|
+
}
|
|
1401
|
+
const visitUsingDeclaration = (node) => {
|
|
1402
|
+
if (support.exportScopeBlockers.some((blocker) => matchesExportScopeBlocker(node, blocker)))
|
|
1403
|
+
return;
|
|
1404
|
+
if (node.type === "using_declaration") {
|
|
1405
|
+
const qualified = node.namedChildren.find((child) => child.type === "qualified_identifier") ??
|
|
1406
|
+
node.namedChildren
|
|
1407
|
+
.flatMap((child) => child.namedChildren)
|
|
1408
|
+
.find((child) => child.type === "qualified_identifier");
|
|
1409
|
+
if (qualified) {
|
|
1410
|
+
const importedSegments = cppQualifiedNameSegments(qualified, source);
|
|
1411
|
+
const importedName = importedSegments.join("::");
|
|
1412
|
+
const localName = importedSegments.at(-1);
|
|
1413
|
+
if (!localName)
|
|
1414
|
+
return;
|
|
1415
|
+
const exportedName = cppQualifiedExportName(node, source, localName);
|
|
1416
|
+
const exportedNames = [exportedName];
|
|
1417
|
+
if (exportedName !== localName) {
|
|
1418
|
+
const visibleAs = cppQualifiedExportName(node, source, localName, true);
|
|
1419
|
+
if (visibleAs !== exportedName)
|
|
1420
|
+
exportedNames.push(visibleAs);
|
|
1421
|
+
}
|
|
1422
|
+
const targets = exports.filter((entry) => entry.type === "local" && entry.exportedAs === importedName);
|
|
1423
|
+
for (const exportedAs of exportedNames) {
|
|
1424
|
+
// Included declarations are not available during per-file extraction.
|
|
1425
|
+
// Retain the qualified target for resolution against the completed index.
|
|
1426
|
+
for (const imp of imports) {
|
|
1427
|
+
if (imp.kind !== "star" || typeof imp.resolved !== "string")
|
|
1428
|
+
continue;
|
|
1429
|
+
exports.push({
|
|
1430
|
+
type: "reexport",
|
|
1431
|
+
exportedAs,
|
|
1432
|
+
fromModule: imp.resolved,
|
|
1433
|
+
sourceSpecifier: importedName,
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
for (const target of targets) {
|
|
1437
|
+
if (exports.some((entry) => entry.type === "local" &&
|
|
1438
|
+
entry.exportedAs === exportedAs &&
|
|
1439
|
+
entry.target.range.start.index === target.target.range.start.index)) {
|
|
1440
|
+
continue;
|
|
1441
|
+
}
|
|
1442
|
+
exports.push({
|
|
1443
|
+
type: "local",
|
|
1444
|
+
exportedAs,
|
|
1445
|
+
target: target.target,
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
for (const child of node.namedChildren)
|
|
1453
|
+
visitUsingDeclaration(child);
|
|
1454
|
+
};
|
|
1455
|
+
if (treeForUsingDeclarations)
|
|
1456
|
+
visitUsingDeclaration(treeForUsingDeclarations.rootNode);
|
|
1457
|
+
}
|
|
953
1458
|
// The native query does not cover CommonJS member assignments and some
|
|
954
1459
|
// re-export forms. Always run the deduplicating fallback for JS-like files:
|
|
955
1460
|
// source-form probes are too error-prone to risk silently dropping exports.
|
|
956
1461
|
const isJsLike = support.id === "ts" || support.id === "tsx" || support.id === "js";
|
|
957
1462
|
if (isJsLike) {
|
|
958
|
-
appendJsLikeRegexFallbackExports(file, source, locals, exports);
|
|
1463
|
+
appendJsLikeRegexFallbackExports(file, source, locals, exports, leadingDocstringAt, ensureTree());
|
|
959
1464
|
}
|
|
960
1465
|
if (support.id === "python") {
|
|
961
1466
|
for (const binding of imports) {
|
|
@@ -1040,6 +1545,12 @@ export function collectLocalsAndExportsFromSource(file, source, support, imports
|
|
|
1040
1545
|
}
|
|
1041
1546
|
}
|
|
1042
1547
|
}
|
|
1043
|
-
return {
|
|
1548
|
+
return {
|
|
1549
|
+
file,
|
|
1550
|
+
exports: dedupeExportEntries(collapseTypeScriptCallableExports(exports, ensureTree(), support.id), support.id),
|
|
1551
|
+
imports,
|
|
1552
|
+
locals,
|
|
1553
|
+
...(tree && DOCSTRING_CAPTURE_LANGUAGES.has(support.id) ? { docstringsChecked: true } : {}),
|
|
1554
|
+
};
|
|
1044
1555
|
}
|
|
1045
1556
|
//# sourceMappingURL=locals-and-exports.js.map
|