@colbymchenry/codegraph-win32-arm64 1.6.0 → 1.6.1

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 (622) hide show
  1. package/bin/codegraph +5 -0
  2. package/lib/dist/.test-build-engine.json +1 -0
  3. package/lib/dist/.test-build-viewer.json +1 -0
  4. package/lib/dist/bin/codegraph.d.ts +1 -0
  5. package/lib/dist/bin/codegraph.d.ts.map +1 -1
  6. package/lib/dist/bin/codegraph.js +599 -291
  7. package/lib/dist/bin/codegraph.js.map +1 -1
  8. package/lib/dist/bin/viewer-gate.d.ts +17 -0
  9. package/lib/dist/bin/viewer-gate.d.ts.map +1 -0
  10. package/lib/dist/bin/viewer-gate.js +31 -0
  11. package/lib/dist/bin/viewer-gate.js.map +1 -0
  12. package/lib/dist/context/index.d.ts.map +1 -1
  13. package/lib/dist/context/index.js +43 -2
  14. package/lib/dist/context/index.js.map +1 -1
  15. package/lib/dist/db/index.d.ts +21 -2
  16. package/lib/dist/db/index.d.ts.map +1 -1
  17. package/lib/dist/db/index.js +86 -31
  18. package/lib/dist/db/index.js.map +1 -1
  19. package/lib/dist/db/migrations.d.ts +1 -1
  20. package/lib/dist/db/migrations.d.ts.map +1 -1
  21. package/lib/dist/db/migrations.js +40 -1
  22. package/lib/dist/db/migrations.js.map +1 -1
  23. package/lib/dist/db/queries.d.ts +423 -3
  24. package/lib/dist/db/queries.d.ts.map +1 -1
  25. package/lib/dist/db/queries.js +1026 -33
  26. package/lib/dist/db/queries.js.map +1 -1
  27. package/lib/dist/db/schema.sql +11 -1
  28. package/lib/dist/db/sqlite-adapter.d.ts +2 -0
  29. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
  30. package/lib/dist/db/sqlite-adapter.js +56 -7
  31. package/lib/dist/db/sqlite-adapter.js.map +1 -1
  32. package/lib/dist/db/synthesis-stage.d.ts +12 -0
  33. package/lib/dist/db/synthesis-stage.d.ts.map +1 -0
  34. package/lib/dist/db/synthesis-stage.js +89 -0
  35. package/lib/dist/db/synthesis-stage.js.map +1 -0
  36. package/lib/dist/db/wal-valve.d.ts +32 -12
  37. package/lib/dist/db/wal-valve.d.ts.map +1 -1
  38. package/lib/dist/db/wal-valve.js +65 -22
  39. package/lib/dist/db/wal-valve.js.map +1 -1
  40. package/lib/dist/db/wsl-shared-index.d.ts +53 -0
  41. package/lib/dist/db/wsl-shared-index.d.ts.map +1 -0
  42. package/lib/dist/db/wsl-shared-index.js +121 -0
  43. package/lib/dist/db/wsl-shared-index.js.map +1 -0
  44. package/lib/dist/directory.d.ts +101 -2
  45. package/lib/dist/directory.d.ts.map +1 -1
  46. package/lib/dist/directory.js +254 -23
  47. package/lib/dist/directory.js.map +1 -1
  48. package/lib/dist/errors.d.ts +14 -0
  49. package/lib/dist/errors.d.ts.map +1 -1
  50. package/lib/dist/errors.js +16 -1
  51. package/lib/dist/errors.js.map +1 -1
  52. package/lib/dist/extraction/cfml-extractor.d.ts +1 -0
  53. package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
  54. package/lib/dist/extraction/cfml-extractor.js +15 -3
  55. package/lib/dist/extraction/cfml-extractor.js.map +1 -1
  56. package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -1
  57. package/lib/dist/extraction/dfm-extractor.js +14 -10
  58. package/lib/dist/extraction/dfm-extractor.js.map +1 -1
  59. package/lib/dist/extraction/extraction-version.d.ts +1 -1
  60. package/lib/dist/extraction/extraction-version.js +1 -1
  61. package/lib/dist/extraction/function-ref.d.ts +6 -4
  62. package/lib/dist/extraction/function-ref.d.ts.map +1 -1
  63. package/lib/dist/extraction/function-ref.js +35 -14
  64. package/lib/dist/extraction/function-ref.js.map +1 -1
  65. package/lib/dist/extraction/grammars.d.ts +38 -0
  66. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  67. package/lib/dist/extraction/grammars.js +77 -1
  68. package/lib/dist/extraction/grammars.js.map +1 -1
  69. package/lib/dist/extraction/index.d.ts +113 -15
  70. package/lib/dist/extraction/index.d.ts.map +1 -1
  71. package/lib/dist/extraction/index.js +599 -132
  72. package/lib/dist/extraction/index.js.map +1 -1
  73. package/lib/dist/extraction/languages/c-cpp.d.ts +58 -0
  74. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  75. package/lib/dist/extraction/languages/c-cpp.js +291 -15
  76. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  77. package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
  78. package/lib/dist/extraction/languages/dart.js +8 -3
  79. package/lib/dist/extraction/languages/dart.js.map +1 -1
  80. package/lib/dist/extraction/languages/javascript.js +1 -1
  81. package/lib/dist/extraction/languages/javascript.js.map +1 -1
  82. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
  83. package/lib/dist/extraction/languages/kotlin.js +169 -36
  84. package/lib/dist/extraction/languages/kotlin.js.map +1 -1
  85. package/lib/dist/extraction/languages/lua.d.ts.map +1 -1
  86. package/lib/dist/extraction/languages/lua.js +4 -1
  87. package/lib/dist/extraction/languages/lua.js.map +1 -1
  88. package/lib/dist/extraction/languages/python.d.ts.map +1 -1
  89. package/lib/dist/extraction/languages/python.js +71 -0
  90. package/lib/dist/extraction/languages/python.js.map +1 -1
  91. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  92. package/lib/dist/extraction/languages/rust.js +3 -0
  93. package/lib/dist/extraction/languages/rust.js.map +1 -1
  94. package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
  95. package/lib/dist/extraction/languages/scala.js +18 -3
  96. package/lib/dist/extraction/languages/scala.js.map +1 -1
  97. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
  98. package/lib/dist/extraction/languages/typescript.js +9 -2
  99. package/lib/dist/extraction/languages/typescript.js.map +1 -1
  100. package/lib/dist/extraction/liquid-extractor.d.ts +18 -0
  101. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
  102. package/lib/dist/extraction/liquid-extractor.js +98 -22
  103. package/lib/dist/extraction/liquid-extractor.js.map +1 -1
  104. package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -1
  105. package/lib/dist/extraction/mybatis-extractor.js +6 -4
  106. package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
  107. package/lib/dist/extraction/syntax-tokens.d.ts +103 -0
  108. package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -0
  109. package/lib/dist/extraction/syntax-tokens.js +381 -0
  110. package/lib/dist/extraction/syntax-tokens.js.map +1 -0
  111. package/lib/dist/extraction/tree-sitter-helpers.d.ts +5 -0
  112. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  113. package/lib/dist/extraction/tree-sitter-helpers.js +17 -0
  114. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
  115. package/lib/dist/extraction/tree-sitter-types.d.ts +29 -3
  116. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  117. package/lib/dist/extraction/tree-sitter.d.ts +96 -17
  118. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  119. package/lib/dist/extraction/tree-sitter.js +820 -82
  120. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  121. package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  122. package/lib/dist/file-limits.d.ts +40 -0
  123. package/lib/dist/file-limits.d.ts.map +1 -0
  124. package/lib/dist/file-limits.js +147 -0
  125. package/lib/dist/file-limits.js.map +1 -0
  126. package/lib/dist/graph/branch-guards.d.ts +248 -0
  127. package/lib/dist/graph/branch-guards.d.ts.map +1 -0
  128. package/lib/dist/graph/branch-guards.js +2231 -0
  129. package/lib/dist/graph/branch-guards.js.map +1 -0
  130. package/lib/dist/graph/dead-code.d.ts +251 -0
  131. package/lib/dist/graph/dead-code.d.ts.map +1 -0
  132. package/lib/dist/graph/dead-code.js +776 -0
  133. package/lib/dist/graph/dead-code.js.map +1 -0
  134. package/lib/dist/graph/dynamic-boundary-report.d.ts +121 -0
  135. package/lib/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
  136. package/lib/dist/graph/dynamic-boundary-report.js +283 -0
  137. package/lib/dist/graph/dynamic-boundary-report.js.map +1 -0
  138. package/lib/dist/graph/index.d.ts +4 -0
  139. package/lib/dist/graph/index.d.ts.map +1 -1
  140. package/lib/dist/graph/index.js +16 -1
  141. package/lib/dist/graph/index.js.map +1 -1
  142. package/lib/dist/graph/named-symbol-flow.d.ts +125 -0
  143. package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -0
  144. package/lib/dist/graph/named-symbol-flow.js +552 -0
  145. package/lib/dist/graph/named-symbol-flow.js.map +1 -0
  146. package/lib/dist/graph/symbol-lookup.d.ts +83 -0
  147. package/lib/dist/graph/symbol-lookup.d.ts.map +1 -0
  148. package/lib/dist/graph/symbol-lookup.js +181 -0
  149. package/lib/dist/graph/symbol-lookup.js.map +1 -0
  150. package/lib/dist/graph/traversal.d.ts +9 -0
  151. package/lib/dist/graph/traversal.d.ts.map +1 -1
  152. package/lib/dist/graph/traversal.js +61 -35
  153. package/lib/dist/graph/traversal.js.map +1 -1
  154. package/lib/dist/graph/type-hierarchy.d.ts +155 -0
  155. package/lib/dist/graph/type-hierarchy.d.ts.map +1 -0
  156. package/lib/dist/graph/type-hierarchy.js +382 -0
  157. package/lib/dist/graph/type-hierarchy.js.map +1 -0
  158. package/lib/dist/index.d.ts +251 -11
  159. package/lib/dist/index.d.ts.map +1 -1
  160. package/lib/dist/index.js +395 -34
  161. package/lib/dist/index.js.map +1 -1
  162. package/lib/dist/installer/index.d.ts.map +1 -1
  163. package/lib/dist/installer/index.js +3 -2
  164. package/lib/dist/installer/index.js.map +1 -1
  165. package/lib/dist/installer/targets/antigravity.d.ts.map +1 -1
  166. package/lib/dist/installer/targets/antigravity.js +14 -2
  167. package/lib/dist/installer/targets/antigravity.js.map +1 -1
  168. package/lib/dist/installer/targets/claude.d.ts +3 -0
  169. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  170. package/lib/dist/installer/targets/claude.js +35 -7
  171. package/lib/dist/installer/targets/claude.js.map +1 -1
  172. package/lib/dist/installer/targets/codex.d.ts +2 -1
  173. package/lib/dist/installer/targets/codex.d.ts.map +1 -1
  174. package/lib/dist/installer/targets/codex.js +14 -4
  175. package/lib/dist/installer/targets/codex.js.map +1 -1
  176. package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -1
  177. package/lib/dist/installer/targets/copilot-cli.js +7 -1
  178. package/lib/dist/installer/targets/copilot-cli.js.map +1 -1
  179. package/lib/dist/installer/targets/opencode.d.ts +16 -5
  180. package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
  181. package/lib/dist/installer/targets/opencode.js +73 -22
  182. package/lib/dist/installer/targets/opencode.js.map +1 -1
  183. package/lib/dist/installer/targets/shared.d.ts +14 -3
  184. package/lib/dist/installer/targets/shared.d.ts.map +1 -1
  185. package/lib/dist/installer/targets/shared.js +39 -11
  186. package/lib/dist/installer/targets/shared.js.map +1 -1
  187. package/lib/dist/installer/targets/types.d.ts +7 -0
  188. package/lib/dist/installer/targets/types.d.ts.map +1 -1
  189. package/lib/dist/mcp/answer-freshness.d.ts +10 -0
  190. package/lib/dist/mcp/answer-freshness.d.ts.map +1 -0
  191. package/lib/dist/mcp/answer-freshness.js +68 -0
  192. package/lib/dist/mcp/answer-freshness.js.map +1 -0
  193. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -1
  194. package/lib/dist/mcp/daemon-manager.js +16 -0
  195. package/lib/dist/mcp/daemon-manager.js.map +1 -1
  196. package/lib/dist/mcp/daemon-paths.d.ts +2 -0
  197. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
  198. package/lib/dist/mcp/daemon-paths.js +12 -3
  199. package/lib/dist/mcp/daemon-paths.js.map +1 -1
  200. package/lib/dist/mcp/daemon-registry.d.ts +7 -4
  201. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
  202. package/lib/dist/mcp/daemon-registry.js +91 -29
  203. package/lib/dist/mcp/daemon-registry.js.map +1 -1
  204. package/lib/dist/mcp/daemon.d.ts +17 -7
  205. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  206. package/lib/dist/mcp/daemon.js +116 -24
  207. package/lib/dist/mcp/daemon.js.map +1 -1
  208. package/lib/dist/mcp/dynamic-boundaries.d.ts +1 -10
  209. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
  210. package/lib/dist/mcp/dynamic-boundaries.js +46 -42
  211. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
  212. package/lib/dist/mcp/engine.d.ts +28 -9
  213. package/lib/dist/mcp/engine.d.ts.map +1 -1
  214. package/lib/dist/mcp/engine.js +146 -62
  215. package/lib/dist/mcp/engine.js.map +1 -1
  216. package/lib/dist/mcp/explore-dedup.d.ts +5 -2
  217. package/lib/dist/mcp/explore-dedup.d.ts.map +1 -1
  218. package/lib/dist/mcp/explore-dedup.js +8 -5
  219. package/lib/dist/mcp/explore-dedup.js.map +1 -1
  220. package/lib/dist/mcp/index-freshness-worker.d.ts +2 -0
  221. package/lib/dist/mcp/index-freshness-worker.d.ts.map +1 -0
  222. package/lib/dist/mcp/index-freshness-worker.js +30 -0
  223. package/lib/dist/mcp/index-freshness-worker.js.map +1 -0
  224. package/lib/dist/mcp/index-freshness.d.ts +7 -0
  225. package/lib/dist/mcp/index-freshness.d.ts.map +1 -0
  226. package/lib/dist/mcp/index-freshness.js +94 -0
  227. package/lib/dist/mcp/index-freshness.js.map +1 -0
  228. package/lib/dist/mcp/index.d.ts +3 -1
  229. package/lib/dist/mcp/index.d.ts.map +1 -1
  230. package/lib/dist/mcp/index.js +95 -11
  231. package/lib/dist/mcp/index.js.map +1 -1
  232. package/lib/dist/mcp/liveness-watchdog.d.ts +4 -1
  233. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  234. package/lib/dist/mcp/liveness-watchdog.js +11 -2
  235. package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
  236. package/lib/dist/mcp/project-lifecycle.d.ts +9 -0
  237. package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -0
  238. package/lib/dist/mcp/project-lifecycle.js +181 -0
  239. package/lib/dist/mcp/project-lifecycle.js.map +1 -0
  240. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  241. package/lib/dist/mcp/proxy.js +9 -0
  242. package/lib/dist/mcp/proxy.js.map +1 -1
  243. package/lib/dist/mcp/query-pool.d.ts +2 -2
  244. package/lib/dist/mcp/query-pool.d.ts.map +1 -1
  245. package/lib/dist/mcp/query-pool.js +9 -7
  246. package/lib/dist/mcp/query-pool.js.map +1 -1
  247. package/lib/dist/mcp/query-worker.js +2 -2
  248. package/lib/dist/mcp/query-worker.js.map +1 -1
  249. package/lib/dist/mcp/server-instructions.d.ts +1 -1
  250. package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
  251. package/lib/dist/mcp/server-instructions.js +6 -3
  252. package/lib/dist/mcp/server-instructions.js.map +1 -1
  253. package/lib/dist/mcp/startup-handshake.d.ts +3 -1
  254. package/lib/dist/mcp/startup-handshake.d.ts.map +1 -1
  255. package/lib/dist/mcp/startup-handshake.js +10 -2
  256. package/lib/dist/mcp/startup-handshake.js.map +1 -1
  257. package/lib/dist/mcp/tools.d.ts +276 -36
  258. package/lib/dist/mcp/tools.d.ts.map +1 -1
  259. package/lib/dist/mcp/tools.js +2295 -980
  260. package/lib/dist/mcp/tools.js.map +1 -1
  261. package/lib/dist/mcp/writer-lock.d.ts +61 -0
  262. package/lib/dist/mcp/writer-lock.d.ts.map +1 -0
  263. package/lib/dist/mcp/writer-lock.js +260 -0
  264. package/lib/dist/mcp/writer-lock.js.map +1 -0
  265. package/lib/dist/resolution/alias-binding.d.ts +56 -0
  266. package/lib/dist/resolution/alias-binding.d.ts.map +1 -0
  267. package/lib/dist/resolution/alias-binding.js +127 -0
  268. package/lib/dist/resolution/alias-binding.js.map +1 -0
  269. package/lib/dist/resolution/callback-synthesizer.d.ts +23 -1
  270. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  271. package/lib/dist/resolution/callback-synthesizer.js +291 -143
  272. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  273. package/lib/dist/resolution/cpp-constructor.d.ts +4 -0
  274. package/lib/dist/resolution/cpp-constructor.d.ts.map +1 -0
  275. package/lib/dist/resolution/cpp-constructor.js +123 -0
  276. package/lib/dist/resolution/cpp-constructor.js.map +1 -0
  277. package/lib/dist/resolution/cpp-macro-visibility.d.ts +12 -0
  278. package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -0
  279. package/lib/dist/resolution/cpp-macro-visibility.js +342 -0
  280. package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -0
  281. package/lib/dist/resolution/expo-router-synthesizer.d.ts +32 -0
  282. package/lib/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
  283. package/lib/dist/resolution/expo-router-synthesizer.js +189 -0
  284. package/lib/dist/resolution/expo-router-synthesizer.js.map +1 -0
  285. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
  286. package/lib/dist/resolution/frameworks/csharp.js +96 -2
  287. package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
  288. package/lib/dist/resolution/frameworks/expo-router.d.ts +189 -0
  289. package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
  290. package/lib/dist/resolution/frameworks/expo-router.js +785 -0
  291. package/lib/dist/resolution/frameworks/expo-router.js.map +1 -0
  292. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
  293. package/lib/dist/resolution/frameworks/express.js +251 -16
  294. package/lib/dist/resolution/frameworks/express.js.map +1 -1
  295. package/lib/dist/resolution/frameworks/index.d.ts +5 -0
  296. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
  297. package/lib/dist/resolution/frameworks/index.js +29 -1
  298. package/lib/dist/resolution/frameworks/index.js.map +1 -1
  299. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
  300. package/lib/dist/resolution/frameworks/java.js +79 -47
  301. package/lib/dist/resolution/frameworks/java.js.map +1 -1
  302. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
  303. package/lib/dist/resolution/frameworks/nestjs.js +6 -14
  304. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
  305. package/lib/dist/resolution/frameworks/nextjs.d.ts +76 -0
  306. package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
  307. package/lib/dist/resolution/frameworks/nextjs.js +328 -0
  308. package/lib/dist/resolution/frameworks/nextjs.js.map +1 -0
  309. package/lib/dist/resolution/frameworks/object-literal.d.ts +32 -0
  310. package/lib/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
  311. package/lib/dist/resolution/frameworks/object-literal.js +139 -0
  312. package/lib/dist/resolution/frameworks/object-literal.js.map +1 -0
  313. package/lib/dist/resolution/frameworks/package-deps.d.ts +14 -0
  314. package/lib/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
  315. package/lib/dist/resolution/frameworks/package-deps.js +78 -0
  316. package/lib/dist/resolution/frameworks/package-deps.js.map +1 -0
  317. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
  318. package/lib/dist/resolution/frameworks/python.js +166 -0
  319. package/lib/dist/resolution/frameworks/python.js.map +1 -1
  320. package/lib/dist/resolution/frameworks/react-native.d.ts +26 -0
  321. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  322. package/lib/dist/resolution/frameworks/react-native.js +153 -14
  323. package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
  324. package/lib/dist/resolution/frameworks/react-router.d.ts +46 -0
  325. package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -0
  326. package/lib/dist/resolution/frameworks/react-router.js +187 -0
  327. package/lib/dist/resolution/frameworks/react-router.js.map +1 -0
  328. package/lib/dist/resolution/frameworks/react.d.ts +2 -1
  329. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
  330. package/lib/dist/resolution/frameworks/react.js +188 -139
  331. package/lib/dist/resolution/frameworks/react.js.map +1 -1
  332. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -1
  333. package/lib/dist/resolution/frameworks/svelte.js +6 -1
  334. package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
  335. package/lib/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
  336. package/lib/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
  337. package/lib/dist/resolution/frameworks/sveltekit-router.js +156 -0
  338. package/lib/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
  339. package/lib/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
  340. package/lib/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
  341. package/lib/dist/resolution/frameworks/tanstack-router.js +437 -0
  342. package/lib/dist/resolution/frameworks/tanstack-router.js.map +1 -0
  343. package/lib/dist/resolution/frameworks/vue-router.d.ts +82 -0
  344. package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
  345. package/lib/dist/resolution/frameworks/vue-router.js +377 -0
  346. package/lib/dist/resolution/frameworks/vue-router.js.map +1 -0
  347. package/lib/dist/resolution/import-resolver.d.ts +38 -0
  348. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  349. package/lib/dist/resolution/import-resolver.js +376 -26
  350. package/lib/dist/resolution/import-resolver.js.map +1 -1
  351. package/lib/dist/resolution/index.d.ts +89 -25
  352. package/lib/dist/resolution/index.d.ts.map +1 -1
  353. package/lib/dist/resolution/index.js +552 -145
  354. package/lib/dist/resolution/index.js.map +1 -1
  355. package/lib/dist/resolution/js-builtins.d.ts +13 -0
  356. package/lib/dist/resolution/js-builtins.d.ts.map +1 -0
  357. package/lib/dist/resolution/js-builtins.js +46 -0
  358. package/lib/dist/resolution/js-builtins.js.map +1 -0
  359. package/lib/dist/resolution/name-matcher.d.ts +69 -22
  360. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  361. package/lib/dist/resolution/name-matcher.js +1902 -87
  362. package/lib/dist/resolution/name-matcher.js.map +1 -1
  363. package/lib/dist/resolution/next-router-synthesizer.d.ts +27 -0
  364. package/lib/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
  365. package/lib/dist/resolution/next-router-synthesizer.js +113 -0
  366. package/lib/dist/resolution/next-router-synthesizer.js.map +1 -0
  367. package/lib/dist/resolution/react-router-synthesizer.d.ts +33 -0
  368. package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
  369. package/lib/dist/resolution/react-router-synthesizer.js +126 -0
  370. package/lib/dist/resolution/react-router-synthesizer.js.map +1 -0
  371. package/lib/dist/resolution/resolver-pool.d.ts +2 -0
  372. package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
  373. package/lib/dist/resolution/resolver-pool.js +4 -0
  374. package/lib/dist/resolution/resolver-pool.js.map +1 -1
  375. package/lib/dist/resolution/strip-comments.d.ts +6 -0
  376. package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
  377. package/lib/dist/resolution/strip-comments.js +58 -0
  378. package/lib/dist/resolution/strip-comments.js.map +1 -1
  379. package/lib/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
  380. package/lib/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
  381. package/lib/dist/resolution/sveltekit-synthesizer.js +173 -0
  382. package/lib/dist/resolution/sveltekit-synthesizer.js.map +1 -0
  383. package/lib/dist/resolution/synth-utils.d.ts +26 -0
  384. package/lib/dist/resolution/synth-utils.d.ts.map +1 -0
  385. package/lib/dist/resolution/synth-utils.js +75 -0
  386. package/lib/dist/resolution/synth-utils.js.map +1 -0
  387. package/lib/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
  388. package/lib/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
  389. package/lib/dist/resolution/tanstack-router-synthesizer.js +114 -0
  390. package/lib/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
  391. package/lib/dist/resolution/tier-synthesizer.d.ts +49 -0
  392. package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -0
  393. package/lib/dist/resolution/tier-synthesizer.js +931 -0
  394. package/lib/dist/resolution/tier-synthesizer.js.map +1 -0
  395. package/lib/dist/resolution/types.d.ts +78 -2
  396. package/lib/dist/resolution/types.d.ts.map +1 -1
  397. package/lib/dist/resolution/types.js +64 -0
  398. package/lib/dist/resolution/types.js.map +1 -1
  399. package/lib/dist/resolution/vue-router-synthesizer.d.ts +30 -0
  400. package/lib/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
  401. package/lib/dist/resolution/vue-router-synthesizer.js +115 -0
  402. package/lib/dist/resolution/vue-router-synthesizer.js.map +1 -0
  403. package/lib/dist/search/query-paths.d.ts +50 -1
  404. package/lib/dist/search/query-paths.d.ts.map +1 -1
  405. package/lib/dist/search/query-paths.js +227 -12
  406. package/lib/dist/search/query-paths.js.map +1 -1
  407. package/lib/dist/search/query-utils.d.ts +15 -0
  408. package/lib/dist/search/query-utils.d.ts.map +1 -1
  409. package/lib/dist/search/query-utils.js +35 -7
  410. package/lib/dist/search/query-utils.js.map +1 -1
  411. package/lib/dist/sync/watch-policy.d.ts +14 -0
  412. package/lib/dist/sync/watch-policy.d.ts.map +1 -1
  413. package/lib/dist/sync/watch-policy.js +19 -0
  414. package/lib/dist/sync/watch-policy.js.map +1 -1
  415. package/lib/dist/sync/watcher.d.ts +52 -35
  416. package/lib/dist/sync/watcher.d.ts.map +1 -1
  417. package/lib/dist/sync/watcher.js +236 -100
  418. package/lib/dist/sync/watcher.js.map +1 -1
  419. package/lib/dist/telemetry/index.d.ts +4 -2
  420. package/lib/dist/telemetry/index.d.ts.map +1 -1
  421. package/lib/dist/telemetry/index.js +92 -41
  422. package/lib/dist/telemetry/index.js.map +1 -1
  423. package/lib/dist/types.d.ts +1 -1
  424. package/lib/dist/types.d.ts.map +1 -1
  425. package/lib/dist/types.js +1 -0
  426. package/lib/dist/types.js.map +1 -1
  427. package/lib/dist/ui-server/api/deadcode.d.ts +84 -0
  428. package/lib/dist/ui-server/api/deadcode.d.ts.map +1 -0
  429. package/lib/dist/ui-server/api/deadcode.js +136 -0
  430. package/lib/dist/ui-server/api/deadcode.js.map +1 -0
  431. package/lib/dist/ui-server/api/effects.d.ts +87 -0
  432. package/lib/dist/ui-server/api/effects.d.ts.map +1 -0
  433. package/lib/dist/ui-server/api/effects.js +499 -0
  434. package/lib/dist/ui-server/api/effects.js.map +1 -0
  435. package/lib/dist/ui-server/api/entrypoints.d.ts +86 -0
  436. package/lib/dist/ui-server/api/entrypoints.d.ts.map +1 -0
  437. package/lib/dist/ui-server/api/entrypoints.js +279 -0
  438. package/lib/dist/ui-server/api/entrypoints.js.map +1 -0
  439. package/lib/dist/ui-server/api/events.d.ts +183 -0
  440. package/lib/dist/ui-server/api/events.d.ts.map +1 -0
  441. package/lib/dist/ui-server/api/events.js +430 -0
  442. package/lib/dist/ui-server/api/events.js.map +1 -0
  443. package/lib/dist/ui-server/api/file.d.ts +66 -0
  444. package/lib/dist/ui-server/api/file.d.ts.map +1 -0
  445. package/lib/dist/ui-server/api/file.js +235 -0
  446. package/lib/dist/ui-server/api/file.js.map +1 -0
  447. package/lib/dist/ui-server/api/filecode.d.ts +126 -0
  448. package/lib/dist/ui-server/api/filecode.d.ts.map +1 -0
  449. package/lib/dist/ui-server/api/filecode.js +205 -0
  450. package/lib/dist/ui-server/api/filecode.js.map +1 -0
  451. package/lib/dist/ui-server/api/flow.d.ts +226 -0
  452. package/lib/dist/ui-server/api/flow.d.ts.map +1 -0
  453. package/lib/dist/ui-server/api/flow.js +612 -0
  454. package/lib/dist/ui-server/api/flow.js.map +1 -0
  455. package/lib/dist/ui-server/api/hierarchy.d.ts +81 -0
  456. package/lib/dist/ui-server/api/hierarchy.d.ts.map +1 -0
  457. package/lib/dist/ui-server/api/hierarchy.js +92 -0
  458. package/lib/dist/ui-server/api/hierarchy.js.map +1 -0
  459. package/lib/dist/ui-server/api/index.d.ts +90 -0
  460. package/lib/dist/ui-server/api/index.d.ts.map +1 -0
  461. package/lib/dist/ui-server/api/index.js +332 -0
  462. package/lib/dist/ui-server/api/index.js.map +1 -0
  463. package/lib/dist/ui-server/api/map.d.ts +238 -0
  464. package/lib/dist/ui-server/api/map.d.ts.map +1 -0
  465. package/lib/dist/ui-server/api/map.js +681 -0
  466. package/lib/dist/ui-server/api/map.js.map +1 -0
  467. package/lib/dist/ui-server/api/node.d.ts +81 -0
  468. package/lib/dist/ui-server/api/node.d.ts.map +1 -0
  469. package/lib/dist/ui-server/api/node.js +388 -0
  470. package/lib/dist/ui-server/api/node.js.map +1 -0
  471. package/lib/dist/ui-server/api/nodes.d.ts +25 -0
  472. package/lib/dist/ui-server/api/nodes.d.ts.map +1 -0
  473. package/lib/dist/ui-server/api/nodes.js +45 -0
  474. package/lib/dist/ui-server/api/nodes.js.map +1 -0
  475. package/lib/dist/ui-server/api/program.d.ts +139 -0
  476. package/lib/dist/ui-server/api/program.d.ts.map +1 -0
  477. package/lib/dist/ui-server/api/program.js +315 -0
  478. package/lib/dist/ui-server/api/program.js.map +1 -0
  479. package/lib/dist/ui-server/api/respond.d.ts +76 -0
  480. package/lib/dist/ui-server/api/respond.d.ts.map +1 -0
  481. package/lib/dist/ui-server/api/respond.js +186 -0
  482. package/lib/dist/ui-server/api/respond.js.map +1 -0
  483. package/lib/dist/ui-server/api/route-roots.d.ts +39 -0
  484. package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -0
  485. package/lib/dist/ui-server/api/route-roots.js +96 -0
  486. package/lib/dist/ui-server/api/route-roots.js.map +1 -0
  487. package/lib/dist/ui-server/api/routes.d.ts +59 -0
  488. package/lib/dist/ui-server/api/routes.d.ts.map +1 -0
  489. package/lib/dist/ui-server/api/routes.js +108 -0
  490. package/lib/dist/ui-server/api/routes.js.map +1 -0
  491. package/lib/dist/ui-server/api/screens.d.ts +117 -0
  492. package/lib/dist/ui-server/api/screens.d.ts.map +1 -0
  493. package/lib/dist/ui-server/api/screens.js +611 -0
  494. package/lib/dist/ui-server/api/screens.js.map +1 -0
  495. package/lib/dist/ui-server/api/search.d.ts +29 -0
  496. package/lib/dist/ui-server/api/search.d.ts.map +1 -0
  497. package/lib/dist/ui-server/api/search.js +232 -0
  498. package/lib/dist/ui-server/api/search.js.map +1 -0
  499. package/lib/dist/ui-server/api/session.d.ts +52 -0
  500. package/lib/dist/ui-server/api/session.d.ts.map +1 -0
  501. package/lib/dist/ui-server/api/session.js +196 -0
  502. package/lib/dist/ui-server/api/session.js.map +1 -0
  503. package/lib/dist/ui-server/api/source.d.ts +200 -0
  504. package/lib/dist/ui-server/api/source.d.ts.map +1 -0
  505. package/lib/dist/ui-server/api/source.js +422 -0
  506. package/lib/dist/ui-server/api/source.js.map +1 -0
  507. package/lib/dist/ui-server/api/stats.d.ts +27 -0
  508. package/lib/dist/ui-server/api/stats.d.ts.map +1 -0
  509. package/lib/dist/ui-server/api/stats.js +164 -0
  510. package/lib/dist/ui-server/api/stats.js.map +1 -0
  511. package/lib/dist/ui-server/api/steps.d.ts +274 -0
  512. package/lib/dist/ui-server/api/steps.d.ts.map +1 -0
  513. package/lib/dist/ui-server/api/steps.js +1446 -0
  514. package/lib/dist/ui-server/api/steps.js.map +1 -0
  515. package/lib/dist/ui-server/api/trail-store.d.ts +142 -0
  516. package/lib/dist/ui-server/api/trail-store.d.ts.map +1 -0
  517. package/lib/dist/ui-server/api/trail-store.js +323 -0
  518. package/lib/dist/ui-server/api/trail-store.js.map +1 -0
  519. package/lib/dist/ui-server/api/trails.d.ts +163 -0
  520. package/lib/dist/ui-server/api/trails.d.ts.map +1 -0
  521. package/lib/dist/ui-server/api/trails.js +369 -0
  522. package/lib/dist/ui-server/api/trails.js.map +1 -0
  523. package/lib/dist/ui-server/api/when.d.ts +125 -0
  524. package/lib/dist/ui-server/api/when.d.ts.map +1 -0
  525. package/lib/dist/ui-server/api/when.js +251 -0
  526. package/lib/dist/ui-server/api/when.js.map +1 -0
  527. package/lib/dist/ui-server/api/wire.d.ts +179 -0
  528. package/lib/dist/ui-server/api/wire.d.ts.map +1 -0
  529. package/lib/dist/ui-server/api/wire.js +231 -0
  530. package/lib/dist/ui-server/api/wire.js.map +1 -0
  531. package/lib/dist/ui-server/assets.d.ts +40 -0
  532. package/lib/dist/ui-server/assets.d.ts.map +1 -0
  533. package/lib/dist/ui-server/assets.js +110 -0
  534. package/lib/dist/ui-server/assets.js.map +1 -0
  535. package/lib/dist/ui-server/constants.d.ts +32 -0
  536. package/lib/dist/ui-server/constants.d.ts.map +1 -0
  537. package/lib/dist/ui-server/constants.js +35 -0
  538. package/lib/dist/ui-server/constants.js.map +1 -0
  539. package/lib/dist/ui-server/highlight/index.d.ts +113 -0
  540. package/lib/dist/ui-server/highlight/index.d.ts.map +1 -0
  541. package/lib/dist/ui-server/highlight/index.js +307 -0
  542. package/lib/dist/ui-server/highlight/index.js.map +1 -0
  543. package/lib/dist/ui-server/highlight/languages.d.ts +36 -0
  544. package/lib/dist/ui-server/highlight/languages.d.ts.map +1 -0
  545. package/lib/dist/ui-server/highlight/languages.js +50 -0
  546. package/lib/dist/ui-server/highlight/languages.js.map +1 -0
  547. package/lib/dist/ui-server/index.d.ts +92 -0
  548. package/lib/dist/ui-server/index.d.ts.map +1 -0
  549. package/lib/dist/ui-server/index.js +399 -0
  550. package/lib/dist/ui-server/index.js.map +1 -0
  551. package/lib/dist/ui-server/open-browser.d.ts +31 -0
  552. package/lib/dist/ui-server/open-browser.d.ts.map +1 -0
  553. package/lib/dist/ui-server/open-browser.js +79 -0
  554. package/lib/dist/ui-server/open-browser.js.map +1 -0
  555. package/lib/dist/ui-server/security.d.ts +127 -0
  556. package/lib/dist/ui-server/security.d.ts.map +1 -0
  557. package/lib/dist/ui-server/security.js +332 -0
  558. package/lib/dist/ui-server/security.js.map +1 -0
  559. package/lib/dist/ui-server/static.d.ts +45 -0
  560. package/lib/dist/ui-server/static.d.ts.map +1 -0
  561. package/lib/dist/ui-server/static.js +165 -0
  562. package/lib/dist/ui-server/static.js.map +1 -0
  563. package/lib/dist/utils.d.ts +14 -2
  564. package/lib/dist/utils.d.ts.map +1 -1
  565. package/lib/dist/utils.js +25 -10
  566. package/lib/dist/utils.js.map +1 -1
  567. package/lib/dist/viewer/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  568. package/lib/dist/viewer/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  569. package/lib/dist/viewer/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  570. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-2syK4fUT.woff +0 -0
  571. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-CBJ8pzag.woff2 +0 -0
  572. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  573. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  574. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  575. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  576. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  577. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  578. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-B4oTjJdl.woff +0 -0
  579. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-CBjNughH.woff2 +0 -0
  580. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  581. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  582. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  583. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  584. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  585. package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  586. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-66oory27.woff +0 -0
  587. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
  588. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  589. package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  590. package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  591. package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  592. package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  593. package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  594. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-B7_fu1kp.woff2 +0 -0
  595. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-Bg0ZHwF4.woff +0 -0
  596. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  597. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  598. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  599. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  600. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  601. package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  602. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-D6eaYXMU.woff +0 -0
  603. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-DRuN92E5.woff2 +0 -0
  604. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  605. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  606. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  607. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  608. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  609. package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  610. package/lib/dist/viewer/assets/index-CF9yvio6.css +1 -0
  611. package/lib/dist/viewer/assets/index-D4S7YUPf.js +97 -0
  612. package/lib/dist/viewer/index.html +16 -0
  613. package/lib/kernel/codegraph-kernel.node +2 -2
  614. package/lib/node_modules/.package-lock.json +4 -4
  615. package/lib/node_modules/picomatch/README.md +56 -51
  616. package/lib/node_modules/picomatch/lib/constants.js +4 -0
  617. package/lib/node_modules/picomatch/lib/parse.js +341 -1
  618. package/lib/node_modules/picomatch/lib/picomatch.js +25 -5
  619. package/lib/node_modules/picomatch/lib/scan.js +30 -18
  620. package/lib/node_modules/picomatch/package.json +4 -4
  621. package/lib/package.json +9 -2
  622. package/package.json +1 -1
