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