@colbymchenry/codegraph-win32-arm64 1.6.1 → 1.6.3

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