@@ -4,16 +4,52 @@
4
4
  *
5
5
  * Handles symbol name matching for reference resolution.
6
6
  */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
7
40
  Object.defineProperty(exports, "__esModule", { value: true });
8
41
  exports.matchByFilePath = matchByFilePath;
9
42
  exports.sameLanguageFamily = sameLanguageFamily;
10
- exports.isKnownLanguageFamily = isKnownLanguageFamily;
11
- exports.crossesKnownFamily = crossesKnownFamily;
43
+ exports.crossesCodeBoundary = crossesCodeBoundary;
44
+ exports.gateLanguageMatch = gateLanguageMatch;
12
45
  exports.matchFunctionRef = matchFunctionRef;
46
+ exports.isVisibleAcrossFiles = isVisibleAcrossFiles;
13
47
  exports.matchByExactName = matchByExactName;
14
48
  exports.matchByQualifiedName = matchByQualifiedName;
15
49
  exports.preferCallSiteFile = preferCallSiteFile;
16
50
  exports.resolveObjectLiteralMember = resolveObjectLiteralMember;
51
+ exports.objectLiteralMemberBinding = objectLiteralMemberBinding;
52
+ exports.resolveObjectLiteralBinding = resolveObjectLiteralBinding;
17
53
  exports.resolveMethodOnType = resolveMethodOnType;
18
54
  exports.matchCppCallChain = matchCppCallChain;
19
55
  exports.matchScopedCallChain = matchScopedCallChain;
@@ -23,9 +59,15 @@ exports.clearNameMatcherMemos = clearNameMatcherMemos;
23
59
  exports.localReceiverTypePatterns = localReceiverTypePatterns;
24
60
  exports.matchMethodCall = matchMethodCall;
25
61
  exports.rustFieldTypeName = rustFieldTypeName;
62
+ exports.matchJsStoreBindingCall = matchJsStoreBindingCall;
63
+ exports.isUnresolvedJsMemberCall = isUnresolvedJsMemberCall;
26
64
  exports.matchFuzzy = matchFuzzy;
27
65
  exports.dumpNameMatcherProfile = dumpNameMatcherProfile;
28
66
  exports.matchReference = matchReference;
67
+ const path = __importStar(require("path"));
68
+ const types_1 = require("./types");
69
+ const strip_comments_1 = require("./strip-comments");
70
+ const js_builtins_1 = require("./js-builtins");
29
71
  /**
30
72
  * Ceiling on how many same-named definitions a FUZZY name-match strategy will
31
73
  * score. A name defined more times than this is "ubiquitous" — a method/symbol
@@ -145,14 +187,16 @@ function pickClosestFileNode(candidates, ref) {
145
187
  */
146
188
  const LANGUAGE_FAMILY = {
147
189
  java: 'jvm', kotlin: 'jvm', scala: 'jvm',
148
- swift: 'apple', objc: 'apple',
190
+ swift: 'native', objc: 'native',
149
191
  // ArkTS is a TS superset — every HarmonyOS project mixes `.ets` UI with
150
192
  // `.ts` logic modules, so refs must cross freely between them.
151
193
  typescript: 'web', tsx: 'web', javascript: 'web', jsx: 'web', arkts: 'web',
152
- c: 'c', cpp: 'c',
194
+ c: 'native', cpp: 'native',
153
195
  // Razor/Blazor markup names C# types — same family so `@model Foo` /
154
196
  // `<MyComponent/>` resolve to their `.cs` class through the cross-family gate.
155
- csharp: 'dotnet', razor: 'dotnet',
197
+ csharp: 'dotnet', razor: 'dotnet', vbnet: 'dotnet',
198
+ svelte: 'web', vue: 'web', astro: 'web',
199
+ cfml: 'cfml', cfscript: 'cfml',
156
200
  };
