codegraph-java 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (866) hide show
  1. package/README.md +131 -0
  2. package/dist/base-graph/index.d.ts +57 -0
  3. package/dist/base-graph/index.d.ts.map +1 -0
  4. package/dist/base-graph/index.js +175 -0
  5. package/dist/base-graph/index.js.map +1 -0
  6. package/dist/bin/codegraph.d.ts +28 -0
  7. package/dist/bin/codegraph.d.ts.map +1 -0
  8. package/dist/bin/codegraph.js +2615 -0
  9. package/dist/bin/codegraph.js.map +1 -0
  10. package/dist/bin/command-supervision.d.ts +49 -0
  11. package/dist/bin/command-supervision.d.ts.map +1 -0
  12. package/dist/bin/command-supervision.js +95 -0
  13. package/dist/bin/command-supervision.js.map +1 -0
  14. package/dist/bin/fatal-handler.d.ts +20 -0
  15. package/dist/bin/fatal-handler.d.ts.map +1 -0
  16. package/dist/bin/fatal-handler.js +118 -0
  17. package/dist/bin/fatal-handler.js.map +1 -0
  18. package/dist/bin/node-version-check.d.ts +45 -0
  19. package/dist/bin/node-version-check.d.ts.map +1 -0
  20. package/dist/bin/node-version-check.js +98 -0
  21. package/dist/bin/node-version-check.js.map +1 -0
  22. package/dist/bin/uninstall.d.ts +14 -0
  23. package/dist/bin/uninstall.d.ts.map +1 -0
  24. package/dist/bin/uninstall.js +36 -0
  25. package/dist/bin/uninstall.js.map +1 -0
  26. package/dist/context/formatter.d.ts +36 -0
  27. package/dist/context/formatter.d.ts.map +1 -0
  28. package/dist/context/formatter.js +269 -0
  29. package/dist/context/formatter.js.map +1 -0
  30. package/dist/context/index.d.ts +131 -0
  31. package/dist/context/index.d.ts.map +1 -0
  32. package/dist/context/index.js +1378 -0
  33. package/dist/context/index.js.map +1 -0
  34. package/dist/context/markers.d.ts +19 -0
  35. package/dist/context/markers.d.ts.map +1 -0
  36. package/dist/context/markers.js +22 -0
  37. package/dist/context/markers.js.map +1 -0
  38. package/dist/db/index.d.ts +380 -0
  39. package/dist/db/index.d.ts.map +1 -0
  40. package/dist/db/index.js +854 -0
  41. package/dist/db/index.js.map +1 -0
  42. package/dist/db/migrations.d.ts +44 -0
  43. package/dist/db/migrations.d.ts.map +1 -0
  44. package/dist/db/migrations.js +255 -0
  45. package/dist/db/migrations.js.map +1 -0
  46. package/dist/db/queries.d.ts +1060 -0
  47. package/dist/db/queries.d.ts.map +1 -0
  48. package/dist/db/queries.js +3191 -0
  49. package/dist/db/queries.js.map +1 -0
  50. package/dist/db/schema.sql +209 -0
  51. package/dist/db/sqlite-adapter.d.ts +55 -0
  52. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  53. package/dist/db/sqlite-adapter.js +135 -0
  54. package/dist/db/sqlite-adapter.js.map +1 -0
  55. package/dist/db/wal-valve.d.ts +119 -0
  56. package/dist/db/wal-valve.d.ts.map +1 -0
  57. package/dist/db/wal-valve.js +290 -0
  58. package/dist/db/wal-valve.js.map +1 -0
  59. package/dist/directory.d.ts +213 -0
  60. package/dist/directory.d.ts.map +1 -0
  61. package/dist/directory.js +781 -0
  62. package/dist/directory.js.map +1 -0
  63. package/dist/errors.d.ts +150 -0
  64. package/dist/errors.d.ts.map +1 -0
  65. package/dist/errors.js +234 -0
  66. package/dist/errors.js.map +1 -0
  67. package/dist/extraction/extraction-version.d.ts +25 -0
  68. package/dist/extraction/extraction-version.d.ts.map +1 -0
  69. package/dist/extraction/extraction-version.js +28 -0
  70. package/dist/extraction/extraction-version.js.map +1 -0
  71. package/dist/extraction/function-ref.d.ts +118 -0
  72. package/dist/extraction/function-ref.d.ts.map +1 -0
  73. package/dist/extraction/function-ref.js +746 -0
  74. package/dist/extraction/function-ref.js.map +1 -0
  75. package/dist/extraction/generated-detection.d.ts +66 -0
  76. package/dist/extraction/generated-detection.d.ts.map +1 -0
  77. package/dist/extraction/generated-detection.js +248 -0
  78. package/dist/extraction/generated-detection.js.map +1 -0
  79. package/dist/extraction/grammars.d.ts +148 -0
  80. package/dist/extraction/grammars.d.ts.map +1 -0
  81. package/dist/extraction/grammars.js +558 -0
  82. package/dist/extraction/grammars.js.map +1 -0
  83. package/dist/extraction/index.d.ts +367 -0
  84. package/dist/extraction/index.d.ts.map +1 -0
  85. package/dist/extraction/index.js +2833 -0
  86. package/dist/extraction/index.js.map +1 -0
  87. package/dist/extraction/kernel/decode.d.ts +9 -0
  88. package/dist/extraction/kernel/decode.d.ts.map +1 -0
  89. package/dist/extraction/kernel/decode.js +162 -0
  90. package/dist/extraction/kernel/decode.js.map +1 -0
  91. package/dist/extraction/kernel/index.d.ts +64 -0
  92. package/dist/extraction/kernel/index.d.ts.map +1 -0
  93. package/dist/extraction/kernel/index.js +204 -0
  94. package/dist/extraction/kernel/index.js.map +1 -0
  95. package/dist/extraction/kernel/layout.d.ts +101 -0
  96. package/dist/extraction/kernel/layout.d.ts.map +1 -0
  97. package/dist/extraction/kernel/layout.js +104 -0
  98. package/dist/extraction/kernel/layout.js.map +1 -0
  99. package/dist/extraction/kernel/loader.d.ts +103 -0
  100. package/dist/extraction/kernel/loader.d.ts.map +1 -0
  101. package/dist/extraction/kernel/loader.js +146 -0
  102. package/dist/extraction/kernel/loader.js.map +1 -0
  103. package/dist/extraction/languages/c-cpp.d.ts +124 -0
  104. package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  105. package/dist/extraction/languages/c-cpp.js +1689 -0
  106. package/dist/extraction/languages/c-cpp.js.map +1 -0
  107. package/dist/extraction/languages/index.d.ts +11 -0
  108. package/dist/extraction/languages/index.d.ts.map +1 -0
  109. package/dist/extraction/languages/index.js +15 -0
  110. package/dist/extraction/languages/index.js.map +1 -0
  111. package/dist/extraction/languages/java.d.ts +3 -0
  112. package/dist/extraction/languages/java.d.ts.map +1 -0
  113. package/dist/extraction/languages/java.js +315 -0
  114. package/dist/extraction/languages/java.js.map +1 -0
  115. package/dist/extraction/languages/rust.d.ts +23 -0
  116. package/dist/extraction/languages/rust.d.ts.map +1 -0
  117. package/dist/extraction/languages/rust.js +169 -0
  118. package/dist/extraction/languages/rust.js.map +1 -0
  119. package/dist/extraction/parse-pool.d.ts +167 -0
  120. package/dist/extraction/parse-pool.d.ts.map +1 -0
  121. package/dist/extraction/parse-pool.js +421 -0
  122. package/dist/extraction/parse-pool.js.map +1 -0
  123. package/dist/extraction/parse-worker.d.ts +8 -0
  124. package/dist/extraction/parse-worker.d.ts.map +1 -0
  125. package/dist/extraction/parse-worker.js +138 -0
  126. package/dist/extraction/parse-worker.js.map +1 -0
  127. package/dist/extraction/store-worker.d.ts +24 -0
  128. package/dist/extraction/store-worker.d.ts.map +1 -0
  129. package/dist/extraction/store-worker.js +139 -0
  130. package/dist/extraction/store-worker.js.map +1 -0
  131. package/dist/extraction/store-writer.d.ts +63 -0
  132. package/dist/extraction/store-writer.d.ts.map +1 -0
  133. package/dist/extraction/store-writer.js +174 -0
  134. package/dist/extraction/store-writer.js.map +1 -0
  135. package/dist/extraction/syntax-tokens.d.ts +103 -0
  136. package/dist/extraction/syntax-tokens.d.ts.map +1 -0
  137. package/dist/extraction/syntax-tokens.js +381 -0
  138. package/dist/extraction/syntax-tokens.js.map +1 -0
  139. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  140. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  141. package/dist/extraction/tree-sitter-helpers.js +153 -0
  142. package/dist/extraction/tree-sitter-helpers.js.map +1 -0
  143. package/dist/extraction/tree-sitter-types.d.ts +260 -0
  144. package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  145. package/dist/extraction/tree-sitter-types.js +10 -0
  146. package/dist/extraction/tree-sitter-types.js.map +1 -0
  147. package/dist/extraction/tree-sitter.d.ts +745 -0
  148. package/dist/extraction/tree-sitter.d.ts.map +1 -0
  149. package/dist/extraction/tree-sitter.js +6725 -0
  150. package/dist/extraction/tree-sitter.js.map +1 -0
  151. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  152. package/dist/extraction/wasm-runtime-flags.d.ts +53 -0
  153. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  154. package/dist/extraction/wasm-runtime-flags.js +130 -0
  155. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  156. package/dist/graph/branch-guards.d.ts +248 -0
  157. package/dist/graph/branch-guards.d.ts.map +1 -0
  158. package/dist/graph/branch-guards.js +2231 -0
  159. package/dist/graph/branch-guards.js.map +1 -0
  160. package/dist/graph/dead-code.d.ts +251 -0
  161. package/dist/graph/dead-code.d.ts.map +1 -0
  162. package/dist/graph/dead-code.js +756 -0
  163. package/dist/graph/dead-code.js.map +1 -0
  164. package/dist/graph/dynamic-boundary-report.d.ts +121 -0
  165. package/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
  166. package/dist/graph/dynamic-boundary-report.js +283 -0
  167. package/dist/graph/dynamic-boundary-report.js.map +1 -0
  168. package/dist/graph/index.d.ts +12 -0
  169. package/dist/graph/index.d.ts.map +1 -0
  170. package/dist/graph/index.js +28 -0
  171. package/dist/graph/index.js.map +1 -0
  172. package/dist/graph/named-symbol-flow.d.ts +153 -0
  173. package/dist/graph/named-symbol-flow.d.ts.map +1 -0
  174. package/dist/graph/named-symbol-flow.js +609 -0
  175. package/dist/graph/named-symbol-flow.js.map +1 -0
  176. package/dist/graph/queries.d.ts +106 -0
  177. package/dist/graph/queries.d.ts.map +1 -0
  178. package/dist/graph/queries.js +341 -0
  179. package/dist/graph/queries.js.map +1 -0
  180. package/dist/graph/traversal.d.ts +127 -0
  181. package/dist/graph/traversal.d.ts.map +1 -0
  182. package/dist/graph/traversal.js +599 -0
  183. package/dist/graph/traversal.js.map +1 -0
  184. package/dist/graph/type-hierarchy.d.ts +155 -0
  185. package/dist/graph/type-hierarchy.d.ts.map +1 -0
  186. package/dist/graph/type-hierarchy.js +382 -0
  187. package/dist/graph/type-hierarchy.js.map +1 -0
  188. package/dist/index.d.ts +886 -0
  189. package/dist/index.d.ts.map +1 -0
  190. package/dist/index.js +2019 -0
  191. package/dist/index.js.map +1 -0
  192. package/dist/installer/beta-signup.d.ts +54 -0
  193. package/dist/installer/beta-signup.d.ts.map +1 -0
  194. package/dist/installer/beta-signup.js +178 -0
  195. package/dist/installer/beta-signup.js.map +1 -0
  196. package/dist/installer/config-writer.d.ts +28 -0
  197. package/dist/installer/config-writer.d.ts.map +1 -0
  198. package/dist/installer/config-writer.js +91 -0
  199. package/dist/installer/config-writer.js.map +1 -0
  200. package/dist/installer/index.d.ts +143 -0
  201. package/dist/installer/index.d.ts.map +1 -0
  202. package/dist/installer/index.js +632 -0
  203. package/dist/installer/index.js.map +1 -0
  204. package/dist/installer/instructions-template.d.ts +41 -0
  205. package/dist/installer/instructions-template.d.ts.map +1 -0
  206. package/dist/installer/instructions-template.js +53 -0
  207. package/dist/installer/instructions-template.js.map +1 -0
  208. package/dist/installer/targets/antigravity.d.ts +57 -0
  209. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  210. package/dist/installer/targets/antigravity.js +308 -0
  211. package/dist/installer/targets/antigravity.js.map +1 -0
  212. package/dist/installer/targets/claude.d.ts +62 -0
  213. package/dist/installer/targets/claude.d.ts.map +1 -0
  214. package/dist/installer/targets/claude.js +486 -0
  215. package/dist/installer/targets/claude.js.map +1 -0
  216. package/dist/installer/targets/codex.d.ts +32 -0
  217. package/dist/installer/targets/codex.d.ts.map +1 -0
  218. package/dist/installer/targets/codex.js +202 -0
  219. package/dist/installer/targets/codex.js.map +1 -0
  220. package/dist/installer/targets/copilot-cli.d.ts +32 -0
  221. package/dist/installer/targets/copilot-cli.d.ts.map +1 -0
  222. package/dist/installer/targets/copilot-cli.js +209 -0
  223. package/dist/installer/targets/copilot-cli.js.map +1 -0
  224. package/dist/installer/targets/copilot-jetbrains.d.ts +42 -0
  225. package/dist/installer/targets/copilot-jetbrains.d.ts.map +1 -0
  226. package/dist/installer/targets/copilot-jetbrains.js +238 -0
  227. package/dist/installer/targets/copilot-jetbrains.js.map +1 -0
  228. package/dist/installer/targets/copilot-vscode.d.ts +47 -0
  229. package/dist/installer/targets/copilot-vscode.d.ts.map +1 -0
  230. package/dist/installer/targets/copilot-vscode.js +219 -0
  231. package/dist/installer/targets/copilot-vscode.js.map +1 -0
  232. package/dist/installer/targets/cursor.d.ts +35 -0
  233. package/dist/installer/targets/cursor.d.ts.map +1 -0
  234. package/dist/installer/targets/cursor.js +254 -0
  235. package/dist/installer/targets/cursor.js.map +1 -0
  236. package/dist/installer/targets/gemini.d.ts +26 -0
  237. package/dist/installer/targets/gemini.d.ts.map +1 -0
  238. package/dist/installer/targets/gemini.js +165 -0
  239. package/dist/installer/targets/gemini.js.map +1 -0
  240. package/dist/installer/targets/hermes.d.ts +18 -0
  241. package/dist/installer/targets/hermes.d.ts.map +1 -0
  242. package/dist/installer/targets/hermes.js +359 -0
  243. package/dist/installer/targets/hermes.js.map +1 -0
  244. package/dist/installer/targets/kiro.d.ts +27 -0
  245. package/dist/installer/targets/kiro.d.ts.map +1 -0
  246. package/dist/installer/targets/kiro.js +178 -0
  247. package/dist/installer/targets/kiro.js.map +1 -0
  248. package/dist/installer/targets/opencode.d.ts +38 -0
  249. package/dist/installer/targets/opencode.d.ts.map +1 -0
  250. package/dist/installer/targets/opencode.js +288 -0
  251. package/dist/installer/targets/opencode.js.map +1 -0
  252. package/dist/installer/targets/registry.d.ts +35 -0
  253. package/dist/installer/targets/registry.d.ts.map +1 -0
  254. package/dist/installer/targets/registry.js +101 -0
  255. package/dist/installer/targets/registry.js.map +1 -0
  256. package/dist/installer/targets/shared.d.ts +101 -0
  257. package/dist/installer/targets/shared.d.ts.map +1 -0
  258. package/dist/installer/targets/shared.js +264 -0
  259. package/dist/installer/targets/shared.js.map +1 -0
  260. package/dist/installer/targets/toml.d.ts +53 -0
  261. package/dist/installer/targets/toml.d.ts.map +1 -0
  262. package/dist/installer/targets/toml.js +226 -0
  263. package/dist/installer/targets/toml.js.map +1 -0
  264. package/dist/installer/targets/trae.d.ts +30 -0
  265. package/dist/installer/targets/trae.d.ts.map +1 -0
  266. package/dist/installer/targets/trae.js +164 -0
  267. package/dist/installer/targets/trae.js.map +1 -0
  268. package/dist/installer/targets/types.d.ts +108 -0
  269. package/dist/installer/targets/types.d.ts.map +1 -0
  270. package/dist/installer/targets/types.js +16 -0
  271. package/dist/installer/targets/types.js.map +1 -0
  272. package/dist/installer/targets/workbuddy.d.ts +29 -0
  273. package/dist/installer/targets/workbuddy.d.ts.map +1 -0
  274. package/dist/installer/targets/workbuddy.js +163 -0
  275. package/dist/installer/targets/workbuddy.js.map +1 -0
  276. package/dist/mcp/daemon-manager.d.ts +42 -0
  277. package/dist/mcp/daemon-manager.d.ts.map +1 -0
  278. package/dist/mcp/daemon-manager.js +129 -0
  279. package/dist/mcp/daemon-manager.js.map +1 -0
  280. package/dist/mcp/daemon-paths.d.ts +79 -0
  281. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  282. package/dist/mcp/daemon-paths.js +219 -0
  283. package/dist/mcp/daemon-paths.js.map +1 -0
  284. package/dist/mcp/daemon-registry.d.ts +57 -0
  285. package/dist/mcp/daemon-registry.d.ts.map +1 -0
  286. package/dist/mcp/daemon-registry.js +281 -0
  287. package/dist/mcp/daemon-registry.js.map +1 -0
  288. package/dist/mcp/daemon.d.ts +293 -0
  289. package/dist/mcp/daemon.d.ts.map +1 -0
  290. package/dist/mcp/daemon.js +864 -0
  291. package/dist/mcp/daemon.js.map +1 -0
  292. package/dist/mcp/dynamic-boundaries.d.ts +41 -0
  293. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  294. package/dist/mcp/dynamic-boundaries.js +360 -0
  295. package/dist/mcp/dynamic-boundaries.js.map +1 -0
  296. package/dist/mcp/early-ppid.d.ts +26 -0
  297. package/dist/mcp/early-ppid.d.ts.map +1 -0
  298. package/dist/mcp/early-ppid.js +29 -0
  299. package/dist/mcp/early-ppid.js.map +1 -0
  300. package/dist/mcp/engine.d.ts +125 -0
  301. package/dist/mcp/engine.d.ts.map +1 -0
  302. package/dist/mcp/engine.js +392 -0
  303. package/dist/mcp/engine.js.map +1 -0
  304. package/dist/mcp/explore-dedup.d.ts +137 -0
  305. package/dist/mcp/explore-dedup.d.ts.map +1 -0
  306. package/dist/mcp/explore-dedup.js +236 -0
  307. package/dist/mcp/explore-dedup.js.map +1 -0
  308. package/dist/mcp/explore-diagnostics.d.ts +289 -0
  309. package/dist/mcp/explore-diagnostics.d.ts.map +1 -0
  310. package/dist/mcp/explore-diagnostics.js +558 -0
  311. package/dist/mcp/explore-diagnostics.js.map +1 -0
  312. package/dist/mcp/explore-session-state.d.ts +217 -0
  313. package/dist/mcp/explore-session-state.d.ts.map +1 -0
  314. package/dist/mcp/explore-session-state.js +322 -0
  315. package/dist/mcp/explore-session-state.js.map +1 -0
  316. package/dist/mcp/index.d.ts +137 -0
  317. package/dist/mcp/index.d.ts.map +1 -0
  318. package/dist/mcp/index.js +567 -0
  319. package/dist/mcp/index.js.map +1 -0
  320. package/dist/mcp/liveness-watchdog.d.ts +35 -0
  321. package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  322. package/dist/mcp/liveness-watchdog.js +269 -0
  323. package/dist/mcp/liveness-watchdog.js.map +1 -0
  324. package/dist/mcp/ppid-watchdog.d.ts +62 -0
  325. package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  326. package/dist/mcp/ppid-watchdog.js +64 -0
  327. package/dist/mcp/ppid-watchdog.js.map +1 -0
  328. package/dist/mcp/proxy.d.ts +87 -0
  329. package/dist/mcp/proxy.d.ts.map +1 -0
  330. package/dist/mcp/proxy.js +672 -0
  331. package/dist/mcp/proxy.js.map +1 -0
  332. package/dist/mcp/query-pool.d.ts +108 -0
  333. package/dist/mcp/query-pool.d.ts.map +1 -0
  334. package/dist/mcp/query-pool.js +315 -0
  335. package/dist/mcp/query-pool.js.map +1 -0
  336. package/dist/mcp/query-worker.d.ts +24 -0
  337. package/dist/mcp/query-worker.d.ts.map +1 -0
  338. package/dist/mcp/query-worker.js +87 -0
  339. package/dist/mcp/query-worker.js.map +1 -0
  340. package/dist/mcp/server-instructions.d.ts +34 -0
  341. package/dist/mcp/server-instructions.d.ts.map +1 -0
  342. package/dist/mcp/server-instructions.js +111 -0
  343. package/dist/mcp/server-instructions.js.map +1 -0
  344. package/dist/mcp/session.d.ts +109 -0
  345. package/dist/mcp/session.d.ts.map +1 -0
  346. package/dist/mcp/session.js +380 -0
  347. package/dist/mcp/session.js.map +1 -0
  348. package/dist/mcp/startup-handshake.d.ts +44 -0
  349. package/dist/mcp/startup-handshake.d.ts.map +1 -0
  350. package/dist/mcp/startup-handshake.js +73 -0
  351. package/dist/mcp/startup-handshake.js.map +1 -0
  352. package/dist/mcp/stdin-teardown.d.ts +27 -0
  353. package/dist/mcp/stdin-teardown.d.ts.map +1 -0
  354. package/dist/mcp/stdin-teardown.js +49 -0
  355. package/dist/mcp/stdin-teardown.js.map +1 -0
  356. package/dist/mcp/tools.d.ts +877 -0
  357. package/dist/mcp/tools.d.ts.map +1 -0
  358. package/dist/mcp/tools.js +6371 -0
  359. package/dist/mcp/tools.js.map +1 -0
  360. package/dist/mcp/transport.d.ts +188 -0
  361. package/dist/mcp/transport.d.ts.map +1 -0
  362. package/dist/mcp/transport.js +377 -0
  363. package/dist/mcp/transport.js.map +1 -0
  364. package/dist/mcp/version.d.ts +19 -0
  365. package/dist/mcp/version.d.ts.map +1 -0
  366. package/dist/mcp/version.js +71 -0
  367. package/dist/mcp/version.js.map +1 -0
  368. package/dist/project-config.d.ts +158 -0
  369. package/dist/project-config.d.ts.map +1 -0
  370. package/dist/project-config.js +489 -0
  371. package/dist/project-config.js.map +1 -0
  372. package/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
  373. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  374. package/dist/resolution/c-fnptr-synthesizer.js +1506 -0
  375. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  376. package/dist/resolution/callback-synthesizer.d.ts +59 -0
  377. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  378. package/dist/resolution/callback-synthesizer.js +4066 -0
  379. package/dist/resolution/callback-synthesizer.js.map +1 -0
  380. package/dist/resolution/cooperative-yield.d.ts +40 -0
  381. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  382. package/dist/resolution/cooperative-yield.js +44 -0
  383. package/dist/resolution/cooperative-yield.js.map +1 -0
  384. package/dist/resolution/expo-router-synthesizer.d.ts +32 -0
  385. package/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
  386. package/dist/resolution/expo-router-synthesizer.js +189 -0
  387. package/dist/resolution/expo-router-synthesizer.js.map +1 -0
  388. package/dist/resolution/frameworks/astro.d.ts +9 -0
  389. package/dist/resolution/frameworks/astro.d.ts.map +1 -0
  390. package/dist/resolution/frameworks/astro.js +169 -0
  391. package/dist/resolution/frameworks/astro.js.map +1 -0
  392. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  393. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  394. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  395. package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  396. package/dist/resolution/frameworks/cics.d.ts +20 -0
  397. package/dist/resolution/frameworks/cics.d.ts.map +1 -0
  398. package/dist/resolution/frameworks/cics.js +90 -0
  399. package/dist/resolution/frameworks/cics.js.map +1 -0
  400. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  401. package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  402. package/dist/resolution/frameworks/csharp.js +335 -0
  403. package/dist/resolution/frameworks/csharp.js.map +1 -0
  404. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  405. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  406. package/dist/resolution/frameworks/drupal.js +367 -0
  407. package/dist/resolution/frameworks/drupal.js.map +1 -0
  408. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  409. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  410. package/dist/resolution/frameworks/expo-modules.js +148 -0
  411. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  412. package/dist/resolution/frameworks/expo-router.d.ts +189 -0
  413. package/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
  414. package/dist/resolution/frameworks/expo-router.js +785 -0
  415. package/dist/resolution/frameworks/expo-router.js.map +1 -0
  416. package/dist/resolution/frameworks/express.d.ts +8 -0
  417. package/dist/resolution/frameworks/express.d.ts.map +1 -0
  418. package/dist/resolution/frameworks/express.js +540 -0
  419. package/dist/resolution/frameworks/express.js.map +1 -0
  420. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  421. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  422. package/dist/resolution/frameworks/fabric.js +354 -0
  423. package/dist/resolution/frameworks/fabric.js.map +1 -0
  424. package/dist/resolution/frameworks/go.d.ts +8 -0
  425. package/dist/resolution/frameworks/go.d.ts.map +1 -0
  426. package/dist/resolution/frameworks/go.js +184 -0
  427. package/dist/resolution/frameworks/go.js.map +1 -0
  428. package/dist/resolution/frameworks/goframe.d.ts +41 -0
  429. package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  430. package/dist/resolution/frameworks/goframe.js +112 -0
  431. package/dist/resolution/frameworks/goframe.js.map +1 -0
  432. package/dist/resolution/frameworks/index.d.ts +30 -0
  433. package/dist/resolution/frameworks/index.d.ts.map +1 -0
  434. package/dist/resolution/frameworks/index.js +72 -0
  435. package/dist/resolution/frameworks/index.js.map +1 -0
  436. package/dist/resolution/frameworks/java.d.ts +8 -0
  437. package/dist/resolution/frameworks/java.d.ts.map +1 -0
  438. package/dist/resolution/frameworks/java.js +517 -0
  439. package/dist/resolution/frameworks/java.js.map +1 -0
  440. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  441. package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  442. package/dist/resolution/frameworks/laravel.js +257 -0
  443. package/dist/resolution/frameworks/laravel.js.map +1 -0
  444. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  445. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  446. package/dist/resolution/frameworks/nestjs.js +690 -0
  447. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  448. package/dist/resolution/frameworks/nextjs.d.ts +76 -0
  449. package/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
  450. package/dist/resolution/frameworks/nextjs.js +328 -0
  451. package/dist/resolution/frameworks/nextjs.js.map +1 -0
  452. package/dist/resolution/frameworks/object-literal.d.ts +32 -0
  453. package/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
  454. package/dist/resolution/frameworks/object-literal.js +139 -0
  455. package/dist/resolution/frameworks/object-literal.js.map +1 -0
  456. package/dist/resolution/frameworks/package-deps.d.ts +14 -0
  457. package/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
  458. package/dist/resolution/frameworks/package-deps.js +78 -0
  459. package/dist/resolution/frameworks/package-deps.js.map +1 -0
  460. package/dist/resolution/frameworks/play.d.ts +19 -0
  461. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  462. package/dist/resolution/frameworks/play.js +111 -0
  463. package/dist/resolution/frameworks/play.js.map +1 -0
  464. package/dist/resolution/frameworks/python.d.ts +10 -0
  465. package/dist/resolution/frameworks/python.d.ts.map +1 -0
  466. package/dist/resolution/frameworks/python.js +566 -0
  467. package/dist/resolution/frameworks/python.js.map +1 -0
  468. package/dist/resolution/frameworks/react-native.d.ts +29 -0
  469. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  470. package/dist/resolution/frameworks/react-native.js +549 -0
  471. package/dist/resolution/frameworks/react-native.js.map +1 -0
  472. package/dist/resolution/frameworks/react-router.d.ts +46 -0
  473. package/dist/resolution/frameworks/react-router.d.ts.map +1 -0
  474. package/dist/resolution/frameworks/react-router.js +187 -0
  475. package/dist/resolution/frameworks/react-router.js.map +1 -0
  476. package/dist/resolution/frameworks/react.d.ts +9 -0
  477. package/dist/resolution/frameworks/react.d.ts.map +1 -0
  478. package/dist/resolution/frameworks/react.js +257 -0
  479. package/dist/resolution/frameworks/react.js.map +1 -0
  480. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  481. package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  482. package/dist/resolution/frameworks/ruby.js +302 -0
  483. package/dist/resolution/frameworks/ruby.js.map +1 -0
  484. package/dist/resolution/frameworks/rust.d.ts +8 -0
  485. package/dist/resolution/frameworks/rust.d.ts.map +1 -0
  486. package/dist/resolution/frameworks/rust.js +304 -0
  487. package/dist/resolution/frameworks/rust.js.map +1 -0
  488. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  489. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  490. package/dist/resolution/frameworks/svelte.js +258 -0
  491. package/dist/resolution/frameworks/svelte.js.map +1 -0
  492. package/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
  493. package/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
  494. package/dist/resolution/frameworks/sveltekit-router.js +156 -0
  495. package/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
  496. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  497. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  498. package/dist/resolution/frameworks/swift-objc.js +252 -0
  499. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  500. package/dist/resolution/frameworks/swift.d.ts +10 -0
  501. package/dist/resolution/frameworks/swift.d.ts.map +1 -0
  502. package/dist/resolution/frameworks/swift.js +410 -0
  503. package/dist/resolution/frameworks/swift.js.map +1 -0
  504. package/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
  505. package/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
  506. package/dist/resolution/frameworks/tanstack-router.js +437 -0
  507. package/dist/resolution/frameworks/tanstack-router.js.map +1 -0
  508. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  509. package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  510. package/dist/resolution/frameworks/terraform.js +277 -0
  511. package/dist/resolution/frameworks/terraform.js.map +1 -0
  512. package/dist/resolution/frameworks/vue-router.d.ts +82 -0
  513. package/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
  514. package/dist/resolution/frameworks/vue-router.js +377 -0
  515. package/dist/resolution/frameworks/vue-router.js.map +1 -0
  516. package/dist/resolution/frameworks/vue.d.ts +9 -0
  517. package/dist/resolution/frameworks/vue.d.ts.map +1 -0
  518. package/dist/resolution/frameworks/vue.js +303 -0
  519. package/dist/resolution/frameworks/vue.js.map +1 -0
  520. package/dist/resolution/go-module.d.ts +26 -0
  521. package/dist/resolution/go-module.d.ts.map +1 -0
  522. package/dist/resolution/go-module.js +78 -0
  523. package/dist/resolution/go-module.js.map +1 -0
  524. package/dist/resolution/goframe-synthesizer.d.ts +29 -0
  525. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  526. package/dist/resolution/goframe-synthesizer.js +163 -0
  527. package/dist/resolution/goframe-synthesizer.js.map +1 -0
  528. package/dist/resolution/import-resolver.d.ts +84 -0
  529. package/dist/resolution/import-resolver.d.ts.map +1 -0
  530. package/dist/resolution/import-resolver.js +2240 -0
  531. package/dist/resolution/import-resolver.js.map +1 -0
  532. package/dist/resolution/index.d.ts +343 -0
  533. package/dist/resolution/index.d.ts.map +1 -0
  534. package/dist/resolution/index.js +2352 -0
  535. package/dist/resolution/index.js.map +1 -0
  536. package/dist/resolution/lru-cache.d.ts +24 -0
  537. package/dist/resolution/lru-cache.d.ts.map +1 -0
  538. package/dist/resolution/lru-cache.js +62 -0
  539. package/dist/resolution/lru-cache.js.map +1 -0
  540. package/dist/resolution/memory-budget.d.ts +48 -0
  541. package/dist/resolution/memory-budget.d.ts.map +1 -0
  542. package/dist/resolution/memory-budget.js +162 -0
  543. package/dist/resolution/memory-budget.js.map +1 -0
  544. package/dist/resolution/name-matcher.d.ts +153 -0
  545. package/dist/resolution/name-matcher.d.ts.map +1 -0
  546. package/dist/resolution/name-matcher.js +2412 -0
  547. package/dist/resolution/name-matcher.js.map +1 -0
  548. package/dist/resolution/next-router-synthesizer.d.ts +27 -0
  549. package/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
  550. package/dist/resolution/next-router-synthesizer.js +113 -0
  551. package/dist/resolution/next-router-synthesizer.js.map +1 -0
  552. package/dist/resolution/path-aliases.d.ts +70 -0
  553. package/dist/resolution/path-aliases.d.ts.map +1 -0
  554. package/dist/resolution/path-aliases.js +346 -0
  555. package/dist/resolution/path-aliases.js.map +1 -0
  556. package/dist/resolution/react-router-synthesizer.d.ts +33 -0
  557. package/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
  558. package/dist/resolution/react-router-synthesizer.js +126 -0
  559. package/dist/resolution/react-router-synthesizer.js.map +1 -0
  560. package/dist/resolution/resolver-pool.d.ts +106 -0
  561. package/dist/resolution/resolver-pool.d.ts.map +1 -0
  562. package/dist/resolution/resolver-pool.js +344 -0
  563. package/dist/resolution/resolver-pool.js.map +1 -0
  564. package/dist/resolution/resolver-worker.d.ts +17 -0
  565. package/dist/resolution/resolver-worker.d.ts.map +1 -0
  566. package/dist/resolution/resolver-worker.js +141 -0
  567. package/dist/resolution/resolver-worker.js.map +1 -0
  568. package/dist/resolution/strip-comments.d.ts +27 -0
  569. package/dist/resolution/strip-comments.d.ts.map +1 -0
  570. package/dist/resolution/strip-comments.js +492 -0
  571. package/dist/resolution/strip-comments.js.map +1 -0
  572. package/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
  573. package/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
  574. package/dist/resolution/sveltekit-synthesizer.js +173 -0
  575. package/dist/resolution/sveltekit-synthesizer.js.map +1 -0
  576. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  577. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  578. package/dist/resolution/swift-objc-bridge.js +256 -0
  579. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  580. package/dist/resolution/synth-utils.d.ts +26 -0
  581. package/dist/resolution/synth-utils.d.ts.map +1 -0
  582. package/dist/resolution/synth-utils.js +75 -0
  583. package/dist/resolution/synth-utils.js.map +1 -0
  584. package/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
  585. package/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
  586. package/dist/resolution/tanstack-router-synthesizer.js +114 -0
  587. package/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
  588. package/dist/resolution/tier-synthesizer.d.ts +48 -0
  589. package/dist/resolution/tier-synthesizer.d.ts.map +1 -0
  590. package/dist/resolution/tier-synthesizer.js +907 -0
  591. package/dist/resolution/tier-synthesizer.js.map +1 -0
  592. package/dist/resolution/types.d.ts +290 -0
  593. package/dist/resolution/types.d.ts.map +1 -0
  594. package/dist/resolution/types.js +8 -0
  595. package/dist/resolution/types.js.map +1 -0
  596. package/dist/resolution/vue-router-synthesizer.d.ts +30 -0
  597. package/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
  598. package/dist/resolution/vue-router-synthesizer.js +115 -0
  599. package/dist/resolution/vue-router-synthesizer.js.map +1 -0
  600. package/dist/resolution/workspace-packages.d.ts +58 -0
  601. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  602. package/dist/resolution/workspace-packages.js +346 -0
  603. package/dist/resolution/workspace-packages.js.map +1 -0
  604. package/dist/search/identifier-segments.d.ts +70 -0
  605. package/dist/search/identifier-segments.d.ts.map +1 -0
  606. package/dist/search/identifier-segments.js +205 -0
  607. package/dist/search/identifier-segments.js.map +1 -0
  608. package/dist/search/query-parser.d.ts +57 -0
  609. package/dist/search/query-parser.d.ts.map +1 -0
  610. package/dist/search/query-parser.js +177 -0
  611. package/dist/search/query-parser.js.map +1 -0
  612. package/dist/search/query-paths.d.ts +57 -0
  613. package/dist/search/query-paths.d.ts.map +1 -0
  614. package/dist/search/query-paths.js +298 -0
  615. package/dist/search/query-paths.js.map +1 -0
  616. package/dist/search/query-utils.d.ts +102 -0
  617. package/dist/search/query-utils.d.ts.map +1 -0
  618. package/dist/search/query-utils.js +487 -0
  619. package/dist/search/query-utils.js.map +1 -0
  620. package/dist/sync/git-hooks.d.ts +45 -0
  621. package/dist/sync/git-hooks.d.ts.map +1 -0
  622. package/dist/sync/git-hooks.js +227 -0
  623. package/dist/sync/git-hooks.js.map +1 -0
  624. package/dist/sync/index.d.ts +19 -0
  625. package/dist/sync/index.d.ts.map +1 -0
  626. package/dist/sync/index.js +35 -0
  627. package/dist/sync/index.js.map +1 -0
  628. package/dist/sync/watch-policy.d.ts +48 -0
  629. package/dist/sync/watch-policy.d.ts.map +1 -0
  630. package/dist/sync/watch-policy.js +124 -0
  631. package/dist/sync/watch-policy.js.map +1 -0
  632. package/dist/sync/watcher.d.ts +401 -0
  633. package/dist/sync/watcher.d.ts.map +1 -0
  634. package/dist/sync/watcher.js +967 -0
  635. package/dist/sync/watcher.js.map +1 -0
  636. package/dist/sync/worktree.d.ts +63 -0
  637. package/dist/sync/worktree.d.ts.map +1 -0
  638. package/dist/sync/worktree.js +182 -0
  639. package/dist/sync/worktree.js.map +1 -0
  640. package/dist/telemetry/index.d.ts +143 -0
  641. package/dist/telemetry/index.d.ts.map +1 -0
  642. package/dist/telemetry/index.js +541 -0
  643. package/dist/telemetry/index.js.map +1 -0
  644. package/dist/types.d.ts +486 -0
  645. package/dist/types.d.ts.map +1 -0
  646. package/dist/types.js +118 -0
  647. package/dist/types.js.map +1 -0
  648. package/dist/ui/color.d.ts +21 -0
  649. package/dist/ui/color.d.ts.map +1 -0
  650. package/dist/ui/color.js +42 -0
  651. package/dist/ui/color.js.map +1 -0
  652. package/dist/ui/glyphs.d.ts +67 -0
  653. package/dist/ui/glyphs.d.ts.map +1 -0
  654. package/dist/ui/glyphs.js +125 -0
  655. package/dist/ui/glyphs.js.map +1 -0
  656. package/dist/ui/shimmer-progress.d.ts +11 -0
  657. package/dist/ui/shimmer-progress.d.ts.map +1 -0
  658. package/dist/ui/shimmer-progress.js +164 -0
  659. package/dist/ui/shimmer-progress.js.map +1 -0
  660. package/dist/ui/shimmer-worker.d.ts +2 -0
  661. package/dist/ui/shimmer-worker.d.ts.map +1 -0
  662. package/dist/ui/shimmer-worker.js +126 -0
  663. package/dist/ui/shimmer-worker.js.map +1 -0
  664. package/dist/ui/types.d.ts +15 -0
  665. package/dist/ui/types.d.ts.map +1 -0
  666. package/dist/ui/types.js +3 -0
  667. package/dist/ui/types.js.map +1 -0
  668. package/dist/ui-server/api/deadcode.d.ts +84 -0
  669. package/dist/ui-server/api/deadcode.d.ts.map +1 -0
  670. package/dist/ui-server/api/deadcode.js +136 -0
  671. package/dist/ui-server/api/deadcode.js.map +1 -0
  672. package/dist/ui-server/api/effects.d.ts +87 -0
  673. package/dist/ui-server/api/effects.d.ts.map +1 -0
  674. package/dist/ui-server/api/effects.js +499 -0
  675. package/dist/ui-server/api/effects.js.map +1 -0
  676. package/dist/ui-server/api/entrypoints.d.ts +86 -0
  677. package/dist/ui-server/api/entrypoints.d.ts.map +1 -0
  678. package/dist/ui-server/api/entrypoints.js +279 -0
  679. package/dist/ui-server/api/entrypoints.js.map +1 -0
  680. package/dist/ui-server/api/events.d.ts +183 -0
  681. package/dist/ui-server/api/events.d.ts.map +1 -0
  682. package/dist/ui-server/api/events.js +430 -0
  683. package/dist/ui-server/api/events.js.map +1 -0
  684. package/dist/ui-server/api/file.d.ts +66 -0
  685. package/dist/ui-server/api/file.d.ts.map +1 -0
  686. package/dist/ui-server/api/file.js +222 -0
  687. package/dist/ui-server/api/file.js.map +1 -0
  688. package/dist/ui-server/api/filecode.d.ts +126 -0
  689. package/dist/ui-server/api/filecode.d.ts.map +1 -0
  690. package/dist/ui-server/api/filecode.js +205 -0
  691. package/dist/ui-server/api/filecode.js.map +1 -0
  692. package/dist/ui-server/api/flow.d.ts +226 -0
  693. package/dist/ui-server/api/flow.d.ts.map +1 -0
  694. package/dist/ui-server/api/flow.js +611 -0
  695. package/dist/ui-server/api/flow.js.map +1 -0
  696. package/dist/ui-server/api/hierarchy.d.ts +81 -0
  697. package/dist/ui-server/api/hierarchy.d.ts.map +1 -0
  698. package/dist/ui-server/api/hierarchy.js +92 -0
  699. package/dist/ui-server/api/hierarchy.js.map +1 -0
  700. package/dist/ui-server/api/index.d.ts +90 -0
  701. package/dist/ui-server/api/index.d.ts.map +1 -0
  702. package/dist/ui-server/api/index.js +332 -0
  703. package/dist/ui-server/api/index.js.map +1 -0
  704. package/dist/ui-server/api/map.d.ts +187 -0
  705. package/dist/ui-server/api/map.d.ts.map +1 -0
  706. package/dist/ui-server/api/map.js +498 -0
  707. package/dist/ui-server/api/map.js.map +1 -0
  708. package/dist/ui-server/api/node.d.ts +81 -0
  709. package/dist/ui-server/api/node.d.ts.map +1 -0
  710. package/dist/ui-server/api/node.js +388 -0
  711. package/dist/ui-server/api/node.js.map +1 -0
  712. package/dist/ui-server/api/nodes.d.ts +25 -0
  713. package/dist/ui-server/api/nodes.d.ts.map +1 -0
  714. package/dist/ui-server/api/nodes.js +45 -0
  715. package/dist/ui-server/api/nodes.js.map +1 -0
  716. package/dist/ui-server/api/program.d.ts +139 -0
  717. package/dist/ui-server/api/program.d.ts.map +1 -0
  718. package/dist/ui-server/api/program.js +315 -0
  719. package/dist/ui-server/api/program.js.map +1 -0
  720. package/dist/ui-server/api/respond.d.ts +76 -0
  721. package/dist/ui-server/api/respond.d.ts.map +1 -0
  722. package/dist/ui-server/api/respond.js +186 -0
  723. package/dist/ui-server/api/respond.js.map +1 -0
  724. package/dist/ui-server/api/route-roots.d.ts +39 -0
  725. package/dist/ui-server/api/route-roots.d.ts.map +1 -0
  726. package/dist/ui-server/api/route-roots.js +96 -0
  727. package/dist/ui-server/api/route-roots.js.map +1 -0
  728. package/dist/ui-server/api/routes.d.ts +59 -0
  729. package/dist/ui-server/api/routes.d.ts.map +1 -0
  730. package/dist/ui-server/api/routes.js +112 -0
  731. package/dist/ui-server/api/routes.js.map +1 -0
  732. package/dist/ui-server/api/screens.d.ts +117 -0
  733. package/dist/ui-server/api/screens.d.ts.map +1 -0
  734. package/dist/ui-server/api/screens.js +611 -0
  735. package/dist/ui-server/api/screens.js.map +1 -0
  736. package/dist/ui-server/api/search.d.ts +29 -0
  737. package/dist/ui-server/api/search.d.ts.map +1 -0
  738. package/dist/ui-server/api/search.js +232 -0
  739. package/dist/ui-server/api/search.js.map +1 -0
  740. package/dist/ui-server/api/session.d.ts +52 -0
  741. package/dist/ui-server/api/session.d.ts.map +1 -0
  742. package/dist/ui-server/api/session.js +196 -0
  743. package/dist/ui-server/api/session.js.map +1 -0
  744. package/dist/ui-server/api/source.d.ts +200 -0
  745. package/dist/ui-server/api/source.d.ts.map +1 -0
  746. package/dist/ui-server/api/source.js +419 -0
  747. package/dist/ui-server/api/source.js.map +1 -0
  748. package/dist/ui-server/api/stats.d.ts +27 -0
  749. package/dist/ui-server/api/stats.d.ts.map +1 -0
  750. package/dist/ui-server/api/stats.js +164 -0
  751. package/dist/ui-server/api/stats.js.map +1 -0
  752. package/dist/ui-server/api/steps.d.ts +274 -0
  753. package/dist/ui-server/api/steps.d.ts.map +1 -0
  754. package/dist/ui-server/api/steps.js +1446 -0
  755. package/dist/ui-server/api/steps.js.map +1 -0
  756. package/dist/ui-server/api/trail-store.d.ts +142 -0
  757. package/dist/ui-server/api/trail-store.d.ts.map +1 -0
  758. package/dist/ui-server/api/trail-store.js +323 -0
  759. package/dist/ui-server/api/trail-store.js.map +1 -0
  760. package/dist/ui-server/api/trails.d.ts +163 -0
  761. package/dist/ui-server/api/trails.d.ts.map +1 -0
  762. package/dist/ui-server/api/trails.js +369 -0
  763. package/dist/ui-server/api/trails.js.map +1 -0
  764. package/dist/ui-server/api/when.d.ts +125 -0
  765. package/dist/ui-server/api/when.d.ts.map +1 -0
  766. package/dist/ui-server/api/when.js +251 -0
  767. package/dist/ui-server/api/when.js.map +1 -0
  768. package/dist/ui-server/api/wire.d.ts +179 -0
  769. package/dist/ui-server/api/wire.d.ts.map +1 -0
  770. package/dist/ui-server/api/wire.js +231 -0
  771. package/dist/ui-server/api/wire.js.map +1 -0
  772. package/dist/ui-server/assets.d.ts +40 -0
  773. package/dist/ui-server/assets.d.ts.map +1 -0
  774. package/dist/ui-server/assets.js +110 -0
  775. package/dist/ui-server/assets.js.map +1 -0
  776. package/dist/ui-server/constants.d.ts +32 -0
  777. package/dist/ui-server/constants.d.ts.map +1 -0
  778. package/dist/ui-server/constants.js +35 -0
  779. package/dist/ui-server/constants.js.map +1 -0
  780. package/dist/ui-server/highlight/index.d.ts +113 -0
  781. package/dist/ui-server/highlight/index.d.ts.map +1 -0
  782. package/dist/ui-server/highlight/index.js +307 -0
  783. package/dist/ui-server/highlight/index.js.map +1 -0
  784. package/dist/ui-server/highlight/languages.d.ts +36 -0
  785. package/dist/ui-server/highlight/languages.d.ts.map +1 -0
  786. package/dist/ui-server/highlight/languages.js +50 -0
  787. package/dist/ui-server/highlight/languages.js.map +1 -0
  788. package/dist/ui-server/index.d.ts +92 -0
  789. package/dist/ui-server/index.d.ts.map +1 -0
  790. package/dist/ui-server/index.js +399 -0
  791. package/dist/ui-server/index.js.map +1 -0
  792. package/dist/ui-server/open-browser.d.ts +31 -0
  793. package/dist/ui-server/open-browser.d.ts.map +1 -0
  794. package/dist/ui-server/open-browser.js +79 -0
  795. package/dist/ui-server/open-browser.js.map +1 -0
  796. package/dist/ui-server/security.d.ts +127 -0
  797. package/dist/ui-server/security.d.ts.map +1 -0
  798. package/dist/ui-server/security.js +332 -0
  799. package/dist/ui-server/security.js.map +1 -0
  800. package/dist/ui-server/static.d.ts +45 -0
  801. package/dist/ui-server/static.d.ts.map +1 -0
  802. package/dist/ui-server/static.js +165 -0
  803. package/dist/ui-server/static.js.map +1 -0
  804. package/dist/upgrade/index.d.ts +177 -0
  805. package/dist/upgrade/index.d.ts.map +1 -0
  806. package/dist/upgrade/index.js +665 -0
  807. package/dist/upgrade/index.js.map +1 -0
  808. package/dist/upgrade/remove-binary.d.ts +87 -0
  809. package/dist/upgrade/remove-binary.d.ts.map +1 -0
  810. package/dist/upgrade/remove-binary.js +289 -0
  811. package/dist/upgrade/remove-binary.js.map +1 -0
  812. package/dist/upgrade/update-check.d.ts +92 -0
  813. package/dist/upgrade/update-check.d.ts.map +1 -0
  814. package/dist/upgrade/update-check.js +258 -0
  815. package/dist/upgrade/update-check.js.map +1 -0
  816. package/dist/utils.d.ts +224 -0
  817. package/dist/utils.d.ts.map +1 -0
  818. package/dist/utils.js +583 -0
  819. package/dist/utils.js.map +1 -0
  820. package/dist/viewer/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
  821. package/dist/viewer/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
  822. package/dist/viewer/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
  823. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-2syK4fUT.woff +0 -0
  824. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-CBJ8pzag.woff2 +0 -0
  825. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  826. package/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  827. package/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  828. package/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  829. package/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  830. package/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  831. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-B4oTjJdl.woff +0 -0
  832. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-CBjNughH.woff2 +0 -0
  833. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  834. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  835. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  836. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  837. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  838. package/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  839. package/dist/viewer/assets/ibm-plex-mono-latin-400-italic-66oory27.woff +0 -0
  840. package/dist/viewer/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
  841. package/dist/viewer/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  842. package/dist/viewer/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  843. package/dist/viewer/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  844. package/dist/viewer/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  845. package/dist/viewer/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  846. package/dist/viewer/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  847. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-B7_fu1kp.woff2 +0 -0
  848. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-Bg0ZHwF4.woff +0 -0
  849. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  850. package/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  851. package/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  852. package/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  853. package/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  854. package/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  855. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-D6eaYXMU.woff +0 -0
  856. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-DRuN92E5.woff2 +0 -0
  857. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  858. package/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  859. package/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  860. package/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  861. package/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  862. package/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  863. package/dist/viewer/assets/index-2IPslW5t.js +13 -0
  864. package/dist/viewer/assets/index-DSwi2Seu.css +1 -0
  865. package/dist/viewer/index.html +16 -0
  866. package/package.json +67 -0
