@colbymchenry/codegraph-win32-arm64 1.6.2 → 1.6.4
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/bin/codegraph +1 -1
- package/bin/codegraph.cmd +1 -1
- package/lib/dist/.test-build-engine.json +1 -1
- package/lib/dist/.test-build-viewer.json +1 -1
- package/lib/dist/bin/codegraph.d.ts +3 -0
- package/lib/dist/bin/codegraph.d.ts.map +1 -1
- package/lib/dist/bin/codegraph.js +507 -702
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/bin/command-supervision.js +1 -57
- package/lib/dist/bin/command-supervision.js.map +1 -1
- package/lib/dist/bin/fatal-handler.js +0 -46
- package/lib/dist/bin/fatal-handler.js.map +1 -1
- package/lib/dist/bin/node-version-check.js +0 -33
- package/lib/dist/bin/node-version-check.js.map +1 -1
- package/lib/dist/bin/uninstall.js +0 -19
- package/lib/dist/bin/uninstall.js.map +1 -1
- package/lib/dist/bin/viewer-gate.js +0 -14
- package/lib/dist/bin/viewer-gate.js.map +1 -1
- package/lib/dist/compile-cache.d.ts +2 -0
- package/lib/dist/compile-cache.d.ts.map +1 -0
- package/lib/dist/compile-cache.js +45 -0
- package/lib/dist/compile-cache.js.map +1 -0
- package/lib/dist/context/formatter.js +3 -66
- package/lib/dist/context/formatter.js.map +1 -1
- package/lib/dist/context/index.d.ts +44 -1
- package/lib/dist/context/index.d.ts.map +1 -1
- package/lib/dist/context/index.js +123 -430
- package/lib/dist/context/index.js.map +1 -1
- package/lib/dist/context/markers.js +0 -17
- package/lib/dist/context/markers.js.map +1 -1
- package/lib/dist/db/index.d.ts +44 -1
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +123 -395
- package/lib/dist/db/index.js.map +1 -1
- package/lib/dist/db/migrations.d.ts +11 -1
- package/lib/dist/db/migrations.d.ts.map +1 -1
- package/lib/dist/db/migrations.js +71 -79
- package/lib/dist/db/migrations.js.map +1 -1
- package/lib/dist/db/name-substring-index.d.ts +63 -0
- package/lib/dist/db/name-substring-index.d.ts.map +1 -0
- package/lib/dist/db/name-substring-index.js +151 -0
- package/lib/dist/db/name-substring-index.js.map +1 -0
- package/lib/dist/db/node-sqlite.d.ts +19 -0
- package/lib/dist/db/node-sqlite.d.ts.map +1 -0
- package/lib/dist/db/node-sqlite.js +23 -0
- package/lib/dist/db/node-sqlite.js.map +1 -0
- package/lib/dist/db/open-error.d.ts +36 -0
- package/lib/dist/db/open-error.d.ts.map +1 -0
- package/lib/dist/db/open-error.js +63 -0
- package/lib/dist/db/open-error.js.map +1 -0
- package/lib/dist/db/parameter-flow-queries.d.ts +120 -0
- package/lib/dist/db/parameter-flow-queries.d.ts.map +1 -0
- package/lib/dist/db/parameter-flow-queries.js +168 -0
- package/lib/dist/db/parameter-flow-queries.js.map +1 -0
- package/lib/dist/db/queries.d.ts +654 -34
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +1466 -1470
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/db/reference-tail.d.ts +83 -0
- package/lib/dist/db/reference-tail.d.ts.map +1 -0
- package/lib/dist/db/reference-tail.js +68 -0
- package/lib/dist/db/reference-tail.js.map +1 -0
- package/lib/dist/db/schema.sql +18 -2
- package/lib/dist/db/sqlite-adapter.d.ts +18 -1
- package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/lib/dist/db/sqlite-adapter.js +12 -62
- package/lib/dist/db/sqlite-adapter.js.map +1 -1
- package/lib/dist/db/synthesis-stage.d.ts.map +1 -1
- package/lib/dist/db/synthesis-stage.js +2 -6
- package/lib/dist/db/synthesis-stage.js.map +1 -1
- package/lib/dist/db/wal-valve.js +1 -153
- package/lib/dist/db/wal-valve.js.map +1 -1
- package/lib/dist/db/wsl-shared-index.js +0 -37
- package/lib/dist/db/wsl-shared-index.js.map +1 -1
- package/lib/dist/directory.d.ts +51 -0
- package/lib/dist/directory.d.ts.map +1 -1
- package/lib/dist/directory.js +76 -530
- package/lib/dist/directory.js.map +1 -1
- package/lib/dist/engine.d.ts +15 -0
- package/lib/dist/engine.d.ts.map +1 -0
- package/lib/dist/engine.js +35 -0
- package/lib/dist/engine.js.map +1 -0
- package/lib/dist/errors.d.ts +10 -0
- package/lib/dist/errors.d.ts.map +1 -1
- package/lib/dist/errors.js +8 -101
- package/lib/dist/errors.js.map +1 -1
- package/lib/dist/extraction/astro-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/astro-extractor.js +11 -101
- package/lib/dist/extraction/astro-extractor.js.map +1 -1
- package/lib/dist/extraction/cfml-extractor.d.ts +27 -1
- package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/cfml-extractor.js +70 -206
- package/lib/dist/extraction/cfml-extractor.js.map +1 -1
- package/lib/dist/extraction/commonjs-requires.js +0 -31
- package/lib/dist/extraction/commonjs-requires.js.map +1 -1
- package/lib/dist/extraction/dfm-extractor.js +0 -21
- package/lib/dist/extraction/dfm-extractor.js.map +1 -1
- package/lib/dist/extraction/extraction-version.d.ts +1 -1
- package/lib/dist/extraction/extraction-version.js +1 -24
- package/lib/dist/extraction/extraction-version.js.map +1 -1
- package/lib/dist/extraction/function-ref.d.ts +40 -0
- package/lib/dist/extraction/function-ref.d.ts.map +1 -1
- package/lib/dist/extraction/function-ref.js +157 -207
- package/lib/dist/extraction/function-ref.js.map +1 -1
- package/lib/dist/extraction/generated-detection.js +0 -165
- package/lib/dist/extraction/generated-detection.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts +73 -4
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +160 -431
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +208 -7
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +594 -1383
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/kernel/decode.js +0 -16
- package/lib/dist/extraction/kernel/decode.js.map +1 -1
- package/lib/dist/extraction/kernel/index.d.ts +3 -1
- package/lib/dist/extraction/kernel/index.d.ts.map +1 -1
- package/lib/dist/extraction/kernel/index.js +48 -135
- package/lib/dist/extraction/kernel/index.js.map +1 -1
- package/lib/dist/extraction/kernel/layout.js +42 -76
- package/lib/dist/extraction/kernel/layout.js.map +1 -1
- package/lib/dist/extraction/kernel/loader.d.ts +5 -1
- package/lib/dist/extraction/kernel/loader.d.ts.map +1 -1
- package/lib/dist/extraction/kernel/loader.js +0 -37
- package/lib/dist/extraction/kernel/loader.js.map +1 -1
- package/lib/dist/extraction/languages/arkts.js +0 -59
- package/lib/dist/extraction/languages/arkts.js.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.d.ts +125 -28
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +789 -856
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/languages/cfquery.js +0 -9
- package/lib/dist/extraction/languages/cfquery.js.map +1 -1
- package/lib/dist/extraction/languages/cfscript.d.ts +20 -0
- package/lib/dist/extraction/languages/cfscript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/cfscript.js +80 -9
- package/lib/dist/extraction/languages/cfscript.js.map +1 -1
- package/lib/dist/extraction/languages/cobol.js +0 -114
- package/lib/dist/extraction/languages/cobol.js.map +1 -1
- package/lib/dist/extraction/languages/cpp-brace-scopes.d.ts +66 -0
- package/lib/dist/extraction/languages/cpp-brace-scopes.d.ts.map +1 -0
- package/lib/dist/extraction/languages/cpp-brace-scopes.js +343 -0
- package/lib/dist/extraction/languages/cpp-brace-scopes.js.map +1 -0
- package/lib/dist/extraction/languages/cpp-macro-methods.d.ts +41 -0
- package/lib/dist/extraction/languages/cpp-macro-methods.d.ts.map +1 -0
- package/lib/dist/extraction/languages/cpp-macro-methods.js +487 -0
- package/lib/dist/extraction/languages/cpp-macro-methods.js.map +1 -0
- package/lib/dist/extraction/languages/csharp.js +3 -55
- package/lib/dist/extraction/languages/csharp.js.map +1 -1
- package/lib/dist/extraction/languages/dart.d.ts +129 -0
- package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
- package/lib/dist/extraction/languages/dart.js +517 -162
- package/lib/dist/extraction/languages/dart.js.map +1 -1
- package/lib/dist/extraction/languages/erlang.d.ts.map +1 -1
- package/lib/dist/extraction/languages/erlang.js +15 -102
- package/lib/dist/extraction/languages/erlang.js.map +1 -1
- package/lib/dist/extraction/languages/go.d.ts +48 -0
- package/lib/dist/extraction/languages/go.d.ts.map +1 -1
- package/lib/dist/extraction/languages/go.js +102 -31
- package/lib/dist/extraction/languages/go.js.map +1 -1
- package/lib/dist/extraction/languages/index.js +0 -6
- package/lib/dist/extraction/languages/index.js.map +1 -1
- package/lib/dist/extraction/languages/java.d.ts.map +1 -1
- package/lib/dist/extraction/languages/java.js +67 -78
- package/lib/dist/extraction/languages/java.js.map +1 -1
- package/lib/dist/extraction/languages/javascript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/javascript.js +2 -12
- package/lib/dist/extraction/languages/javascript.js.map +1 -1
- package/lib/dist/extraction/languages/kotlin.d.ts +11 -0
- package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/lib/dist/extraction/languages/kotlin.js +43 -197
- package/lib/dist/extraction/languages/kotlin.js.map +1 -1
- package/lib/dist/extraction/languages/lua.js +2 -39
- package/lib/dist/extraction/languages/lua.js.map +1 -1
- package/lib/dist/extraction/languages/luau.js +0 -14
- package/lib/dist/extraction/languages/luau.js.map +1 -1
- package/lib/dist/extraction/languages/nix.js +0 -16
- package/lib/dist/extraction/languages/nix.js.map +1 -1
- package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
- package/lib/dist/extraction/languages/objc.js +5 -16
- package/lib/dist/extraction/languages/objc.js.map +1 -1
- package/lib/dist/extraction/languages/pascal-preparse.d.ts +66 -0
- package/lib/dist/extraction/languages/pascal-preparse.d.ts.map +1 -0
- package/lib/dist/extraction/languages/pascal-preparse.js +958 -0
- package/lib/dist/extraction/languages/pascal-preparse.js.map +1 -0
- package/lib/dist/extraction/languages/pascal-system.d.ts +11 -0
- package/lib/dist/extraction/languages/pascal-system.d.ts.map +1 -0
- package/lib/dist/extraction/languages/pascal-system.js +23 -0
- package/lib/dist/extraction/languages/pascal-system.js.map +1 -0
- package/lib/dist/extraction/languages/pascal.d.ts.map +1 -1
- package/lib/dist/extraction/languages/pascal.js +3 -4
- package/lib/dist/extraction/languages/pascal.js.map +1 -1
- package/lib/dist/extraction/languages/php.d.ts +9 -0
- package/lib/dist/extraction/languages/php.d.ts.map +1 -1
- package/lib/dist/extraction/languages/php.js +207 -44
- package/lib/dist/extraction/languages/php.js.map +1 -1
- package/lib/dist/extraction/languages/python.js +2 -20
- package/lib/dist/extraction/languages/python.js.map +1 -1
- package/lib/dist/extraction/languages/r.js +8 -78
- package/lib/dist/extraction/languages/r.js.map +1 -1
- package/lib/dist/extraction/languages/ruby.d.ts.map +1 -1
- package/lib/dist/extraction/languages/ruby.js +17 -25
- package/lib/dist/extraction/languages/ruby.js.map +1 -1
- package/lib/dist/extraction/languages/rust-macro-calls.d.ts +32 -0
- package/lib/dist/extraction/languages/rust-macro-calls.d.ts.map +1 -0
- package/lib/dist/extraction/languages/rust-macro-calls.js +306 -0
- package/lib/dist/extraction/languages/rust-macro-calls.js.map +1 -0
- package/lib/dist/extraction/languages/rust.d.ts +10 -0
- package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
- package/lib/dist/extraction/languages/rust.js +15 -47
- package/lib/dist/extraction/languages/rust.js.map +1 -1
- package/lib/dist/extraction/languages/scala.js +5 -41
- package/lib/dist/extraction/languages/scala.js.map +1 -1
- package/lib/dist/extraction/languages/solidity.js +1 -82
- package/lib/dist/extraction/languages/solidity.js.map +1 -1
- package/lib/dist/extraction/languages/swift.js +3 -47
- package/lib/dist/extraction/languages/swift.js.map +1 -1
- package/lib/dist/extraction/languages/terraform.js +6 -152
- package/lib/dist/extraction/languages/terraform.js.map +1 -1
- package/lib/dist/extraction/languages/typescript.d.ts +64 -0
- package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/typescript.js +73 -49
- package/lib/dist/extraction/languages/typescript.js.map +1 -1
- package/lib/dist/extraction/languages/vbnet.d.ts.map +1 -1
- package/lib/dist/extraction/languages/vbnet.js +9 -42
- package/lib/dist/extraction/languages/vbnet.js.map +1 -1
- package/lib/dist/extraction/lazy-frameworks.d.ts +15 -0
- package/lib/dist/extraction/lazy-frameworks.d.ts.map +1 -0
- package/lib/dist/extraction/lazy-frameworks.js +8 -0
- package/lib/dist/extraction/lazy-frameworks.js.map +1 -0
- package/lib/dist/extraction/liquid-extractor.d.ts +29 -3
- package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/liquid-extractor.js +89 -148
- package/lib/dist/extraction/liquid-extractor.js.map +1 -1
- package/lib/dist/extraction/mybatis-extractor.js +0 -78
- package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
- package/lib/dist/extraction/parse-budget.d.ts +42 -7
- package/lib/dist/extraction/parse-budget.d.ts.map +1 -1
- package/lib/dist/extraction/parse-budget.js +39 -15
- package/lib/dist/extraction/parse-budget.js.map +1 -1
- package/lib/dist/extraction/parse-pool.d.ts +29 -17
- package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
- package/lib/dist/extraction/parse-pool.js +49 -193
- package/lib/dist/extraction/parse-pool.js.map +1 -1
- package/lib/dist/extraction/parse-worker.d.ts +1 -1
- package/lib/dist/extraction/parse-worker.d.ts.map +1 -1
- package/lib/dist/extraction/parse-worker.js +5 -58
- package/lib/dist/extraction/parse-worker.js.map +1 -1
- package/lib/dist/extraction/razor-extractor.d.ts +9 -0
- package/lib/dist/extraction/razor-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/razor-extractor.js +45 -69
- package/lib/dist/extraction/razor-extractor.js.map +1 -1
- package/lib/dist/extraction/razor-script.d.ts +23 -0
- package/lib/dist/extraction/razor-script.d.ts.map +1 -0
- package/lib/dist/extraction/razor-script.js +244 -0
- package/lib/dist/extraction/razor-script.js.map +1 -0
- package/lib/dist/extraction/sfc-script.d.ts +42 -0
- package/lib/dist/extraction/sfc-script.d.ts.map +1 -1
- package/lib/dist/extraction/sfc-script.js +32 -31
- package/lib/dist/extraction/sfc-script.js.map +1 -1
- package/lib/dist/extraction/store-worker.d.ts +1 -1
- package/lib/dist/extraction/store-worker.d.ts.map +1 -1
- package/lib/dist/extraction/store-worker.js +1 -38
- package/lib/dist/extraction/store-worker.js.map +1 -1
- package/lib/dist/extraction/store-writer.js +2 -34
- package/lib/dist/extraction/store-writer.js.map +1 -1
- package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/svelte-extractor.js +11 -87
- package/lib/dist/extraction/svelte-extractor.js.map +1 -1
- package/lib/dist/extraction/syntax-tokens.d.ts +6 -5
- package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -1
- package/lib/dist/extraction/syntax-tokens.js +4 -152
- package/lib/dist/extraction/syntax-tokens.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.d.ts +37 -1
- package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.js +76 -68
- package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-types.d.ts +102 -22
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter-types.js +0 -7
- package/lib/dist/extraction/tree-sitter-types.js.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +518 -10
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +2118 -2554
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/vue-extractor.d.ts +13 -0
- package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/vue-extractor.js +52 -92
- package/lib/dist/extraction/vue-extractor.js.map +1 -1
- package/lib/dist/extraction/vue-options-api.js +0 -32
- package/lib/dist/extraction/vue-options-api.js.map +1 -1
- package/lib/dist/extraction/vue-template-calls.d.ts +37 -0
- package/lib/dist/extraction/vue-template-calls.d.ts.map +1 -0
- package/lib/dist/extraction/vue-template-calls.js +497 -0
- package/lib/dist/extraction/vue-template-calls.js.map +1 -0
- package/lib/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/lib/dist/extraction/wasm-runtime-flags.d.ts +15 -0
- package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
- package/lib/dist/extraction/wasm-runtime-flags.js +18 -89
- package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -1
- package/lib/dist/file-limits.d.ts +8 -0
- package/lib/dist/file-limits.d.ts.map +1 -1
- package/lib/dist/file-limits.js +13 -28
- package/lib/dist/file-limits.js.map +1 -1
- package/lib/dist/graph/branch-guards.d.ts.map +1 -1
- package/lib/dist/graph/branch-guards.js +4 -251
- package/lib/dist/graph/branch-guards.js.map +1 -1
- package/lib/dist/graph/call-sites.d.ts +12 -0
- package/lib/dist/graph/call-sites.d.ts.map +1 -0
- package/lib/dist/graph/call-sites.js +17 -0
- package/lib/dist/graph/call-sites.js.map +1 -0
- package/lib/dist/graph/cobol-copybooks.d.ts +75 -0
- package/lib/dist/graph/cobol-copybooks.d.ts.map +1 -0
- package/lib/dist/graph/cobol-copybooks.js +45 -0
- package/lib/dist/graph/cobol-copybooks.js.map +1 -0
- package/lib/dist/graph/dead-code.d.ts +26 -4
- package/lib/dist/graph/dead-code.d.ts.map +1 -1
- package/lib/dist/graph/dead-code.js +157 -311
- package/lib/dist/graph/dead-code.js.map +1 -1
- package/lib/dist/graph/dynamic-boundary-report.js +1 -88
- package/lib/dist/graph/dynamic-boundary-report.js.map +1 -1
- package/lib/dist/graph/file-cycles.d.ts +20 -0
- package/lib/dist/graph/file-cycles.d.ts.map +1 -0
- package/lib/dist/graph/file-cycles.js +79 -0
- package/lib/dist/graph/file-cycles.js.map +1 -0
- package/lib/dist/graph/file-drift.d.ts +35 -0
- package/lib/dist/graph/file-drift.d.ts.map +1 -0
- package/lib/dist/graph/file-drift.js +46 -0
- package/lib/dist/graph/file-drift.js.map +1 -0
- package/lib/dist/graph/go-package.d.ts +27 -0
- package/lib/dist/graph/go-package.d.ts.map +1 -0
- package/lib/dist/graph/go-package.js +49 -0
- package/lib/dist/graph/go-package.js.map +1 -0
- package/lib/dist/graph/index.d.ts +2 -0
- package/lib/dist/graph/index.d.ts.map +1 -1
- package/lib/dist/graph/index.js +4 -6
- package/lib/dist/graph/index.js.map +1 -1
- package/lib/dist/graph/named-symbol-flow.d.ts +5 -1
- package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -1
- package/lib/dist/graph/named-symbol-flow.js +82 -223
- package/lib/dist/graph/named-symbol-flow.js.map +1 -1
- package/lib/dist/graph/owning-package.d.ts +59 -0
- package/lib/dist/graph/owning-package.d.ts.map +1 -0
- package/lib/dist/graph/owning-package.js +120 -0
- package/lib/dist/graph/owning-package.js.map +1 -0
- package/lib/dist/graph/queries.d.ts +6 -3
- package/lib/dist/graph/queries.d.ts.map +1 -1
- package/lib/dist/graph/queries.js +4 -137
- package/lib/dist/graph/queries.js.map +1 -1
- package/lib/dist/graph/symbol-lookup.d.ts +15 -3
- package/lib/dist/graph/symbol-lookup.d.ts.map +1 -1
- package/lib/dist/graph/symbol-lookup.js +47 -89
- package/lib/dist/graph/symbol-lookup.js.map +1 -1
- package/lib/dist/graph/symbol-references.d.ts +86 -0
- package/lib/dist/graph/symbol-references.d.ts.map +1 -0
- package/lib/dist/graph/symbol-references.js +304 -0
- package/lib/dist/graph/symbol-references.js.map +1 -0
- package/lib/dist/graph/synthesized-hop.d.ts +37 -0
- package/lib/dist/graph/synthesized-hop.d.ts.map +1 -0
- package/lib/dist/graph/synthesized-hop.js +62 -0
- package/lib/dist/graph/synthesized-hop.js.map +1 -0
- package/lib/dist/graph/test-code.d.ts +33 -0
- package/lib/dist/graph/test-code.d.ts.map +1 -0
- package/lib/dist/graph/test-code.js +104 -0
- package/lib/dist/graph/test-code.js.map +1 -0
- package/lib/dist/graph/traversal.d.ts +31 -2
- package/lib/dist/graph/traversal.d.ts.map +1 -1
- package/lib/dist/graph/traversal.js +96 -226
- package/lib/dist/graph/traversal.js.map +1 -1
- package/lib/dist/graph/type-hierarchy.js +0 -138
- package/lib/dist/graph/type-hierarchy.js.map +1 -1
- package/lib/dist/index.d.ts +214 -26
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +736 -1112
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/beta-signup.js +0 -39
- package/lib/dist/installer/beta-signup.js.map +1 -1
- package/lib/dist/installer/config-writer.js +0 -24
- package/lib/dist/installer/config-writer.js.map +1 -1
- package/lib/dist/installer/index.d.ts +13 -6
- package/lib/dist/installer/index.d.ts.map +1 -1
- package/lib/dist/installer/index.js +27 -160
- package/lib/dist/installer/index.js.map +1 -1
- package/lib/dist/installer/instructions-template.d.ts +16 -1
- package/lib/dist/installer/instructions-template.d.ts.map +1 -1
- package/lib/dist/installer/instructions-template.js +10 -38
- package/lib/dist/installer/instructions-template.js.map +1 -1
- package/lib/dist/installer/targets/antigravity.js +0 -113
- package/lib/dist/installer/targets/antigravity.js.map +1 -1
- package/lib/dist/installer/targets/bob.d.ts +20 -0
- package/lib/dist/installer/targets/bob.d.ts.map +1 -0
- package/lib/dist/installer/targets/bob.js +83 -0
- package/lib/dist/installer/targets/bob.js.map +1 -0
- package/lib/dist/installer/targets/claude.d.ts.map +1 -1
- package/lib/dist/installer/targets/claude.js +1 -185
- package/lib/dist/installer/targets/claude.js.map +1 -1
- package/lib/dist/installer/targets/codex.d.ts.map +1 -1
- package/lib/dist/installer/targets/codex.js +17 -109
- package/lib/dist/installer/targets/codex.js.map +1 -1
- package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -1
- package/lib/dist/installer/targets/copilot-cli.js +2 -54
- package/lib/dist/installer/targets/copilot-cli.js.map +1 -1
- package/lib/dist/installer/targets/copilot-jetbrains.js +0 -57
- package/lib/dist/installer/targets/copilot-jetbrains.js.map +1 -1
- package/lib/dist/installer/targets/copilot-vscode.js +0 -58
- package/lib/dist/installer/targets/copilot-vscode.js.map +1 -1
- package/lib/dist/installer/targets/cursor.js +7 -88
- package/lib/dist/installer/targets/cursor.js.map +1 -1
- package/lib/dist/installer/targets/droid.d.ts +18 -0
- package/lib/dist/installer/targets/droid.d.ts.map +1 -0
- package/lib/dist/installer/targets/droid.js +92 -0
- package/lib/dist/installer/targets/droid.js.map +1 -0
- package/lib/dist/installer/targets/dsh.d.ts +35 -0
- package/lib/dist/installer/targets/dsh.d.ts.map +1 -0
- package/lib/dist/installer/targets/dsh.js +267 -0
- package/lib/dist/installer/targets/dsh.js.map +1 -0
- package/lib/dist/installer/targets/gemini.js +0 -37
- package/lib/dist/installer/targets/gemini.js.map +1 -1
- package/lib/dist/installer/targets/grok.d.ts +25 -0
- package/lib/dist/installer/targets/grok.d.ts.map +1 -0
- package/lib/dist/installer/targets/grok.js +96 -0
- package/lib/dist/installer/targets/grok.js.map +1 -0
- package/lib/dist/installer/targets/hermes.d.ts +19 -7
- package/lib/dist/installer/targets/hermes.d.ts.map +1 -1
- package/lib/dist/installer/targets/hermes.js +218 -214
- package/lib/dist/installer/targets/hermes.js.map +1 -1
- package/lib/dist/installer/targets/json-config.d.ts +45 -0
- package/lib/dist/installer/targets/json-config.d.ts.map +1 -0
- package/lib/dist/installer/targets/json-config.js +128 -0
- package/lib/dist/installer/targets/json-config.js.map +1 -0
- package/lib/dist/installer/targets/kimi.d.ts +21 -0
- package/lib/dist/installer/targets/kimi.d.ts.map +1 -0
- package/lib/dist/installer/targets/kimi.js +97 -0
- package/lib/dist/installer/targets/kimi.js.map +1 -0
- package/lib/dist/installer/targets/kiro.js +1 -41
- package/lib/dist/installer/targets/kiro.js.map +1 -1
- package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
- package/lib/dist/installer/targets/opencode.js +1 -103
- package/lib/dist/installer/targets/opencode.js.map +1 -1
- package/lib/dist/installer/targets/pi.d.ts +24 -0
- package/lib/dist/installer/targets/pi.d.ts.map +1 -0
- package/lib/dist/installer/targets/pi.js +100 -0
- package/lib/dist/installer/targets/pi.js.map +1 -0
- package/lib/dist/installer/targets/qoder.d.ts +23 -0
- package/lib/dist/installer/targets/qoder.d.ts.map +1 -0
- package/lib/dist/installer/targets/qoder.js +83 -0
- package/lib/dist/installer/targets/qoder.js.map +1 -0
- package/lib/dist/installer/targets/qwen.d.ts +21 -0
- package/lib/dist/installer/targets/qwen.d.ts.map +1 -0
- package/lib/dist/installer/targets/qwen.js +115 -0
- package/lib/dist/installer/targets/qwen.js.map +1 -0
- package/lib/dist/installer/targets/registry.d.ts.map +1 -1
- package/lib/dist/installer/targets/registry.js +18 -25
- package/lib/dist/installer/targets/registry.js.map +1 -1
- package/lib/dist/installer/targets/shared.d.ts +83 -13
- package/lib/dist/installer/targets/shared.d.ts.map +1 -1
- package/lib/dist/installer/targets/shared.js +201 -131
- package/lib/dist/installer/targets/shared.js.map +1 -1
- package/lib/dist/installer/targets/toml.d.ts +82 -6
- package/lib/dist/installer/targets/toml.d.ts.map +1 -1
- package/lib/dist/installer/targets/toml.js +318 -112
- package/lib/dist/installer/targets/toml.js.map +1 -1
- package/lib/dist/installer/targets/types.d.ts +1 -1
- package/lib/dist/installer/targets/types.d.ts.map +1 -1
- package/lib/dist/installer/targets/types.js +0 -13
- package/lib/dist/installer/targets/types.js.map +1 -1
- package/lib/dist/installer/targets/windsurf.d.ts +22 -0
- package/lib/dist/installer/targets/windsurf.d.ts.map +1 -0
- package/lib/dist/installer/targets/windsurf.js +90 -0
- package/lib/dist/installer/targets/windsurf.js.map +1 -0
- package/lib/dist/lazy-engine.d.ts +22 -0
- package/lib/dist/lazy-engine.d.ts.map +1 -0
- package/lib/dist/lazy-engine.js +16 -0
- package/lib/dist/lazy-engine.js.map +1 -0
- package/lib/dist/mcp/answer-freshness.js +0 -6
- package/lib/dist/mcp/answer-freshness.js.map +1 -1
- package/lib/dist/mcp/daemon-manager.js +2 -23
- package/lib/dist/mcp/daemon-manager.js.map +1 -1
- package/lib/dist/mcp/daemon-paths.d.ts +2 -0
- package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-paths.js +9 -85
- package/lib/dist/mcp/daemon-paths.js.map +1 -1
- package/lib/dist/mcp/daemon-proof.d.ts +19 -0
- package/lib/dist/mcp/daemon-proof.d.ts.map +1 -0
- package/lib/dist/mcp/daemon-proof.js +126 -0
- package/lib/dist/mcp/daemon-proof.js.map +1 -0
- package/lib/dist/mcp/daemon-registry.d.ts +47 -2
- package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-registry.js +188 -139
- package/lib/dist/mcp/daemon-registry.js.map +1 -1
- package/lib/dist/mcp/daemon.d.ts +69 -0
- package/lib/dist/mcp/daemon.d.ts.map +1 -1
- package/lib/dist/mcp/daemon.js +186 -376
- package/lib/dist/mcp/daemon.js.map +1 -1
- package/lib/dist/mcp/dynamic-boundaries.js +4 -78
- package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
- package/lib/dist/mcp/early-ppid.js +0 -24
- package/lib/dist/mcp/early-ppid.js.map +1 -1
- package/lib/dist/mcp/engine.d.ts +24 -0
- package/lib/dist/mcp/engine.d.ts.map +1 -1
- package/lib/dist/mcp/engine.js +47 -152
- package/lib/dist/mcp/engine.js.map +1 -1
- package/lib/dist/mcp/explore-dedup.js +0 -108
- package/lib/dist/mcp/explore-dedup.js.map +1 -1
- package/lib/dist/mcp/explore-diagnostics.d.ts +6 -0
- package/lib/dist/mcp/explore-diagnostics.d.ts.map +1 -1
- package/lib/dist/mcp/explore-diagnostics.js +8 -116
- package/lib/dist/mcp/explore-diagnostics.js.map +1 -1
- package/lib/dist/mcp/explore-one-symbol.d.ts +77 -0
- package/lib/dist/mcp/explore-one-symbol.d.ts.map +1 -0
- package/lib/dist/mcp/explore-one-symbol.js +431 -0
- package/lib/dist/mcp/explore-one-symbol.js.map +1 -0
- package/lib/dist/mcp/explore-session-state.js +0 -129
- package/lib/dist/mcp/explore-session-state.js.map +1 -1
- package/lib/dist/mcp/hook-client.d.ts +44 -0
- package/lib/dist/mcp/hook-client.d.ts.map +1 -0
- package/lib/dist/mcp/hook-client.js +202 -0
- package/lib/dist/mcp/hook-client.js.map +1 -0
- package/lib/dist/mcp/index-freshness-worker.js +1 -6
- package/lib/dist/mcp/index-freshness-worker.js.map +1 -1
- package/lib/dist/mcp/index-freshness.js +0 -15
- package/lib/dist/mcp/index-freshness.js.map +1 -1
- package/lib/dist/mcp/index-version-warning.d.ts +21 -0
- package/lib/dist/mcp/index-version-warning.d.ts.map +1 -0
- package/lib/dist/mcp/index-version-warning.js +38 -0
- package/lib/dist/mcp/index-version-warning.js.map +1 -0
- package/lib/dist/mcp/index.d.ts +29 -1
- package/lib/dist/mcp/index.d.ts.map +1 -1
- package/lib/dist/mcp/index.js +131 -300
- package/lib/dist/mcp/index.js.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.d.ts +13 -3
- package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.js +106 -121
- package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
- package/lib/dist/mcp/opencode-tool-names.d.ts +32 -0
- package/lib/dist/mcp/opencode-tool-names.d.ts.map +1 -0
- package/lib/dist/mcp/opencode-tool-names.js +24 -0
- package/lib/dist/mcp/opencode-tool-names.js.map +1 -0
- package/lib/dist/mcp/ppid-watchdog.js +0 -24
- package/lib/dist/mcp/ppid-watchdog.js.map +1 -1
- package/lib/dist/mcp/process-identity.d.ts +42 -0
- package/lib/dist/mcp/process-identity.d.ts.map +1 -0
- package/lib/dist/mcp/process-identity.js +130 -0
- package/lib/dist/mcp/process-identity.js.map +1 -0
- package/lib/dist/mcp/project-lifecycle.d.ts +6 -0
- package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -1
- package/lib/dist/mcp/project-lifecycle.js +70 -19
- package/lib/dist/mcp/project-lifecycle.js.map +1 -1
- package/lib/dist/mcp/prompt-explore.d.ts +19 -0
- package/lib/dist/mcp/prompt-explore.d.ts.map +1 -0
- package/lib/dist/mcp/prompt-explore.js +6 -0
- package/lib/dist/mcp/prompt-explore.js.map +1 -0
- package/lib/dist/mcp/proxy.d.ts +25 -7
- package/lib/dist/mcp/proxy.d.ts.map +1 -1
- package/lib/dist/mcp/proxy.js +145 -274
- package/lib/dist/mcp/proxy.js.map +1 -1
- package/lib/dist/mcp/query-pool.d.ts +52 -3
- package/lib/dist/mcp/query-pool.d.ts.map +1 -1
- package/lib/dist/mcp/query-pool.js +114 -123
- package/lib/dist/mcp/query-pool.js.map +1 -1
- package/lib/dist/mcp/query-worker.js +24 -36
- package/lib/dist/mcp/query-worker.js.map +1 -1
- package/lib/dist/mcp/server-instructions.d.ts +18 -0
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
- package/lib/dist/mcp/server-instructions.js +12 -32
- package/lib/dist/mcp/server-instructions.js.map +1 -1
- package/lib/dist/mcp/session.d.ts +46 -0
- package/lib/dist/mcp/session.d.ts.map +1 -1
- package/lib/dist/mcp/session.js +70 -132
- package/lib/dist/mcp/session.js.map +1 -1
- package/lib/dist/mcp/startup-handshake.js +1 -48
- package/lib/dist/mcp/startup-handshake.js.map +1 -1
- package/lib/dist/mcp/stdin-teardown.js +0 -28
- package/lib/dist/mcp/stdin-teardown.js.map +1 -1
- package/lib/dist/mcp/stdout-teardown.d.ts +26 -0
- package/lib/dist/mcp/stdout-teardown.d.ts.map +1 -0
- package/lib/dist/mcp/stdout-teardown.js +20 -0
- package/lib/dist/mcp/stdout-teardown.js.map +1 -0
- package/lib/dist/mcp/tools.d.ts +157 -18
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +797 -3621
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/mcp/transport.d.ts.map +1 -1
- package/lib/dist/mcp/transport.js +4 -96
- package/lib/dist/mcp/transport.js.map +1 -1
- package/lib/dist/mcp/version.d.ts +13 -1
- package/lib/dist/mcp/version.d.ts.map +1 -1
- package/lib/dist/mcp/version.js +19 -21
- package/lib/dist/mcp/version.js.map +1 -1
- package/lib/dist/mcp/writer-lock.d.ts +11 -0
- package/lib/dist/mcp/writer-lock.d.ts.map +1 -1
- package/lib/dist/mcp/writer-lock.js +49 -46
- package/lib/dist/mcp/writer-lock.js.map +1 -1
- package/lib/dist/project-config.d.ts +20 -0
- package/lib/dist/project-config.d.ts.map +1 -1
- package/lib/dist/project-config.js +31 -140
- package/lib/dist/project-config.js.map +1 -1
- package/lib/dist/resolution/alias-binding.d.ts +7 -0
- package/lib/dist/resolution/alias-binding.d.ts.map +1 -1
- package/lib/dist/resolution/alias-binding.js +7 -56
- package/lib/dist/resolution/alias-binding.js.map +1 -1
- package/lib/dist/resolution/ambient-modules.d.ts +185 -0
- package/lib/dist/resolution/ambient-modules.d.ts.map +1 -0
- package/lib/dist/resolution/ambient-modules.js +732 -0
- package/lib/dist/resolution/ambient-modules.js.map +1 -0
- package/lib/dist/resolution/angular-template-synthesizer.d.ts +48 -1
- package/lib/dist/resolution/angular-template-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/angular-template-synthesizer.js +401 -65
- package/lib/dist/resolution/angular-template-synthesizer.js.map +1 -1
- package/lib/dist/resolution/c-feature-variants.d.ts +40 -0
- package/lib/dist/resolution/c-feature-variants.d.ts.map +1 -0
- package/lib/dist/resolution/c-feature-variants.js +249 -0
- package/lib/dist/resolution/c-feature-variants.js.map +1 -0
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.js +23 -391
- package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/lib/dist/resolution/c-macro-renames.d.ts +25 -0
- package/lib/dist/resolution/c-macro-renames.d.ts.map +1 -0
- package/lib/dist/resolution/c-macro-renames.js +95 -0
- package/lib/dist/resolution/c-macro-renames.js.map +1 -0
- package/lib/dist/resolution/callback-synthesizer.d.ts +19 -5
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +1395 -1343
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/const-alias-synthesizer.d.ts +48 -0
- package/lib/dist/resolution/const-alias-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/const-alias-synthesizer.js +234 -0
- package/lib/dist/resolution/const-alias-synthesizer.js.map +1 -0
- package/lib/dist/resolution/cooperative-yield.js +0 -27
- package/lib/dist/resolution/cooperative-yield.js.map +1 -1
- package/lib/dist/resolution/cpp-constructor.d.ts.map +1 -1
- package/lib/dist/resolution/cpp-constructor.js +15 -17
- package/lib/dist/resolution/cpp-constructor.js.map +1 -1
- package/lib/dist/resolution/cpp-includers.d.ts +46 -0
- package/lib/dist/resolution/cpp-includers.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-includers.js +153 -0
- package/lib/dist/resolution/cpp-includers.js.map +1 -0
- package/lib/dist/resolution/cpp-macro-visibility.d.ts +16 -0
- package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -1
- package/lib/dist/resolution/cpp-macro-visibility.js +17 -68
- package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -1
- package/lib/dist/resolution/cpp-namespaces.d.ts +54 -0
- package/lib/dist/resolution/cpp-namespaces.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-namespaces.js +151 -0
- package/lib/dist/resolution/cpp-namespaces.js.map +1 -0
- package/lib/dist/resolution/cpp-raw-strings.d.ts +33 -0
- package/lib/dist/resolution/cpp-raw-strings.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-raw-strings.js +167 -0
- package/lib/dist/resolution/cpp-raw-strings.js.map +1 -0
- package/lib/dist/resolution/cpp-supertypes.d.ts +118 -0
- package/lib/dist/resolution/cpp-supertypes.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-supertypes.js +322 -0
- package/lib/dist/resolution/cpp-supertypes.js.map +1 -0
- package/lib/dist/resolution/cpp-template-instantiations.d.ts +83 -0
- package/lib/dist/resolution/cpp-template-instantiations.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-template-instantiations.js +983 -0
- package/lib/dist/resolution/cpp-template-instantiations.js.map +1 -0
- package/lib/dist/resolution/cpp-type-aliases.d.ts +194 -0
- package/lib/dist/resolution/cpp-type-aliases.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-type-aliases.js +648 -0
- package/lib/dist/resolution/cpp-type-aliases.js.map +1 -0
- package/lib/dist/resolution/dart-libraries.d.ts +75 -0
- package/lib/dist/resolution/dart-libraries.d.ts.map +1 -0
- package/lib/dist/resolution/dart-libraries.js +721 -0
- package/lib/dist/resolution/dart-libraries.js.map +1 -0
- package/lib/dist/resolution/dart-local-scope.d.ts +41 -0
- package/lib/dist/resolution/dart-local-scope.d.ts.map +1 -0
- package/lib/dist/resolution/dart-local-scope.js +565 -0
- package/lib/dist/resolution/dart-local-scope.js.map +1 -0
- package/lib/dist/resolution/event-emitter-synthesizer.d.ts +39 -0
- package/lib/dist/resolution/event-emitter-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/event-emitter-synthesizer.js +656 -0
- package/lib/dist/resolution/event-emitter-synthesizer.js.map +1 -0
- package/lib/dist/resolution/expo-router-synthesizer.js +0 -52
- package/lib/dist/resolution/expo-router-synthesizer.js.map +1 -1
- package/lib/dist/resolution/frameworks/angular-router.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/angular-router.js +41 -208
- package/lib/dist/resolution/frameworks/angular-router.js.map +1 -1
- package/lib/dist/resolution/frameworks/aspnet-routes.d.ts +62 -0
- package/lib/dist/resolution/frameworks/aspnet-routes.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/aspnet-routes.js +382 -0
- package/lib/dist/resolution/frameworks/aspnet-routes.js.map +1 -0
- package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/astro.js +4 -60
- package/lib/dist/resolution/frameworks/astro.js.map +1 -1
- package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -1
- package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/cargo-workspace.js +65 -15
- package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -1
- package/lib/dist/resolution/frameworks/cics.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/cics.js +7 -33
- package/lib/dist/resolution/frameworks/cics.js.map +1 -1
- package/lib/dist/resolution/frameworks/codeigniter.d.ts +23 -0
- package/lib/dist/resolution/frameworks/codeigniter.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/codeigniter.js +271 -0
- package/lib/dist/resolution/frameworks/codeigniter.js.map +1 -0
- package/lib/dist/resolution/frameworks/component-folder.d.ts +17 -0
- package/lib/dist/resolution/frameworks/component-folder.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/component-folder.js +11 -0
- package/lib/dist/resolution/frameworks/component-folder.js.map +1 -0
- package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/csharp.js +85 -102
- package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
- package/lib/dist/resolution/frameworks/drupal.d.ts +17 -8
- package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/drupal.js +377 -142
- package/lib/dist/resolution/frameworks/drupal.js.map +1 -1
- package/lib/dist/resolution/frameworks/elysia.d.ts +38 -0
- package/lib/dist/resolution/frameworks/elysia.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/elysia.js +683 -0
- package/lib/dist/resolution/frameworks/elysia.js.map +1 -0
- package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/expo-modules.js +8 -88
- package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
- package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/expo-router.js +9 -190
- package/lib/dist/resolution/frameworks/expo-router.js.map +1 -1
- package/lib/dist/resolution/frameworks/express.d.ts +48 -1
- package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/express.js +193 -199
- package/lib/dist/resolution/frameworks/express.js.map +1 -1
- package/lib/dist/resolution/frameworks/fabric.js +1 -104
- package/lib/dist/resolution/frameworks/fabric.js.map +1 -1
- package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/go.js +14 -43
- package/lib/dist/resolution/frameworks/go.js.map +1 -1
- package/lib/dist/resolution/frameworks/goframe.js +1 -55
- package/lib/dist/resolution/frameworks/goframe.js.map +1 -1
- package/lib/dist/resolution/frameworks/index.d.ts +14 -0
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +16 -50
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/java.js +203 -129
- package/lib/dist/resolution/frameworks/java.js.map +1 -1
- package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/laravel.js +71 -136
- package/lib/dist/resolution/frameworks/laravel.js.map +1 -1
- package/lib/dist/resolution/frameworks/name-heuristic.js +0 -12
- package/lib/dist/resolution/frameworks/name-heuristic.js.map +1 -1
- package/lib/dist/resolution/frameworks/nestjs.js +2 -199
- package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
- package/lib/dist/resolution/frameworks/next-proxy.d.ts +67 -0
- package/lib/dist/resolution/frameworks/next-proxy.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/next-proxy.js +239 -0
- package/lib/dist/resolution/frameworks/next-proxy.js.map +1 -0
- package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/nextjs.js +10 -66
- package/lib/dist/resolution/frameworks/nextjs.js.map +1 -1
- package/lib/dist/resolution/frameworks/object-literal.js +0 -21
- package/lib/dist/resolution/frameworks/object-literal.js.map +1 -1
- package/lib/dist/resolution/frameworks/package-deps.d.ts +11 -7
- package/lib/dist/resolution/frameworks/package-deps.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/package-deps.js +35 -26
- package/lib/dist/resolution/frameworks/package-deps.js.map +1 -1
- package/lib/dist/resolution/frameworks/page-component.js +0 -14
- package/lib/dist/resolution/frameworks/page-component.js.map +1 -1
- package/lib/dist/resolution/frameworks/play.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/play.js +26 -34
- package/lib/dist/resolution/frameworks/play.js.map +1 -1
- package/lib/dist/resolution/frameworks/python.js +5 -102
- package/lib/dist/resolution/frameworks/python.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.js +1 -166
- package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-router.d.ts +13 -4
- package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react-router.js +10 -82
- package/lib/dist/resolution/frameworks/react-router.js.map +1 -1
- package/lib/dist/resolution/frameworks/react.d.ts +57 -0
- package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react.js +1449 -191
- package/lib/dist/resolution/frameworks/react.js.map +1 -1
- package/lib/dist/resolution/frameworks/ruby.js +1 -61
- package/lib/dist/resolution/frameworks/ruby.js.map +1 -1
- package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/rust.js +35 -56
- package/lib/dist/resolution/frameworks/rust.js.map +1 -1
- package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/svelte.js +7 -75
- package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
- package/lib/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/sveltekit-router.js +8 -46
- package/lib/dist/resolution/frameworks/sveltekit-router.js.map +1 -1
- package/lib/dist/resolution/frameworks/swift-objc.js +0 -97
- package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -1
- package/lib/dist/resolution/frameworks/swift.js +0 -97
- package/lib/dist/resolution/frameworks/swift.js.map +1 -1
- package/lib/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/tanstack-router.js +9 -130
- package/lib/dist/resolution/frameworks/tanstack-router.js.map +1 -1
- package/lib/dist/resolution/frameworks/terraform.js +1 -85
- package/lib/dist/resolution/frameworks/terraform.js.map +1 -1
- package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/vue-router.js +11 -134
- package/lib/dist/resolution/frameworks/vue-router.js.map +1 -1
- package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/vue.js +42 -114
- package/lib/dist/resolution/frameworks/vue.js.map +1 -1
- package/lib/dist/resolution/go-func-field-synthesizer.d.ts +58 -0
- package/lib/dist/resolution/go-func-field-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/go-func-field-synthesizer.js +696 -0
- package/lib/dist/resolution/go-func-field-synthesizer.js.map +1 -0
- package/lib/dist/resolution/go-module.d.ts +23 -7
- package/lib/dist/resolution/go-module.d.ts.map +1 -1
- package/lib/dist/resolution/go-module.js +21 -24
- package/lib/dist/resolution/go-module.js.map +1 -1
- package/lib/dist/resolution/go-stdlib-methods.d.ts +9 -0
- package/lib/dist/resolution/go-stdlib-methods.d.ts.map +1 -0
- package/lib/dist/resolution/go-stdlib-methods.js +224 -0
- package/lib/dist/resolution/go-stdlib-methods.js.map +1 -0
- package/lib/dist/resolution/goframe-synthesizer.js +2 -53
- package/lib/dist/resolution/goframe-synthesizer.js.map +1 -1
- package/lib/dist/resolution/import-resolver.d.ts +278 -29
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +1825 -1396
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts +517 -6
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +1604 -1042
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/js-builtins.d.ts +23 -0
- package/lib/dist/resolution/js-builtins.d.ts.map +1 -1
- package/lib/dist/resolution/js-builtins.js +34 -14
- package/lib/dist/resolution/js-builtins.js.map +1 -1
- package/lib/dist/resolution/js-class-expressions.d.ts +48 -0
- package/lib/dist/resolution/js-class-expressions.d.ts.map +1 -0
- package/lib/dist/resolution/js-class-expressions.js +25 -0
- package/lib/dist/resolution/js-class-expressions.js.map +1 -0
- package/lib/dist/resolution/js-super-calls.d.ts +18 -0
- package/lib/dist/resolution/js-super-calls.d.ts.map +1 -0
- package/lib/dist/resolution/js-super-calls.js +94 -0
- package/lib/dist/resolution/js-super-calls.js.map +1 -0
- package/lib/dist/resolution/jsx-code.d.ts +28 -0
- package/lib/dist/resolution/jsx-code.d.ts.map +1 -0
- package/lib/dist/resolution/jsx-code.js +459 -0
- package/lib/dist/resolution/jsx-code.js.map +1 -0
- package/lib/dist/resolution/lru-cache.d.ts +5 -13
- package/lib/dist/resolution/lru-cache.d.ts.map +1 -1
- package/lib/dist/resolution/lru-cache.js +43 -32
- package/lib/dist/resolution/lru-cache.js.map +1 -1
- package/lib/dist/resolution/memory-budget.js +0 -52
- package/lib/dist/resolution/memory-budget.js.map +1 -1
- package/lib/dist/resolution/module-importers.d.ts +210 -0
- package/lib/dist/resolution/module-importers.d.ts.map +1 -0
- package/lib/dist/resolution/module-importers.js +673 -0
- package/lib/dist/resolution/module-importers.js.map +1 -0
- package/lib/dist/resolution/name-matcher.d.ts +986 -7
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +24176 -6745
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/next-router-synthesizer.d.ts +19 -0
- package/lib/dist/resolution/next-router-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/next-router-synthesizer.js +46 -28
- package/lib/dist/resolution/next-router-synthesizer.js.map +1 -1
- package/lib/dist/resolution/override-parameters.d.ts +40 -0
- package/lib/dist/resolution/override-parameters.d.ts.map +1 -0
- package/lib/dist/resolution/override-parameters.js +339 -0
- package/lib/dist/resolution/override-parameters.js.map +1 -0
- package/lib/dist/resolution/parameter-flow.d.ts +218 -0
- package/lib/dist/resolution/parameter-flow.d.ts.map +1 -0
- package/lib/dist/resolution/parameter-flow.js +474 -0
- package/lib/dist/resolution/parameter-flow.js.map +1 -0
- package/lib/dist/resolution/pascal-scope.d.ts +91 -0
- package/lib/dist/resolution/pascal-scope.d.ts.map +1 -0
- package/lib/dist/resolution/pascal-scope.js +961 -0
- package/lib/dist/resolution/pascal-scope.js.map +1 -0
- package/lib/dist/resolution/path-aliases.d.ts +32 -4
- package/lib/dist/resolution/path-aliases.d.ts.map +1 -1
- package/lib/dist/resolution/path-aliases.js +43 -110
- package/lib/dist/resolution/path-aliases.js.map +1 -1
- package/lib/dist/resolution/php-web-root.d.ts +39 -0
- package/lib/dist/resolution/php-web-root.d.ts.map +1 -0
- package/lib/dist/resolution/php-web-root.js +141 -0
- package/lib/dist/resolution/php-web-root.js.map +1 -0
- package/lib/dist/resolution/project-scans.d.ts +38 -0
- package/lib/dist/resolution/project-scans.d.ts.map +1 -0
- package/lib/dist/resolution/project-scans.js +30 -0
- package/lib/dist/resolution/project-scans.js.map +1 -0
- package/lib/dist/resolution/python-overloads.d.ts +10 -0
- package/lib/dist/resolution/python-overloads.d.ts.map +1 -0
- package/lib/dist/resolution/python-overloads.js +75 -0
- package/lib/dist/resolution/python-overloads.js.map +1 -0
- package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/react-router-synthesizer.js +3 -55
- package/lib/dist/resolution/react-router-synthesizer.js.map +1 -1
- package/lib/dist/resolution/resolver-pool.d.ts +23 -2
- package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
- package/lib/dist/resolution/resolver-pool.js +43 -111
- package/lib/dist/resolution/resolver-pool.js.map +1 -1
- package/lib/dist/resolution/resolver-worker.d.ts +1 -1
- package/lib/dist/resolution/resolver-worker.d.ts.map +1 -1
- package/lib/dist/resolution/resolver-worker.js +8 -37
- package/lib/dist/resolution/resolver-worker.js.map +1 -1
- package/lib/dist/resolution/resurrect-ref.d.ts +25 -0
- package/lib/dist/resolution/resurrect-ref.d.ts.map +1 -0
- package/lib/dist/resolution/resurrect-ref.js +19 -0
- package/lib/dist/resolution/resurrect-ref.js.map +1 -0
- package/lib/dist/resolution/ruby-constant-paths.d.ts +56 -0
- package/lib/dist/resolution/ruby-constant-paths.d.ts.map +1 -0
- package/lib/dist/resolution/ruby-constant-paths.js +255 -0
- package/lib/dist/resolution/ruby-constant-paths.js.map +1 -0
- package/lib/dist/resolution/ruby-parameter-flow.d.ts +10 -0
- package/lib/dist/resolution/ruby-parameter-flow.d.ts.map +1 -0
- package/lib/dist/resolution/ruby-parameter-flow.js +801 -0
- package/lib/dist/resolution/ruby-parameter-flow.js.map +1 -0
- package/lib/dist/resolution/rust-scopes.d.ts +120 -0
- package/lib/dist/resolution/rust-scopes.d.ts.map +1 -0
- package/lib/dist/resolution/rust-scopes.js +730 -0
- package/lib/dist/resolution/rust-scopes.js.map +1 -0
- package/lib/dist/resolution/shopify-themes.d.ts +10 -0
- package/lib/dist/resolution/shopify-themes.d.ts.map +1 -0
- package/lib/dist/resolution/shopify-themes.js +19 -0
- package/lib/dist/resolution/shopify-themes.js.map +1 -0
- package/lib/dist/resolution/strip-comments.d.ts +20 -1
- package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
- package/lib/dist/resolution/strip-comments.js +164 -119
- package/lib/dist/resolution/strip-comments.js.map +1 -1
- package/lib/dist/resolution/sveltekit-synthesizer.js +0 -64
- package/lib/dist/resolution/sveltekit-synthesizer.js.map +1 -1
- package/lib/dist/resolution/swift-objc-bridge.js +0 -160
- package/lib/dist/resolution/swift-objc-bridge.js.map +1 -1
- package/lib/dist/resolution/swift-type-visibility.d.ts.map +1 -1
- package/lib/dist/resolution/swift-type-visibility.js +62 -104
- package/lib/dist/resolution/swift-type-visibility.js.map +1 -1
- package/lib/dist/resolution/synth-utils.js +1 -22
- package/lib/dist/resolution/synth-utils.js.map +1 -1
- package/lib/dist/resolution/tanstack-router-synthesizer.js +0 -32
- package/lib/dist/resolution/tanstack-router-synthesizer.js.map +1 -1
- package/lib/dist/resolution/tauri-synthesizer.d.ts +37 -0
- package/lib/dist/resolution/tauri-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/tauri-synthesizer.js +1038 -0
- package/lib/dist/resolution/tauri-synthesizer.js.map +1 -0
- package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/tier-synthesizer.js +35 -177
- package/lib/dist/resolution/tier-synthesizer.js.map +1 -1
- package/lib/dist/resolution/type-parameters.d.ts +23 -0
- package/lib/dist/resolution/type-parameters.d.ts.map +1 -1
- package/lib/dist/resolution/type-parameters.js +52 -54
- package/lib/dist/resolution/type-parameters.js.map +1 -1
- package/lib/dist/resolution/types.d.ts +192 -11
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/resolution/types.js +0 -47
- package/lib/dist/resolution/types.js.map +1 -1
- package/lib/dist/resolution/vbnet-receivers.d.ts +92 -0
- package/lib/dist/resolution/vbnet-receivers.d.ts.map +1 -0
- package/lib/dist/resolution/vbnet-receivers.js +1482 -0
- package/lib/dist/resolution/vbnet-receivers.js.map +1 -0
- package/lib/dist/resolution/vue-router-synthesizer.js +0 -31
- package/lib/dist/resolution/vue-router-synthesizer.js.map +1 -1
- package/lib/dist/resolution/workspace-packages.d.ts +206 -15
- package/lib/dist/resolution/workspace-packages.d.ts.map +1 -1
- package/lib/dist/resolution/workspace-packages.js +573 -152
- package/lib/dist/resolution/workspace-packages.js.map +1 -1
- package/lib/dist/search/identifier-segments.js +2 -93
- package/lib/dist/search/identifier-segments.js.map +1 -1
- package/lib/dist/search/query-parser.js +0 -54
- package/lib/dist/search/query-parser.js.map +1 -1
- package/lib/dist/search/query-paths.js +0 -167
- package/lib/dist/search/query-paths.js.map +1 -1
- package/lib/dist/search/query-utils.d.ts +44 -0
- package/lib/dist/search/query-utils.d.ts.map +1 -1
- package/lib/dist/search/query-utils.js +120 -198
- package/lib/dist/search/query-utils.js.map +1 -1
- package/lib/dist/sync/git-hooks.d.ts +14 -5
- package/lib/dist/sync/git-hooks.d.ts.map +1 -1
- package/lib/dist/sync/git-hooks.js +118 -65
- package/lib/dist/sync/git-hooks.js.map +1 -1
- package/lib/dist/sync/index.js +0 -14
- package/lib/dist/sync/index.js.map +1 -1
- package/lib/dist/sync/watch-policy.js +0 -45
- package/lib/dist/sync/watch-policy.js.map +1 -1
- package/lib/dist/sync/watcher.d.ts +29 -11
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +83 -487
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/sync/worktree.d.ts +7 -2
- package/lib/dist/sync/worktree.d.ts.map +1 -1
- package/lib/dist/sync/worktree.js +24 -97
- package/lib/dist/sync/worktree.js.map +1 -1
- package/lib/dist/telemetry/index.d.ts.map +1 -1
- package/lib/dist/telemetry/index.js +15 -135
- package/lib/dist/telemetry/index.js.map +1 -1
- package/lib/dist/types.d.ts +46 -0
- package/lib/dist/types.d.ts.map +1 -1
- package/lib/dist/types.js +15 -44
- package/lib/dist/types.js.map +1 -1
- package/lib/dist/ui/color.js +0 -19
- package/lib/dist/ui/color.js.map +1 -1
- package/lib/dist/ui/glyphs.js +2 -45
- package/lib/dist/ui/glyphs.js.map +1 -1
- package/lib/dist/ui/shimmer-progress.js +0 -21
- package/lib/dist/ui/shimmer-progress.js.map +1 -1
- package/lib/dist/ui/shimmer-worker.js +0 -22
- package/lib/dist/ui/shimmer-worker.js.map +1 -1
- package/lib/dist/ui-server/api/deadcode.d.ts.map +1 -1
- package/lib/dist/ui-server/api/deadcode.js +2 -31
- package/lib/dist/ui-server/api/deadcode.js.map +1 -1
- package/lib/dist/ui-server/api/effects.js +0 -111
- package/lib/dist/ui-server/api/effects.js.map +1 -1
- package/lib/dist/ui-server/api/entrypoints.js +0 -142
- package/lib/dist/ui-server/api/entrypoints.js.map +1 -1
- package/lib/dist/ui-server/api/events.js +0 -145
- package/lib/dist/ui-server/api/events.js.map +1 -1
- package/lib/dist/ui-server/api/file.js +0 -80
- package/lib/dist/ui-server/api/file.js.map +1 -1
- package/lib/dist/ui-server/api/filecode.js +0 -95
- package/lib/dist/ui-server/api/filecode.js.map +1 -1
- package/lib/dist/ui-server/api/flow.js +0 -149
- package/lib/dist/ui-server/api/flow.js.map +1 -1
- package/lib/dist/ui-server/api/hierarchy.js +0 -28
- package/lib/dist/ui-server/api/hierarchy.js.map +1 -1
- package/lib/dist/ui-server/api/index.js +0 -88
- package/lib/dist/ui-server/api/index.js.map +1 -1
- package/lib/dist/ui-server/api/map.d.ts.map +1 -1
- package/lib/dist/ui-server/api/map.js +4 -317
- package/lib/dist/ui-server/api/map.js.map +1 -1
- package/lib/dist/ui-server/api/node.js +0 -111
- package/lib/dist/ui-server/api/node.js.map +1 -1
- package/lib/dist/ui-server/api/nodes.js +0 -16
- package/lib/dist/ui-server/api/nodes.js.map +1 -1
- package/lib/dist/ui-server/api/program.js +0 -90
- package/lib/dist/ui-server/api/program.js.map +1 -1
- package/lib/dist/ui-server/api/respond.js +0 -60
- package/lib/dist/ui-server/api/respond.js.map +1 -1
- package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -1
- package/lib/dist/ui-server/api/route-roots.js +2 -44
- package/lib/dist/ui-server/api/route-roots.js.map +1 -1
- package/lib/dist/ui-server/api/routes.d.ts.map +1 -1
- package/lib/dist/ui-server/api/routes.js +4 -60
- package/lib/dist/ui-server/api/routes.js.map +1 -1
- package/lib/dist/ui-server/api/screens.d.ts.map +1 -1
- package/lib/dist/ui-server/api/screens.js +4 -174
- package/lib/dist/ui-server/api/screens.js.map +1 -1
- package/lib/dist/ui-server/api/search.js +0 -62
- package/lib/dist/ui-server/api/search.js.map +1 -1
- package/lib/dist/ui-server/api/session.js +0 -58
- package/lib/dist/ui-server/api/session.js.map +1 -1
- package/lib/dist/ui-server/api/source.d.ts.map +1 -1
- package/lib/dist/ui-server/api/source.js +0 -161
- package/lib/dist/ui-server/api/source.js.map +1 -1
- package/lib/dist/ui-server/api/stats.js +0 -58
- package/lib/dist/ui-server/api/stats.js.map +1 -1
- package/lib/dist/ui-server/api/steps.d.ts.map +1 -1
- package/lib/dist/ui-server/api/steps.js +5 -381
- package/lib/dist/ui-server/api/steps.js.map +1 -1
- package/lib/dist/ui-server/api/trail-store.d.ts +3 -3
- package/lib/dist/ui-server/api/trail-store.d.ts.map +1 -1
- package/lib/dist/ui-server/api/trail-store.js +24 -106
- package/lib/dist/ui-server/api/trail-store.js.map +1 -1
- package/lib/dist/ui-server/api/trails.d.ts.map +1 -1
- package/lib/dist/ui-server/api/trails.js +19 -94
- package/lib/dist/ui-server/api/trails.js.map +1 -1
- package/lib/dist/ui-server/api/when.js +0 -36
- package/lib/dist/ui-server/api/when.js.map +1 -1
- package/lib/dist/ui-server/api/wire.js +0 -58
- package/lib/dist/ui-server/api/wire.js.map +1 -1
- package/lib/dist/ui-server/assets.js +0 -35
- package/lib/dist/ui-server/assets.js.map +1 -1
- package/lib/dist/ui-server/constants.js +0 -26
- package/lib/dist/ui-server/constants.js.map +1 -1
- package/lib/dist/ui-server/highlight/bounded-tokenize.js +0 -25
- package/lib/dist/ui-server/highlight/bounded-tokenize.js.map +1 -1
- package/lib/dist/ui-server/highlight/index.js +1 -132
- package/lib/dist/ui-server/highlight/index.js.map +1 -1
- package/lib/dist/ui-server/highlight/languages.d.ts +3 -3
- package/lib/dist/ui-server/highlight/languages.js +0 -31
- package/lib/dist/ui-server/highlight/languages.js.map +1 -1
- package/lib/dist/ui-server/highlight/tokenize-worker.js +0 -5
- package/lib/dist/ui-server/highlight/tokenize-worker.js.map +1 -1
- package/lib/dist/ui-server/index.d.ts +25 -0
- package/lib/dist/ui-server/index.d.ts.map +1 -1
- package/lib/dist/ui-server/index.js +35 -103
- package/lib/dist/ui-server/index.js.map +1 -1
- package/lib/dist/ui-server/open-browser.js +0 -34
- package/lib/dist/ui-server/open-browser.js.map +1 -1
- package/lib/dist/ui-server/security.d.ts +5 -0
- package/lib/dist/ui-server/security.d.ts.map +1 -1
- package/lib/dist/ui-server/security.js +11 -147
- package/lib/dist/ui-server/security.js.map +1 -1
- package/lib/dist/ui-server/static.js +0 -41
- package/lib/dist/ui-server/static.js.map +1 -1
- package/lib/dist/upgrade/index.d.ts +18 -5
- package/lib/dist/upgrade/index.d.ts.map +1 -1
- package/lib/dist/upgrade/index.js +73 -229
- package/lib/dist/upgrade/index.js.map +1 -1
- package/lib/dist/upgrade/remove-binary.js +2 -67
- package/lib/dist/upgrade/remove-binary.js.map +1 -1
- package/lib/dist/upgrade/update-check.js +1 -81
- package/lib/dist/upgrade/update-check.js.map +1 -1
- package/lib/dist/utils.d.ts +69 -1
- package/lib/dist/utils.d.ts.map +1 -1
- package/lib/dist/utils.js +224 -266
- package/lib/dist/utils.js.map +1 -1
- package/lib/dist/worker-teardown.js +0 -47
- package/lib/dist/worker-teardown.js.map +1 -1
- package/lib/kernel/codegraph-kernel.node +2 -2
- package/lib/node_modules/.package-lock.json +4 -4
- package/lib/node_modules/ignore/README.md +138 -8
- package/lib/node_modules/ignore/index.d.ts +56 -20
- package/lib/node_modules/ignore/index.js +1033 -221
- package/lib/node_modules/ignore/legacy.js +871 -178
- package/lib/node_modules/ignore/package.json +10 -4
- package/lib/package.json +14 -8
- package/node.exe +2 -2
- package/package.json +1 -1
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Import Resolver
|
|
4
|
-
*
|
|
5
|
-
* Resolves import paths to actual files and symbols.
|
|
6
|
-
*/
|
|
7
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
3
|
if (k2 === undefined) k2 = k;
|
|
9
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -38,46 +33,64 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
33
|
};
|
|
39
34
|
})();
|
|
40
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.REEXPORT_MAX_DEPTH = exports.CPP_COMPILE_DB_FILES = exports.ESM_IMPORT_LANGUAGES = void 0;
|
|
41
37
|
exports.isNixPathImportRef = isNixPathImportRef;
|
|
38
|
+
exports.isStatedDefaultExport = isStatedDefaultExport;
|
|
42
39
|
exports.clearImportResolverMemos = clearImportResolverMemos;
|
|
43
40
|
exports.resolveImportPath = resolveImportPath;
|
|
41
|
+
exports.pythonRootFingerprint = pythonRootFingerprint;
|
|
42
|
+
exports.pythonReopenScope = pythonReopenScope;
|
|
43
|
+
exports.pythonScriptModuleScope = pythonScriptModuleScope;
|
|
44
|
+
exports.pythonPackageImporters = pythonPackageImporters;
|
|
44
45
|
exports.isExternalImport = isExternalImport;
|
|
45
|
-
exports.
|
|
46
|
-
exports.
|
|
46
|
+
exports.packageJsonMain = packageJsonMain;
|
|
47
|
+
exports.loadCppIncludeDirsFromCompileDB = loadCppIncludeDirsFromCompileDB;
|
|
48
|
+
exports.readCompileDbIncludeDirs = readCompileDbIncludeDirs;
|
|
49
|
+
exports.loadCppIncludeDirsHeuristic = loadCppIncludeDirsHeuristic;
|
|
47
50
|
exports.isPhpIncludePathRef = isPhpIncludePathRef;
|
|
48
51
|
exports.isCobolCopybookRef = isCobolCopybookRef;
|
|
52
|
+
exports.isDartImportRef = isDartImportRef;
|
|
53
|
+
exports.isLuaRequireRef = isLuaRequireRef;
|
|
49
54
|
exports.extractImportMappings = extractImportMappings;
|
|
50
|
-
exports.clearImportMappingCache = clearImportMappingCache;
|
|
51
55
|
exports.extractReExports = extractReExports;
|
|
52
56
|
exports.resolveJvmImport = resolveJvmImport;
|
|
53
57
|
exports.resolvePhpImportedStaticCall = resolvePhpImportedStaticCall;
|
|
54
58
|
exports.isJsPathImportRef = isJsPathImportRef;
|
|
59
|
+
exports.jsModuleFile = jsModuleFile;
|
|
55
60
|
exports.resolvePhpQualifiedClassRef = resolvePhpQualifiedClassRef;
|
|
61
|
+
exports.resolveTsQualifiedTypeRef = resolveTsQualifiedTypeRef;
|
|
56
62
|
exports.resolveViaImport = resolveViaImport;
|
|
63
|
+
exports.reachesAmbientModule = reachesAmbientModule;
|
|
64
|
+
exports.pythonImportsInScope = pythonImportsInScope;
|
|
57
65
|
exports.isBoundToOutOfRepoImport = isBoundToOutOfRepoImport;
|
|
66
|
+
exports.importBindingTail = importBindingTail;
|
|
67
|
+
exports.pythonModulePath = pythonModulePath;
|
|
68
|
+
exports.moduleDefaultExport = moduleDefaultExport;
|
|
69
|
+
exports.isJsFamilyFile = isJsFamilyFile;
|
|
70
|
+
exports.isModuleBindingName = isModuleBindingName;
|
|
71
|
+
const crypto = __importStar(require("crypto"));
|
|
58
72
|
const fs = __importStar(require("fs"));
|
|
59
73
|
const path = __importStar(require("path"));
|
|
60
74
|
const path_aliases_1 = require("./path-aliases");
|
|
61
75
|
const alias_binding_1 = require("./alias-binding");
|
|
62
76
|
const workspace_packages_1 = require("./workspace-packages");
|
|
63
77
|
const strip_comments_1 = require("./strip-comments");
|
|
78
|
+
const synth_utils_1 = require("./synth-utils");
|
|
79
|
+
const dart_libraries_1 = require("./dart-libraries");
|
|
80
|
+
const ambient_modules_1 = require("./ambient-modules");
|
|
81
|
+
const query_utils_1 = require("../search/query-utils");
|
|
82
|
+
const reference_tail_1 = require("../db/reference-tail");
|
|
83
|
+
const php_1 = require("../extraction/languages/php");
|
|
84
|
+
const project_config_1 = require("../project-config");
|
|
85
|
+
const php_web_root_1 = require("./php-web-root");
|
|
64
86
|
const name_matcher_1 = require("./name-matcher");
|
|
65
|
-
|
|
66
|
-
* Extension resolution order by language
|
|
67
|
-
*/
|
|
87
|
+
const js_builtins_1 = require("./js-builtins");
|
|
68
88
|
const EXTENSION_RESOLUTION = {
|
|
69
|
-
typescript: ['.ts', '.tsx', '.d.ts', '.js', '.jsx', '/index.ts', '/index.tsx', '/index.js'],
|
|
70
|
-
// ArkTS imports both `.ets` components and plain `.ts` logic modules —
|
|
71
|
-
// HarmonyOS projects are always a mix. `/Index.ets` (capital I) is ohpm's
|
|
72
|
-
// module-entry convention, hit when a bare workspace import ("data") is
|
|
73
|
-
// rewritten to the member's directory; lowercase variants for safety.
|
|
89
|
+
typescript: ['.ts', '.tsx', '.d.ts', '.js', '.jsx', '/index.ts', '/index.tsx', '/index.js', '/index.jsx'],
|
|
74
90
|
arkts: ['.ets', '.ts', '.d.ts', '.js', '/Index.ets', '/index.ets', '/index.ts', '/index.js'],
|
|
75
|
-
javascript: ['.js', '.jsx', '.mjs', '.cjs', '.xsjs', '.xsjslib', '/index.js', '/index.jsx'],
|
|
76
|
-
tsx: ['.tsx', '.ts', '.d.ts', '.js', '.jsx', '/index.tsx', '/index.ts', '/index.js'],
|
|
77
|
-
jsx: ['.jsx', '.js', '/index.jsx', '/index.js'],
|
|
78
|
-
// SFC consumers import plain TS/JS, sibling components, and barrels
|
|
79
|
-
// (`./lib` → `./lib/index.ts`). Without a list, relative imports from a
|
|
80
|
-
// `.svelte`/`.vue` file resolve to nothing, so barrel callers vanish (#629).
|
|
91
|
+
javascript: ['.js', '.jsx', '.mjs', '.cjs', '.xsjs', '.xsjslib', '.ts', '.tsx', '/index.js', '/index.jsx', '/index.ts', '/index.tsx'],
|
|
92
|
+
tsx: ['.tsx', '.ts', '.d.ts', '.js', '.jsx', '/index.tsx', '/index.ts', '/index.js', '/index.jsx'],
|
|
93
|
+
jsx: ['.jsx', '.js', '.tsx', '.ts', '/index.jsx', '/index.js', '/index.tsx', '/index.ts'],
|
|
81
94
|
svelte: ['.ts', '.js', '.svelte', '.tsx', '.jsx', '/index.ts', '/index.js', '/index.svelte'],
|
|
82
95
|
vue: ['.ts', '.js', '.vue', '.tsx', '.jsx', '/index.ts', '/index.js', '/index.vue'],
|
|
83
96
|
astro: ['.ts', '.js', '.astro', '.tsx', '.jsx', '/index.ts', '/index.js', '/index.astro'],
|
|
@@ -99,47 +112,95 @@ function isNixPathImportRef(ref) {
|
|
|
99
112
|
(ref.referenceName.startsWith('./') || ref.referenceName.startsWith('../')) &&
|
|
100
113
|
!/[\s{}()[\];"'<>$]/.test(ref.referenceName));
|
|
101
114
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Resolve an import path to an actual file
|
|
104
|
-
*/
|
|
105
|
-
// Per-context memos for the two hottest pure lookups on the resolution path:
|
|
106
|
-
// import-specifier → file resolution and exported-symbol lookup. Both are pure
|
|
107
|
-
// given a stable file set + node table, which is exactly the window between
|
|
108
|
-
// ReferenceResolver.clearCaches() calls — clearImportResolverMemos() is invoked
|
|
109
|
-
// there, so the staleness discipline matches the resolver's own caches.
|
|
110
115
|
const importPathMemos = new WeakMap();
|
|
111
116
|
const exportedSymbolMemos = new WeakMap();
|
|
112
117
|
const DEFAULT_BINDING_KINDS = new Set(['function', 'class', 'component', 'constant', 'variable']);
|
|
113
|
-
const
|
|
118
|
+
const DEFAULT_DECLARATION_KINDS = new Set(['function', 'class', 'component']);
|
|
119
|
+
const ESM_DEFAULT_EXPORT_RE = /^[ \t]*export\s+default\b/m;
|
|
114
120
|
const JS_FAMILY_FILE = /\.(?:[cm]?[jt]sx?)$/;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
const EXPORT_DEFAULT_HEAD = /^[ \t]*export\s+default\s+/gm;
|
|
122
|
+
const DEFAULT_DECLARATION_RE = /^(?:async\s+)?function\b\s*(?:\*\s*)?([A-Za-z_$][\w$]*)?|^(?:abstract\s+)?class\b(?:\s+(?!extends\b|implements\b)([A-Za-z_$][\w$]*))?/;
|
|
123
|
+
const DEFAULT_ARROW_RE = /^(?:async\s+)?(?:[A-Za-z_$][\w$]*\s*=>|\()/;
|
|
124
|
+
const DEFAULT_BINDING_RE = /^([A-Za-z_$][\w$]*)\s*;?[ \t]*(?:\r?\n|$)/;
|
|
125
|
+
function readDefaultExport(code, at) {
|
|
126
|
+
const rest = code.slice(at, at + 2048);
|
|
127
|
+
if (rest.startsWith('{'))
|
|
128
|
+
return { name: 'default', nameAt: at, declared: true, object: true };
|
|
129
|
+
const decl = DEFAULT_DECLARATION_RE.exec(rest);
|
|
130
|
+
if (decl) {
|
|
131
|
+
const name = decl[1] ?? decl[2];
|
|
132
|
+
return name ? { name, nameAt: at + decl[0].length - name.length, declared: true } : 'anonymous';
|
|
133
|
+
}
|
|
134
|
+
const arrow = DEFAULT_ARROW_RE.exec(rest);
|
|
135
|
+
if (arrow) {
|
|
136
|
+
if (!arrow[0].endsWith('('))
|
|
137
|
+
return 'anonymous';
|
|
138
|
+
let depth = 0;
|
|
139
|
+
for (let i = arrow[0].length - 1; i < rest.length; i++) {
|
|
140
|
+
if (rest[i] === '(')
|
|
141
|
+
depth++;
|
|
142
|
+
else if (rest[i] === ')' && --depth === 0)
|
|
143
|
+
return /^\s*(?:=>|:)/.test(rest.slice(i + 1)) ? 'anonymous' : null;
|
|
144
|
+
}
|
|
121
145
|
return null;
|
|
122
|
-
|
|
146
|
+
}
|
|
147
|
+
const binding = DEFAULT_BINDING_RE.exec(rest);
|
|
148
|
+
return binding ? { name: binding[1], nameAt: at, declared: false } : null;
|
|
149
|
+
}
|
|
150
|
+
function statedDefaultExport(filePath, idx, context) {
|
|
151
|
+
if (idx.statedDefault !== undefined)
|
|
152
|
+
return idx.statedDefault;
|
|
153
|
+
let stated;
|
|
154
|
+
const source = JS_FAMILY_FILE.test(filePath) ? context.readFile(filePath) : null;
|
|
155
|
+
if (source && /\bexport\s+default\b/.test(source)) {
|
|
156
|
+
const code = (0, strip_comments_1.stripCommentsForRegex)(source, 'typescript');
|
|
157
|
+
const lineAt = (0, synth_utils_1.makeLineAt)(code, 1);
|
|
158
|
+
const inTemplateText = (0, strip_comments_1.templateLiteralTextAt)(source);
|
|
159
|
+
EXPORT_DEFAULT_HEAD.lastIndex = 0;
|
|
160
|
+
for (let m = EXPORT_DEFAULT_HEAD.exec(code); m !== null; m = EXPORT_DEFAULT_HEAD.exec(code)) {
|
|
161
|
+
if (inTemplateText?.(m.index))
|
|
162
|
+
continue;
|
|
163
|
+
const value = readDefaultExport(code, m.index + m[0].length);
|
|
164
|
+
if (value === 'anonymous') {
|
|
165
|
+
stated ??= 'anonymous';
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
stated ??= 'unstated';
|
|
169
|
+
if (value === null)
|
|
170
|
+
continue;
|
|
171
|
+
const named = nodesInFileNamed(filePath, value.name, context);
|
|
172
|
+
const from = lineAt(m.index);
|
|
173
|
+
const to = lineAt(value.nameAt);
|
|
174
|
+
const node = value.object
|
|
175
|
+
? named.find((n) => n.kind === 'constant' && n.startLine === from)
|
|
176
|
+
: value.declared
|
|
177
|
+
? named.find((n) => DEFAULT_DECLARATION_KINDS.has(n.kind) && n.startLine >= from && n.startLine <= to)
|
|
178
|
+
: moduleBindingsFirst(filePath, named
|
|
179
|
+
.filter((n) => DEFAULT_BINDING_KINDS.has(n.kind))
|
|
180
|
+
.sort((a, b) => a.startLine - b.startLine || a.startColumn - b.startColumn))[0];
|
|
181
|
+
if (node) {
|
|
182
|
+
stated = node;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
idx.statedDefault = stated ?? 'unstated';
|
|
188
|
+
return idx.statedDefault;
|
|
123
189
|
}
|
|
124
190
|
const fileExportIndexes = new WeakMap();
|
|
125
|
-
/**
|
|
126
|
-
* `module.exports = …` (also `exports = module.exports = …`): the name it
|
|
127
|
-
* binds (`createApplication`, `function name(`, `class Name`) or the module
|
|
128
|
-
* it forwards (`require('./lib/express')`), or null.
|
|
129
|
-
*/
|
|
130
191
|
const COMMONJS_DEFAULT_EXPORT = /^[ \t]*(?:exports\s*=\s*)?module\.exports\s*=\s*(?:exports\s*=\s*)?(?:require\(\s*['"]([^'"]+)['"]\s*\)\s*;?[ \t]*$|(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)\s*\(|class\s+([A-Za-z_$][\w$]*)|([A-Za-z_$][\w$]*)\s*;?[ \t]*$)/m;
|
|
131
192
|
function commonJsDefaultExport(filePath, context) {
|
|
132
193
|
if (!JS_FAMILY_FILE.test(filePath))
|
|
133
194
|
return null;
|
|
134
195
|
if (context.fileContains && !context.fileContains(filePath, 'module.exports'))
|
|
135
196
|
return null;
|
|
197
|
+
const idx = getFileExportIndex(filePath, context);
|
|
198
|
+
if (idx.commonJsDefault !== undefined)
|
|
199
|
+
return idx.commonJsDefault;
|
|
136
200
|
const source = context.readFile(filePath);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (!m)
|
|
141
|
-
return null;
|
|
142
|
-
return m[1] ? { source: m[1] } : { name: m[2] ?? m[3] ?? m[4] };
|
|
201
|
+
const m = source && source.includes('module.exports') ? COMMONJS_DEFAULT_EXPORT.exec(source) : null;
|
|
202
|
+
idx.commonJsDefault = !m ? null : m[1] ? { source: m[1] } : { name: m[2] ?? m[3] ?? m[4] };
|
|
203
|
+
return idx.commonJsDefault;
|
|
143
204
|
}
|
|
144
205
|
function getFileExportIndex(filePath, context) {
|
|
145
206
|
let perFile = fileExportIndexes.get(context);
|
|
@@ -149,9 +210,17 @@ function getFileExportIndex(filePath, context) {
|
|
|
149
210
|
}
|
|
150
211
|
let idx = perFile.get(filePath);
|
|
151
212
|
if (!idx) {
|
|
152
|
-
idx = { byName: new Map(), defaultComponent: undefined, defaultFnClass: undefined };
|
|
153
|
-
const exported =
|
|
213
|
+
idx = { byName: new Map(), defaultComponent: undefined, defaultFnClass: undefined, members: new Map() };
|
|
214
|
+
const exported = PYTHON_MODULE_FILE.test(filePath)
|
|
215
|
+
? context.getNodesInFile(filePath).filter((n) => n.isExported || isPythonModuleLevelDef(n))
|
|
216
|
+
: context.getExportedNodesInFile?.(filePath) ?? context.getNodesInFile(filePath).filter((n) => n.isExported);
|
|
217
|
+
const jsFamily = JS_FAMILY_FILE.test(filePath);
|
|
154
218
|
for (const n of exported) {
|
|
219
|
+
if (jsFamily && n.qualifiedName !== n.name) {
|
|
220
|
+
if (!idx.members.has(n.name))
|
|
221
|
+
idx.members.set(n.name, n);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
155
224
|
if (!idx.byName.has(n.name))
|
|
156
225
|
idx.byName.set(n.name, n);
|
|
157
226
|
if (idx.defaultComponent === undefined && n.kind === 'component')
|
|
@@ -163,40 +232,51 @@ function getFileExportIndex(filePath, context) {
|
|
|
163
232
|
}
|
|
164
233
|
return idx;
|
|
165
234
|
}
|
|
166
|
-
|
|
235
|
+
function moduleBindingsFirst(filePath, nodes) {
|
|
236
|
+
if (!JS_FAMILY_FILE.test(filePath))
|
|
237
|
+
return nodes;
|
|
238
|
+
const own = nodes.filter((n) => n.qualifiedName === n.name);
|
|
239
|
+
return own.length === nodes.length ? nodes : [...own, ...nodes.filter((n) => n.qualifiedName !== n.name)];
|
|
240
|
+
}
|
|
167
241
|
function nodesInFileNamed(filePath, name, context) {
|
|
168
242
|
return context.getNodesInFileNamed?.(filePath, name) ?? context.getNodesInFile(filePath).filter((n) => n.name === name);
|
|
169
243
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
244
|
+
function esmDefaultExport(filePath, idx, context) {
|
|
245
|
+
const stated = statedDefaultExport(filePath, idx, context);
|
|
246
|
+
if (stated === 'anonymous')
|
|
247
|
+
return undefined;
|
|
248
|
+
if (stated !== 'unstated')
|
|
249
|
+
return stated;
|
|
250
|
+
return idx.defaultComponent ?? idx.defaultFnClass;
|
|
251
|
+
}
|
|
252
|
+
function hasEsmDefaultExport(filePath, idx, context) {
|
|
253
|
+
if (idx.defaultComponent)
|
|
254
|
+
return true;
|
|
255
|
+
if (!JS_FAMILY_FILE.test(filePath))
|
|
256
|
+
return false;
|
|
257
|
+
const source = context.readFile(filePath);
|
|
258
|
+
return !!source && source.includes('default') && ESM_DEFAULT_EXPORT_RE.test(source);
|
|
259
|
+
}
|
|
260
|
+
function isStatedDefaultExport(node, context) {
|
|
261
|
+
if (!JS_FAMILY_FILE.test(node.filePath))
|
|
262
|
+
return node.kind === 'component';
|
|
263
|
+
if ((0, ambient_modules_1.isDeclarationFile)(node.filePath))
|
|
264
|
+
return true;
|
|
265
|
+
const stated = statedDefaultExport(node.filePath, getFileExportIndex(node.filePath, context), context);
|
|
266
|
+
return typeof stated === 'object' ? stated.id === node.id : commonJsDefaultExport(node.filePath, context)?.name === node.name;
|
|
182
267
|
}
|
|
183
|
-
/** What this file exports as `name`: an exported declaration, else a local export clause's binding. */
|
|
184
268
|
function exportedByName(filePath, idx, name, context) {
|
|
185
269
|
const direct = idx.byName.get(name);
|
|
186
270
|
if (direct)
|
|
187
271
|
return direct;
|
|
188
272
|
if (idx.clauseAliases === undefined) {
|
|
189
|
-
// Bind names introduced by a local export clause to their declarations, so
|
|
190
|
-
// an importer asking for the renamed name gets the real symbol instead of
|
|
191
|
-
// falling through to the name-matcher (which cannot cross the rename).
|
|
192
|
-
// The declaration is the file's first node of that name, exported or not.
|
|
193
273
|
idx.clauseAliases = new Map();
|
|
194
274
|
const content = context.readFile(filePath);
|
|
195
275
|
if (content && content.includes('export')) {
|
|
196
276
|
for (const { exportedName, localName } of (0, alias_binding_1.extractLocalExportAliases)(content)) {
|
|
197
277
|
if (idx.byName.has(exportedName) || idx.clauseAliases.has(exportedName))
|
|
198
278
|
continue;
|
|
199
|
-
const decl = nodesInFileNamed(filePath, localName, context)[0];
|
|
279
|
+
const decl = moduleBindingsFirst(filePath, nodesInFileNamed(filePath, localName, context))[0];
|
|
200
280
|
if (decl)
|
|
201
281
|
idx.clauseAliases.set(exportedName, decl);
|
|
202
282
|
}
|
|
@@ -204,15 +284,17 @@ function exportedByName(filePath, idx, name, context) {
|
|
|
204
284
|
}
|
|
205
285
|
return idx.clauseAliases.get(name);
|
|
206
286
|
}
|
|
207
|
-
|
|
287
|
+
const cppIncludeSearches = new WeakMap();
|
|
208
288
|
function clearImportResolverMemos(context) {
|
|
209
289
|
importPathMemos.delete(context);
|
|
290
|
+
cppIncludeSearches.delete(context);
|
|
210
291
|
exportedSymbolMemos.delete(context);
|
|
211
292
|
fileExportIndexes.delete(context);
|
|
212
293
|
luaFileBasenameIndexes.delete(context);
|
|
213
294
|
cobolCopybookIndexes.delete(context);
|
|
214
|
-
|
|
215
|
-
|
|
295
|
+
PROJECT_FOLDER_SUFFIXES.delete(context);
|
|
296
|
+
pythonModuleIndexes.delete(context);
|
|
297
|
+
pythonStarExportMemos.delete(context);
|
|
216
298
|
}
|
|
217
299
|
function resolveImportPath(importPath, fromFile, language, context) {
|
|
218
300
|
let memo = importPathMemos.get(context);
|
|
@@ -229,56 +311,29 @@ function resolveImportPath(importPath, fromFile, language, context) {
|
|
|
229
311
|
return resolved;
|
|
230
312
|
}
|
|
231
313
|
function resolveImportPathUncached(importPath, fromFile, language, context) {
|
|
232
|
-
// COBOL COPY/EXEC SQL INCLUDE names a copybook member, not a path — the
|
|
233
|
-
// compiler searches a library, so we match against indexed file basenames.
|
|
234
|
-
// Must run before isExternalImport: a bare member name would otherwise be
|
|
235
|
-
// misclassified as an external package.
|
|
236
314
|
if (language === 'cobol') {
|
|
237
315
|
return resolveCobolCopybook(importPath, fromFile, context);
|
|
238
316
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return null;
|
|
317
|
+
if (isExternalImport(importPath, language, context, { fromFile })) {
|
|
318
|
+
return resolveFromOwnConfig(importPath, fromFile, language, context);
|
|
319
|
+
}
|
|
320
|
+
if (language === 'python') {
|
|
321
|
+
return resolvePythonModule(importPath, fromFile, context);
|
|
245
322
|
}
|
|
246
323
|
const projectRoot = context.getProjectRoot();
|
|
247
324
|
const fromDir = path.dirname(path.join(projectRoot, fromFile));
|
|
248
|
-
// Handle relative imports
|
|
249
325
|
if (importPath.startsWith('.')) {
|
|
250
326
|
return resolveRelativeImport(importPath, fromDir, language, context);
|
|
251
327
|
}
|
|
252
|
-
// Handle absolute/aliased imports (like @/ or src/)
|
|
253
328
|
const aliased = resolveAliasedImport(importPath, projectRoot, language, context, fromFile);
|
|
254
329
|
if (aliased)
|
|
255
330
|
return aliased;
|
|
256
|
-
// C/C++ include directory search: when neither relative nor aliased
|
|
257
|
-
// resolution found a match, search -I directories from
|
|
258
|
-
// compile_commands.json or heuristic probing.
|
|
259
331
|
if (language === 'c' || language === 'cpp') {
|
|
260
332
|
return resolveCppIncludePath(importPath, language, context);
|
|
261
333
|
}
|
|
262
334
|
return null;
|
|
263
335
|
}
|
|
264
|
-
/**
|
|
265
|
-
* COBOL copybook lookup: `COPY CVACT01Y` (or `EXEC SQL INCLUDE X`) names a
|
|
266
|
-
* library member resolved by the compiler's copybook search path, so we match
|
|
267
|
-
* the member against indexed file basenames, case-insensitively. `.cpy` wins
|
|
268
|
-
* over a same-named program; a same-directory hit wins within a tier. The
|
|
269
|
-
* stem index is built once per resolution context (a per-ref scan of every
|
|
270
|
-
* file node would go quadratic on copybook-heavy repos).
|
|
271
|
-
*/
|
|
272
336
|
const cobolCopybookIndexes = new WeakMap();
|
|
273
|
-
/**
|
|
274
|
-
* Per-context basename → file-paths index for Lua/Luau require resolution
|
|
275
|
-
* (cobolCopybookIndexes pattern). resolveLuaRequire previously ran
|
|
276
|
-
* `getAllFiles().filter(endsWith)` FOUR times per require ref — ~7.5k string
|
|
277
|
-
* suffix scans each, measured at ~0.9ms/ref (2.7s combined on kong's 3k
|
|
278
|
-
* requires). Buckets preserve getAllFiles() iteration order so the per-suffix
|
|
279
|
-
* candidate list filters to exactly the array the full scan produced —
|
|
280
|
-
* identical matches, identical stable sort, identical winner.
|
|
281
|
-
*/
|
|
282
337
|
const luaFileBasenameIndexes = new WeakMap();
|
|
283
338
|
function luaBasenameIndex(context) {
|
|
284
339
|
let index = luaFileBasenameIndexes.get(context);
|
|
@@ -336,25 +391,493 @@ function resolveCobolCopybook(member, fromFile, context) {
|
|
|
336
391
|
}
|
|
337
392
|
return best;
|
|
338
393
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
394
|
+
const pythonModuleIndexes = new WeakMap();
|
|
395
|
+
const PYTHON_MODULE_FILE = /\.py$/;
|
|
396
|
+
const PYTHON_MODULE_LEVEL_KINDS = new Set(['function', 'class', 'variable', 'constant']);
|
|
397
|
+
const PYTHON_NON_PROJECT_DIRS = new Set([
|
|
398
|
+
'tests', 'test', 'testing', 'fixtures', 'testdata', 'examples', 'example', 'samples', 'vendor', 'third_party',
|
|
399
|
+
]);
|
|
400
|
+
const PYTHON_STDLIB_MODULES = new Set([
|
|
401
|
+
'__future__', 'abc', 'annotationlib', 'antigravity', 'argparse', 'array', 'ast', 'asyncio', 'atexit',
|
|
402
|
+
'base64', 'bdb', 'binascii', 'bisect', 'builtins', 'bz2', 'cProfile', 'calendar', 'cmath', 'cmd', 'code',
|
|
403
|
+
'codecs', 'codeop', 'collections', 'colorsys', 'compileall', 'compression', 'concurrent', 'configparser',
|
|
404
|
+
'contextlib', 'contextvars', 'copy', 'copyreg', 'csv', 'ctypes', 'curses', 'dataclasses', 'datetime',
|
|
405
|
+
'dbm', 'decimal', 'difflib', 'dis', 'doctest', 'email', 'encodings', 'ensurepip', 'enum', 'errno',
|
|
406
|
+
'faulthandler', 'fcntl', 'filecmp', 'fileinput', 'fnmatch', 'fractions', 'ftplib', 'functools', 'gc',
|
|
407
|
+
'genericpath', 'getopt', 'getpass', 'gettext', 'glob', 'graphlib', 'grp', 'gzip', 'hashlib', 'heapq',
|
|
408
|
+
'hmac', 'html', 'http', 'idlelib', 'imaplib', 'importlib', 'inspect', 'io', 'ipaddress', 'itertools',
|
|
409
|
+
'json', 'keyword', 'linecache', 'locale', 'logging', 'lzma', 'mailbox', 'marshal', 'math', 'mimetypes',
|
|
410
|
+
'mmap', 'modulefinder', 'msvcrt', 'multiprocessing', 'netrc', 'nt', 'ntpath', 'nturl2path', 'numbers',
|
|
411
|
+
'opcode', 'operator', 'optparse', 'os', 'pathlib', 'pdb', 'pickle', 'pickletools', 'pkgutil', 'platform',
|
|
412
|
+
'plistlib', 'poplib', 'posix', 'posixpath', 'pprint', 'profile', 'profiling', 'pstats', 'pty', 'pwd',
|
|
413
|
+
'py_compile', 'pyclbr', 'pydoc', 'pydoc_data', 'pyexpat', 'queue', 'quopri', 'random', 're', 'readline',
|
|
414
|
+
'reprlib', 'resource', 'rlcompleter', 'runpy', 'sched', 'secrets', 'select', 'selectors', 'shelve',
|
|
415
|
+
'shlex', 'shutil', 'signal', 'site', 'smtplib', 'socket', 'socketserver', 'sqlite3', 'ssl', 'stat',
|
|
416
|
+
'statistics', 'string', 'stringprep', 'struct', 'subprocess', 'symtable', 'sys', 'sysconfig', 'syslog',
|
|
417
|
+
'tabnanny', 'tarfile', 'tempfile', 'termios', 'textwrap', 'this', 'threading', 'time', 'timeit',
|
|
418
|
+
'tkinter', 'token', 'tokenize', 'tomllib', 'trace', 'traceback', 'tracemalloc', 'tty', 'turtle',
|
|
419
|
+
'turtledemo', 'types', 'typing', 'unicodedata', 'unittest', 'urllib', 'uuid', 'venv', 'warnings', 'wave',
|
|
420
|
+
'weakref', 'webbrowser', 'winreg', 'winsound', 'wsgiref', 'xml', 'xmlrpc', 'zipapp', 'zipfile',
|
|
421
|
+
'zipimport', 'zlib', 'zoneinfo',
|
|
422
|
+
]);
|
|
423
|
+
function isPythonModuleLevelDef(n) {
|
|
424
|
+
return PYTHON_MODULE_LEVEL_KINDS.has(n.kind) && !n.qualifiedName.includes('::');
|
|
425
|
+
}
|
|
426
|
+
function parentDir(dir) {
|
|
427
|
+
const slash = dir.lastIndexOf('/');
|
|
428
|
+
return slash < 0 ? '' : dir.slice(0, slash);
|
|
429
|
+
}
|
|
430
|
+
function joinRel(dir, rel) {
|
|
431
|
+
return dir ? `${dir}/${rel}` : rel;
|
|
432
|
+
}
|
|
433
|
+
function isWithin(dir, scope) {
|
|
434
|
+
return scope === '' || dir === scope || dir.startsWith(`${scope}/`);
|
|
435
|
+
}
|
|
436
|
+
function pythonModuleIndex(context) {
|
|
437
|
+
let index = pythonModuleIndexes.get(context);
|
|
438
|
+
if (!index) {
|
|
439
|
+
index = buildPythonModuleIndex(context);
|
|
440
|
+
pythonModuleIndexes.set(context, index);
|
|
441
|
+
}
|
|
442
|
+
return index;
|
|
443
|
+
}
|
|
444
|
+
function buildPythonModuleIndex(context) {
|
|
445
|
+
const files = new Set();
|
|
446
|
+
const packageDirs = new Set();
|
|
447
|
+
const dirs = new Set(['']);
|
|
448
|
+
for (const f of context.getAllFiles()) {
|
|
449
|
+
const norm = f.replace(/\\/g, '/');
|
|
450
|
+
if (!PYTHON_MODULE_FILE.test(norm))
|
|
451
|
+
continue;
|
|
452
|
+
files.add(norm);
|
|
453
|
+
const dir = parentDir(norm);
|
|
454
|
+
if (norm === '__init__.py' || norm.endsWith('/__init__.py'))
|
|
455
|
+
packageDirs.add(dir);
|
|
456
|
+
for (let d = dir; d && !dirs.has(d); d = parentDir(d))
|
|
457
|
+
dirs.add(d);
|
|
458
|
+
}
|
|
459
|
+
const serviceReach = (service) => {
|
|
460
|
+
if (packageDirs.has(service))
|
|
461
|
+
return service;
|
|
462
|
+
for (let a = parentDir(service); a; a = parentDir(a)) {
|
|
463
|
+
if (packageDirs.has(a))
|
|
464
|
+
return service;
|
|
465
|
+
if (PYTHON_NON_PROJECT_DIRS.has(a.slice(a.lastIndexOf('/') + 1)))
|
|
466
|
+
return a;
|
|
467
|
+
}
|
|
468
|
+
return null;
|
|
469
|
+
};
|
|
470
|
+
const projectRoots = new Set(['']);
|
|
471
|
+
const localRoots = new Map();
|
|
472
|
+
const addLocal = (root, reach) => {
|
|
473
|
+
const prior = localRoots.get(root);
|
|
474
|
+
if (prior === undefined || isWithin(prior, reach))
|
|
475
|
+
localRoots.set(root, reach);
|
|
476
|
+
};
|
|
477
|
+
for (const dir of packageDirs) {
|
|
478
|
+
let top = dir;
|
|
479
|
+
while (top && packageDirs.has(parentDir(top)))
|
|
480
|
+
top = parentDir(top);
|
|
481
|
+
if (top)
|
|
482
|
+
addLocal(parentDir(top), parentDir(top));
|
|
483
|
+
}
|
|
484
|
+
for (const service of dirs) {
|
|
485
|
+
const hasConfig = files.has(joinRel(service, 'setup.py')) ||
|
|
486
|
+
context.fileExists(joinRel(service, 'pyproject.toml')) ||
|
|
487
|
+
context.fileExists(joinRel(service, 'setup.cfg'));
|
|
488
|
+
if (!hasConfig && service !== '')
|
|
489
|
+
continue;
|
|
490
|
+
const reach = service === '' ? null : serviceReach(service);
|
|
491
|
+
const roots = [service];
|
|
492
|
+
const src = joinRel(service, 'src');
|
|
493
|
+
if (dirs.has(src) && !packageDirs.has(src))
|
|
494
|
+
roots.push(src);
|
|
495
|
+
for (const declared of declaredPythonRoots(context, service)) {
|
|
496
|
+
if (dirs.has(declared))
|
|
497
|
+
roots.push(declared);
|
|
498
|
+
}
|
|
499
|
+
for (const root of roots) {
|
|
500
|
+
if (reach === null)
|
|
501
|
+
projectRoots.add(root);
|
|
502
|
+
else
|
|
503
|
+
addLocal(root, reach);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
for (const root of projectRoots)
|
|
507
|
+
localRoots.delete(root);
|
|
508
|
+
return { files, packageDirs, dirs, projectRoots, localRoots, headsByName: new Map() };
|
|
509
|
+
}
|
|
510
|
+
function declaredPythonRoots(context, service) {
|
|
511
|
+
const out = [];
|
|
512
|
+
const add = (raw) => {
|
|
513
|
+
const dir = raw.trim().replace(/^["']|["']$/g, '').replace(/^\.(?:\/|$)/, '').replace(/\/+$/, '');
|
|
514
|
+
if (!dir || dir.startsWith('..') || path.isAbsolute(dir))
|
|
515
|
+
return;
|
|
516
|
+
out.push(joinRel(service, dir));
|
|
517
|
+
};
|
|
518
|
+
const toml = context.readFile(joinRel(service, 'pyproject.toml'));
|
|
519
|
+
if (toml) {
|
|
520
|
+
for (const [table, body] of iniTables(toml)) {
|
|
521
|
+
if (table === 'tool.setuptools.packages.find') {
|
|
522
|
+
const m = body.match(/^\s*where\s*=\s*\[([^\]]*)\]/m);
|
|
523
|
+
if (m)
|
|
524
|
+
for (const item of m[1].split(','))
|
|
525
|
+
add(item);
|
|
526
|
+
}
|
|
527
|
+
else if (table === 'tool.setuptools.package-dir') {
|
|
528
|
+
const m = body.match(/^\s*["']{2}\s*=\s*["']([^"']+)["']/m);
|
|
529
|
+
if (m)
|
|
530
|
+
add(m[1]);
|
|
531
|
+
}
|
|
532
|
+
else if (table === 'tool.setuptools') {
|
|
533
|
+
const m = body.match(/package-dir\s*=\s*\{[^}]*?["']{2}\s*=\s*["']([^"']+)["']/);
|
|
534
|
+
if (m)
|
|
535
|
+
add(m[1]);
|
|
536
|
+
}
|
|
537
|
+
else if (table === 'tool.poetry') {
|
|
538
|
+
const pkgs = body.match(/^\s*packages\s*=\s*\[([\s\S]*?)\]\s*$/m);
|
|
539
|
+
if (pkgs)
|
|
540
|
+
for (const m of pkgs[1].matchAll(/\bfrom\s*=\s*["']([^"']+)["']/g))
|
|
541
|
+
add(m[1]);
|
|
542
|
+
}
|
|
543
|
+
else if (table === 'tool.hatch.build.targets.wheel') {
|
|
544
|
+
const pkgs = body.match(/^\s*packages\s*=\s*\[([^\]]*)\]/m);
|
|
545
|
+
if (pkgs) {
|
|
546
|
+
for (const item of pkgs[1].split(',')) {
|
|
547
|
+
const p = item.trim().replace(/^["']|["']$/g, '');
|
|
548
|
+
if (p.includes('/'))
|
|
549
|
+
add(p.slice(0, p.lastIndexOf('/')));
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
const cfg = context.readFile(joinRel(service, 'setup.cfg'));
|
|
556
|
+
if (cfg) {
|
|
557
|
+
for (const [table, body] of iniTables(cfg)) {
|
|
558
|
+
if (table === 'options') {
|
|
559
|
+
const m = body.match(/^\s*package_dir\s*=\s*(?:\n\s+)?=\s*(\S+)\s*$/m);
|
|
560
|
+
if (m)
|
|
561
|
+
add(m[1]);
|
|
562
|
+
}
|
|
563
|
+
else if (table === 'options.packages.find') {
|
|
564
|
+
const m = body.match(/^\s*where\s*=\s*(\S+)\s*$/m);
|
|
565
|
+
if (m)
|
|
566
|
+
add(m[1]);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return out;
|
|
571
|
+
}
|
|
572
|
+
function iniTables(content) {
|
|
573
|
+
const out = [];
|
|
574
|
+
const headers = [...content.matchAll(/^[ \t]*\[([^\[\]\n]+)\][ \t]*(?:#.*)?$/gm)];
|
|
575
|
+
headers.forEach((h, i) => {
|
|
576
|
+
const end = i + 1 < headers.length ? headers[i + 1].index : content.length;
|
|
577
|
+
out.push([h[1].trim().replace(/["']/g, ''), content.slice(h.index + h[0].length, end)]);
|
|
578
|
+
});
|
|
579
|
+
return out;
|
|
580
|
+
}
|
|
581
|
+
function pythonModuleAt(base, index) {
|
|
582
|
+
const init = joinRel(base, '__init__.py');
|
|
583
|
+
if (index.files.has(init))
|
|
584
|
+
return init;
|
|
585
|
+
return index.files.has(`${base}.py`) ? `${base}.py` : null;
|
|
586
|
+
}
|
|
587
|
+
function pythonModuleUnder(root, relPath, index) {
|
|
588
|
+
const parts = relPath.split('/');
|
|
589
|
+
let base = root;
|
|
590
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
591
|
+
base = joinRel(base, parts[i]);
|
|
592
|
+
if (index.files.has(joinRel(base, '__init__.py')))
|
|
593
|
+
continue;
|
|
594
|
+
if (index.files.has(`${base}.py`) || !index.dirs.has(base))
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
597
|
+
return pythonModuleAt(joinRel(root, relPath), index);
|
|
598
|
+
}
|
|
599
|
+
function pythonHeadKind(root, head, index) {
|
|
600
|
+
const base = joinRel(root, head);
|
|
601
|
+
if (pythonModuleAt(base, index))
|
|
602
|
+
return 'concrete';
|
|
603
|
+
return index.dirs.has(base) ? 'namespace' : null;
|
|
604
|
+
}
|
|
605
|
+
function pythonRootHeads(head, index) {
|
|
606
|
+
let heads = index.headsByName.get(head);
|
|
607
|
+
if (!heads) {
|
|
608
|
+
heads = { concrete: [], namespace: [] };
|
|
609
|
+
for (const root of [...index.projectRoots, ...index.localRoots.keys()]) {
|
|
610
|
+
const kind = pythonHeadKind(root, head, index);
|
|
611
|
+
if (kind)
|
|
612
|
+
heads[kind].push(root);
|
|
613
|
+
}
|
|
614
|
+
index.headsByName.set(head, heads);
|
|
615
|
+
}
|
|
616
|
+
return heads;
|
|
617
|
+
}
|
|
618
|
+
function resolvePythonModule(specifier, fromFile, context) {
|
|
619
|
+
if (!/^\.*[\w.]*$/.test(specifier) || specifier === '')
|
|
620
|
+
return null;
|
|
621
|
+
const index = pythonModuleIndex(context);
|
|
622
|
+
const importerDir = parentDir(fromFile.replace(/\\/g, '/'));
|
|
623
|
+
const dots = specifier.length - specifier.replace(/^\.+/, '').length;
|
|
624
|
+
if (dots > 0) {
|
|
625
|
+
let base = importerDir;
|
|
626
|
+
for (let level = 1; level < dots; level++) {
|
|
627
|
+
if (index.packageDirs.has(base) && !index.packageDirs.has(parentDir(base)))
|
|
628
|
+
return null;
|
|
629
|
+
if (!base)
|
|
630
|
+
return null;
|
|
631
|
+
base = parentDir(base);
|
|
632
|
+
}
|
|
633
|
+
const rest = specifier.slice(dots);
|
|
634
|
+
if (rest)
|
|
635
|
+
return pythonModuleUnder(base, rest.replace(/\./g, '/'), index);
|
|
636
|
+
const init = joinRel(base, '__init__.py');
|
|
637
|
+
return index.files.has(init) ? init : null;
|
|
638
|
+
}
|
|
639
|
+
const relPath = specifier.replace(/\./g, '/');
|
|
640
|
+
const head = specifier.split('.')[0];
|
|
641
|
+
const containing = [];
|
|
642
|
+
for (let dir = importerDir; dir !== null; dir = dir ? parentDir(dir) : null) {
|
|
643
|
+
const isRoot = index.projectRoots.has(dir) ||
|
|
644
|
+
index.localRoots.has(dir) ||
|
|
645
|
+
(!index.packageDirs.has(dir) &&
|
|
646
|
+
(dir === importerDir || importerDir === joinRel(dir, head) || importerDir.startsWith(`${joinRel(dir, head)}/`)));
|
|
647
|
+
if (isRoot)
|
|
648
|
+
containing.push(dir);
|
|
649
|
+
}
|
|
650
|
+
let headIsLocal = false;
|
|
651
|
+
for (const root of containing) {
|
|
652
|
+
const hit = pythonModuleUnder(root, relPath, index);
|
|
653
|
+
if (hit)
|
|
654
|
+
return hit;
|
|
655
|
+
if (pythonHeadKind(root, head, index) === 'concrete')
|
|
656
|
+
headIsLocal = true;
|
|
657
|
+
}
|
|
658
|
+
if (headIsLocal)
|
|
659
|
+
return null;
|
|
660
|
+
const heads = pythonRootHeads(head, index);
|
|
661
|
+
const reaches = (root) => !containing.includes(root) &&
|
|
662
|
+
(index.projectRoots.has(root) || isWithin(importerDir, index.localRoots.get(root)));
|
|
663
|
+
const concrete = heads.concrete.filter(reaches);
|
|
664
|
+
if (concrete.length > 0) {
|
|
665
|
+
return concrete.length === 1 ? pythonModuleUnder(concrete[0], relPath, index) : null;
|
|
666
|
+
}
|
|
667
|
+
let found = null;
|
|
668
|
+
for (const root of heads.namespace) {
|
|
669
|
+
if (!reaches(root))
|
|
670
|
+
continue;
|
|
671
|
+
const hit = pythonModuleUnder(root, relPath, index);
|
|
672
|
+
if (!hit)
|
|
673
|
+
continue;
|
|
674
|
+
if (found !== null && found !== hit)
|
|
675
|
+
return null;
|
|
676
|
+
found = hit;
|
|
677
|
+
}
|
|
678
|
+
return found ?? pythonModuleOfScript(specifier, relPath, fromFile, importerDir, index, context);
|
|
679
|
+
}
|
|
680
|
+
function pythonModuleOfScript(specifier, relPath, fromFile, importerDir, index, context) {
|
|
681
|
+
if (PYTHON_STDLIB_MODULES.has(specifier.split('.')[0]))
|
|
682
|
+
return null;
|
|
683
|
+
const taken = context.getImportMappings(fromFile, 'python')
|
|
684
|
+
.filter((imp) => imp.source === specifier && !imp.isNamespace)
|
|
685
|
+
.map((imp) => imp.exportedName);
|
|
686
|
+
if (taken.length === 0)
|
|
687
|
+
return null;
|
|
688
|
+
for (let dir = importerDir; dir; dir = parentDir(dir)) {
|
|
689
|
+
if (dir !== importerDir && index.packageDirs.has(dir))
|
|
690
|
+
continue;
|
|
691
|
+
const file = pythonModuleUnder(dir, relPath, index);
|
|
692
|
+
if (!file || context.getImportMappings(file, 'python').some((imp) => imp.source === specifier))
|
|
693
|
+
continue;
|
|
694
|
+
const defined = new Set(context.getNodesInFile(file).filter(isPythonModuleLevelDef).map((n) => n.name));
|
|
695
|
+
if (taken.every((name) => defined.has(name)))
|
|
696
|
+
return file;
|
|
697
|
+
}
|
|
698
|
+
return null;
|
|
699
|
+
}
|
|
700
|
+
function pythonRootFingerprint(context) {
|
|
701
|
+
const index = buildPythonModuleIndex(context);
|
|
702
|
+
if (index.files.size === 0)
|
|
703
|
+
return '';
|
|
704
|
+
const hash = crypto.createHash('sha1');
|
|
705
|
+
hash.update([...index.projectRoots].sort().join('\n'));
|
|
706
|
+
hash.update('\0');
|
|
707
|
+
hash.update([...index.localRoots].map(([root, reach]) => `${root}\t${reach}`).sort().join('\n'));
|
|
708
|
+
return hash.digest('hex');
|
|
709
|
+
}
|
|
710
|
+
function pythonReopenScope(context, changedFiles) {
|
|
711
|
+
const index = buildPythonModuleIndex(context);
|
|
712
|
+
const roots = [...index.projectRoots, ...index.localRoots.keys()];
|
|
713
|
+
const moduleNames = (file) => {
|
|
714
|
+
const out = [];
|
|
715
|
+
const mod = file.replace(/(?:^|\/)__init__\.py$/, '').replace(/\.py$/, '');
|
|
716
|
+
for (const root of roots) {
|
|
717
|
+
if (root && !mod.startsWith(`${root}/`))
|
|
718
|
+
continue;
|
|
719
|
+
const rel = root ? mod.slice(root.length + 1) : mod;
|
|
720
|
+
if (rel)
|
|
721
|
+
out.push(rel.replace(/\//g, '.'));
|
|
722
|
+
}
|
|
723
|
+
return out;
|
|
724
|
+
};
|
|
725
|
+
const affected = new Set();
|
|
726
|
+
const sourceDirs = new Set();
|
|
727
|
+
for (const raw of changedFiles) {
|
|
728
|
+
const file = raw.replace(/\\/g, '/');
|
|
729
|
+
if (!PYTHON_MODULE_FILE.test(file))
|
|
730
|
+
continue;
|
|
731
|
+
for (const m of moduleNames(file))
|
|
732
|
+
affected.add(m);
|
|
733
|
+
if (file === '__init__.py' || file.endsWith('/__init__.py'))
|
|
734
|
+
sourceDirs.add(parentDir(file));
|
|
735
|
+
}
|
|
736
|
+
const targetFiles = [];
|
|
737
|
+
for (const file of index.files) {
|
|
738
|
+
const hit = moduleNames(file).some((m) => {
|
|
739
|
+
for (let i = m.length; i > 0; i = m.lastIndexOf('.', i - 1)) {
|
|
740
|
+
if (affected.has(m.slice(0, i)))
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
return false;
|
|
744
|
+
});
|
|
745
|
+
if (hit)
|
|
746
|
+
targetFiles.push(file);
|
|
747
|
+
}
|
|
748
|
+
const moduleLeaves = [...new Set([...affected].map((m) => m.slice(m.lastIndexOf('.') + 1)))];
|
|
749
|
+
return { targetFiles, sourceDirs: [...sourceDirs], moduleLeaves };
|
|
750
|
+
}
|
|
751
|
+
function pythonScriptModuleScope(context, editedFiles) {
|
|
752
|
+
const index = pythonModuleIndex(context);
|
|
753
|
+
const targetFiles = [];
|
|
754
|
+
const moduleLeaves = [];
|
|
755
|
+
for (const raw of editedFiles) {
|
|
756
|
+
const file = raw.replace(/\\/g, '/');
|
|
757
|
+
if (!PYTHON_MODULE_FILE.test(file))
|
|
758
|
+
continue;
|
|
759
|
+
const mod = file.replace(/(?:^|\/)__init__\.py$/, '').replace(/\.py$/, '');
|
|
760
|
+
for (let dir = parentDir(mod); dir; dir = parentDir(dir)) {
|
|
761
|
+
const specifier = mod.slice(dir.length + 1).replace(/\//g, '.');
|
|
762
|
+
if (PYTHON_STDLIB_MODULES.has(specifier.split('.')[0]))
|
|
763
|
+
continue;
|
|
764
|
+
const importers = context.getNodesByName(specifier)
|
|
765
|
+
.filter((n) => n.kind === 'import' && PYTHON_MODULE_FILE.test(n.filePath))
|
|
766
|
+
.map((n) => parentDir(n.filePath));
|
|
767
|
+
const reached = index.packageDirs.has(dir)
|
|
768
|
+
? importers.includes(dir)
|
|
769
|
+
: !index.projectRoots.has(dir) && !index.localRoots.has(dir) &&
|
|
770
|
+
importers.some((d) => d.startsWith(`${dir}/`));
|
|
771
|
+
if (!reached)
|
|
772
|
+
continue;
|
|
773
|
+
targetFiles.push(file);
|
|
774
|
+
moduleLeaves.push(mod.slice(mod.lastIndexOf('/') + 1));
|
|
775
|
+
break;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
return { targetFiles, sourceDirs: [], moduleLeaves };
|
|
779
|
+
}
|
|
780
|
+
function pythonPackageImporters(context, initFiles) {
|
|
781
|
+
const index = pythonModuleIndex(context);
|
|
782
|
+
const packages = new Set(initFiles.map((f) => f.replace(/\\/g, '/')));
|
|
783
|
+
const out = new Map();
|
|
784
|
+
const bindingNow = (imp, file) => {
|
|
785
|
+
if (imp.isNamespace || imp.exportedName === '*')
|
|
786
|
+
return null;
|
|
787
|
+
const packageFile = resolveImportPath(imp.source, file, 'python', context);
|
|
788
|
+
if (!packageFile)
|
|
789
|
+
return null;
|
|
790
|
+
const symbol = findExportedSymbol(packageFile, { isDefault: false, isNamespace: false, exportedName: imp.exportedName, memberName: null }, 'python', context, new Set());
|
|
791
|
+
if (symbol)
|
|
792
|
+
return `${symbol.filePath}\0${symbol.name}`;
|
|
793
|
+
const sub = resolveImportPath(imp.source.endsWith('.') ? imp.source + imp.exportedName : `${imp.source}.${imp.exportedName}`, file, 'python', context);
|
|
794
|
+
return sub ? `${sub}\0` : '\0';
|
|
795
|
+
};
|
|
796
|
+
const importNodes = context.getNodesByKind('import').filter((n) => PYTHON_MODULE_FILE.test(n.filePath));
|
|
797
|
+
for (let grew = true; grew;) {
|
|
798
|
+
grew = false;
|
|
799
|
+
const candidates = new Set();
|
|
800
|
+
for (const n of importNodes) {
|
|
801
|
+
const target = resolveImportPath(n.name, n.filePath, 'python', context);
|
|
802
|
+
if (target && packages.has(target) && index.files.has(n.filePath))
|
|
803
|
+
candidates.add(n.filePath);
|
|
804
|
+
}
|
|
805
|
+
for (const file of candidates) {
|
|
806
|
+
for (const imp of context.getImportMappings(file, 'python')) {
|
|
807
|
+
const target = resolveImportPath(imp.source, file, 'python', context);
|
|
808
|
+
if (!target || !packages.has(target) || target === file)
|
|
809
|
+
continue;
|
|
810
|
+
let names = out.get(file);
|
|
811
|
+
if (!names)
|
|
812
|
+
out.set(file, (names = new Map()));
|
|
813
|
+
names.set(imp.localName, bindingNow(imp, file));
|
|
814
|
+
if (imp.isNamespace)
|
|
815
|
+
names.set(imp.source.split('.')[0], null);
|
|
816
|
+
if (/(?:^|\/)__init__\.py$/.test(file) && !packages.has(file)) {
|
|
817
|
+
packages.add(file);
|
|
818
|
+
grew = true;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return out;
|
|
824
|
+
}
|
|
825
|
+
function pythonModuleFileNode(specifier, fromFile, context) {
|
|
826
|
+
const file = resolveImportPath(specifier, fromFile, 'python', context);
|
|
827
|
+
if (!file || file === fromFile)
|
|
828
|
+
return null;
|
|
829
|
+
return context.getNodesInFile(file).find((n) => n.kind === 'file') ?? null;
|
|
830
|
+
}
|
|
831
|
+
const pythonStarExportMemos = new WeakMap();
|
|
832
|
+
function pythonStarExports(filePath, context) {
|
|
833
|
+
let memo = pythonStarExportMemos.get(context);
|
|
834
|
+
if (!memo) {
|
|
835
|
+
memo = new Map();
|
|
836
|
+
pythonStarExportMemos.set(context, memo);
|
|
837
|
+
}
|
|
838
|
+
if (memo.has(filePath))
|
|
839
|
+
return memo.get(filePath);
|
|
840
|
+
let names = null;
|
|
841
|
+
const content = context.readFile(filePath);
|
|
842
|
+
if (content && content.includes('__all__')) {
|
|
843
|
+
const code = (0, strip_comments_1.stripCommentsForRegex)(content, 'python');
|
|
844
|
+
let literal = true;
|
|
845
|
+
const collected = new Set();
|
|
846
|
+
for (const m of code.matchAll(/^[ \t]*__all__\b[ \t]*(\.|\+=|=|:[^=\n]*=)?[ \t]*(.?)/gm)) {
|
|
847
|
+
const open = m.index + m[0].length - 1;
|
|
848
|
+
const bracket = m[2];
|
|
849
|
+
const close = bracket === '[' ? code.indexOf(']', open) : bracket === '(' ? code.indexOf(')', open) : -1;
|
|
850
|
+
const assigns = m[1] !== undefined && m[1] !== '.';
|
|
851
|
+
const tail = close < 0 ? '' : code.slice(close + 1, code.indexOf('\n', close) < 0 ? undefined : code.indexOf('\n', close));
|
|
852
|
+
if (!assigns || close < 0 || tail.trim() !== '') {
|
|
853
|
+
literal = false;
|
|
854
|
+
break;
|
|
855
|
+
}
|
|
856
|
+
for (const lit of content.slice(open, close).matchAll(/["']([A-Za-z_]\w*)["']/g))
|
|
857
|
+
collected.add(lit[1]);
|
|
858
|
+
}
|
|
859
|
+
if (literal && collected.size > 0)
|
|
860
|
+
names = collected;
|
|
861
|
+
}
|
|
862
|
+
memo.set(filePath, names);
|
|
863
|
+
return names;
|
|
864
|
+
}
|
|
865
|
+
function pythonStarAllows(filePath, name, context) {
|
|
866
|
+
const names = pythonStarExports(filePath, context);
|
|
867
|
+
return names ? names.has(name) : !name.startsWith('_');
|
|
868
|
+
}
|
|
343
869
|
const C_CPP_STDLIB_HEADERS = new Set([
|
|
344
|
-
// C standard library headers
|
|
345
870
|
'assert.h', 'complex.h', 'ctype.h', 'errno.h', 'fenv.h', 'float.h',
|
|
346
871
|
'inttypes.h', 'iso646.h', 'limits.h', 'locale.h', 'math.h', 'setjmp.h',
|
|
347
872
|
'signal.h', 'stdalign.h', 'stdarg.h', 'stdatomic.h', 'stdbool.h',
|
|
348
873
|
'stddef.h', 'stdint.h', 'stdio.h', 'stdlib.h', 'stdnoreturn.h',
|
|
349
874
|
'string.h', 'tgmath.h', 'threads.h', 'time.h', 'uchar.h', 'wchar.h',
|
|
350
875
|
'wctype.h',
|
|
351
|
-
// C++ C-library wrappers (cname form)
|
|
352
876
|
'cassert', 'ccomplex', 'cctype', 'cerrno', 'cfenv', 'cfloat',
|
|
353
877
|
'cinttypes', 'ciso646', 'climits', 'clocale', 'cmath', 'csetjmp',
|
|
354
878
|
'csignal', 'cstdalign', 'cstdarg', 'cstdbool', 'cstddef', 'cstdint',
|
|
355
879
|
'cstdio', 'cstdlib', 'cstring', 'ctgmath', 'ctime', 'cuchar',
|
|
356
880
|
'cwchar', 'cwctype',
|
|
357
|
-
// C++ STL headers
|
|
358
881
|
'algorithm', 'any', 'array', 'atomic', 'barrier', 'bit', 'bitset',
|
|
359
882
|
'charconv', 'chrono', 'codecvt', 'compare', 'complex', 'concepts',
|
|
360
883
|
'condition_variable', 'coroutine', 'deque', 'exception', 'execution',
|
|
@@ -372,160 +895,116 @@ const C_CPP_STDLIB_HEADERS = new Set([
|
|
|
372
895
|
'unordered_set', 'utility', 'valarray', 'variant', 'vector',
|
|
373
896
|
'version',
|
|
374
897
|
]);
|
|
375
|
-
|
|
376
|
-
* Languages whose imports are ES-module specifiers, extracted by
|
|
377
|
-
* `extractJSImports` and therefore classified by the same bare-specifier /
|
|
378
|
-
* alias / workspace rules. Svelte, Vue and Astro belong here: an SFC imports
|
|
379
|
-
* inside its `<script>` block (Astro: the `---` frontmatter) with exactly the
|
|
380
|
-
* same syntax, and leaving them out made `isExternalImport` answer "not
|
|
381
|
-
* external" for every npm specifier in an SFC.
|
|
382
|
-
*/
|
|
383
|
-
const ESM_IMPORT_LANGUAGES = new Set([
|
|
898
|
+
exports.ESM_IMPORT_LANGUAGES = new Set([
|
|
384
899
|
'typescript', 'tsx', 'javascript', 'jsx', 'arkts', 'svelte', 'vue', 'astro',
|
|
385
900
|
]);
|
|
386
|
-
|
|
387
|
-
const RUST_STDLIB_ROOTS = new Set(['std', 'core', 'alloc', 'proc_macro']);
|
|
388
|
-
/**
|
|
389
|
-
* Check if an import is external (npm package, etc.)
|
|
390
|
-
*
|
|
391
|
-
* `context` is consulted for project-defined path aliases
|
|
392
|
-
* (tsconfig/jsconfig `paths`). Without that check, custom prefixes
|
|
393
|
-
* like `@components/*` would fail the bare-specifier heuristic and
|
|
394
|
-
* be classified as external before alias resolution can run.
|
|
395
|
-
*/
|
|
396
|
-
function isExternalImport(importPath, language, context) {
|
|
397
|
-
// Relative imports are not external
|
|
901
|
+
function isExternalImport(importPath, language, context, options = {}) {
|
|
398
902
|
if (importPath.startsWith('.')) {
|
|
399
903
|
return false;
|
|
400
904
|
}
|
|
401
|
-
// Workspace-member imports (`@scope/ui`, `@scope/ui/widgets`) are LOCAL to
|
|
402
|
-
// a monorepo even though they look like bare npm specifiers. Consult the
|
|
403
|
-
// workspace map first so they aren't misclassified as external (#629). The
|
|
404
|
-
// map is null for single-package repos, so this is a no-op there.
|
|
405
905
|
const workspaces = context?.getWorkspacePackages?.();
|
|
406
|
-
if (workspaces && (0, workspace_packages_1.resolveWorkspaceImport)(importPath, workspaces)) {
|
|
906
|
+
if (workspaces && (0, workspace_packages_1.resolveWorkspaceImport)(importPath, workspaces, options.fromFile)) {
|
|
407
907
|
return false;
|
|
408
908
|
}
|
|
409
|
-
|
|
410
|
-
if (ESM_IMPORT_LANGUAGES.has(language)) {
|
|
411
|
-
// Node built-ins
|
|
909
|
+
if (exports.ESM_IMPORT_LANGUAGES.has(language)) {
|
|
412
910
|
if (['fs', 'path', 'os', 'crypto', 'http', 'https', 'url', 'util', 'events', 'stream', 'child_process', 'buffer'].includes(importPath)) {
|
|
413
911
|
return true;
|
|
414
912
|
}
|
|
415
|
-
|
|
416
|
-
const aliases = context?.getProjectAliases?.();
|
|
913
|
+
const aliases = options.aliasPrefixes === false ? null : context?.getProjectAliases?.();
|
|
417
914
|
if (aliases) {
|
|
418
915
|
for (const pat of aliases.patterns) {
|
|
419
|
-
if (importPath.startsWith(pat.prefix))
|
|
916
|
+
if (pat.prefix !== '' && importPath.startsWith(pat.prefix))
|
|
420
917
|
return false;
|
|
421
918
|
}
|
|
422
919
|
}
|
|
423
|
-
// Scoped packages or bare specifiers that don't start with aliases
|
|
424
920
|
if (!importPath.startsWith('@/') && !importPath.startsWith('~/') && !importPath.startsWith('src/')) {
|
|
425
|
-
// Likely an npm package
|
|
426
921
|
return true;
|
|
427
922
|
}
|
|
428
923
|
}
|
|
429
924
|
if (language === 'python') {
|
|
430
|
-
// Standard library modules
|
|
431
925
|
const stdLibs = ['os', 'sys', 'json', 're', 'math', 'datetime', 'collections', 'typing', 'pathlib', 'logging'];
|
|
432
926
|
if (stdLibs.includes(importPath.split('.')[0])) {
|
|
433
927
|
return true;
|
|
434
928
|
}
|
|
435
929
|
}
|
|
436
930
|
if (language === 'go') {
|
|
437
|
-
// Relative imports (rare in idiomatic Go but the grammar allows them).
|
|
438
931
|
if (importPath.startsWith('.')) {
|
|
439
932
|
return false;
|
|
440
933
|
}
|
|
441
|
-
|
|
442
|
-
// this project. Without the module-path check we'd flag every
|
|
443
|
-
// cross-package call in a Go monorepo as external (issue #388).
|
|
444
|
-
const mod = context?.getGoModule?.();
|
|
445
|
-
if (mod && (importPath === mod.modulePath || importPath.startsWith(mod.modulePath + '/'))) {
|
|
934
|
+
if (context?.getGoPackageDir?.(importPath) != null) {
|
|
446
935
|
return false;
|
|
447
936
|
}
|
|
448
|
-
// `internal/` packages stay local even when go.mod is missing —
|
|
449
|
-
// preserves the pre-#388 escape hatch for repos without a parsed module path.
|
|
450
937
|
if (importPath.includes('/internal/')) {
|
|
451
938
|
return false;
|
|
452
939
|
}
|
|
453
|
-
// Anything else is the Go standard library or a third-party module.
|
|
454
940
|
return true;
|
|
455
941
|
}
|
|
456
942
|
if (language === 'c' || language === 'cpp') {
|
|
457
|
-
// C/C++ standard library headers — both C-style (<stdio.h>) and
|
|
458
|
-
// C++-style (<cstdio>, <vector>) forms. Checked against the import
|
|
459
|
-
// path (which the extractor strips of <> or "" delimiters).
|
|
460
943
|
if (C_CPP_STDLIB_HEADERS.has(importPath))
|
|
461
944
|
return true;
|
|
462
|
-
// C++ headers without .h extension (e.g. "vector", "string")
|
|
463
945
|
const withoutExt = importPath.replace(/\.h$/, '');
|
|
464
946
|
if (C_CPP_STDLIB_HEADERS.has(withoutExt))
|
|
465
947
|
return true;
|
|
466
948
|
}
|
|
467
949
|
return false;
|
|
468
950
|
}
|
|
469
|
-
/**
|
|
470
|
-
* Resolve a relative import
|
|
471
|
-
*/
|
|
472
951
|
function resolveRelativeImport(importPath, fromDir, language, context) {
|
|
473
952
|
const projectRoot = context.getProjectRoot();
|
|
474
953
|
const extensions = EXTENSION_RESOLUTION[language] || [];
|
|
475
|
-
// Python dotted-relative imports (`from .certs import x`, `from ..pkg.mod
|
|
476
|
-
// import y`): leading dots are PACKAGE levels (1 = current package), and the
|
|
477
|
-
// remainder is a dotted submodule path. `path.resolve(dir, '.certs')` would
|
|
478
|
-
// treat `.certs` as a literal hidden filename, so translate the Python form
|
|
479
|
-
// to a real filesystem-relative path before resolving.
|
|
480
|
-
if (language === 'python' && importPath.startsWith('.')) {
|
|
481
|
-
const dots = importPath.length - importPath.replace(/^\.+/, '').length;
|
|
482
|
-
const up = '../'.repeat(Math.max(0, dots - 1)); // 1 dot = current dir
|
|
483
|
-
const rest = importPath.slice(dots).replace(/\./g, '/'); // 'sub.mod' -> 'sub/mod'
|
|
484
|
-
const pyBase = path.resolve(fromDir, up + rest);
|
|
485
|
-
const pyRel = path.relative(projectRoot, pyBase).replace(/\\/g, '/');
|
|
486
|
-
for (const ext of extensions) {
|
|
487
|
-
if (context.fileExists(pyRel + ext))
|
|
488
|
-
return pyRel + ext;
|
|
489
|
-
}
|
|
490
|
-
if (pyRel && context.fileExists(pyRel))
|
|
491
|
-
return pyRel;
|
|
492
|
-
return null;
|
|
493
|
-
}
|
|
494
|
-
// Try the path as-is first
|
|
495
954
|
const basePath = path.resolve(fromDir, importPath);
|
|
496
955
|
const relativePath = path.relative(projectRoot, basePath).replace(/\\/g, '/');
|
|
497
|
-
|
|
956
|
+
let mainTried = false;
|
|
498
957
|
for (const ext of extensions) {
|
|
499
958
|
if (relativePath === '' && !ext.startsWith('/'))
|
|
500
959
|
continue;
|
|
960
|
+
if (ext.startsWith('/') && !mainTried && FOLDER_MAIN_LANGUAGES.has(language)) {
|
|
961
|
+
mainTried = true;
|
|
962
|
+
const main = relativeDirectoryMain(relativePath, language, context);
|
|
963
|
+
if (main)
|
|
964
|
+
return main;
|
|
965
|
+
}
|
|
501
966
|
const candidatePath = relativePath === '' ? ext.slice(1) : relativePath + ext;
|
|
502
967
|
if (context.fileExists(candidatePath)) {
|
|
503
968
|
return candidatePath;
|
|
504
969
|
}
|
|
505
970
|
}
|
|
506
|
-
// Try without extension (might already have one)
|
|
507
971
|
if (context.fileExists(relativePath)) {
|
|
508
972
|
return relativePath;
|
|
509
973
|
}
|
|
510
974
|
return findSourceForEmittedSpecifier(relativePath, language, context);
|
|
511
975
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
976
|
+
const FOLDER_MAIN_LANGUAGES = new Set(['javascript', 'typescript', 'tsx', 'jsx']);
|
|
977
|
+
function packageJsonMain(text) {
|
|
978
|
+
let main;
|
|
979
|
+
try {
|
|
980
|
+
main = JSON.parse(text.replace(/^\uFEFF/, ''))?.main;
|
|
981
|
+
}
|
|
982
|
+
catch {
|
|
983
|
+
return null;
|
|
984
|
+
}
|
|
985
|
+
return typeof main === 'string' && main.trim() ? main.trim() : null;
|
|
986
|
+
}
|
|
987
|
+
function relativeDirectoryMain(dir, language, context) {
|
|
988
|
+
const manifestPath = dir === '' ? 'package.json' : `${dir}/package.json`;
|
|
989
|
+
const manifest = context.readFile(manifestPath);
|
|
990
|
+
if (!manifest)
|
|
991
|
+
return null;
|
|
992
|
+
context.noteModuleConfigFile?.(manifestPath);
|
|
993
|
+
const main = packageJsonMain(manifest);
|
|
994
|
+
if (!main)
|
|
995
|
+
return null;
|
|
996
|
+
const entry = path.posix.normalize(path.posix.join(dir, main));
|
|
997
|
+
if (entry.startsWith('..') || entry === '.')
|
|
998
|
+
return null;
|
|
999
|
+
return indexedTarget(entry, language, context);
|
|
1000
|
+
}
|
|
522
1001
|
const EMITTED_TO_SOURCE_EXTENSIONS = [
|
|
523
1002
|
[/\.js$/, ['.ts', '.tsx', '.d.ts']],
|
|
524
1003
|
[/\.jsx$/, ['.tsx']],
|
|
525
1004
|
[/\.mjs$/, ['.mts', '.d.mts']],
|
|
526
1005
|
[/\.cjs$/, ['.cts', '.d.cts']],
|
|
527
1006
|
];
|
|
528
|
-
function findSourceForEmittedSpecifier(relativePath, language, context) {
|
|
1007
|
+
function findSourceForEmittedSpecifier(relativePath, language, context, exists = (file) => context.fileExists(file)) {
|
|
529
1008
|
if (!EMITTED_SPECIFIER_LANGUAGES.has(language))
|
|
530
1009
|
return null;
|
|
531
1010
|
for (const [emitted, sources] of EMITTED_TO_SOURCE_EXTENSIONS) {
|
|
@@ -534,42 +1013,18 @@ function findSourceForEmittedSpecifier(relativePath, language, context) {
|
|
|
534
1013
|
const stem = relativePath.replace(emitted, '');
|
|
535
1014
|
for (const ext of sources) {
|
|
536
1015
|
const candidate = stem + ext;
|
|
537
|
-
if (
|
|
1016
|
+
if (exists(candidate))
|
|
538
1017
|
return candidate;
|
|
539
1018
|
}
|
|
540
1019
|
return null;
|
|
541
1020
|
}
|
|
542
1021
|
return null;
|
|
543
1022
|
}
|
|
544
|
-
/** Languages whose import specifiers can name the emitted `.js` of a `.ts` source. */
|
|
545
1023
|
const EMITTED_SPECIFIER_LANGUAGES = new Set([
|
|
546
1024
|
'typescript', 'tsx', 'javascript', 'jsx', 'vue', 'svelte', 'astro', 'arkts',
|
|
547
1025
|
]);
|
|
548
|
-
/**
|
|
549
|
-
* Resolve an aliased/absolute import.
|
|
550
|
-
*
|
|
551
|
-
* Tries, in order:
|
|
552
|
-
* 1. Project-defined `compilerOptions.paths` (tsconfig/jsconfig).
|
|
553
|
-
* Each pattern can have multiple replacements; tried in tsconfig
|
|
554
|
-
* priority order with extension permutations.
|
|
555
|
-
* 2. The legacy hard-coded fallback list (`@/`, `~/`, `src/`, ...)
|
|
556
|
-
* for projects that have aliases but no tsconfig paths block.
|
|
557
|
-
* 3. Direct path lookup (with extensions).
|
|
558
|
-
*/
|
|
559
1026
|
function resolveAliasedImport(importPath, projectRoot, language, context, fromFile) {
|
|
560
|
-
const
|
|
561
|
-
const tryWithExt = (basePath) => {
|
|
562
|
-
for (const ext of extensions) {
|
|
563
|
-
const candidate = basePath + ext;
|
|
564
|
-
if (context.fileExists(candidate))
|
|
565
|
-
return candidate;
|
|
566
|
-
}
|
|
567
|
-
if (context.fileExists(basePath))
|
|
568
|
-
return basePath;
|
|
569
|
-
return findSourceForEmittedSpecifier(basePath, language, context);
|
|
570
|
-
};
|
|
571
|
-
// 1. tsconfig/jsconfig paths: the config nearest the importing file (an
|
|
572
|
-
// app of a monorepo keeps its own `@/*`), then the project root's.
|
|
1027
|
+
const tryWithExt = (basePath) => tryWithExtensions(basePath, language, context);
|
|
573
1028
|
const nearest = fromFile ? context.getNearestAliases?.(fromFile) : null;
|
|
574
1029
|
const rootMap = context.getProjectAliases?.();
|
|
575
1030
|
for (const aliasMap of nearest && nearest !== rootMap ? [nearest, rootMap] : [rootMap]) {
|
|
@@ -582,20 +1037,26 @@ function resolveAliasedImport(importPath, projectRoot, language, context, fromFi
|
|
|
582
1037
|
return hit;
|
|
583
1038
|
}
|
|
584
1039
|
}
|
|
585
|
-
// 1.5 Workspace packages (`@scope/ui/widgets` → `packages/ui/widgets`).
|
|
586
|
-
// Resolves a monorepo member import to the member's directory; the
|
|
587
|
-
// extension/index permutations below then find its barrel (#629).
|
|
588
1040
|
const workspaces = context.getWorkspacePackages?.();
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
1041
|
+
const targets = workspaces ? (0, workspace_packages_1.workspaceImportTargets)(importPath, workspaces, fromFile) : null;
|
|
1042
|
+
if (targets) {
|
|
1043
|
+
const forBrowser = targets.browser.length > 0 && fromFile !== undefined && isBrowserCode(fromFile, context)
|
|
1044
|
+
? declaredWorkspaceEntry({ ...targets, declared: targets.browser }, language, context)
|
|
1045
|
+
: null;
|
|
1046
|
+
if (forBrowser)
|
|
1047
|
+
return forBrowser;
|
|
1048
|
+
const declared = declaredWorkspaceEntry(targets, language, context);
|
|
1049
|
+
if (declared)
|
|
1050
|
+
return declared;
|
|
1051
|
+
const direct = tryWithExt(targets.directory);
|
|
1052
|
+
if (direct && (context.isIndexedFile?.(direct) ?? true))
|
|
1053
|
+
return direct;
|
|
1054
|
+
const built = builtSourceOf(targets.directory, targets.packageDir, language, context);
|
|
1055
|
+
if (built)
|
|
1056
|
+
return built;
|
|
1057
|
+
if (direct)
|
|
1058
|
+
return direct;
|
|
596
1059
|
}
|
|
597
|
-
// 2. Hard-coded fallback list. Kept for projects that use these
|
|
598
|
-
// conventional aliases without declaring them in tsconfig.
|
|
599
1060
|
const fallbackAliases = {
|
|
600
1061
|
'@/': 'src/',
|
|
601
1062
|
'~/': 'src/',
|
|
@@ -611,69 +1072,128 @@ function resolveAliasedImport(importPath, projectRoot, language, context, fromFi
|
|
|
611
1072
|
return hit;
|
|
612
1073
|
}
|
|
613
1074
|
}
|
|
614
|
-
// 3. Direct path.
|
|
615
1075
|
return tryWithExt(importPath);
|
|
616
1076
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Discover C/C++ include search directories for a project.
|
|
630
|
-
*
|
|
631
|
-
* Strategy:
|
|
632
|
-
* 1. Look for compile_commands.json (Clang compilation database) in the
|
|
633
|
-
* project root and common build subdirectories. Parse -I and -isystem
|
|
634
|
-
* flags from compiler commands.
|
|
635
|
-
* 2. If no compilation database is found, probe for common convention
|
|
636
|
-
* directories (include/, src/, lib/, api/) and top-level directories
|
|
637
|
-
* containing .h/.hpp files.
|
|
638
|
-
*
|
|
639
|
-
* Returns paths relative to projectRoot.
|
|
640
|
-
*/
|
|
641
|
-
function loadCppIncludeDirs(projectRoot) {
|
|
642
|
-
const cached = cppIncludeDirCache.get(projectRoot);
|
|
643
|
-
if (cached !== undefined)
|
|
644
|
-
return cached;
|
|
645
|
-
const dirs = loadCppIncludeDirsFromCompileDB(projectRoot)
|
|
646
|
-
|| loadCppIncludeDirsHeuristic(projectRoot);
|
|
647
|
-
cppIncludeDirCache.set(projectRoot, dirs);
|
|
648
|
-
return dirs;
|
|
1077
|
+
function tryWithExtensions(basePath, language, context) {
|
|
1078
|
+
for (const ext of EXTENSION_RESOLUTION[language] || []) {
|
|
1079
|
+
const candidate = indexedSpelling(basePath + ext, language);
|
|
1080
|
+
if (context.fileExists(candidate))
|
|
1081
|
+
return candidate;
|
|
1082
|
+
}
|
|
1083
|
+
const asIs = indexedSpelling(basePath, language);
|
|
1084
|
+
if (context.fileExists(asIs))
|
|
1085
|
+
return asIs;
|
|
1086
|
+
return findSourceForEmittedSpecifier(asIs, language, context);
|
|
649
1087
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
function
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
1088
|
+
function indexedSpelling(filePath, language) {
|
|
1089
|
+
return exports.ESM_IMPORT_LANGUAGES.has(language) && /\/\/|(?:^|\/)\.\.?(?:\/|$)/.test(filePath)
|
|
1090
|
+
? path.posix.normalize(filePath)
|
|
1091
|
+
: filePath;
|
|
1092
|
+
}
|
|
1093
|
+
function declaredWorkspaceEntry(targets, language, context) {
|
|
1094
|
+
for (const target of targets.declared) {
|
|
1095
|
+
const hit = indexedTarget(target, language, context) ?? builtSourceOf(target, targets.packageDir, language, context);
|
|
1096
|
+
if (hit)
|
|
1097
|
+
return hit;
|
|
1098
|
+
}
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
const BROWSER_GLOBAL_READ = /(?<![\w$.])(?:document|window)\s*[.[]/;
|
|
1102
|
+
function isBrowserCode(file, context) {
|
|
1103
|
+
const source = context.readFile(file);
|
|
1104
|
+
return !!source && BROWSER_GLOBAL_READ.test((0, strip_comments_1.blankStringContents)((0, strip_comments_1.stripCommentsForRegex)(source, 'typescript')));
|
|
1105
|
+
}
|
|
1106
|
+
function builtSourceOf(target, packageDir, language, context) {
|
|
1107
|
+
for (const source of builtSourcesOf(target, packageDir)) {
|
|
1108
|
+
const hit = indexedTarget(source, language, context);
|
|
1109
|
+
if (hit)
|
|
1110
|
+
return hit;
|
|
1111
|
+
}
|
|
1112
|
+
return null;
|
|
1113
|
+
}
|
|
1114
|
+
function indexedTarget(target, language, context) {
|
|
1115
|
+
const indexed = (file) => context.isIndexedFile?.(file) ?? context.fileExists(file);
|
|
1116
|
+
const asIs = indexedSpelling(target, language);
|
|
1117
|
+
if (indexed(asIs))
|
|
1118
|
+
return asIs;
|
|
1119
|
+
for (const ext of EXTENSION_RESOLUTION[language] || []) {
|
|
1120
|
+
const candidate = indexedSpelling(target + ext, language);
|
|
1121
|
+
if (indexed(candidate))
|
|
1122
|
+
return candidate;
|
|
1123
|
+
}
|
|
1124
|
+
return findSourceForEmittedSpecifier(asIs, language, context, indexed);
|
|
1125
|
+
}
|
|
1126
|
+
const BUILD_ROOT = /^(?:dist|build|lib|out|output|es|esm|cjs|umd)\//;
|
|
1127
|
+
const BUILD_FORMAT = /^(?:esm|cjs|es|mjs|module|modules|commonjs|types|typings|umd|node|browser|src)\//;
|
|
1128
|
+
const EMITTED_EXTENSION = /(?:\.d)?\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
1129
|
+
function builtSourcesOf(target, packageDir) {
|
|
1130
|
+
const prefix = packageDir === '' ? '' : packageDir + '/';
|
|
1131
|
+
if (!target.startsWith(prefix))
|
|
1132
|
+
return [];
|
|
1133
|
+
const inPackage = target.slice(prefix.length);
|
|
1134
|
+
const root = BUILD_ROOT.exec(inPackage);
|
|
1135
|
+
if (!root)
|
|
1136
|
+
return [];
|
|
1137
|
+
const mirrored = inPackage.slice(root[0].length);
|
|
1138
|
+
const format = BUILD_FORMAT.exec(mirrored);
|
|
1139
|
+
const stems = [mirrored, ...(format ? [mirrored.slice(format[0].length)] : [])]
|
|
1140
|
+
.map((rest) => rest.replace(EMITTED_EXTENSION, ''))
|
|
1141
|
+
.filter((stem) => stem !== '' && !stem.startsWith('src/'));
|
|
1142
|
+
return [...new Set(stems)].map((stem) => `${prefix}src/${stem}`);
|
|
1143
|
+
}
|
|
1144
|
+
function resolveFromOwnConfig(importPath, fromFile, language, context) {
|
|
1145
|
+
const candidates = ownConfigCandidates(importPath, fromFile, language, context);
|
|
1146
|
+
if (!candidates)
|
|
1147
|
+
return null;
|
|
1148
|
+
const indexed = (file) => context.isIndexedFile?.(file) !== false;
|
|
1149
|
+
if (context.isDeclaredPackage?.(importPath, fromFile) !== false) {
|
|
1150
|
+
if (!EXTENSION_RESOLUTION[language]?.includes('.d.ts'))
|
|
1151
|
+
return null;
|
|
1152
|
+
for (const candidate of candidates) {
|
|
1153
|
+
const declarations = `${candidate}.d.ts`;
|
|
1154
|
+
if (context.fileExists(declarations) && indexed(declarations))
|
|
1155
|
+
return declarations;
|
|
673
1156
|
}
|
|
1157
|
+
return null;
|
|
674
1158
|
}
|
|
675
|
-
|
|
1159
|
+
for (const candidate of candidates) {
|
|
1160
|
+
const hit = tryWithExtensions(candidate, language, context);
|
|
1161
|
+
if (hit && indexed(hit))
|
|
1162
|
+
return hit;
|
|
1163
|
+
}
|
|
1164
|
+
return null;
|
|
1165
|
+
}
|
|
1166
|
+
function ownConfigCandidates(importPath, fromFile, language, context) {
|
|
1167
|
+
if (!exports.ESM_IMPORT_LANGUAGES.has(language) || !importPath || importPath.startsWith('//') || /^[A-Za-z][\w+.-]*:/.test(importPath))
|
|
676
1168
|
return null;
|
|
1169
|
+
const config = context.getNearestAliases?.(fromFile) ?? context.getProjectAliases?.();
|
|
1170
|
+
if (!config)
|
|
1171
|
+
return null;
|
|
1172
|
+
const candidates = importPath.startsWith('/')
|
|
1173
|
+
? (0, path_aliases_1.applyAliases)(importPath, config, context.getProjectRoot())
|
|
1174
|
+
: (0, path_aliases_1.aliasAndBaseUrlCandidates)(importPath, config, context.getProjectRoot());
|
|
1175
|
+
return candidates.length > 0 ? candidates : null;
|
|
1176
|
+
}
|
|
1177
|
+
function namesOwnConfigModule(importPath, fromFile, language, context) {
|
|
1178
|
+
return context.isDeclaredPackage?.(importPath, fromFile) === false &&
|
|
1179
|
+
resolveImportPath(importPath, fromFile, language, context) !== null;
|
|
1180
|
+
}
|
|
1181
|
+
exports.CPP_COMPILE_DB_FILES = [
|
|
1182
|
+
'compile_commands.json',
|
|
1183
|
+
'build/compile_commands.json',
|
|
1184
|
+
'cmake-build-debug/compile_commands.json',
|
|
1185
|
+
'cmake-build-release/compile_commands.json',
|
|
1186
|
+
'out/compile_commands.json',
|
|
1187
|
+
];
|
|
1188
|
+
function loadCppIncludeDirsFromCompileDB(projectRoot) {
|
|
1189
|
+
for (const file of exports.CPP_COMPILE_DB_FILES) {
|
|
1190
|
+
const dbPath = path.join(projectRoot, file);
|
|
1191
|
+
if (fs.statSync(dbPath, { throwIfNoEntry: false })?.isFile())
|
|
1192
|
+
return readCompileDbIncludeDirs(dbPath, projectRoot);
|
|
1193
|
+
}
|
|
1194
|
+
return null;
|
|
1195
|
+
}
|
|
1196
|
+
function readCompileDbIncludeDirs(dbPath, projectRoot) {
|
|
677
1197
|
try {
|
|
678
1198
|
const content = fs.readFileSync(dbPath, 'utf-8');
|
|
679
1199
|
const entries = JSON.parse(content);
|
|
@@ -686,24 +1206,18 @@ function loadCppIncludeDirsFromCompileDB(projectRoot) {
|
|
|
686
1206
|
for (let i = 0; i < args.length; i++) {
|
|
687
1207
|
const arg = args[i];
|
|
688
1208
|
let includeDir;
|
|
689
|
-
// -I<dir> (no space)
|
|
690
1209
|
if (arg.startsWith('-I') && arg.length > 2) {
|
|
691
1210
|
includeDir = arg.substring(2);
|
|
692
1211
|
}
|
|
693
|
-
// -isystem <dir> (space-separated)
|
|
694
1212
|
else if ((arg === '-isystem' || arg === '-I') && i + 1 < args.length) {
|
|
695
1213
|
includeDir = args[i + 1];
|
|
696
|
-
i++;
|
|
1214
|
+
i++;
|
|
697
1215
|
}
|
|
698
1216
|
if (includeDir) {
|
|
699
|
-
// Normalize: resolve relative to the compilation directory
|
|
700
1217
|
const absPath = path.isAbsolute(includeDir)
|
|
701
1218
|
? includeDir
|
|
702
1219
|
: path.resolve(dir, includeDir);
|
|
703
1220
|
const relPath = path.relative(projectRoot, absPath).replace(/\\/g, '/');
|
|
704
|
-
// Skip system directories and paths outside the project
|
|
705
|
-
// (relative paths starting with .. or absolute paths like
|
|
706
|
-
// /usr/include or C:\usr on Windows)
|
|
707
1221
|
if (!relPath.startsWith('..') && relPath.length > 0 && !path.isAbsolute(relPath)) {
|
|
708
1222
|
dirSet.add(relPath);
|
|
709
1223
|
}
|
|
@@ -716,15 +1230,10 @@ function loadCppIncludeDirsFromCompileDB(projectRoot) {
|
|
|
716
1230
|
return null;
|
|
717
1231
|
}
|
|
718
1232
|
}
|
|
719
|
-
/**
|
|
720
|
-
* Minimal shlex-style split for compiler command strings.
|
|
721
|
-
* Handles double-quoted and single-quoted arguments.
|
|
722
|
-
*/
|
|
723
1233
|
function shlexSplit(cmd) {
|
|
724
1234
|
const result = [];
|
|
725
1235
|
let i = 0;
|
|
726
1236
|
while (i < cmd.length) {
|
|
727
|
-
// Skip whitespace
|
|
728
1237
|
while (i < cmd.length && /\s/.test(cmd[i]))
|
|
729
1238
|
i++;
|
|
730
1239
|
if (i >= cmd.length)
|
|
@@ -743,7 +1252,7 @@ function shlexSplit(cmd) {
|
|
|
743
1252
|
}
|
|
744
1253
|
i++;
|
|
745
1254
|
}
|
|
746
|
-
i++;
|
|
1255
|
+
i++;
|
|
747
1256
|
result.push(arg);
|
|
748
1257
|
}
|
|
749
1258
|
else if (ch === "'") {
|
|
@@ -753,7 +1262,7 @@ function shlexSplit(cmd) {
|
|
|
753
1262
|
arg += cmd[i];
|
|
754
1263
|
i++;
|
|
755
1264
|
}
|
|
756
|
-
i++;
|
|
1265
|
+
i++;
|
|
757
1266
|
result.push(arg);
|
|
758
1267
|
}
|
|
759
1268
|
else {
|
|
@@ -767,10 +1276,6 @@ function shlexSplit(cmd) {
|
|
|
767
1276
|
}
|
|
768
1277
|
return result;
|
|
769
1278
|
}
|
|
770
|
-
/**
|
|
771
|
-
* Heuristic include directory discovery when no compile_commands.json exists.
|
|
772
|
-
* Checks common convention directories and scans top-level dirs for headers.
|
|
773
|
-
*/
|
|
774
1279
|
function loadCppIncludeDirsHeuristic(projectRoot) {
|
|
775
1280
|
const dirs = [];
|
|
776
1281
|
const conventionDirs = ['include', 'src', 'lib', 'api', 'inc'];
|
|
@@ -780,12 +1285,10 @@ function loadCppIncludeDirsHeuristic(projectRoot) {
|
|
|
780
1285
|
if (!entry.isDirectory())
|
|
781
1286
|
continue;
|
|
782
1287
|
const name = entry.name;
|
|
783
|
-
// Convention directories
|
|
784
1288
|
if (conventionDirs.includes(name.toLowerCase())) {
|
|
785
1289
|
dirs.push(name);
|
|
786
1290
|
continue;
|
|
787
1291
|
}
|
|
788
|
-
// Any top-level directory containing .h or .hpp files
|
|
789
1292
|
try {
|
|
790
1293
|
const subFiles = fs.readdirSync(path.join(projectRoot, name));
|
|
791
1294
|
if (subFiles.some(f => /\.(h|hpp|hxx|hh)$/i.test(f))) {
|
|
@@ -793,20 +1296,24 @@ function loadCppIncludeDirsHeuristic(projectRoot) {
|
|
|
793
1296
|
}
|
|
794
1297
|
}
|
|
795
1298
|
catch {
|
|
796
|
-
// ignore permission errors
|
|
797
1299
|
}
|
|
798
1300
|
}
|
|
799
1301
|
}
|
|
800
1302
|
catch {
|
|
801
|
-
// ignore
|
|
802
1303
|
}
|
|
803
1304
|
return dirs;
|
|
804
1305
|
}
|
|
805
|
-
/**
|
|
806
|
-
* Resolve a C/C++ include path by searching include directories.
|
|
807
|
-
* Called as a fallback after relative and aliased resolution fail.
|
|
808
|
-
*/
|
|
809
1306
|
function resolveCppIncludePath(importPath, language, context) {
|
|
1307
|
+
let memo = cppIncludeSearches.get(context);
|
|
1308
|
+
if (!memo)
|
|
1309
|
+
cppIncludeSearches.set(context, (memo = new Map()));
|
|
1310
|
+
const key = `${language}\0${importPath}`;
|
|
1311
|
+
let found = memo.get(key);
|
|
1312
|
+
if (found === undefined)
|
|
1313
|
+
memo.set(key, (found = searchCppIncludeDirs(importPath, language, context)));
|
|
1314
|
+
return found;
|
|
1315
|
+
}
|
|
1316
|
+
function searchCppIncludeDirs(importPath, language, context) {
|
|
810
1317
|
const includeDirs = context.getCppIncludeDirs?.() ?? [];
|
|
811
1318
|
const extensions = EXTENSION_RESOLUTION[language] ?? [];
|
|
812
1319
|
for (const dir of includeDirs) {
|
|
@@ -816,74 +1323,54 @@ function resolveCppIncludePath(importPath, language, context) {
|
|
|
816
1323
|
if (context.fileExists(candidate))
|
|
817
1324
|
return candidate;
|
|
818
1325
|
}
|
|
819
|
-
// Try as-is (already has extension)
|
|
820
1326
|
const candidate = normalizedDir + '/' + importPath;
|
|
821
1327
|
if (context.fileExists(candidate))
|
|
822
1328
|
return candidate;
|
|
823
1329
|
}
|
|
824
1330
|
return null;
|
|
825
1331
|
}
|
|
826
|
-
/**
|
|
827
|
-
* Is this reference a PHP include/require PATH (vs a namespace `use` symbol)?
|
|
828
|
-
*
|
|
829
|
-
* include/require emit a file path ("lib.php", "inc/db.php", "../x.php"),
|
|
830
|
-
* whereas namespace use is an FQN (App\Foo\Bar) or a bare class symbol
|
|
831
|
-
* (Closure). PHP identifiers contain neither '/' nor '.', so a slash or dot
|
|
832
|
-
* marks a path-shaped include. Such references resolve to files only — never
|
|
833
|
-
* to a same-named symbol — so callers must not fall back to the name-matcher.
|
|
834
|
-
*/
|
|
835
1332
|
function isPhpIncludePathRef(ref) {
|
|
836
1333
|
return (ref.language === 'php' &&
|
|
837
1334
|
ref.referenceKind === 'imports' &&
|
|
838
1335
|
(ref.referenceName.includes('/') || ref.referenceName.includes('.')));
|
|
839
1336
|
}
|
|
840
|
-
/**
|
|
841
|
-
* Is this a COBOL COPY / EXEC SQL INCLUDE copybook reference? These resolve
|
|
842
|
-
* to files only (or stay unresolved for compiler-supplied members) — never
|
|
843
|
-
* to a same-named symbol via the name-matcher.
|
|
844
|
-
*/
|
|
845
1337
|
function isCobolCopybookRef(ref) {
|
|
846
1338
|
return ref.language === 'cobol' && ref.referenceKind === 'imports';
|
|
847
1339
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
*/
|
|
1340
|
+
function isDartImportRef(ref) {
|
|
1341
|
+
return ref.language === 'dart' && ref.referenceKind === 'imports';
|
|
1342
|
+
}
|
|
1343
|
+
function isLuaRequireRef(ref) {
|
|
1344
|
+
return (ref.language === 'lua' || ref.language === 'luau') && ref.referenceKind === 'imports';
|
|
1345
|
+
}
|
|
855
1346
|
function resolvePhpIncludePath(includePath, fromFile, context) {
|
|
856
1347
|
const projectRoot = context.getProjectRoot();
|
|
1348
|
+
if (includePath.startsWith(`${php_1.PHP_DOCUMENT_ROOT}/`)) {
|
|
1349
|
+
const webRoot = context.getPhpWebRoot ? context.getPhpWebRoot(fromFile) : (0, project_config_1.loadWebRoot)(projectRoot);
|
|
1350
|
+
if (webRoot === null)
|
|
1351
|
+
return null;
|
|
1352
|
+
const target = (0, php_web_root_1.underWebRoot)(webRoot, includePath.slice(php_1.PHP_DOCUMENT_ROOT.length + 1));
|
|
1353
|
+
return target !== null && context.fileExists(target) ? target : null;
|
|
1354
|
+
}
|
|
857
1355
|
const fromDir = path.dirname(path.join(projectRoot, fromFile));
|
|
858
1356
|
const basePath = path.resolve(fromDir, includePath);
|
|
859
1357
|
const relativePath = path.relative(projectRoot, basePath).replace(/\\/g, '/');
|
|
860
1358
|
if (context.fileExists(relativePath))
|
|
861
1359
|
return relativePath;
|
|
862
|
-
|
|
1360
|
+
if (includePath.startsWith('./') || includePath.startsWith('../'))
|
|
1361
|
+
return null;
|
|
863
1362
|
for (const ext of EXTENSION_RESOLUTION.php ?? []) {
|
|
864
1363
|
if (context.fileExists(relativePath + ext))
|
|
865
1364
|
return relativePath + ext;
|
|
866
1365
|
}
|
|
867
1366
|
return null;
|
|
868
1367
|
}
|
|
869
|
-
/**
|
|
870
|
-
* Extract import mappings from a file
|
|
871
|
-
*/
|
|
872
1368
|
function extractImportMappings(_filePath, content, language) {
|
|
873
1369
|
const mappings = [];
|
|
874
1370
|
if (language === 'typescript' || language === 'javascript' || language === 'tsx' || language === 'jsx' || language === 'arkts') {
|
|
875
1371
|
mappings.push(...extractJSImports(content));
|
|
876
1372
|
}
|
|
877
1373
|
else if (language === 'svelte' || language === 'vue' || language === 'astro') {
|
|
878
|
-
// Svelte/Vue single-file components import via plain ES6 inside their
|
|
879
|
-
// `<script>` block (Astro: the `---` frontmatter). Without this, a
|
|
880
|
-
// `.svelte`/`.vue`/`.astro` consumer produces
|
|
881
|
-
// zero import mappings, so `resolveViaImport` can't run and a barrel
|
|
882
|
-
// import (`import { Foo } from './lib'`) falls back to name-matching —
|
|
883
|
-
// which silently fails whenever the re-export alias differs from the
|
|
884
|
-
// component's real name, yielding a false 0 callers (#629). The ES6
|
|
885
|
-
// import regex only matches `import … from '…'`, so running it over the
|
|
886
|
-
// whole SFC (markup + styles included) is safe.
|
|
887
1374
|
mappings.push(...extractJSImports(content));
|
|
888
1375
|
}
|
|
889
1376
|
else if (language === 'python') {
|
|
@@ -903,20 +1390,78 @@ function extractImportMappings(_filePath, content, language) {
|
|
|
903
1390
|
}
|
|
904
1391
|
return mappings;
|
|
905
1392
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
1393
|
+
const JS_IDENT = '[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*';
|
|
1394
|
+
const JS_STRING = `"(?:[^"\\\\\\n]|\\\\.)*"|'(?:[^'\\\\\\n]|\\\\.)*'`;
|
|
1395
|
+
const SPECIFIER_NAME = `(?:${JS_IDENT}|${JS_STRING})`;
|
|
1396
|
+
const TYPE_MODIFIER = '(?:type(?:of)?\\s+)';
|
|
1397
|
+
const SPECIFIER_ALIAS = new RegExp(`^${TYPE_MODIFIER}?(${SPECIFIER_NAME})\\s+as\\s+(${SPECIFIER_NAME})$`, 'u');
|
|
1398
|
+
const SPECIFIER_PLAIN = new RegExp(`^${TYPE_MODIFIER}?(${SPECIFIER_NAME})$`, 'u');
|
|
1399
|
+
const SPECIFIER_LIST = '[^{}]+';
|
|
1400
|
+
const ES_IMPORT_RE = new RegExp(`(?<![$.\\p{ID_Continue}])import(?:\\s+|(?=[{*]))(?:(?:type(?:of)?|defer)(?:\\s*(?=[{*])|\\s+(?!from(?![$\\p{ID_Continue}]))(?=[$_\\p{ID_Start}])))?` +
|
|
1401
|
+
`(?:(${JS_IDENT})(?![$\\u200c\\u200d\\p{ID_Continue}{])\\s*(?:,\\s*)?)?` +
|
|
1402
|
+
`(?:\\{(${SPECIFIER_LIST})\\}\\s*)?` +
|
|
1403
|
+
`(?:(\\*)\\s*as\\s+(${JS_IDENT})\\s*)?` +
|
|
1404
|
+
`from\\s*['"]([^'"]+)['"]`, 'gu');
|
|
1405
|
+
const WILDCARD_REEXPORT_RE = new RegExp(`(?<![$.\\p{ID_Continue}])export(?![$\\p{ID_Continue}])\\s*(?:type(?![$\\p{ID_Continue}])\\s*)?\\*(?:\\s*as(?:\\s+(${JS_IDENT})|\\s*(${JS_STRING})))?\\s*from\\s*['"]([^'"]+)['"]`, 'gu');
|
|
1406
|
+
const NAMED_REEXPORT_RE = new RegExp(`(?<![$.\\p{ID_Continue}])export(?![$\\p{ID_Continue}])\\s*(?:type(?![$\\p{ID_Continue}])\\s*)?\\{(${SPECIFIER_LIST})\\}\\s*from\\s*['"]([^'"]+)['"]`, 'gu');
|
|
1407
|
+
function splitSpecifierList(list) {
|
|
1408
|
+
const out = [];
|
|
1409
|
+
let start = 0;
|
|
1410
|
+
let quote = null;
|
|
1411
|
+
for (let i = 0; i < list.length; i++) {
|
|
1412
|
+
const ch = list[i];
|
|
1413
|
+
if (quote !== null) {
|
|
1414
|
+
if (ch === '\\')
|
|
1415
|
+
i++;
|
|
1416
|
+
else if (ch === quote)
|
|
1417
|
+
quote = null;
|
|
1418
|
+
}
|
|
1419
|
+
else if (ch === '"' || ch === "'") {
|
|
1420
|
+
quote = ch;
|
|
1421
|
+
}
|
|
1422
|
+
else if (ch === ',') {
|
|
1423
|
+
out.push(list.slice(start, i));
|
|
1424
|
+
start = i + 1;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
out.push(list.slice(start));
|
|
1428
|
+
return out;
|
|
1429
|
+
}
|
|
1430
|
+
const SIMPLE_ESCAPES = { n: '\n', t: '\t', r: '\r', b: '\b', f: '\f', v: '\v', '0': '\0' };
|
|
1431
|
+
function cleanSpecifierList(list) {
|
|
1432
|
+
return list.includes('/') ? stripJsComments(list) : list;
|
|
1433
|
+
}
|
|
1434
|
+
function withoutJsDocPrefixes(list) {
|
|
1435
|
+
return list.replace(/^[ \t]*\*(?!\/)/gm, '');
|
|
1436
|
+
}
|
|
1437
|
+
function unquoteSpecifier(name) {
|
|
1438
|
+
if (!/^["']/.test(name))
|
|
1439
|
+
return name;
|
|
1440
|
+
return name.slice(1, -1).replace(/\\(u\{[0-9a-fA-F]+\}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|[\s\S])/g, (_, esc) => {
|
|
1441
|
+
if (esc[0] === 'u' || esc[0] === 'x') {
|
|
1442
|
+
const hex = esc[1] === '{' ? esc.slice(2, -1) : esc.slice(1);
|
|
1443
|
+
const code = parseInt(hex, 16);
|
|
1444
|
+
return code <= 0x10ffff ? String.fromCodePoint(code) : esc;
|
|
1445
|
+
}
|
|
1446
|
+
return SIMPLE_ESCAPES[esc] ?? esc;
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
function parseSpecifier(raw) {
|
|
1450
|
+
const item = raw.trim();
|
|
1451
|
+
const alias = SPECIFIER_ALIAS.exec(item);
|
|
1452
|
+
if (alias)
|
|
1453
|
+
return { imported: unquoteSpecifier(alias[1]), local: unquoteSpecifier(alias[2]) };
|
|
1454
|
+
const plain = SPECIFIER_PLAIN.exec(item);
|
|
1455
|
+
if (plain) {
|
|
1456
|
+
const name = unquoteSpecifier(plain[1]);
|
|
1457
|
+
return { imported: name, local: name };
|
|
1458
|
+
}
|
|
1459
|
+
return null;
|
|
1460
|
+
}
|
|
909
1461
|
function extractJSImports(content) {
|
|
910
1462
|
const mappings = [];
|
|
911
|
-
|
|
912
|
-
// type-only form, not a default import named `type` — which every such
|
|
913
|
-
// line used to add, making `type.innerType()` a call on an import.
|
|
914
|
-
// (`import type from './x'` still binds `type`: backtracking gives it back.)
|
|
915
|
-
const importRegex = /import\s+(?:type\s+(?=[{*]|(?!from\b)\w))?(?:(\w+)\s*,?\s*)?(?:\{([^}]+)\})?\s*(?:(\*)\s+as\s+(\w+))?\s*from\s*['"]([^'"]+)['"]/g;
|
|
916
|
-
let match;
|
|
917
|
-
while ((match = importRegex.exec(content)) !== null) {
|
|
1463
|
+
for (const match of content.matchAll(ES_IMPORT_RE)) {
|
|
918
1464
|
const [, defaultImport, namedImports, star, namespaceAlias, source] = match;
|
|
919
|
-
// Default import
|
|
920
1465
|
if (defaultImport) {
|
|
921
1466
|
mappings.push({
|
|
922
1467
|
localName: defaultImport,
|
|
@@ -926,33 +1471,21 @@ function extractJSImports(content) {
|
|
|
926
1471
|
isNamespace: false,
|
|
927
1472
|
});
|
|
928
1473
|
}
|
|
929
|
-
// Named imports
|
|
930
1474
|
if (namedImports) {
|
|
931
|
-
|
|
932
|
-
const
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
if (aliasMatch) {
|
|
936
|
-
mappings.push({
|
|
937
|
-
localName: aliasMatch[2],
|
|
938
|
-
exportedName: aliasMatch[1],
|
|
939
|
-
source: source,
|
|
940
|
-
isDefault: false,
|
|
941
|
-
isNamespace: false,
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
else if (name) {
|
|
1475
|
+
const list = content[match.index - 1] === '@' ? withoutJsDocPrefixes(namedImports) : namedImports;
|
|
1476
|
+
for (const name of splitSpecifierList(cleanSpecifierList(list))) {
|
|
1477
|
+
const specifier = parseSpecifier(name);
|
|
1478
|
+
if (specifier) {
|
|
945
1479
|
mappings.push({
|
|
946
|
-
localName:
|
|
947
|
-
exportedName:
|
|
1480
|
+
localName: specifier.local,
|
|
1481
|
+
exportedName: specifier.imported,
|
|
948
1482
|
source: source,
|
|
949
|
-
isDefault:
|
|
1483
|
+
isDefault: specifier.imported === 'default',
|
|
950
1484
|
isNamespace: false,
|
|
951
1485
|
});
|
|
952
1486
|
}
|
|
953
1487
|
}
|
|
954
1488
|
}
|
|
955
|
-
// Namespace import
|
|
956
1489
|
if (star && namespaceAlias) {
|
|
957
1490
|
mappings.push({
|
|
958
1491
|
localName: namespaceAlias,
|
|
@@ -963,11 +1496,12 @@ function extractJSImports(content) {
|
|
|
963
1496
|
});
|
|
964
1497
|
}
|
|
965
1498
|
}
|
|
966
|
-
|
|
967
|
-
// request = require('supertest')`), and a member of the module (`require('./utils').methods`).
|
|
1499
|
+
let match;
|
|
968
1500
|
const requireRegex = /(?:\b(?:const|let|var)\s+|,\s*)(?:([A-Za-z_$][\w$]*)|{([^}]+)})\s*=\s*require\(\s*['"]([^'"]+)['"]\s*\)(?:\s*\.\s*([A-Za-z_$][\w$]*))?/g;
|
|
969
1501
|
while ((match = requireRegex.exec(content)) !== null) {
|
|
970
1502
|
const [, defaultName, destructured, source, member] = match;
|
|
1503
|
+
if (source.startsWith('.') && /^\s*\(/.test(content.slice(requireRegex.lastIndex, requireRegex.lastIndex + 40)))
|
|
1504
|
+
continue;
|
|
971
1505
|
if (defaultName) {
|
|
972
1506
|
mappings.push({
|
|
973
1507
|
localName: defaultName,
|
|
@@ -980,7 +1514,7 @@ function extractJSImports(content) {
|
|
|
980
1514
|
if (destructured) {
|
|
981
1515
|
const names = destructured.split(',').map((s) => s.trim());
|
|
982
1516
|
for (const name of names) {
|
|
983
|
-
const aliasMatch = name.match(/(\w
|
|
1517
|
+
const aliasMatch = name.match(/([A-Za-z_$][\w$]*)\s*:\s*([A-Za-z_$][\w$]*)/);
|
|
984
1518
|
if (aliasMatch) {
|
|
985
1519
|
mappings.push({
|
|
986
1520
|
localName: aliasMatch[2],
|
|
@@ -1004,87 +1538,56 @@ function extractJSImports(content) {
|
|
|
1004
1538
|
}
|
|
1005
1539
|
return mappings;
|
|
1006
1540
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
localName: aliasMatch[2],
|
|
1024
|
-
exportedName: aliasMatch[1],
|
|
1025
|
-
source: source,
|
|
1026
|
-
isDefault: false,
|
|
1027
|
-
isNamespace: false,
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
else if (name && name !== '*') {
|
|
1031
|
-
mappings.push({
|
|
1032
|
-
localName: name,
|
|
1033
|
-
exportedName: name,
|
|
1034
|
-
source: source,
|
|
1035
|
-
isDefault: false,
|
|
1036
|
-
isNamespace: false,
|
|
1037
|
-
});
|
|
1541
|
+
function pythonFromImports(code) {
|
|
1542
|
+
const out = [];
|
|
1543
|
+
const fromRe = /^[ \t]*from[ \t]+(\.*[\w.]*)[ \t]+import[ \t]*(\([^)]*\)|(?:[^\n\\;]|\\\r?\n)+)/gm;
|
|
1544
|
+
let m;
|
|
1545
|
+
while ((m = fromRe.exec(code)) !== null) {
|
|
1546
|
+
const source = m[1];
|
|
1547
|
+
if (!source)
|
|
1548
|
+
continue;
|
|
1549
|
+
const list = m[2].replace(/^\(|\)$/g, '').replace(/\\\r?\n/g, ' ');
|
|
1550
|
+
const names = [];
|
|
1551
|
+
let star = false;
|
|
1552
|
+
for (const raw of list.split(',')) {
|
|
1553
|
+
const item = raw.trim();
|
|
1554
|
+
if (item === '*') {
|
|
1555
|
+
star = true;
|
|
1556
|
+
continue;
|
|
1038
1557
|
}
|
|
1558
|
+
const im = item.match(/^(\w+)(?:\s+as\s+(\w+))?$/);
|
|
1559
|
+
if (im)
|
|
1560
|
+
names.push({ name: im[1], alias: im[2] ?? im[1] });
|
|
1039
1561
|
}
|
|
1562
|
+
out.push({ source, names, star });
|
|
1040
1563
|
}
|
|
1041
|
-
|
|
1042
|
-
const importRegex = /^import\s+([\w.]+)(?:\s+as\s+(\w+))?/gm;
|
|
1043
|
-
while ((match = importRegex.exec(content)) !== null) {
|
|
1044
|
-
const [, source, alias] = match;
|
|
1045
|
-
const localName = alias || source.split('.').pop();
|
|
1046
|
-
mappings.push({
|
|
1047
|
-
localName,
|
|
1048
|
-
exportedName: '*',
|
|
1049
|
-
source: source,
|
|
1050
|
-
isDefault: false,
|
|
1051
|
-
isNamespace: true,
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
return mappings;
|
|
1564
|
+
return out;
|
|
1055
1565
|
}
|
|
1056
|
-
|
|
1057
|
-
* Extract Go import mappings
|
|
1058
|
-
*/
|
|
1059
|
-
function extractGoImports(content) {
|
|
1566
|
+
function extractPythonImports(content) {
|
|
1060
1567
|
const mappings = [];
|
|
1061
|
-
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
isNamespace: true,
|
|
1073
|
-
});
|
|
1568
|
+
const code = (0, strip_comments_1.stripCommentsForRegex)(content, 'python');
|
|
1569
|
+
for (const { source, names } of pythonFromImports(code)) {
|
|
1570
|
+
for (const { name, alias } of names) {
|
|
1571
|
+
mappings.push({
|
|
1572
|
+
localName: alias,
|
|
1573
|
+
exportedName: name,
|
|
1574
|
+
source,
|
|
1575
|
+
isDefault: false,
|
|
1576
|
+
isNamespace: false,
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1074
1579
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
while ((match =
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
const [, alias, source] = lineMatch;
|
|
1083
|
-
const packageName = source.split('/').pop();
|
|
1580
|
+
const importRe = /^import[ \t]+((?:[^\n\\;]|\\\r?\n)+)/gm;
|
|
1581
|
+
let match;
|
|
1582
|
+
while ((match = importRe.exec(code)) !== null) {
|
|
1583
|
+
for (const raw of match[1].replace(/\\\r?\n/g, ' ').split(',')) {
|
|
1584
|
+
const im = raw.trim().match(/^([\w.]+)(?:\s+as\s+(\w+))?$/);
|
|
1585
|
+
if (!im)
|
|
1586
|
+
continue;
|
|
1084
1587
|
mappings.push({
|
|
1085
|
-
localName:
|
|
1588
|
+
localName: im[2] || im[1].split('.').pop(),
|
|
1086
1589
|
exportedName: '*',
|
|
1087
|
-
source:
|
|
1590
|
+
source: im[1],
|
|
1088
1591
|
isDefault: false,
|
|
1089
1592
|
isNamespace: true,
|
|
1090
1593
|
});
|
|
@@ -1092,34 +1595,69 @@ function extractGoImports(content) {
|
|
|
1092
1595
|
}
|
|
1093
1596
|
return mappings;
|
|
1094
1597
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
*
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1598
|
+
function extractGoImports(content) {
|
|
1599
|
+
const specs = [];
|
|
1600
|
+
const code = (0, strip_comments_1.stripCommentsForRegex)(content.slice(0, goImportsEnd(content)), 'go');
|
|
1601
|
+
const singleImportRegex = /\bimport\s+(?:([A-Za-z_]\w*)[ \t]*)?["']([^"']+)["']/g;
|
|
1602
|
+
let match;
|
|
1603
|
+
while ((match = singleImportRegex.exec(code)) !== null) {
|
|
1604
|
+
specs.push({ name: match[1], source: match[2] });
|
|
1605
|
+
}
|
|
1606
|
+
const blockImportRegex = /\bimport\s*\(\s*([^)]+)\s*\)/g;
|
|
1607
|
+
while ((match = blockImportRegex.exec(code)) !== null) {
|
|
1608
|
+
const lineRegex = /(?:([A-Za-z_]\w*|\.)[ \t]*)?["']([^"']+)["']/g;
|
|
1609
|
+
let lineMatch;
|
|
1610
|
+
while ((lineMatch = lineRegex.exec(match[1])) !== null) {
|
|
1611
|
+
specs.push({ name: lineMatch[1], source: lineMatch[2] });
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
const mapping = (localName, source) => ({ localName, exportedName: '*', source, isDefault: false, isNamespace: true });
|
|
1615
|
+
const explicit = new Set(specs.flatMap(({ name }) => (name !== undefined && name !== '.' && name !== '_' ? [name] : [])));
|
|
1616
|
+
const mappings = specs
|
|
1617
|
+
.map(({ name, source }) => ({ explicitly: name !== undefined && name !== '.', localName: name === undefined || name === '.' ? source.split('/').pop() : name, source }))
|
|
1618
|
+
.filter(({ explicitly, localName }) => explicitly || !explicit.has(localName))
|
|
1619
|
+
.map(({ localName, source }) => mapping(localName, source));
|
|
1620
|
+
const bound = new Set(mappings.map((m) => m.localName));
|
|
1621
|
+
const assumed = new Map();
|
|
1622
|
+
for (const { name, source } of specs) {
|
|
1623
|
+
if (name !== undefined)
|
|
1624
|
+
continue;
|
|
1625
|
+
const assumedName = goAssumedPackageName(source);
|
|
1626
|
+
if (assumedName && !bound.has(assumedName))
|
|
1627
|
+
assumed.set(assumedName, [...(assumed.get(assumedName) ?? []), source]);
|
|
1628
|
+
}
|
|
1629
|
+
for (const [localName, sources] of assumed) {
|
|
1630
|
+
if (sources.length === 1)
|
|
1631
|
+
mappings.push(mapping(localName, sources[0]));
|
|
1632
|
+
}
|
|
1633
|
+
return mappings;
|
|
1634
|
+
}
|
|
1635
|
+
function goImportsEnd(content) {
|
|
1636
|
+
const decl = /^(?:func|type|var|const)\b/gm;
|
|
1637
|
+
for (let m; (m = decl.exec(content)) !== null;) {
|
|
1638
|
+
if (content.lastIndexOf('/*', m.index) <= content.lastIndexOf('*/', m.index))
|
|
1639
|
+
return m.index;
|
|
1640
|
+
}
|
|
1641
|
+
return content.length;
|
|
1642
|
+
}
|
|
1643
|
+
function goAssumedPackageName(importPath) {
|
|
1644
|
+
const elements = importPath.split('/');
|
|
1645
|
+
let base = elements[elements.length - 1];
|
|
1646
|
+
if (elements.length > 1 && /^v\d+$/.test(base))
|
|
1647
|
+
base = elements[elements.length - 2];
|
|
1648
|
+
if (base.startsWith('go-'))
|
|
1649
|
+
base = base.slice(3);
|
|
1650
|
+
return /^[\p{L}\p{Nd}_]*/u.exec(base)[0];
|
|
1651
|
+
}
|
|
1109
1652
|
function extractJavaImports(content) {
|
|
1110
1653
|
const mappings = [];
|
|
1111
|
-
// Strip line and block comments so `// import foo;` doesn't false-match.
|
|
1112
1654
|
const stripped = content
|
|
1113
1655
|
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
1114
1656
|
.replace(/\/\/[^\n]*/g, '');
|
|
1115
|
-
// `import [static] <fqn>[.*];` — and Kotlin's `import <fqn> [as Alias]`, with no `;`.
|
|
1116
1657
|
const re = /^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)(?:\s+as\s+([\w]+))?\s*(?:;|$)/gm;
|
|
1117
1658
|
let match;
|
|
1118
1659
|
while ((match = re.exec(stripped)) !== null) {
|
|
1119
1660
|
const fqn = match[2];
|
|
1120
|
-
// `import com.example.*;` — wildcard. We can't materialize a single
|
|
1121
|
-
// local name; skip and let name-matching handle members reachable
|
|
1122
|
-
// through the wildcard. (Future enhancement: enumerate package files.)
|
|
1123
1661
|
if (fqn.endsWith('.*'))
|
|
1124
1662
|
continue;
|
|
1125
1663
|
const parts = fqn.split('.');
|
|
@@ -1136,12 +1674,8 @@ function extractJavaImports(content) {
|
|
|
1136
1674
|
}
|
|
1137
1675
|
return mappings;
|
|
1138
1676
|
}
|
|
1139
|
-
/**
|
|
1140
|
-
* Extract PHP import mappings (use statements)
|
|
1141
|
-
*/
|
|
1142
1677
|
function extractPHPImports(content) {
|
|
1143
1678
|
const mappings = [];
|
|
1144
|
-
// use Namespace\Class; or use Namespace\Class as Alias;
|
|
1145
1679
|
const useRegex = /use\s+([\w\\]+)(?:\s+as\s+(\w+))?;/g;
|
|
1146
1680
|
let match;
|
|
1147
1681
|
while ((match = useRegex.exec(content)) !== null) {
|
|
@@ -1157,23 +1691,12 @@ function extractPHPImports(content) {
|
|
|
1157
1691
|
}
|
|
1158
1692
|
return mappings;
|
|
1159
1693
|
}
|
|
1160
|
-
/**
|
|
1161
|
-
* Extract C/C++ import mappings from #include directives.
|
|
1162
|
-
*
|
|
1163
|
-
* #include brings all symbols from the included header into scope
|
|
1164
|
-
* (namespace import), so each mapping uses isNamespace: true and
|
|
1165
|
-
* exportedName: '*'. The localName is set to the header's basename
|
|
1166
|
-
* without extension so that symbol references like `MyClass` can
|
|
1167
|
-
* match against any include that might provide it.
|
|
1168
|
-
*/
|
|
1169
1694
|
function extractCppImports(content) {
|
|
1170
1695
|
const mappings = [];
|
|
1171
|
-
// Match both #include <...> and #include "..."
|
|
1172
1696
|
const includeRegex = /^\s*#\s*include\s+[<"]([^>"]+)[>"]/gm;
|
|
1173
1697
|
let match;
|
|
1174
1698
|
while ((match = includeRegex.exec(content)) !== null) {
|
|
1175
1699
|
const modulePath = match[1];
|
|
1176
|
-
// Basename without extension for localName matching
|
|
1177
1700
|
const basename = modulePath.split('/').pop().replace(/\.(h|hpp|hxx|hh|inl|ipp|cxx|cc|cpp)$/, '');
|
|
1178
1701
|
mappings.push({
|
|
1179
1702
|
localName: basename || modulePath,
|
|
@@ -1185,27 +1708,6 @@ function extractCppImports(content) {
|
|
|
1185
1708
|
}
|
|
1186
1709
|
return mappings;
|
|
1187
1710
|
}
|
|
1188
|
-
// Cache import mappings per file to avoid re-reading and re-parsing
|
|
1189
|
-
const importMappingCache = new Map();
|
|
1190
|
-
/**
|
|
1191
|
-
* Clear the import mapping cache (call between indexing runs)
|
|
1192
|
-
*/
|
|
1193
|
-
function clearImportMappingCache() {
|
|
1194
|
-
importMappingCache.clear();
|
|
1195
|
-
cppIncludeDirCache.clear();
|
|
1196
|
-
}
|
|
1197
|
-
/**
|
|
1198
|
-
* Strip JS line + block comments from `content` while preserving
|
|
1199
|
-
* string literals (so `"//"` inside a string stays intact). Used by
|
|
1200
|
-
* {@link extractReExports} so commented-out export-from statements
|
|
1201
|
-
* don't generate phantom re-export edges.
|
|
1202
|
-
*
|
|
1203
|
-
* Scanner is deliberately small: it only tracks the three contexts
|
|
1204
|
-
* relevant for JS/TS — single-quote string, double-quote string, and
|
|
1205
|
-
* template literal. Comment recognition is the JS spec subset, no
|
|
1206
|
-
* regex-literal awareness (which is fine for our use case: we don't
|
|
1207
|
-
* apply this to function bodies, only to top-level files).
|
|
1208
|
-
*/
|
|
1209
1711
|
function stripJsComments(content) {
|
|
1210
1712
|
let out = '';
|
|
1211
1713
|
let i = 0;
|
|
@@ -1240,6 +1742,7 @@ function stripJsComments(content) {
|
|
|
1240
1742
|
while (i < content.length && !(content[i] === '*' && content[i + 1] === '/'))
|
|
1241
1743
|
i++;
|
|
1242
1744
|
i += 2;
|
|
1745
|
+
out += ' ';
|
|
1243
1746
|
continue;
|
|
1244
1747
|
}
|
|
1245
1748
|
out += ch;
|
|
@@ -1247,22 +1750,9 @@ function stripJsComments(content) {
|
|
|
1247
1750
|
}
|
|
1248
1751
|
return out;
|
|
1249
1752
|
}
|
|
1250
|
-
/**
|
|
1251
|
-
* Extract JS/TS re-export declarations from `content`.
|
|
1252
|
-
*
|
|
1253
|
-
* Recognised forms:
|
|
1254
|
-
* export { foo } from './a';
|
|
1255
|
-
* export { foo as bar } from './a';
|
|
1256
|
-
* export * from './a';
|
|
1257
|
-
* export * as ns from './a'; (treated as wildcard for chasing)
|
|
1258
|
-
* export { default as Foo } from './a';
|
|
1259
|
-
*
|
|
1260
|
-
* The walker intentionally stays regex-based — the import-resolver
|
|
1261
|
-
* elsewhere in this file already chooses regex over a fresh
|
|
1262
|
-
* tree-sitter pass, and this function shares that trade-off. Errors
|
|
1263
|
-
* fall through silently; resolution simply skips the broken file.
|
|
1264
|
-
*/
|
|
1265
1753
|
function extractReExports(content, language) {
|
|
1754
|
+
if (language === 'python')
|
|
1755
|
+
return extractPythonReExports(content);
|
|
1266
1756
|
if (language !== 'typescript' &&
|
|
1267
1757
|
language !== 'javascript' &&
|
|
1268
1758
|
language !== 'tsx' &&
|
|
@@ -1271,60 +1761,39 @@ function extractReExports(content, language) {
|
|
|
1271
1761
|
return [];
|
|
1272
1762
|
}
|
|
1273
1763
|
const out = [];
|
|
1274
|
-
// Pre-strip block comments + line comments so a commented-out
|
|
1275
|
-
// `// export { x } from '...'` doesn't produce a phantom edge.
|
|
1276
|
-
// (Template literals are still a possible source of false positives;
|
|
1277
|
-
// a project that builds export statements as runtime strings is
|
|
1278
|
-
// out of scope.)
|
|
1279
1764
|
const cleaned = stripJsComments(content);
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
while ((m = wildcardRe.exec(cleaned)) !== null) {
|
|
1284
|
-
out.push(m[1] ? { kind: 'namespace', exportedName: m[1], source: m[2] } : { kind: 'wildcard', source: m[2] });
|
|
1765
|
+
for (const m of cleaned.matchAll(WILDCARD_REEXPORT_RE)) {
|
|
1766
|
+
const ns = m[1] ?? (m[2] ? m[2].slice(1, -1) : undefined);
|
|
1767
|
+
out.push(ns ? { kind: 'namespace', exportedName: ns, source: m[3] } : { kind: 'wildcard', source: m[3] });
|
|
1285
1768
|
}
|
|
1286
|
-
|
|
1287
|
-
const namedRe = /export\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g;
|
|
1288
|
-
while ((m = namedRe.exec(cleaned)) !== null) {
|
|
1769
|
+
for (const m of cleaned.matchAll(NAMED_REEXPORT_RE)) {
|
|
1289
1770
|
const inner = m[1];
|
|
1290
1771
|
const source = m[2];
|
|
1291
|
-
for (const raw of inner
|
|
1292
|
-
const
|
|
1293
|
-
if (!
|
|
1772
|
+
for (const raw of splitSpecifierList(cleanSpecifierList(inner))) {
|
|
1773
|
+
const specifier = parseSpecifier(raw);
|
|
1774
|
+
if (!specifier)
|
|
1294
1775
|
continue;
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
}
|
|
1776
|
+
out.push({
|
|
1777
|
+
kind: 'named',
|
|
1778
|
+
exportedName: specifier.local,
|
|
1779
|
+
originalName: specifier.imported,
|
|
1780
|
+
source,
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
return out;
|
|
1785
|
+
}
|
|
1786
|
+
function extractPythonReExports(content) {
|
|
1787
|
+
const out = [];
|
|
1788
|
+
for (const { source, names, star } of pythonFromImports((0, strip_comments_1.stripCommentsForRegex)(content, 'python'))) {
|
|
1789
|
+
if (star)
|
|
1790
|
+
out.push({ kind: 'wildcard', source });
|
|
1791
|
+
for (const { name, alias } of names) {
|
|
1792
|
+
out.push({ kind: 'named', exportedName: alias, originalName: name, source });
|
|
1312
1793
|
}
|
|
1313
1794
|
}
|
|
1314
1795
|
return out;
|
|
1315
1796
|
}
|
|
1316
|
-
/**
|
|
1317
|
-
* Resolve a reference using import mappings
|
|
1318
|
-
*/
|
|
1319
|
-
/**
|
|
1320
|
-
* JVM (Java / Kotlin) imports use fully-qualified names (`import
|
|
1321
|
-
* com.example.foo.Bar`) decoupled from filenames, so the JS/Python
|
|
1322
|
-
* style filesystem path lookup misses them whenever the file isn't
|
|
1323
|
-
* named after its primary symbol (Kotlin `Utils.kt` exporting `Bar`,
|
|
1324
|
-
* top-level fns, extension fns). Resolve them through the
|
|
1325
|
-
* `qualifiedName` index instead — populated by the package_header /
|
|
1326
|
-
* package_declaration namespace wrappers in the extractor.
|
|
1327
|
-
*/
|
|
1328
1797
|
function resolveJvmImport(ref, context) {
|
|
1329
1798
|
if (ref.referenceKind !== 'imports')
|
|
1330
1799
|
return null;
|
|
@@ -1336,20 +1805,18 @@ function resolveJvmImport(ref, context) {
|
|
|
1336
1805
|
return null;
|
|
1337
1806
|
const pkg = fqn.substring(0, lastDot);
|
|
1338
1807
|
const sym = fqn.substring(lastDot + 1);
|
|
1339
|
-
// Wildcard imports (`com.example.*`) deliberately punt to name-matcher.
|
|
1340
1808
|
if (sym === '*')
|
|
1341
1809
|
return null;
|
|
1342
1810
|
const candidates = context.getNodesByQualifiedName(`${pkg}::${sym}`);
|
|
1343
|
-
if (candidates.length === 0)
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
const best = candidates.length === 1 ? candidates[0] : pickClosestJvmCandidate(candidates, ref.filePath);
|
|
1811
|
+
if (candidates.length === 0) {
|
|
1812
|
+
if (ref.language !== 'java' || !/^\w+Kt$/.test(sym))
|
|
1813
|
+
return null;
|
|
1814
|
+
const file = context
|
|
1815
|
+
.getNodesByName(`${sym.slice(0, -2)}.kt`)
|
|
1816
|
+
.find((n) => n.kind === 'file' && context.getNodesInFile(n.filePath).some((d) => d.kind === 'namespace' && d.qualifiedName === pkg));
|
|
1817
|
+
return file ? { original: ref, targetNodeId: file.id, confidence: 0.9, resolvedBy: 'import' } : null;
|
|
1818
|
+
}
|
|
1819
|
+
const best = candidates.length === 1 ? candidates[0] : pickJvmDeclaration(candidates, ref);
|
|
1353
1820
|
return {
|
|
1354
1821
|
original: ref,
|
|
1355
1822
|
targetNodeId: best.id,
|
|
@@ -1357,7 +1824,6 @@ function resolveJvmImport(ref, context) {
|
|
|
1357
1824
|
resolvedBy: 'import',
|
|
1358
1825
|
};
|
|
1359
1826
|
}
|
|
1360
|
-
/** `Alias` / `Alias.member` through a renaming Kotlin import, by the imported FQN. */
|
|
1361
1827
|
function resolveJvmAlias(ref, imports, context) {
|
|
1362
1828
|
const dot = ref.referenceName.indexOf('.');
|
|
1363
1829
|
const root = dot < 0 ? ref.referenceName : ref.referenceName.slice(0, dot);
|
|
@@ -1365,7 +1831,6 @@ function resolveJvmAlias(ref, imports, context) {
|
|
|
1365
1831
|
if (!imp)
|
|
1366
1832
|
return null;
|
|
1367
1833
|
const parts = imp.source.split('.');
|
|
1368
|
-
// The package is some prefix of the FQN; the rest is the type path (`Outer::Inner`).
|
|
1369
1834
|
for (let i = parts.length - 1; i > 0; i--) {
|
|
1370
1835
|
const target = context.getNodesByQualifiedName(`${parts.slice(0, i).join('.')}::${parts.slice(i).join('::')}`)[0];
|
|
1371
1836
|
if (!target)
|
|
@@ -1380,12 +1845,6 @@ function resolveJvmAlias(ref, imports, context) {
|
|
|
1380
1845
|
}
|
|
1381
1846
|
return null;
|
|
1382
1847
|
}
|
|
1383
|
-
/**
|
|
1384
|
-
* Pick the same-FQN candidate closest to `fromPath` by shared directory
|
|
1385
|
-
* prefix, preferring an `expect` declaration on a tie. Used to keep a Kotlin
|
|
1386
|
-
* Multiplatform `expect`/`actual` import resolving within the importer's own
|
|
1387
|
-
* source set instead of an arbitrary platform `actual`.
|
|
1388
|
-
*/
|
|
1389
1848
|
function pickClosestJvmCandidate(candidates, fromPath) {
|
|
1390
1849
|
const fromDirs = fromPath.split('/').slice(0, -1);
|
|
1391
1850
|
const sharedPrefix = (p) => {
|
|
@@ -1412,13 +1871,34 @@ function pickClosestJvmCandidate(candidates, fromPath) {
|
|
|
1412
1871
|
}
|
|
1413
1872
|
return best;
|
|
1414
1873
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1874
|
+
function kmpSourceSet(filePath) {
|
|
1875
|
+
return /(?:^|\/)src\/([^/]+)\//.exec(filePath)?.[1] ?? null;
|
|
1876
|
+
}
|
|
1877
|
+
function kmpBuildTarget(set) {
|
|
1878
|
+
return set.replace(/(?:Main|(?:Unit|Instrumented|Device|Host)?Test)$/, '');
|
|
1879
|
+
}
|
|
1880
|
+
const KMP_JVM_TARGET = /^(?:android|jvm|desktop)/;
|
|
1881
|
+
function pickJvmDeclaration(declarations, ref) {
|
|
1882
|
+
const actuals = declarations.filter((n) => n.decorators?.includes('actual'));
|
|
1883
|
+
if (actuals.length === 0 || actuals.length === declarations.length)
|
|
1884
|
+
return pickClosestJvmCandidate(declarations, ref.filePath);
|
|
1885
|
+
const set = kmpSourceSet(ref.filePath);
|
|
1886
|
+
const target = set === null ? null : kmpBuildTarget(set);
|
|
1887
|
+
const targetOf = (n) => kmpBuildTarget(kmpSourceSet(n.filePath) ?? '');
|
|
1888
|
+
if (target?.startsWith('common') || (target === null && ref.language !== 'java'))
|
|
1889
|
+
return pickClosestJvmCandidate(declarations, ref.filePath);
|
|
1890
|
+
const own = actuals.filter((n) => targetOf(n) === target);
|
|
1891
|
+
if (own.length > 0)
|
|
1892
|
+
return pickClosestJvmCandidate(own, ref.filePath);
|
|
1893
|
+
if (ref.language === 'java' || target === 'main' || target === 'test') {
|
|
1894
|
+
const jvm = actuals.filter((n) => KMP_JVM_TARGET.test(targetOf(n)));
|
|
1895
|
+
const android = /android/i.test(ref.filePath);
|
|
1896
|
+
const named = jvm.filter((n) => targetOf(n).startsWith('android') === android);
|
|
1897
|
+
return pickClosestJvmCandidate(named.length > 0 ? named : jvm.length > 0 ? jvm : actuals, ref.filePath);
|
|
1898
|
+
}
|
|
1899
|
+
const above = actuals.filter((n) => targetOf(n) !== '' && target.startsWith(targetOf(n)));
|
|
1900
|
+
return pickClosestJvmCandidate(above.length > 0 ? above : declarations, ref.filePath);
|
|
1901
|
+
}
|
|
1422
1902
|
function resolvePhpImportedStaticCall(ref, context) {
|
|
1423
1903
|
if (ref.language !== 'php' || ref.referenceKind !== 'calls')
|
|
1424
1904
|
return undefined;
|
|
@@ -1430,9 +1910,6 @@ function resolvePhpImportedStaticCall(ref, context) {
|
|
|
1430
1910
|
.find((i) => i.localName === receiver);
|
|
1431
1911
|
if (!imp)
|
|
1432
1912
|
return undefined;
|
|
1433
|
-
// PHP variables occupy a different namespace from class imports. Extraction
|
|
1434
|
-
// strips the leading "$" from "$Alias->method()" too; leave that receiver to
|
|
1435
|
-
// local type inference even when a class import has the same local name.
|
|
1436
1913
|
const lines = context.getFileLines?.(ref.filePath) ?? context.readFile(ref.filePath)?.split('\n');
|
|
1437
1914
|
const line = lines?.[ref.line - 1];
|
|
1438
1915
|
if (line?.slice(ref.column).startsWith('$'))
|
|
@@ -1447,51 +1924,51 @@ function resolvePhpImportedStaticCall(ref, context) {
|
|
|
1447
1924
|
if (owners.length !== 1)
|
|
1448
1925
|
return null;
|
|
1449
1926
|
const owner = owners[0];
|
|
1450
|
-
const methods =
|
|
1451
|
-
.filter((n) => n.language === 'php' && n.kind === 'method' && n.filePath === owner.filePath);
|
|
1927
|
+
const methods = phpOwnMethods(owner, member, context);
|
|
1452
1928
|
if (methods.length !== 1)
|
|
1453
1929
|
return null;
|
|
1454
1930
|
return { original: ref, targetNodeId: methods[0].id, confidence: 0.95, resolvedBy: 'import' };
|
|
1455
1931
|
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1932
|
+
function phpOwnMethods(owner, member, context) {
|
|
1933
|
+
const exact = context.getNodesByQualifiedName(`${owner.qualifiedName}::${member}`)
|
|
1934
|
+
.filter((n) => n.language === 'php' && n.kind === 'method' && n.filePath === owner.filePath);
|
|
1935
|
+
if (exact.length > 0)
|
|
1936
|
+
return exact;
|
|
1937
|
+
const want = `${owner.qualifiedName}::${member}`.toLowerCase();
|
|
1938
|
+
return context.getNodesInFile(owner.filePath)
|
|
1939
|
+
.filter((n) => n.language === 'php' && n.kind === 'method' && n.qualifiedName.toLowerCase() === want);
|
|
1940
|
+
}
|
|
1462
1941
|
function isJsPathSpecifier(name) {
|
|
1463
1942
|
return name.startsWith('./') || name.startsWith('../') || name === '.' || name === '..' ||
|
|
1464
|
-
(name.includes('/') && !/\s/.test(name)
|
|
1943
|
+
(name.includes('/') && !/\s/.test(name));
|
|
1465
1944
|
}
|
|
1466
|
-
/**
|
|
1467
|
-
* A JS/TS `imports` reference that names a module by path. It names a FILE, not
|
|
1468
|
-
* a symbol, so it skips the resolver's name-exists pre-filter — a CommonJS
|
|
1469
|
-
* `require('./x')` has no import node of that name to pass it.
|
|
1470
|
-
*/
|
|
1471
1945
|
function isJsPathImportRef(ref) {
|
|
1472
|
-
return ref.referenceKind === 'imports' &&
|
|
1946
|
+
return ref.referenceKind === 'imports' && exports.ESM_IMPORT_LANGUAGES.has(ref.language) && isJsPathSpecifier(ref.referenceName);
|
|
1947
|
+
}
|
|
1948
|
+
function isJsBareModuleRef(ref, context) {
|
|
1949
|
+
if (ref.referenceKind !== 'imports' || !exports.ESM_IMPORT_LANGUAGES.has(ref.language) || isJsPathSpecifier(ref.referenceName))
|
|
1950
|
+
return false;
|
|
1951
|
+
const imports = context.getImportMappings(ref.filePath, ref.language);
|
|
1952
|
+
return imports.some((m) => m.source === ref.referenceName) && !imports.some((m) => m.localName === ref.referenceName);
|
|
1953
|
+
}
|
|
1954
|
+
function jsModuleFile(ref, context) {
|
|
1955
|
+
if (!isJsPathImportRef(ref) && !isJsBareModuleRef(ref, context))
|
|
1956
|
+
return null;
|
|
1957
|
+
const declaring = declaredModuleFile(ref.referenceName, ref, context);
|
|
1958
|
+
if (declaring)
|
|
1959
|
+
return declaring.filePath;
|
|
1960
|
+
const file = resolveImportPath(ref.referenceName, ref.filePath, ref.language, context);
|
|
1961
|
+
return file && file !== ref.filePath ? file : null;
|
|
1473
1962
|
}
|
|
1474
|
-
/** PHP reference kinds whose name is a class name, written as in the source. */
|
|
1475
1963
|
const PHP_CLASS_NAME_REFS = new Set(['instantiates', 'extends', 'implements', 'references']);
|
|
1476
|
-
/**
|
|
1477
|
-
* A PHP class name written with a namespace in it (#2256). `use App\Fields as
|
|
1478
|
-
* Field;` aliases a namespace, so `new Field\FirstName()`, `extends Field\Base`
|
|
1479
|
-
* and `Field\FirstName::make()` all name `App\Fields\FirstName`. PHP reads a
|
|
1480
|
-
* qualified name one way: a leading `\` makes it absolute; otherwise a first
|
|
1481
|
-
* segment a `use` imports is replaced by what it imports, and any other name is
|
|
1482
|
-
* relative to the current namespace. Both extractors emit the written name
|
|
1483
|
-
* verbatim, and with no `.` or `::` in it the pre-filter would drop it.
|
|
1484
|
-
* undefined means the ref is not a qualified class name (or names a method the
|
|
1485
|
-
* class inherits); null means it is but no single project class has that name
|
|
1486
|
-
* — it lives outside the project — so name fallbacks must not guess.
|
|
1487
|
-
*/
|
|
1488
1964
|
function resolvePhpQualifiedClassRef(ref, context) {
|
|
1489
1965
|
if (ref.language !== 'php')
|
|
1490
1966
|
return undefined;
|
|
1491
1967
|
let name = ref.referenceName;
|
|
1492
1968
|
let member = null;
|
|
1493
1969
|
if (ref.referenceKind === 'calls') {
|
|
1494
|
-
|
|
1970
|
+
if (/^\(\s*new\s/i.test(name))
|
|
1971
|
+
return undefined;
|
|
1495
1972
|
const call = /^(.*\\[^\\.:]+)(?:\.|::)(\w+)$/.exec(name);
|
|
1496
1973
|
if (!call)
|
|
1497
1974
|
return undefined;
|
|
@@ -1509,13 +1986,12 @@ function resolvePhpQualifiedClassRef(ref, context) {
|
|
|
1509
1986
|
fqn = name.slice(1);
|
|
1510
1987
|
}
|
|
1511
1988
|
else {
|
|
1512
|
-
const head = name.slice(0, separator);
|
|
1513
|
-
const imp = context.getImportMappings(ref.filePath, ref.language).find((i) => i.localName === head);
|
|
1989
|
+
const head = name.slice(0, separator).toLowerCase();
|
|
1990
|
+
const imp = context.getImportMappings(ref.filePath, ref.language).find((i) => i.localName.toLowerCase() === head);
|
|
1514
1991
|
if (imp) {
|
|
1515
1992
|
fqn = imp.source.replace(/^\\/, '') + name.slice(separator);
|
|
1516
1993
|
}
|
|
1517
1994
|
else {
|
|
1518
|
-
// `namespace App;` applies until the next namespace statement.
|
|
1519
1995
|
const namespace = context.getNodesInFile(ref.filePath)
|
|
1520
1996
|
.filter((n) => n.kind === 'namespace' && n.startLine <= ref.line)
|
|
1521
1997
|
.sort((a, b) => b.startLine - a.startLine)[0];
|
|
@@ -1526,47 +2002,226 @@ function resolvePhpQualifiedClassRef(ref, context) {
|
|
|
1526
2002
|
const qualifiedName = cut < 0 ? fqn : `${fqn.slice(0, cut)}::${fqn.slice(cut + 1)}`;
|
|
1527
2003
|
const classes = context.getNodesByQualifiedName(qualifiedName)
|
|
1528
2004
|
.filter((n) => n.language === 'php' && STATIC_MEMBER_CONTAINERS.has(n.kind));
|
|
1529
|
-
// A type mention can name something other than a class (a namespaced
|
|
1530
|
-
// constant or function), so it keeps the ordinary strategies.
|
|
1531
2005
|
if (classes.length !== 1)
|
|
1532
2006
|
return ref.referenceKind === 'references' ? undefined : null;
|
|
1533
2007
|
const owner = classes[0];
|
|
1534
2008
|
if (!member)
|
|
1535
2009
|
return { original: ref, targetNodeId: owner.id, confidence: 0.95, resolvedBy: 'import' };
|
|
1536
|
-
const methods =
|
|
1537
|
-
.filter((n) => n.language === 'php' && n.kind === 'method' && n.filePath === owner.filePath);
|
|
1538
|
-
// A method the class inherits is left to the strategies that walk supertypes.
|
|
2010
|
+
const methods = phpOwnMethods(owner, member, context);
|
|
1539
2011
|
if (methods.length !== 1)
|
|
1540
2012
|
return undefined;
|
|
1541
2013
|
return { original: ref, targetNodeId: methods[0].id, confidence: 0.95, resolvedBy: 'import' };
|
|
1542
2014
|
}
|
|
2015
|
+
const TS_JS_FILE = /\.[cm]?[jt]sx?$/i;
|
|
2016
|
+
function resolveTsQualifiedTypeRef(ref, context) {
|
|
2017
|
+
if (ref.referenceKind !== 'references' || !exports.ESM_IMPORT_LANGUAGES.has(ref.language) || !TS_JS_FILE.test(ref.filePath))
|
|
2018
|
+
return undefined;
|
|
2019
|
+
const qualifier = typeQualifier(ref, context);
|
|
2020
|
+
if (!qualifier)
|
|
2021
|
+
return undefined;
|
|
2022
|
+
const head = qualifier[0];
|
|
2023
|
+
const path = [...qualifier.slice(1), ref.referenceName];
|
|
2024
|
+
const imp = context.getImportMappings(ref.filePath, ref.language).find((m) => m.localName === head);
|
|
2025
|
+
let target;
|
|
2026
|
+
if (imp) {
|
|
2027
|
+
target = importedTypeMember(imp, path, ref, context);
|
|
2028
|
+
}
|
|
2029
|
+
else {
|
|
2030
|
+
if ((0, name_matcher_1.tsGlobalScope)(ref.filePath, context)?.importAliases.has(head))
|
|
2031
|
+
return undefined;
|
|
2032
|
+
target = ownTypeMember(head, path, ref, context);
|
|
2033
|
+
if (target === undefined)
|
|
2034
|
+
target = globalTypeMember(qualifier.join('.'), ref, context) ?? null;
|
|
2035
|
+
}
|
|
2036
|
+
if (target === undefined)
|
|
2037
|
+
return undefined;
|
|
2038
|
+
return target ? { original: ref, targetNodeId: target.id, confidence: 0.9, resolvedBy: imp ? 'import' : 'qualified-name' } : null;
|
|
2039
|
+
}
|
|
2040
|
+
function typeQualifier(ref, context) {
|
|
2041
|
+
const line = context.getFileLines?.(ref.filePath)?.[ref.line - 1] ?? context.readFile(ref.filePath)?.split(/\r?\n/)[ref.line - 1];
|
|
2042
|
+
if (!line?.startsWith(ref.referenceName, ref.column))
|
|
2043
|
+
return null;
|
|
2044
|
+
const names = [];
|
|
2045
|
+
let i = ref.column - 1;
|
|
2046
|
+
for (;;) {
|
|
2047
|
+
while (i >= 0 && (line[i] === ' ' || line[i] === '\t'))
|
|
2048
|
+
i--;
|
|
2049
|
+
if (line[i] !== '.')
|
|
2050
|
+
break;
|
|
2051
|
+
i--;
|
|
2052
|
+
while (i >= 0 && (line[i] === ' ' || line[i] === '\t'))
|
|
2053
|
+
i--;
|
|
2054
|
+
const end = i + 1;
|
|
2055
|
+
while (i >= 0 && /[\w$]/.test(line[i]))
|
|
2056
|
+
i--;
|
|
2057
|
+
const name = line.slice(i + 1, end);
|
|
2058
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(name))
|
|
2059
|
+
return null;
|
|
2060
|
+
names.unshift(name);
|
|
2061
|
+
}
|
|
2062
|
+
return names.length > 0 ? names : null;
|
|
2063
|
+
}
|
|
2064
|
+
function importedTypeMember(imp, path, ref, context) {
|
|
2065
|
+
const file = resolveImportPath(imp.source, ref.filePath, ref.language, context);
|
|
2066
|
+
let found;
|
|
2067
|
+
let rest;
|
|
2068
|
+
if (imp.isNamespace) {
|
|
2069
|
+
const want = { isDefault: false, isNamespace: true, exportedName: path[0], memberName: path[0] };
|
|
2070
|
+
found = findImportedExport(imp.source, file, want, ref, context);
|
|
2071
|
+
if (found && path.length === 1)
|
|
2072
|
+
return found;
|
|
2073
|
+
rest = path.slice(1);
|
|
2074
|
+
}
|
|
2075
|
+
else {
|
|
2076
|
+
const want = { isDefault: imp.isDefault, isNamespace: false, exportedName: imp.isDefault ? 'default' : imp.exportedName, memberName: null };
|
|
2077
|
+
found = findImportedExport(imp.source, file, want, ref, context);
|
|
2078
|
+
rest = path;
|
|
2079
|
+
}
|
|
2080
|
+
if (found) {
|
|
2081
|
+
const member = STATIC_MEMBER_CONTAINERS.has(found.kind) ? containerMember(found, rest, context) : undefined;
|
|
2082
|
+
return member ?? typeMemberIn(found.filePath, [], [found.name, ...rest], context) ?? null;
|
|
2083
|
+
}
|
|
2084
|
+
const namespace = imp.isNamespace ? path[0] : imp.isDefault ? null : imp.exportedName;
|
|
2085
|
+
const declaring = file && namespace ? namespaceDeclaringFile(file, namespace, ref.language, context) : undefined;
|
|
2086
|
+
if (declaring)
|
|
2087
|
+
return typeMemberIn(declaring.file, [], [declaring.name, ...rest], context) ?? null;
|
|
2088
|
+
const outside = !file && !(0, ambient_modules_1.findAmbientModuleFile)(imp.source, ref.filePath, context) &&
|
|
2089
|
+
context.isOutOfRepoImport?.(imp.source, ref.filePath, ref.language) === true;
|
|
2090
|
+
return outside ? null : undefined;
|
|
2091
|
+
}
|
|
2092
|
+
function ownTypeMember(head, path, ref, context) {
|
|
2093
|
+
const at = { startLine: ref.line, startColumn: ref.column };
|
|
2094
|
+
const scopes = (0, ambient_modules_1.namespaceBlocks)(ref.filePath, context)
|
|
2095
|
+
.filter((b) => (0, ambient_modules_1.inBlock)(at, b))
|
|
2096
|
+
.map((b) => b.path.split('.'))
|
|
2097
|
+
.sort((a, b) => b.length - a.length);
|
|
2098
|
+
for (const scope of [...scopes, []]) {
|
|
2099
|
+
if (!hasNamespace(ref.filePath, [...scope, head].join('.'), context) && declarationsIn(ref.filePath, scope, head, context).length === 0)
|
|
2100
|
+
continue;
|
|
2101
|
+
return typeMemberIn(ref.filePath, scope, [head, ...path], context) ?? null;
|
|
2102
|
+
}
|
|
2103
|
+
return undefined;
|
|
2104
|
+
}
|
|
2105
|
+
function globalTypeMember(namespace, ref, context) {
|
|
2106
|
+
const fromTest = (0, query_utils_1.isTestFile)(ref.filePath);
|
|
2107
|
+
return context.getNodesByName(ref.referenceName)
|
|
2108
|
+
.filter((n) => {
|
|
2109
|
+
if (!TS_JS_FILE.test(n.filePath) || n.qualifiedName !== n.name || !MEMBER_DECLARATION_KINDS.has(n.kind))
|
|
2110
|
+
return false;
|
|
2111
|
+
if (!fromTest && (0, query_utils_1.isTestFile)(n.filePath))
|
|
2112
|
+
return false;
|
|
2113
|
+
const block = innermostBlock(n, (0, ambient_modules_1.namespaceBlocks)(n.filePath, context));
|
|
2114
|
+
return block?.global === true && block.path === namespace;
|
|
2115
|
+
})
|
|
2116
|
+
.sort(typesFirst)[0];
|
|
2117
|
+
}
|
|
2118
|
+
function typeMemberIn(file, scope, path, context) {
|
|
2119
|
+
const [name, ...rest] = path;
|
|
2120
|
+
if (name === undefined)
|
|
2121
|
+
return undefined;
|
|
2122
|
+
if (rest.length > 0 && hasNamespace(file, [...scope, name].join('.'), context)) {
|
|
2123
|
+
return typeMemberIn(file, [...scope, name], rest, context);
|
|
2124
|
+
}
|
|
2125
|
+
const declared = declarationsIn(file, scope, name, context);
|
|
2126
|
+
if (rest.length === 0)
|
|
2127
|
+
return declared[0];
|
|
2128
|
+
const container = declared.find((n) => STATIC_MEMBER_CONTAINERS.has(n.kind));
|
|
2129
|
+
return container ? containerMember(container, rest, context) : undefined;
|
|
2130
|
+
}
|
|
2131
|
+
function containerMember(container, path, context) {
|
|
2132
|
+
if (path.length === 0)
|
|
2133
|
+
return undefined;
|
|
2134
|
+
return context.getNodesByQualifiedName(`${container.qualifiedName}::${path.join('::')}`)
|
|
2135
|
+
.filter((n) => n.filePath === container.filePath)
|
|
2136
|
+
.sort(typesFirst)[0];
|
|
2137
|
+
}
|
|
2138
|
+
const MEMBER_DECLARATION_KINDS = new Set([
|
|
2139
|
+
'class', 'interface', 'type_alias', 'enum', 'struct', 'function', 'component', 'constant', 'variable',
|
|
2140
|
+
]);
|
|
2141
|
+
const TYPE_DECLARATION_KINDS = new Set([
|
|
2142
|
+
'class', 'interface', 'type_alias', 'enum', 'enum_member', 'struct',
|
|
2143
|
+
]);
|
|
2144
|
+
function typesFirst(a, b) {
|
|
2145
|
+
return Number(!TYPE_DECLARATION_KINDS.has(a.kind)) - Number(!TYPE_DECLARATION_KINDS.has(b.kind));
|
|
2146
|
+
}
|
|
2147
|
+
function declarationsIn(file, scope, name, context) {
|
|
2148
|
+
const blocks = (0, ambient_modules_1.namespaceBlocks)(file, context);
|
|
2149
|
+
const want = scope.join('.');
|
|
2150
|
+
return (context.getNodesInFileNamed?.(file, name) ?? context.getNodesInFile(file).filter((n) => n.name === name))
|
|
2151
|
+
.filter((n) => n.qualifiedName === name && MEMBER_DECLARATION_KINDS.has(n.kind) && (innermostBlock(n, blocks)?.path ?? '') === want)
|
|
2152
|
+
.sort(typesFirst);
|
|
2153
|
+
}
|
|
2154
|
+
function hasNamespace(file, path, context) {
|
|
2155
|
+
return (0, ambient_modules_1.namespaceBlocks)(file, context).some((b) => b.path === path || b.path.startsWith(`${path}.`));
|
|
2156
|
+
}
|
|
2157
|
+
function innermostBlock(node, blocks) {
|
|
2158
|
+
let inner;
|
|
2159
|
+
for (const block of blocks) {
|
|
2160
|
+
if (!(0, ambient_modules_1.inBlock)(node, block))
|
|
2161
|
+
continue;
|
|
2162
|
+
if (!inner || block.startLine > inner.startLine || (block.startLine === inner.startLine && block.startColumn > inner.startColumn))
|
|
2163
|
+
inner = block;
|
|
2164
|
+
}
|
|
2165
|
+
return inner;
|
|
2166
|
+
}
|
|
2167
|
+
function namespaceDeclaringFile(file, name, language, context, depth = 0) {
|
|
2168
|
+
if (depth > exports.REEXPORT_MAX_DEPTH)
|
|
2169
|
+
return undefined;
|
|
2170
|
+
if ((0, ambient_modules_1.namespaceBlocks)(file, context).some((b) => b.path === name || b.path.startsWith(`${name}.`)))
|
|
2171
|
+
return { file, name };
|
|
2172
|
+
for (const rex of context.getReExports?.(file, language) ?? []) {
|
|
2173
|
+
if (rex.kind !== 'wildcard' && !(rex.kind === 'named' && rex.exportedName === name))
|
|
2174
|
+
continue;
|
|
2175
|
+
const next = resolveImportPath(rex.source, file, language, context);
|
|
2176
|
+
const found = next ? namespaceDeclaringFile(next, rex.kind === 'named' ? rex.originalName : name, language, context, depth + 1) : undefined;
|
|
2177
|
+
if (found)
|
|
2178
|
+
return found;
|
|
2179
|
+
}
|
|
2180
|
+
return undefined;
|
|
2181
|
+
}
|
|
2182
|
+
function namespaceExportModule(file, name, language, context, depth = 0, seen = new Set()) {
|
|
2183
|
+
if (depth > exports.REEXPORT_MAX_DEPTH || seen.has(file))
|
|
2184
|
+
return null;
|
|
2185
|
+
seen.add(file);
|
|
2186
|
+
if (exportedByName(file, getFileExportIndex(file, context), name, context))
|
|
2187
|
+
return null;
|
|
2188
|
+
const reExports = context.getReExports?.(file, language) ?? [];
|
|
2189
|
+
const namespaced = reExports.find((rex) => rex.kind === 'namespace' && rex.exportedName === name);
|
|
2190
|
+
if (namespaced)
|
|
2191
|
+
return resolveImportPath(namespaced.source, file, language, context);
|
|
2192
|
+
const source = context.readFile(file);
|
|
2193
|
+
if (source?.includes('export')) {
|
|
2194
|
+
for (const { exportedName, localName } of (0, alias_binding_1.extractLocalExportAliases)(source)) {
|
|
2195
|
+
if (exportedName !== name)
|
|
2196
|
+
continue;
|
|
2197
|
+
const imported = context.getImportMappings(file, language).find((m) => m.isNamespace && m.localName === localName);
|
|
2198
|
+
if (imported)
|
|
2199
|
+
return resolveImportPath(imported.source, file, language, context);
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
for (const rex of reExports) {
|
|
2203
|
+
if (rex.kind !== 'wildcard' && !(rex.kind === 'named' && rex.exportedName === name))
|
|
2204
|
+
continue;
|
|
2205
|
+
const next = resolveImportPath(rex.source, file, language, context);
|
|
2206
|
+
const found = next ? namespaceExportModule(next, rex.kind === 'named' ? rex.originalName : name, language, context, depth + 1, seen) : null;
|
|
2207
|
+
if (found)
|
|
2208
|
+
return found;
|
|
2209
|
+
}
|
|
2210
|
+
return null;
|
|
2211
|
+
}
|
|
1543
2212
|
function resolveViaImport(ref, context) {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
// aliases. Matching the basename instead missed every extensionless one
|
|
1548
|
-
// (the common spelling) and could land on a same-named file elsewhere.
|
|
1549
|
-
if (isJsPathImportRef(ref)) {
|
|
1550
|
-
const file = resolveImportPath(ref.referenceName, ref.filePath, ref.language, context);
|
|
1551
|
-
const fileNode = file && file !== ref.filePath ? context.getNodesInFile(file).find((n) => n.kind === 'file') : undefined;
|
|
2213
|
+
const moduleFile = jsModuleFile(ref, context);
|
|
2214
|
+
if (moduleFile) {
|
|
2215
|
+
const fileNode = context.getNodesInFile(moduleFile).find((n) => n.kind === 'file');
|
|
1552
2216
|
if (fileNode)
|
|
1553
2217
|
return { original: ref, targetNodeId: fileNode.id, confidence: 0.9, resolvedBy: 'import' };
|
|
1554
2218
|
}
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
// edge — resolveViaImport's symbol lookup below would search the
|
|
1561
|
-
// resolved file for a symbol named like the file extension and fail.
|
|
2219
|
+
if (isDartImportRef(ref)) {
|
|
2220
|
+
const file = (0, dart_libraries_1.dartDirectiveFile)(ref.filePath, ref.referenceName, context);
|
|
2221
|
+
const fileNode = file && file !== ref.filePath ? context.getNodesInFile(file).find((n) => n.kind === 'file') : undefined;
|
|
2222
|
+
return fileNode ? { original: ref, targetNodeId: fileNode.id, confidence: 0.9, resolvedBy: 'import' } : null;
|
|
2223
|
+
}
|
|
1562
2224
|
if ((ref.language === 'c' || ref.language === 'cpp') && ref.referenceKind === 'imports') {
|
|
1563
|
-
// C/C++ quoted includes (`#include "X.h"`) resolve relative to the
|
|
1564
|
-
// INCLUDING file's own directory first (the C standard's quoted-include
|
|
1565
|
-
// search order). Prefer a same-directory header over an -I directory or a
|
|
1566
|
-
// same-named header on another platform (windows/code/RNCAsyncStorage.h vs
|
|
1567
|
-
// apple/.../RNCAsyncStorage.h) — the include-dir heuristic below would
|
|
1568
|
-
// otherwise pick an arbitrary same-named header, leaving the real local one
|
|
1569
|
-
// with no dependents.
|
|
1570
2225
|
const slash = ref.filePath.lastIndexOf('/');
|
|
1571
2226
|
const fromDir = slash >= 0 ? ref.filePath.slice(0, slash) : '';
|
|
1572
2227
|
const siblingPath = path.posix.normalize(fromDir ? `${fromDir}/${ref.referenceName}` : ref.referenceName);
|
|
@@ -1593,11 +2248,6 @@ function resolveViaImport(ref, context) {
|
|
|
1593
2248
|
}
|
|
1594
2249
|
return null;
|
|
1595
2250
|
}
|
|
1596
|
-
// COBOL COPY / EXEC SQL INCLUDE — resolve the copybook member to a
|
|
1597
|
-
// file→file edge, mirroring the C/C++ include branch above. A member that
|
|
1598
|
-
// matches no indexed file (compiler-supplied copybooks like SQLCA/DFHAID)
|
|
1599
|
-
// stays unresolved — callers must not fall back to the symbol name-matcher,
|
|
1600
|
-
// which would connect it to a same-named import symbol elsewhere.
|
|
1601
2251
|
if (isCobolCopybookRef(ref)) {
|
|
1602
2252
|
const resolvedPath = resolveImportPath(ref.referenceName, ref.filePath, ref.language, context);
|
|
1603
2253
|
if (!resolvedPath)
|
|
@@ -1616,13 +2266,6 @@ function resolveViaImport(ref, context) {
|
|
|
1616
2266
|
}
|
|
1617
2267
|
return null;
|
|
1618
2268
|
}
|
|
1619
|
-
// PHP include/require — resolve the static string path to a file→file
|
|
1620
|
-
// edge, mirroring the C/C++ branch above. Distinguish include PATHS from
|
|
1621
|
-
// namespace `use` symbols by shape: an include path contains a slash or a
|
|
1622
|
-
// file extension ("lib.php", "inc/db.php", "../x.php"), whereas a namespace
|
|
1623
|
-
// use is an FQN (App\Foo\Bar) or a bare class symbol (Closure) — PHP
|
|
1624
|
-
// identifiers contain neither '/' nor '.'. Only path-shaped references are
|
|
1625
|
-
// includes; symbol references fall through to the namespace resolution.
|
|
1626
2269
|
if (isPhpIncludePathRef(ref)) {
|
|
1627
2270
|
const resolvedPath = resolvePhpIncludePath(ref.referenceName, ref.filePath, context);
|
|
1628
2271
|
if (resolvedPath) {
|
|
@@ -1639,16 +2282,8 @@ function resolveViaImport(ref, context) {
|
|
|
1639
2282
|
};
|
|
1640
2283
|
}
|
|
1641
2284
|
}
|
|
1642
|
-
// A path-shaped include that doesn't resolve to a known project file is a
|
|
1643
|
-
// dead end. Return unresolved rather than falling through to the symbol
|
|
1644
|
-
// name-matcher, which would mis-connect e.g. "inc/db.php" to an unrelated
|
|
1645
|
-
// db.php elsewhere in the tree — a wrong edge is worse than a missing one.
|
|
1646
2285
|
return null;
|
|
1647
2286
|
}
|
|
1648
|
-
// Nix static project-path imports (`import ./x.nix`, `builtins.import ./dir`,
|
|
1649
|
-
// `import ./x.nix {}`) resolve to file nodes only. Do not resolve
|
|
1650
|
-
// angle-bracket channels, attribute expressions, variables, or other dynamic
|
|
1651
|
-
// expressions as project files.
|
|
1652
2287
|
if (isNixPathImportRef(ref)) {
|
|
1653
2288
|
const resolvedPath = resolveImportPath(ref.referenceName, ref.filePath, ref.language, context);
|
|
1654
2289
|
if (!resolvedPath)
|
|
@@ -1667,70 +2302,39 @@ function resolveViaImport(ref, context) {
|
|
|
1667
2302
|
}
|
|
1668
2303
|
return null;
|
|
1669
2304
|
}
|
|
1670
|
-
|
|
1671
|
-
const imports = context.getImportMappings(ref.filePath, ref.language);
|
|
2305
|
+
let imports = context.getImportMappings(ref.filePath, ref.language);
|
|
1672
2306
|
if (imports.length === 0 && !context.readFile(ref.filePath)) {
|
|
1673
2307
|
return null;
|
|
1674
2308
|
}
|
|
1675
|
-
// Go cross-package calls: `pkga.FuncX(...)` extracts to referenceName
|
|
1676
|
-
// `pkga.FuncX` and the import `github.com/example/myproject/pkga`
|
|
1677
|
-
// maps to a *package directory* containing one or more .go files.
|
|
1678
|
-
// The generic file-based lookup below can't follow that — issue #388.
|
|
1679
2309
|
if (ref.language === 'go') {
|
|
1680
2310
|
const goResult = resolveGoCrossPackageReference(ref, imports, context);
|
|
1681
2311
|
if (goResult)
|
|
1682
2312
|
return goResult;
|
|
1683
2313
|
}
|
|
1684
|
-
// Java / Kotlin: imports are FQNs (`import com.example.Foo;`) — no
|
|
1685
|
-
// resolvable file path the JS/TS-style chain below could follow. Look
|
|
1686
|
-
// up the symbol by name and filter to the candidate whose file path
|
|
1687
|
-
// matches the imported FQN. This is the disambiguation signal that
|
|
1688
|
-
// breaks the same-name class collision the path-proximity matcher
|
|
1689
|
-
// can't resolve (issue #314).
|
|
1690
2314
|
if (ref.language === 'java' || ref.language === 'kotlin') {
|
|
1691
2315
|
const javaResult = resolveJavaImportedReference(ref, imports, context);
|
|
1692
2316
|
if (javaResult)
|
|
1693
2317
|
return javaResult;
|
|
1694
2318
|
}
|
|
1695
|
-
// Python qualified access through an imported MODULE: `certs.where()` after
|
|
1696
|
-
// `from . import certs`, `mod.func()` after `import mod`. The receiver names a
|
|
1697
|
-
// submodule (a file), not a symbol, so the generic symbol lookup below would
|
|
1698
|
-
// search the *package* for `certs` instead of looking inside the module.
|
|
1699
2319
|
if (ref.language === 'python') {
|
|
2320
|
+
imports = pythonImportsInScope(ref, imports, context);
|
|
1700
2321
|
const pyResult = resolvePythonModuleMember(ref, imports, context);
|
|
1701
2322
|
if (pyResult)
|
|
1702
2323
|
return pyResult;
|
|
1703
|
-
// Absolute dotted module import: `import conduit.apps.articles.signals`
|
|
1704
|
-
// (the standard Django AppConfig.ready() signal-registration pattern, and
|
|
1705
|
-
// any side-effect `import pkg.mod`). Map the dotted path to its file.
|
|
1706
2324
|
const pyModResult = resolvePythonAbsoluteModule(ref, context);
|
|
1707
2325
|
if (pyModResult)
|
|
1708
2326
|
return pyModResult;
|
|
1709
2327
|
}
|
|
1710
|
-
// Rust qualified path: resolve the module prefix of `crate::m::Item` /
|
|
1711
|
-
// `self::sub::Item` / `super::m::func` to a file, then find the leaf symbol in
|
|
1712
|
-
// it. Disambiguates common-name `pub use self::read::read` re-exports that
|
|
1713
|
-
// name-matching would land on the wrong same-named symbol.
|
|
1714
2328
|
if (ref.language === 'rust' && ref.referenceName.includes('::')) {
|
|
1715
2329
|
const rustResult = resolveRustPathReference(ref, context);
|
|
1716
2330
|
if (rustResult)
|
|
1717
2331
|
return rustResult;
|
|
1718
2332
|
}
|
|
1719
|
-
// Lua / Luau `require(...)`: a dotted module path (`a.b.c` from
|
|
1720
|
-
// `require("a.b.c")`) or an instance-path leaf (`Signal` from
|
|
1721
|
-
// `require(script.Parent.Signal)`) — map it to a module file. There's no static
|
|
1722
|
-
// import statement, so the generic path-matcher can't bridge the dot↔slash /
|
|
1723
|
-
// leaf↔basename gap; resolve it explicitly to the module file.
|
|
1724
2333
|
if ((ref.language === 'lua' || ref.language === 'luau') && ref.referenceKind === 'imports') {
|
|
1725
2334
|
const luaResult = resolveLuaRequire(ref, context);
|
|
1726
2335
|
if (luaResult)
|
|
1727
2336
|
return luaResult;
|
|
1728
2337
|
}
|
|
1729
|
-
// Whole-module / namespace imports → link the importing file to the module
|
|
1730
|
-
// file. Python `from . import certs` / `import mod`, and TS/JS `import * as ns
|
|
1731
|
-
// from './x'` (so a namespace touched only via a value-member read still
|
|
1732
|
-
// records the dependency). A named TS/JS import returns null here and falls
|
|
1733
|
-
// through to symbol resolution below.
|
|
1734
2338
|
if (ref.language === 'python' ||
|
|
1735
2339
|
ref.language === 'typescript' ||
|
|
1736
2340
|
ref.language === 'tsx' ||
|
|
@@ -1741,40 +2345,47 @@ function resolveViaImport(ref, context) {
|
|
|
1741
2345
|
if (moduleFile)
|
|
1742
2346
|
return moduleFile;
|
|
1743
2347
|
}
|
|
1744
|
-
// Kotlin's `import app.model.Outer.Inner as Made`: `Made.create()` is the
|
|
1745
|
-
// aliased class's member, found by its FQN — nothing else binds the alias.
|
|
1746
2348
|
if (ref.language === 'kotlin' && ref.referenceKind !== 'imports') {
|
|
1747
2349
|
const aliased = resolveJvmAlias(ref, imports, context);
|
|
1748
2350
|
if (aliased)
|
|
1749
2351
|
return aliased;
|
|
1750
2352
|
}
|
|
1751
|
-
// Check if the reference name matches any import
|
|
1752
2353
|
for (const imp of imports) {
|
|
1753
2354
|
if (imp.localName === ref.referenceName || ref.referenceName.startsWith(imp.localName + '.')) {
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
// Named Python imports need the same absolute-module lookup as namespace
|
|
1757
|
-
// imports, including aliases used as receiver types (#1820).
|
|
1758
|
-
if (!resolvedPath && ref.language === 'python') {
|
|
1759
|
-
resolvedPath = findPythonModuleFile(imp.source, context, ref.filePath)?.filePath ?? null;
|
|
1760
|
-
}
|
|
1761
|
-
if (resolvedPath) {
|
|
2355
|
+
const resolvedPath = resolveImportPath(imp.source, ref.filePath, ref.language, context);
|
|
2356
|
+
if (resolvedPath || isBareModuleSpecifier(imp.source, ref.language)) {
|
|
1762
2357
|
const exportedName = imp.isDefault ? 'default' : imp.exportedName;
|
|
1763
2358
|
const memberName = imp.isNamespace
|
|
1764
2359
|
? ref.referenceName.replace(imp.localName + '.', '')
|
|
1765
2360
|
: null;
|
|
1766
|
-
const
|
|
1767
|
-
|
|
1768
|
-
|
|
2361
|
+
const want = { isDefault: imp.isDefault, isNamespace: imp.isNamespace, exportedName, memberName };
|
|
2362
|
+
const targetNode = findImportedExport(imp.source, resolvedPath, want, ref, context);
|
|
2363
|
+
const memberRead = !imp.isNamespace && ref.referenceName.startsWith(imp.localName + '.');
|
|
2364
|
+
const namespace = !targetNode && !imp.isNamespace && !imp.isDefault && resolvedPath && exports.ESM_IMPORT_LANGUAGES.has(ref.language)
|
|
2365
|
+
? namespaceExportModule(resolvedPath, exportedName, ref.language, context) : null;
|
|
2366
|
+
if (namespace) {
|
|
2367
|
+
if (memberRead) {
|
|
2368
|
+
const member = ref.referenceName.slice(imp.localName.length + 1);
|
|
2369
|
+
const found = findExportedSymbol(namespace, { isDefault: false, isNamespace: true, exportedName: member.split('.')[0], memberName: member }, ref.language, context, new Set());
|
|
2370
|
+
if (found)
|
|
2371
|
+
return { original: ref, targetNodeId: found.id, confidence: 0.9, resolvedBy: 'import' };
|
|
2372
|
+
}
|
|
2373
|
+
else if (ref.referenceKind === 'imports') {
|
|
2374
|
+
const fileNode = context.getNodesInFile(namespace).find((n) => n.kind === 'file');
|
|
2375
|
+
if (fileNode)
|
|
2376
|
+
return { original: ref, targetNodeId: fileNode.id, confidence: 0.9, resolvedBy: 'import' };
|
|
2377
|
+
}
|
|
2378
|
+
continue;
|
|
2379
|
+
}
|
|
2380
|
+
const throughDefault = memberRead && imp.isDefault && exports.ESM_IMPORT_LANGUAGES.has(ref.language);
|
|
2381
|
+
const exported = throughDefault
|
|
2382
|
+
? findImportedExport(imp.source, resolvedPath, { ...want, isDefault: false, isNamespace: true, memberName: ref.referenceName.slice(imp.localName.length + 1) }, ref, context)
|
|
2383
|
+
: undefined;
|
|
2384
|
+
const guessed = throughDefault && !(targetNode && isStatedDefaultExport(targetNode, context));
|
|
2385
|
+
if (guessed && exported)
|
|
2386
|
+
return { original: ref, targetNodeId: exported.id, confidence: 0.9, resolvedBy: 'import' };
|
|
1769
2387
|
if (targetNode) {
|
|
1770
|
-
|
|
1771
|
-
// accessed through a member. `findExportedSymbol` resolved `Foo` to
|
|
1772
|
-
// the class itself; descend into it so the reference links to the
|
|
1773
|
-
// member `bar`, not the class. Without this the edge points at the
|
|
1774
|
-
// class and `createEdges` then mis-promotes the call to an
|
|
1775
|
-
// `instantiates` edge, so the static method shows zero callers and a
|
|
1776
|
-
// hollow impact radius. (#825)
|
|
1777
|
-
if (!imp.isNamespace && ref.referenceName.startsWith(imp.localName + '.')) {
|
|
2388
|
+
if (memberRead) {
|
|
1778
2389
|
const memberNode = resolveStaticMember(targetNode, ref, imp.localName, context);
|
|
1779
2390
|
if (memberNode) {
|
|
1780
2391
|
return {
|
|
@@ -1784,13 +2395,6 @@ function resolveViaImport(ref, context) {
|
|
|
1784
2395
|
resolvedBy: 'import',
|
|
1785
2396
|
};
|
|
1786
2397
|
}
|
|
1787
|
-
// An imported object literal used as a namespace (#1573):
|
|
1788
|
-
// `api.call()` after `import { api } from './api'` where `api` is
|
|
1789
|
-
// `export const api = { call() {…} }`. Its members have bare
|
|
1790
|
-
// qualified names inside the constant's extent, so the
|
|
1791
|
-
// `Container::member` lookup above can't see them and the edge
|
|
1792
|
-
// landed on the constant — every cross-file caller of the method
|
|
1793
|
-
// went missing. Resolve the member by containment instead.
|
|
1794
2398
|
if (targetNode.kind === 'constant' || targetNode.kind === 'variable') {
|
|
1795
2399
|
const member = ref.referenceName.slice(imp.localName.length + 1).split('.')[0];
|
|
1796
2400
|
if (member) {
|
|
@@ -1802,26 +2406,23 @@ function resolveViaImport(ref, context) {
|
|
|
1802
2406
|
return aliasMember;
|
|
1803
2407
|
}
|
|
1804
2408
|
}
|
|
1805
|
-
// An imported VALUE (singleton constant / shared instance) called
|
|
1806
|
-
// through a member: `reproStore.notifyJoinGuildStatus()` after
|
|
1807
|
-
// `import { reproStore } from './store'`. findExportedSymbol
|
|
1808
|
-
// resolved the CONSTANT itself; linking the CALL there hides the
|
|
1809
|
-
// real callee — callers of the method miss every cross-file use
|
|
1810
|
-
// and the method can look unused (#1292). Infer the value's type
|
|
1811
|
-
// from its own declaration in the exporting file and resolve the
|
|
1812
|
-
// member on that type. resolveMethodOnType VALIDATES the type
|
|
1813
|
-
// declares the method, so a mis-inference falls through to the
|
|
1814
|
-
// constant edge below rather than fabricating a wrong one.
|
|
1815
2409
|
const instanceMember = resolveImportedInstanceMember(targetNode, ref, imp.localName, context);
|
|
1816
2410
|
if (instanceMember)
|
|
1817
2411
|
return instanceMember;
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
// work; it does not call the imported task function directly.
|
|
1821
|
-
// Keep unknown members unresolved (including callback values)
|
|
1822
|
-
// instead of falling back to the receiver as their target.
|
|
2412
|
+
if (exported)
|
|
2413
|
+
return { original: ref, targetNodeId: exported.id, confidence: 0.9, resolvedBy: 'import' };
|
|
1823
2414
|
if (ref.language === 'python')
|
|
1824
2415
|
return null;
|
|
2416
|
+
if (guessed)
|
|
2417
|
+
continue;
|
|
2418
|
+
const member = ref.referenceName.slice(imp.localName.length + 1);
|
|
2419
|
+
if (targetNode.kind === 'function' && !imp.isDefault && exports.ESM_IMPORT_LANGUAGES.has(ref.language) && !/^(?:call|apply|bind)$/.test(member)) {
|
|
2420
|
+
const merged = hasNamespace(targetNode.filePath, targetNode.name, context)
|
|
2421
|
+
? typeMemberIn(targetNode.filePath, [targetNode.name], member.split('.'), context) : undefined;
|
|
2422
|
+
if (merged)
|
|
2423
|
+
return { original: ref, targetNodeId: merged.id, confidence: 0.9, resolvedBy: 'import' };
|
|
2424
|
+
continue;
|
|
2425
|
+
}
|
|
1825
2426
|
}
|
|
1826
2427
|
return {
|
|
1827
2428
|
original: ref,
|
|
@@ -1833,102 +2434,183 @@ function resolveViaImport(ref, context) {
|
|
|
1833
2434
|
}
|
|
1834
2435
|
}
|
|
1835
2436
|
}
|
|
2437
|
+
if (ref.referenceKind === 'imports' && exports.ESM_IMPORT_LANGUAGES.has(ref.language)) {
|
|
2438
|
+
const source = (0, name_matcher_1.reExportSource)(ref.referenceName, ref, context);
|
|
2439
|
+
const resolvedPath = source === undefined ? null : resolveImportPath(source, ref.filePath, ref.language, context);
|
|
2440
|
+
const targetNode = resolvedPath === null ? undefined : findExportedSymbol(resolvedPath, { isDefault: false, isNamespace: false, exportedName: ref.referenceName, memberName: null }, ref.language, context, new Set());
|
|
2441
|
+
if (targetNode)
|
|
2442
|
+
return { original: ref, targetNodeId: targetNode.id, confidence: 0.9, resolvedBy: 'import' };
|
|
2443
|
+
}
|
|
1836
2444
|
return null;
|
|
1837
2445
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
2446
|
+
function isBareModuleSpecifier(source, language) {
|
|
2447
|
+
return exports.ESM_IMPORT_LANGUAGES.has(language) && !source.startsWith('.') && !source.startsWith('/');
|
|
2448
|
+
}
|
|
2449
|
+
function isRepositoryModule(specifier, file, ref, context) {
|
|
2450
|
+
if (file === null || (0, ambient_modules_1.isDeclarationFile)(file))
|
|
2451
|
+
return false;
|
|
2452
|
+
const workspaces = context.getWorkspacePackages?.();
|
|
2453
|
+
return !!workspaces && (0, workspace_packages_1.workspaceImportTargets)(specifier, workspaces, ref.filePath) !== null;
|
|
2454
|
+
}
|
|
2455
|
+
function findImportedExport(source, file, want, ref, context) {
|
|
2456
|
+
const inFile = () => (file ? findExportedSymbol(file, want, ref.language, context, new Set()) : undefined);
|
|
2457
|
+
const declared = isBareModuleSpecifier(source, ref.language) ? (0, ambient_modules_1.findAmbientModuleExport)(source, want, ref, context) : undefined;
|
|
2458
|
+
if (!declared)
|
|
2459
|
+
return inFile();
|
|
2460
|
+
return (isRepositoryModule(source, file, ref, context) ? inFile() : undefined) ?? declared;
|
|
2461
|
+
}
|
|
2462
|
+
function declaredModuleFile(specifier, ref, context) {
|
|
2463
|
+
if (!isBareModuleSpecifier(specifier, ref.language))
|
|
2464
|
+
return undefined;
|
|
2465
|
+
const declaring = (0, ambient_modules_1.findAmbientModuleFile)(specifier, ref.filePath, context);
|
|
2466
|
+
if (!declaring)
|
|
2467
|
+
return undefined;
|
|
2468
|
+
return isRepositoryModule(specifier, resolveImportPath(specifier, ref.filePath, ref.language, context), ref, context) ? undefined : declaring;
|
|
2469
|
+
}
|
|
2470
|
+
const LAST_NAME_KINDS = new Set(['references', 'extends', 'implements', 'type_of', 'returns', 'instantiates']);
|
|
2471
|
+
function reachesAmbientModule(ref, specifier, declaringFile, context) {
|
|
2472
|
+
const answers = (0, ambient_modules_1.declaringFileAnswers)(declaringFile, ref.filePath, context);
|
|
2473
|
+
if (answers && (0, ambient_modules_1.isInModuleBlock)(ref.filePath, ref.line, ref.column ?? 0, specifier, context))
|
|
2474
|
+
return true;
|
|
2475
|
+
const mappings = context.getImportMappings(ref.filePath, ref.language);
|
|
2476
|
+
const relative = (source) => source.startsWith('.') || source.startsWith('/');
|
|
2477
|
+
const leadsTo = (source, through) => {
|
|
2478
|
+
if (source === specifier)
|
|
2479
|
+
return answers;
|
|
2480
|
+
if (!relative(source))
|
|
2481
|
+
return false;
|
|
2482
|
+
const file = resolveImportPath(source, ref.filePath, ref.language, context);
|
|
2483
|
+
return file !== null && (file === declaringFile || through(file));
|
|
2484
|
+
};
|
|
2485
|
+
const head = ref.referenceName.split('.')[0];
|
|
2486
|
+
const binding = mappings.find((m) => m.localName === head);
|
|
2487
|
+
if (binding) {
|
|
2488
|
+
return leadsTo(binding.source, (file) => context.getImportMappings(file, ref.language).some((m) => m.source === specifier));
|
|
2489
|
+
}
|
|
2490
|
+
return LAST_NAME_KINDS.has(ref.referenceKind) && mappings.some((m) => leadsTo(m.source, () => false));
|
|
2491
|
+
}
|
|
2492
|
+
function pythonImportsInScope(ref, imports, context) {
|
|
2493
|
+
if (ref.language !== 'python' || ref.referenceKind === 'imports')
|
|
2494
|
+
return imports;
|
|
2495
|
+
const dot = ref.referenceName.indexOf('.');
|
|
2496
|
+
if (dot < 0 && /^[A-Za-z_]\w*$/.test(ref.referenceName))
|
|
2497
|
+
return pythonBareImportsInScope(ref, imports, context);
|
|
2498
|
+
if (dot <= 0)
|
|
2499
|
+
return imports;
|
|
2500
|
+
const receiver = ref.referenceName.slice(0, dot);
|
|
2501
|
+
const binds = (m) => m.localName === receiver ||
|
|
2502
|
+
(m.isNamespace && m.source.split('.')[0] === receiver && m.localName === m.source.split('.').pop());
|
|
2503
|
+
if (!imports.some(binds))
|
|
2504
|
+
return imports;
|
|
2505
|
+
const binding = (0, name_matcher_1.pythonReceiverBinding)(receiver, ref, context);
|
|
2506
|
+
if (binding === 'module') {
|
|
2507
|
+
const keyOf = (m) => (m.isNamespace ? `${m.source}:*` : `${m.source}:${m.exportedName}`);
|
|
2508
|
+
if (new Set(imports.filter(binds).map(keyOf)).size < 2)
|
|
2509
|
+
return imports;
|
|
2510
|
+
const moduleLevel = (0, name_matcher_1.pythonModuleImportKeys)(receiver, ref.filePath, context);
|
|
2511
|
+
const kept = imports.filter((m) => !binds(m) || m.isNamespace || moduleLevel.has(keyOf(m)));
|
|
2512
|
+
return kept.some(binds) ? kept : imports;
|
|
2513
|
+
}
|
|
2514
|
+
return imports.filter((m) => {
|
|
2515
|
+
if (!binds(m))
|
|
2516
|
+
return true;
|
|
2517
|
+
if (binding === 'local')
|
|
2518
|
+
return false;
|
|
2519
|
+
if ('module' in binding)
|
|
2520
|
+
return m.isNamespace && (m.localName === receiver ? m.source : receiver) === binding.module;
|
|
2521
|
+
return !m.isNamespace && m.source === binding.source && m.exportedName === binding.exportedName;
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
function pythonBareImportsInScope(ref, imports, context) {
|
|
2525
|
+
const name = ref.referenceName;
|
|
2526
|
+
const binds = (m) => m.localName === name;
|
|
2527
|
+
if (!imports.some(binds))
|
|
2528
|
+
return imports;
|
|
2529
|
+
const local = (0, name_matcher_1.pythonFunctionImportKeys)(name, ref.filePath, context);
|
|
2530
|
+
if (local.size === 0)
|
|
2531
|
+
return imports;
|
|
2532
|
+
const keyOf = (m) => (m.isNamespace ? `${m.source}:*` : `${m.source}:${m.exportedName}`);
|
|
2533
|
+
const binding = (0, name_matcher_1.pythonReceiverBinding)(name, ref, context);
|
|
2534
|
+
if (binding === 'module') {
|
|
2535
|
+
const moduleLevel = (0, name_matcher_1.pythonModuleImportKeys)(name, ref.filePath, context);
|
|
2536
|
+
return imports.filter((m) => !binds(m) || moduleLevel.has(keyOf(m)) || !local.has(keyOf(m)));
|
|
2537
|
+
}
|
|
2538
|
+
if (binding === 'local' || 'module' in binding)
|
|
2539
|
+
return imports;
|
|
2540
|
+
return imports.filter((m) => !binds(m) || (!m.isNamespace && m.source === binding.source && m.exportedName === binding.exportedName));
|
|
2541
|
+
}
|
|
1854
2542
|
function resolvePythonModuleMember(ref, imports, context) {
|
|
1855
2543
|
const dotIdx = ref.referenceName.indexOf('.');
|
|
1856
2544
|
if (dotIdx <= 0)
|
|
1857
2545
|
return null;
|
|
1858
2546
|
const receiver = ref.referenceName.substring(0, dotIdx);
|
|
1859
|
-
// The immediate member of the module (first segment after the receiver).
|
|
1860
2547
|
const member = ref.referenceName.substring(dotIdx + 1).split('.')[0];
|
|
1861
2548
|
if (!member)
|
|
1862
2549
|
return null;
|
|
2550
|
+
const local = (0, name_matcher_1.pythonFunctionModuleAlias)(receiver, ref, context);
|
|
2551
|
+
if (local) {
|
|
2552
|
+
const localPath = resolveImportPath(local, ref.filePath, ref.language, context);
|
|
2553
|
+
const target = localPath && localPath !== ref.filePath
|
|
2554
|
+
? findExportedSymbol(localPath, { isDefault: false, isNamespace: false, exportedName: member, memberName: null }, 'python', context, new Set())
|
|
2555
|
+
: null;
|
|
2556
|
+
return target ? { original: ref, targetNodeId: target.id, confidence: 0.85, resolvedBy: 'import' } : null;
|
|
2557
|
+
}
|
|
1863
2558
|
for (const imp of imports) {
|
|
1864
|
-
|
|
2559
|
+
const spelledOut = imp.isNamespace && imp.localName === imp.source.split('.').pop()
|
|
2560
|
+
&& imp.source.includes('.') && ref.referenceName.startsWith(`${imp.source}.`);
|
|
2561
|
+
if (imp.localName !== receiver && !spelledOut)
|
|
1865
2562
|
continue;
|
|
1866
|
-
// `import mod` / `import numpy as np` bind the module at `source` itself;
|
|
1867
|
-
// `from . import certs` / `from pkg import mod` bind a SUBMODULE whose
|
|
1868
|
-
// dotted path is the source joined with the imported name.
|
|
1869
|
-
//
|
|
1870
|
-
// Join with the EXPORTED name, not the local one: under
|
|
1871
|
-
// `from pkg import mod as alias` the receiver is `alias` but the module on
|
|
1872
|
-
// disk is `pkg.mod`, and building `pkg.alias` looked for a file that does
|
|
1873
|
-
// not exist — so the aliased form dropped its `calls` edge while the plain
|
|
1874
|
-
// form (where the two names coincide) worked (#1626). For an unaliased
|
|
1875
|
-
// import the two are identical, so this changes nothing there.
|
|
1876
2563
|
const moduleName = imp.exportedName === '*' ? imp.localName : imp.exportedName;
|
|
1877
|
-
|
|
2564
|
+
let modulePath = imp.isNamespace
|
|
1878
2565
|
? imp.source
|
|
1879
2566
|
: imp.source.endsWith('.')
|
|
1880
2567
|
? imp.source + moduleName
|
|
1881
2568
|
: imp.source + '.' + moduleName;
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
// `from pkg import module` dropped its `calls` edge even though the import
|
|
1888
|
-
// edge resolved (#578).
|
|
2569
|
+
const rest = ref.referenceName
|
|
2570
|
+
.substring(spelledOut ? imp.source.length + 1 : dotIdx + 1)
|
|
2571
|
+
.split('.');
|
|
2572
|
+
if (!imp.isNamespace && pythonPackageBinds(imp, ref.filePath, context))
|
|
2573
|
+
continue;
|
|
1889
2574
|
let resolvedPath = resolveImportPath(modulePath, ref.filePath, ref.language, context);
|
|
1890
|
-
if (!resolvedPath) {
|
|
1891
|
-
resolvedPath = findPythonModuleFile(modulePath, context, ref.filePath)?.filePath ?? null;
|
|
1892
|
-
}
|
|
1893
2575
|
if (!resolvedPath || resolvedPath === ref.filePath)
|
|
1894
2576
|
continue;
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
2577
|
+
const bound = (filePath, name) => findExportedSymbol(filePath, { isDefault: false, isNamespace: false, exportedName: name, memberName: null }, 'python', context, new Set());
|
|
2578
|
+
if (ref.referenceKind === 'calls' && rest.length > 1) {
|
|
2579
|
+
while (rest.length > 1) {
|
|
2580
|
+
const sub = resolveImportPath(`${modulePath}.${rest[0]}`, ref.filePath, ref.language, context);
|
|
2581
|
+
if (!sub)
|
|
2582
|
+
break;
|
|
2583
|
+
modulePath = `${modulePath}.${rest.shift()}`;
|
|
2584
|
+
resolvedPath = sub;
|
|
2585
|
+
}
|
|
2586
|
+
const head = bound(resolvedPath, rest[0]);
|
|
2587
|
+
let target;
|
|
2588
|
+
if (rest.length === 1) {
|
|
2589
|
+
target = head && (head.kind === 'function' || head.kind === 'class') ? head : undefined;
|
|
2590
|
+
}
|
|
2591
|
+
else if (rest.length === 2 && head?.kind === 'class') {
|
|
2592
|
+
target = context.getNodesInFile(head.filePath).find((n) => n.kind === 'method' && n.name === rest[1] && n.qualifiedName === `${head.qualifiedName}::${rest[1]}`);
|
|
2593
|
+
}
|
|
2594
|
+
if (target) {
|
|
2595
|
+
return { original: ref, targetNodeId: target.id, confidence: 0.85, resolvedBy: 'import' };
|
|
2596
|
+
}
|
|
2597
|
+
continue;
|
|
2598
|
+
}
|
|
2599
|
+
const target = bound(resolvedPath, rest[0]);
|
|
1899
2600
|
if (target) {
|
|
1900
2601
|
return { original: ref, targetNodeId: target.id, confidence: 0.85, resolvedBy: 'import' };
|
|
1901
2602
|
}
|
|
1902
2603
|
}
|
|
1903
2604
|
return null;
|
|
1904
2605
|
}
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
* It is also the robust backstop for {@link resolvePythonModuleMember} and for
|
|
1914
|
-
* TS namespace usage: it records the dependency even when the used member is
|
|
1915
|
-
* re-exported elsewhere (requests' `certs.where`, re-exported from `certifi`),
|
|
1916
|
-
* the usage is module-level code that isn't extracted as a call, or a TS
|
|
1917
|
-
* namespace is touched only via a value-member read (`ns.SOME_CONST`).
|
|
1918
|
-
*
|
|
1919
|
-
* Only fires for dot-free `imports`-kind refs whose module path resolves to a
|
|
1920
|
-
* real file. A NAMED TS/JS import (`import { widget }`) is not a module, so it
|
|
1921
|
-
* returns null and normal symbol resolution handles it.
|
|
1922
|
-
*/
|
|
1923
|
-
/**
|
|
1924
|
-
* Resolve a Lua/Luau `require(...)` to its module file. The reference name is
|
|
1925
|
-
* either a dotted module path (`telescope.config` → `telescope/config.lua`) or a
|
|
1926
|
-
* Roblox instance-path leaf (`Signal` from `require(script.Parent.Signal)` →
|
|
1927
|
-
* `Signal.luau`). We try `<path>.lua|.luau` and `<path>/init.lua|.luau`, matched
|
|
1928
|
-
* by path suffix (the module root — `lua/`, `src/`, … — is project-specific).
|
|
1929
|
-
* Among suffix matches, the one sharing the longest directory prefix with the
|
|
1930
|
-
* requiring file wins (instance-path requires resolve within the same package).
|
|
1931
|
-
*/
|
|
2606
|
+
function pythonPackageBinds(imp, fromFile, context) {
|
|
2607
|
+
if (imp.isNamespace || imp.exportedName === '*')
|
|
2608
|
+
return false;
|
|
2609
|
+
const packageFile = resolveImportPath(imp.source, fromFile, 'python', context);
|
|
2610
|
+
if (!packageFile || !/(?:^|\/)__init__\.py$/.test(packageFile))
|
|
2611
|
+
return false;
|
|
2612
|
+
return (findExportedSymbol(packageFile, { isDefault: false, isNamespace: false, exportedName: imp.exportedName, memberName: null }, 'python', context, new Set()) !== undefined);
|
|
2613
|
+
}
|
|
1932
2614
|
function resolveLuaRequire(ref, context) {
|
|
1933
2615
|
const name = ref.referenceName;
|
|
1934
2616
|
if (!name)
|
|
@@ -1943,9 +2625,6 @@ function resolveLuaRequire(ref, context) {
|
|
|
1943
2625
|
return i;
|
|
1944
2626
|
};
|
|
1945
2627
|
for (const suffix of suffixes) {
|
|
1946
|
-
// Only files sharing the suffix's basename can match — the bucket is in
|
|
1947
|
-
// getAllFiles() order, so this filter yields exactly what the full-list
|
|
1948
|
-
// scan did.
|
|
1949
2628
|
const candidates = byBasename.get(suffix.split('/').pop() ?? '') ?? [];
|
|
1950
2629
|
const matches = candidates.filter((f) => f === suffix || f.endsWith('/' + suffix));
|
|
1951
2630
|
if (matches.length === 0)
|
|
@@ -1956,30 +2635,11 @@ function resolveLuaRequire(ref, context) {
|
|
|
1956
2635
|
continue;
|
|
1957
2636
|
const fileNode = context.getNodesInFile(best).find((n) => n.kind === 'file');
|
|
1958
2637
|
if (fileNode) {
|
|
1959
|
-
// Confidence ≥ 0.9 so this deterministic path/suffix match wins over
|
|
1960
|
-
// name-matching, which otherwise resolves the require to the import node
|
|
1961
|
-
// itself (a same-name self-match).
|
|
1962
2638
|
return { original: ref, targetNodeId: fileNode.id, confidence: 0.9, resolvedBy: 'import' };
|
|
1963
2639
|
}
|
|
1964
2640
|
}
|
|
1965
2641
|
return null;
|
|
1966
2642
|
}
|
|
1967
|
-
/**
|
|
1968
|
-
* `UploadApi.uploadARCapture()` where `UploadApi` is a NAMESPACE OBJECT — the
|
|
1969
|
-
* default-export façade most React Native API layers are written as:
|
|
1970
|
-
*
|
|
1971
|
-
* import { uploadARCapture } from './frames'
|
|
1972
|
-
* const UploadApi = { uploadARCapture, createFolder }
|
|
1973
|
-
* export default UploadApi
|
|
1974
|
-
*
|
|
1975
|
-
* The member is a shorthand (or `key: ident`) property whose value is a
|
|
1976
|
-
* binding of the object's file, not a function defined inside the literal,
|
|
1977
|
-
* so containment (`resolveObjectLiteralMember`) finds nothing and the call
|
|
1978
|
-
* landed on the constant — every cross-file caller of the API function went
|
|
1979
|
-
* missing. Read the literal's source, take the binding the member names, and
|
|
1980
|
-
* resolve it where the object's file would: a symbol declared there, else
|
|
1981
|
-
* through its own imports. Calls accept callable targets only.
|
|
1982
|
-
*/
|
|
1983
2643
|
function resolveObjectLiteralAlias(container, member, ref, context) {
|
|
1984
2644
|
if (container.kind !== 'constant' && container.kind !== 'variable')
|
|
1985
2645
|
return null;
|
|
@@ -1998,28 +2658,22 @@ function resolveModuleImportToFile(ref, imports, context) {
|
|
|
1998
2658
|
continue;
|
|
1999
2659
|
let modulePath;
|
|
2000
2660
|
if (imp.isNamespace || imp.isDefault) {
|
|
2001
|
-
// `import * as ns from './x'` (namespace) or `import x from './x'`
|
|
2002
|
-
// (default) — the dependency is on the MODULE FILE. A default import binds
|
|
2003
|
-
// a (possibly renamed) local to whatever the module's default export is
|
|
2004
|
-
// (`import articlesController from './article.controller'` ← `export
|
|
2005
|
-
// default router`), so the binding name can't be found as a symbol — link
|
|
2006
|
-
// the file the import resolves to instead. External modules don't resolve
|
|
2007
|
-
// (no file), so `import React from 'react'` creates no edge.
|
|
2008
2661
|
modulePath = imp.source;
|
|
2009
2662
|
}
|
|
2010
2663
|
else if (ref.language === 'python') {
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
// still links to the real module file (#1626).
|
|
2664
|
+
if (pythonPackageBinds(imp, ref.filePath, context))
|
|
2665
|
+
continue;
|
|
2014
2666
|
const moduleName = imp.exportedName === '*' ? imp.localName : imp.exportedName;
|
|
2015
2667
|
modulePath = imp.source.endsWith('.')
|
|
2016
2668
|
? imp.source + moduleName
|
|
2017
2669
|
: imp.source + '.' + moduleName;
|
|
2018
2670
|
}
|
|
2019
2671
|
else {
|
|
2020
|
-
// A named TS/JS import binds a symbol, not a module — leave it alone.
|
|
2021
2672
|
continue;
|
|
2022
2673
|
}
|
|
2674
|
+
const declaring = declaredModuleFile(modulePath, ref, context);
|
|
2675
|
+
if (declaring)
|
|
2676
|
+
return { original: ref, targetNodeId: declaring.id, confidence: 0.9, resolvedBy: 'import' };
|
|
2023
2677
|
const resolvedPath = resolveImportPath(modulePath, ref.filePath, ref.language, context);
|
|
2024
2678
|
if (resolvedPath && resolvedPath !== ref.filePath) {
|
|
2025
2679
|
const fileNode = context.getNodesInFile(resolvedPath).find((n) => n.kind === 'file');
|
|
@@ -2027,390 +2681,172 @@ function resolveModuleImportToFile(ref, imports, context) {
|
|
|
2027
2681
|
return { original: ref, targetNodeId: fileNode.id, confidence: 0.9, resolvedBy: 'import' };
|
|
2028
2682
|
}
|
|
2029
2683
|
}
|
|
2030
|
-
// Python absolute `from a.b import submodule` (a FastAPI router aggregator's
|
|
2031
|
-
// `from app.api.routes import authentication`): resolveImportPath only maps
|
|
2032
|
-
// RELATIVE dotted paths to a file, so resolve the absolute dotted module
|
|
2033
|
-
// directly to its file node.
|
|
2034
|
-
if (ref.language === 'python') {
|
|
2035
|
-
const modFile = findPythonModuleFile(modulePath, context, ref.filePath);
|
|
2036
|
-
if (modFile) {
|
|
2037
|
-
return { original: ref, targetNodeId: modFile.id, confidence: 0.9, resolvedBy: 'import' };
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
2684
|
}
|
|
2041
2685
|
return null;
|
|
2042
2686
|
}
|
|
2043
|
-
/**
|
|
2044
|
-
* Find the file node for a Python dotted module path `a.b.c` — a module file
|
|
2045
|
-
* ending in `a/b/c.py`, or a package `a/b/c/__init__.py` (suffix-matched, so a
|
|
2046
|
-
* package rooted under `src/` etc. still resolves). Returns null for
|
|
2047
|
-
* stdlib/external modules (no matching repo file node), so `import os` creates
|
|
2048
|
-
* no edge. Shared by absolute `import a.b.c` and absolute `from a.b import c`
|
|
2049
|
-
* (where `c` is a submodule) resolution.
|
|
2050
|
-
*/
|
|
2051
|
-
/**
|
|
2052
|
-
* Per-context memo for findPythonModuleFile: module path → the `<mod>.py` and
|
|
2053
|
-
* `<mod>/__init__.py` file nodes whose path ends with it, in name-lookup
|
|
2054
|
-
* order. Only the importing file's own path is excluded per call, so taking
|
|
2055
|
-
* the first survivor returns the node the unmemoized scan found. Without it,
|
|
2056
|
-
* every ref naming a module outside the project (`from unittest import mock`)
|
|
2057
|
-
* rescanned every `__init__.py` in the tree. Same stable window as the name
|
|
2058
|
-
* caches; dropped by clearImportResolverMemos.
|
|
2059
|
-
*/
|
|
2060
|
-
const pythonModuleFileMemos = new WeakMap();
|
|
2061
|
-
/**
|
|
2062
|
-
* A top-level class / function / value named `name` in a Python module, or
|
|
2063
|
-
* one the module re-exports — `from .users import *`, `from .users import
|
|
2064
|
-
* User` — a few packages deep. netbox's `from users.models import User` names
|
|
2065
|
-
* `users/models/__init__.py`, which star-imports `.users`, where `User` is.
|
|
2066
|
-
*/
|
|
2067
|
-
const PY_MODULE_SYMBOLS = new WeakMap();
|
|
2068
|
-
function pythonModuleSymbol(file, name, context, depth) {
|
|
2069
|
-
let memo = PY_MODULE_SYMBOLS.get(context);
|
|
2070
|
-
if (!memo)
|
|
2071
|
-
PY_MODULE_SYMBOLS.set(context, (memo = new Map()));
|
|
2072
|
-
const key = `${file}\0${name}`;
|
|
2073
|
-
const hit = memo.get(key);
|
|
2074
|
-
if (hit !== undefined)
|
|
2075
|
-
return hit ?? undefined;
|
|
2076
|
-
// (A cycle of star imports reads as "not here" while it is being walked.)
|
|
2077
|
-
memo.set(key, null);
|
|
2078
|
-
const found = pythonModuleSymbolUncached(file, name, context, depth);
|
|
2079
|
-
memo.set(key, found ?? null);
|
|
2080
|
-
return found;
|
|
2081
|
-
}
|
|
2082
|
-
function pythonModuleSymbolUncached(file, name, context, depth) {
|
|
2083
|
-
const own = context.getNodesInFile(file).find((n) => n.name === name && !n.qualifiedName.includes('::') &&
|
|
2084
|
-
(n.kind === 'class' || n.kind === 'function' || n.kind === 'variable' || n.kind === 'constant'));
|
|
2085
|
-
if (own || depth >= 3)
|
|
2086
|
-
return own;
|
|
2087
|
-
// Re-exported by name (`from .users import User`), else through a star import
|
|
2088
|
-
// (`from .users import *` — not among the import mappings, so read here).
|
|
2089
|
-
const sources = context.getImportMappings(file, 'python')
|
|
2090
|
-
.filter((imp) => !imp.isNamespace && imp.localName === name)
|
|
2091
|
-
.map((imp) => ({ source: imp.source, exported: imp.exportedName }));
|
|
2092
|
-
for (const m of (context.readFile(file) ?? '').matchAll(/^\s*from\s+([\w.]+)\s+import\s+\*/gm)) {
|
|
2093
|
-
sources.push({ source: m[1], exported: name });
|
|
2094
|
-
}
|
|
2095
|
-
for (const { source, exported } of sources) {
|
|
2096
|
-
const target = resolveImportPath(source, file, 'python', context) ?? findPythonModuleFile(source, context, file)?.filePath ?? null;
|
|
2097
|
-
if (!target || target === file)
|
|
2098
|
-
continue;
|
|
2099
|
-
const found = pythonModuleSymbol(target, exported, context, depth + 1);
|
|
2100
|
-
if (found)
|
|
2101
|
-
return found;
|
|
2102
|
-
}
|
|
2103
|
-
return undefined;
|
|
2104
|
-
}
|
|
2105
|
-
function findPythonModuleFile(mod, context, excludeFilePath) {
|
|
2106
|
-
if (!mod || mod.startsWith('.'))
|
|
2107
|
-
return null; // relative imports handled elsewhere
|
|
2108
|
-
let memo = pythonModuleFileMemos.get(context);
|
|
2109
|
-
if (!memo) {
|
|
2110
|
-
memo = new Map();
|
|
2111
|
-
pythonModuleFileMemos.set(context, memo);
|
|
2112
|
-
}
|
|
2113
|
-
let files = memo.get(mod);
|
|
2114
|
-
if (!files) {
|
|
2115
|
-
const rel = mod.replace(/\./g, '/');
|
|
2116
|
-
const lastSeg = mod.split('.').pop();
|
|
2117
|
-
const endsWith = (p, want) => p === want || p.endsWith('/' + want);
|
|
2118
|
-
files = {
|
|
2119
|
-
module: context
|
|
2120
|
-
.getNodesByName(`${lastSeg}.py`)
|
|
2121
|
-
.filter((n) => n.kind === 'file' && endsWith(n.filePath, `${rel}.py`)),
|
|
2122
|
-
pkg: context
|
|
2123
|
-
.getNodesByName('__init__.py')
|
|
2124
|
-
.filter((n) => n.kind === 'file' && endsWith(n.filePath, `${rel}/__init__.py`)),
|
|
2125
|
-
};
|
|
2126
|
-
memo.set(mod, files);
|
|
2127
|
-
}
|
|
2128
|
-
return (files.module.find((n) => n.filePath !== excludeFilePath) ??
|
|
2129
|
-
files.pkg.find((n) => n.filePath !== excludeFilePath) ??
|
|
2130
|
-
null);
|
|
2131
|
-
}
|
|
2132
|
-
/**
|
|
2133
|
-
* Resolve a Python ABSOLUTE dotted module import (`import a.b.c`) to its file —
|
|
2134
|
-
* the Django `AppConfig.ready(): import myapp.signals` pattern and any
|
|
2135
|
-
* side-effect module import.
|
|
2136
|
-
*/
|
|
2137
2687
|
function resolvePythonAbsoluteModule(ref, context) {
|
|
2138
2688
|
if (ref.referenceKind !== 'imports')
|
|
2139
2689
|
return null;
|
|
2140
|
-
|
|
2141
|
-
// (`from app.api.routes import authentication`) is ambiguous on its own — three
|
|
2142
|
-
// `authentication.py` files may exist — so leave it to resolveModuleImportToFile,
|
|
2143
|
-
// which uses the import's source (`app.api.routes`) to build the full path.
|
|
2144
|
-
if (!ref.referenceName.includes('.'))
|
|
2690
|
+
if (!ref.referenceName.includes('.') && !(0, name_matcher_1.isPythonFromImportModule)(ref, context))
|
|
2145
2691
|
return null;
|
|
2146
|
-
const hit =
|
|
2692
|
+
const hit = pythonModuleFileNode(ref.referenceName, ref.filePath, context);
|
|
2147
2693
|
return hit ? { original: ref, targetNodeId: hit.id, confidence: 0.9, resolvedBy: 'import' } : null;
|
|
2148
2694
|
}
|
|
2149
|
-
/**
|
|
2150
|
-
* Resolve a Rust qualified reference `A::B::C` by mapping the MODULE prefix
|
|
2151
|
-
* (`A::B`) to a file and finding the leaf symbol (`C`) in it. This is the Rust
|
|
2152
|
-
* analog of {@link resolvePythonModuleMember} / {@link resolveGoCrossPackageReference}
|
|
2153
|
-
* and the precise answer to common-name re-exports (`pub use self::read::read`)
|
|
2154
|
-
* that name-matching can't disambiguate. Returns null when the prefix isn't a
|
|
2155
|
-
* real module path (e.g. `Widget::new` — `Widget` is a struct, not a module),
|
|
2156
|
-
* so associated-function calls and enum-variant paths fall through untouched.
|
|
2157
|
-
*/
|
|
2158
2695
|
function resolveRustPathReference(ref, context) {
|
|
2159
|
-
const
|
|
2160
|
-
|
|
2161
|
-
return null;
|
|
2162
|
-
const leaf = segments[segments.length - 1];
|
|
2163
|
-
const modSegs = segments.slice(0, -1);
|
|
2164
|
-
const file = resolveRustModuleFile(modSegs, ref.filePath, context);
|
|
2165
|
-
if (!file || file === ref.filePath)
|
|
2166
|
-
return null;
|
|
2167
|
-
const target = context.getNodesInFile(file).find((n) => n.name === leaf &&
|
|
2168
|
-
(n.kind === 'function' ||
|
|
2169
|
-
n.kind === 'struct' ||
|
|
2170
|
-
n.kind === 'union' ||
|
|
2171
|
-
n.kind === 'enum' ||
|
|
2172
|
-
n.kind === 'trait' ||
|
|
2173
|
-
n.kind === 'type_alias' ||
|
|
2174
|
-
n.kind === 'constant' ||
|
|
2175
|
-
n.kind === 'method' ||
|
|
2176
|
-
n.kind === 'class' ||
|
|
2177
|
-
n.kind === 'interface'));
|
|
2178
|
-
if (target) {
|
|
2179
|
-
return { original: ref, targetNodeId: target.id, confidence: 0.9, resolvedBy: 'import' };
|
|
2180
|
-
}
|
|
2181
|
-
return null;
|
|
2696
|
+
const target = (0, name_matcher_1.rustPathTarget)(ref, context);
|
|
2697
|
+
return target ? { original: ref, targetNodeId: target.id, confidence: 0.9, resolvedBy: 'import' } : null;
|
|
2182
2698
|
}
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
const
|
|
2187
|
-
let
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
const parent = path.dirname(dir);
|
|
2194
|
-
if (parent === dir)
|
|
2195
|
-
return null;
|
|
2196
|
-
dir = parent;
|
|
2699
|
+
const JVM_IMPORT_LANGUAGES = new Set(['java', 'kotlin']);
|
|
2700
|
+
const JVM_IMPORT_TYPE_KINDS = new Set(['class', 'interface', 'enum', 'struct', 'trait', 'type_alias']);
|
|
2701
|
+
function jvmImportedDeclarations(fqn, context) {
|
|
2702
|
+
const parts = fqn.split('.');
|
|
2703
|
+
for (let i = parts.length - 1; i > 0; i--) {
|
|
2704
|
+
const found = context
|
|
2705
|
+
.getNodesByQualifiedName(`${parts.slice(0, i).join('.')}::${parts.slice(i).join('::')}`)
|
|
2706
|
+
.filter((n) => JVM_IMPORT_LANGUAGES.has(n.language));
|
|
2707
|
+
if (found.length > 0)
|
|
2708
|
+
return found;
|
|
2197
2709
|
}
|
|
2198
|
-
return
|
|
2710
|
+
return [];
|
|
2199
2711
|
}
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
const asMod = toRel(path.join(dir, seg, 'mod.rs'));
|
|
2233
|
-
if (context.fileExists(asFile))
|
|
2234
|
-
targetFile = asFile;
|
|
2235
|
-
else if (context.fileExists(asMod))
|
|
2236
|
-
targetFile = asMod;
|
|
2237
|
-
else
|
|
2238
|
-
return null;
|
|
2239
|
-
dir = path.join(dir, seg);
|
|
2712
|
+
function kotlinFileFacadeMembers(fqn, member, context) {
|
|
2713
|
+
const dot = fqn.lastIndexOf('.');
|
|
2714
|
+
const facade = fqn.slice(dot + 1);
|
|
2715
|
+
if (dot <= 0 || !/^\w+Kt$/.test(facade))
|
|
2716
|
+
return [];
|
|
2717
|
+
const fileName = `${facade.slice(0, -2)}.kt`;
|
|
2718
|
+
return context
|
|
2719
|
+
.getNodesByQualifiedName(`${fqn.slice(0, dot)}::${member}`)
|
|
2720
|
+
.filter((n) => n.language === 'kotlin' && (n.kind === 'function' || n.kind === 'variable' || n.kind === 'constant') &&
|
|
2721
|
+
path.posix.basename(n.filePath.replace(/\\/g, '/')) === fileName);
|
|
2722
|
+
}
|
|
2723
|
+
function jvmImportedMember(owner, steps, ref, context) {
|
|
2724
|
+
const built = (type) => (ref.language === 'kotlin'
|
|
2725
|
+
? context.getNodesByQualifiedName(`${type.qualifiedName}::${type.name}`)
|
|
2726
|
+
.find((n) => n.kind === 'method' && n.filePath === type.filePath)
|
|
2727
|
+
: undefined) ?? type;
|
|
2728
|
+
let current = owner;
|
|
2729
|
+
for (let i = 0; i < steps.length; i++) {
|
|
2730
|
+
const segment = steps[i];
|
|
2731
|
+
const last = i === steps.length - 1;
|
|
2732
|
+
if (!last && (segment === 'INSTANCE' || segment === 'Companion') && current.language === 'kotlin' &&
|
|
2733
|
+
JVM_IMPORT_TYPE_KINDS.has(current.kind))
|
|
2734
|
+
continue;
|
|
2735
|
+
const members = context
|
|
2736
|
+
.getNodesByQualifiedName(`${current.qualifiedName}::${segment}`)
|
|
2737
|
+
.filter((n) => n.filePath === current.filePath);
|
|
2738
|
+
if (!last) {
|
|
2739
|
+
const nested = members.find((n) => JVM_IMPORT_TYPE_KINDS.has(n.kind));
|
|
2740
|
+
if (!nested)
|
|
2741
|
+
return undefined;
|
|
2742
|
+
current = nested;
|
|
2743
|
+
continue;
|
|
2240
2744
|
}
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
// and general cross-module-call pattern) the prefix is a SUBMODULE of the
|
|
2261
|
-
// current module, i.e. 2018 `self::`-relative — so try self-relative FIRST.
|
|
2262
|
-
// Fall back to crate-relative for 2015-edition / crate-root items. External
|
|
2263
|
-
// crate paths (`serde::de::Error`) miss both and fall through to name-matching.
|
|
2264
|
-
return (resolveUnder(rustSelfModuleDir(fromAbs), segments) ??
|
|
2265
|
-
resolveUnder(rustCrateRootDir(fromAbs, context), segments));
|
|
2266
|
-
}
|
|
2267
|
-
/**
|
|
2268
|
-
* Resolve a Java/Kotlin reference whose receiver is the simple name of
|
|
2269
|
-
* an imported FQN: `Foo.bar(...)` where `import com.example.Foo;`. The
|
|
2270
|
-
* imported FQN converts to a file-path suffix (`com/example/Foo.java`
|
|
2271
|
-
* or `.kt`) which uniquely identifies the right symbol when multiple
|
|
2272
|
-
* classes share the same simple name.
|
|
2273
|
-
*
|
|
2274
|
-
* Also handles bare references to the imported class itself
|
|
2275
|
-
* (`new Foo()` extraction emits `Foo` as a `references`/`instantiates`
|
|
2276
|
-
* ref) and `import static <Foo>.bar` style imports of a single member.
|
|
2277
|
-
*/
|
|
2745
|
+
if (ref.referenceKind !== 'calls')
|
|
2746
|
+
return members[0];
|
|
2747
|
+
const method = members.find((n) => n.kind === 'method' || n.kind === 'function');
|
|
2748
|
+
if (method)
|
|
2749
|
+
return method;
|
|
2750
|
+
const type = members.find((n) => JVM_IMPORT_TYPE_KINDS.has(n.kind));
|
|
2751
|
+
if (type)
|
|
2752
|
+
return built(type);
|
|
2753
|
+
const holder = current;
|
|
2754
|
+
const extension = ref.language === 'kotlin' && holder.language === 'kotlin'
|
|
2755
|
+
? context
|
|
2756
|
+
.getNodesByQualifiedName(`${holder.name}::${segment}`)
|
|
2757
|
+
.find((n) => n.kind === 'method' && n.language === 'kotlin' && n.filePath === holder.filePath &&
|
|
2758
|
+
(0, name_matcher_1.isKotlinExtensionInScope)(n, ref, context))
|
|
2759
|
+
: undefined;
|
|
2760
|
+
return extension ?? members[0];
|
|
2761
|
+
}
|
|
2762
|
+
return ref.referenceKind === 'calls' && JVM_IMPORT_TYPE_KINDS.has(current.kind) ? built(current) : current;
|
|
2763
|
+
}
|
|
2278
2764
|
function resolveJavaImportedReference(ref, imports, context) {
|
|
2279
2765
|
if (imports.length === 0)
|
|
2280
2766
|
return null;
|
|
2281
|
-
const ext = ref.language === 'kotlin' ? '.kt' : '.java';
|
|
2282
2767
|
for (const imp of imports) {
|
|
2283
2768
|
const matchesBare = imp.localName === ref.referenceName;
|
|
2284
2769
|
const matchesQualified = ref.referenceName.startsWith(imp.localName + '.');
|
|
2285
2770
|
if (!matchesBare && !matchesQualified)
|
|
2286
2771
|
continue;
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
if (node.language !== ref.language)
|
|
2299
|
-
continue;
|
|
2300
|
-
const fp = node.filePath.replace(/\\/g, '/');
|
|
2301
|
-
if (fp.endsWith(fqnPath) || fp.endsWith('/' + fqnPath)) {
|
|
2302
|
-
return {
|
|
2303
|
-
original: ref,
|
|
2304
|
-
targetNodeId: node.id,
|
|
2305
|
-
confidence: 0.9,
|
|
2306
|
-
resolvedBy: 'import',
|
|
2307
|
-
};
|
|
2308
|
-
}
|
|
2772
|
+
const memberPath = matchesBare ? [] : ref.referenceName.substring(imp.localName.length + 1).split('.');
|
|
2773
|
+
const named = jvmImportedDeclarations(imp.source, context);
|
|
2774
|
+
const declarations = named.filter((n) => JVM_IMPORT_TYPE_KINDS.has(n.kind));
|
|
2775
|
+
const callOfFunction = matchesBare && ref.referenceKind === 'calls' &&
|
|
2776
|
+
named.some((n) => n.kind === 'function' || n.kind === 'method');
|
|
2777
|
+
if (declarations.length > 0 && !callOfFunction) {
|
|
2778
|
+
const owner = declarations.length === 1 ? declarations[0] : pickJvmDeclaration(declarations, ref);
|
|
2779
|
+
const target = jvmImportedMember(owner, memberPath, ref, context);
|
|
2780
|
+
if (target)
|
|
2781
|
+
return (0, name_matcher_1.retargetSelfOverload)({ original: ref, targetNodeId: target.id, confidence: 0.9, resolvedBy: 'import' }, ref, context);
|
|
2782
|
+
continue;
|
|
2309
2783
|
}
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
const dot = imp.source.lastIndexOf('.');
|
|
2316
|
-
if (dot > 0) {
|
|
2317
|
-
const ownerFqn = imp.source.substring(0, dot);
|
|
2318
|
-
const ownerPath = ownerFqn.replace(/\./g, '/') + ext;
|
|
2319
|
-
for (const node of candidates) {
|
|
2320
|
-
if (node.language !== ref.language)
|
|
2321
|
-
continue;
|
|
2322
|
-
const fp = node.filePath.replace(/\\/g, '/');
|
|
2323
|
-
if (fp.endsWith(ownerPath) || fp.endsWith('/' + ownerPath)) {
|
|
2324
|
-
return {
|
|
2325
|
-
original: ref,
|
|
2326
|
-
targetNodeId: node.id,
|
|
2327
|
-
confidence: 0.9,
|
|
2328
|
-
resolvedBy: 'import',
|
|
2329
|
-
};
|
|
2330
|
-
}
|
|
2331
|
-
}
|
|
2784
|
+
if (ref.language === 'java' && memberPath.length === 1) {
|
|
2785
|
+
const facadeMembers = kotlinFileFacadeMembers(imp.source, memberPath[0], context);
|
|
2786
|
+
if (facadeMembers.length > 0) {
|
|
2787
|
+
const target = facadeMembers.length === 1 ? facadeMembers[0] : pickClosestJvmCandidate(facadeMembers, ref.filePath);
|
|
2788
|
+
return (0, name_matcher_1.retargetSelfOverload)({ original: ref, targetNodeId: target.id, confidence: 0.9, resolvedBy: 'import' }, ref, context);
|
|
2332
2789
|
}
|
|
2333
2790
|
}
|
|
2791
|
+
const memberName = matchesBare ? imp.localName : memberPath.join('.');
|
|
2792
|
+
const fqnPath = imp.source.replace(/\./g, '/');
|
|
2793
|
+
const ownerPath = imp.source.includes('.') ? imp.source.substring(0, imp.source.lastIndexOf('.')).replace(/\./g, '/') : '';
|
|
2794
|
+
const inFile = (node, file) => {
|
|
2795
|
+
const fp = node.filePath.replace(/\\/g, '/');
|
|
2796
|
+
return ['.java', '.kt'].some((ext) => fp.endsWith(file + ext) && (fp.length === file.length + ext.length || fp[fp.length - file.length - ext.length - 1] === '/'));
|
|
2797
|
+
};
|
|
2798
|
+
const candidates = context.getNodesByName(memberName).filter((n) => JVM_IMPORT_LANGUAGES.has(n.language));
|
|
2799
|
+
const byPath = candidates.find((n) => inFile(n, fqnPath)) ??
|
|
2800
|
+
(matchesBare && ownerPath ? candidates.find((n) => inFile(n, ownerPath)) : undefined);
|
|
2801
|
+
if (byPath)
|
|
2802
|
+
return (0, name_matcher_1.retargetSelfOverload)({ original: ref, targetNodeId: byPath.id, confidence: 0.9, resolvedBy: 'import' }, ref, context);
|
|
2334
2803
|
}
|
|
2335
2804
|
return null;
|
|
2336
2805
|
}
|
|
2337
|
-
/**
|
|
2338
|
-
* Resolve a Go cross-package qualified reference (`pkga.FuncX`) by matching
|
|
2339
|
-
* the package alias against an in-module import, stripping the module prefix
|
|
2340
|
-
* to a project-relative directory, and locating the exported symbol in any
|
|
2341
|
-
* `.go` file under that directory. Returns `null` for stdlib / third-party
|
|
2342
|
-
* imports (no `go.mod`-relative match) so the rest of `resolveViaImport`
|
|
2343
|
-
* can still try the file-based path.
|
|
2344
|
-
*/
|
|
2345
2806
|
function resolveGoCrossPackageReference(ref, imports, context) {
|
|
2346
|
-
const mod = context.getGoModule?.();
|
|
2347
|
-
if (!mod)
|
|
2348
|
-
return null;
|
|
2349
|
-
// Qualified call: receiver before `.`, member after. A bare reference
|
|
2350
|
-
// (no dot) is a same-file/in-package call — handled elsewhere.
|
|
2351
2807
|
const dotIdx = ref.referenceName.indexOf('.');
|
|
2352
|
-
if (dotIdx <= 0)
|
|
2353
|
-
|
|
2808
|
+
if (dotIdx <= 0) {
|
|
2809
|
+
const imp = (0, name_matcher_1.goRefQualifier)(ref, context);
|
|
2810
|
+
return imp ? findGoPackageMember(ref.referenceName, imp, ref, context) : null;
|
|
2811
|
+
}
|
|
2354
2812
|
const receiver = ref.referenceName.substring(0, dotIdx);
|
|
2355
2813
|
const memberName = ref.referenceName.substring(dotIdx + 1);
|
|
2356
2814
|
if (!memberName)
|
|
2357
2815
|
return null;
|
|
2816
|
+
if (!(0, name_matcher_1.goRefQualifier)(ref, context))
|
|
2817
|
+
return null;
|
|
2358
2818
|
for (const imp of imports) {
|
|
2359
2819
|
if (imp.localName !== receiver)
|
|
2360
2820
|
continue;
|
|
2361
|
-
|
|
2362
|
-
if (
|
|
2821
|
+
const found = findGoPackageMember(memberName, imp, ref, context);
|
|
2822
|
+
if (found)
|
|
2823
|
+
return found;
|
|
2824
|
+
}
|
|
2825
|
+
return null;
|
|
2826
|
+
}
|
|
2827
|
+
function findGoPackageMember(memberName, imp, ref, context) {
|
|
2828
|
+
const pkgDir = context.getGoPackageDir?.(imp.source, ref.filePath);
|
|
2829
|
+
if (pkgDir == null)
|
|
2830
|
+
return null;
|
|
2831
|
+
for (const node of context.getNodesByName(memberName)) {
|
|
2832
|
+
if (node.language !== 'go')
|
|
2363
2833
|
continue;
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
for (const node of candidates) {
|
|
2374
|
-
if (node.language !== 'go')
|
|
2375
|
-
continue;
|
|
2376
|
-
if (!node.isExported)
|
|
2377
|
-
continue;
|
|
2378
|
-
const fp = node.filePath.replace(/\\/g, '/');
|
|
2379
|
-
const lastSlash = fp.lastIndexOf('/');
|
|
2380
|
-
const fileDir = lastSlash >= 0 ? fp.substring(0, lastSlash) : '';
|
|
2381
|
-
if (fileDir === pkgDir) {
|
|
2382
|
-
return {
|
|
2383
|
-
original: ref,
|
|
2384
|
-
targetNodeId: node.id,
|
|
2385
|
-
confidence: 0.9,
|
|
2386
|
-
resolvedBy: 'import',
|
|
2387
|
-
};
|
|
2388
|
-
}
|
|
2834
|
+
if (!node.isExported || node.kind === 'method')
|
|
2835
|
+
continue;
|
|
2836
|
+
if (path.posix.dirname(node.filePath.replace(/\\/g, '/')) === pkgDir) {
|
|
2837
|
+
return {
|
|
2838
|
+
original: ref,
|
|
2839
|
+
targetNodeId: node.id,
|
|
2840
|
+
confidence: 0.9,
|
|
2841
|
+
resolvedBy: 'import',
|
|
2842
|
+
};
|
|
2389
2843
|
}
|
|
2390
2844
|
}
|
|
2391
2845
|
return null;
|
|
2392
2846
|
}
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
const REEXPORT_MAX_DEPTH = 8;
|
|
2397
|
-
/**
|
|
2398
|
-
* Find an exported symbol in `filePath`, following `export { x } from
|
|
2399
|
-
* './other'` and `export * from './other'` chains until the original
|
|
2400
|
-
* declaration is reached. Cycle-safe via the `visited` set.
|
|
2401
|
-
*
|
|
2402
|
-
* Without this, every barrel-style import (`import { Foo } from
|
|
2403
|
-
* './index'` where `index.ts` only re-exports) used to resolve to
|
|
2404
|
-
* nothing — the existing code only looked for declarations IN the
|
|
2405
|
-
* resolved file, not declarations the file forwarded.
|
|
2406
|
-
*/
|
|
2407
|
-
function findExportedSymbol(filePath, want, language, context, visited, depth = 0) {
|
|
2408
|
-
// Memoize fresh (top-level) lookups only: recursive re-export steps carry a
|
|
2409
|
-
// populated `visited` set, whose contents change the reachable answer.
|
|
2410
|
-
// Every ref to the same imported symbol repeats this exact walk, so the
|
|
2411
|
-
// top-level memo removes the re-export chase + per-file linear scans from
|
|
2412
|
-
// all but the first occurrence.
|
|
2413
|
-
if (depth === 0 && visited.size === 0) {
|
|
2847
|
+
exports.REEXPORT_MAX_DEPTH = 8;
|
|
2848
|
+
function findExportedSymbol(filePath, want, language, context, visited, depth = 0, members = 'after') {
|
|
2849
|
+
if (depth === 0 && visited.size === 0 && members === 'after') {
|
|
2414
2850
|
let memo = exportedSymbolMemos.get(context);
|
|
2415
2851
|
if (!memo) {
|
|
2416
2852
|
memo = new Map();
|
|
@@ -2419,82 +2855,83 @@ function findExportedSymbol(filePath, want, language, context, visited, depth =
|
|
|
2419
2855
|
const key = `${filePath}\0${want.isDefault ? 1 : 0}${want.isNamespace ? 1 : 0}\0${want.exportedName}\0${want.memberName ?? ''}\0${language}`;
|
|
2420
2856
|
if (memo.has(key))
|
|
2421
2857
|
return memo.get(key);
|
|
2422
|
-
const result = findExportedSymbolWalk(filePath, want, language, context, visited, depth);
|
|
2858
|
+
const result = findExportedSymbolWalk(filePath, want, language, context, visited, depth, members);
|
|
2423
2859
|
memo.set(key, result);
|
|
2424
2860
|
return result;
|
|
2425
2861
|
}
|
|
2426
|
-
return findExportedSymbolWalk(filePath, want, language, context, visited, depth);
|
|
2862
|
+
return findExportedSymbolWalk(filePath, want, language, context, visited, depth, members);
|
|
2427
2863
|
}
|
|
2428
|
-
function findExportedSymbolWalk(filePath, want, language, context, visited, depth) {
|
|
2429
|
-
if (depth > REEXPORT_MAX_DEPTH)
|
|
2864
|
+
function findExportedSymbolWalk(filePath, want, language, context, visited, depth, members) {
|
|
2865
|
+
if (depth > exports.REEXPORT_MAX_DEPTH)
|
|
2430
2866
|
return undefined;
|
|
2431
2867
|
if (visited.has(filePath))
|
|
2432
2868
|
return undefined;
|
|
2433
2869
|
visited.add(filePath);
|
|
2434
2870
|
const exportIndex = getFileExportIndex(filePath, context);
|
|
2435
|
-
// 1. Direct hit: the symbol is declared in this file.
|
|
2436
2871
|
if (want.isDefault) {
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
// branch, an `export { default as X } from './X.svelte'` barrel never
|
|
2442
|
-
// resolves and the component shows a false 0 callers (#629).
|
|
2443
|
-
// A component file IS its default export; otherwise the statement that
|
|
2444
|
-
// names the binding beats the first-exported-function guess.
|
|
2445
|
-
const direct = exportIndex.defaultComponent ?? defaultExportBindingNode(filePath, exportIndex, context) ?? exportIndex.defaultFnClass;
|
|
2446
|
-
if (direct)
|
|
2447
|
-
return direct;
|
|
2448
|
-
// CommonJS: `module.exports = createApplication`, or `= require('./lib/express')`.
|
|
2449
|
-
const commonJs = commonJsDefaultExport(filePath, context);
|
|
2872
|
+
const stated = statedDefaultExport(filePath, exportIndex, context);
|
|
2873
|
+
if (stated === 'anonymous')
|
|
2874
|
+
return undefined;
|
|
2875
|
+
const commonJs = typeof stated === 'object' ? null : commonJsDefaultExport(filePath, context);
|
|
2450
2876
|
if (commonJs?.source) {
|
|
2451
2877
|
const next = resolveImportPath(commonJs.source, filePath, language, context);
|
|
2452
|
-
|
|
2453
|
-
|
|
2878
|
+
const forwarded = next ? findExportedSymbol(next, want, language, context, visited, depth + 1, members) : undefined;
|
|
2879
|
+
if (forwarded)
|
|
2880
|
+
return forwarded;
|
|
2454
2881
|
}
|
|
2455
2882
|
else if (commonJs?.name) {
|
|
2456
|
-
const bound = nodesInFileNamed(filePath, commonJs.name, context)
|
|
2883
|
+
const bound = moduleBindingsFirst(filePath, nodesInFileNamed(filePath, commonJs.name, context)
|
|
2457
2884
|
.filter((n) => DEFAULT_BINDING_KINDS.has(n.kind))
|
|
2458
|
-
.sort((a, b) => a.startLine - b.startLine || a.startColumn - b.startColumn)[0];
|
|
2885
|
+
.sort((a, b) => a.startLine - b.startLine || a.startColumn - b.startColumn))[0];
|
|
2459
2886
|
if (bound)
|
|
2460
2887
|
return bound;
|
|
2461
2888
|
}
|
|
2889
|
+
const direct = esmDefaultExport(filePath, exportIndex, context);
|
|
2890
|
+
if (direct)
|
|
2891
|
+
return direct;
|
|
2462
2892
|
}
|
|
2463
2893
|
else if (want.isNamespace && want.memberName) {
|
|
2464
2894
|
const direct = exportedByName(filePath, exportIndex, want.memberName, context);
|
|
2465
2895
|
if (direct)
|
|
2466
2896
|
return direct;
|
|
2897
|
+
const source = commonJsDefaultExport(filePath, context)?.source;
|
|
2898
|
+
const next = source ? resolveImportPath(source, filePath, language, context) : null;
|
|
2899
|
+
const forwarded = next ? findExportedSymbol(next, want, language, context, visited, depth + 1, members) : undefined;
|
|
2900
|
+
if (forwarded)
|
|
2901
|
+
return forwarded;
|
|
2467
2902
|
}
|
|
2468
2903
|
else {
|
|
2469
2904
|
const direct = exportedByName(filePath, exportIndex, want.exportedName, context);
|
|
2470
2905
|
if (direct)
|
|
2471
2906
|
return direct;
|
|
2907
|
+
if (depth === 0 &&
|
|
2908
|
+
want.exportedName === 'default' &&
|
|
2909
|
+
exports.ESM_IMPORT_LANGUAGES.has(language) &&
|
|
2910
|
+
hasEsmDefaultExport(filePath, exportIndex, context)) {
|
|
2911
|
+
const esmDefault = esmDefaultExport(filePath, exportIndex, context);
|
|
2912
|
+
if (esmDefault)
|
|
2913
|
+
return esmDefault;
|
|
2914
|
+
}
|
|
2472
2915
|
}
|
|
2473
|
-
// 2. Re-export hit: the file forwards the symbol to another module.
|
|
2474
2916
|
const reExports = context.getReExports?.(filePath, language) ?? [];
|
|
2475
2917
|
if (reExports.length === 0)
|
|
2476
|
-
return undefined;
|
|
2477
|
-
// Look for explicit `export { want } from './other'` (with optional rename) — for
|
|
2478
|
-
// `ns.member` through `import * as ns`, the member is the name wanted.
|
|
2918
|
+
return members === 'no' ? undefined : exportedMember(exportIndex, want);
|
|
2479
2919
|
const targetName = want.isDefault ? 'default' : want.isNamespace && want.memberName ? want.memberName : want.exportedName;
|
|
2480
2920
|
for (const rex of reExports) {
|
|
2481
2921
|
if (rex.kind === 'named' && rex.exportedName === targetName) {
|
|
2482
2922
|
const next = resolveImportPath(rex.source, filePath, language, context);
|
|
2483
2923
|
if (!next)
|
|
2484
2924
|
continue;
|
|
2485
|
-
// After rename: `export { foo as bar } from './x'` — to chase
|
|
2486
|
-
// `bar`, we look for `foo` in `./x`.
|
|
2487
2925
|
const chained = findExportedSymbol(next, {
|
|
2488
2926
|
isDefault: rex.originalName === 'default',
|
|
2489
2927
|
isNamespace: false,
|
|
2490
2928
|
exportedName: rex.originalName,
|
|
2491
2929
|
memberName: null,
|
|
2492
|
-
}, language, context, visited, depth + 1);
|
|
2930
|
+
}, language, context, visited, depth + 1, members);
|
|
2493
2931
|
if (chained)
|
|
2494
2932
|
return chained;
|
|
2495
2933
|
}
|
|
2496
2934
|
}
|
|
2497
|
-
// `z.core.util.fn` through `export * as core from './core'`: the member continues in that module.
|
|
2498
2935
|
if (want.isNamespace && want.memberName) {
|
|
2499
2936
|
const dot = want.memberName.indexOf('.');
|
|
2500
2937
|
const head = dot < 0 ? want.memberName : want.memberName.slice(0, dot);
|
|
@@ -2503,66 +2940,46 @@ function findExportedSymbolWalk(filePath, want, language, context, visited, dept
|
|
|
2503
2940
|
const next = resolveImportPath(rex.source, filePath, language, context);
|
|
2504
2941
|
const rest = want.memberName.slice(dot + 1);
|
|
2505
2942
|
return next
|
|
2506
|
-
? findExportedSymbol(next, { ...want, exportedName: rest.split('.')[0], memberName: rest }, language, context, visited, depth + 1)
|
|
2943
|
+
? findExportedSymbol(next, { ...want, exportedName: rest.split('.')[0], memberName: rest }, language, context, visited, depth + 1, members)
|
|
2507
2944
|
: undefined;
|
|
2508
2945
|
}
|
|
2509
2946
|
}
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2947
|
+
const wildcards = reExports.filter((rex) => rex.kind === 'wildcard');
|
|
2948
|
+
const passes = members === 'after' && wildcards.length > 0 ? ['no', 'yes'] : [members];
|
|
2949
|
+
const before = passes.length > 1 ? new Set(visited) : visited;
|
|
2950
|
+
for (const [i, pass] of passes.entries()) {
|
|
2951
|
+
const seen = i > 0 ? new Set(before) : visited;
|
|
2952
|
+
for (const rex of wildcards) {
|
|
2514
2953
|
const next = resolveImportPath(rex.source, filePath, language, context);
|
|
2515
2954
|
if (!next)
|
|
2516
2955
|
continue;
|
|
2517
|
-
|
|
2956
|
+
if (PYTHON_MODULE_FILE.test(next) && !want.isDefault && !pythonStarAllows(next, want.exportedName, context))
|
|
2957
|
+
continue;
|
|
2958
|
+
const chained = findExportedSymbol(next, want, language, context, seen, depth + 1, pass);
|
|
2518
2959
|
if (chained)
|
|
2519
2960
|
return chained;
|
|
2520
2961
|
}
|
|
2521
2962
|
}
|
|
2522
|
-
return undefined;
|
|
2963
|
+
return members === 'no' ? undefined : exportedMember(exportIndex, want);
|
|
2964
|
+
}
|
|
2965
|
+
function exportedMember(idx, want) {
|
|
2966
|
+
const name = want.isDefault ? null : want.isNamespace ? want.memberName : want.exportedName;
|
|
2967
|
+
return name ? idx.members.get(name) : undefined;
|
|
2523
2968
|
}
|
|
2524
|
-
/** Node kinds that own static members reachable as `Container.member`. */
|
|
2525
2969
|
const STATIC_MEMBER_CONTAINERS = new Set([
|
|
2526
2970
|
'class', 'struct', 'union', 'interface', 'enum', 'trait', 'protocol',
|
|
2527
2971
|
]);
|
|
2528
|
-
/**
|
|
2529
|
-
* Resolve `Container.member` — a static method/property access on a NAMED class
|
|
2530
|
-
* import (`import { Foo } …; Foo.bar()`) — to the member node, given the
|
|
2531
|
-
* already-resolved container class.
|
|
2532
|
-
*
|
|
2533
|
-
* Members carry a `Container::member` qualifiedName, so we look up
|
|
2534
|
-
* `${container.qualifiedName}::${member}` within the container's own file (the
|
|
2535
|
-
* file filter disambiguates same-named classes in other modules). Returns
|
|
2536
|
-
* undefined when the container isn't a member-owning kind or the member isn't
|
|
2537
|
-
* found, so the caller falls back to the container itself (prior behavior) —
|
|
2538
|
-
* languages whose members aren't `::`-qualified, and genuine class references,
|
|
2539
|
-
* are unaffected. See #825.
|
|
2540
|
-
*/
|
|
2541
|
-
/**
|
|
2542
|
-
* Resolve a CALL through an imported value to the method on the value's own
|
|
2543
|
-
* type: `reproStore.notifyJoinGuildStatus()` where `reproStore` is
|
|
2544
|
-
* `export const reproStore = new ReproStore()` in the imported file (#1292).
|
|
2545
|
-
* The same-file form of this call already resolves via local-variable
|
|
2546
|
-
* receiver inference (#1108); this is the cross-file/import half. The type is
|
|
2547
|
-
* recovered from the VALUE'S OWN declaration lines in the exporting file
|
|
2548
|
-
* (initializer `= new T(...)` or a type annotation, per the shared #1108
|
|
2549
|
-
* pattern table), then the member is resolved AND VALIDATED on that type by
|
|
2550
|
-
* resolveMethodOnType — a failed inference or validation returns null so the
|
|
2551
|
-
* caller keeps its existing constant-edge behavior.
|
|
2552
|
-
*/
|
|
2553
2972
|
function resolveImportedInstanceMember(value, ref, localName, context) {
|
|
2554
2973
|
if (ref.referenceKind !== 'calls')
|
|
2555
2974
|
return null;
|
|
2556
2975
|
if (value.kind !== 'constant' && value.kind !== 'variable')
|
|
2557
2976
|
return null;
|
|
2558
|
-
const member = ref.referenceName.slice(localName.length + 1)
|
|
2559
|
-
if (!member)
|
|
2977
|
+
const member = ref.referenceName.slice(localName.length + 1);
|
|
2978
|
+
if (!member || member.includes('.'))
|
|
2560
2979
|
return null;
|
|
2561
2980
|
const source = context.readFile(value.filePath);
|
|
2562
2981
|
if (!source)
|
|
2563
2982
|
return null;
|
|
2564
|
-
// Only the value's own declaration lines — never the whole file, so a
|
|
2565
|
-
// same-named identifier elsewhere can't donate a type.
|
|
2566
2983
|
const lines = source.split('\n');
|
|
2567
2984
|
const declSlice = lines.slice(Math.max(0, value.startLine - 1), value.endLine).join('\n');
|
|
2568
2985
|
const receiver = value.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
@@ -2573,26 +2990,31 @@ function resolveImportedInstanceMember(value, ref, localName, context) {
|
|
|
2573
2990
|
const typeName = (0, name_matcher_1.normalizeInferredTypeName)(m[1]);
|
|
2574
2991
|
if (!typeName)
|
|
2575
2992
|
continue;
|
|
2576
|
-
const
|
|
2993
|
+
const declaring = exports.ESM_IMPORT_LANGUAGES.has(value.language)
|
|
2994
|
+
? (0, name_matcher_1.tsImportedTypeFile)(m[1], { ...ref, filePath: value.filePath, language: value.language }, context) ?? value.filePath
|
|
2995
|
+
: undefined;
|
|
2996
|
+
const resolved = (0, name_matcher_1.resolveMethodOnType)(typeName, member, ref, context, 0.85, 'instance-method', declaring);
|
|
2577
2997
|
if (resolved)
|
|
2578
2998
|
return resolved;
|
|
2579
2999
|
}
|
|
2580
3000
|
return null;
|
|
2581
3001
|
}
|
|
2582
3002
|
function resolveStaticMember(container, ref, localName, context) {
|
|
2583
|
-
|
|
3003
|
+
const constructorFn = container.kind === 'function' && JS_FAMILY_FILE.test(container.filePath);
|
|
3004
|
+
if (!STATIC_MEMBER_CONTAINERS.has(container.kind) && !constructorFn)
|
|
2584
3005
|
return undefined;
|
|
2585
|
-
|
|
2586
|
-
const member = ref.referenceName.slice(localName.length + 1).split('.')[0];
|
|
3006
|
+
const [member, ...rest] = ref.referenceName.slice(localName.length + 1).split('.');
|
|
2587
3007
|
if (!member)
|
|
2588
3008
|
return undefined;
|
|
2589
3009
|
const candidates = context
|
|
2590
3010
|
.getNodesByQualifiedName(`${container.qualifiedName}::${member}`)
|
|
2591
|
-
.filter((n) => n.filePath === container.filePath);
|
|
3011
|
+
.filter((n) => n.filePath === container.filePath && (!constructorFn || (n.kind === 'method' && n.isStatic === true)));
|
|
2592
3012
|
if (candidates.length === 0)
|
|
2593
3013
|
return undefined;
|
|
2594
|
-
|
|
2595
|
-
|
|
3014
|
+
if (ref.language === 'python' && rest.length > 0) {
|
|
3015
|
+
const next = candidates.find((n) => STATIC_MEMBER_CONTAINERS.has(n.kind));
|
|
3016
|
+
return next && resolveStaticMember(next, { ...ref, referenceName: `${member}.${rest.join('.')}` }, member, context);
|
|
3017
|
+
}
|
|
2596
3018
|
if (ref.referenceKind === 'calls') {
|
|
2597
3019
|
const callable = candidates.find((n) => n.kind === 'method' || n.kind === 'function');
|
|
2598
3020
|
if (callable)
|
|
@@ -2600,132 +3022,139 @@ function resolveStaticMember(container, ref, localName, context) {
|
|
|
2600
3022
|
}
|
|
2601
3023
|
return candidates[0];
|
|
2602
3024
|
}
|
|
2603
|
-
|
|
2604
|
-
* Rust `use` declarations, flattened to `localName → full path`.
|
|
2605
|
-
*
|
|
2606
|
-
* Rust is the one supported language with NO `ImportMapping` extraction (see
|
|
2607
|
-
* `extractImportMappings`), so this is the only channel that can tell whether
|
|
2608
|
-
* a bare type name in a Rust file was brought in by a `use`. Handles nested
|
|
2609
|
-
* groups (`use a::{b::C, d as E}`), globs (skipped — they bind no single
|
|
2610
|
-
* name), and `as` aliases.
|
|
2611
|
-
*/
|
|
2612
|
-
function collectRustUseBindings(content) {
|
|
2613
|
-
const out = new Map();
|
|
2614
|
-
// Expand one level of `{...}` at a time so `a::{b::{C, D}, E}` flattens.
|
|
2615
|
-
const expand = (spec) => {
|
|
2616
|
-
const open = spec.indexOf('{');
|
|
2617
|
-
if (open === -1)
|
|
2618
|
-
return [spec.trim()];
|
|
2619
|
-
const prefix = spec.slice(0, open);
|
|
2620
|
-
let depth = 0;
|
|
2621
|
-
let close = -1;
|
|
2622
|
-
for (let i = open; i < spec.length; i++) {
|
|
2623
|
-
if (spec[i] === '{')
|
|
2624
|
-
depth++;
|
|
2625
|
-
else if (spec[i] === '}') {
|
|
2626
|
-
depth--;
|
|
2627
|
-
if (depth === 0) {
|
|
2628
|
-
close = i;
|
|
2629
|
-
break;
|
|
2630
|
-
}
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
if (close === -1)
|
|
2634
|
-
return [];
|
|
2635
|
-
const suffix = spec.slice(close + 1);
|
|
2636
|
-
const inner = spec.slice(open + 1, close);
|
|
2637
|
-
const parts = [];
|
|
2638
|
-
let depth2 = 0;
|
|
2639
|
-
let start = 0;
|
|
2640
|
-
for (let i = 0; i <= inner.length; i++) {
|
|
2641
|
-
const ch = inner[i];
|
|
2642
|
-
if (ch === '{')
|
|
2643
|
-
depth2++;
|
|
2644
|
-
else if (ch === '}')
|
|
2645
|
-
depth2--;
|
|
2646
|
-
if (i === inner.length || (ch === ',' && depth2 === 0)) {
|
|
2647
|
-
const seg = inner.slice(start, i).trim();
|
|
2648
|
-
if (seg)
|
|
2649
|
-
parts.push(seg);
|
|
2650
|
-
start = i + 1;
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
return parts.flatMap((p) => expand(prefix + p + suffix));
|
|
2654
|
-
};
|
|
2655
|
-
// `use` items end at the first `;`. Attributes/visibility (`pub use`) are
|
|
2656
|
-
// irrelevant to the binding itself.
|
|
2657
|
-
const useRe = /(^|\n)\s*(?:pub(?:\([^)]*\))?\s+)?use\s+([^;]+);/g;
|
|
2658
|
-
let m;
|
|
2659
|
-
while ((m = useRe.exec(content)) !== null) {
|
|
2660
|
-
for (const spec of expand(m[2].replace(/\s+/g, ' '))) {
|
|
2661
|
-
const aliasMatch = /^(.*?)\s+as\s+([A-Za-z_]\w*)$/.exec(spec);
|
|
2662
|
-
const rawPath = (aliasMatch ? aliasMatch[1] : spec).trim();
|
|
2663
|
-
if (!rawPath || rawPath.endsWith('*'))
|
|
2664
|
-
continue;
|
|
2665
|
-
const segments = rawPath.split('::').map((s) => s.trim()).filter(Boolean);
|
|
2666
|
-
const leaf = segments[segments.length - 1];
|
|
2667
|
-
if (!leaf)
|
|
2668
|
-
continue;
|
|
2669
|
-
const local = aliasMatch ? aliasMatch[2] : leaf;
|
|
2670
|
-
out.set(local, segments.join('::'));
|
|
2671
|
-
}
|
|
2672
|
-
}
|
|
2673
|
-
return out;
|
|
2674
|
-
}
|
|
2675
|
-
/**
|
|
2676
|
-
* Is `name`, as used in `ref`'s file, bound by an import whose module lives
|
|
2677
|
-
* OUTSIDE the repository?
|
|
2678
|
-
*
|
|
2679
|
-
* When it is, no in-repo node can be the referent: the symbol is defined in a
|
|
2680
|
-
* third-party crate/package, and any same-named local symbol the name-matcher
|
|
2681
|
-
* finds is a coincidence. Rust `use std::error::Error;` + `impl Error for
|
|
2682
|
-
* MapperError {}` bound to a local `MapperError::Error` variant, and once
|
|
2683
|
-
* non-type kinds were filtered out it simply moved to an unrelated local
|
|
2684
|
-
* `type Error` alias — restricting kinds alone RELOCATES the false edge
|
|
2685
|
-
* instead of removing it, so locality has to be checked too.
|
|
2686
|
-
*
|
|
2687
|
-
* Answers only when it can be CERTAIN, because a false "yes" deletes a real
|
|
2688
|
-
* edge. Two languages qualify, each with an oracle that cannot be wrong:
|
|
2689
|
-
*
|
|
2690
|
-
* - **Rust** — the `use` path is rooted at a standard-library crate
|
|
2691
|
-
* (`std`/`core`/`alloc`/`proc_macro`), which by definition ships outside
|
|
2692
|
-
* any repository. Deliberately NOT generalized to "the module path doesn't
|
|
2693
|
-
* resolve to a file": a crate can re-export another workspace crate's
|
|
2694
|
-
* modules (`pub use pupil_core::{ports, domain};`), so `crate::ports::X`
|
|
2695
|
-
* has no `src/ports/` directory to walk yet is entirely in-repo — that
|
|
2696
|
-
* generalization measured 13 real trait implementations deleted.
|
|
2697
|
-
* - **ES modules** — `isExternalImport`, which already accounts for tsconfig
|
|
2698
|
-
* path aliases and monorepo workspace packages.
|
|
2699
|
-
*
|
|
2700
|
-
* Everything else returns false and resolves exactly as before. JVM and Python
|
|
2701
|
-
* imports notably do NOT go through `resolveImportPath` (they have dedicated
|
|
2702
|
-
* FQN/module matchers), so there is no trustworthy oracle to consult here.
|
|
2703
|
-
*/
|
|
2704
|
-
function isBoundToOutOfRepoImport(ref, context) {
|
|
3025
|
+
function isBoundToOutOfRepoImport(ref, context, target) {
|
|
2705
3026
|
const name = ref.referenceName;
|
|
2706
3027
|
if (name.includes('::') || name.includes('.'))
|
|
2707
|
-
return false;
|
|
2708
|
-
if (ref.language === 'rust')
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
if (!usePath)
|
|
2714
|
-
return false;
|
|
2715
|
-
const segments = usePath.split('::');
|
|
2716
|
-
if (segments.length < 2 || !RUST_STDLIB_ROOTS.has(segments[0]))
|
|
2717
|
-
return false;
|
|
2718
|
-
// 2015-edition crate-relative paths can shadow a stdlib root with a local
|
|
2719
|
-
// module of the same name — if the path walks to a real file, it's local.
|
|
2720
|
-
return resolveRustModuleFile(segments.slice(0, -1), ref.filePath, context) === null;
|
|
2721
|
-
}
|
|
2722
|
-
if (!ESM_IMPORT_LANGUAGES.has(ref.language))
|
|
3028
|
+
return false;
|
|
3029
|
+
if (ref.language === 'rust')
|
|
3030
|
+
return (0, name_matcher_1.isRustNameFromStd)(ref, context);
|
|
3031
|
+
if (ref.language === 'python')
|
|
3032
|
+
return (0, name_matcher_1.isPythonNameFromOutside)(name, ref.filePath, target, context);
|
|
3033
|
+
if (!exports.ESM_IMPORT_LANGUAGES.has(ref.language))
|
|
2723
3034
|
return false;
|
|
2724
3035
|
for (const imp of context.getImportMappings(ref.filePath, ref.language)) {
|
|
2725
3036
|
if (imp.localName !== name)
|
|
2726
3037
|
continue;
|
|
2727
|
-
return isExternalImport(imp.source, ref.language, context)
|
|
3038
|
+
return isExternalImport(imp.source, ref.language, context, { fromFile: ref.filePath }) &&
|
|
3039
|
+
resolveImportPath(imp.source, ref.filePath, ref.language, context) === null &&
|
|
3040
|
+
!(0, ambient_modules_1.ambientModuleDeclares)(imp.source, imp.exportedName, imp.isDefault, ref, context);
|
|
2728
3041
|
}
|
|
2729
3042
|
return false;
|
|
2730
3043
|
}
|
|
3044
|
+
function importBindingTail(ref, context, readContext = context) {
|
|
3045
|
+
if (ref.language === 'python')
|
|
3046
|
+
return pythonImportBindingTail(ref, context);
|
|
3047
|
+
if (!exports.ESM_IMPORT_LANGUAGES.has(ref.language))
|
|
3048
|
+
return undefined;
|
|
3049
|
+
const receiver = ref.referenceKind === 'imports' ? undefined : MEMBER_RECEIVER.exec(ref.referenceName)?.[1];
|
|
3050
|
+
const name = receiver ?? ref.referenceName;
|
|
3051
|
+
if (!receiver && !IDENTIFIER.test(name))
|
|
3052
|
+
return undefined;
|
|
3053
|
+
const mappings = context.getImportMappings(ref.filePath, ref.language);
|
|
3054
|
+
let binding = mappings.find((m) => m.localName === name);
|
|
3055
|
+
if (!binding && receiver && ref.referenceKind === 'calls') {
|
|
3056
|
+
const typeFile = (0, name_matcher_1.jsReceiverTypeFile)(receiver, ref, readContext);
|
|
3057
|
+
if (typeFile)
|
|
3058
|
+
return (0, reference_tail_1.moduleTail)(typeFile) || undefined;
|
|
3059
|
+
binding = localTypeBinding(receiver, ref, context, mappings);
|
|
3060
|
+
}
|
|
3061
|
+
if (!binding)
|
|
3062
|
+
return undefined;
|
|
3063
|
+
if (isExternalImport(binding.source, ref.language, context, { fromFile: ref.filePath }) &&
|
|
3064
|
+
!context.getNearestAliases?.(ref.filePath)?.patterns.some((p) => p.prefix !== '' && binding.source.startsWith(p.prefix)) &&
|
|
3065
|
+
!namesOwnConfigModule(binding.source, ref.filePath, ref.language, context)) {
|
|
3066
|
+
return undefined;
|
|
3067
|
+
}
|
|
3068
|
+
const modulePath = binding.source.startsWith('.')
|
|
3069
|
+
? path.posix.join(path.posix.dirname(ref.filePath), binding.source)
|
|
3070
|
+
: binding.source;
|
|
3071
|
+
const tail = (0, reference_tail_1.moduleTail)(modulePath);
|
|
3072
|
+
if (!tail)
|
|
3073
|
+
return undefined;
|
|
3074
|
+
if (!receiver && !binding.isDefault && !binding.isNamespace && binding.exportedName === binding.localName) {
|
|
3075
|
+
const moduleFile = resolveImportPath(binding.source, ref.filePath, ref.language, context);
|
|
3076
|
+
if (!moduleFile || !(context.isIndexedFile?.(moduleFile) ?? true) || !(0, reference_tail_1.moduleReferenceKeys)(moduleFile).includes(tail))
|
|
3077
|
+
return undefined;
|
|
3078
|
+
const want = { isDefault: false, isNamespace: false, exportedName: binding.exportedName, memberName: null };
|
|
3079
|
+
if (findExportedSymbol(moduleFile, want, ref.language, context, new Set()))
|
|
3080
|
+
return undefined;
|
|
3081
|
+
}
|
|
3082
|
+
return tail;
|
|
3083
|
+
}
|
|
3084
|
+
function pythonImportBindingTail(ref, context) {
|
|
3085
|
+
if (!IDENTIFIER.test(ref.referenceName))
|
|
3086
|
+
return undefined;
|
|
3087
|
+
const binding = context.getImportMappings(ref.filePath, 'python').find((m) => m.localName === ref.referenceName);
|
|
3088
|
+
if (!binding || isExternalImport(binding.source, 'python', context))
|
|
3089
|
+
return undefined;
|
|
3090
|
+
const declared = binding.isNamespace ? binding.source.slice(binding.source.lastIndexOf('.') + 1) : binding.exportedName;
|
|
3091
|
+
if (declared === binding.localName && (binding.isNamespace || !isProjectPythonModule(binding.source, context)))
|
|
3092
|
+
return undefined;
|
|
3093
|
+
const modulePath = pythonModulePath(binding.source, ref.filePath);
|
|
3094
|
+
return modulePath ? (0, reference_tail_1.moduleTail)(modulePath) || undefined : undefined;
|
|
3095
|
+
}
|
|
3096
|
+
function isProjectPythonModule(source, context) {
|
|
3097
|
+
if (source.startsWith('.'))
|
|
3098
|
+
return true;
|
|
3099
|
+
const folders = projectFolderSuffixes(context);
|
|
3100
|
+
const modulePath = source.replace(/\./g, '/');
|
|
3101
|
+
const slash = modulePath.lastIndexOf('/');
|
|
3102
|
+
return folders.has(modulePath) || (slash > 0 && folders.has(modulePath.slice(0, slash)));
|
|
3103
|
+
}
|
|
3104
|
+
const PROJECT_FOLDER_SUFFIXES = new WeakMap();
|
|
3105
|
+
function projectFolderSuffixes(context) {
|
|
3106
|
+
let suffixes = PROJECT_FOLDER_SUFFIXES.get(context);
|
|
3107
|
+
if (suffixes)
|
|
3108
|
+
return suffixes;
|
|
3109
|
+
const folders = new Set();
|
|
3110
|
+
for (const file of context.getAllFiles()) {
|
|
3111
|
+
for (let i = file.lastIndexOf('/'); i > 0; i = file.lastIndexOf('/', i - 1)) {
|
|
3112
|
+
const folder = file.slice(0, i);
|
|
3113
|
+
if (folders.has(folder))
|
|
3114
|
+
break;
|
|
3115
|
+
folders.add(folder);
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
suffixes = new Set();
|
|
3119
|
+
for (const folder of folders) {
|
|
3120
|
+
for (let i = -1;; i = folder.indexOf('/', i + 1)) {
|
|
3121
|
+
suffixes.add(folder.slice(i + 1));
|
|
3122
|
+
if (folder.indexOf('/', i + 1) === -1)
|
|
3123
|
+
break;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
PROJECT_FOLDER_SUFFIXES.set(context, suffixes);
|
|
3127
|
+
return suffixes;
|
|
3128
|
+
}
|
|
3129
|
+
function pythonModulePath(source, fromFile) {
|
|
3130
|
+
const name = source.replace(/^\.+/, '');
|
|
3131
|
+
const dots = source.length - name.length;
|
|
3132
|
+
if (dots === 0)
|
|
3133
|
+
return name.replace(/\./g, '/');
|
|
3134
|
+
const modulePath = path.posix.join(path.posix.dirname(fromFile), '../'.repeat(dots - 1), name.replace(/\./g, '/'));
|
|
3135
|
+
return modulePath === '..' || modulePath.startsWith('../') ? null : modulePath;
|
|
3136
|
+
}
|
|
3137
|
+
function localTypeBinding(receiver, ref, context, mappings) {
|
|
3138
|
+
if (mappings.length === 0)
|
|
3139
|
+
return undefined;
|
|
3140
|
+
const decl = {};
|
|
3141
|
+
const type = (0, name_matcher_1.inferLocalReceiverType)(receiver, ref, context, decl);
|
|
3142
|
+
if (!type || !decl.raw)
|
|
3143
|
+
return undefined;
|
|
3144
|
+
if ((0, name_matcher_1.arrayElementType)(type) !== undefined && js_builtins_1.JS_ARRAY_METHODS.has(ref.referenceName.slice(receiver.length + 1)))
|
|
3145
|
+
return undefined;
|
|
3146
|
+
const head = decl.raw.split(/[.<[\s]/)[0];
|
|
3147
|
+
return mappings.find((m) => m.localName === head);
|
|
3148
|
+
}
|
|
3149
|
+
function moduleDefaultExport(filePath, language, context) {
|
|
3150
|
+
return findExportedSymbol(filePath, { isDefault: true, isNamespace: false, exportedName: 'default', memberName: null }, language, context, new Set());
|
|
3151
|
+
}
|
|
3152
|
+
function isJsFamilyFile(filePath) {
|
|
3153
|
+
return JS_FAMILY_FILE.test(filePath);
|
|
3154
|
+
}
|
|
3155
|
+
function isModuleBindingName(name) {
|
|
3156
|
+
return IDENTIFIER.test(name);
|
|
3157
|
+
}
|
|
3158
|
+
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
3159
|
+
const MEMBER_RECEIVER = /^([A-Za-z_$][\w$]*)\.[A-Za-z_$][\w$]*$/;
|
|
2731
3160
|
//# sourceMappingURL=import-resolver.js.map
|