157
201
  function sameLanguageFamily(a, b) {
158
202
  if (a === b)
@@ -160,62 +204,324 @@ function sameLanguageFamily(a, b) {
160
204
  const fa = LANGUAGE_FAMILY[a];
161
205
  return fa !== undefined && fa === LANGUAGE_FAMILY[b];
162
206
  }
163
- /**
164
- * True when `lang` belongs to a known multi-language family (jvm/apple/web/c).
165
- * Languages not listed (php, python, go, ruby, rust, dart, …) and config
166
- * formats (yaml/xml/blade) form their own singleton families and return
167
- * `false` — used to leave config↔code framework bridges (whose config side is
168
- * never a known programming-language family) out of the cross-family gate.
169
- */
170
- function isKnownLanguageFamily(lang) {
171
- return LANGUAGE_FAMILY[lang] !== undefined;
207
+ /** Config/markup transitions stay open; every other code language has a family. */
208
+ const CODE_FAMILY = {
209
+ ...LANGUAGE_FAMILY,
210
+ python: 'python', go: 'go', rust: 'rust', php: 'php', ruby: 'ruby', dart: 'dart',
211
+ lua: 'lua', luau: 'lua', r: 'r', erlang: 'erlang', pascal: 'pascal', solidity: 'solidity',
212
+ nix: 'nix', cobol: 'cobol',
213
+ };
214
+ function crossesCodeBoundary(a, b) {
215
+ return CODE_FAMILY[a] !== undefined && CODE_FAMILY[b] !== undefined &&
216
+ CODE_FAMILY[a] !== CODE_FAMILY[b];
172
217
  }
173
218
  /**
174
- * True when `a` and `b` are two DIFFERENT *known* language families — the
175
- * signature of a coincidental cross-language name collision (a TS `import
176
- * React` matching a Swift `import React`, a C++ `#include "X.h"` matching a
177
- * same-named ObjC header on another platform). The both-*known* test is
178
- * deliberately weaker than {@link sameLanguageFamily}'s negation: a
179
- * single-file-component language that carries its own tag (`vue`/`svelte`)
180
- * importing a `.ts` module, or any singleton-family language (php/go/ruby/…),
181
- * returns `false` here and is left alone.
219
+ * Cross-family name matches need a framework export or an actual ABI boundary,
220
+ * not merely a native caller. ABI evidence is scoped to the named free function.
182
221
  */
183
- function crossesKnownFamily(a, b) {
184
- return isKnownLanguageFamily(a) && isKnownLanguageFamily(b) && !sameLanguageFamily(a, b);
222
+ function hasBridgeEvidence(candidate, ref, context) {
223
+ if (ref.referenceKind !== 'calls')
224
+ return false;
225
+ // Expo's extractor creates explicit JS exports, resolved by the ordinary
226
+ // name matcher rather than a framework resolve() branch.
227
+ if (CODE_FAMILY[ref.language] === 'web' && candidate.id.startsWith('expo-module:') &&
228
+ candidate.isExported && (candidate.language === 'swift' || candidate.language === 'kotlin'))
229
+ return true;
230
+ if (candidate.kind !== 'function')
231
+ return false;
232
+ const name = candidate.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
233
+ if (CODE_FAMILY[ref.language] === 'native') {
234
+ const source = context.readFile(candidate.filePath);
235
+ if (!source)
236
+ return false;
237
+ if (candidate.language === 'go') {
238
+ const declaration = source.split('\n').slice(Math.max(0, candidate.startLine - 2), candidate.endLine).join('\n');
239
+ return /\bimport\s+(?:\(\s*)?"C"/.test((0, strip_comments_1.stripCommentsForRegex)(source, 'go')) &&
240
+ new RegExp('^//export ' + name + '\\r?\\nfunc ' + name + '\\s*\\(', 'm').test(declaration);
241
+ }
242
+ if (candidate.language === 'rust') {
243
+ const declaration = source.split('\n').slice(candidate.startLine - 1, candidate.endLine).join('\n');
244
+ return new RegExp('\\bpub\\s+extern\\s+"C"\\s+fn\\s+' + name + '\\b')
245
+ .test((0, strip_comments_1.stripCommentsForRegex)(declaration, 'rust'));
246
+ }
247
+ }
248
+ if (candidate.language === 'c' || candidate.language === 'cpp') {
249
+ const source = context.readFile(ref.filePath);
250
+ if (!source)
251
+ return false;
252
+ if (ref.language === 'go') {
253
+ return /\bimport\s+(?:\(\s*)?"C"/.test((0, strip_comments_1.stripCommentsForRegex)(source, 'go')) &&
254
+ ref.referenceName === 'C.' + candidate.name;
255
+ }
256
+ if (ref.language === 'rust') {
257
+ return new RegExp('extern\\s+"C"\\s*\\{[^}]*\\bfn\\s+' + name + '\\s*\\(')
258
+ .test((0, strip_comments_1.stripCommentsForRegex)(source, 'rust'));
259
+ }
260
+ }
261
+ return false;
185
262
  }
186
263
  /**
187
- * Drop cross-language candidates from a name lookup. Two regimes:
188
- * - `references` (type-usage): a type named in language X resolves to a
189
- * SAME-family type, never a coincidentally same-named symbol in another
190
- * language (the Android `BatteryManager` system class vs a JS one). Strict
191
- * same-family filter — cross-language communication is `calls`, not refs.
192
- * - `imports` (import binding): an `import`/`#include` never crosses two
193
- * KNOWN families (TS `import React` ↮ Swift `import React`). Weaker
194
- * both-known filter so `.vue`/`.svelte` (own tag) importing `.ts` survives.
264
+ * Per-context memo: node id → its language, for gateLanguageMatch. Matches
265
+ * land on ~5 refs per target on vscode, and each check otherwise fetched the
266
+ * whole node (a point read + row decode past the query layer's small cache)
267
+ * only to read one field. Nodes are fixed within a resolution pass; the memo
268
+ * drops with clearNameMatcherMemos.
195
269
  */
196
- function applyLanguageGate(candidates, ref) {
197
- if (ref.referenceKind === 'references' || ref.referenceKind === 'function_ref') {
198
- return candidates.filter((c) => sameLanguageFamily(c.language, ref.language));
270
+ const TARGET_LANGUAGE = new WeakMap();
271
+ /** Reject the chosen result without shrinking a pool or trying a replacement. */
272
+ function gateLanguageMatch(result, ref, context) {
273
+ if (!result)
274
+ return result;
275
+ // No code family on the reference's side: no target can cross a boundary.
276
+ if (CODE_FAMILY[ref.language] === undefined)
277
+ return result;
278
+ if (context.getNodeById) {
279
+ let languages = TARGET_LANGUAGE.get(context);
280
+ if (!languages) {
281
+ languages = new Map();
282
+ TARGET_LANGUAGE.set(context, languages);
283
+ }
284
+ let language = languages.get(result.targetNodeId);
285
+ if (language === undefined) {
286
+ const node = context.getNodeById(result.targetNodeId);
287
+ if (node) {
288
+ language = node.language;
289
+ if (languages.size >= 400_000)
290
+ languages.clear();
291
+ languages.set(result.targetNodeId, language);
292
+ }
293
+ }
294
+ if (language !== undefined) {
295
+ if (!crossesCodeBoundary(ref.language, language))
296
+ return result;
297
+ const target = context.getNodeById(result.targetNodeId);
298
+ return target && !hasBridgeEvidence(target, ref, context) ? null : result;
299
+ }
300
+ }
301
+ const target = context.getNodeById?.(result.targetNodeId) ??
302
+ context.getNodesByName(ref.referenceName).find((n) => n.id === result.targetNodeId);
303
+ if (target && crossesCodeBoundary(ref.language, target.language) &&
304
+ !hasBridgeEvidence(target, ref, context))
305
+ return null;
306
+ return result;
307
+ }
308
+ /** Member values retain their receiver; never break ties by file order (#1820). */
309
+ function matchMemberFunctionRef(ref, context) {
310
+ const dot = ref.referenceName.lastIndexOf('.');
311
+ const receiver = ref.referenceName.slice(0, dot);
312
+ const member = ref.referenceName.slice(dot + 1);
313
+ const result = (nodes, confidence = 0.9) => {
314
+ const pool = nodes.filter(n => sameLanguageFamily(n.language, ref.language));
315
+ const target = pool.length === 1 ? pool[0] : undefined;
316
+ return target && (target.kind === 'function' || target.kind === 'method') &&
317
+ target.id !== ref.fromNodeId && !isPythonProperty(target, context)
318
+ ? { original: ref, targetNodeId: target.id, confidence, resolvedBy: 'function-ref' }
319
+ : null;
320
+ };
321
+ const imports = context.getImportMappings(ref.filePath, ref.language);
322
+ // An import is authoritative even when it points outside the project.
323
+ if (imports.some(i => i.localName === receiver.split('.')[0])) {
324
+ if (ref.language === 'python') {
325
+ const cls = pythonRefClass(receiver, ref, context);
326
+ if (cls)
327
+ return result(pythonMembers(cls, member, ref, context));
328
+ }
329
+ const imported = context.resolveImport?.(ref);
330
+ const node = imported && context.getNodeById?.(imported.targetNodeId);
331
+ return node ? result(context.getNodesByQualifiedName(node.qualifiedName).filter(n => n.filePath === node.filePath)) : null;
332
+ }
333
+ if (ref.language === 'go') {
334
+ if (receiver.includes('.'))
335
+ return matchGoFieldChainCall(receiver, member, ref, context);
336
+ const type = inferLocalReceiverType(receiver, ref, context);
337
+ if (type)
338
+ return resolveMethodOnType(type, member, ref, context, 0.9, 'function-ref');
339
+ const types = context.getNodesByName(receiver).filter(n => n.language === 'go' && (n.kind === 'struct' || n.kind === 'interface'));
340
+ if (types.length)
341
+ return types.length === 1 ? resolveMethodOnType(receiver, member, ref, context, 0.9, 'function-ref') : null;
342
+ }
343
+ else {
344
+ const owner = context.getNodesInFile(ref.filePath).filter(n => n.kind === 'class' && n.startLine <= ref.line && n.endLine >= ref.line)
345
+ .sort((a, b) => b.startLine - a.startLine)[0];
346
+ let type = null;
347
+ if (receiver === 'self' || receiver === 'cls') {
348
+ return owner ? result(pythonMembers(owner, member, ref, context)) : null;
349
+ }
350
+ if (/^(self|cls)\.\w+$/.test(receiver)) {
351
+ if (!owner)
352
+ return null;
353
+ type = pythonFieldType(receiver, owner, ref, context);
354
+ }
355
+ else {
356
+ type = pythonLocalType(receiver, ref, context);
357
+ }
358
+ // A type name used directly (`Store.fetch`) is scoped just like an annotation.
359
+ if (!type && /^[A-Z]\w*$/.test(receiver))
360
+ type = receiver;
361
+ if (type && type !== 'object' && type !== 'Any') {
362
+ const cls = pythonRefClass(type, ref, context);
363
+ if (!cls)
364
+ return null;
365
+ const members = pythonMembers(cls, member, ref, context);
366
+ if (members.length)
367
+ return result(members);
368
+ // A base-typed field can hold a subclass-only method (the reported case).
369
+ // Keep only descendants of THAT base; unrelated same-name methods cannot win.
370
+ const candidates = context.getNodesByName(member).filter(n => n.kind === 'method' && n.language === 'python');
371
+ const descendants = candidates.filter(n => {
372
+ const parent = context.getNodesInFile(n.filePath).find(c => c.kind === 'class' && n.qualifiedName === `${c.qualifiedName}::${member}`);
373
+ return parent && pythonDerivesFrom(parent, cls, ref, context);
374
+ });
375
+ return result(descendants, 0.8);
376
+ }
199
377
  }
200
- if (ref.referenceKind === 'imports') {
201
- return candidates.filter((c) => !crossesKnownFamily(c.language, ref.language));
378
+ // Unknown receivers retain the old unique-or-drop discipline, across ALL
379
+ // files. Tests and abstract-looking bodies are candidates too.
380
+ return result(context.getNodesByName(member), 0.8);
381
+ }
382
+ function pythonRefClass(name, ref, context) {
383
+ const imports = context.getImportMappings(ref.filePath, 'python');
384
+ if (imports.some(i => i.localName === name.split('.')[0])) {
385
+ const hit = context.resolveImport?.({ ...ref, referenceName: name, referenceKind: 'references' });
386
+ const node = hit && context.getNodeById?.(hit.targetNodeId);
387
+ return node?.kind === 'class' && context.getNodesByQualifiedName(node.qualifiedName)
388
+ .filter(n => n.kind === 'class' && n.filePath === node.filePath).length === 1 ? node : null;
202
389
  }
203
- return candidates;
390
+ const classes = context.getNodesByName(name).filter(n => n.kind === 'class' && n.filePath === ref.filePath);
391
+ return classes.length === 1 ? classes[0] : null;
392
+ }
393
+ function pythonBases(cls, ref, context) {
394
+ const line = context.getFileLines?.(cls.filePath)?.[cls.startLine - 1]
395
+ ?? context.readFile(cls.filePath)?.split('\n')[cls.startLine - 1] ?? '';
396
+ const bases = line.match(/^\s*class\s+\w+\s*\(([^)]*)\)/)?.[1];
397
+ return (bases?.split(',') ?? []).flatMap(name => {
398
+ const base = pythonRefClass(name.trim(), { ...ref, filePath: cls.filePath }, context);
399
+ return base ? [base] : [];
400
+ });
401
+ }
402
+ function pythonDerivesFrom(cls, base, ref, context, seen = new Set()) {
403
+ if (seen.has(cls.id) || seen.size >= 16)
404
+ return false;
405
+ seen.add(cls.id);
406
+ return pythonBases(cls, ref, context).some(p => p.id === base.id || pythonDerivesFrom(p, base, ref, context, seen));
407
+ }
408
+ function pythonMembers(cls, member, ref, context, seen = new Set()) {
409
+ if (seen.has(cls.id) || seen.size >= 16)
410
+ return [];
411
+ seen.add(cls.id);
412
+ // Instance assignments also shadow methods, even though they are not nodes.
413
+ const body = pythonMemberLines(cls.filePath, context).slice(cls.startLine - 1, cls.endLine).join('\n');
414
+ if (new RegExp(`^\\s*(?:(?:self|cls)\\.)?${member}\\s*(?:=|:)`, 'm').test(body))
415
+ return [cls];
416
+ const own = context.getNodesByQualifiedName(`${cls.qualifiedName}::${member}`).filter(n => n.filePath === cls.filePath);
417
+ if (own.length)
418
+ return own;
419
+ return [...new Map(pythonBases(cls, ref, context).flatMap(p => pythonMembers(p, member, ref, context, seen)).map(n => [n.id, n])).values()];
420
+ }
421
+ function isPythonProperty(node, context) {
422
+ if (node.language !== 'python' || node.kind !== 'method')
423
+ return false;
424
+ const lines = context.getFileLines?.(node.filePath) ?? context.readFile(node.filePath)?.split('\n') ?? [];
425
+ for (let i = node.startLine - 2; i >= 0 && lines[i].trim().startsWith('@'); i--) {
426
+ if (/^\s*@(?:property|(?:functools\.)?cached_property)\s*$/.test(lines[i]))
427
+ return true;
428
+ }
429
+ return false;
430
+ }
431
+ const PYTHON_MEMBER_LINES = new WeakMap();
432
+ function pythonMemberLines(filePath, context) {
433
+ let files = PYTHON_MEMBER_LINES.get(context);
434
+ if (!files) {
435
+ files = new Map();
436
+ PYTHON_MEMBER_LINES.set(context, files);
437
+ }
438
+ let lines = files.get(filePath);
439
+ if (!lines) {
440
+ lines = (0, strip_comments_1.stripCommentsForRegex)(context.readFile(filePath) ?? '', 'python').split('\n');
441
+ files.set(filePath, lines);
442
+ }
443
+ return lines;
444
+ }
445
+ function pythonLocalType(receiver, ref, context) {
446
+ if (!/^\w+$/.test(receiver))
447
+ return null;
448
+ const caller = context.getNodeById?.(ref.fromNodeId);
449
+ const lines = pythonMemberLines(ref.filePath, context);
450
+ const declaration = new RegExp(`^\\s*${receiver}\\s*(?::\\s*["']?([\\w.]+)["']?)?\\s*=\\s*(.*)$`);
451
+ const annotation = new RegExp(`^\\s*${receiver}\\s*:\\s*["']?([\\w.]+)`);
452
+ for (let i = ref.line - 1; i >= (caller?.startLine ?? 1) - 1; i--) {
453
+ const line = lines[i] ?? '';
454
+ const assigned = line.match(declaration);
455
+ if (assigned)
456
+ return assigned[1] ?? assigned[2].match(/^([A-Z][\w.]*)\s*\(/)?.[1] ?? '<unknown>';
457
+ const declared = line.match(annotation)?.[1];
458
+ if (declared)
459
+ return declared;
460
+ }
461
+ return caller?.signature?.match(new RegExp(`\\b${receiver}\\s*:\\s*["']?([\\w.]+)`))?.[1] ?? null;
462
+ }
463
+ /** Read a field's own annotation/initializer, or a constructor parameter assigned to it. */
464
+ function pythonFieldType(receiver, owner, ref, context) {
465
+ const lines = pythonMemberLines(ref.filePath, context);
466
+ const field = receiver.split('.')[1];
467
+ const assignment = new RegExp(`^\\s*(?:self|cls)\\.${field}\\s*(?::\\s*["']?([\\w.]+)["']?)?\\s*=\\s*(.*)$`);
468
+ const annotation = new RegExp(`^\\s*(?:(?:self|cls)\\.)?${field}\\s*:\\s*["']?([\\w.]+)`);
469
+ const methods = context.getNodesInFile(ref.filePath).filter(n => n.kind === 'method' &&
470
+ n.qualifiedName.startsWith(`${owner.qualifiedName}::`));
471
+ const types = new Set();
472
+ for (let i = owner.startLine; i < owner.endLine; i++) {
473
+ const method = methods.find(n => n.startLine <= i + 1 && n.endLine >= i + 1);
474
+ if (method && method.name !== '__init__' && method.id !== ref.fromNodeId)
475
+ continue;
476
+ if (method?.id === ref.fromNodeId && i + 1 > ref.line)
477
+ continue;
478
+ const line = lines[i] ?? '';
479
+ const declared = !method || /^\s*(?:self|cls)\./.test(line) ? line.match(annotation)?.[1] : undefined;
480
+ if (declared)
481
+ types.add(declared);
482
+ const assigned = line.match(assignment);
483
+ if (!assigned)
484
+ continue;
485
+ if (assigned[1]) {
486
+ types.add(assigned[1]);
487
+ continue;
488
+ }
489
+ const constructor = assigned[2].match(/^([A-Z][\w.]*)\s*\(/)?.[1];
490
+ if (constructor) {
491
+ types.add(constructor);
492
+ continue;
493
+ }
494
+ const param = assigned[2].trim();
495
+ if (method && /^\w+$/.test(param)) {
496
+ const signature = method.signature ?? '';
497
+ const type = signature.match(new RegExp(`\\b${param}\\s*:\\s*["']?([\\w.]+)`))?.[1];
498
+ if (type)
499
+ types.add(type);
500
+ }
501
+ else {
502
+ types.add('<unknown>');
503
+ }
504
+ }
505
+ // Conflicting assignments are known-but-ambiguous, never a name-only fallback.
506
+ return types.size === 1 ? [...types][0] : types.size > 1 ? '<ambiguous>' : null;
204
507
  }
205
508
  /**
206
509
  * Resolve a function-as-value reference (#756) — a function name used as a
207
510
  * callback/function-pointer value (`register(handler)`, `o->cb = handler`,
208
511
  * `{ .cb = handler }`, `signal(SIGINT, handler)`). The ONLY strategy allowed
209
512
  * for `function_ref` refs: exact name, function/method targets only, same
210
- * language family, same-file first, and cross-file only when the match is
211
- * UNIQUE. No fuzzy fallback, no qualified-name walking — a wrong callback
212
- * edge is worse than none.
513
+ * language family, same-file first for bare names, and unique-only cross-file.
514
+ * Member values use receiver/type/import scope before a unique-name fallback.
515
+ * A wrong callback edge is worse than none.
213
516
  */
214
517
  function matchFunctionRef(ref, context) {
215
518
  // `this.<member>` refs are resolved ONLY by the class-scoped resolver in
216
519
  // resolveOne (resolveThisMemberFnRef) — never by name matching here.
217
520
  if (ref.referenceName.startsWith('this.'))
218
521
  return null;
522
+ if ((ref.language === 'python' || ref.language === 'go') && ref.referenceName.includes('.')) {
523
+ return matchMemberFunctionRef(ref, context);
524
+ }
219
525
  // In JS/TS/Python a bare identifier can never be a method value (methods
220
526
  // are only reachable through a receiver — `this.m` / `self.m` /
221
527
  // `Cls.m`), so bare fn-refs match FUNCTIONS only. This also sidesteps the
@@ -345,6 +651,8 @@ function matchFunctionRef(ref, context) {
345
651
  }
346
652
  return null;
347
653
  }
654
+ /** Languages with no nested named functions: nesting in the graph is never a scope. */
655
+ const NO_NESTED_FUNCTIONS = new Set(['c', 'cpp']);
348
656
  /**
349
657
  * A function nested inside another FUNCTION is only callable from within its
350
658
  * container — Python, JS/TS, and every closure language scope it lexically.
@@ -359,6 +667,15 @@ function matchFunctionRef(ref, context) {
359
667
  function isLexicallyReachable(candidate, ref, context) {
360
668
  if (candidate.kind !== 'function')
361
669
  return true;
670
+ // C and C++ have no nested named functions, so a function the graph shows
671
+ // inside another is an extraction artifact, not a scope: tree-sitter-c
672
+ // cannot parse a macro call whose arguments are designated initializers
673
+ // (betaflight's `RESET_CONFIG(pidProfile_t, pidProfile, .pid = {…})`), and
674
+ // its error recovery runs the enclosing function_definition to the end of
675
+ // the file, nesting every function after it. Trusting that nesting rejected
676
+ // 117 real calls into pid.c on that tree; the functions are reachable.
677
+ if (NO_NESTED_FUNCTIONS.has(candidate.language))
678
+ return true;
362
679
  const qn = candidate.qualifiedName;
363
680
  if (!qn || !qn.includes('::'))
364
681
  return true;
@@ -374,6 +691,469 @@ function isLexicallyReachable(candidate, ref, context) {
374
691
  return (ref.filePath === candidate.filePath &&
375
692
  containers.some((p) => ref.line >= p.startLine && ref.line <= p.endLine));
376
693
  }
694
+ /** Languages whose module boundary is `import`/`export` (or CommonJS). */
695
+ const ESM_FAMILY = new Set(['typescript', 'tsx', 'javascript', 'jsx', 'arkts']);
696
+ /**
697
+ * A line-initial `import` statement — the marker that a JS/TS file is a MODULE
698
+ * rather than a classic script. Line-anchored and followed by a name, brace,
699
+ * star or quote, so a dynamic `import(` and the word inside a comment or string
700
+ * do not match.
701
+ */
702
+ const HAS_IMPORT_STATEMENT = /^[ \t]*import[\s{*'"]/m;
703
+ /**
704
+ * Anything the file could offer another file, in every form the extractor's own
705
+ * `isExported` flag misses. `^export` covers the declaration and later forms
706
+ * (`export const`, `export { x }`, `export default x`, `export *`); the
707
+ * CommonJS shapes cover files that never use ESM syntax at all, in both the dot
708
+ * and the bracket form; and `declare global` contributes names to every file
709
+ * whether or not the module exports anything of its own. Kept as a source test
710
+ * rather than a node scan precisely because `isExported` is set only from an
711
+ * `export_statement` ancestor, so `const x = …; export { x }` and
712
+ * `module.exports = { x }` both read as unexported on the node.
713
+ */
714
+ const HAS_ESM_EXPORT = /^[ \t]*export[\s{*]|^[ \t]*declare\s+global\b/m;
715
+ const HAS_CJS_EXPORT = /\bmodule\.exports\b|\bexports\s*[.[]/;
716
+ /**
717
+ * Per-context memo of "this file is a module that exports nothing", asked once
718
+ * per candidate FILE rather than once per reference. Derived from file source,
719
+ * so it drops with the context's file caches — clearNameMatcherMemos deletes it
720
+ * alongside INFER_SCAN_STATES.
721
+ */
722
+ const SEALED_MODULES = new WeakMap();
723
+ /**
724
+ * Whether `filePath` is a JS/TS module that exports NOTHING — an import
725
+ * statement present, no export of any form. No reference from another file can
726
+ * reach any binding in such a file, so every one of its symbols is a false
727
+ * candidate for a cross-file name match.
728
+ *
729
+ * This is the general case behind a package name capturing a same-named local:
730
+ * on `vitejs/vite`, 157 cross-file `imports` refs — every `import { defineConfig
731
+ * } from 'vite'` in the playground and the create-vite templates — resolved onto
732
+ * `playground/ssr-html/test-stacktrace.js::vite`, which is `const vite = await
733
+ * createServer(…)` at module scope in a file with zero exports. The existing
734
+ * guards cannot see it: `isLexicallyReachable` returns early for any candidate
735
+ * that is not a `function`, and the bare-import guard correctly declines because
736
+ * `vite` IS a workspace member, so the specifier really is project-local. What
737
+ * is wrong is only which node the name lands on.
738
+ *
739
+ * Deliberately narrow on three axes, because each is a class this would
740
+ * otherwise resolve wrongly in the opposite direction:
741
+ *
742
+ * - **A classic script is exempt.** Requiring an `import` statement means a
743
+ * non-module `.js` file — concatenated globals, a browser `<script>` — keeps
744
+ * its cross-file matches, where a top-level binding genuinely is reachable.
745
+ * - **CommonJS is exempt.** `module.exports` and `exports.x` are matched as
746
+ * exports, so a CJS file is never sealed.
747
+ * - **Other languages are exempt.** Go, Python, Java and the rest have no
748
+ * equivalent boundary, and several extractors hardcode `isExported`.
749
+ */
750
+ function isSealedModule(filePath, context) {
751
+ let memo = SEALED_MODULES.get(context);
752
+ if (!memo) {
753
+ memo = new Map();
754
+ SEALED_MODULES.set(context, memo);
755
+ }
756
+ const hit = memo.get(filePath);
757
+ if (hit !== undefined)
758
+ return hit;
759
+ // CommonJS assignments can execute inside template interpolations, which the
760
+ // masker blanks. Keep the conservative raw-source exemption for those forms.
761
+ // Cheapest disqualifiers first: nearly every module exports a node (asked
762
+ // without reading or decoding the file), and masking the source is only
763
+ // needed to rule out the ones that don't. (The masker only blanks text, so
764
+ // no `import` in the source means none in code.)
765
+ const exportsNode = context.fileHasExportedNode
766
+ ? context.fileHasExportedNode(filePath)
767
+ : context.getNodesInFile(filePath).some((n) => n.isExported);
768
+ const source = exportsNode ? null : context.readFile(filePath);
769
+ const sealed = !exportsNode && source !== null && source.includes('import') &&
770
+ !HAS_CJS_EXPORT.test(source) &&
771
+ (() => {
772
+ const code = (0, strip_comments_1.blankStringContents)((0, strip_comments_1.stripCommentsForRegex)(source, 'typescript'));
773
+ return HAS_IMPORT_STATEMENT.test(code) && !HAS_ESM_EXPORT.test(code);
774
+ })();
775
+ memo.set(filePath, sealed);
776
+ return sealed;
777
+ }
778
+ /**
779
+ * Whether `candidate` can be named by a reference in `ref`'s file at all.
780
+ * Both name-based strategies validate their chosen candidate. Removing an
781
+ * unreachable candidate before ranking can promote an unrelated runner-up;
782
+ * rejecting the chosen target must leave the reference unresolved instead.
783
+ */
784
+ function isCrossFileReachable(candidate, ref, context) {
785
+ if (ref.language !== 'markdown' && candidate.language === 'markdown')
786
+ return false;
787
+ if (ref.referenceKind === 'calls' && ESM_FAMILY.has(candidate.language) &&
788
+ (candidate.kind === 'constant' || candidate.kind === 'variable') &&
789
+ /^=\s*require\s*\(\s*(['"])[^'"]+\.json\1\s*\)\s*;?\s*$/.test(candidate.signature ?? ''))
790
+ return false;
791
+ return (candidate.filePath === ref.filePath ||
792
+ !ESM_FAMILY.has(candidate.language) ||
793
+ !isSealedModule(candidate.filePath, context));
794
+ }
795
+ /**
796
+ * Languages in which `visibility: 'private'` on a definition means no other
797
+ * FILE can name it: a Kotlin `private fun` is file- or class-local, and the
798
+ * same holds for Java, C#, Swift, Scala, Dart and PHP members.
799
+ */
800
+ const PRIVATE_IS_FILE_LOCAL = new Set(['kotlin', 'java', 'csharp', 'swift', 'scala', 'dart', 'php']);
801
+ /** Per-context memo: node id → "this C/C++ function is declared `static`". */
802
+ const C_STATIC_MEMO = new WeakMap();
803
+ /**
804
+ * A C/C++ file that IS a translation unit. A `static` defined here is local
805
+ * to it. A `static` (typically `static inline`) in a header is a different
806
+ * thing: the header is textually included, so the function exists in every
807
+ * unit that includes it and is callable from each — MAVLink's generated
808
+ * `mavlink_msg_*.h` are nothing but such functions, 4,306 real calls on one
809
+ * betaflight tree.
810
+ */
811
+ const C_SOURCE_EXT = /\.(c|cc|cpp|cxx|c\+\+|m|mm)$/i;
812
+ /**
813
+ * Whether a C/C++ function definition carries the `static` storage class —
814
+ * read from its first source line(s), since the extractor records no storage
815
+ * class and the kernel arm would need the same field. `static` on the line
816
+ * above the name (`static void\nfoo(void)`) is the common alternative layout.
817
+ */
818
+ function isStaticCFunction(candidate, context) {
819
+ let memo = C_STATIC_MEMO.get(context);
820
+ if (!memo) {
821
+ memo = new Map();
822
+ C_STATIC_MEMO.set(context, memo);
823
+ }
824
+ const hit = memo.get(candidate.id);
825
+ if (hit !== undefined)
826
+ return hit;
827
+ const lines = context.getFileLines?.(candidate.filePath) ?? context.readFile(candidate.filePath)?.split('\n') ?? [];
828
+ const head = [lines[candidate.startLine - 2] ?? '', lines[candidate.startLine - 1] ?? ''].join('\n');
829
+ const isStatic = /(^|[\s;}])static\s/.test(head);
830
+ memo.set(candidate.id, isStatic);
831
+ return isStatic;
832
+ }
833
+ /** Per-context memo: node id → "this Rust method implements a trait". */
834
+ const RUST_TRAIT_IMPL_MEMO = new WeakMap();
835
+ /**
836
+ * Whether a Rust method sits in an `impl Trait for Type` block. Such a method
837
+ * carries no `pub` — the trait decides its visibility — so the extractor
838
+ * records it as private; it is reachable wherever the trait is. Read from the
839
+ * nearest enclosing `impl` header above the method, memoised per node.
840
+ */
841
+ function isRustTraitImplMethod(candidate, context) {
842
+ if (candidate.kind !== 'method')
843
+ return false;
844
+ let memo = RUST_TRAIT_IMPL_MEMO.get(context);
845
+ if (!memo) {
846
+ memo = new Map();
847
+ RUST_TRAIT_IMPL_MEMO.set(context, memo);
848
+ }
849
+ const hit = memo.get(candidate.id);
850
+ if (hit !== undefined)
851
+ return hit;
852
+ const lines = context.getFileLines?.(candidate.filePath) ?? context.readFile(candidate.filePath)?.split('\n') ?? [];
853
+ let isTrait = false;
854
+ for (let i = candidate.startLine - 2; i >= 0; i--) {
855
+ const line = lines[i] ?? '';
856
+ if (/^\s*(pub(\([^)]*\))?\s+)?(unsafe\s+)?impl\b/.test(line)) {
857
+ isTrait = /\sfor\s/.test(line.replace(/\/\/.*$/, ''));
858
+ break;
859
+ }
860
+ // A top-level item above the method means it was not inside an impl.
861
+ if (/^(pub(\([^)]*\))?\s+)?(fn|struct|enum|mod|trait|const|static|type)\b/.test(line))
862
+ break;
863
+ }
864
+ memo.set(candidate.id, isTrait);
865
+ return isTrait;
866
+ }
867
+ /**
868
+ * The directory a Rust file's private items are visible from: the file's own
869
+ * module subtree. `src/net.rs` and `src/net/mod.rs` own `src/net/`; a crate
870
+ * root (`lib.rs` / `main.rs`) owns its directory. A child module reaches its
871
+ * ancestors' private items (`super::`), a sibling or another crate never does.
872
+ */
873
+ function rustModuleDir(filePath) {
874
+ const base = path.posix.basename(filePath);
875
+ const dir = path.posix.dirname(filePath);
876
+ if (base === 'mod.rs' || base === 'lib.rs' || base === 'main.rs')
877
+ return dir;
878
+ return path.posix.join(dir, base.replace(/\.rs$/, ''));
879
+ }
880
+ /**
881
+ * Whether `candidate` can be NAMED from a reference in `ref`'s file at all,
882
+ * given what its language says about the definition's visibility. A
883
+ * definition the language makes file-local is not a candidate for a
884
+ * cross-file name match, however well the names agree:
885
+ *
886
+ * - **C / C++**: a `static` function defined in a SOURCE file is local to
887
+ * that translation unit; one in a header is part of every unit that
888
+ * includes it and stays visible. On a 2,109-file betaflight tree 145
889
+ * cross-file calls resolved onto a `static` in another `.c` (#1730) —
890
+ * `usbd_get_descriptor` onto the `static get_device_descriptor` of
891
+ * whichever USB class file ranked first.
892
+ * - **Kotlin, Java, C#, Swift, Scala, Dart, PHP**: `private` is class- or
893
+ * file-local. An Android `editor.apply()` resolved onto an unrelated class's
894
+ * `private fun apply`.
895
+ * - **Go**: an unexported (lowercase) identifier is package-local, and a
896
+ * package is a directory. Judged by the name's case: the extractor's
897
+ * `isExported` is unset for every Go method.
898
+ * - **Rust**: a non-`pub` item is visible to its module and that module's
899
+ * descendants, never to a sibling module or another crate — `.count()` on
900
+ * an iterator resolved onto a `fn count` in a different crate. A method in
901
+ * an `impl Trait for Type` block has the trait's visibility, not `private`.
902
+ * - **JS / TS / ArkTS**: a binding in a module that exports nothing (an
903
+ * `import` present, no `export` / CommonJS / `declare global`) is sealed —
904
+ * the vite playground's `const vite = await createServer(…)` took 157
905
+ * `import { defineConfig } from 'vite'` edges (#1719). Classic scripts,
906
+ * CommonJS, later `export { … }`, and ambient globals stay visible.
907
+ *
908
+ * Same-file candidates are always visible. Applied by ReferenceResolver to
909
+ * the target the whole name-matching pipeline settled on, so a rejection ends
910
+ * the reference unresolved: declining inside matchByExactName instead let the
911
+ * ref fall through to matchFuzzy, which then committed to a same-language
912
+ * namesake the ranking had passed over — eight such edges on one tree, all
913
+ * onto a local `const fail = …` arrow the graph does not hold. matchFuzzy
914
+ * checks its own survivor as well, since nothing runs after it.
915
+ */
916
+ function isVisibleAcrossFiles(candidate, ref, context) {
917
+ if (candidate.filePath === ref.filePath)
918
+ return true;
919
+ const lang = candidate.language;
920
+ if (lang === 'c' || lang === 'cpp') {
921
+ return (candidate.kind !== 'function' ||
922
+ !C_SOURCE_EXT.test(candidate.filePath) ||
923
+ !isStaticCFunction(candidate, context));
924
+ }
925
+ if (lang === 'go') {
926
+ // By the name's first letter, not the extractor's flag: the flag is unset
927
+ // for every Go method, exported or not.
928
+ return /^[A-Z]/.test(candidate.name) || path.posix.dirname(candidate.filePath) === path.posix.dirname(ref.filePath);
929
+ }
930
+ if (lang === 'rust') {
931
+ if (candidate.visibility !== 'private')
932
+ return true;
933
+ if (isRustTraitImplMethod(candidate, context))
934
+ return true;
935
+ const owner = rustModuleDir(candidate.filePath);
936
+ return ref.filePath.startsWith(owner + '/');
937
+ }
938
+ if (PRIVATE_IS_FILE_LOCAL.has(lang))
939
+ return candidate.visibility !== 'private';
940
+ // JS/TS/ArkTS sealed modules + markdown/JSON call-target guards (#1719).
941
+ // Same predicate matchByExactName / matchFuzzy apply to their survivors so a
942
+ // rejection here cannot fall through to a promoted runner-up.
943
+ return isCrossFileReachable(candidate, ref, context);
944
+ }
945
+ const JS_FAMILY = new Set(['typescript', 'tsx', 'javascript', 'jsx']);
946
+ /**
947
+ * Whether a JS/TS `calls` ref is a RECEIVER-LESS call — `serialize(x)`, not
948
+ * `this.serialize(x)` / `obj.serialize(x)`. The extractor emits `this.m()`
949
+ * and `super.m()` under the bare method name, so the receiver is read back
950
+ * from the call site's own line: the text at the ref's column is the call
951
+ * expression, and it starts with the name itself only when nothing precedes
952
+ * it. In JS/TS a bare call can never bind to a class method (methods need a
953
+ * receiver), so a `method` node is not a candidate for it (#1714) — the
954
+ * enclosing method itself least of all, which the same-file proximity term
955
+ * used to pick over the module-scope function the call actually means.
956
+ */
957
+ function isBareJsCall(ref, context) {
958
+ return JS_FAMILY.has(ref.language) && isReceiverLessCall(ref, context);
959
+ }
960
+ /**
961
+ * Whether a Go `calls` ref is receiver-less — `relogin(ctx)`, not
962
+ * `l.relogin(ctx)`. A Go method is only reachable through a value or a method
963
+ * expression, so a bare call (a func parameter, a local func value, a
964
+ * package-level function) is never a method, in its own package or in one the
965
+ * file does not import (#1857). Read from the source line like the JS/TS
966
+ * check, because `pkg.Factory().Method()` reaches the resolver as a bare
967
+ * `Method` ref too.
968
+ */
969
+ function isBareGoCall(ref, context) {
970
+ return ref.language === 'go' && isReceiverLessCall(ref, context);
971
+ }
972
+ function isReceiverLessCall(ref, context) {
973
+ if (ref.referenceKind !== 'calls')
974
+ return false;
975
+ if (ref.referenceName.includes('.'))
976
+ return false;
977
+ const line = context.getFileLines?.(ref.filePath)?.[ref.line - 1]
978
+ ?? context.readFile(ref.filePath)?.split('\n')[ref.line - 1];
979
+ if (line === undefined)
980
+ return false;
981
+ // `^<name>\s*[(<]` at the call's column, without compiling a pattern per call.
982
+ if (!line.startsWith(ref.referenceName, ref.column))
983
+ return false;
984
+ CALL_OPENER.lastIndex = ref.column + ref.referenceName.length;
985
+ if (!CALL_OPENER.test(line))
986
+ return false;
987
+ // Nothing but whitespace, an operator or an opener may precede a bare call:
988
+ // read the text before the column backwards, past trailing whitespace,
989
+ // instead of end-anchoring a pattern that scans the prefix from its start.
990
+ let end = Math.min(ref.column, line.length);
991
+ while (end > 0 && WHITESPACE.test(line[end - 1]))
992
+ end--;
993
+ if (end === 0 || !RECEIVER_TAIL_CHAR.test(line[end - 1]))
994
+ return true;
995
+ let start = end;
996
+ while (start > 0 && WORD_CHAR.test(line[start - 1]))
997
+ start--;
998
+ return BARE_CALL_KEYWORDS.has(line.slice(start, end));
999
+ }
1000
+ /** `\s*[(<]` from a given index (sticky). */
1001
+ const CALL_OPENER = /\s*[(<]/y;
1002
+ const WHITESPACE = /\s/;
1003
+ const WORD_CHAR = /\w/;
1004
+ /** A character that ends a receiver: `.`, a word character, `$`, `]` or `)`. */
1005
+ const RECEIVER_TAIL_CHAR = /[.\w$\])]/;
1006
+ /** Keywords after which a name starts an expression, so the call has no receiver. */
1007
+ const BARE_CALL_KEYWORDS = new Set([
1008
+ 'return', 'await', 'yield', 'typeof', 'void', 'new', 'else', 'case', 'throw', 'in', 'of', 'instanceof', 'go', 'defer',
1009
+ ]);
1010
+ /** Per-context memo: `file\0name` → "the file binds this name locally". */
1011
+ const LOCAL_BINDING_MEMO = new WeakMap();
1012
+ const LOCAL_BINDING_SITES = new WeakMap();
1013
+ const LOCAL_BINDING_SITES_KEEP = 16;
1014
+ const VAR_DECL_SITE = /\b(?:const|let|var)\s/g;
1015
+ const FN_DECL_SITE = /\b(?:function|class)\s/g;
1016
+ function localBindingSites(filePath, source, context) {
1017
+ let cache = LOCAL_BINDING_SITES.get(context);
1018
+ if (!cache) {
1019
+ cache = new Map();
1020
+ LOCAL_BINDING_SITES.set(context, cache);
1021
+ }
1022
+ let sites = cache.get(filePath);
1023
+ if (!sites) {
1024
+ const offsets = (re) => Array.from(source.matchAll(re), (m) => m.index);
1025
+ const arrows = [];
1026
+ for (let a = source.indexOf('=>'); a !== -1; a = source.indexOf('=>', a + 2))
1027
+ arrows.push(a);
1028
+ sites = { varDecls: offsets(VAR_DECL_SITE), fnDecls: offsets(FN_DECL_SITE), arrows };
1029
+ if (cache.size >= LOCAL_BINDING_SITES_KEEP)
1030
+ cache.delete(cache.keys().next().value);
1031
+ cache.set(filePath, sites);
1032
+ }
1033
+ return sites;
1034
+ }
1035
+ /** Sticky binding patterns by name — the same names recur file after file. */
1036
+ const LOCAL_BINDING_PATTERNS = new Map();
1037
+ const LOCAL_BINDING_PATTERNS_CAP = 4096;
1038
+ const JS_BINDING_NAME = /^[\w$]+$/;
1039
+ const ARROW_HEAD_CHAR = /[\w$.]/;
1040
+ const IMPORT_BINDING_VALUE = /^\s*(?:await\s+)?(?:require|import)\s*\(/;
1041
+ function localBindingPatterns(name, flags) {
1042
+ const n = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1043
+ return {
1044
+ // `const { name } = require('./m')` / `= await import('./m')` binds an IMPORT,
1045
+ // not a shadow: the symbol lives in the other file and the call means it.
1046
+ decl: new RegExp('\\b(?:const|let|var)\\s+(?:' + n + '\\b|[{\\[][^;=]*?\\b' + n + '\\b[^;=]*?[}\\]])\\s*(?:=\\s*([^;\\n]*))?', flags),
1047
+ fn: new RegExp('\\b(?:function|class)\\s+' + n + '\\b', flags),
1048
+ // a parameter: every token before the name in the list is itself a
1049
+ // parameter (identifier, optional type, optional default) — so a string
1050
+ // argument containing the word cannot match.
1051
+ // Each earlier parameter has exactly one parse: its first non-space
1052
+ // character after the identifier picks the type (`?`/`:`), default (`=`)
1053
+ // or bare alternative. Written as `(type)?(default)?\s*`, the same
1054
+ // strings split several ways per parameter, and a failing search
1055
+ // backtracked through every combination — 30-40s per name on a vscode
1056
+ // test file whose helper takes nine `name: T = value` parameters.
1057
+ param: new RegExp('\\(\\s*(?:(?:\\.\\.\\.)?[\\w$]+(?:\\s*(?:\\?\\s*)?:[^,()]+|\\s*=[^,()]+|\\s*),\\s*)*' +
1058
+ n + '\\b(?:\\s*\\??\\s*:[^,()]*)?(?:\\s*=[^,()]*)?(?:\\s*,\\s*[^()]*)?\\)\\s*(?::[^=;{]*)?(?:=>|\\{)', flags),
1059
+ };
1060
+ }
1061
+ /**
1062
+ * Whether a JS/TS file binds `name` itself — as a `const`/`let`/`var`/
1063
+ * `function`/`class` declaration (destructuring included) or as a parameter
1064
+ * of a function or arrow. Such a binding shadows every same-named symbol in
1065
+ * other files, so a bare call to it has no cross-file candidate: the
1066
+ * `resolve` of `new Promise((resolve, reject) => …)`, a spec's
1067
+ * `const transform = await makeTransform()`, a factory's `const now =
1068
+ * options.now || (() => new Date())`. None of these is a node the graph
1069
+ * holds (a parameter, a const bound to a call result), so without this the
1070
+ * matcher hands the call to whichever other file defines the name — and
1071
+ * once methods stop being candidates for a bare call (#1714), the function
1072
+ * that was out-ranked steps in. Read from source, memoised per file+name.
1073
+ */
1074
+ function isLocallyBoundJsName(name, filePath, context) {
1075
+ let memo = LOCAL_BINDING_MEMO.get(context);
1076
+ if (!memo) {
1077
+ memo = new Map();
1078
+ LOCAL_BINDING_MEMO.set(context, memo);
1079
+ }
1080
+ const key = filePath + '\0' + name;
1081
+ const hit = memo.get(key);
1082
+ if (hit !== undefined)
1083
+ return hit;
1084
+ const source = context.readFile(filePath) ?? '';
1085
+ const bound = JS_BINDING_NAME.test(name)
1086
+ ? bindsAtSites(source, name, localBindingSites(filePath, source, context))
1087
+ : bindsAnywhere(source, name);
1088
+ memo.set(key, bound);
1089
+ return bound;
1090
+ }
1091
+ /** isLocallyBoundJsName's patterns, searched through the whole source. */
1092
+ function bindsAnywhere(source, name) {
1093
+ const { decl, fn, param } = localBindingPatterns(name, 'g');
1094
+ for (const m of source.matchAll(decl)) {
1095
+ if (!IMPORT_BINDING_VALUE.test(m[1] ?? ''))
1096
+ return true;
1097
+ }
1098
+ const n = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1099
+ return fn.test(source) || param.test(source) || new RegExp('(?:^|[^\\w$.])' + n + '\\s*=>').test(source);
1100
+ }
1101
+ /**
1102
+ * bindsAnywhere for a plain identifier, tried only where a match can start:
1103
+ * a declaration at its keyword (in order, resuming past each match exactly as
1104
+ * the global search does), a parameter at the `(` its list opens with — the
1105
+ * last `(` before an occurrence of the name, with no `)` between, since no
1106
+ * earlier parameter can hold a parenthesis — and `name =>` at each arrow.
1107
+ */
1108
+ function bindsAtSites(source, name, sites) {
1109
+ let patterns = LOCAL_BINDING_PATTERNS.get(name);
1110
+ if (!patterns) {
1111
+ patterns = localBindingPatterns(name, 'y');
1112
+ if (LOCAL_BINDING_PATTERNS.size >= LOCAL_BINDING_PATTERNS_CAP) {
1113
+ LOCAL_BINDING_PATTERNS.delete(LOCAL_BINDING_PATTERNS.keys().next().value);
1114
+ }
1115
+ LOCAL_BINDING_PATTERNS.set(name, patterns);
1116
+ }
1117
+ const { decl, fn, param } = patterns;
1118
+ let from = 0;
1119
+ for (const at of sites.varDecls) {
1120
+ if (at < from)
1121
+ continue;
1122
+ decl.lastIndex = at;
1123
+ const m = decl.exec(source);
1124
+ if (!m)
1125
+ continue;
1126
+ from = at + m[0].length;
1127
+ if (!IMPORT_BINDING_VALUE.test(m[1] ?? ''))
1128
+ return true;
1129
+ }
1130
+ for (const at of sites.fnDecls) {
1131
+ fn.lastIndex = at;
1132
+ if (fn.test(source))
1133
+ return true;
1134
+ }
1135
+ let tried = -1;
1136
+ for (let at = source.indexOf(name); at !== -1; at = source.indexOf(name, at + 1)) {
1137
+ const open = at > 0 ? source.lastIndexOf('(', at - 1) : -1;
1138
+ if (open < 0 || open === tried || source.lastIndexOf(')', at - 1) > open)
1139
+ continue;
1140
+ tried = open;
1141
+ param.lastIndex = open;
1142
+ if (param.test(source))
1143
+ return true;
1144
+ }
1145
+ // `name =>`: the name ends where the whitespace before the arrow starts.
1146
+ for (const arrow of sites.arrows) {
1147
+ let end = arrow;
1148
+ while (end > 0 && WHITESPACE.test(source[end - 1]))
1149
+ end--;
1150
+ const start = end - name.length;
1151
+ if (start >= 0 && source.startsWith(name, start) && (start === 0 || !ARROW_HEAD_CHAR.test(source[start - 1]))) {
1152
+ return true;
1153
+ }
1154
+ }
1155
+ return false;
1156
+ }
377
1157
  /**
378
1158
  * Try to resolve a reference by exact name match
379
1159
  */
@@ -387,15 +1167,62 @@ function matchByExactName(ref, context) {
387
1167
  // unresolved import refs each scored K same-named import candidates through
388
1168
  // findBestMatch — O(K²) per package, the dominant cost of "Resolving refs" on
389
1169
  // large import-heavy (front-end + back-end) repos (#915).
390
- const candidates = applyLanguageGate(context.getNodesByName(ref.referenceName), ref)
391
- .filter((n) => n.kind !== 'import')
1170
+ const bareJs = isBareJsCall(ref, context);
1171
+ const bareGo = isBareGoCall(ref, context);
1172
+ if (bareJs) {
1173
+ const storeAction = matchJsStoreBindingCall(ref, context);
1174
+ if (storeAction)
1175
+ return storeAction;
1176
+ }
1177
+ // Every rule below judges one candidate on its own, so they run as ONE pass,
1178
+ // the kind/language checks before the ones that read source: a common name
1179
+ // has thousands of same-named nodes, and a chain of filters copied that
1180
+ // list once per rule for every reference.
1181
+ const valueRef = ref.referenceKind === 'references' || ref.referenceKind === 'function_ref';
1182
+ const importRef = ref.referenceKind === 'imports';
1183
+ const inheritanceRef = (0, types_1.isInheritanceRef)(ref);
1184
+ const sameName = context.getNodesByName(ref.referenceName);
1185
+ // `NAME(...)` where NAME is a function-like macro somewhere in the project is
1186
+ // an expansion or a call to a same-named function — never the macro itself
1187
+ // (#1839), and never a type that happens to share the name (#2070: expat's
1188
+ // `PREFIX(scanRef)(…)` bound to an unrelated `struct PREFIX`). Keep
1189
+ // upstream's language gate on the chosen result.
1190
+ const cMacroCall = ref.referenceKind === 'calls' && (ref.language === 'c' || ref.language === 'cpp') &&
1191
+ sameName.some((n) => n.kind === 'constant' && types_1.CPP_DEFINE_SIGNATURE.test(n.signature ?? ''));
1192
+ const candidates = sameName.filter((n) => !(cMacroCall && n.kind !== 'function' && n.kind !== 'method') &&
1193
+ // Type/value references retain same-family eligibility: a native namesake
1194
+ // must not hide the actual web type. Calls still gate only the winner.
1195
+ (!valueRef || sameLanguageFamily(n.language, ref.language)) &&
1196
+ n.kind !== 'import' &&
1197
+ // A receiver-less JS/TS or Go call cannot reach a method (#1714, #1857).
1198
+ !((bareJs || bareGo) && n.kind === 'method') &&
1199
+ // An `extends`/`implements` ref names a supertype, so anything that can't
1200
+ // BE one is not a candidate at all. This is eligibility, not
1201
+ // ranking: kind is only a scoring bonus below (and none is awarded for
1202
+ // inheritance refs), so without this a same-named `enum_member` outranked
1203
+ // the real `trait`, and as the sole candidate was adopted outright by the
1204
+ // single-match shortcut. Restricting the pool BEFORE ranking lets the
1205
+ // legitimate supertype win instead of merely dropping the false edge.
1206
+ (!inheritanceRef || (0, types_1.isSupertypeTarget)(n)) &&
1207
+ // Likewise for `imports`: a member that only exists inside a type is not
1208
+ // importable, so it is not a candidate. Without this a `path`/`id`/`url`
1209
+ // import resolved to some interface's same-named property.
1210
+ (!importRef || (0, types_1.isImportableKind)(n.kind)) &&
392
1211
  // Nested locals are only reachable from inside their container (#1230).
393
- .filter((n) => isLexicallyReachable(n, ref, context));
1212
+ isLexicallyReachable(n, ref, context) &&
1213
+ // Preserve import ranking; calls reject the winner without promoting another.
1214
+ (!importRef || n.filePath === ref.filePath ||
1215
+ !ESM_FAMILY.has(n.language) || !isSealedModule(n.filePath, context)) &&
1216
+ // A name the file binds itself (a parameter, a const) shadows every other
1217
+ // file's symbol of that name, so a bare call has no cross-file candidate.
1218
+ !(bareJs && n.filePath !== ref.filePath && isLocallyBoundJsName(ref.referenceName, ref.filePath, context)));
394
1219
  if (candidates.length === 0) {
395
1220
  return null;
396
1221
  }
397
1222
  // If only one match, use it — but penalize cross-language matches
398
1223
  if (candidates.length === 1) {
1224
+ if (!isCrossFileReachable(candidates[0], ref, context))
1225
+ return null;
399
1226
  const isCrossLanguage = candidates[0].language !== ref.language;
400
1227
  return {
401
1228
  original: ref,
@@ -414,7 +1241,7 @@ function matchByExactName(ref, context) {
414
1241
  }
415
1242
  // Multiple matches - try to narrow down
416
1243
  const bestMatch = findBestMatch(ref, candidates, context);
417
- if (bestMatch) {
1244
+ if (bestMatch && isCrossFileReachable(bestMatch, ref, context)) {
418
1245
  // Lower confidence when the match is from a distant/unrelated module
419
1246
  const proximity = computePathProximity(ref.filePath, bestMatch.filePath);
420
1247
  const confidence = proximity >= 30 ? 0.7 : 0.4;
@@ -514,6 +1341,11 @@ function matchByQualifiedName(ref, context) {
514
1341
  }
515
1342
  return null;
516
1343
  }
1344
+ /** A node a `Receiver.method()` call can name as the method's owning type. */
1345
+ function isMethodOwnerKind(n) {
1346
+ return n.kind === 'class' || n.kind === 'struct' || n.kind === 'union' || n.kind === 'interface' ||
1347
+ (n.language === 'scala' && n.kind === 'module');
1348
+ }
517
1349
  /**
518
1350
  * When a symbol name is ambiguous across files, prefer the candidate(s) declared
519
1351
  * in the call site's own file, keeping the rest in their original order (#1079).
@@ -584,7 +1416,10 @@ function resolveObjectLiteralMember(container, member, ref, context, confidence,
584
1416
  const valueMember = (n) => callable(n) || n.kind === 'property' || n.kind === 'variable' || n.kind === 'constant';
585
1417
  const accepts = ref.referenceKind === 'calls' ? callable : valueMember;
586
1418
  const inside = inFile.filter((n) => n.id !== container.id && rangeWithin(n, container));
587
- let candidates = inside.filter((n) => n.name === member && accepts(n));
1419
+ const property = objectLiteralProperty(container, member, context);
1420
+ if (property === null || property?.binding)
1421
+ return null;
1422
+ let candidates = inside.filter((n) => n.name === member && accepts(n) && (!property || property.contains(n)));
588
1423
  if (candidates.length === 0)
589
1424
  return null;
590
1425
  // Drop a candidate nested inside ANOTHER callable's body within the literal
@@ -611,6 +1446,144 @@ function resolveObjectLiteralMember(container, member, ref, context, confidence,
611
1446
  resolvedBy,
612
1447
  };
613
1448
  }
1449
+ /**
1450
+ * The binding an object-literal member names when it is a shorthand property
1451
+ * (`{ getUser }`) or a pair whose value is a bare identifier (`{ getUser:
1452
+ * fetchUser }`) — the usual way an API module assembles its namespace from
1453
+ * standalone functions (#1932). Only the literal's own members count: a member
1454
+ * of a nested object, a word inside a member's body, a comment or a string
1455
+ * never donates one. Null when the member is absent, or when its value is not
1456
+ * a bare identifier (`{ fn: 1 }` names nothing).
1457
+ */
1458
+ function objectLiteralMemberBinding(container, member, context) {
1459
+ return objectLiteralProperty(container, member, context)?.binding ?? null;
1460
+ }
1461
+ /** The last own property wins; an unknown spread/computed key invalidates earlier evidence. */
1462
+ function objectLiteralProperty(container, member, context) {
1463
+ const lines = context.getFileLines?.(container.filePath) ?? context.readFile(container.filePath)?.split('\n');
1464
+ if (!lines)
1465
+ return undefined;
1466
+ const extentLines = lines.slice(container.startLine - 1, container.endLine);
1467
+ if (!extentLines.length)
1468
+ return undefined;
1469
+ extentLines[extentLines.length - 1] = extentLines[extentLines.length - 1].slice(0, container.endColumn);
1470
+ extentLines[0] = extentLines[0].slice(container.startColumn);
1471
+ const extent = (0, strip_comments_1.stripCommentsForRegex)(extentLines.join('\n'), 'typescript');
1472
+ const code = (0, strip_comments_1.blankStringContents)(extent);
1473
+ // Start at THIS declarator, including its columns, never a sibling on the same line.
1474
+ const open = /^[^=]*=\s*(?:(?:Object\.(?:freeze|seal)\s*)?\(\s*)*\{/.exec(code);
1475
+ if (!open)
1476
+ return undefined;
1477
+ const members = [];
1478
+ let depth = 0;
1479
+ let start = open[0].length;
1480
+ for (let i = start; i < code.length; i++) {
1481
+ const ch = code[i];
1482
+ if (ch === '{' || ch === '(' || ch === '[')
1483
+ depth++;
1484
+ else if (ch === ')' || ch === ']')
1485
+ depth--;
1486
+ else if (ch === '}') {
1487
+ if (depth === 0) {
1488
+ members.push({ start, end: i });
1489
+ break;
1490
+ }
1491
+ depth--;
1492
+ }
1493
+ else if (ch === ',' && depth === 0) {
1494
+ members.push({ start, end: i });
1495
+ start = i + 1;
1496
+ }
1497
+ }
1498
+ let selected = null;
1499
+ for (const part of members) {
1500
+ const text = extent.slice(part.start, part.end).trim();
1501
+ if (/^(?:\.\.\.|\[)/.test(text)) {
1502
+ selected = null;
1503
+ continue;
1504
+ }
1505
+ const key = /^(?:(?:async|get|set)\s+)?\*?\s*(?:([A-Za-z_$][\w$]*)|['"]([^'"\\]*)['"])(?=\s*(?:[:(<,=]|$))/.exec(text);
1506
+ if ((key?.[1] ?? key?.[2]) !== member)
1507
+ continue;
1508
+ const value = text.slice(key[0].length).trim();
1509
+ const binding = value === '' ? member : /^:\s*([A-Za-z_$][\w$]*)$/.exec(value)?.[1] ?? null;
1510
+ selected = { ...part, binding };
1511
+ }
1512
+ if (!selected)
1513
+ return null;
1514
+ const offset = (node) => {
1515
+ let result = node.startColumn - container.startColumn;
1516
+ for (let line = container.startLine; line < node.startLine; line++)
1517
+ result += lines[line - 1].length + 1;
1518
+ return result;
1519
+ };
1520
+ const property = selected;
1521
+ return { binding: property.binding, contains: (node) => offset(node) >= property.start && offset(node) < property.end };
1522
+ }
1523
+ /**
1524
+ * Shared lexical lookup for namespace-object aliases (#1932): `api.getUser()` where
1525
+ * `api` is `const api = { getUser }` (or `{ getUser: fetchUser }`) in the
1526
+ * object's own file. The member's function is declared OUTSIDE the literal, so
1527
+ * containment (`resolveObjectLiteralMember`) finds nothing. Follow the binding
1528
+ * the member names — a symbol of this file, else one of its imports — unless a
1529
+ * parameter or nearer declaration shadows that name where the literal is
1530
+ * written (the edge would then name the wrong function).
1531
+ */
1532
+ function resolveObjectLiteralBinding(container, member, ref, context) {
1533
+ const binding = objectLiteralMemberBinding(container, member, context);
1534
+ if (!binding)
1535
+ return null;
1536
+ const at = { ...ref, filePath: container.filePath, language: container.language,
1537
+ fromNodeId: container.id, line: container.startLine, column: container.startColumn };
1538
+ const inFile = context.getNodesInFile(container.filePath);
1539
+ if (inFile.some((n) => (n.kind === 'function' || n.kind === 'method') &&
1540
+ rangeWithin(container, n) && n.signature &&
1541
+ hasParameterBinding(`${n.signature} {`, binding.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))))
1542
+ return null;
1543
+ const lines = context.getFileLines?.(container.filePath) ?? context.readFile(container.filePath)?.split('\n');
1544
+ if (!lines)
1545
+ return null;
1546
+ const code = (0, strip_comments_1.blankStringContents)((0, strip_comments_1.stripCommentsForRegex)(lines.join('\n'), 'typescript'));
1547
+ const offsets = [0];
1548
+ for (let i = 0; i < code.length; i++)
1549
+ if (code[i] === '\n')
1550
+ offsets.push(i + 1);
1551
+ const scopeAt = (node) => {
1552
+ const end = (offsets[node.startLine - 1] ?? code.length) + node.startColumn;
1553
+ const scope = [];
1554
+ for (let i = 0; i < end; i++) {
1555
+ if (code[i] === '{')
1556
+ scope.push(i);
1557
+ else if (code[i] === '}')
1558
+ scope.pop();
1559
+ }
1560
+ return scope;
1561
+ };
1562
+ const scope = scopeAt(container);
1563
+ const callable = (n) => n.kind === 'function' || n.kind === 'method' || n.kind === 'class';
1564
+ const accepts = ref.referenceKind === 'calls'
1565
+ ? callable
1566
+ : (n) => callable(n) || n.kind === 'constant' || n.kind === 'variable' || n.kind === 'component';
1567
+ const locals = inFile
1568
+ .filter((n) => n.name === binding && n.id !== container.id &&
1569
+ ['function', 'class', 'constant', 'variable', 'component'].includes(n.kind))
1570
+ .map((node) => ({ node, scope: scopeAt(node) }))
1571
+ .filter((entry) => entry.scope.every((position, i) => scope[i] === position))
1572
+ .sort((a, b) => b.scope.length - a.scope.length);
1573
+ // Select the lexical binding BEFORE checking callability: a nearer value
1574
+ // shadows an outer function even if that value cannot be called.
1575
+ const local = locals[0]?.node;
1576
+ if (local)
1577
+ return accepts(local)
1578
+ ? { original: ref, targetNodeId: local.id, confidence: 0.85, resolvedBy: 'instance-method' }
1579
+ : null;
1580
+ const imported = context.resolveImport?.({ ...at, referenceName: binding });
1581
+ const target = imported ? context.getNodeById?.(imported.targetNodeId) : null;
1582
+ if (target && accepts(target)) {
1583
+ return { original: ref, targetNodeId: target.id, confidence: 0.85, resolvedBy: 'instance-method' };
1584
+ }
1585
+ return null;
1586
+ }
614
1587
  // Exported for the precedence unit tests (#1079): they assert the
615
1588
  // preferredFqn → same-file → matches[0] ordering directly.
616
1589
  function resolveMethodOnType(typeName, methodName, ref, context, confidence, resolvedBy,
@@ -646,7 +1619,7 @@ depth = 0) {
646
1619
  for (const m of methodCandidates) {
647
1620
  if (m.kind !== 'method')
648
1621
  continue;
649
- if (m.language !== ref.language)
1622
+ if (!sameLanguageFamily(m.language, ref.language))
650
1623
  continue;
651
1624
  const qn = m.qualifiedName;
652
1625
  if (qn === want || qn.endsWith(`::${want}`)) {
@@ -701,6 +1674,8 @@ depth = 0) {
701
1674
  // block, so Java/Kotlin import disambiguation — whose target is intentionally
702
1675
  // in ANOTHER file (#314) — is unaffected: that block returns early whenever
703
1676
  // an import FQN pins the class.
1677
+ if (ref.referenceKind === 'function_ref' && matches.length !== 1)
1678
+ return null;
704
1679
  const ordered = preferCallSiteFile(matches, ref.filePath);
705
1680
  return {
706
1681
  original: ref,
@@ -1169,6 +2144,8 @@ function normalizeInferredTypeName(raw) {
1169
2144
  const PATTERN_MEMO = new Map();
1170
2145
  const PATTERN_MEMO_CAP = 8192;
1171
2146
  const INFER_SCAN_STATES = new WeakMap();
2147
+ const AWAITED_TYPE_MEMO = new WeakMap();
2148
+ const AWAITED_FILES = new WeakMap();
1172
2149
  function getInferScanStates(context) {
1173
2150
  let m = INFER_SCAN_STATES.get(context);
1174
2151
  if (!m) {
@@ -1180,6 +2157,19 @@ function getInferScanStates(context) {
1180
2157
  /** Drop the per-context scan states (see ReferenceResolver.clearCaches). */
1181
2158
  function clearNameMatcherMemos(context) {
1182
2159
  INFER_SCAN_STATES.delete(context);
2160
+ PYTHON_MEMBER_LINES.delete(context);
2161
+ AWAITED_TYPE_MEMO.delete(context);
2162
+ AWAITED_FILES.delete(context);
2163
+ C_STATIC_MEMO.delete(context);
2164
+ RUST_TRAIT_IMPL_MEMO.delete(context);
2165
+ SEALED_MODULES.delete(context);
2166
+ LOCAL_BINDING_MEMO.delete(context);
2167
+ LOCAL_BINDING_SITES.delete(context);
2168
+ SELECTOR_NAMES.delete(context);
2169
+ GET_STATE_FILES.delete(context);
2170
+ TS_FIELD_DECL_MEMO.delete(context);
2171
+ TS_CLASS_LINES.delete(context);
2172
+ TARGET_LANGUAGE.delete(context);
1183
2173
  }
1184
2174
  function memoPatterns(key, build) {
1185
2175
  const hit = PATTERN_MEMO.get(key);
@@ -1218,6 +2208,12 @@ function buildLocalReceiverTypePatterns(language, r) {
1218
2208
  case 'python':
1219
2209
  return [
1220
2210
  new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // lg = Logger(...)
2211
+ // A quoted forward reference (`lg: "Logger"`, `lg: 'pkg.Logger'`) is the
2212
+ // same annotation — and what every file under `from __future__ import
2213
+ // annotations` or with a not-yet-defined class writes. The unquoted
2214
+ // pattern below stopped at the quote and read no type at all, so the
2215
+ // call produced no edge (#1684). Tried first: it is the stricter shape.
2216
+ new RegExp(`\\b${r}\\b\\s*:\\s*["']([A-Z][\\w.]*)["']`), // lg: "Logger"
1221
2217
  new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // lg: Logger (PEP 526)
1222
2218
  ];
1223
2219
  case 'java':
@@ -1514,6 +2510,191 @@ function inferLocalReceiverType(receiverName, ref, context) {
1514
2510
  }
1515
2511
  return null;
1516
2512
  }
2513
+ /** Infer only a visible awaited binding and its actual local/imported callee.
2514
+ * The signature already carries the return annotation in both extractors, so
2515
+ * multiline declarations and neighboring declarations cannot donate a type.
2516
+ * `null` means no awaited evidence; a null NAME means an awaited receiver whose
2517
+ * type is unknown, which must not fall back to an unrelated method name. */
2518
+ function inferEsmAwaitedCallType(receiverName, ref, context) {
2519
+ if (!/^[A-Za-z_$][\w$]*$/.test(receiverName))
2520
+ return null;
2521
+ let files = AWAITED_FILES.get(context);
2522
+ if (!files) {
2523
+ files = new Map();
2524
+ AWAITED_FILES.set(context, files);
2525
+ }
2526
+ let file = files.get(ref.filePath);
2527
+ if (file === undefined) {
2528
+ const source = context.readFile(ref.filePath) ?? '';
2529
+ file = null;
2530
+ // Raw eligibility is cheap; sanitize and index scopes only when a ref
2531
+ // actually uses one of these names. Comments cannot donate a binding:
2532
+ // the names are checked again after sanitizing on the first real lookup.
2533
+ const names = new Set([...source.matchAll(/\b(?:const|let|var)\s+([\w$]+)\s*=\s*await\s+[\w$]+\s*\(/g)].map(m => m[1]));
2534
+ if (names.size)
2535
+ file = { code: source, ready: false, names, offsets: [], scopes: [], declarations: new Map() };
2536
+ if (files.size >= 256)
2537
+ files.delete(files.keys().next().value);
2538
+ files.set(ref.filePath, file);
2539
+ }
2540
+ if (!file?.names.has(receiverName))
2541
+ return null;
2542
+ if (!file.ready) {
2543
+ const code = (0, strip_comments_1.blankStringContents)((0, strip_comments_1.stripCommentsForRegex)(file.code, 'typescript'));
2544
+ const names = new Set([...code.matchAll(/\b(?:const|let|var)\s+([\w$]+)\s*=\s*await\s+[\w$]+\s*\(/g)].map(m => m[1]));
2545
+ const offsets = [0];
2546
+ const scopes = [{ start: -1, end: code.length, parent: -1 }];
2547
+ const stack = [0];
2548
+ for (let i = 0; i < code.length; i++) {
2549
+ if (code[i] === '\n')
2550
+ offsets.push(i + 1);
2551
+ if (code[i] === '{') {
2552
+ scopes.push({ start: i, end: code.length, parent: stack[stack.length - 1] });
2553
+ stack.push(scopes.length - 1);
2554
+ }
2555
+ else if (code[i] === '}' && stack.length > 1)
2556
+ scopes[stack.pop()].end = i;
2557
+ }
2558
+ const declarations = new Map();
2559
+ for (const m of code.matchAll(/\b(?:const|let|var)\s+([\w$]+)\s*=\s*/g)) {
2560
+ if (!names.has(m[1]))
2561
+ continue;
2562
+ const entries = declarations.get(m[1]) ?? [];
2563
+ entries.push({ index: m.index, length: m[0].length });
2564
+ declarations.set(m[1], entries);
2565
+ }
2566
+ Object.assign(file, { code, ready: true, names, offsets, scopes, declarations });
2567
+ if (!names.has(receiverName))
2568
+ return null;
2569
+ }
2570
+ let memo = AWAITED_TYPE_MEMO.get(context);
2571
+ if (!memo) {
2572
+ memo = new Map();
2573
+ AWAITED_TYPE_MEMO.set(context, memo);
2574
+ }
2575
+ const key = `${ref.filePath}|${ref.line}|${ref.column}|${receiverName}`;
2576
+ if (memo.has(key))
2577
+ return memo.get(key);
2578
+ const result = resolveAwaitedCallType(receiverName, file, ref, context);
2579
+ if (memo.size >= PATTERN_MEMO_CAP)
2580
+ memo.delete(memo.keys().next().value);
2581
+ memo.set(key, result);
2582
+ return result;
2583
+ }
2584
+ function resolveAwaitedCallType(receiverName, file, ref, context) {
2585
+ const unknown = { name: null, filePath: ref.filePath };
2586
+ const end = (file.offsets[ref.line - 1] ?? file.code.length) + ref.column;
2587
+ const code = file.code.slice(0, end);
2588
+ const escaped = receiverName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2589
+ // Locate scopes in the precomputed brace tree. Rescanning the entire file
2590
+ // for every candidate binding made large test files quadratic in refs.
2591
+ const scopeAt = (offset) => {
2592
+ let lo = 0, hi = file.scopes.length;
2593
+ while (lo + 1 < hi) {
2594
+ const mid = (lo + hi) >>> 1;
2595
+ if (file.scopes[mid].start < offset)
2596
+ lo = mid;
2597
+ else
2598
+ hi = mid;
2599
+ }
2600
+ while (lo > 0 && file.scopes[lo].end < offset)
2601
+ lo = file.scopes[lo].parent;
2602
+ return lo;
2603
+ };
2604
+ const visibleAt = (declaration, use) => {
2605
+ const ancestor = scopeAt(declaration);
2606
+ for (let scope = scopeAt(use); scope >= 0; scope = file.scopes[scope].parent)
2607
+ if (scope === ancestor)
2608
+ return true;
2609
+ return false;
2610
+ };
2611
+ const binding = [...(file.declarations.get(receiverName) ?? [])].reverse()
2612
+ .find(m => m.index < end && visibleAt(m.index, end));
2613
+ if (!binding)
2614
+ return null;
2615
+ const init = code.slice(binding.index + binding.length);
2616
+ if (!/^await\b/.test(init))
2617
+ return null;
2618
+ // Only a bare call result, not a following member/index/conditional expression.
2619
+ const call = /^await\s+([A-Za-z_$][\w$]*)\s*\(/.exec(init);
2620
+ if (!call)
2621
+ return null;
2622
+ let depth = 1, callEnd = call[0].length;
2623
+ for (; callEnd < init.length && depth; callEnd++) {
2624
+ if (init[callEnd] === '(')
2625
+ depth++;
2626
+ else if (init[callEnd] === ')')
2627
+ depth--;
2628
+ }
2629
+ if (depth)
2630
+ return unknown;
2631
+ const tail = init.slice(callEnd);
2632
+ // A following property/index/call is not the callee's annotated value.
2633
+ if (!/^[ \t]*(?:;|\r?\n(?![ \t]*[.(\[?]))/.test(tail))
2634
+ return unknown;
2635
+ const rest = tail;
2636
+ if (new RegExp(`\\b(?:const|let|var|function|class)\\s+(?:${escaped}\\b|\\{[^}]*\\b${escaped}\\b)`).test(rest) ||
2637
+ new RegExp(`\\b${escaped}\\s*=(?!=)`).test(rest) || hasParameterBinding(rest, escaped))
2638
+ return unknown;
2639
+ const bindingLine = file.code.slice(0, binding.index).split('\n').length;
2640
+ const bindingRef = { ...ref, line: bindingLine, column: binding.index - file.offsets[bindingLine - 1] };
2641
+ const callee = call[1];
2642
+ const calleeEscaped = callee.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2643
+ if (context.getNodesInFile(ref.filePath).some(n => (n.kind === 'function' || n.kind === 'method') && n.startLine <= bindingLine && n.endLine >= bindingLine &&
2644
+ n.signature && hasParameterBinding(`${n.signature} {`, calleeEscaped)))
2645
+ return unknown;
2646
+ const imported = context.getImportMappings(ref.filePath, ref.language).some(m => m.localName === callee);
2647
+ let declaring;
2648
+ if (imported) {
2649
+ if (importShadowedAt(callee, bindingRef, context))
2650
+ return unknown;
2651
+ const resolved = context.resolveImport?.({ ...bindingRef, referenceName: callee, referenceKind: 'calls' });
2652
+ declaring = resolved ? context.getNodeById?.(resolved.targetNodeId) ?? undefined : undefined;
2653
+ }
2654
+ else {
2655
+ const local = context.getNodesByName(callee).filter(n => n.kind === 'function' &&
2656
+ n.filePath === ref.filePath && ESM_FAMILY.has(n.language) && isLexicallyReachable(n, bindingRef, context));
2657
+ if (local.length === 1)
2658
+ declaring = local[0];
2659
+ }
2660
+ if (!declaring || declaring.kind !== 'function' || !declaring.signature)
2661
+ return unknown;
2662
+ if (!imported) {
2663
+ const beforeBinding = code.slice(0, binding.index);
2664
+ const shadows = new RegExp(`\\b(?:const|let|var)\\s+${calleeEscaped}\\b`, 'g');
2665
+ for (const shadow of beforeBinding.matchAll(shadows)) {
2666
+ if (!visibleAt(shadow.index, binding.index))
2667
+ continue;
2668
+ // A typed arrow function may itself be the declared local factory.
2669
+ const line = file.code.slice(0, shadow.index).split('\n').length;
2670
+ if (line !== declaring.startLine || shadow.index - file.offsets[line - 1] > declaring.startColumn)
2671
+ return unknown;
2672
+ }
2673
+ }
2674
+ const signature = declaring.signature;
2675
+ const annotation = signature.slice(signature.lastIndexOf(')') + 1).match(/^\s*:\s*([\s\S]+)$/)?.[1]?.trim();
2676
+ if (!annotation)
2677
+ return unknown;
2678
+ // Do not turn unions, arrays, object/function types, or conditional types into
2679
+ // a project class. Await recursively unwraps promises, but this narrow path
2680
+ // accepts a single named Promise<T> layer only.
2681
+ const returned = annotation.match(/^Promise\s*<\s*([\w$]+)\s*>$/)?.[1] ?? annotation;
2682
+ if (!/^[A-Za-z_$][\w$]*$/.test(returned))
2683
+ return unknown;
2684
+ if (js_builtins_1.TS_PRIMITIVE_TYPES.has(returned))
2685
+ return { name: returned, filePath: declaring.filePath };
2686
+ const typeRef = { ...bindingRef, fromNodeId: declaring.id, filePath: declaring.filePath,
2687
+ language: declaring.language, line: declaring.startLine, column: declaring.startColumn,
2688
+ referenceName: returned, referenceKind: 'references' };
2689
+ const typeImport = context.getImportMappings(declaring.filePath, declaring.language).some(m => m.localName === returned);
2690
+ const resolved = typeImport ? context.resolveImport?.(typeRef) : null;
2691
+ const typeNode = resolved ? context.getNodeById?.(resolved.targetNodeId) :
2692
+ context.getNodesByName(returned).find(n => n.filePath === declaring.filePath &&
2693
+ ESM_FAMILY.has(n.language) && (n.kind === 'class' || n.kind === 'interface'));
2694
+ if (!typeNode || (typeNode.kind !== 'class' && typeNode.kind !== 'interface'))
2695
+ return unknown;
2696
+ return { name: typeNode.name, filePath: typeNode.filePath };
2697
+ }
1517
2698
  /**
1518
2699
  * Patterns that recover a PHP class property's declared type for a
1519
2700
  * `$this->prop` receiver. Deliberately NOT localReceiverTypePatterns: only
@@ -1651,6 +2832,15 @@ function matchMethodCall(ref, context) {
1651
2832
  return null;
1652
2833
  return resolveMethodOnType(inferredType, phpMethodName, ref, context, 0.9, 'instance-method', importedFqnOf(inferredType, ref, context));
1653
2834
  }
2835
+ // A TS/JS call through an ES private field of the enclosing class —
2836
+ // `this.#items.add()`, emitted as `this.#items.add` (#1987) — resolves
2837
+ // exactly like `this.<field>` below (#1496). `#` is outside dotMatch's
2838
+ // receiver class, so the shape is matched here.
2839
+ if (ref.language === 'typescript' || ref.language === 'javascript' || ref.language === 'tsx' || ref.language === 'jsx') {
2840
+ const privateField = ref.referenceName.match(/^this\.(#[\w$]+)\.(\w+)$/);
2841
+ if (privateField)
2842
+ return matchTsThisFieldCall(privateField[1], privateField[2], ref, context);
2843
+ }
1654
2844
  const match = dotMatch || colonMatch || luaColonMatch || rDollarMatch;
1655
2845
  if (!match) {
1656
2846
  return null;
@@ -1665,9 +2855,16 @@ function matchMethodCall(ref, context) {
1665
2855
  // shared source-based inferrer. resolveMethodOnType validates the method
1666
2856
  // exists on the inferred type, so a mis-inference produces no edge.
1667
2857
  if (inferableReceiver) {
1668
- const inferredType = nmTimedT('mc-infer', ref, () => ref.language === 'cpp'
2858
+ let inferredType = nmTimedT('mc-infer', ref, () => ref.language === 'cpp'
1669
2859
  ? inferCppReceiverType(objectOrClass, ref, context)
1670
2860
  : inferLocalReceiverType(objectOrClass, ref, context));
2861
+ const awaited = !inferredType && ESM_FAMILY.has(ref.language)
2862
+ ? inferEsmAwaitedCallType(objectOrClass, ref, context) : null;
2863
+ if (awaited) {
2864
+ if (!awaited.name || js_builtins_1.TS_PRIMITIVE_TYPES.has(awaited.name))
2865
+ return null;
2866
+ inferredType = awaited.name;
2867
+ }
1671
2868
  if (inferredType) {
1672
2869
  // Java/Kotlin: when two classes share the simple name, the file's import
1673
2870
  // pins WHICH one (#314). Other languages disambiguate by call-site file.
@@ -1676,10 +2873,29 @@ function matchMethodCall(ref, context) {
1676
2873
  .getImportMappings(ref.filePath, ref.language)
1677
2874
  .find((i) => i.localName === inferredType)?.source
1678
2875
  : undefined;
1679
- const typedMatch = nmTimedT('mc-rmot', ref, () => resolveMethodOnType(inferredType, methodName, ref, context, 0.9, 'instance-method', importedFqn));
2876
+ const typedMatch = nmTimedT('mc-rmot', ref, () => resolveMethodOnType(inferredType, methodName, awaited ? { ...ref, filePath: awaited.filePath } : ref, context, 0.9, 'instance-method', importedFqn));
1680
2877
  if (typedMatch) {
2878
+ if (awaited) {
2879
+ const target = context.getNodeById?.(typedMatch.targetNodeId);
2880
+ if (!target || (target.qualifiedName.startsWith(`${inferredType}::`) && target.filePath !== awaited.filePath))
2881
+ return null;
2882
+ return { ...typedMatch, original: ref };
2883
+ }
1681
2884
  return typedMatch;
1682
2885
  }
2886
+ if (awaited)
2887
+ return null;
2888
+ // A known JS/TS builtin receiver is external when it has no project
2889
+ // method (#1566). Inference already strips generics (`Map<K, V>` →
2890
+ // `Map`); do not let Strategy 3 guess an unrelated `get`/`set`/`has`.
2891
+ // Keep the validated match above for a project type shadowing a builtin.
2892
+ // A primitive receiver joins the builtins here: `listed.split()` on a
2893
+ // `string` is the built-in method, and Strategy 3 would otherwise hand
2894
+ // it whichever project class happens to declare a lone `split` (#1840).
2895
+ if (ESM_FAMILY.has(ref.language) &&
2896
+ (js_builtins_1.JS_BUILT_INS.has(inferredType) || js_builtins_1.TS_PRIMITIVE_TYPES.has(inferredType))) {
2897
+ return null;
2898
+ }
1683
2899
  }
1684
2900
  }
1685
2901
  // Go 2-hop field chain `base.field.Method` (#1276): the base's type comes
@@ -1707,6 +2923,28 @@ function matchMethodCall(ref, context) {
1707
2923
  if (ref.language === 'rust' && dotMatch && objectOrClass.startsWith('self.')) {
1708
2924
  return matchRustSelfFieldCall(objectOrClass.slice('self.'.length), methodName, ref, context);
1709
2925
  }
2926
+ // Rust call on the enclosing type itself — `self.reset()`, emitted as
2927
+ // `self.reset` (#1861). Same discipline as the field branch above, and
2928
+ // EXCLUSIVE for the same reason: the owner is written on the `impl` line and
2929
+ // carried in the calling method's qualified name, so it is not a guess.
2930
+ // Letting this shape reach the bare-name strategies below is how
2931
+ // `self.reset()` resolved to a same-named method on an unrelated type
2932
+ // whenever that type's method happened to sit nearer the call site.
2933
+ if (ref.language === 'rust' && dotMatch && objectOrClass === 'self') {
2934
+ return matchRustSelfCall(methodName, ref, context);
2935
+ }
2936
+ // TS/JS call through a field of the enclosing class — `this.mailer.send()`,
2937
+ // emitted as `this.mailer.send` (#1496). Same discipline as the Rust branch
2938
+ // above, and EXCLUSIVE for the same reason: the field's declared type off
2939
+ // the class's own declaration, validated by resolveMethodOnType, or nothing.
2940
+ // Letting the bare name through is how `this.mailer.send()` inside
2941
+ // `Notifier.send()` resolved to the calling method itself — a self-edge the
2942
+ // source does not contain — whenever the two shared a name.
2943
+ if ((ref.language === 'typescript' || ref.language === 'javascript' || ref.language === 'tsx' || ref.language === 'jsx') &&
2944
+ dotMatch &&
2945
+ objectOrClass.startsWith('this.')) {
2946
+ return matchTsThisFieldCall(objectOrClass.slice('this.'.length), methodName, ref, context);
2947
+ }
1710
2948
  // Java/Kotlin: receiver may be a field whose name doesn't match the type by
1711
2949
  // Java naming convention (`userbo` → class `UserBO`, abbreviated). Look up
1712
2950
  // the field in the enclosing class to get its declared type, then resolve
@@ -1735,9 +2973,11 @@ function matchMethodCall(ref, context) {
1735
2973
  // cross-file use reaches the same helper through the import path.
1736
2974
  if (dotMatch && !objectOrClass.includes('.') && OBJECT_LITERAL_LANGUAGES.has(ref.language)) {
1737
2975
  const literalMatch = nmTimedT('mc-literal', ref, () => {
1738
- const holders = preferCallSiteFile(context.getNodesByName(objectOrClass), ref.filePath).filter((n) => (n.kind === 'constant' || n.kind === 'variable') && n.filePath === ref.filePath);
2976
+ // Same-file holders only, so the call-site-first ordering is moot.
2977
+ const holders = context.getNodesByName(objectOrClass).filter((n) => (n.kind === 'constant' || n.kind === 'variable') && n.filePath === ref.filePath);
1739
2978
  for (const holder of holders) {
1740
- const hit = resolveObjectLiteralMember(holder, methodName, ref, context, 0.85, 'instance-method');
2979
+ const hit = resolveObjectLiteralMember(holder, methodName, ref, context, 0.85, 'instance-method') ??
2980
+ resolveObjectLiteralBinding(holder, methodName, ref, context);
1741
2981
  if (hit)
1742
2982
  return hit;
1743
2983
  }
@@ -1752,53 +2992,57 @@ function matchMethodCall(ref, context) {
1752
2992
  // own file first — otherwise the first-indexed class wins and a call in `b/`
1753
2993
  // resolves to `a/`'s method (#1079).
1754
2994
  const strat1 = nmTimedT('mc-class', ref, () => {
1755
- const classCandidates = preferCallSiteFile(context.getNodesByName(objectOrClass), ref.filePath);
2995
+ const classCandidates = preferCallSiteFile(context.getNodesByName(objectOrClass).filter(isMethodOwnerKind), ref.filePath);
1756
2996
  for (const classNode of classCandidates) {
1757
- if (classNode.kind === 'class' || classNode.kind === 'struct' || classNode.kind === 'union' || classNode.kind === 'interface') {
1758
- // Skip cross-language class matches
1759
- if (classNode.language !== ref.language)
1760
- continue;
1761
- const nodesInFile = context.getNodesInFile(classNode.filePath);
1762
- const methodNode = nodesInFile.find((n) => n.kind === 'method' &&
1763
- n.name === methodName &&
1764
- n.qualifiedName.includes(classNode.name));
1765
- if (methodNode) {
1766
- return {
1767
- original: ref,
1768
- targetNodeId: methodNode.id,
1769
- confidence: 0.85,
1770
- resolvedBy: 'qualified-name',
1771
- };
1772
- }
2997
+ // Skip cross-language class matches
2998
+ if (classNode.language !== ref.language)
2999
+ continue;
3000
+ const nodesInFile = context.getNodesInFile(classNode.filePath);
3001
+ const methodNode = nodesInFile.find((n) => n.kind === 'method' &&
3002
+ n.name === methodName &&
3003
+ n.qualifiedName.includes(classNode.name));
3004
+ if (methodNode) {
3005
+ return {
3006
+ original: ref,
3007
+ targetNodeId: methodNode.id,
3008
+ confidence: 0.85,
3009
+ resolvedBy: 'qualified-name',
3010
+ };
1773
3011
  }
1774
3012
  }
1775
3013
  return null;
1776
3014
  });
1777
3015
  if (strat1)
1778
3016
  return strat1;
3017
+ // Built-in method names need a validated receiver (#1987). Typed, imported,
3018
+ // object-literal and direct class receivers have had their chance above;
3019
+ // capitalization, word overlap or a unique method name are not evidence
3020
+ // that `list.map()` / `cache.get()` calls a project class.
3021
+ if (ref.referenceKind === 'calls' && JS_FAMILY.has(ref.language) &&
3022
+ objectOrClass !== 'this' && objectOrClass !== 'super' &&
3023
+ js_builtins_1.JS_BUILTIN_METHODS.has(methodName))
3024
+ return null;
1779
3025
  // Strategy 2: Instance variable receiver - try capitalized form to find class
1780
3026
  // e.g., "permissionEngine" → look for classes containing "PermissionEngine"
1781
3027
  const capitalizedReceiver = objectOrClass.charAt(0).toUpperCase() + objectOrClass.slice(1);
1782
3028
  if (capitalizedReceiver !== objectOrClass) {
1783
3029
  const strat2 = nmTimedT('mc-capital', ref, () => {
1784
- const fuzzyClassCandidates = preferCallSiteFile(context.getNodesByName(capitalizedReceiver), ref.filePath);
3030
+ const fuzzyClassCandidates = preferCallSiteFile(context.getNodesByName(capitalizedReceiver).filter(isMethodOwnerKind), ref.filePath);
1785
3031
  for (const classNode of fuzzyClassCandidates) {
1786
- if (classNode.kind === 'class' || classNode.kind === 'struct' || classNode.kind === 'union' || classNode.kind === 'interface') {
1787
- // Skip cross-language class matches
1788
- if (classNode.language !== ref.language)
1789
- continue;
1790
- const nodesInFile = context.getNodesInFile(classNode.filePath);
1791
- const methodNode = nodesInFile.find((n) => n.kind === 'method' &&
1792
- n.name === methodName &&
1793
- n.qualifiedName.includes(classNode.name));
1794
- if (methodNode) {
1795
- return {
1796
- original: ref,
1797
- targetNodeId: methodNode.id,
1798
- confidence: 0.8,
1799
- resolvedBy: 'instance-method',
1800
- };
1801
- }
3032
+ // Skip cross-language class matches
3033
+ if (classNode.language !== ref.language)
3034
+ continue;
3035
+ const nodesInFile = context.getNodesInFile(classNode.filePath);
3036
+ const methodNode = nodesInFile.find((n) => n.kind === 'method' &&
3037
+ n.name === methodName &&
3038
+ n.qualifiedName.includes(classNode.name));
3039
+ if (methodNode) {
3040
+ return {
3041
+ original: ref,
3042
+ targetNodeId: methodNode.id,
3043
+ confidence: 0.8,
3044
+ resolvedBy: 'instance-method',
3045
+ };
1802
3046
  }
1803
3047
  }
1804
3048
  return null;
@@ -1994,6 +3238,49 @@ function rustFieldTypeName(raw) {
1994
3238
  return null; // bare single-letter generic parameter
1995
3239
  return seg;
1996
3240
  }
3241
+ /**
3242
+ * `self.method()` in Rust — the method on the type the call sits inside.
3243
+ *
3244
+ * The owner is the calling method's qualified-name prefix (`Target::run` →
3245
+ * `Target`), which is where the `impl` block's type ends up. A free function
3246
+ * has no `self`, so a caller whose qualified name carries no owner declines.
3247
+ * Exactly one candidate must belong to that owner: a project with two `impl`
3248
+ * blocks for the same type is normal, two same-named methods on it is not, and
3249
+ * guessing between them is the failure this replaces.
3250
+ */
3251
+ function matchRustSelfCall(methodName, ref, context) {
3252
+ const caller = context.getNodeById?.(ref.fromNodeId);
3253
+ if (!caller?.qualifiedName)
3254
+ return null;
3255
+ const sep = caller.qualifiedName.lastIndexOf('::');
3256
+ if (sep <= 0)
3257
+ return null; // a free fn has no `self`
3258
+ const owner = caller.qualifiedName.slice(0, sep);
3259
+ let owned = context
3260
+ .getNodesByQualifiedName(`${owner}::${methodName}`)
3261
+ .filter((n) => n.kind === 'method' &&
3262
+ n.language === 'rust' &&
3263
+ n.qualifiedName === `${owner}::${methodName}`);
3264
+ // Rust's extracted qualified names omit module paths. Two modules can
3265
+ // each declare `Target`; matching just `Target::reset` does not establish
3266
+ // ownership. In that case require a single owner declaration in the
3267
+ // caller's file and a method in that file. Otherwise leave it unresolved.
3268
+ // A unique owner still permits ordinary impl blocks split across files.
3269
+ const owners = context.getNodesByQualifiedName(owner).filter((n) => n.language === 'rust' && ['struct', 'enum', 'union', 'trait', 'class'].includes(n.kind));
3270
+ if (owners.length > 1) {
3271
+ if (owners.filter((n) => n.filePath === caller.filePath).length !== 1)
3272
+ return null;
3273
+ owned = owned.filter((n) => n.filePath === caller.filePath);
3274
+ }
3275
+ if (owned.length !== 1)
3276
+ return null;
3277
+ return {
3278
+ original: ref,
3279
+ targetNodeId: owned[0].id,
3280
+ confidence: 0.9,
3281
+ resolvedBy: 'qualified-name',
3282
+ };
3283
+ }
1997
3284
  /**
1998
3285
  * Resolve a Rust call through a field of the enclosing type —
1999
3286
  * `self.inner.run()`, emitted by the extractor as `self.inner.run` (#1585).
@@ -2052,6 +3339,495 @@ function matchRustSelfFieldCall(field, methodName, ref, context) {
2052
3339
  }
2053
3340
  return null;
2054
3341
  }
3342
+ /**
3343
+ * Per-context memo for matchTsThisFieldCall's declaration scan: `classId\0field`
3344
+ * → the first line of the class that declares the field (as `: typeof X`,
3345
+ * `: X`, or `= new X`, tried in that order per line) with its captured type,
3346
+ * or null. The scan depends only on the class and the field, but ran for every
3347
+ * `this.<field>.<method>()` call — re-splitting the file and compiling three
3348
+ * patterns each time, a third of all method-call matching on vscode. Derived
3349
+ * from file source: drops with clearNameMatcherMemos.
3350
+ */
3351
+ const TS_FIELD_DECL_MEMO = new WeakMap();
3352
+ /** The last few classes' declarations — calls arrive file by file. */
3353
+ const TS_CLASS_LINES = new WeakMap();
3354
+ const TS_CLASS_LINES_KEEP = 32;
3355
+ function tsClassDecl(cls, context) {
3356
+ let cache = TS_CLASS_LINES.get(context);
3357
+ if (!cache) {
3358
+ cache = new Map();
3359
+ TS_CLASS_LINES.set(context, cache);
3360
+ }
3361
+ const hit = cache.get(cls.id);
3362
+ if (hit !== undefined)
3363
+ return hit;
3364
+ const source = context.readFile(cls.filePath);
3365
+ const decl = source
3366
+ ? {
3367
+ lines: source
3368
+ .split('\n')
3369
+ .slice(Math.max(0, cls.startLine - 1), cls.endLine)
3370
+ .map((rawLine) => rawLine.replace(/\/\/.*$/, '').replace(/\/\*.*?\*\//g, '')),
3371
+ lookups: 0,
3372
+ linesByToken: null,
3373
+ }
3374
+ : null;
3375
+ if (cache.size >= TS_CLASS_LINES_KEEP)
3376
+ cache.delete(cache.keys().next().value);
3377
+ cache.set(cls.id, decl);
3378
+ return decl;
3379
+ }
3380
+ const TS_FIELD_TOKEN = /^[\w$#]+$/;
3381
+ const TS_LINE_TOKEN = /[\w$#]+/g;
3382
+ const TS_TOKEN_CHAR = /[\w$#]/;
3383
+ /**
3384
+ * tsFieldPatterns with the field spelled `[\w$#]+`, tried sticky at a whole-
3385
+ * token occurrence of the field. There the run consumes exactly the field (a
3386
+ * shorter prefix cannot continue: every pattern needs `\s`, `?`, `!`, `:` or
3387
+ * `=` next), so each matches exactly where the field's own pattern would —
3388
+ * without compiling three patterns for every field of every class.
3389
+ */
3390
+ const TS_FIELD_PATTERNS_AT = [
3391
+ { re: /(?<![\w$#])[\w$#]+\b\s*[?!]?\s*:\s*(?:readonly\s+)?typeof\s+([A-Za-z_$][\w.$]*)/y, valueType: true },
3392
+ { re: /(?<![\w$#])[\w$#]+\b\s*[?!]?\s*:\s*(?:readonly\s+)?([A-Za-z_$][\w.$]*)/y, valueType: false },
3393
+ { re: /(?<![\w$#])[\w$#]+\b\s*=\s*new\s+([A-Za-z_$][\w.$]*)/y, valueType: false },
3394
+ ];
3395
+ /** The first declaration of `field` on one line, as `line.match` of its patterns in order would find it. */
3396
+ function tsFieldOnLine(line, field) {
3397
+ let at = null;
3398
+ for (let i = line.indexOf(field); i !== -1; i = line.indexOf(field, i + 1)) {
3399
+ const end = i + field.length;
3400
+ if ((i > 0 && TS_TOKEN_CHAR.test(line[i - 1])) || (end < line.length && TS_TOKEN_CHAR.test(line[end])))
3401
+ continue;
3402
+ (at ??= []).push(i);
3403
+ }
3404
+ if (!at)
3405
+ return null;
3406
+ for (const { re, valueType } of TS_FIELD_PATTERNS_AT) {
3407
+ for (const i of at) {
3408
+ re.lastIndex = i;
3409
+ const m = re.exec(line);
3410
+ if (m && m[1])
3411
+ return { valueType, type: m[1] };
3412
+ }
3413
+ }
3414
+ return null;
3415
+ }
3416
+ /** Indices of the class lines holding `token` as a whole `[\w$#]` run, ascending. */
3417
+ function tsClassLinesWithToken(decl, token) {
3418
+ if (!decl.linesByToken) {
3419
+ const index = new Map();
3420
+ for (let i = 0; i < decl.lines.length; i++) {
3421
+ for (const m of decl.lines[i].matchAll(TS_LINE_TOKEN)) {
3422
+ const rows = index.get(m[0]);
3423
+ if (!rows)
3424
+ index.set(m[0], [i]);
3425
+ else if (rows[rows.length - 1] !== i)
3426
+ rows.push(i);
3427
+ }
3428
+ }
3429
+ decl.linesByToken = index;
3430
+ }
3431
+ return decl.linesByToken.get(token) ?? [];
3432
+ }
3433
+ /** Compiled declaration patterns by field name — fields recur across classes. */
3434
+ const TS_FIELD_PATTERNS = new Map();
3435
+ const TS_FIELD_PATTERNS_CAP = 4096;
3436
+ function tsFieldPatterns(field) {
3437
+ const hit = TS_FIELD_PATTERNS.get(field);
3438
+ if (hit)
3439
+ return hit;
3440
+ const fieldEsc = field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
3441
+ // A word boundary cannot open a private name; it also lets a public
3442
+ // `items` match `#items`. Keep the two field namespaces distinct (#1987).
3443
+ const fieldStart = '(?<![\\w$#])';
3444
+ const patterns = [
3445
+ // `storage: typeof DraftHubStorage` — the type OF a value: an object
3446
+ // literal used as a namespace. Its members are bare-named functions inside
3447
+ // the constant's extent (#1573), so they are found by containment, not by
3448
+ // `Type::method`. Tried first: the declared-type pattern below would
3449
+ // otherwise capture the word `typeof`.
3450
+ {
3451
+ re: new RegExp(`${fieldStart}${fieldEsc}\\b\\s*[?!]?\\s*:\\s*(?:readonly\\s+)?typeof\\s+([A-Za-z_$][\\w.$]*)`),
3452
+ valueType: true,
3453
+ },
3454
+ // `private readonly mailer?: Mailer` — a class field or a constructor
3455
+ // parameter property; the capture stops at `<`, `[` or `|`, so a generic
3456
+ // or union type yields its head and resolveMethodOnType decides.
3457
+ {
3458
+ re: new RegExp(`${fieldStart}${fieldEsc}\\b\\s*[?!]?\\s*:\\s*(?:readonly\\s+)?([A-Za-z_$][\\w.$]*)`),
3459
+ valueType: false,
3460
+ },
3461
+ // `mailer = new Mailer()` / `this.mailer = new Mailer()`
3462
+ { re: new RegExp(`${fieldStart}${fieldEsc}\\b\\s*=\\s*new\\s+([A-Za-z_$][\\w.$]*)`), valueType: false },
3463
+ ];
3464
+ if (TS_FIELD_PATTERNS.size >= TS_FIELD_PATTERNS_CAP)
3465
+ TS_FIELD_PATTERNS.delete(TS_FIELD_PATTERNS.keys().next().value);
3466
+ TS_FIELD_PATTERNS.set(field, patterns);
3467
+ return patterns;
3468
+ }
3469
+ function tsFieldDeclaration(cls, field, context) {
3470
+ let memo = TS_FIELD_DECL_MEMO.get(context);
3471
+ if (!memo) {
3472
+ memo = new Map();
3473
+ TS_FIELD_DECL_MEMO.set(context, memo);
3474
+ }
3475
+ const key = cls.id + '\0' + field;
3476
+ const hit = memo.get(key);
3477
+ if (hit !== undefined)
3478
+ return hit;
3479
+ let found = null;
3480
+ const decl = tsClassDecl(cls, context);
3481
+ if (decl && TS_FIELD_TOKEN.test(field)) {
3482
+ // Every pattern needs the field as a whole `[\w$#]` run — the lookbehind
3483
+ // bars one before it, and nothing after it but `\s`, `?`, `!`, `:` or `=`
3484
+ // can continue a match — so only lines holding that token can match. A
3485
+ // class asked about several fields is indexed by token once.
3486
+ const rows = ++decl.lookups > 1 ? tsClassLinesWithToken(decl, field) : null;
3487
+ const count = rows ? rows.length : decl.lines.length;
3488
+ for (let k = 0; k < count && !found; k++) {
3489
+ const line = decl.lines[rows ? rows[k] : k];
3490
+ // Every pattern spells the field literally, so only a line that contains
3491
+ // it can match — and most of a class's lines never mention a given field.
3492
+ if (line.includes(field))
3493
+ found = tsFieldOnLine(line, field);
3494
+ }
3495
+ }
3496
+ else if (decl) {
3497
+ const patterns = tsFieldPatterns(field);
3498
+ scan: for (const line of decl.lines) {
3499
+ if (!line.includes(field))
3500
+ continue;
3501
+ for (const { re, valueType } of patterns) {
3502
+ const m = line.match(re);
3503
+ if (!m || !m[1])
3504
+ continue;
3505
+ found = { valueType, type: m[1] };
3506
+ break scan;
3507
+ }
3508
+ }
3509
+ }
3510
+ memo.set(key, found);
3511
+ return found;
3512
+ }
3513
+ /**
3514
+ * Resolve a TS/JS `this.<field>.<method>()` call (#1496) through the field's
3515
+ * declared type, read off the ENCLOSING class's own declaration lines:
3516
+ * a field or constructor-parameter property (`private mailer: Mailer`,
3517
+ * `mailer?: Mailer`, `readonly mailer: Mailer`) or an initializer
3518
+ * (`mailer = new Mailer()`, `this.mailer = new Mailer()`). The method is then
3519
+ * VALIDATED on that type by resolveMethodOnType. Null — never a bare-name
3520
+ * fallback — when the field is not declared there or its type is external,
3521
+ * a builtin (`this.items.push()`) or not spelled out.
3522
+ */
3523
+ function matchTsThisFieldCall(field, methodName, ref, context) {
3524
+ if (!field || field.includes('.'))
3525
+ return null;
3526
+ const caller = context.getNodeById?.(ref.fromNodeId);
3527
+ if (!caller)
3528
+ return null;
3529
+ const sep = caller.qualifiedName.lastIndexOf('::');
3530
+ if (sep <= 0)
3531
+ return null; // not inside a class
3532
+ const owner = caller.qualifiedName.slice(0, sep).split('::').pop();
3533
+ if (!owner)
3534
+ return null;
3535
+ const owners = preferCallSiteFile(context.getNodesByName(owner), ref.filePath).filter((n) => (n.kind === 'class' || n.kind === 'component') && sameLanguageFamily(n.language, ref.language));
3536
+ for (const cls of owners) {
3537
+ const decl = tsFieldDeclaration(cls, field, context);
3538
+ if (!decl)
3539
+ continue;
3540
+ if (decl.valueType) {
3541
+ // The value's declaration may live in another file (it is imported);
3542
+ // the call site's file is preferred when several share the name.
3543
+ const holderName = decl.type.split('.').pop();
3544
+ const holders = preferCallSiteFile(context.getNodesByName(holderName), ref.filePath).filter((n) => (n.kind === 'constant' || n.kind === 'variable') && sameLanguageFamily(n.language, ref.language));
3545
+ for (const holder of holders) {
3546
+ const hit = resolveObjectLiteralMember(holder, methodName, ref, context, 0.85, 'instance-method');
3547
+ if (hit)
3548
+ return hit;
3549
+ }
3550
+ return null;
3551
+ }
3552
+ // `ns.Mailer` → `Mailer`; a primitive or builtin names no project type.
3553
+ const typeName = decl.type.split('.').pop();
3554
+ if (!/^[A-Z]/.test(typeName))
3555
+ return null;
3556
+ // Two apps in one repo may each declare a `UserService`. The bare-name
3557
+ // path this replaces broke that tie by directory proximity, so keep the
3558
+ // same signal: among the type's declarations of the method, prefer the
3559
+ // one closest to the call site's directory (its own app), never index
3560
+ // order. resolveMethodOnType still answers the single-declaration and
3561
+ // supertype cases.
3562
+ const declared = context
3563
+ .getNodesByName(methodName)
3564
+ .filter((n) => n.kind === 'method' &&
3565
+ sameLanguageFamily(n.language, ref.language) &&
3566
+ (n.qualifiedName === `${typeName}::${methodName}` || n.qualifiedName.endsWith(`::${typeName}::${methodName}`)));
3567
+ if (declared.length > 1) {
3568
+ const callDirs = ref.filePath.split('/').slice(0, -1);
3569
+ const shared = (fp) => {
3570
+ const dirs = fp.split('/').slice(0, -1);
3571
+ let i = 0;
3572
+ while (i < dirs.length && i < callDirs.length && dirs[i] === callDirs[i])
3573
+ i++;
3574
+ return i;
3575
+ };
3576
+ const nearest = [...declared].sort((a, b) => shared(b.filePath) - shared(a.filePath) || a.filePath.localeCompare(b.filePath))[0];
3577
+ return { original: ref, targetNodeId: nearest.id, confidence: 0.85, resolvedBy: 'instance-method' };
3578
+ }
3579
+ return resolveMethodOnType(typeName, methodName, ref, context, 0.85, 'instance-method');
3580
+ }
3581
+ return null;
3582
+ }
3583
+ /**
3584
+ * The one fallback a TS/JS/Python call-receiver chain keeps (#1683): a STORE
3585
+ * ACCESSOR. Zustand's `get()` inside the store factory and
3586
+ * `useStore.getState()` outside it hand back the store whose actions are
3587
+ * indexed as functions (#1573). JS/TS resolves the member within that store;
3588
+ * the existing Python fallback still requires a unique callable. Nothing else
3589
+ * qualifies: a chain rooted in a project value still says nothing about what
3590
+ * the inner call RETURNS — `db.prepare(sql).all()` would bind to any project
3591
+ * function named `all` — so it resolves to nothing, exactly like a chain
3592
+ * rooted in a parameter (`d.setdefault(k, []).append(v)`).
3593
+ */
3594
+ function matchStoreAccessorChain(ref, context) {
3595
+ const m = ref.referenceName.match(/^([\w$.]+)\(\)\.(\w+)$/);
3596
+ if (!m || !m[1] || !m[2])
3597
+ return null;
3598
+ const inner = m[1];
3599
+ const method = m[2];
3600
+ if (!(inner === 'get' || inner === 'getState' || inner.endsWith('.getState')))
3601
+ return null;
3602
+ if (JS_FAMILY.has(ref.language)) {
3603
+ return resolveStoreAction(inner, method, ref, context);
3604
+ }
3605
+ const callables = context
3606
+ .getNodesByName(method)
3607
+ .filter((n) => (n.kind === 'function' || n.kind === 'method') && sameLanguageFamily(n.language, ref.language) && n.id !== ref.fromNodeId);
3608
+ if (callables.length !== 1)
3609
+ return null;
3610
+ return { original: ref, targetNodeId: callables[0].id, confidence: 0.6, resolvedBy: 'exact-match' };
3611
+ }
3612
+ /** Resolve the implementation inside the identified store, not a namesake or
3613
+ * an interface signature elsewhere in the project. Import resolution already
3614
+ * follows aliases/barrels; containment already excludes nested action locals. */
3615
+ function resolveStoreAction(inner, member, ref, context, selector = false) {
3616
+ let holders;
3617
+ if (inner === 'get' || inner === 'getState') {
3618
+ const caller = context.getNodeById?.(ref.fromNodeId);
3619
+ if (!caller)
3620
+ return null;
3621
+ holders = context.getNodesInFile(ref.filePath).filter((n) => {
3622
+ if ((n.kind !== 'constant' && n.kind !== 'variable') || !rangeWithin(caller, n))
3623
+ return false;
3624
+ const source = context.readFile(n.filePath)?.split('\n').slice(n.startLine - 1, caller.startLine).join('\n') ?? '';
3625
+ // The accessor must actually be a parameter of the enclosing factory.
3626
+ return new RegExp(`\\(\\s*[\\w$]+\\s*,\\s*${inner}\\s*(?:,\\s*[\\w$]+\\s*)?\\)\\s*=>`).test(source);
3627
+ });
3628
+ }
3629
+ else {
3630
+ const name = inner.slice(0, -'.getState'.length);
3631
+ if (!/^[\w$]+$/.test(name))
3632
+ return null;
3633
+ const imported = context.resolveImport?.({ ...ref, referenceName: name, referenceKind: 'references' });
3634
+ const node = imported && context.getNodeById?.(imported.targetNodeId);
3635
+ if (node && importShadowedAt(name, ref, context))
3636
+ return null;
3637
+ holders = node ? [node] : context.getNodesByName(name).filter((n) => n.filePath === ref.filePath && isLexicallyReachable(n, ref, context));
3638
+ }
3639
+ if (holders.length !== 1)
3640
+ return null;
3641
+ const holder = holders[0];
3642
+ if (selector) {
3643
+ // Only a Zustand hook promises to return the selector's result. An
3644
+ // arbitrary function accepting that callback is not a store binding.
3645
+ const text = context.readFile(holder.filePath)?.split('\n').slice(holder.startLine - 1, holder.endLine).join('\n') ?? '';
3646
+ const escaped = holder.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
3647
+ const factory = new RegExp(`\\b(?:const|let)\\s+${escaped}\\s*=\\s*([\\w$]+)\\s*[<(]`).exec(text)?.[1];
3648
+ if (!factory || !context.getImportMappings(holder.filePath, holder.language).some(m => m.localName === factory && m.source === 'zustand' && (m.exportedName === 'create' || m.isDefault)))
3649
+ return null;
3650
+ }
3651
+ return resolveObjectLiteralMember(holder, member, ref, context, 0.9, 'instance-method');
3652
+ }
3653
+ // Eligibility is a file property, not a call-site property. Cache both answers
3654
+ // within the same stable-source window as the resolver's file cache; sync drops
3655
+ // it via clearNameMatcherMemos. Keep only booleans, FIFO-capped like PATTERN_MEMO
3656
+ // to avoid per-hit LRU churn. Eviction merely repeats the source scan.
3657
+ const GET_STATE_FILES = new WeakMap();
3658
+ const GET_STATE_FILES_CAP = 8192;
3659
+ /** A const destructuring is a bound reference, so it is eligible even though
3660
+ * arbitrary locally-bound bare calls must never guess a cross-file target. */
3661
+ function matchDestructuredStoreCall(ref, context) {
3662
+ let files = GET_STATE_FILES.get(context);
3663
+ if (!files) {
3664
+ files = new Map();
3665
+ GET_STATE_FILES.set(context, files);
3666
+ }
3667
+ let eligible = files.get(ref.filePath);
3668
+ let source;
3669
+ if (eligible === undefined) {
3670
+ source = context.readFile(ref.filePath);
3671
+ eligible = source?.includes('.getState') ?? false;
3672
+ if (files.size >= GET_STATE_FILES_CAP) {
3673
+ const oldest = files.keys().next().value;
3674
+ if (oldest !== undefined)
3675
+ files.delete(oldest);
3676
+ }
3677
+ files.set(ref.filePath, eligible);
3678
+ }
3679
+ if (!eligible)
3680
+ return null;
3681
+ source ??= context.readFile(ref.filePath);
3682
+ if (!source)
3683
+ return null;
3684
+ const lines = source.split('\n');
3685
+ const start = enclosingScopeStartLine(ref, context) - 1;
3686
+ const before = lines.slice(start, ref.line - 1).concat(lines[ref.line - 1].slice(0, ref.column)).join('\n');
3687
+ const code = (0, strip_comments_1.blankStringContents)((0, strip_comments_1.stripCommentsForRegex)(before, 'typescript'));
3688
+ const name = ref.referenceName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
3689
+ const binding = /\bconst\s*\{([^{}]*)\}\s*=\s*([\w$]+)\.getState\s*\(\s*\)/g;
3690
+ // Compare block identities, not just nesting depth: a binding in a sibling
3691
+ // or already-closed block is not in scope at this call.
3692
+ const stackAt = (end) => {
3693
+ const stack = [];
3694
+ for (let i = 0; i < end; i++) {
3695
+ if (code[i] === '{')
3696
+ stack.push(i);
3697
+ else if (code[i] === '}')
3698
+ stack.pop();
3699
+ }
3700
+ return stack;
3701
+ };
3702
+ const callScope = stackAt(code.length);
3703
+ for (const m of [...code.matchAll(binding)].reverse()) {
3704
+ // Plain named bindings only; defaults, rest and computed keys need their
3705
+ // own value tracing rather than a same-name guess.
3706
+ if (!m[1].split(',').some(part => part.trim() === ref.referenceName))
3707
+ continue;
3708
+ const scope = stackAt(m.index);
3709
+ if (!scope.every((pos, i) => callScope[i] === pos))
3710
+ continue;
3711
+ const rest = code.slice(m.index + m[0].length);
3712
+ // Keep the guard when another declaration shadows the captured const.
3713
+ if (new RegExp(`\\b(?:const|let|var|function|class)\\s+(?:${name}\\b|\\{[^}]*\\b${name}\\b)`).test(rest))
3714
+ return null;
3715
+ return resolveStoreAction(`${m[2]}.getState`, ref.referenceName, ref, context);
3716
+ }
3717
+ return null;
3718
+ }
3719
+ /** Bound action names need not have a same-named definition (selectors may
3720
+ * rename them). The resolver's symbol-existence prefilter must allow them. */
3721
+ function matchJsStoreBindingCall(ref, context) {
3722
+ if (!isBareJsCall(ref, context))
3723
+ return null;
3724
+ return matchDestructuredStoreCall(ref, context) ?? matchSelectedStoreCall(ref, context);
3725
+ }
3726
+ /** A qualified untyped chain is useful source evidence, not permission to
3727
+ * infer a property type. Framework resolution runs before this guard. */
3728
+ function isUnresolvedJsMemberCall(ref) {
3729
+ return ref.referenceKind === 'calls' && JS_FAMILY.has(ref.language) &&
3730
+ !/^(?:this|window)\./.test(ref.referenceName) &&
3731
+ /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*){2,}$/.test(ref.referenceName);
3732
+ }
3733
+ const SELECTOR_NAMES = new WeakMap();
3734
+ /** A selector returns the named action from one identified store. Keep the
3735
+ * lexical block identity so closures may capture it but sibling scopes and
3736
+ * shadowing parameters/declarations cannot donate a binding. */
3737
+ function matchSelectedStoreCall(ref, context) {
3738
+ const source = context.readFile(ref.filePath);
3739
+ if (!source?.includes('=>'))
3740
+ return null;
3741
+ let files = SELECTOR_NAMES.get(context);
3742
+ if (!files) {
3743
+ files = new Map();
3744
+ SELECTOR_NAMES.set(context, files);
3745
+ }
3746
+ let names = files.get(ref.filePath);
3747
+ if (!names) {
3748
+ names = new Set([...source.matchAll(/\bconst\s+([\w$]+)\s*=\s*[\w$]+\s*\(\s*(?:\(\s*[\w$]+\s*\)|[\w$]+)\s*=>/g)].map(m => m[1]));
3749
+ files.set(ref.filePath, names);
3750
+ }
3751
+ if (!names.has(ref.referenceName))
3752
+ return null;
3753
+ const name = ref.referenceName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
3754
+ const lines = source.split('\n');
3755
+ const before = lines.slice(0, ref.line - 1).concat(lines[ref.line - 1].slice(0, ref.column)).join('\n');
3756
+ const code = (0, strip_comments_1.blankStringContents)((0, strip_comments_1.stripCommentsForRegex)(before, 'typescript'));
3757
+ const binding = new RegExp(`\\bconst\\s+${name}\\s*=\\s*([\\w$]+)\\s*\\(\\s*(?:\\(\\s*([\\w$]+)\\s*\\)|([\\w$]+))\\s*=>\\s*([\\w$]+)\\.([\\w$]+)\\s*\\)`, 'g');
3758
+ const stackAt = (end) => {
3759
+ const stack = [];
3760
+ for (let i = 0; i < end; i++) {
3761
+ if (code[i] === '{')
3762
+ stack.push(i);
3763
+ else if (code[i] === '}')
3764
+ stack.pop();
3765
+ }
3766
+ return stack;
3767
+ };
3768
+ const callScope = stackAt(code.length);
3769
+ for (const m of [...code.matchAll(binding)].reverse()) {
3770
+ if ((m[2] ?? m[3]) !== m[4])
3771
+ continue;
3772
+ if (!stackAt(m.index).every((pos, i) => callScope[i] === pos))
3773
+ continue;
3774
+ const rest = code.slice(m.index + m[0].length);
3775
+ if (new RegExp(`\\b(?:const|let|var|function|class)\\s+(?:${name}\\b|\\{[^}]*\\b${name}\\b)`).test(rest) ||
3776
+ hasParameterBinding(rest, name))
3777
+ return null;
3778
+ return resolveStoreAction(`${m[1]}.getState`, m[5], ref, context, true);
3779
+ }
3780
+ return null;
3781
+ }
3782
+ /** Import resolution names the module binding; a nearer parameter or block
3783
+ * declaration can shadow that binding at this particular call site. */
3784
+ function importShadowedAt(name, ref, context) {
3785
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
3786
+ for (const fn of context.getNodesInFile(ref.filePath)) {
3787
+ if ((fn.kind === 'function' || fn.kind === 'method') && fn.startLine <= ref.line && fn.endLine >= ref.line &&
3788
+ fn.signature && hasParameterBinding(`${fn.signature} {`, escaped))
3789
+ return true;
3790
+ }
3791
+ const lines = (context.readFile(ref.filePath) ?? '').split('\n');
3792
+ const before = lines.slice(0, ref.line - 1).concat(lines[ref.line - 1]?.slice(0, ref.column) ?? '').join('\n');
3793
+ const code = (0, strip_comments_1.blankStringContents)((0, strip_comments_1.stripCommentsForRegex)(before, 'typescript'));
3794
+ const stackAt = (end) => {
3795
+ const stack = [];
3796
+ for (let i = 0; i < end; i++) {
3797
+ if (code[i] === '{')
3798
+ stack.push(i);
3799
+ else if (code[i] === '}')
3800
+ stack.pop();
3801
+ }
3802
+ return stack;
3803
+ };
3804
+ const scope = stackAt(code.length);
3805
+ const declarations = new RegExp(`\\b(?:const|let|var|function|class)\\s+(?:${escaped}\\b|\\{[^}]*\\b${escaped}\\b)`, 'g');
3806
+ return [...code.matchAll(declarations)].some(m => stackAt(m.index).every((p, i) => scope[i] === p));
3807
+ }
3808
+ /** Balanced parameter lists also cover function-typed parameters, whose own
3809
+ * parentheses must not make the outer shadow invisible. Conservative when a
3810
+ * parameter's type mentions the same name: leave that call unresolved. */
3811
+ function hasParameterBinding(code, escapedName) {
3812
+ const name = new RegExp(`\\b${escapedName}\\b`);
3813
+ if (new RegExp(`\\b${escapedName}\\s*=>`).test(code))
3814
+ return true;
3815
+ for (let i = 0; i < code.length; i++) {
3816
+ if (code[i] !== '(' || /\b(?:if|while|for|switch|with)\s*$/.test(code.slice(0, i)))
3817
+ continue;
3818
+ let depth = 1, j = i + 1;
3819
+ for (; j < code.length && depth; j++) {
3820
+ if (code[j] === '(')
3821
+ depth++;
3822
+ else if (code[j] === ')')
3823
+ depth--;
3824
+ }
3825
+ if (depth === 0 && name.test(code.slice(i + 1, j - 1)) &&
3826
+ /^\s*(?::[^=;{]*)?(?:=>|\{)/.test(code.slice(j)))
3827
+ return true;
3828
+ }
3829
+ return false;
3830
+ }
2055
3831
  /**
2056
3832
  * Split a camelCase or PascalCase string into words.
2057
3833
  */
@@ -2191,11 +3967,35 @@ function matchFuzzy(ref, context) {
2191
3967
  const candidates = context.getNodesByLowerName(lowerName);
2192
3968
  // Filter to callable kinds only (function, method, class)
2193
3969
  const callableKinds = new Set(['function', 'method', 'class']);
2194
- const callableCandidates = applyLanguageGate(candidates.filter((n) => callableKinds.has(n.kind)), ref);
3970
+ const callableCandidates = candidates.filter((n) => callableKinds.has(n.kind))
3971
+ .filter((n) => (ref.referenceKind !== 'references' && ref.referenceKind !== 'function_ref') ||
3972
+ sameLanguageFamily(n.language, ref.language));
2195
3973
  // Prefer same-language matches
2196
3974
  const sameLanguageCandidates = callableCandidates.filter(n => n.language === ref.language);
2197
3975
  const finalCandidates = sameLanguageCandidates.length > 0 ? sameLanguageCandidates : callableCandidates;
2198
- if (finalCandidates.length === 1) {
3976
+ // Both post-pipeline visibility guards (#1745 language-local + #1719 sealed
3977
+ // module). The sealed-module test rejects the survivor and never filters the
3978
+ // set that produced it: removing a sealed candidate from a crowd would leave
3979
+ // a lone one and manufacture a 0.5 guess out of an ambiguity fuzzy declines.
3980
+ // Also decline a bare JS/TS call whose only survivor is a method or a
3981
+ // cross-file name the file already binds locally (#1714).
3982
+ // A function nested inside another function is only callable from inside
3983
+ // its container (#1230), so a builtin method call (`res.text()`) whose only
3984
+ // same-named project symbol is some file's closure must decline (#1708).
3985
+ // The check sits on the ONE candidate this strategy would commit to, not on
3986
+ // the candidate set: filtering the unreachable ones out of a crowd would
3987
+ // leave a single survivor and hand it every call of that name — on vite,
3988
+ // `import { resolve } from 'node:path'` in a dozen playground configs onto
3989
+ // the one reachable `resolve` method (#1709). Reachability may reject a
3990
+ // unique guess; it must never manufacture one.
3991
+ if (finalCandidates.length === 1 &&
3992
+ isVisibleAcrossFiles(finalCandidates[0], ref, context) &&
3993
+ isCrossFileReachable(finalCandidates[0], ref, context) &&
3994
+ !(isBareJsCall(ref, context) &&
3995
+ (finalCandidates[0].kind === 'method' ||
3996
+ (finalCandidates[0].filePath !== ref.filePath && isLocallyBoundJsName(ref.referenceName, ref.filePath, context)))) &&
3997
+ !(finalCandidates[0].kind === 'method' && isBareGoCall(ref, context)) &&
3998
+ isLexicallyReachable(finalCandidates[0], ref, context)) {
2199
3999
  const isCrossLanguage = finalCandidates[0].language !== ref.language;
2200
4000
  return {
2201
4001
  original: ref,
@@ -2251,6 +4051,9 @@ function dumpNameMatcherProfile(label) {
2251
4051
  }
2252
4052
  }
2253
4053
  function matchReference(ref, context) {
4054
+ return gateLanguageMatch(matchReferenceInner(ref, context), ref, context);
4055
+ }
4056
+ function matchReferenceInner(ref, context) {
2254
4057
  // Function-as-value refs (#756) resolve ONLY through the dedicated matcher —
2255
4058
  // never the fuzzy/qualified fallthrough below (a wrong callback edge is
2256
4059
  // worse than none).
@@ -2348,6 +4151,8 @@ function matchReference(ref, context) {
2348
4151
  return null;
2349
4152
  }
2350
4153
  }
4154
+ if (isUnresolvedJsMemberCall(ref))
4155
+ return null;
2351
4156
  // Try strategies in order of confidence
2352
4157
  let result;
2353
4158
  // 0. File path match (e.g., "snippets/drawer-menu.liquid" → file node)
@@ -2395,6 +4200,16 @@ function matchReference(ref, context) {
2395
4200
  if (result)
2396
4201
  return result;
2397
4202
  }
4203
+ // A call-receiver chain the extractor encoded as `<inner>().<method>` for a
4204
+ // language with no chain resolver above (TS/JS, Python — #1683) is a
4205
+ // receiver whose type is unknown. Nothing below may guess for it: the
4206
+ // method-call pattern rejects the parens, exact name never matches, but the
4207
+ // fuzzy strategy splits on `.` and would hand `make().run` to any `run` —
4208
+ // the fabricated edge the encoding exists to prevent.
4209
+ if (ref.referenceName.includes('().') &&
4210
+ (ref.language === 'typescript' || ref.language === 'javascript' || ref.language === 'tsx' || ref.language === 'jsx' || ref.language === 'python')) {
4211
+ return nmTimed('storeAccessorChain', ref, () => matchStoreAccessorChain(ref, context));
4212
+ }
2398
4213
  // 2. Method call pattern
2399
4214
  result = nmTimed('methodCall', ref, () => matchMethodCall(ref, context));
2400
4215
  if (result)