@@ -0,0 +1,2412 @@
1
+ "use strict";
2
+ /**
3
+ * Name Matcher
4
+ *
5
+ * Handles symbol name matching for reference resolution.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.matchByFilePath = matchByFilePath;
9
+ exports.sameLanguageFamily = sameLanguageFamily;
10
+ exports.isKnownLanguageFamily = isKnownLanguageFamily;
11
+ exports.crossesKnownFamily = crossesKnownFamily;
12
+ exports.matchFunctionRef = matchFunctionRef;
13
+ exports.matchByExactName = matchByExactName;
14
+ exports.matchByQualifiedName = matchByQualifiedName;
15
+ exports.preferCallSiteFile = preferCallSiteFile;
16
+ exports.resolveObjectLiteralMember = resolveObjectLiteralMember;
17
+ exports.resolveMethodOnType = resolveMethodOnType;
18
+ exports.matchCppCallChain = matchCppCallChain;
19
+ exports.matchScopedCallChain = matchScopedCallChain;
20
+ exports.matchDottedCallChain = matchDottedCallChain;
21
+ exports.normalizeInferredTypeName = normalizeInferredTypeName;
22
+ exports.clearNameMatcherMemos = clearNameMatcherMemos;
23
+ exports.localReceiverTypePatterns = localReceiverTypePatterns;
24
+ exports.matchMethodCall = matchMethodCall;
25
+ exports.rustFieldTypeName = rustFieldTypeName;
26
+ exports.matchFuzzy = matchFuzzy;
27
+ exports.dumpNameMatcherProfile = dumpNameMatcherProfile;
28
+ exports.matchReference = matchReference;
29
+ /**
30
+ * Ceiling on how many same-named definitions a FUZZY name-match strategy will
31
+ * score. A name defined more times than this is "ubiquitous" — a method/symbol
32
+ * re-declared across a vendored theme or SDK (e.g. `init`/`update`/`render` on
33
+ * every widget of a committed Metronic theme — #999). No directory-proximity or
34
+ * receiver-word-overlap score can reliably pick THE one true target among
35
+ * thousands, so the fuzzy strategies (matchByExactName's findBestMatch, and
36
+ * matchMethodCall Strategy 3) decline above the ceiling instead of emitting a
37
+ * low-confidence, almost-certainly-wrong edge. This also caps their per-ref cost
38
+ * at O(ceiling): without it, K same-named refs each scored K candidates — the
39
+ * O(K²) blow-up that pinned a core for 15-28 min at "Resolving refs … 94%" on a
40
+ * repo vendoring a large JS/TS theme (#999). The PRECISE strategies are
41
+ * unaffected: qualified-name, import-based, and class-name (Strategy 1/2)
42
+ * resolution all still run and resolve a ubiquitous name when the context names
43
+ * its exact target. Real repos top out near ~40 same-named methods, so a normal
44
+ * codebase never reaches this; only bulk-vendored code does. Tune via
45
+ * `CODEGRAPH_AMBIGUOUS_NAME_CEILING`.
46
+ */
47
+ const DEFAULT_AMBIGUOUS_NAME_CEILING = 500;
48
+ function resolveAmbiguousNameCeiling() {
49
+ const raw = process.env.CODEGRAPH_AMBIGUOUS_NAME_CEILING;
50
+ if (!raw)
51
+ return DEFAULT_AMBIGUOUS_NAME_CEILING;
52
+ const parsed = Number.parseInt(raw, 10);
53
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_AMBIGUOUS_NAME_CEILING;
54
+ }
55
+ const AMBIGUOUS_NAME_CEILING = resolveAmbiguousNameCeiling();
56
+ /**
57
+ * Try to resolve a path-like reference (e.g., "snippets/drawer-menu.liquid")
58
+ * by matching the filename against file nodes.
59
+ */
60
+ function matchByFilePath(ref, context) {
61
+ // Path-like (`a/b.liquid`) OR a bare filename ending in a short extension
62
+ // (`Foo.h` — an Objective-C `#import "Foo.h"`, resolved to the header by
63
+ // basename). A bare ref WITHOUT an extension is a symbol name, not a file, so
64
+ // leave it to the symbol-matching strategies.
65
+ if (!ref.referenceName.includes('/') && !/\.[A-Za-z][A-Za-z0-9]{0,3}$/.test(ref.referenceName)) {
66
+ return null;
67
+ }
68
+ // Extract the filename from the path
69
+ const fileName = ref.referenceName.split('/').pop();
70
+ if (!fileName)
71
+ return null;
72
+ // Search for file nodes with this name
73
+ const candidates = context.getNodesByName(fileName);
74
+ const fileNodes = candidates.filter(n => n.kind === 'file');
75
+ if (fileNodes.length === 0)
76
+ return null;
77
+ // Prefer exact path match on qualified_name
78
+ const exactMatch = fileNodes.find(n => n.qualifiedName === ref.referenceName || n.filePath === ref.referenceName);
79
+ if (exactMatch) {
80
+ return {
81
+ original: ref,
82
+ targetNodeId: exactMatch.id,
83
+ confidence: 0.95,
84
+ resolvedBy: 'file-path',
85
+ };
86
+ }
87
+ // Fall back to suffix match (e.g., ref="snippets/foo.liquid" matches
88
+ // "src/snippets/foo.liquid"). When several files share the basename — a
89
+ // `#include "RNCAsyncStorage.h"` with a same-named header on another platform
90
+ // (windows/code/ vs apple/) — prefer the one in the includer's own directory,
91
+ // then by directory proximity / same language family. A C/C++ include (and any
92
+ // bare-filename import) resolves relative to the including file, not to an
93
+ // arbitrary same-named header elsewhere in the tree.
94
+ const suffixMatches = fileNodes.filter(n => n.qualifiedName.endsWith(ref.referenceName) || n.filePath.endsWith(ref.referenceName));
95
+ if (suffixMatches.length > 0) {
96
+ return {
97
+ original: ref,
98
+ targetNodeId: pickClosestFileNode(suffixMatches, ref).id,
99
+ confidence: 0.85,
100
+ resolvedBy: 'file-path',
101
+ };
102
+ }
103
+ // If only one file node with this name, use it with lower confidence
104
+ if (fileNodes.length === 1) {
105
+ return {
106
+ original: ref,
107
+ targetNodeId: fileNodes[0].id,
108
+ confidence: 0.7,
109
+ resolvedBy: 'file-path',
110
+ };
111
+ }
112
+ return null;
113
+ }
114
+ /**
115
+ * Among several file nodes that all match a bare include/import by basename,
116
+ * pick the one closest to the referencing file: same directory first, then by
117
+ * directory-tree proximity, with the same language family as a tiebreak. A
118
+ * C/C++ `#include "X.h"` (and any bare-filename import) resolves relative to the
119
+ * including file — not to an arbitrary same-named header on another platform.
120
+ */
121
+ function pickClosestFileNode(candidates, ref) {
122
+ const dirOf = (p) => {
123
+ const i = p.lastIndexOf('/');
124
+ return i >= 0 ? p.slice(0, i) : '';
125
+ };
126
+ const refDir = dirOf(ref.filePath);
127
+ const sameDir = candidates.filter((c) => dirOf(c.filePath) === refDir);
128
+ const pool = sameDir.length > 0 ? sameDir : candidates;
129
+ let best = pool[0];
130
+ let bestScore = -Infinity;
131
+ for (const c of pool) {
132
+ const score = computePathProximity(ref.filePath, c.filePath) +
133
+ (sameLanguageFamily(c.language, ref.language) ? 5 : 0);
134
+ if (score > bestScore) {
135
+ bestScore = score;
136
+ best = c;
137
+ }
138
+ }
139
+ return best;
140
+ }
141
+ /**
142
+ * Language families that share a type system / runtime, so a same-language-only
143
+ * reference may still resolve across them (a Kotlin `Foo.BAR` can name a Java
144
+ * `Foo`). Anything not listed forms its own singleton family.
145
+ */
146
+ const LANGUAGE_FAMILY = {
147
+ java: 'jvm', kotlin: 'jvm', scala: 'jvm',
148
+ swift: 'apple', objc: 'apple',
149
+ // ArkTS is a TS superset — every HarmonyOS project mixes `.ets` UI with
150
+ // `.ts` logic modules, so refs must cross freely between them.
151
+ typescript: 'web', tsx: 'web', javascript: 'web', jsx: 'web', arkts: 'web',
152
+ c: 'c', cpp: 'c',
153
+ // Razor/Blazor markup names C# types — same family so `@model Foo` /
154
+ // `<MyComponent/>` resolve to their `.cs` class through the cross-family gate.
155
+ csharp: 'dotnet', razor: 'dotnet',
156
+ };
157
+ function sameLanguageFamily(a, b) {
158
+ if (a === b)
159
+ return true;
160
+ const fa = LANGUAGE_FAMILY[a];
161
+ return fa !== undefined && fa === LANGUAGE_FAMILY[b];
162
+ }
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;
172
+ }
173
+ /**
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.
182
+ */
183
+ function crossesKnownFamily(a, b) {
184
+ return isKnownLanguageFamily(a) && isKnownLanguageFamily(b) && !sameLanguageFamily(a, b);
185
+ }
186
+ /**
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.
195
+ */
196
+ function applyLanguageGate(candidates, ref) {
197
+ if (ref.referenceKind === 'references' || ref.referenceKind === 'function_ref') {
198
+ return candidates.filter((c) => sameLanguageFamily(c.language, ref.language));
199
+ }
200
+ if (ref.referenceKind === 'imports') {
201
+ return candidates.filter((c) => !crossesKnownFamily(c.language, ref.language));
202
+ }
203
+ return candidates;
204
+ }
205
+ /**
206
+ * Resolve a function-as-value reference (#756) — a function name used as a
207
+ * callback/function-pointer value (`register(handler)`, `o->cb = handler`,
208
+ * `{ .cb = handler }`, `signal(SIGINT, handler)`). The ONLY strategy allowed
209
+ * 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.
213
+ */
214
+ function matchFunctionRef(ref, context) {
215
+ // `this.<member>` refs are resolved ONLY by the class-scoped resolver in
216
+ // resolveOne (resolveThisMemberFnRef) — never by name matching here.
217
+ if (ref.referenceName.startsWith('this.'))
218
+ return null;
219
+ // In JS/TS/Python a bare identifier can never be a method value (methods
220
+ // are only reachable through a receiver — `this.m` / `self.m` /
221
+ // `Cls.m`), so bare fn-refs match FUNCTIONS only. This also sidesteps the
222
+ // pre-existing TS quirk of class fields extracting as method-kind nodes,
223
+ // which otherwise soaked up local names passed as arguments (excalidraw
224
+ // A/B finding; same pattern in vendored docopt.py). Python's `self.m`
225
+ // form keeps method targets via its own capture shape. C++ likewise: a
226
+ // bare identifier can only be a FREE function (member values need
227
+ // `&Cls::method`). PHP string callables name global FUNCTIONS (methods
228
+ // need the `[$obj, 'm']` array form, which carries its own shape). Other
229
+ // languages keep method targets: C# method groups, Swift/Dart
230
+ // implicit-self, Java/Kotlin method references.
231
+ const bareFnOnly = ref.language === 'typescript' || ref.language === 'tsx' ||
232
+ ref.language === 'javascript' || ref.language === 'jsx' ||
233
+ ref.language === 'arkts' ||
234
+ ref.language === 'cpp' || ref.language === 'python' ||
235
+ ref.language === 'php';
236
+ // Python additionally accepts CLASS targets for bare identifiers (#1478):
237
+ // class-as-value is a core Python idiom (`return SomeSerializer`,
238
+ // `Meta.model = Org`, registry dicts, `admin.site.register(Model, Admin)`)
239
+ // and, unlike TS, Python has no type-annotation recovery path. The
240
+ // false-positive mechanism behind the function-only rule was lowercase
241
+ // locals colliding with same-named METHODS (docopt.py) — a candidate must
242
+ // be an exact-name CLASS node here, and the extraction gate (same-file
243
+ // class ∪ imports) plus unique-or-drop still apply. Methods stay excluded.
244
+ const bareClassOk = ref.language === 'python';
245
+ // Qualified member-pointer (`&Widget::on_click` → "Widget::on_click"):
246
+ // resolve the member ON THAT SCOPE — exempt from bareFnOnly (the `&Cls::m`
247
+ // shape is an explicit member reference). Unique-or-drop like everything else.
248
+ if (ref.referenceName.includes('::')) {
249
+ const memberName = ref.referenceName.slice(ref.referenceName.lastIndexOf('::') + 2);
250
+ const scoped = context
251
+ .getNodesByName(memberName)
252
+ .filter((n) => (n.kind === 'function' || n.kind === 'method') &&
253
+ sameLanguageFamily(n.language, ref.language) &&
254
+ n.id !== ref.fromNodeId &&
255
+ (n.qualifiedName === ref.referenceName ||
256
+ n.qualifiedName.endsWith(`::${ref.referenceName}`)));
257
+ if (scoped.length === 0)
258
+ return null;
259
+ const sameFileScoped = scoped.filter((n) => n.filePath === ref.filePath);
260
+ const pool = sameFileScoped.length > 0 ? sameFileScoped : scoped;
261
+ if (sameFileScoped.length === 0 && scoped.length > 1)
262
+ return null;
263
+ const target = pool.reduce((a, b) => (a.startLine <= b.startLine ? a : b));
264
+ return {
265
+ original: ref,
266
+ targetNodeId: target.id,
267
+ confidence: 0.9,
268
+ resolvedBy: 'function-ref',
269
+ };
270
+ }
271
+ let candidates = context
272
+ .getNodesByName(ref.referenceName)
273
+ .filter((n) => (n.kind === 'function' ||
274
+ (!bareFnOnly && n.kind === 'method') ||
275
+ (bareClassOk && n.kind === 'class')) &&
276
+ sameLanguageFamily(n.language, ref.language) &&
277
+ n.id !== ref.fromNodeId // a function registering itself is not a dependency edge
278
+ );
279
+ if (candidates.length === 0)
280
+ return null;
281
+ // Swift implicit-self: a bare identifier can name a METHOD only of the
282
+ // ENCLOSING type (`Button(action: handleTap)` written inside that type) —
283
+ // a same-named method on any OTHER class is a parameter collision
284
+ // (Alamofire: a `request` parameter resolving to EventMonitor::request).
285
+ // Scope method candidates to the from-symbol's type; top-level code has no
286
+ // implicit self, so method targets are excluded there entirely. Free
287
+ // functions are unaffected.
288
+ if (ref.language === 'swift' && candidates.some((n) => n.kind === 'method')) {
289
+ const fromNode = context.getNodeById?.(ref.fromNodeId);
290
+ const sep = fromNode ? fromNode.qualifiedName.lastIndexOf('::') : -1;
291
+ const classPrefix = fromNode && sep > 0 ? fromNode.qualifiedName.slice(0, sep) : null;
292
+ candidates = candidates.filter((n) => {
293
+ if (n.kind !== 'method')
294
+ return true;
295
+ if (!classPrefix)
296
+ return false;
297
+ const mSep = n.qualifiedName.lastIndexOf('::');
298
+ if (mSep <= 0)
299
+ return false;
300
+ const methodPrefix = n.qualifiedName.slice(0, mSep);
301
+ // Accept exact-scope matches plus suffix relationships either way, so
302
+ // extension-declared members (`Holder::m`) still match a nested
303
+ // from-scope (`Module::Holder::wire`) and vice versa.
304
+ return (methodPrefix === classPrefix ||
305
+ methodPrefix.endsWith(`::${classPrefix}`) ||
306
+ classPrefix.endsWith(`::${methodPrefix}`));
307
+ });
308
+ if (candidates.length === 0)
309
+ return null;
310
+ }
311
+ // Same-file definition wins — the extraction gate guarantees most survivors
312
+ // have one, and it's the dominant C pattern (static callback registered in
313
+ // a same-file ops struct).
314
+ const sameFile = candidates.filter((n) => n.filePath === ref.filePath);
315
+ if (sameFile.length > 0) {
316
+ // Swift: several same-named METHODS in one file is an API overload family
317
+ // (`Session.request(...)` × N), and a bare identifier hitting it is almost
318
+ // always a same-named parameter, not a method value (Alamofire A/B
319
+ // finding) — refuse rather than guess. A single method (SwiftUI's
320
+ // `action: handleTap`) still resolves.
321
+ if (ref.language === 'swift' &&
322
+ sameFile.length > 1 &&
323
+ sameFile.every((n) => n.kind === 'method')) {
324
+ return null;
325
+ }
326
+ // Same-name overloads in one file are the same conceptual symbol; pick
327
+ // the first by position for determinism.
328
+ const target = sameFile.reduce((a, b) => (a.startLine <= b.startLine ? a : b));
329
+ return {
330
+ original: ref,
331
+ targetNodeId: target.id,
332
+ confidence: sameFile.length === 1 ? 0.95 : 0.9,
333
+ resolvedBy: 'function-ref',
334
+ };
335
+ }
336
+ // Cross-file (imported names the import resolver didn't already claim):
337
+ // only an unambiguous match resolves.
338
+ if (candidates.length === 1) {
339
+ return {
340
+ original: ref,
341
+ targetNodeId: candidates[0].id,
342
+ confidence: 0.8,
343
+ resolvedBy: 'function-ref',
344
+ };
345
+ }
346
+ return null;
347
+ }
348
+ /**
349
+ * A function nested inside another FUNCTION is only callable from within its
350
+ * container — Python, JS/TS, and every closure language scope it lexically.
351
+ * Resolving a bare name from elsewhere to a nested local fabricates an edge
352
+ * scope already rules out: `join(...)` in one function must never bind to a
353
+ * `join` defined inside a DIFFERENT function (#1230). A candidate whose
354
+ * qualifiedName parent is a same-file function/method is kept only when the
355
+ * ref originates inside that parent's line range. Class members are
356
+ * unaffected (their parent resolves to a class-like node), as are top-level
357
+ * symbols and C++ namespace-prefixed names (the prefix has no node).
358
+ */
359
+ function isLexicallyReachable(candidate, ref, context) {
360
+ if (candidate.kind !== 'function')
361
+ return true;
362
+ const qn = candidate.qualifiedName;
363
+ if (!qn || !qn.includes('::'))
364
+ return true;
365
+ const parentQn = qn.slice(0, qn.lastIndexOf('::'));
366
+ const containers = context
367
+ .getNodesByQualifiedName(parentQn)
368
+ .filter((p) => p.filePath === candidate.filePath &&
369
+ (p.kind === 'function' || p.kind === 'method') &&
370
+ p.startLine <= candidate.startLine &&
371
+ p.endLine >= candidate.endLine);
372
+ if (containers.length === 0)
373
+ return true;
374
+ return (ref.filePath === candidate.filePath &&
375
+ containers.some((p) => ref.line >= p.startLine && ref.line <= p.endLine));
376
+ }
377
+ /**
378
+ * Try to resolve a reference by exact name match
379
+ */
380
+ function matchByExactName(ref, context) {
381
+ // `import`-kind nodes are import STATEMENTS, not definitions, so a reference
382
+ // resolving to a sibling file's `import` is a meaningless edge — the real
383
+ // import→definition resolution is the import resolver's job (resolveViaImport),
384
+ // never name-matching here. Excluding them also removes a quadratic blow-up:
385
+ // a ubiquitous package (`react`, `@superset-ui/core`, Python `logging`/`typing`)
386
+ // is re-declared as an `import` node in every file that imports it, so K
387
+ // unresolved import refs each scored K same-named import candidates through
388
+ // findBestMatch — O(K²) per package, the dominant cost of "Resolving refs" on
389
+ // large import-heavy (front-end + back-end) repos (#915).
390
+ const candidates = applyLanguageGate(context.getNodesByName(ref.referenceName), ref)
391
+ .filter((n) => n.kind !== 'import')
392
+ // Nested locals are only reachable from inside their container (#1230).
393
+ .filter((n) => isLexicallyReachable(n, ref, context));
394
+ if (candidates.length === 0) {
395
+ return null;
396
+ }
397
+ // If only one match, use it — but penalize cross-language matches
398
+ if (candidates.length === 1) {
399
+ const isCrossLanguage = candidates[0].language !== ref.language;
400
+ return {
401
+ original: ref,
402
+ targetNodeId: candidates[0].id,
403
+ confidence: isCrossLanguage ? 0.5 : 0.9,
404
+ resolvedBy: 'exact-match',
405
+ };
406
+ }
407
+ // Ubiquitous-name ceiling (#999): above it, picking one target among K
408
+ // same-named defs by directory proximity is unreliable AND O(K) per ref — the
409
+ // quadratic behind the "Resolving refs" wedge on theme/SDK-vendoring repos.
410
+ // Decline; the precise strategies (qualified-name, import, class-name) already
411
+ // ran. Falls through to fuzzy, which itself only resolves a UNIQUE candidate.
412
+ if (candidates.length > AMBIGUOUS_NAME_CEILING) {
413
+ return null;
414
+ }
415
+ // Multiple matches - try to narrow down
416
+ const bestMatch = findBestMatch(ref, candidates, context);
417
+ if (bestMatch) {
418
+ // Lower confidence when the match is from a distant/unrelated module
419
+ const proximity = computePathProximity(ref.filePath, bestMatch.filePath);
420
+ const confidence = proximity >= 30 ? 0.7 : 0.4;
421
+ return {
422
+ original: ref,
423
+ targetNodeId: bestMatch.id,
424
+ confidence,
425
+ resolvedBy: 'exact-match',
426
+ };
427
+ }
428
+ return null;
429
+ }
430
+ /**
431
+ * Try to resolve by qualified name
432
+ */
433
+ function matchByQualifiedName(ref, context) {
434
+ // Check if the reference name looks qualified (contains :: or .)
435
+ if (!ref.referenceName.includes('::') && !ref.referenceName.includes('.')) {
436
+ return null;
437
+ }
438
+ // A method call `receiver.method()` can share an exact qualified name with a
439
+ // config-file key: `service.process()` (a `calls` ref named `service.process`)
440
+ // vs the yaml key `service.process`. Config keys are bound to their code refs
441
+ // upstream by the framework resolvers (`@Value` → `references`); a `calls` ref
442
+ // must never resolve to a yaml/properties config node — that's a wrong edge
443
+ // AND it hides the real callee. Drop those from both the exact and the partial
444
+ // candidate sets so resolution falls through to method resolution below (#1180).
445
+ const keepForRef = (nodes) => ref.referenceKind === 'calls'
446
+ ? nodes.filter((n) => !(n.kind === 'constant' && (n.language === 'yaml' || n.language === 'properties')))
447
+ : nodes;
448
+ const candidates = keepForRef(context.getNodesByQualifiedName(ref.referenceName));
449
+ if (candidates.length === 1) {
450
+ return {
451
+ original: ref,
452
+ targetNodeId: candidates[0].id,
453
+ confidence: 0.95,
454
+ resolvedBy: 'qualified-name',
455
+ };
456
+ }
457
+ // Several symbols share this exact qualified name (e.g. `Logger::log` declared
458
+ // in two files — an ODR clash or separate translation units): prefer the one
459
+ // in the call site's own file before the partial-match fallback below, else
460
+ // the first-indexed def wins and a call in `b/svc` targets `a/svc` (#1079).
461
+ if (candidates.length > 1) {
462
+ const ordered = preferCallSiteFile(candidates, ref.filePath);
463
+ if (ordered[0].filePath === ref.filePath) {
464
+ return {
465
+ original: ref,
466
+ targetNodeId: ordered[0].id,
467
+ confidence: 0.95,
468
+ resolvedBy: 'qualified-name',
469
+ };
470
+ }
471
+ }
472
+ // Erlang qualified refs (#1610): every erlang function's qualifiedName
473
+ // carries its arity (`mod::f/2`), and refs carry the call-site arity when it
474
+ // is statically known.
475
+ if (ref.language === 'erlang' && ref.referenceName.includes('::')) {
476
+ // A ref WITH arity that missed the exact lookup names an arity that isn't
477
+ // defined (or a module out of repo). Never fall through to the partial
478
+ // match — its "last segment" would be the arity digits — and never settle
479
+ // for a sibling arity: silent beats wrong.
480
+ if (/\/\d{1,3}$/.test(ref.referenceName))
481
+ return null;
482
+ // An arity-LESS qualified ref (dynamic MFA whose args list wasn't a
483
+ // static literal): resolve only when the module defines exactly ONE arity
484
+ // of that function; several arities with no signal is a guess.
485
+ const base = ref.referenceName.slice(ref.referenceName.lastIndexOf('::') + 2);
486
+ const prefix = `${ref.referenceName}/`;
487
+ const arityCands = keepForRef(context.getNodesByName(base)).filter((n) => n.qualifiedName.startsWith(prefix) && /^\d{1,3}$/.test(n.qualifiedName.slice(prefix.length)));
488
+ if (arityCands.length === 1) {
489
+ return {
490
+ original: ref,
491
+ targetNodeId: arityCands[0].id,
492
+ confidence: 0.85,
493
+ resolvedBy: 'qualified-name',
494
+ };
495
+ }
496
+ return null;
497
+ }
498
+ // Try partial qualified name match — again preferring the call site's own
499
+ // file when more than one symbol's qualifiedName ends with the reference.
500
+ const parts = ref.referenceName.split(/[:.]/);
501
+ const lastName = parts[parts.length - 1];
502
+ if (lastName) {
503
+ const partialCandidates = keepForRef(context.getNodesByName(lastName))
504
+ .filter((candidate) => candidate.qualifiedName.endsWith(ref.referenceName));
505
+ const chosen = preferCallSiteFile(partialCandidates, ref.filePath)[0];
506
+ if (chosen) {
507
+ return {
508
+ original: ref,
509
+ targetNodeId: chosen.id,
510
+ confidence: 0.85,
511
+ resolvedBy: 'qualified-name',
512
+ };
513
+ }
514
+ }
515
+ return null;
516
+ }
517
+ /**
518
+ * When a symbol name is ambiguous across files, prefer the candidate(s) declared
519
+ * in the call site's own file, keeping the rest in their original order (#1079).
520
+ * A same-file definition is the strongest language-agnostic signal for which of
521
+ * several same-named symbols a call means; without it, resolution collapses onto
522
+ * whichever was indexed first, so a call in `b/svc` wrongly targets `a/svc`.
523
+ * No-op when there are <2 candidates or none share the call site's file.
524
+ */
525
+ function preferCallSiteFile(nodes, callSiteFile) {
526
+ if (nodes.length < 2)
527
+ return nodes;
528
+ const same = [];
529
+ const other = [];
530
+ for (const n of nodes) {
531
+ if (n.filePath === callSiteFile)
532
+ same.push(n);
533
+ else
534
+ other.push(n);
535
+ }
536
+ return same.length ? [...same, ...other] : nodes;
537
+ }
538
+ /**
539
+ * Languages whose object literals declare callable members — `export const
540
+ * api = { call() {…}, get: () => {…} }` used as a namespace (#1573).
541
+ */
542
+ const OBJECT_LITERAL_LANGUAGES = new Set(['typescript', 'tsx', 'javascript', 'jsx', 'arkts']);
543
+ /** True when `inner`'s source range lies within `outer`'s (lines, then columns on a shared line). */
544
+ function rangeWithin(inner, outer) {
545
+ const innerEnd = inner.endLine ?? inner.startLine;
546
+ const outerEnd = outer.endLine ?? outer.startLine;
547
+ if (inner.startLine < outer.startLine || innerEnd > outerEnd)
548
+ return false;
549
+ if (inner.startLine === outer.startLine && inner.startColumn < outer.startColumn)
550
+ return false;
551
+ if (innerEnd === outerEnd && inner.endColumn > outer.endColumn)
552
+ return false;
553
+ return true;
554
+ }
555
+ function sameRange(a, b) {
556
+ return (a.startLine === b.startLine &&
557
+ a.startColumn === b.startColumn &&
558
+ (a.endLine ?? a.startLine) === (b.endLine ?? b.startLine) &&
559
+ a.endColumn === b.endColumn);
560
+ }
561
+ /**
562
+ * Resolve `container.member` where `container` is a VALUE holding an object
563
+ * literal — `export const api = { call() {…}, get: () => {…} }` used as the
564
+ * module's namespace (#1573). The members are extracted as plain functions
565
+ * with BARE qualified names inside the constant's source extent (there is no
566
+ * `api::call`), so neither the `Container::member` lookup the class-shaped
567
+ * kinds use (#825) nor the declared-type inference for singleton instances
568
+ * (#1292) can reach them, and every such call resolved to nothing — or, via
569
+ * an import, to the constant itself. This looks the member up by CONTAINMENT:
570
+ * a node named `member` whose range lies inside the container's, in the
571
+ * container's own file. A helper declared inside a member's body is not a
572
+ * member and is skipped; nothing else in the file can donate a match. Calls
573
+ * take callable kinds only; other references accept value members too.
574
+ */
575
+ function resolveObjectLiteralMember(container, member, ref, context, confidence, resolvedBy) {
576
+ if (container.kind !== 'constant' && container.kind !== 'variable')
577
+ return null;
578
+ if (!OBJECT_LITERAL_LANGUAGES.has(container.language))
579
+ return null;
580
+ if (!sameLanguageFamily(container.language, ref.language))
581
+ return null;
582
+ const inFile = context.getNodesInFile(container.filePath);
583
+ const callable = (n) => n.kind === 'function' || n.kind === 'method';
584
+ const valueMember = (n) => callable(n) || n.kind === 'property' || n.kind === 'variable' || n.kind === 'constant';
585
+ const accepts = ref.referenceKind === 'calls' ? callable : valueMember;
586
+ const inside = inFile.filter((n) => n.id !== container.id && rangeWithin(n, container));
587
+ let candidates = inside.filter((n) => n.name === member && accepts(n));
588
+ if (candidates.length === 0)
589
+ return null;
590
+ // Drop a candidate nested inside ANOTHER callable's body within the literal
591
+ // (`{ run() { const call = () => {}; } }` — `call` is `run`'s local, not a
592
+ // member). Strict containment: an identically-ranged sibling node for the
593
+ // same member (a property node over an arrow function) is not a body.
594
+ const bodies = inside.filter(callable);
595
+ candidates = candidates.filter((c) => !bodies.some((b) => b.id !== c.id && !sameRange(b, c) && rangeWithin(c, b)));
596
+ if (candidates.length === 0)
597
+ return null;
598
+ // Several survivors (a property AND a function for one arrow member, say):
599
+ // a callable first, then the earliest in source order.
600
+ candidates.sort((a, b) => {
601
+ const ca = callable(a) ? 0 : 1;
602
+ const cb = callable(b) ? 0 : 1;
603
+ if (ca !== cb)
604
+ return ca - cb;
605
+ return a.startLine - b.startLine || a.startColumn - b.startColumn;
606
+ });
607
+ return {
608
+ original: ref,
609
+ targetNodeId: candidates[0].id,
610
+ confidence,
611
+ resolvedBy,
612
+ };
613
+ }
614
+ // Exported for the precedence unit tests (#1079): they assert the
615
+ // preferredFqn → same-file → matches[0] ordering directly.
616
+ function resolveMethodOnType(typeName, methodName, ref, context, confidence, resolvedBy,
617
+ /**
618
+ * Optional FQN that identifies WHICH class declaration `typeName`
619
+ * refers to in the caller's file. When multiple candidates share
620
+ * the same qualifiedName (`FooConverter::convert` in both
621
+ * `dao/converter/` and `service/converter/`), the FQN's
622
+ * file-path-suffix picks the right one — the disambiguation
623
+ * signal Java imports carry but the call site doesn't (#314).
624
+ */
625
+ preferredFqn,
626
+ /** Recursion guard for the supertype/conformance walk. */
627
+ depth = 0) {
628
+ // Look up methods by name and match by qualifiedName ending in
629
+ // `<typeName>::<methodName>`. This works whether the method is defined
630
+ // in-class (`class Foo { int bar() { ... } }`) or out-of-line in a separate
631
+ // file (`int Foo::bar() { ... }` in foo.cpp while class Foo is in foo.hpp).
632
+ // The previous same-file approach missed the latter — the typical C++ layout.
633
+ // Prefer the context's per-(type, method) memo: the raw name lookup fetches
634
+ // EVERY node sharing the method name — tens of thousands of rows for a
635
+ // collision-heavy Java name like `execute` — and re-filtering that per ref
636
+ // was a dominant term in the #1122 watchdog kill on large repos. Only the
637
+ // ref-independent filter is memoized; per-ref disambiguation stays below.
638
+ let matches;
639
+ if (context.getMethodMatches) {
640
+ matches = context.getMethodMatches(typeName, methodName, ref.language);
641
+ }
642
+ else {
643
+ const methodCandidates = context.getNodesByName(methodName);
644
+ const want = `${typeName}::${methodName}`;
645
+ matches = [];
646
+ for (const m of methodCandidates) {
647
+ if (m.kind !== 'method')
648
+ continue;
649
+ if (m.language !== ref.language)
650
+ continue;
651
+ const qn = m.qualifiedName;
652
+ if (qn === want || qn.endsWith(`::${want}`)) {
653
+ matches.push(m);
654
+ }
655
+ }
656
+ }
657
+ if (matches.length === 0) {
658
+ // Conformance fallback: the method may be defined on a supertype `typeName`
659
+ // extends, or on a protocol / trait it conforms to (e.g. a Swift protocol-
660
+ // extension method, a C# default-interface or extension method, a Kotlin
661
+ // extension on a supertype). Walk supertypes transitively (depth-capped) via
662
+ // the resolved implements/extends edges — empty in the first resolution pass,
663
+ // populated in the conformance pass. Still VALIDATED (the method must exist on
664
+ // a supertype), so a wrong inference produces no edge.
665
+ if (depth < 4 && context.getSupertypes) {
666
+ const viaSupers = nmTimedT('rmot-supers', ref, () => {
667
+ for (const supertype of context.getSupertypes(typeName, ref.language)) {
668
+ const via = resolveMethodOnType(supertype, methodName, ref, context, confidence, resolvedBy, preferredFqn, depth + 1);
669
+ if (via)
670
+ return via;
671
+ }
672
+ return null;
673
+ });
674
+ if (viaSupers)
675
+ return viaSupers;
676
+ }
677
+ return null;
678
+ }
679
+ if (matches.length > 1 && preferredFqn) {
680
+ const ext = ref.language === 'kotlin' ? '.kt' : '.java';
681
+ const fqnPath = preferredFqn.replace(/\./g, '/') + ext;
682
+ const chosen = matches.find((m) => {
683
+ const fp = m.filePath.replace(/\\/g, '/');
684
+ return fp.endsWith(fqnPath) || fp.endsWith('/' + fqnPath);
685
+ });
686
+ if (chosen) {
687
+ return {
688
+ original: ref,
689
+ targetNodeId: chosen.id,
690
+ confidence,
691
+ resolvedBy,
692
+ };
693
+ }
694
+ }
695
+ // Language-agnostic disambiguation: when several same-named methods survive
696
+ // (e.g. two files each declaring `class Logger { void log(); }` — an ODR
697
+ // clash, an anonymous-namespace type, or separate translation units), prefer
698
+ // the definition in the CALL SITE's own file. Without this, every ambiguous
699
+ // call collapses onto the first-indexed definition, so a call in `b/svc.cpp`
700
+ // wrongly points at `a/svc.cpp` (#1079). This runs AFTER the `preferredFqn`
701
+ // block, so Java/Kotlin import disambiguation — whose target is intentionally
702
+ // in ANOTHER file (#314) — is unaffected: that block returns early whenever
703
+ // an import FQN pins the class.
704
+ const ordered = preferCallSiteFile(matches, ref.filePath);
705
+ return {
706
+ original: ref,
707
+ targetNodeId: ordered[0].id,
708
+ confidence,
709
+ resolvedBy,
710
+ };
711
+ }
712
+ // C++ keywords/control-flow tokens that can appear right before a receiver
713
+ // (e.g. `return ptr->m()`) and must NOT be treated as a type.
714
+ const CPP_NON_TYPE_TOKENS = new Set([
715
+ 'return', 'if', 'else', 'for', 'while', 'do', 'switch', 'case', 'default',
716
+ 'break', 'continue', 'goto', 'throw', 'new', 'delete', 'co_await', 'co_yield',
717
+ 'co_return', 'static_cast', 'const_cast', 'dynamic_cast', 'reinterpret_cast',
718
+ 'sizeof', 'alignof', 'typeid', 'and', 'or', 'not', 'xor',
719
+ ]);
720
+ function normalizeCppTypeName(typeName) {
721
+ const normalized = typeName
722
+ .replace(/\b(const|volatile|mutable|typename|class|struct)\b/g, ' ')
723
+ .replace(/[&*]+/g, ' ')
724
+ .replace(/<[^>]*>/g, ' ')
725
+ .replace(/\s+/g, ' ')
726
+ .trim();
727
+ if (!normalized)
728
+ return null;
729
+ const parts = normalized.split(/::/).filter(Boolean);
730
+ const last = parts[parts.length - 1];
731
+ if (!last)
732
+ return null;
733
+ if (CPP_NON_TYPE_TOKENS.has(last))
734
+ return null;
735
+ return last;
736
+ }
737
+ // Declarator regex: matches `Type receiver`, `Type* receiver`, `Type *receiver`,
738
+ // `Type*receiver`, `Type<X> receiver`, etc., REQUIRING a declarator terminator
739
+ // (`;`, `=`, `,`, `)`, `[`, `{`, `(`, or end-of-line) after the receiver. The
740
+ // terminator rules out uses like `return receiver->m()` where the preceding
741
+ // token is a keyword, not a type.
742
+ function buildDeclaratorRegex(escapedReceiver) {
743
+ return new RegExp(`([A-Za-z_][\\w:]*(?:\\s*<[^;=(){}]+>)?(?:\\s*[*&]+)?)\\s*\\b${escapedReceiver}\\b\\s*(?=[;=,)\\[{(]|$)`);
744
+ }
745
+ function inferCppReceiverType(receiverName, ref, context, depth = 0) {
746
+ // Per-file lines cache when available — this runs per `receiver->method()`
747
+ // ref and re-splitting the file each time is the same quadratic as the
748
+ // shared inferrer's (#1122).
749
+ const lines = context.getFileLines
750
+ ? context.getFileLines(ref.filePath)
751
+ : (context.readFile(ref.filePath)?.split(/\r?\n/) ?? null);
752
+ if (!lines || lines.length === 0)
753
+ return null;
754
+ const callLineIndex = Math.max(0, Math.min(lines.length - 1, ref.line - 1));
755
+ const escapedReceiver = receiverName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
756
+ const receiverPattern = new RegExp(`\\b${escapedReceiver}\\b`);
757
+ const declaratorRegex = buildDeclaratorRegex(escapedReceiver);
758
+ for (let i = callLineIndex; i >= 0; i--) {
759
+ const line = lines[i];
760
+ if (!line || !receiverPattern.test(line))
761
+ continue;
762
+ const declaratorMatch = line.match(declaratorRegex);
763
+ if (declaratorMatch) {
764
+ const normalized = normalizeCppTypeName(declaratorMatch[1] ?? '');
765
+ if (normalized === 'auto') {
766
+ // `auto x = Foo::instance();` — the declared type is deduced; recover it
767
+ // from the initializer (call return type / construction) (#645).
768
+ const initType = inferCppAutoInitializerType(line, receiverName, ref, context, depth);
769
+ if (initType)
770
+ return initType;
771
+ // No usable initializer on this line — keep scanning earlier ones.
772
+ }
773
+ else if (normalized) {
774
+ return normalized;
775
+ }
776
+ }
777
+ }
778
+ const headerCandidates = [
779
+ ref.filePath.replace(/\.(?:c|cc|cpp|cxx)$/i, '.h'),
780
+ ref.filePath.replace(/\.(?:c|cc|cpp|cxx)$/i, '.hpp'),
781
+ ref.filePath.replace(/\.(?:c|cc|cpp|cxx)$/i, '.hxx'),
782
+ ].filter((candidate, index, arr) => arr.indexOf(candidate) === index && candidate !== ref.filePath);
783
+ for (const headerPath of headerCandidates) {
784
+ if (!context.fileExists(headerPath))
785
+ continue;
786
+ const headerLines = context.getFileLines
787
+ ? context.getFileLines(headerPath)
788
+ : (context.readFile(headerPath)?.split(/\r?\n/) ?? null);
789
+ if (!headerLines)
790
+ continue;
791
+ for (const line of headerLines) {
792
+ if (!receiverPattern.test(line))
793
+ continue;
794
+ const declaratorMatch = line.match(declaratorRegex);
795
+ if (!declaratorMatch)
796
+ continue;
797
+ const normalized = normalizeCppTypeName(declaratorMatch[1] ?? '');
798
+ if (normalized && normalized !== 'auto')
799
+ return normalized;
800
+ }
801
+ }
802
+ return null;
803
+ }
804
+ /**
805
+ * Last `::`-separated segment of a (possibly namespace-qualified) C++ name.
806
+ */
807
+ function cppLastSegment(name) {
808
+ const parts = name.split('::').filter(Boolean);
809
+ return parts[parts.length - 1] ?? name;
810
+ }
811
+ /**
812
+ * Return type captured at extraction for `Class::method` (or a free function),
813
+ * read off the indexed node's `returnType` — used by the C++ (#645) and PHP
814
+ * (#608) chained-call resolvers. Language-filtered. Null when not indexed or no
815
+ * return type was recorded (a `void`/primitive return).
816
+ */
817
+ function lookupCalleeReturnType(callee, ref, context) {
818
+ let method = callee;
819
+ let cls = null;
820
+ if (callee.includes('::')) {
821
+ const parts = callee.split('::').filter(Boolean);
822
+ method = parts[parts.length - 1] ?? callee;
823
+ cls = parts.slice(0, -1).join('::');
824
+ }
825
+ const candidates = context.getNodesByName(method).filter((n) => (n.kind === 'method' || n.kind === 'function') &&
826
+ n.language === ref.language &&
827
+ !!n.returnType);
828
+ if (cls) {
829
+ const want = `${cls}::${method}`;
830
+ // The call site may name the class with MORE namespace qualification than
831
+ // the stored node (`details::registry::instance` at the call vs
832
+ // `registry::instance` on the node — the receiver type only carries the
833
+ // immediate class), or LESS. Accept an exact match or either being a
834
+ // namespace-suffix of the other; the shared `::<class>::<method>` tail keeps
835
+ // it specific.
836
+ const m = candidates.find((n) => n.qualifiedName === want ||
837
+ n.qualifiedName.endsWith(`::${want}`) ||
838
+ want.endsWith(`::${n.qualifiedName}`));
839
+ return m?.returnType ?? null;
840
+ }
841
+ return candidates.find((n) => n.kind === 'function')?.returnType ?? null;
842
+ }
843
+ /** Does the graph contain an aggregate type named `name`'s last segment? */
844
+ function cppClassExists(name, ref, context) {
845
+ const last = cppLastSegment(name);
846
+ return context
847
+ .getNodesByName(last)
848
+ .some((n) => (n.kind === 'class' || n.kind === 'struct' || n.kind === 'union') && n.language === ref.language);
849
+ }
850
+ /**
851
+ * Infer the class produced by a C++ call/construction expression, using return
852
+ * types captured at extraction (#645). Handles, in order:
853
+ * - `make_unique<T>()` / `make_shared<T>()` → T
854
+ * - single-level member call `recv.method()` → recv's type, then method's return
855
+ * - `Class::method()` / free `func()` → the callee's recorded return type
856
+ * - direct construction `Type()` / `ns::Type()` → Type
857
+ * Returns null when undeterminable. Callers MUST still validate the outer method
858
+ * exists on the result before creating an edge, so a wrong guess stays silent.
859
+ */
860
+ function resolveCppCallResultType(inner, ref, context, depth = 0) {
861
+ if (depth > 3)
862
+ return null; // guard against pathological mutual recursion
863
+ const expr = inner.trim();
864
+ const make = expr.match(/(?:^|::)(?:make_unique|make_shared)\s*<\s*([A-Za-z_]\w*)/);
865
+ if (make)
866
+ return make[1] ?? null;
867
+ // Single-level member call `recv.method` (the `manager.view().render()` shape).
868
+ const dotIdx = expr.lastIndexOf('.');
869
+ if (dotIdx > 0) {
870
+ const recv = expr.slice(0, dotIdx);
871
+ const method = expr.slice(dotIdx + 1);
872
+ if (recv.includes('.') || recv.includes('(') || recv.includes('::'))
873
+ return null; // single level only
874
+ const recvType = inferCppReceiverType(recv, ref, context, depth + 1);
875
+ if (!recvType)
876
+ return null;
877
+ return lookupCalleeReturnType(`${recvType}::${method}`, ref, context);
878
+ }
879
+ const ret = lookupCalleeReturnType(expr, ref, context);
880
+ if (ret)
881
+ return ret;
882
+ // Direct construction — the callee itself names a class/struct.
883
+ if (cppClassExists(expr, ref, context))
884
+ return cppLastSegment(expr);
885
+ return null;
886
+ }
887
+ /**
888
+ * Recover the type of an `auto`-declared local from its initializer on the
889
+ * declaration line — `auto x = Foo::instance();`, `auto w = make_unique<W>();`,
890
+ * `auto p = new W();`, `auto w = Widget();` (#645).
891
+ */
892
+ function inferCppAutoInitializerType(line, receiverName, ref, context, depth) {
893
+ const escaped = receiverName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
894
+ const m = line.match(new RegExp(`\\b${escaped}\\b\\s*=\\s*([^;]+)`));
895
+ if (!m || !m[1])
896
+ return null;
897
+ const init = m[1].trim();
898
+ const neu = init.match(/^new\s+([A-Za-z_][\w:]*)/);
899
+ if (neu && neu[1])
900
+ return cppLastSegment(neu[1]);
901
+ // A call or construction: `Foo(...)`, `A::b(...)`, `make_unique<T>(...)`.
902
+ const call = init.match(/^([A-Za-z_][\w:]*(?:\s*<[^>;]*>)?)\s*\(/);
903
+ if (call && call[1])
904
+ return resolveCppCallResultType(call[1].replace(/\s+/g, ''), ref, context, depth + 1);
905
+ return null;
906
+ }
907
+ /**
908
+ * Resolve a C++ chained call whose receiver is itself a call — encoded by the
909
+ * extractor as `<innerCallee>().<method>` (#645). The receiver's type is what
910
+ * the inner call returns; the outer method is then resolved and VALIDATED on it
911
+ * (resolveMethodOnType requires `cls::method` to exist), so a wrong inference
912
+ * produces no edge rather than a wrong one.
913
+ */
914
+ function matchCppCallChain(ref, context) {
915
+ const m = ref.referenceName.match(/^(.+)\(\)\.(\w+)$/);
916
+ if (!m || !m[1] || !m[2])
917
+ return null;
918
+ const cls = resolveCppCallResultType(m[1], ref, context);
919
+ if (!cls)
920
+ return null;
921
+ return resolveMethodOnType(cls, m[2], ref, context, 0.85, 'instance-method');
922
+ }
923
+ /**
924
+ * Resolve a `::`-scoped factory chain whose receiver is a scoped/static call —
925
+ * PHP `Cls::for($x)->method()` (#608, the per-credential Laravel client idiom) or
926
+ * Rust `Foo::new().bar()` (an associated-function call) — both encoded by the
927
+ * extractor as `Cls::factory().method`. The receiver's type is what `Cls::factory`
928
+ * returns: a `self` marker (PHP `: self`/`: static`, Rust `-> Self`) resolves to
929
+ * the factory's own type, a concrete return type to that type. The outer method is
930
+ * then resolved and VALIDATED on it (resolveMethodOnType requires the method to
931
+ * exist on the type or a supertype it conforms to), so a wrong inference yields no
932
+ * edge rather than a wrong one. Shared by the `::`-receiver languages (PHP, Rust).
933
+ */
934
+ function matchScopedCallChain(ref, context) {
935
+ const m = ref.referenceName.match(/^(.+)\(\)\.(\w+)$/);
936
+ if (!m || !m[1] || !m[2])
937
+ return null;
938
+ const inner = m[1];
939
+ const method = m[2];
940
+ if (!inner.includes('::'))
941
+ return null; // only static-factory (`Cls::method`) chains
942
+ const factoryClass = inner.slice(0, inner.lastIndexOf('::'));
943
+ const ret = lookupCalleeReturnType(inner, ref, context);
944
+ if (!ret)
945
+ return null;
946
+ // `self` (the extractor's marker for self/static/$this) → the factory's class.
947
+ const resolvedClass = ret === 'self' ? factoryClass : ret;
948
+ return resolveMethodOnType(resolvedClass, method, ref, context, 0.85, 'instance-method');
949
+ }
950
+ /**
951
+ * Languages where an unprefixed capitalized call `Foo(args)` constructs the
952
+ * class (so a `Foo(args).method()` receiver's type is `Foo`). Java/C# need `new`,
953
+ * so a bare `Foo()` there is a method call, not construction — excluded. Scala's
954
+ * `Foo(args)` is a case-class / companion `apply`, which conventionally returns
955
+ * `Foo` — and resolveMethodOnType validates, so a non-conventional `apply` that
956
+ * returns another type simply yields no edge rather than a wrong one. Pascal/Delphi:
957
+ * a `TFoo(x)` is a TYPECAST whose result is a `TFoo`, so `TFoo(x).method()` resolves
958
+ * the method on `TFoo` — same shape, same validation.
959
+ */
960
+ const CONSTRUCTS_VIA_BARE_CALL = new Set(['kotlin', 'swift', 'scala', 'dart', 'pascal']);
961
+ /**
962
+ * Resolve a dotted chained call whose receiver is a static factory / fluent call —
963
+ * `Foo.getInstance().bar()`, encoded by the extractor as `Foo.getInstance().bar`
964
+ * (#645/#608 mechanism). The receiver's type is what `Foo.getInstance` returns
965
+ * (its declared return type); the outer method is then resolved and VALIDATED on
966
+ * it (resolveMethodOnType requires `Type::method` to exist), so a wrong inference
967
+ * yields no edge rather than a wrong one (e.g. a same-named `bar()` on an
968
+ * unrelated class is never matched). Shared by the dot-notation languages
969
+ * (Java, Kotlin, C#, Swift) — same receiver shape, same `Class::method` qualified names.
970
+ */
971
+ function matchDottedCallChain(ref, context) {
972
+ const m = ref.referenceName.match(/^(.+)\(\)\.(\w+)$/);
973
+ if (!m || !m[1] || !m[2])
974
+ return null;
975
+ const inner = m[1]; // `Foo.getInstance`
976
+ const method = m[2]; // `bar`
977
+ const lastDot = inner.lastIndexOf('.');
978
+ if (lastDot <= 0) {
979
+ // Go: bare package-level factory FUNCTION `New().method()` — the receiver's
980
+ // type is what `New` returns; resolve the method on that.
981
+ if (ref.language === 'go') {
982
+ const ret = lookupCalleeReturnType(inner, ref, context);
983
+ if (ret) {
984
+ return resolveMethodOnType(ret, method, ref, context, 0.85, 'instance-method', importedFqnOf(ret, ref, context));
985
+ }
986
+ // `inner` isn't a function with a captured return type — typically a
987
+ // package-level VARIABLE holding a function value (e.g. gin's `engine()`),
988
+ // whose type we can't recover. Fall back to bare-name resolution of the
989
+ // method so we don't DROP an edge the un-re-encoded bare path would have
990
+ // found. (When `inner` IS a real factory function but the method doesn't
991
+ // exist on its return type, `ret` is truthy and we returned no edge above —
992
+ // the absent-method safety guarantee is preserved.)
993
+ //
994
+ // CRITICAL: resolve the TARGET via a synthetic bare-name ref, but return the
995
+ // match tied to the ORIGINAL `ref` (referenceName `inner().method`). The
996
+ // batched resolver (resolveAndPersistBatched) reads unresolved rows from
997
+ // offset 0 every pass and relies on the post-batch cleanup (row-id delete
998
+ // for DB-loaded refs, referenceName-keyed delete otherwise, #1269) to
999
+ // clear each resolved row so the batch empties. If we propagated the
1000
+ // synthetic ref's bare `method` as `.original`, a key-based delete
1001
+ // would never match the stored `inner().method` row, the batch would
1002
+ // never drain, and the loop would re-resolve + re-insert forever (a runaway
1003
+ // that grew gin's graph to 5M edges / 1.4 GB before this fix).
1004
+ const bareRef = { ...ref, referenceName: method };
1005
+ const bareMatch = matchByExactName(bareRef, context) ?? matchFuzzy(bareRef, context);
1006
+ return bareMatch ? { ...bareMatch, original: ref } : null;
1007
+ }
1008
+ // Constructor receiver `Foo(args).method()` (encoded `Foo().method`): a bare,
1009
+ // capitalized inner is a class construction, so the receiver's type is the
1010
+ // class itself — resolve the method on it. Only in languages where an
1011
+ // unprefixed capitalized call constructs the class (Kotlin, Swift); in Java/C#
1012
+ // a bare `Foo()` is a method call (constructors need `new`), so we must not
1013
+ // assume construction. A lowercase bare inner is a top-level `factory().method()`
1014
+ // whose type we can't recover — bail.
1015
+ if (!CONSTRUCTS_VIA_BARE_CALL.has(ref.language) || !/^[A-Z]/.test(inner))
1016
+ return null;
1017
+ return resolveMethodOnType(inner, method, ref, context, 0.85, 'instance-method', importedFqnOf(inner, ref, context));
1018
+ }
1019
+ // Factory/fluent receiver `Receiver.factory(args).method()`: the receiver's
1020
+ // type is what `Receiver.factory` returns (its declared return type).
1021
+ const factoryClass = inner.slice(0, lastDot).split('.').pop(); // simple class name
1022
+ const factoryMethod = inner.slice(lastDot + 1);
1023
+ if (!factoryClass || !factoryMethod)
1024
+ return null;
1025
+ const ret = lookupCalleeReturnType(`${factoryClass}::${factoryMethod}`, ref, context);
1026
+ if (!ret) {
1027
+ // Objective-C: a class-message factory — `[X alloc]`, `[X new]`,
1028
+ // `[X sharedFoo]` — returns an instance of the RECEIVER class `X` by
1029
+ // convention (`instancetype`). So when the factory's own return type isn't
1030
+ // recoverable (its selector returns `instancetype`, or `alloc`/`new` aren't
1031
+ // user-defined nodes at all), the receiver's type is the class `X` itself.
1032
+ // This resolves the ubiquitous `[[X alloc] init]` and singleton chains.
1033
+ // resolveMethodOnType validates against X (and its supertypes), so a class
1034
+ // whose method actually lives elsewhere yields NO edge, not a wrong one — and
1035
+ // crucially this does NOT fire when a concrete return type WAS captured but
1036
+ // simply lacks the method (that already returned null above: absent-method
1037
+ // safety, so a same-named decoy is still never matched).
1038
+ if (ref.language === 'objc' && /^[A-Z]/.test(factoryClass)) {
1039
+ return resolveMethodOnType(factoryClass, method, ref, context, 0.8, 'instance-method', importedFqnOf(factoryClass, ref, context));
1040
+ }
1041
+ // Pascal/Delphi: the extractor only re-encodes a `TFoo`/`IFoo`-prefixed chain
1042
+ // (the type-naming convention), so `factoryClass` is always a real class here.
1043
+ // A factory whose return type wasn't captured is a CONSTRUCTOR
1044
+ // (`TFileMem.Create().SetCachePerformance` — `constructor Create` has no `:
1045
+ // TBar` annotation but returns its own class) or an unannotated function. In
1046
+ // both cases the receiver's type is the class itself, so resolve the method on
1047
+ // `factoryClass`. resolveMethodOnType validates against it (and its
1048
+ // supertypes), so a wrong inference yields no edge — and this never fires when
1049
+ // a return type WAS captured but lacks the method (absent-method safety above).
1050
+ if (ref.language === 'pascal' && /^[TI]/.test(factoryClass)) {
1051
+ return resolveMethodOnType(factoryClass, method, ref, context, 0.8, 'instance-method', importedFqnOf(factoryClass, ref, context));
1052
+ }
1053
+ return null;
1054
+ }
1055
+ return resolveMethodOnType(ret, method, ref, context, 0.85, 'instance-method', importedFqnOf(ret, ref, context));
1056
+ }
1057
+ /**
1058
+ * When several classes share a simple type name, the caller file's import of
1059
+ * that type is the only signal that names WHICH one (#314). Returns the imported
1060
+ * FQN for `typeName` in the ref's file, or undefined.
1061
+ */
1062
+ function importedFqnOf(typeName, ref, context) {
1063
+ const imports = context.getImportMappings(ref.filePath, ref.language);
1064
+ return imports.find((i) => i.localName === typeName)?.source;
1065
+ }
1066
+ /**
1067
+ * Java/Kotlin: infer a receiver's declared type by walking field declarations
1068
+ * in the class enclosing the call site. The field's `signature` is already in
1069
+ * the form "<TypeName> <fieldName>" (set by tree-sitter.ts extractField), so we
1070
+ * pull the type from there. Handles Spring `@Resource UserBO userbo;` /
1071
+ * `@Autowired private UserService userService;` where the receiver field name
1072
+ * doesn't match the class name by Java naming convention.
1073
+ *
1074
+ * Returns the bare type name (generics stripped, dotted package stripped) or
1075
+ * null when no matching field is in the enclosing class.
1076
+ */
1077
+ function inferJavaFieldReceiverType(receiverName, ref, context) {
1078
+ const inFile = context.getNodesInFile(ref.filePath);
1079
+ if (inFile.length === 0)
1080
+ return null;
1081
+ // Find the class enclosing the call line (tightest match by latest start).
1082
+ let enclosing = null;
1083
+ for (const n of inFile) {
1084
+ if (n.kind !== 'class' && n.kind !== 'interface')
1085
+ continue;
1086
+ if (n.language !== ref.language)
1087
+ continue;
1088
+ const end = n.endLine ?? n.startLine;
1089
+ if (n.startLine <= ref.line && end >= ref.line) {
1090
+ if (!enclosing || n.startLine >= enclosing.startLine)
1091
+ enclosing = n;
1092
+ }
1093
+ }
1094
+ if (!enclosing)
1095
+ return null;
1096
+ const enclosingEnd = enclosing.endLine ?? enclosing.startLine;
1097
+ const field = inFile.find((n) => n.kind === 'field' &&
1098
+ n.name === receiverName &&
1099
+ n.language === ref.language &&
1100
+ n.startLine >= enclosing.startLine &&
1101
+ (n.endLine ?? n.startLine) <= enclosingEnd);
1102
+ if (!field || !field.signature)
1103
+ return null;
1104
+ // Signature shape: "<TypeName> <fieldName>" (extractField). Pull the type,
1105
+ // strip generics + dotted package, drop array/varargs markers.
1106
+ const beforeName = field.signature.slice(0, field.signature.lastIndexOf(field.name));
1107
+ const typeRaw = beforeName.trim();
1108
+ if (!typeRaw)
1109
+ return null;
1110
+ const typeNoGenerics = typeRaw.replace(/<[^>]*>/g, '').trim();
1111
+ const typeNoArray = typeNoGenerics.replace(/\[\s*\]/g, '').replace(/\.\.\.$/, '').trim();
1112
+ const parts = typeNoArray.split(/[.\s]+/).filter(Boolean);
1113
+ const lastPart = parts[parts.length - 1];
1114
+ if (!lastPart)
1115
+ return null;
1116
+ if (!/^[A-Z]/.test(lastPart))
1117
+ return null; // primitives / lowercase → skip
1118
+ return lastPart;
1119
+ }
1120
+ // ── Local-variable receiver-type inference (#1108) ──────────────────────────
1121
+ //
1122
+ // Instance calls through a local variable (`const lg = new Logger(); lg.log()`)
1123
+ // only resolved in C++ before this — no other language could learn the
1124
+ // receiver's type. Local variables are not indexed as nodes (node-explosion),
1125
+ // so, like the C++ inferrer above, we read the enclosing function's source and
1126
+ // match the receiver's declaration/initializer to recover its type. The type is
1127
+ // then handed to resolveMethodOnType, which VALIDATES that the type actually
1128
+ // declares the method, so a mis-inference produces NO edge — the safety net
1129
+ // that lets the patterns below stay simple. C++ keeps its dedicated inferrer
1130
+ // (header scan + `auto`); this covers every other language.
1131
+ // Tokens a loose pattern might capture that are never a user-defined type.
1132
+ const NON_TYPE_RECEIVER_TOKENS = new Set([
1133
+ 'this', 'self', 'super', 'new', 'return', 'await', 'yield', 'typeof',
1134
+ 'null', 'nil', 'None', 'true', 'false', 'True', 'False', 'undefined',
1135
+ ]);
1136
+ /**
1137
+ * Normalize a captured type expression to a simple type name: drop generic
1138
+ * args and pointer/ref markers, take the last `.`/`::`-qualified segment, and
1139
+ * reject obvious non-types.
1140
+ */
1141
+ function normalizeInferredTypeName(raw) {
1142
+ const cleaned = raw.replace(/<[^>]*>/g, '').replace(/[&*]/g, '').trim();
1143
+ const seg = cleaned.split(/[.:]+/).filter(Boolean).pop();
1144
+ if (!seg)
1145
+ return null;
1146
+ if (NON_TYPE_RECEIVER_TOKENS.has(seg))
1147
+ return null;
1148
+ return seg;
1149
+ }
1150
+ /**
1151
+ * Per-language patterns that recover a local variable's (or typed parameter's)
1152
+ * type from its declaration/initializer. Each regex captures the type in group
1153
+ * 1; `r` is the already-escaped receiver name. Ordered most-specific first.
1154
+ * PascalCase is required in the capture where the language convention allows,
1155
+ * as a cheap false-positive guard on top of resolveMethodOnType's validation.
1156
+ */
1157
+ /**
1158
+ * Compiled-pattern memo for the receiver-type pattern builders below. They
1159
+ * run for EVERY `receiver.method()` ref the matcher attempts, compiling 2–4
1160
+ * fresh RegExp objects per call — and receivers repeat massively (`self`
1161
+ * alone accounts for tens of thousands of refs on a Lua repo, measured 41µs
1162
+ * per methodCall miss on kong with compilation a large slice). The patterns
1163
+ * are a pure function of (language, receiver) and non-global (`.match()`
1164
+ * never touches lastIndex), so shared instances are behavior-identical.
1165
+ * FIFO-capped with no per-get mutation (the §7a.6 LRU-churn lesson): a hit
1166
+ * costs one Map lookup, overflow evicts oldest, and an evicted entry simply
1167
+ * recompiles exactly as every call did before this memo.
1168
+ */
1169
+ const PATTERN_MEMO = new Map();
1170
+ const PATTERN_MEMO_CAP = 8192;
1171
+ const INFER_SCAN_STATES = new WeakMap();
1172
+ function getInferScanStates(context) {
1173
+ let m = INFER_SCAN_STATES.get(context);
1174
+ if (!m) {
1175
+ m = new Map();
1176
+ INFER_SCAN_STATES.set(context, m);
1177
+ }
1178
+ return m;
1179
+ }
1180
+ /** Drop the per-context scan states (see ReferenceResolver.clearCaches). */
1181
+ function clearNameMatcherMemos(context) {
1182
+ INFER_SCAN_STATES.delete(context);
1183
+ }
1184
+ function memoPatterns(key, build) {
1185
+ const hit = PATTERN_MEMO.get(key);
1186
+ if (hit)
1187
+ return hit;
1188
+ const patterns = build();
1189
+ if (PATTERN_MEMO.size >= PATTERN_MEMO_CAP) {
1190
+ const oldest = PATTERN_MEMO.keys().next().value;
1191
+ if (oldest !== undefined)
1192
+ PATTERN_MEMO.delete(oldest);
1193
+ }
1194
+ PATTERN_MEMO.set(key, patterns);
1195
+ return patterns;
1196
+ }
1197
+ function localReceiverTypePatterns(language, r) {
1198
+ return memoPatterns(`${language}|${r}`, () => buildLocalReceiverTypePatterns(language, r));
1199
+ }
1200
+ function buildLocalReceiverTypePatterns(language, r) {
1201
+ switch (language) {
1202
+ case 'typescript':
1203
+ case 'javascript':
1204
+ case 'tsx':
1205
+ case 'jsx':
1206
+ case 'arkts':
1207
+ return [
1208
+ new RegExp(`\\b${r}\\b\\s*=\\s*new\\s+([A-Za-z_$][\\w.$]*)`), // = new Logger()
1209
+ // No keyword requirement, so this matches BOTH a local annotation
1210
+ // (`const lg: Logger`) and a typed parameter (`function use(lg: Logger)`
1211
+ // / `(lg: Logger) =>`) — the parameter case the old `const|let|var`
1212
+ // prefix excluded (#1125). Mirrors Kotlin/Swift/Scala; the capture stops
1213
+ // at `<` so a generic-typed param (`repo: Repository<User>`) still yields
1214
+ // `Repository`. resolveMethodOnType validates the type actually declares
1215
+ // the method, so the looser match produces no edge on a mis-inference.
1216
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.$]*)`), // lg: Logger (annotation or typed param)
1217
+ ];
1218
+ case 'python':
1219
+ return [
1220
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // lg = Logger(...)
1221
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // lg: Logger (PEP 526)
1222
+ ];
1223
+ case 'java':
1224
+ return [
1225
+ new RegExp(`\\b${r}\\b\\s*=\\s*new\\s+([A-Za-z_][\\w.]*)`), // = new Logger()
1226
+ new RegExp(`\\b([A-Z][\\w.]*)\\s+${r}\\b\\s*[=;,)]`), // Logger lg; / param
1227
+ ];
1228
+ case 'kotlin':
1229
+ return [
1230
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // val lg = Logger(...)
1231
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // val lg: Logger / param
1232
+ ];
1233
+ case 'csharp':
1234
+ return [
1235
+ new RegExp(`\\b${r}\\b\\s*=\\s*new\\s+([A-Za-z_][\\w.]*)`), // = new Logger()
1236
+ new RegExp(`\\b([A-Z][\\w.]*)\\s+${r}\\b\\s*[=;,)]`), // Logger lg; / param
1237
+ ];
1238
+ case 'swift':
1239
+ return [
1240
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // let lg = Logger(...)
1241
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // let lg: Logger / param
1242
+ ];
1243
+ case 'rust':
1244
+ return [
1245
+ new RegExp(`\\blet\\s+(?:mut\\s+)?${r}\\b(?:\\s*:[^=]+)?=\\s*&?(?:mut\\s+)?([A-Z][\\w]*)`), // let lg = Logger::new()/Logger{}/Logger
1246
+ // No `let`, so this covers a `let lg: Logger` binding AND a typed
1247
+ // parameter (`fn use(lg: &Logger)`, a closure `|lg: Logger|`) — the
1248
+ // parameter case the old `let`-anchored pattern excluded (#1125).
1249
+ new RegExp(`\\b${r}\\s*:\\s*&?(?:mut\\s+)?([A-Z][\\w]*)`), // lg: Logger (binding or typed param)
1250
+ ];
1251
+ case 'go':
1252
+ return [
1253
+ new RegExp(`\\b${r}\\b\\s*:=\\s*&?([A-Za-z_][\\w.]*)\\s*{`), // lg := Logger{} / &Logger{}
1254
+ new RegExp(`\\bvar\\s+${r}\\s+\\*?([A-Za-z_][\\w.]*)`), // var lg Logger / *Logger
1255
+ // A typed parameter / method receiver (`func use(lg Logger)`,
1256
+ // `func (l Logger) M()`) — name-before-type with no `var`/`:=` (#1125).
1257
+ // PascalCase-guarded (unlike the anchored patterns above) to keep the
1258
+ // keyword-free `ident Type` shape from matching unrelated pairs; the
1259
+ // enclosing-scope bound already excludes package-level struct fields.
1260
+ new RegExp(`\\b${r}\\s+\\*?([A-Z][\\w.]*)`), // func use(lg Logger) / (l Logger)
1261
+ ];
1262
+ case 'ruby':
1263
+ return [
1264
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w:]*)\\.new\\b`), // lg = Logger.new
1265
+ ];
1266
+ case 'scala':
1267
+ return [
1268
+ new RegExp(`\\b${r}\\b\\s*=\\s*(?:new\\s+)?([A-Z][\\w.]*)`), // val lg = new Logger / Logger(...)
1269
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // val lg: Logger / param
1270
+ ];
1271
+ case 'dart':
1272
+ return [
1273
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // var lg = Logger(...)
1274
+ // Trailing `[=;,)]` (not just `[=;]`) so a typed parameter — `Logger lg)`
1275
+ // / `Logger lg,` — matches too, not only `Logger lg = ...` / `Logger lg;`
1276
+ // (#1125). Mirrors Java/C#.
1277
+ new RegExp(`\\b([A-Z][\\w.]*)\\s+${r}\\b\\s*[=;,)]`), // Logger lg = ... / param
1278
+ ];
1279
+ case 'php':
1280
+ return [
1281
+ new RegExp(`\\$?${r}\\b\\s*=\\s*new\\s+([A-Za-z_\\\\][\\w\\\\]*)`), // $lg = new Logger()
1282
+ // A typed parameter (`function use(Logger $lg)`, `?Logger $lg`,
1283
+ // `\\App\\Logger $lg`, `&$lg` by-ref) and a typed `catch (E $e)` — the
1284
+ // type sits before the `$`-variable (#1125). Namespace `\\` allowed.
1285
+ new RegExp(`\\b([A-Za-z_\\\\][\\w\\\\]*)\\s+&?\\$${r}\\b`), // Logger $lg (typed param)
1286
+ ];
1287
+ case 'lua':
1288
+ case 'luau':
1289
+ return [
1290
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w]*)\\.new\\b`), // local lg = Logger.new()
1291
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w]*)\\s*\\(`), // local lg = Logger(...) (callable table)
1292
+ // Luau annotation (`local lg: Logger`) / typed param — but Lua's
1293
+ // method-call syntax is the IDENTICAL `receiver:Name` shape, and the
1294
+ // backward scan starts on the call's own line, so without a gate any
1295
+ // PascalCase method call (`lg:Log()`, the Roblox convention)
1296
+ // self-matches as "type = Log" before the scan reaches the real
1297
+ // declaration (#1124). The lookahead rejects a capture followed by
1298
+ // any of Lua's three call forms — `(args)`, `"s"`/`'s'`/`[[s]]`,
1299
+ // `{t}` — and its leading `[\w.]` alternative stops backtracking from
1300
+ // shrinking the capture to dodge the gate (`lg:Log()` would otherwise
1301
+ // still match, as `Lo`).
1302
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)(?![\\w.]|\\s*[({"'\\[])`), // local lg: Logger / typed param
1303
+ ];
1304
+ case 'r':
1305
+ return [
1306
+ new RegExp(`\\b${r}\\b\\s*(?:<-|<<-|=)\\s*([A-Z][\\w.]*)\\$new\\b`), // lg <- Logger$new() (R6)
1307
+ ];
1308
+ case 'pascal':
1309
+ return [
1310
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w]*)`), // var lg: TLogger / param lg: TLogger
1311
+ new RegExp(`\\b${r}\\b\\s*:=\\s*([A-Z][\\w.]*)\\.Create\\b`), // lg := TLogger.Create
1312
+ ];
1313
+ case 'cfml':
1314
+ case 'cfscript':
1315
+ return [
1316
+ // svc = new UserService() / new path.to.UserService() — dotted component
1317
+ // paths reduce to their final segment via normalizeInferredTypeName.
1318
+ // Also matches inside tag markup (`<cfset svc = new UserService()>`)
1319
+ // since the scan reads raw source lines.
1320
+ new RegExp(`\\b${r}\\b\\s*=\\s*new\\s+([A-Za-z_][\\w.]*)`),
1321
+ // The classic form: svc = createObject("component", "path.to.UserService")
1322
+ // (casing of createObject varies in the wild), plus the modern
1323
+ // single-argument form createObject("path.to.UserService").
1324
+ new RegExp(`\\b${r}\\b\\s*=\\s*[Cc]reate[Oo]bject\\s*\\(\\s*["']component["']\\s*,\\s*["']([\\w.]+)["']`),
1325
+ new RegExp(`\\b${r}\\b\\s*=\\s*[Cc]reate[Oo]bject\\s*\\(\\s*["']([\\w.]+)["']\\s*\\)`),
1326
+ // Typed cfscript parameter: `function save(UserService svc)` /
1327
+ // `required UserService svc` — CFML's built-in types (string, numeric,
1328
+ // any, struct…) are lowercase by convention, so the PascalCase guard
1329
+ // excludes them.
1330
+ new RegExp(`\\b([A-Z][\\w.]*)\\s+${r}\\b\\s*[=;,)]`),
1331
+ // Tag-form typed argument, either attribute order:
1332
+ // <cfargument name="svc" type="path.to.UserService">
1333
+ new RegExp(`\\bcfargument[^>\\n]*\\bname\\s*=\\s*["']${r}["'][^>\\n]*\\btype\\s*=\\s*["']([\\w.]+)["']`, 'i'),
1334
+ new RegExp(`\\bcfargument[^>\\n]*\\btype\\s*=\\s*["']([\\w.]+)["'][^>\\n]*\\bname\\s*=\\s*["']${r}["']`, 'i'),
1335
+ // Component property (incl. WireBox DI): `property name="svc"
1336
+ // inject="UserService";` / `<cfproperty name="svc" type="UserService">`,
1337
+ // either attribute order. An inject DSL value with a namespace
1338
+ // (`inject="svc@core"`) captures only the leading name and simply
1339
+ // fails type-validation — no edge, never a wrong one.
1340
+ new RegExp(`\\b(?:cf)?property\\b[^;\\n]*\\bname\\s*=\\s*["']${r}["'][^;\\n]*\\b(?:type|inject)\\s*=\\s*["']([\\w.]+)["']`, 'i'),
1341
+ new RegExp(`\\b(?:cf)?property\\b[^;\\n]*\\b(?:type|inject)\\s*=\\s*["']([\\w.]+)["'][^;\\n]*\\bname\\s*=\\s*["']${r}["']`, 'i'),
1342
+ ];
1343
+ default:
1344
+ return [];
1345
+ }
1346
+ }
1347
+ /** 1-based start line of the tightest function/method enclosing the call. */
1348
+ function enclosingScopeStartLine(ref, context) {
1349
+ let start = 1;
1350
+ for (const n of context.getNodesInFile(ref.filePath)) {
1351
+ if (n.kind !== 'function' && n.kind !== 'method')
1352
+ continue;
1353
+ if (n.language !== ref.language)
1354
+ continue;
1355
+ const end = n.endLine ?? n.startLine;
1356
+ if (n.startLine <= ref.line && end >= ref.line && n.startLine >= start) {
1357
+ start = n.startLine;
1358
+ }
1359
+ }
1360
+ return start;
1361
+ }
1362
+ /**
1363
+ * Infer a receiver's type from its local declaration/initializer in the
1364
+ * enclosing function body. Language-dispatched; returns null for languages
1365
+ * without patterns or when no declaration is found. Bounded to the enclosing
1366
+ * scope so a same-named variable in another function can't leak in.
1367
+ */
1368
+ function inferLocalReceiverType(receiverName, ref, context) {
1369
+ // CFML scope prefixes: `variables.svc` / `this.svc` name a COMPONENT-scoped
1370
+ // field whose assignment or `property` declaration usually lives outside the
1371
+ // calling function (the init-pseudoconstructor / WireBox-injection pattern),
1372
+ // and `local.svc` is an explicit function-local. Strip the prefix so the
1373
+ // declaration patterns match (`variables.svc = new X()`, `property
1374
+ // name="svc" …`, `var svc = …` all bind the bare name), and widen the scan
1375
+ // to the whole file for the component-scoped forms — nearest-declaration-
1376
+ // backward still wins, so a function-local shadowing the field is preferred.
1377
+ let scanReceiver = receiverName;
1378
+ let componentScoped = false;
1379
+ if (ref.language === 'cfml' || ref.language === 'cfscript') {
1380
+ const scoped = receiverName.match(/^(variables|this|local|arguments)\.(.+)$/i);
1381
+ if (scoped) {
1382
+ scanReceiver = scoped[2];
1383
+ const scope = scoped[1].toLowerCase();
1384
+ componentScoped = scope === 'variables' || scope === 'this';
1385
+ }
1386
+ }
1387
+ // PHP `$this->prop` receiver — the property's declaration lives outside the
1388
+ // calling method (a promoted constructor parameter `private readonly Foo $prop`,
1389
+ // a typed property `private Foo $prop;`, or a classic constructor parameter
1390
+ // `Foo $prop` assigned in __construct). Strip the prefix and widen the scan to
1391
+ // the whole file (the constructor may sit below the calling method), but —
1392
+ // unlike CFML's scopes above — switch to PROPERTY-shaped patterns: a plain
1393
+ // `$prop` local or parameter lives in a different namespace than `$this->prop`
1394
+ // and can never shadow it, so the generic local patterns would type the
1395
+ // property from unrelated same-named variables in other methods (a wrong
1396
+ // 0.9-confidence edge, not a missing one).
1397
+ let phpProperty = false;
1398
+ if (ref.language === 'php') {
1399
+ const scoped = receiverName.match(/^this->(.+)$/);
1400
+ if (scoped) {
1401
+ scanReceiver = scoped[1];
1402
+ componentScoped = true;
1403
+ phpProperty = true;
1404
+ }
1405
+ }
1406
+ const escapedReceiver = scanReceiver.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1407
+ const patterns = phpProperty
1408
+ ? phpPropertyTypePatterns(escapedReceiver)
1409
+ : localReceiverTypePatterns(ref.language, escapedReceiver);
1410
+ if (patterns.length === 0)
1411
+ return null;
1412
+ // Split through the context's per-file lines cache when available: this runs
1413
+ // for EVERY `receiver.method()` ref, and re-splitting the whole file per ref
1414
+ // was ~20% of total index CPU on Java-heavy repos (#1122).
1415
+ const lines = context.getFileLines
1416
+ ? context.getFileLines(ref.filePath)
1417
+ : (context.readFile(ref.filePath)?.split(/\r?\n/) ?? null);
1418
+ if (!lines || lines.length === 0)
1419
+ return null;
1420
+ const callIdx = Math.max(0, Math.min(lines.length - 1, ref.line - 1));
1421
+ const startIdx = componentScoped
1422
+ ? 0
1423
+ : Math.max(0, enclosingScopeStartLine(ref, context) - 1);
1424
+ const matchLine = (i) => {
1425
+ const line = lines[i];
1426
+ if (!line)
1427
+ return null;
1428
+ // A generated/minified line (one multi-KB statement) is not something a
1429
+ // human-written local declaration lives on, and regexing it per ref is
1430
+ // pure waste — skip it rather than scan it.
1431
+ if (line.length > 10_000)
1432
+ return null;
1433
+ for (const re of patterns) {
1434
+ const m = line.match(re);
1435
+ if (m && m[1]) {
1436
+ const type = normalizeInferredTypeName(m[1]);
1437
+ if (type)
1438
+ return type;
1439
+ }
1440
+ }
1441
+ return null;
1442
+ };
1443
+ // Incremental-scan memo (INFER_SCAN_STATES): this scan runs for EVERY
1444
+ // `receiver.method()` ref and was measured at 61µs/ref on kong (2.4s of
1445
+ // worker time, 99% misses — `self:` calls hunting a declaration Lua never
1446
+ // writes). Refs for the same (file, scope, receiver) arrive in ~ascending
1447
+ // line order, and the scan is a pure function of the file's immutable
1448
+ // lines, so each line pays its regex matches ONCE per key instead of once
1449
+ // per ref: query(c) = highest matching line in [startIdx..c]; a monotonic
1450
+ // call extends the stored watermark by scanning only (hi..c] (the region
1451
+ // at-or-below the previous answer is already proven empty above it); a
1452
+ // non-monotonic call (rare — refs are rowid-ordered) falls back to the
1453
+ // plain bounded scan and leaves the state alone. componentScoped is keyed
1454
+ // out — its position-independent whole-file sweep below has different
1455
+ // semantics.
1456
+ if (!componentScoped) {
1457
+ const states = getInferScanStates(context);
1458
+ const key = `${ref.filePath}|${startIdx}|${ref.language}|${scanReceiver}`;
1459
+ const state = states.get(key);
1460
+ if (!state) {
1461
+ for (let i = callIdx; i >= startIdx; i--) {
1462
+ const type = matchLine(i);
1463
+ if (type) {
1464
+ states.set(key, { hi: callIdx, ansIdx: i, ansType: type });
1465
+ return type;
1466
+ }
1467
+ }
1468
+ states.set(key, { hi: callIdx, ansIdx: -1, ansType: null });
1469
+ return null;
1470
+ }
1471
+ if (callIdx >= state.hi) {
1472
+ for (let i = callIdx; i > state.hi; i--) {
1473
+ const type = matchLine(i);
1474
+ if (type) {
1475
+ state.ansIdx = i;
1476
+ state.ansType = type;
1477
+ break;
1478
+ }
1479
+ }
1480
+ state.hi = callIdx;
1481
+ return state.ansIdx >= startIdx ? state.ansType : null;
1482
+ }
1483
+ for (let i = callIdx; i >= startIdx; i--) {
1484
+ const type = matchLine(i);
1485
+ if (type)
1486
+ return type;
1487
+ }
1488
+ return null;
1489
+ }
1490
+ // Nearest declaration wins: scan backward from the call to the scope start.
1491
+ for (let i = callIdx; i >= startIdx; i--) {
1492
+ const type = matchLine(i);
1493
+ if (type)
1494
+ return type;
1495
+ }
1496
+ // A component-scoped field's declaration is position-independent — the
1497
+ // `variables.svc = new X()` pseudoconstructor assignment or `property`
1498
+ // declaration may sit BELOW the calling function in the file — so when the
1499
+ // backward pass finds nothing, sweep the remainder of the file too.
1500
+ if (componentScoped) {
1501
+ for (let i = callIdx + 1; i < lines.length; i++) {
1502
+ const type = matchLine(i);
1503
+ if (type)
1504
+ return type;
1505
+ }
1506
+ }
1507
+ // A PHP property with no statically-typed declaration (classic pre-7.4
1508
+ // style) may still be typed by what gets ASSIGNED to it — follow the
1509
+ // `$this->prop = $var` assignment to the assigned variable's own typed
1510
+ // declaration (a classic or multi-line constructor parameter, or a typed
1511
+ // setter's parameter).
1512
+ if (phpProperty) {
1513
+ return inferPhpAssignedPropertyType(escapedReceiver, lines, callIdx);
1514
+ }
1515
+ return null;
1516
+ }
1517
+ /**
1518
+ * Patterns that recover a PHP class property's declared type for a
1519
+ * `$this->prop` receiver. Deliberately NOT localReceiverTypePatterns: only
1520
+ * property-shaped declarations qualify —
1521
+ * 1. a modifier-prefixed typed declaration, which covers both a typed
1522
+ * property (`private ?Foo $prop;`) and a promoted constructor parameter
1523
+ * (`private readonly Foo $prop`), and
1524
+ * 2. the pseudoconstructor assignment (`$this->prop = new Foo(...)`).
1525
+ * A bare `X $prop` parameter or `$prop = new X()` local elsewhere in the
1526
+ * file must NOT match: those variables can never alias `$this->prop`.
1527
+ * Union-typed properties (`Foo|Bar $prop`) yield no match and thus no edge —
1528
+ * silent beats wrong. The classic untyped-property-assigned-in-constructor
1529
+ * shape is handled by inferPhpAssignedPropertyType instead.
1530
+ */
1531
+ function phpPropertyTypePatterns(r) {
1532
+ return memoPatterns(`php-prop|${r}`, () => buildPhpPropertyTypePatterns(r));
1533
+ }
1534
+ function buildPhpPropertyTypePatterns(r) {
1535
+ return [
1536
+ new RegExp(`\\b(?:(?:private|protected|public|readonly|static|final)(?:\\(set\\))?\\s+)+\\??([A-Za-z_\\\\][\\w\\\\]*)\\s+&?\\$${r}\\b`), // private readonly ?Foo $prop (typed property / promoted param)
1537
+ new RegExp(`\\$this->${r}\\b\\s*=\\s*new\\s+([A-Za-z_\\\\][\\w\\\\]*)`), // $this->prop = new Foo()
1538
+ ];
1539
+ }
1540
+ /**
1541
+ * Second-chance typing for a PHP `$this->prop` receiver whose property
1542
+ * declaration carries no static type (classic pre-7.4 style): find the
1543
+ * `$this->prop = $var` assignment, then recover `$var`'s type from its own
1544
+ * declaration WITHIN the assignment's function — the constructor's (possibly
1545
+ * multi-line) parameter list, a typed setter's parameter, or a `= new X()`
1546
+ * local. The backward scan stops at the enclosing `function` line (checked
1547
+ * for a match first — a single-line `__construct(Foo $var) { ... }` carries
1548
+ * the typed parameter itself), so a same-named variable in another method
1549
+ * can never type the property.
1550
+ */
1551
+ function inferPhpAssignedPropertyType(escapedProp, lines, callIdx) {
1552
+ const assignRe = new RegExp(`\\$this->${escapedProp}\\b\\s*=\\s*\\$(\\w+)\\b`);
1553
+ const assignAt = (i) => {
1554
+ const line = lines[i];
1555
+ if (!line || line.length > 10_000)
1556
+ return null;
1557
+ return line.match(assignRe);
1558
+ };
1559
+ // The assignment is position-independent relative to the call — nearest-
1560
+ // backward first, then sweep forward, same order as the componentScoped scan.
1561
+ let assignIdx = -1;
1562
+ let varName = null;
1563
+ for (let i = callIdx; i >= 0; i--) {
1564
+ const m = assignAt(i);
1565
+ if (m) {
1566
+ assignIdx = i;
1567
+ varName = m[1];
1568
+ break;
1569
+ }
1570
+ }
1571
+ if (varName === null) {
1572
+ for (let i = callIdx + 1; i < lines.length; i++) {
1573
+ const m = assignAt(i);
1574
+ if (m) {
1575
+ assignIdx = i;
1576
+ varName = m[1];
1577
+ break;
1578
+ }
1579
+ }
1580
+ }
1581
+ if (varName === null)
1582
+ return null;
1583
+ const varPatterns = localReceiverTypePatterns('php', varName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
1584
+ for (let i = assignIdx; i >= 0; i--) {
1585
+ const line = lines[i];
1586
+ if (line && line.length <= 10_000) {
1587
+ for (const re of varPatterns) {
1588
+ const m = line.match(re);
1589
+ if (m && m[1]) {
1590
+ const type = normalizeInferredTypeName(m[1]);
1591
+ if (type)
1592
+ return type;
1593
+ }
1594
+ }
1595
+ }
1596
+ if (line && /\bfunction\b/.test(line))
1597
+ break;
1598
+ }
1599
+ return null;
1600
+ }
1601
+ /**
1602
+ * Try to resolve by method name on a class/object
1603
+ */
1604
+ function matchMethodCall(ref, context) {
1605
+ // Parse method call patterns like "obj.method" or "Class::method". The method
1606
+ // part allows trailing `:` keywords so Objective-C selectors resolve
1607
+ // (`SDImageCache.storeImage:`, `obj.setX:y:`); colons never appear in other
1608
+ // languages' method refs, so this is a no-op for them.
1609
+ // The receiver allows dots (`builder.Services.AddCoreServices`) so a CHAINED
1610
+ // call resolves by its last segment — Strategy 3 below name-matches the method
1611
+ // (with its existing single-candidate / receiver-overlap guards). Without this
1612
+ // a multi-dot extension-method call (C# DI `builder.Services.AddCoreServices()`,
1613
+ // `Guard.Against.X()`) matched no pattern and never resolved.
1614
+ // C++ explicit operator call `a.operator+(b)` reaches the resolver as
1615
+ // `a.operator+` (#1247) — the operator's symbol chars (`+`, `==`, `[]`, `()`)
1616
+ // fail the \w method part of the plain pattern, so admit them explicitly.
1617
+ // Names like `operatorTable` stay on the plain pattern (tried first); the
1618
+ // operator form requires at least one non-word char after `operator`, and
1619
+ // every downstream strategy compares the method part by exact string
1620
+ // equality, so a stray match can't invent an edge.
1621
+ const dotMatch = ref.referenceName.match(/^([\w.]+)\.(\w+:?(?:\w+:)*)$/) ??
1622
+ (ref.language === 'cpp'
1623
+ ? ref.referenceName.match(/^([\w.]+)\.(operator[^\w\s.]+)$/)
1624
+ : null);
1625
+ const colonMatch = ref.referenceName.match(/^(\w+)::(\w+)$/);
1626
+ // Lua/Luau method calls use a single colon (`lg:log`); R uses `$` (`lg$log`).
1627
+ // Recognize these receiver/method separators so local-variable receiver-type
1628
+ // inference (#1108) applies to them too — extraction already emits the ref in
1629
+ // this shape, but the resolver otherwise only understood `.` and `::`.
1630
+ const luaColonMatch = (ref.language === 'lua' || ref.language === 'luau')
1631
+ ? ref.referenceName.match(/^([\w.]+):(\w+)$/)
1632
+ : null;
1633
+ const rDollarMatch = ref.language === 'r'
1634
+ ? ref.referenceName.match(/^([\w.]+)\$(\w+)$/)
1635
+ : null;
1636
+ // PHP property receiver: `$this->prop->method()` reaches the resolver as
1637
+ // `this->prop.method` (the extractor records the receiver's raw text with the
1638
+ // leading `$` stripped). Resolve it EXCLUSIVELY through declared-type
1639
+ // inference + resolveMethodOnType validation — the name-similarity strategies
1640
+ // below must never see this shape, so a property whose type can't be
1641
+ // recovered stays unlinked rather than guessed (a wrong inference produces no
1642
+ // edge rather than a wrong one). Deeper chains (`this->a->b.method`) don't
1643
+ // match the single-property pattern and stay unlinked, same as before.
1644
+ const phpThisPropMatch = ref.language === 'php'
1645
+ ? ref.referenceName.match(/^(this->\w+)\.(\w+)$/)
1646
+ : null;
1647
+ if (phpThisPropMatch) {
1648
+ const [, receiver, phpMethodName] = phpThisPropMatch;
1649
+ const inferredType = inferLocalReceiverType(receiver, ref, context);
1650
+ if (!inferredType)
1651
+ return null;
1652
+ return resolveMethodOnType(inferredType, phpMethodName, ref, context, 0.9, 'instance-method', importedFqnOf(inferredType, ref, context));
1653
+ }
1654
+ const match = dotMatch || colonMatch || luaColonMatch || rDollarMatch;
1655
+ if (!match) {
1656
+ return null;
1657
+ }
1658
+ const [, objectOrClass, methodName] = match;
1659
+ // A simple `receiver.method` / `receiver:method` / `receiver$method` shape whose
1660
+ // receiver type we can try to infer from its local declaration.
1661
+ const inferableReceiver = dotMatch || luaColonMatch || rDollarMatch;
1662
+ // Infer the receiver's type from its local declaration/initializer in the
1663
+ // enclosing scope, then resolve the method on that type (#1108). C++ keeps its
1664
+ // dedicated inferrer (header scan + `auto`); every other language uses the
1665
+ // shared source-based inferrer. resolveMethodOnType validates the method
1666
+ // exists on the inferred type, so a mis-inference produces no edge.
1667
+ if (inferableReceiver) {
1668
+ const inferredType = nmTimedT('mc-infer', ref, () => ref.language === 'cpp'
1669
+ ? inferCppReceiverType(objectOrClass, ref, context)
1670
+ : inferLocalReceiverType(objectOrClass, ref, context));
1671
+ if (inferredType) {
1672
+ // Java/Kotlin: when two classes share the simple name, the file's import
1673
+ // pins WHICH one (#314). Other languages disambiguate by call-site file.
1674
+ const importedFqn = ref.language === 'java' || ref.language === 'kotlin'
1675
+ ? context
1676
+ .getImportMappings(ref.filePath, ref.language)
1677
+ .find((i) => i.localName === inferredType)?.source
1678
+ : undefined;
1679
+ const typedMatch = nmTimedT('mc-rmot', ref, () => resolveMethodOnType(inferredType, methodName, ref, context, 0.9, 'instance-method', importedFqn));
1680
+ if (typedMatch) {
1681
+ return typedMatch;
1682
+ }
1683
+ }
1684
+ }
1685
+ // Go 2-hop field chain `base.field.Method` (#1276): the base's type comes
1686
+ // from the enclosing scope (typed parameter / method receiver / local var),
1687
+ // the field's declared type from that struct's own declaration lines, and
1688
+ // the method is VALIDATED on the field's type by resolveMethodOnType. This
1689
+ // branch is EXCLUSIVE for chained Go receivers: when the hop can't be
1690
+ // inferred or the field's type is external (`conn *sql.DB` — no project
1691
+ // node), the ref stays unresolved rather than falling through to the
1692
+ // bare-name strategies below, which is exactly how `target.conn.Exec(...)`
1693
+ // fabricated a dependency on an unrelated local interface's same-named
1694
+ // method. Chained Go receivers were never emitted before #1276, so there
1695
+ // is no prior recall to preserve on the fallback path.
1696
+ if (ref.language === 'go' && dotMatch && objectOrClass.includes('.')) {
1697
+ return matchGoFieldChainCall(objectOrClass, methodName, ref, context);
1698
+ }
1699
+ // Rust call through a field of the enclosing type — `self.inner.run()`,
1700
+ // emitted as `self.inner.run` (#1585). Same discipline as the Go branch
1701
+ // above, and EXCLUSIVE for the same reason: validated field-type inference
1702
+ // or nothing. Letting this shape reach the bare-name strategies below is
1703
+ // how `self.inner.run()` resolved to a same-named method on an unrelated
1704
+ // type — or to the calling method itself, a self-edge the source doesn't
1705
+ // contain — whenever the field's type was external or merely shared a
1706
+ // method name with something nearby.
1707
+ if (ref.language === 'rust' && dotMatch && objectOrClass.startsWith('self.')) {
1708
+ return matchRustSelfFieldCall(objectOrClass.slice('self.'.length), methodName, ref, context);
1709
+ }
1710
+ // Java/Kotlin: receiver may be a field whose name doesn't match the type by
1711
+ // Java naming convention (`userbo` → class `UserBO`, abbreviated). Look up
1712
+ // the field in the enclosing class to get its declared type, then resolve
1713
+ // the method on that type. Covers Spring `@Resource`/`@Autowired` field
1714
+ // injection where the field type is the concrete bean class.
1715
+ if ((ref.language === 'java' || ref.language === 'kotlin') && dotMatch) {
1716
+ const inferredType = inferJavaFieldReceiverType(objectOrClass, ref, context);
1717
+ if (inferredType) {
1718
+ // When two classes share the same simple name, the caller file's
1719
+ // import is the only signal that names WHICH one — pass the
1720
+ // imported FQN so resolveMethodOnType can disambiguate (#314).
1721
+ const imports = context.getImportMappings(ref.filePath, ref.language);
1722
+ const importedFqn = imports.find((i) => i.localName === inferredType)?.source;
1723
+ const typedMatch = nmTimedT('mc-rmot', ref, () => resolveMethodOnType(inferredType, methodName, ref, context, 0.9, 'instance-method', importedFqn));
1724
+ if (typedMatch) {
1725
+ return typedMatch;
1726
+ }
1727
+ }
1728
+ }
1729
+ // Object-literal namespace receiver (#1573): `api.call()` where `api` is a
1730
+ // same-file `const api = { call() {…}, get: () => {…} }`. Its members are
1731
+ // plain functions with bare names inside the constant's extent — no
1732
+ // `Container::member` qualified name — so none of the class-shaped
1733
+ // strategies below can see them (Strategy 3 only considers `method`
1734
+ // kinds) and the call resolved to nothing at all. Same file only: a
1735
+ // cross-file use reaches the same helper through the import path.
1736
+ if (dotMatch && !objectOrClass.includes('.') && OBJECT_LITERAL_LANGUAGES.has(ref.language)) {
1737
+ 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);
1739
+ for (const holder of holders) {
1740
+ const hit = resolveObjectLiteralMember(holder, methodName, ref, context, 0.85, 'instance-method');
1741
+ if (hit)
1742
+ return hit;
1743
+ }
1744
+ return null;
1745
+ });
1746
+ if (literalMatch)
1747
+ return literalMatch;
1748
+ }
1749
+ // Strategy 1: Direct class name match (existing logic). When the receiver
1750
+ // names a class that exists in several files (`Logger.log()` / `Logger::log()`
1751
+ // with a `Logger` in both `a/` and `b/`), try the class in the call site's
1752
+ // own file first — otherwise the first-indexed class wins and a call in `b/`
1753
+ // resolves to `a/`'s method (#1079).
1754
+ const strat1 = nmTimedT('mc-class', ref, () => {
1755
+ const classCandidates = preferCallSiteFile(context.getNodesByName(objectOrClass), ref.filePath);
1756
+ 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
+ }
1773
+ }
1774
+ }
1775
+ return null;
1776
+ });
1777
+ if (strat1)
1778
+ return strat1;
1779
+ // Strategy 2: Instance variable receiver - try capitalized form to find class
1780
+ // e.g., "permissionEngine" → look for classes containing "PermissionEngine"
1781
+ const capitalizedReceiver = objectOrClass.charAt(0).toUpperCase() + objectOrClass.slice(1);
1782
+ if (capitalizedReceiver !== objectOrClass) {
1783
+ const strat2 = nmTimedT('mc-capital', ref, () => {
1784
+ const fuzzyClassCandidates = preferCallSiteFile(context.getNodesByName(capitalizedReceiver), ref.filePath);
1785
+ 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
+ }
1802
+ }
1803
+ }
1804
+ return null;
1805
+ });
1806
+ if (strat2)
1807
+ return strat2;
1808
+ }
1809
+ // Strategy 3: Find methods by name across the codebase, match by receiver
1810
+ // name similarity with the containing class. Handles abbreviated variable
1811
+ // names like permissionEngine → PermissionRuleEngine.
1812
+ if (methodName) {
1813
+ const strat3 = nmTimedT('mc-byname', ref, () => {
1814
+ const methodCandidates = context.getNodesByName(methodName);
1815
+ // Ubiquitous-method ceiling (#999): a method name re-declared across a
1816
+ // vendored theme/SDK (Metronic's `init`/`update`/… on every widget) yields
1817
+ // K candidates that receiver-word overlap can't reliably disambiguate —
1818
+ // and filtering + scoring all K per call is the O(K²) cost that wedged
1819
+ // "Resolving refs" for 15-28 min. Bail before the O(K) work; Strategy 1/2
1820
+ // (class-name match) already had their precise shot above.
1821
+ if (methodCandidates.length > AMBIGUOUS_NAME_CEILING) {
1822
+ return null;
1823
+ }
1824
+ const methods = methodCandidates.filter((n) => n.kind === 'method' && n.name === methodName);
1825
+ // Filter to same-language candidates first
1826
+ const sameLanguageMethods = methods.filter(m => m.language === ref.language);
1827
+ const targetMethods = sameLanguageMethods.length > 0 ? sameLanguageMethods : methods;
1828
+ // If only one same-language method with this name exists, use it
1829
+ if (targetMethods.length === 1 && targetMethods[0].language === ref.language) {
1830
+ return {
1831
+ original: ref,
1832
+ targetNodeId: targetMethods[0].id,
1833
+ confidence: 0.7,
1834
+ resolvedBy: 'instance-method',
1835
+ };
1836
+ }
1837
+ // Multiple methods: score by receiver name word overlap with class name
1838
+ if (targetMethods.length > 1) {
1839
+ const receiverWords = splitCamelCase(objectOrClass);
1840
+ let bestMatch;
1841
+ let bestScore = 0;
1842
+ // Same-file candidates first, so a score tie (`score > bestScore` keeps
1843
+ // the first seen) resolves to the call site's own file rather than the
1844
+ // first-indexed duplicate (#1079).
1845
+ for (const method of preferCallSiteFile(targetMethods, ref.filePath)) {
1846
+ const classWords = splitCamelCase(method.qualifiedName);
1847
+ let score = receiverWords.filter(w => classWords.some(cw => cw.toLowerCase() === w.toLowerCase())).length;
1848
+ // Bonus for same language
1849
+ if (method.language === ref.language)
1850
+ score += 1;
1851
+ if (score > bestScore) {
1852
+ bestScore = score;
1853
+ bestMatch = method;
1854
+ }
1855
+ }
1856
+ if (bestMatch && bestScore >= 2) {
1857
+ return {
1858
+ original: ref,
1859
+ targetNodeId: bestMatch.id,
1860
+ confidence: 0.65,
1861
+ resolvedBy: 'instance-method',
1862
+ };
1863
+ }
1864
+ }
1865
+ return null;
1866
+ });
1867
+ if (strat3)
1868
+ return strat3;
1869
+ }
1870
+ return null;
1871
+ }
1872
+ /** Go builtin/primitive field types that can never carry a project method. */
1873
+ const GO_BUILTIN_FIELD_TYPES = new Set([
1874
+ 'string', 'bool', 'byte', 'rune', 'error', 'any',
1875
+ 'int', 'int8', 'int16', 'int32', 'int64',
1876
+ 'uint', 'uint8', 'uint16', 'uint32', 'uint64', 'uintptr',
1877
+ 'float32', 'float64', 'complex64', 'complex128',
1878
+ 'chan', 'map', 'func', 'struct', 'interface',
1879
+ ]);
1880
+ /**
1881
+ * Resolve a Go 2-hop field-chain call `base.field.Method(...)` (#1276):
1882
+ * `target.conn.Exec("insert")` where `func (target *Target) Write()` and
1883
+ * `type Target struct { conn *sql.DB }`. Two inference hops, both read from
1884
+ * source the same way #1108 does:
1885
+ * 1. `base`'s type from the enclosing scope (method receiver, typed
1886
+ * parameter, or local declaration) via inferLocalReceiverType;
1887
+ * 2. `field`'s declared type from the struct's own declaration lines.
1888
+ * The method is then resolved AND VALIDATED on the field's type. A field
1889
+ * whose type has no project node (`sql.DB`, any external dependency) yields
1890
+ * null — the caller treats this branch as exclusive for chained Go
1891
+ * receivers, so the ref stays unresolved instead of name-guessing.
1892
+ */
1893
+ function matchGoFieldChainCall(receiverChain, methodName, ref, context) {
1894
+ const segs = receiverChain.split('.');
1895
+ if (segs.length !== 2 || !segs[0] || !segs[1])
1896
+ return null;
1897
+ const [base, field] = segs;
1898
+ const baseType = inferLocalReceiverType(base, ref, context);
1899
+ if (!baseType)
1900
+ return null;
1901
+ const fieldEsc = field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1902
+ const fieldTypeRe = new RegExp(`\\b${fieldEsc}\\s+\\*?\\[?\\]?([A-Za-z_][\\w.]*)`);
1903
+ const structs = preferCallSiteFile(context.getNodesByName(baseType), ref.filePath).filter((n) => (n.kind === 'struct' || n.kind === 'class') && n.language === 'go');
1904
+ for (const s of structs) {
1905
+ const source = context.readFile(s.filePath);
1906
+ if (!source)
1907
+ continue;
1908
+ // Only the struct's own declaration lines — a same-named identifier
1909
+ // elsewhere in the file can't donate a type. Matched LINE BY LINE with
1910
+ // comments stripped: chi's `Mux` has a doc comment reading "the tree
1911
+ // router" right above `tree *node`, and a whole-block match captured
1912
+ // `router` from the prose instead of `node` from the field.
1913
+ const declLines = source.split('\n').slice(Math.max(0, s.startLine - 1), s.endLine);
1914
+ for (const rawLine of declLines) {
1915
+ const line = rawLine.replace(/\/\/.*$/, '').replace(/\/\*.*?\*\//g, '');
1916
+ const m = line.match(fieldTypeRe);
1917
+ if (!m || !m[1])
1918
+ continue;
1919
+ const rawType = m[1];
1920
+ // A package-qualified field type (`http.Handler`, `sql.DB`) is only
1921
+ // followed when the package is IN-MODULE: stripping the qualifier and
1922
+ // matching the bare name would conflate a stdlib/third-party type with
1923
+ // any same-named project type — on chi, `handler http.Handler` bound
1924
+ // to an example app's unrelated local `Handler`. That is the exact
1925
+ // fabrication this matcher exists to prevent (#1276).
1926
+ if (rawType.includes('.')) {
1927
+ const pkg = rawType.split('.')[0];
1928
+ const mod = context.getGoModule?.();
1929
+ const imp = context
1930
+ .getImportMappings(s.filePath, 'go')
1931
+ .find((i) => i.localName === pkg);
1932
+ const inModule = !!mod &&
1933
+ !!imp &&
1934
+ (imp.source === mod.modulePath || imp.source.startsWith(mod.modulePath + '/'));
1935
+ if (!inModule)
1936
+ continue;
1937
+ }
1938
+ // Unexported (lowercase) types are idiomatic Go and stay eligible —
1939
+ // chi's `mx.tree.FindRoute()` chains through `tree *node`. A
1940
+ // mis-capture is harmless: resolveMethodOnType only returns a
1941
+ // validated `<type>::<method>` match.
1942
+ const fieldType = rawType.split('.').pop();
1943
+ if (!fieldType || !/^[A-Za-z_]/.test(fieldType) || GO_BUILTIN_FIELD_TYPES.has(fieldType))
1944
+ continue;
1945
+ const resolved = resolveMethodOnType(fieldType, methodName, ref, context, 0.85, 'instance-method');
1946
+ if (resolved)
1947
+ return resolved;
1948
+ }
1949
+ }
1950
+ return null;
1951
+ }
1952
+ // Rust primitives and the prelude's own types: a field of one of these never
1953
+ // names a project type, so a `self.<field>.<method>()` on it stays unresolved.
1954
+ const RUST_NON_PROJECT_FIELD_TYPES = new Set([
1955
+ 'bool', 'char', 'str', 'String',
1956
+ 'i8', 'i16', 'i32', 'i64', 'i128', 'isize',
1957
+ 'u8', 'u16', 'u32', 'u64', 'u128', 'usize',
1958
+ 'f32', 'f64',
1959
+ 'Self', 'self',
1960
+ ]);
1961
+ /**
1962
+ * Reduce a Rust field's declared type text to the simple name of the type a
1963
+ * method call on that field auto-derefs to, or null when there is none we can
1964
+ * name. Only the layers Rust's method-call auto-deref looks through are
1965
+ * unwrapped: references (`&`, `&'a mut`) and the owning smart pointers
1966
+ * (`Box`, `Rc`, `Arc`) — `self.inner.run()` with `inner: Box<Inner>` calls
1967
+ * `Inner::run`. Containers that do NOT auto-deref to their parameter
1968
+ * (`Option<Inner>`, `Vec<Inner>`, `Mutex<Inner>`, `RefCell<Inner>`) keep their
1969
+ * own name and, having no project node, resolve to nothing — `self.items.push()`
1970
+ * must never become `Inner::push`. A trait object (`Box<dyn Source>`) yields
1971
+ * the trait, whose method node the interface-impl synthesizer fans out. A
1972
+ * generic parameter (`T`), a primitive, a tuple / array / raw pointer / fn
1973
+ * type, or a non-identifier yields null.
1974
+ */
1975
+ function rustFieldTypeName(raw) {
1976
+ let t = raw.trim();
1977
+ for (;;) {
1978
+ const before = t;
1979
+ t = t.replace(/^&\s*(?:'\w+\s+)?(?:mut\s+)?/, '');
1980
+ t = t.replace(/^(?:Box|Rc|Arc)\s*<\s*/, '');
1981
+ t = t.replace(/^(?:dyn|impl)\s+/, '');
1982
+ if (t === before)
1983
+ break;
1984
+ }
1985
+ // Drop generic args, the closing `>`s of unwrapped pointers, and trait-object
1986
+ // bounds (`dyn Source + Send`); keep the last path segment.
1987
+ t = t.replace(/[<>+].*$/, '').trim();
1988
+ const seg = t.split('::').filter(Boolean).pop();
1989
+ if (!seg || !/^[A-Za-z_]\w*$/.test(seg))
1990
+ return null;
1991
+ if (RUST_NON_PROJECT_FIELD_TYPES.has(seg))
1992
+ return null;
1993
+ if (/^[A-Z]$/.test(seg))
1994
+ return null; // bare single-letter generic parameter
1995
+ return seg;
1996
+ }
1997
+ /**
1998
+ * Resolve a Rust call through a field of the enclosing type —
1999
+ * `self.inner.run()`, emitted by the extractor as `self.inner.run` (#1585).
2000
+ * Mirrors the Go 2-hop precedent above (#1276): the owner type is the calling
2001
+ * method's qualified-name prefix (`Outer::run` → `Outer`), the field's declared
2002
+ * type comes from the owner struct's OWN declaration lines, and the method is
2003
+ * resolved AND VALIDATED on that type by resolveMethodOnType. The caller
2004
+ * treats this branch as exclusive for `self.<field>` receivers: a field whose
2005
+ * type is external (`std::vec::IntoIter`, `regex::Regex`), a generic
2006
+ * parameter, or not declared where we can see it yields null and the ref stays
2007
+ * unresolved. Rust struct fields are not graph nodes, so the declaration text
2008
+ * is the only place the type lives.
2009
+ */
2010
+ function matchRustSelfFieldCall(field, methodName, ref, context) {
2011
+ // The extractor only ever emits a single field hop; anything else is not ours.
2012
+ if (!field || field.includes('.'))
2013
+ return null;
2014
+ const caller = context.getNodeById?.(ref.fromNodeId);
2015
+ if (!caller)
2016
+ return null;
2017
+ const sep = caller.qualifiedName.lastIndexOf('::');
2018
+ if (sep <= 0)
2019
+ return null; // a free fn has no `self`
2020
+ const owner = caller.qualifiedName.slice(0, sep).split('::').pop();
2021
+ if (!owner)
2022
+ return null;
2023
+ const owners = preferCallSiteFile(context.getNodesByName(owner), ref.filePath).filter((n) => (n.kind === 'struct' || n.kind === 'union' || n.kind === 'class') &&
2024
+ n.language === 'rust');
2025
+ const fieldEsc = field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2026
+ // `pub inner: Inner,` / `inner: Box<dyn Source>,` / `pub(crate) inner: T }` —
2027
+ // the type text runs to the field separator. A comma inside generic args
2028
+ // (`HashMap<K, V>`) truncates the capture, which rustFieldTypeName then
2029
+ // reduces to the container's own name — exactly the non-deref case it
2030
+ // refuses anyway.
2031
+ const fieldRe = new RegExp(`\\b${fieldEsc}\\s*:\\s*([^,{}]+)`);
2032
+ for (const s of owners) {
2033
+ const source = context.readFile(s.filePath);
2034
+ if (!source)
2035
+ continue;
2036
+ // Only the struct's own declaration lines, comment-stripped line by line —
2037
+ // same discipline as the Go helper: prose or a same-named identifier
2038
+ // elsewhere in the file can never donate a type.
2039
+ const declLines = source.split('\n').slice(Math.max(0, s.startLine - 1), s.endLine);
2040
+ for (const rawLine of declLines) {
2041
+ const line = rawLine.replace(/\/\/.*$/, '').replace(/\/\*.*?\*\//g, '');
2042
+ const m = line.match(fieldRe);
2043
+ if (!m || !m[1])
2044
+ continue;
2045
+ const fieldType = rustFieldTypeName(m[1]);
2046
+ // The field is declared here; whether or not its type names a project
2047
+ // symbol, this owner is the answer — no other same-named struct applies.
2048
+ if (!fieldType)
2049
+ return null;
2050
+ return resolveMethodOnType(fieldType, methodName, ref, context, 0.85, 'instance-method');
2051
+ }
2052
+ }
2053
+ return null;
2054
+ }
2055
+ /**
2056
+ * Split a camelCase or PascalCase string into words.
2057
+ */
2058
+ function splitCamelCase(str) {
2059
+ return str.replace(/([a-z])([A-Z])/g, '$1 $2')
2060
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
2061
+ .split(/[\s._:\/\\]+/)
2062
+ .filter(w => w.length > 1);
2063
+ }
2064
+ /**
2065
+ * Compute directory proximity from a pre-split list of directory segments
2066
+ * (`filePath1` minus its filename) and a second file path.
2067
+ * Returns a score based on the number of shared leading directory segments.
2068
+ * Higher score = closer in directory tree.
2069
+ *
2070
+ * Split into a pre-split variant because findBestMatch scores every candidate
2071
+ * against the SAME `ref.filePath`; re-splitting it per candidate was a hot spot
2072
+ * on large repos (#915), so the caller splits it once and passes the segments.
2073
+ */
2074
+ function pathProximityFromDirs(dir1, filePath2) {
2075
+ const dir2 = filePath2.split('/');
2076
+ dir2.pop(); // drop filename — matches the original slice(0, -1) on both paths
2077
+ let shared = 0;
2078
+ const limit = Math.min(dir1.length, dir2.length);
2079
+ for (let i = 0; i < limit; i++) {
2080
+ if (dir1[i] === dir2[i]) {
2081
+ shared++;
2082
+ }
2083
+ else {
2084
+ break;
2085
+ }
2086
+ }
2087
+ // Each shared directory segment contributes 15 points, capped at 80
2088
+ return Math.min(shared * 15, 80);
2089
+ }
2090
+ /**
2091
+ * Compute directory proximity between two file paths.
2092
+ * Returns a score based on the number of shared directory segments.
2093
+ */
2094
+ function computePathProximity(filePath1, filePath2) {
2095
+ const dir1 = filePath1.split('/');
2096
+ dir1.pop();
2097
+ return pathProximityFromDirs(dir1, filePath2);
2098
+ }
2099
+ /**
2100
+ * Find the best matching node when there are multiple candidates
2101
+ */
2102
+ function findBestMatch(ref, candidates, _context) {
2103
+ // Prioritization rules:
2104
+ // 1. Same file > different file
2105
+ // 2. Directory proximity (same module/package > different module)
2106
+ // 3. Same language > different language
2107
+ // 4. Functions/methods > classes/types (for call references)
2108
+ // 5. Exported > non-exported
2109
+ let bestScore = -1;
2110
+ let bestNode = null;
2111
+ // Split the ref's path once (it's the same across every candidate) instead of
2112
+ // re-splitting it inside computePathProximity per candidate (#915 hot spot).
2113
+ const refDirs = ref.filePath.split('/');
2114
+ refDirs.pop();
2115
+ // A same-language candidate ALWAYS outscores a cross-language one: same-language
2116
+ // scores at least +50 (language bonus), while a cross-language candidate maxes
2117
+ // out at +35 (−80 language, +80 proximity, +25 kind, +10 exported; it can never
2118
+ // be in the same file). So when any same-language candidate exists, skip the
2119
+ // cross-language ones — provably the same winner, without paying the per-candidate
2120
+ // scoring. Cuts the candidate set to same-language size on mixed front-end +
2121
+ // back-end repos (#915). When ALL candidates are cross-language (a legitimate
2122
+ // cross-language `calls` bridge), none are skipped and behavior is unchanged.
2123
+ const hasSameLanguage = candidates.some((c) => c.language === ref.language);
2124
+ for (const candidate of candidates) {
2125
+ if (hasSameLanguage && candidate.language !== ref.language)
2126
+ continue;
2127
+ let score = 0;
2128
+ // Same file bonus
2129
+ if (candidate.filePath === ref.filePath) {
2130
+ score += 100;
2131
+ }
2132
+ // Directory proximity bonus — strongly prefer same module/package
2133
+ score += pathProximityFromDirs(refDirs, candidate.filePath);
2134
+ // Language matching: strongly prefer same language, penalize cross-language
2135
+ if (candidate.language === ref.language) {
2136
+ score += 50;
2137
+ }
2138
+ else {
2139
+ score -= 80;
2140
+ }
2141
+ // For call references, prefer functions/methods
2142
+ if (ref.referenceKind === 'calls') {
2143
+ if (candidate.kind === 'function' || candidate.kind === 'method') {
2144
+ score += 25;
2145
+ }
2146
+ }
2147
+ // For instantiation references (`new Foo()`), prefer class-like
2148
+ // targets — without this, a function named `Foo` in another module
2149
+ // could outscore the actual class.
2150
+ if (ref.referenceKind === 'instantiates') {
2151
+ if (candidate.kind === 'class' ||
2152
+ candidate.kind === 'struct' ||
2153
+ candidate.kind === 'union' ||
2154
+ candidate.kind === 'interface') {
2155
+ score += 25;
2156
+ }
2157
+ }
2158
+ // For decorator references (`@Foo`), prefer functions. Class
2159
+ // decorators (Python `@SomeClass`, Java annotation interfaces)
2160
+ // also resolve here, hence the smaller class bonus.
2161
+ if (ref.referenceKind === 'decorates') {
2162
+ if (candidate.kind === 'function' || candidate.kind === 'method') {
2163
+ score += 25;
2164
+ }
2165
+ else if (candidate.kind === 'class' || candidate.kind === 'interface') {
2166
+ score += 15;
2167
+ }
2168
+ }
2169
+ // Exported bonus
2170
+ if (candidate.isExported) {
2171
+ score += 10;
2172
+ }
2173
+ // Closer line number (within same file)
2174
+ if (candidate.filePath === ref.filePath && candidate.startLine) {
2175
+ const distance = Math.abs(candidate.startLine - ref.line);
2176
+ score += Math.max(0, 20 - distance / 10);
2177
+ }
2178
+ if (score > bestScore) {
2179
+ bestScore = score;
2180
+ bestNode = candidate;
2181
+ }
2182
+ }
2183
+ return bestNode;
2184
+ }
2185
+ /**
2186
+ * Fuzzy match - last resort with lower confidence
2187
+ */
2188
+ function matchFuzzy(ref, context) {
2189
+ const lowerName = ref.referenceName.toLowerCase();
2190
+ // Use pre-built lowercase index for O(1) lookup instead of scanning all nodes
2191
+ const candidates = context.getNodesByLowerName(lowerName);
2192
+ // Filter to callable kinds only (function, method, class)
2193
+ const callableKinds = new Set(['function', 'method', 'class']);
2194
+ const callableCandidates = applyLanguageGate(candidates.filter((n) => callableKinds.has(n.kind)), ref);
2195
+ // Prefer same-language matches
2196
+ const sameLanguageCandidates = callableCandidates.filter(n => n.language === ref.language);
2197
+ const finalCandidates = sameLanguageCandidates.length > 0 ? sameLanguageCandidates : callableCandidates;
2198
+ if (finalCandidates.length === 1) {
2199
+ const isCrossLanguage = finalCandidates[0].language !== ref.language;
2200
+ return {
2201
+ original: ref,
2202
+ targetNodeId: finalCandidates[0].id,
2203
+ confidence: isCrossLanguage ? 0.3 : 0.5,
2204
+ resolvedBy: 'fuzzy',
2205
+ };
2206
+ }
2207
+ return null;
2208
+ }
2209
+ /**
2210
+ * Match all strategies in order of confidence
2211
+ */
2212
+ /** ArkUI attribute-helper decorators a `.attr(...)` chain may resolve to. */
2213
+ const ARKUI_ATTRIBUTE_DECORATORS = new Set(['Extend', 'Styles', 'AnimatableExtend', 'Builder']);
2214
+ /**
2215
+ * CODEGRAPH_RESOLVE_PROFILE=2 sub-stage attribution for matchReference's
2216
+ * strategy pipeline (`nm:<stage>|<refKind>|hit/miss`). Module-global because
2217
+ * the matcher is a free function; each thread (main + every pool worker) has
2218
+ * its own module instance, and dumpNameMatcherProfile is invoked from
2219
+ * ReferenceResolver.dumpResolveProfile so worker tables surface too.
2220
+ */
2221
+ const NM_PROFILE = process.env.CODEGRAPH_RESOLVE_PROFILE === '2' ? new Map() : null;
2222
+ function nmTimedT(stage, ref, fn) {
2223
+ if (!NM_PROFILE)
2224
+ return fn();
2225
+ const t0 = process.hrtime.bigint();
2226
+ const r = fn();
2227
+ const dt = process.hrtime.bigint() - t0;
2228
+ const key = `nm:${stage}|${ref.referenceKind}|${r ? 'hit' : 'miss'}`;
2229
+ const slot = NM_PROFILE.get(key);
2230
+ if (slot) {
2231
+ slot.n++;
2232
+ slot.ns += dt;
2233
+ }
2234
+ else {
2235
+ NM_PROFILE.set(key, { n: 1, ns: dt });
2236
+ }
2237
+ return r;
2238
+ }
2239
+ function nmTimed(stage, ref, fn) {
2240
+ return nmTimedT(stage, ref, fn);
2241
+ }
2242
+ /** Dump this thread's matchReference sub-stage table to stderr (no-op unless =2). */
2243
+ function dumpNameMatcherProfile(label) {
2244
+ if (!NM_PROFILE || NM_PROFILE.size === 0)
2245
+ return;
2246
+ const rows = [...NM_PROFILE.entries()]
2247
+ .map(([k, v]) => ({ k, n: v.n, ms: Number(v.ns / 1000000n) }))
2248
+ .sort((a, b) => b.ms - a.ms);
2249
+ for (const r of rows) {
2250
+ console.error(`[resolve-profile] ${label} ${r.k}: n=${r.n} total=${(r.ms / 1000).toFixed(1)}s avg=${((r.ms * 1000) / Math.max(1, r.n)).toFixed(0)}µs`);
2251
+ }
2252
+ }
2253
+ function matchReference(ref, context) {
2254
+ // Function-as-value refs (#756) resolve ONLY through the dedicated matcher —
2255
+ // never the fuzzy/qualified fallthrough below (a wrong callback edge is
2256
+ // worse than none).
2257
+ if (ref.referenceKind === 'function_ref') {
2258
+ return matchFunctionRef(ref, context);
2259
+ }
2260
+ // ArkTS chained UI attributes — emitted with a leading dot (`.titleStyle`,
2261
+ // `.width`) by the extractor — resolve ONLY to decorator-marked attribute
2262
+ // helpers: `@Extend`/`@Styles`/`@AnimatableExtend` functions (and global
2263
+ // `@Builder`s used attribute-position). Framework attributes (`.width`,
2264
+ // `.fontSize` — on nearly every UI line) match no such helper and stay
2265
+ // unresolved, NEVER falling through to bare-name matching: on a samples
2266
+ // monorepo that fallthrough manufactured 36k wrong edges, giving single
2267
+ // same-named properties thousands of false callers. Ambiguity rule matches
2268
+ // the rest of the file: several same-named helpers → prefer the call-site
2269
+ // file, still ambiguous → drop the ref rather than guess.
2270
+ if (ref.language === 'arkts' && ref.referenceName.startsWith('.')) {
2271
+ const base = ref.referenceName.slice(1);
2272
+ const candidates = context
2273
+ .getNodesByName(base)
2274
+ .filter((n) => n.language === 'arkts' &&
2275
+ n.kind === 'function' &&
2276
+ (n.decorators ?? []).some((d) => ARKUI_ATTRIBUTE_DECORATORS.has(d)));
2277
+ const chosen = candidates.length > 1 ? preferCallSiteFile(candidates, ref.filePath) : candidates;
2278
+ if (chosen.length !== 1)
2279
+ return null;
2280
+ return {
2281
+ original: ref,
2282
+ targetNodeId: chosen[0].id,
2283
+ confidence: 0.85,
2284
+ resolvedBy: 'exact-match',
2285
+ };
2286
+ }
2287
+ // Erlang `-behaviour(m)` refs target a MODULE. Letting them fall through to
2288
+ // bare-name matching grabs any same-named symbol — on emqx,
2289
+ // `-behaviour(supervisor)` resolved to a `-define(supervisor, …)` macro
2290
+ // constant in an unrelated app. Resolve only to the behaviour module's
2291
+ // namespace; an out-of-repo behaviour (OTP's gen_server/supervisor) stays
2292
+ // unresolved rather than guessed. The same module-only rule applies to every
2293
+ // ref an `.app`/`.app.src` resource file emits — its `{mod, …}` callback and
2294
+ // `{applications, …}` dependency names can only mean modules, and on emqx
2295
+ // the `ssl` OTP app otherwise resolved to a test helper FUNCTION named ssl.
2296
+ if (ref.language === 'erlang' &&
2297
+ (ref.referenceKind === 'implements' || /\.app(?:\.src)?$/i.test(ref.filePath))) {
2298
+ const modules = context
2299
+ .getNodesByName(ref.referenceName)
2300
+ .filter((n) => n.language === 'erlang' && n.kind === 'namespace');
2301
+ const chosen = preferCallSiteFile(modules, ref.filePath)[0];
2302
+ if (!chosen)
2303
+ return null;
2304
+ return {
2305
+ original: ref,
2306
+ targetNodeId: chosen.id,
2307
+ confidence: 0.9,
2308
+ resolvedBy: 'exact-match',
2309
+ };
2310
+ }
2311
+ // Erlang call/fun refs carry the call-site arity (`f/1` — #1610) because
2312
+ // arity is part of the function's identity and every erlang function's
2313
+ // qualifiedName carries it (`mod::f/1`). Resolve ONLY to a definition of
2314
+ // that exact arity: the call site's own file first (a local call targets its
2315
+ // own module by language semantics; `-import`ed functions ride the
2316
+ // cross-file branch), and when no definition of that arity exists anywhere,
2317
+ // resolve to NOTHING rather than a sibling arity — the real target may be
2318
+ // macro-generated or out of repo, and a wrong-arity edge is worse than none.
2319
+ if (ref.language === 'erlang' &&
2320
+ !ref.referenceName.includes('::') &&
2321
+ (ref.referenceKind === 'calls' || ref.referenceKind === 'references')) {
2322
+ const am = /^(.+)\/(\d{1,3})$/.exec(ref.referenceName);
2323
+ if (am) {
2324
+ // endsWith is length-anchored, so `/1` cannot match `…/11`.
2325
+ const arityTail = `/${am[2]}`;
2326
+ const candidates = context
2327
+ .getNodesByName(am[1])
2328
+ .filter((n) => n.language === 'erlang' && n.kind === 'function' && n.qualifiedName.endsWith(arityTail));
2329
+ if (candidates.length > 0) {
2330
+ const sameFile = candidates.find((n) => n.filePath === ref.filePath);
2331
+ if (sameFile) {
2332
+ return { original: ref, targetNodeId: sameFile.id, confidence: 0.95, resolvedBy: 'exact-match' };
2333
+ }
2334
+ if (candidates.length === 1) {
2335
+ return { original: ref, targetNodeId: candidates[0].id, confidence: 0.8, resolvedBy: 'exact-match' };
2336
+ }
2337
+ const best = findBestMatch(ref, candidates, context);
2338
+ if (best) {
2339
+ const proximity = computePathProximity(ref.filePath, best.filePath);
2340
+ return {
2341
+ original: ref,
2342
+ targetNodeId: best.id,
2343
+ confidence: proximity >= 30 ? 0.7 : 0.4,
2344
+ resolvedBy: 'exact-match',
2345
+ };
2346
+ }
2347
+ }
2348
+ return null;
2349
+ }
2350
+ }
2351
+ // Try strategies in order of confidence
2352
+ let result;
2353
+ // 0. File path match (e.g., "snippets/drawer-menu.liquid" → file node)
2354
+ result = nmTimed('filePath', ref, () => matchByFilePath(ref, context));
2355
+ if (result)
2356
+ return result;
2357
+ // 1. Qualified name match (highest confidence)
2358
+ result = nmTimed('qualifiedName', ref, () => matchByQualifiedName(ref, context));
2359
+ if (result)
2360
+ return result;
2361
+ // 1b. C++ chained call whose receiver is another call — `Foo::instance().bar()`
2362
+ // encoded as `Foo::instance().bar` by the extractor (#645). Resolve the
2363
+ // receiver's type from what the inner call returns, then the method on it.
2364
+ if (ref.language === 'cpp' || ref.language === 'c') {
2365
+ result = nmTimed('cppChain', ref, () => matchCppCallChain(ref, context));
2366
+ if (result)
2367
+ return result;
2368
+ }
2369
+ // 1c. `::`-scoped factory chain — PHP `Cls::for($x)->method()` (#608) or Rust
2370
+ // `Foo::new().bar()`, both encoded as `Cls::factory().method`. The receiver's
2371
+ // type is the factory's `self` (PHP `: self`/`: static`, Rust `-> Self`) or
2372
+ // concrete return type.
2373
+ if (ref.language === 'php' || ref.language === 'rust') {
2374
+ result = nmTimed('scopedChain', ref, () => matchScopedCallChain(ref, context));
2375
+ if (result)
2376
+ return result;
2377
+ }
2378
+ // 1d. Dotted chained static-factory / fluent call (Java / Kotlin / C# / Swift /
2379
+ // Go / Scala / Dart / Objective-C) — `Foo.getInstance().bar()` encoded as
2380
+ // `Foo.getInstance().bar`, Go's bare-factory `New().Method()` as `New().Method`,
2381
+ // Scala's companion factory, Dart's static factory / factory-constructor, or
2382
+ // ObjC's chained message send `[[Foo create] doIt]` encoded as `Foo.create().doIt`
2383
+ // (#645/#608 mechanism). Resolve the method's class from the inner call's
2384
+ // declared return type, then validate it.
2385
+ if (ref.language === 'java' ||
2386
+ ref.language === 'kotlin' ||
2387
+ ref.language === 'csharp' ||
2388
+ ref.language === 'swift' ||
2389
+ ref.language === 'go' ||
2390
+ ref.language === 'scala' ||
2391
+ ref.language === 'dart' ||
2392
+ ref.language === 'objc' ||
2393
+ ref.language === 'pascal') {
2394
+ result = nmTimed('dottedChain', ref, () => matchDottedCallChain(ref, context));
2395
+ if (result)
2396
+ return result;
2397
+ }
2398
+ // 2. Method call pattern
2399
+ result = nmTimed('methodCall', ref, () => matchMethodCall(ref, context));
2400
+ if (result)
2401
+ return result;
2402
+ // 3. Exact name match
2403
+ result = nmTimed('exactName', ref, () => matchByExactName(ref, context));
2404
+ if (result)
2405
+ return result;
2406
+ // 4. Fuzzy match (lowest confidence)
2407
+ result = nmTimed('fuzzy', ref, () => matchFuzzy(ref, context));
2408
+ if (result)
2409
+ return result;
2410
+ return null;
2411
+ }
2412
+ //# sourceMappingURL=name-matcher.js.map