@bharanidev/bhgraph-darwin-arm64 1.0.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 (842) hide show
  1. package/bin/bhgraph +19 -0
  2. package/lib/dist/bin/bhgraph.d.ts +26 -0
  3. package/lib/dist/bin/bhgraph.d.ts.map +1 -0
  4. package/lib/dist/bin/bhgraph.js +2207 -0
  5. package/lib/dist/bin/bhgraph.js.map +1 -0
  6. package/lib/dist/bin/command-supervision.d.ts +12 -0
  7. package/lib/dist/bin/command-supervision.d.ts.map +1 -0
  8. package/lib/dist/bin/command-supervision.js +89 -0
  9. package/lib/dist/bin/command-supervision.js.map +1 -0
  10. package/lib/dist/bin/fatal-handler.d.ts +20 -0
  11. package/lib/dist/bin/fatal-handler.d.ts.map +1 -0
  12. package/lib/dist/bin/fatal-handler.js +118 -0
  13. package/lib/dist/bin/fatal-handler.js.map +1 -0
  14. package/lib/dist/bin/node-version-check.d.ts +37 -0
  15. package/lib/dist/bin/node-version-check.d.ts.map +1 -0
  16. package/lib/dist/bin/node-version-check.js +79 -0
  17. package/lib/dist/bin/node-version-check.js.map +1 -0
  18. package/lib/dist/bin/uninstall.d.ts +14 -0
  19. package/lib/dist/bin/uninstall.d.ts.map +1 -0
  20. package/lib/dist/bin/uninstall.js +36 -0
  21. package/lib/dist/bin/uninstall.js.map +1 -0
  22. package/lib/dist/context/formatter.d.ts +30 -0
  23. package/lib/dist/context/formatter.d.ts.map +1 -0
  24. package/lib/dist/context/formatter.js +263 -0
  25. package/lib/dist/context/formatter.js.map +1 -0
  26. package/lib/dist/context/index.d.ts +119 -0
  27. package/lib/dist/context/index.d.ts.map +1 -0
  28. package/lib/dist/context/index.js +1296 -0
  29. package/lib/dist/context/index.js.map +1 -0
  30. package/lib/dist/context/markers.d.ts +19 -0
  31. package/lib/dist/context/markers.d.ts.map +1 -0
  32. package/lib/dist/context/markers.js +22 -0
  33. package/lib/dist/context/markers.js.map +1 -0
  34. package/lib/dist/db/index.d.ts +142 -0
  35. package/lib/dist/db/index.d.ts.map +1 -0
  36. package/lib/dist/db/index.js +335 -0
  37. package/lib/dist/db/index.js.map +1 -0
  38. package/lib/dist/db/migrations.d.ts +44 -0
  39. package/lib/dist/db/migrations.d.ts.map +1 -0
  40. package/lib/dist/db/migrations.js +182 -0
  41. package/lib/dist/db/migrations.js.map +1 -0
  42. package/lib/dist/db/queries.d.ts +452 -0
  43. package/lib/dist/db/queries.d.ts.map +1 -0
  44. package/lib/dist/db/queries.js +1740 -0
  45. package/lib/dist/db/queries.js.map +1 -0
  46. package/lib/dist/db/schema.sql +182 -0
  47. package/lib/dist/db/sqlite-adapter.d.ts +53 -0
  48. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -0
  49. package/lib/dist/db/sqlite-adapter.js +117 -0
  50. package/lib/dist/db/sqlite-adapter.js.map +1 -0
  51. package/lib/dist/directory.d.ts +183 -0
  52. package/lib/dist/directory.d.ts.map +1 -0
  53. package/lib/dist/directory.js +797 -0
  54. package/lib/dist/directory.js.map +1 -0
  55. package/lib/dist/errors.d.ts +136 -0
  56. package/lib/dist/errors.d.ts.map +1 -0
  57. package/lib/dist/errors.js +219 -0
  58. package/lib/dist/errors.js.map +1 -0
  59. package/lib/dist/extraction/astro-extractor.d.ts +79 -0
  60. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
  61. package/lib/dist/extraction/astro-extractor.js +320 -0
  62. package/lib/dist/extraction/astro-extractor.js.map +1 -0
  63. package/lib/dist/extraction/cfml-extractor.d.ts +107 -0
  64. package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -0
  65. package/lib/dist/extraction/cfml-extractor.js +494 -0
  66. package/lib/dist/extraction/cfml-extractor.js.map +1 -0
  67. package/lib/dist/extraction/dfm-extractor.d.ts +31 -0
  68. package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -0
  69. package/lib/dist/extraction/dfm-extractor.js +151 -0
  70. package/lib/dist/extraction/dfm-extractor.js.map +1 -0
  71. package/lib/dist/extraction/extraction-version.d.ts +25 -0
  72. package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
  73. package/lib/dist/extraction/extraction-version.js +28 -0
  74. package/lib/dist/extraction/extraction-version.js.map +1 -0
  75. package/lib/dist/extraction/function-ref.d.ts +118 -0
  76. package/lib/dist/extraction/function-ref.d.ts.map +1 -0
  77. package/lib/dist/extraction/function-ref.js +727 -0
  78. package/lib/dist/extraction/function-ref.js.map +1 -0
  79. package/lib/dist/extraction/generated-detection.d.ts +30 -0
  80. package/lib/dist/extraction/generated-detection.d.ts.map +1 -0
  81. package/lib/dist/extraction/generated-detection.js +83 -0
  82. package/lib/dist/extraction/generated-detection.js.map +1 -0
  83. package/lib/dist/extraction/grammars.d.ts +123 -0
  84. package/lib/dist/extraction/grammars.d.ts.map +1 -0
  85. package/lib/dist/extraction/grammars.js +589 -0
  86. package/lib/dist/extraction/grammars.js.map +1 -0
  87. package/lib/dist/extraction/index.d.ts +232 -0
  88. package/lib/dist/extraction/index.d.ts.map +1 -0
  89. package/lib/dist/extraction/index.js +2269 -0
  90. package/lib/dist/extraction/index.js.map +1 -0
  91. package/lib/dist/extraction/languages/arkts.d.ts +3 -0
  92. package/lib/dist/extraction/languages/arkts.d.ts.map +1 -0
  93. package/lib/dist/extraction/languages/arkts.js +127 -0
  94. package/lib/dist/extraction/languages/arkts.js.map +1 -0
  95. package/lib/dist/extraction/languages/c-cpp.d.ts +110 -0
  96. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  97. package/lib/dist/extraction/languages/c-cpp.js +837 -0
  98. package/lib/dist/extraction/languages/c-cpp.js.map +1 -0
  99. package/lib/dist/extraction/languages/cfquery.d.ts +12 -0
  100. package/lib/dist/extraction/languages/cfquery.d.ts.map +1 -0
  101. package/lib/dist/extraction/languages/cfquery.js +28 -0
  102. package/lib/dist/extraction/languages/cfquery.js.map +1 -0
  103. package/lib/dist/extraction/languages/cfscript.d.ts +3 -0
  104. package/lib/dist/extraction/languages/cfscript.d.ts.map +1 -0
  105. package/lib/dist/extraction/languages/cfscript.js +73 -0
  106. package/lib/dist/extraction/languages/cfscript.js.map +1 -0
  107. package/lib/dist/extraction/languages/cobol.d.ts +33 -0
  108. package/lib/dist/extraction/languages/cobol.d.ts.map +1 -0
  109. package/lib/dist/extraction/languages/cobol.js +499 -0
  110. package/lib/dist/extraction/languages/cobol.js.map +1 -0
  111. package/lib/dist/extraction/languages/csharp.d.ts +25 -0
  112. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -0
  113. package/lib/dist/extraction/languages/csharp.js +175 -0
  114. package/lib/dist/extraction/languages/csharp.js.map +1 -0
  115. package/lib/dist/extraction/languages/dart.d.ts +3 -0
  116. package/lib/dist/extraction/languages/dart.d.ts.map +1 -0
  117. package/lib/dist/extraction/languages/dart.js +374 -0
  118. package/lib/dist/extraction/languages/dart.js.map +1 -0
  119. package/lib/dist/extraction/languages/erlang.d.ts +3 -0
  120. package/lib/dist/extraction/languages/erlang.d.ts.map +1 -0
  121. package/lib/dist/extraction/languages/erlang.js +350 -0
  122. package/lib/dist/extraction/languages/erlang.js.map +1 -0
  123. package/lib/dist/extraction/languages/go.d.ts +3 -0
  124. package/lib/dist/extraction/languages/go.d.ts.map +1 -0
  125. package/lib/dist/extraction/languages/go.js +111 -0
  126. package/lib/dist/extraction/languages/go.js.map +1 -0
  127. package/lib/dist/extraction/languages/index.d.ts +10 -0
  128. package/lib/dist/extraction/languages/index.d.ts.map +1 -0
  129. package/lib/dist/extraction/languages/index.js +71 -0
  130. package/lib/dist/extraction/languages/index.js.map +1 -0
  131. package/lib/dist/extraction/languages/java.d.ts +3 -0
  132. package/lib/dist/extraction/languages/java.d.ts.map +1 -0
  133. package/lib/dist/extraction/languages/java.js +315 -0
  134. package/lib/dist/extraction/languages/java.js.map +1 -0
  135. package/lib/dist/extraction/languages/javascript.d.ts +3 -0
  136. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -0
  137. package/lib/dist/extraction/languages/javascript.js +106 -0
  138. package/lib/dist/extraction/languages/javascript.js.map +1 -0
  139. package/lib/dist/extraction/languages/kotlin.d.ts +3 -0
  140. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -0
  141. package/lib/dist/extraction/languages/kotlin.js +379 -0
  142. package/lib/dist/extraction/languages/kotlin.js.map +1 -0
  143. package/lib/dist/extraction/languages/lua.d.ts +3 -0
  144. package/lib/dist/extraction/languages/lua.d.ts.map +1 -0
  145. package/lib/dist/extraction/languages/lua.js +150 -0
  146. package/lib/dist/extraction/languages/lua.js.map +1 -0
  147. package/lib/dist/extraction/languages/luau.d.ts +3 -0
  148. package/lib/dist/extraction/languages/luau.d.ts.map +1 -0
  149. package/lib/dist/extraction/languages/luau.js +37 -0
  150. package/lib/dist/extraction/languages/luau.js.map +1 -0
  151. package/lib/dist/extraction/languages/nix.d.ts +3 -0
  152. package/lib/dist/extraction/languages/nix.d.ts.map +1 -0
  153. package/lib/dist/extraction/languages/nix.js +294 -0
  154. package/lib/dist/extraction/languages/nix.js.map +1 -0
  155. package/lib/dist/extraction/languages/objc.d.ts +3 -0
  156. package/lib/dist/extraction/languages/objc.d.ts.map +1 -0
  157. package/lib/dist/extraction/languages/objc.js +175 -0
  158. package/lib/dist/extraction/languages/objc.js.map +1 -0
  159. package/lib/dist/extraction/languages/pascal.d.ts +3 -0
  160. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -0
  161. package/lib/dist/extraction/languages/pascal.js +77 -0
  162. package/lib/dist/extraction/languages/pascal.js.map +1 -0
  163. package/lib/dist/extraction/languages/php.d.ts +3 -0
  164. package/lib/dist/extraction/languages/php.d.ts.map +1 -0
  165. package/lib/dist/extraction/languages/php.js +196 -0
  166. package/lib/dist/extraction/languages/php.js.map +1 -0
  167. package/lib/dist/extraction/languages/python.d.ts +3 -0
  168. package/lib/dist/extraction/languages/python.d.ts.map +1 -0
  169. package/lib/dist/extraction/languages/python.js +56 -0
  170. package/lib/dist/extraction/languages/python.js.map +1 -0
  171. package/lib/dist/extraction/languages/r.d.ts +3 -0
  172. package/lib/dist/extraction/languages/r.d.ts.map +1 -0
  173. package/lib/dist/extraction/languages/r.js +314 -0
  174. package/lib/dist/extraction/languages/r.js.map +1 -0
  175. package/lib/dist/extraction/languages/ruby.d.ts +3 -0
  176. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -0
  177. package/lib/dist/extraction/languages/ruby.js +149 -0
  178. package/lib/dist/extraction/languages/ruby.js.map +1 -0
  179. package/lib/dist/extraction/languages/rust.d.ts +3 -0
  180. package/lib/dist/extraction/languages/rust.d.ts.map +1 -0
  181. package/lib/dist/extraction/languages/rust.js +142 -0
  182. package/lib/dist/extraction/languages/rust.js.map +1 -0
  183. package/lib/dist/extraction/languages/scala.d.ts +3 -0
  184. package/lib/dist/extraction/languages/scala.d.ts.map +1 -0
  185. package/lib/dist/extraction/languages/scala.js +209 -0
  186. package/lib/dist/extraction/languages/scala.js.map +1 -0
  187. package/lib/dist/extraction/languages/solidity.d.ts +3 -0
  188. package/lib/dist/extraction/languages/solidity.d.ts.map +1 -0
  189. package/lib/dist/extraction/languages/solidity.js +293 -0
  190. package/lib/dist/extraction/languages/solidity.js.map +1 -0
  191. package/lib/dist/extraction/languages/swift.d.ts +3 -0
  192. package/lib/dist/extraction/languages/swift.d.ts.map +1 -0
  193. package/lib/dist/extraction/languages/swift.js +152 -0
  194. package/lib/dist/extraction/languages/swift.js.map +1 -0
  195. package/lib/dist/extraction/languages/terraform.d.ts +3 -0
  196. package/lib/dist/extraction/languages/terraform.d.ts.map +1 -0
  197. package/lib/dist/extraction/languages/terraform.js +641 -0
  198. package/lib/dist/extraction/languages/terraform.js.map +1 -0
  199. package/lib/dist/extraction/languages/typescript.d.ts +16 -0
  200. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -0
  201. package/lib/dist/extraction/languages/typescript.js +167 -0
  202. package/lib/dist/extraction/languages/typescript.js.map +1 -0
  203. package/lib/dist/extraction/languages/vbnet.d.ts +11 -0
  204. package/lib/dist/extraction/languages/vbnet.d.ts.map +1 -0
  205. package/lib/dist/extraction/languages/vbnet.js +141 -0
  206. package/lib/dist/extraction/languages/vbnet.js.map +1 -0
  207. package/lib/dist/extraction/liquid-extractor.d.ts +59 -0
  208. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -0
  209. package/lib/dist/extraction/liquid-extractor.js +357 -0
  210. package/lib/dist/extraction/liquid-extractor.js.map +1 -0
  211. package/lib/dist/extraction/mybatis-extractor.d.ts +68 -0
  212. package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  213. package/lib/dist/extraction/mybatis-extractor.js +300 -0
  214. package/lib/dist/extraction/mybatis-extractor.js.map +1 -0
  215. package/lib/dist/extraction/parse-pool.d.ts +126 -0
  216. package/lib/dist/extraction/parse-pool.d.ts.map +1 -0
  217. package/lib/dist/extraction/parse-pool.js +319 -0
  218. package/lib/dist/extraction/parse-pool.js.map +1 -0
  219. package/lib/dist/extraction/parse-worker.d.ts +8 -0
  220. package/lib/dist/extraction/parse-worker.d.ts.map +1 -0
  221. package/lib/dist/extraction/parse-worker.js +97 -0
  222. package/lib/dist/extraction/parse-worker.js.map +1 -0
  223. package/lib/dist/extraction/razor-extractor.d.ts +42 -0
  224. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
  225. package/lib/dist/extraction/razor-extractor.js +285 -0
  226. package/lib/dist/extraction/razor-extractor.js.map +1 -0
  227. package/lib/dist/extraction/svelte-extractor.d.ts +56 -0
  228. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -0
  229. package/lib/dist/extraction/svelte-extractor.js +275 -0
  230. package/lib/dist/extraction/svelte-extractor.js.map +1 -0
  231. package/lib/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  232. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  233. package/lib/dist/extraction/tree-sitter-helpers.js +153 -0
  234. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -0
  235. package/lib/dist/extraction/tree-sitter-types.d.ts +258 -0
  236. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  237. package/lib/dist/extraction/tree-sitter-types.js +10 -0
  238. package/lib/dist/extraction/tree-sitter-types.js.map +1 -0
  239. package/lib/dist/extraction/tree-sitter.d.ts +706 -0
  240. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -0
  241. package/lib/dist/extraction/tree-sitter.js +6506 -0
  242. package/lib/dist/extraction/tree-sitter.js.map +1 -0
  243. package/lib/dist/extraction/vue-extractor.d.ts +51 -0
  244. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -0
  245. package/lib/dist/extraction/vue-extractor.js +254 -0
  246. package/lib/dist/extraction/vue-extractor.js.map +1 -0
  247. package/lib/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  248. package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  249. package/lib/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  250. package/lib/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  251. package/lib/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  252. package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  253. package/lib/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  254. package/lib/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  255. package/lib/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  256. package/lib/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  257. package/lib/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  258. package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  259. package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  260. package/lib/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  261. package/lib/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  262. package/lib/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  263. package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  264. package/lib/dist/extraction/wasm-runtime-flags.js +106 -0
  265. package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -0
  266. package/lib/dist/graph/index.d.ts +8 -0
  267. package/lib/dist/graph/index.d.ts.map +1 -0
  268. package/lib/dist/graph/index.js +13 -0
  269. package/lib/dist/graph/index.js.map +1 -0
  270. package/lib/dist/graph/queries.d.ts +106 -0
  271. package/lib/dist/graph/queries.d.ts.map +1 -0
  272. package/lib/dist/graph/queries.js +339 -0
  273. package/lib/dist/graph/queries.js.map +1 -0
  274. package/lib/dist/graph/traversal.d.ts +127 -0
  275. package/lib/dist/graph/traversal.d.ts.map +1 -0
  276. package/lib/dist/graph/traversal.js +599 -0
  277. package/lib/dist/graph/traversal.js.map +1 -0
  278. package/lib/dist/index.d.ts +642 -0
  279. package/lib/dist/index.d.ts.map +1 -0
  280. package/lib/dist/index.js +1387 -0
  281. package/lib/dist/index.js.map +1 -0
  282. package/lib/dist/installer/config-writer.d.ts +28 -0
  283. package/lib/dist/installer/config-writer.d.ts.map +1 -0
  284. package/lib/dist/installer/config-writer.js +91 -0
  285. package/lib/dist/installer/config-writer.js.map +1 -0
  286. package/lib/dist/installer/index.d.ts +100 -0
  287. package/lib/dist/installer/index.d.ts.map +1 -0
  288. package/lib/dist/installer/index.js +526 -0
  289. package/lib/dist/installer/index.js.map +1 -0
  290. package/lib/dist/installer/instructions-template.d.ts +41 -0
  291. package/lib/dist/installer/instructions-template.d.ts.map +1 -0
  292. package/lib/dist/installer/instructions-template.js +53 -0
  293. package/lib/dist/installer/instructions-template.js.map +1 -0
  294. package/lib/dist/installer/targets/antigravity.d.ts +57 -0
  295. package/lib/dist/installer/targets/antigravity.d.ts.map +1 -0
  296. package/lib/dist/installer/targets/antigravity.js +308 -0
  297. package/lib/dist/installer/targets/antigravity.js.map +1 -0
  298. package/lib/dist/installer/targets/claude.d.ts +62 -0
  299. package/lib/dist/installer/targets/claude.d.ts.map +1 -0
  300. package/lib/dist/installer/targets/claude.js +454 -0
  301. package/lib/dist/installer/targets/claude.js.map +1 -0
  302. package/lib/dist/installer/targets/codex.d.ts +18 -0
  303. package/lib/dist/installer/targets/codex.d.ts.map +1 -0
  304. package/lib/dist/installer/targets/codex.js +185 -0
  305. package/lib/dist/installer/targets/codex.js.map +1 -0
  306. package/lib/dist/installer/targets/cursor.d.ts +35 -0
  307. package/lib/dist/installer/targets/cursor.d.ts.map +1 -0
  308. package/lib/dist/installer/targets/cursor.js +254 -0
  309. package/lib/dist/installer/targets/cursor.js.map +1 -0
  310. package/lib/dist/installer/targets/gemini.d.ts +26 -0
  311. package/lib/dist/installer/targets/gemini.d.ts.map +1 -0
  312. package/lib/dist/installer/targets/gemini.js +165 -0
  313. package/lib/dist/installer/targets/gemini.js.map +1 -0
  314. package/lib/dist/installer/targets/hermes.d.ts +18 -0
  315. package/lib/dist/installer/targets/hermes.d.ts.map +1 -0
  316. package/lib/dist/installer/targets/hermes.js +359 -0
  317. package/lib/dist/installer/targets/hermes.js.map +1 -0
  318. package/lib/dist/installer/targets/kiro.d.ts +27 -0
  319. package/lib/dist/installer/targets/kiro.d.ts.map +1 -0
  320. package/lib/dist/installer/targets/kiro.js +178 -0
  321. package/lib/dist/installer/targets/kiro.js.map +1 -0
  322. package/lib/dist/installer/targets/opencode.d.ts +38 -0
  323. package/lib/dist/installer/targets/opencode.d.ts.map +1 -0
  324. package/lib/dist/installer/targets/opencode.js +288 -0
  325. package/lib/dist/installer/targets/opencode.js.map +1 -0
  326. package/lib/dist/installer/targets/registry.d.ts +35 -0
  327. package/lib/dist/installer/targets/registry.d.ts.map +1 -0
  328. package/lib/dist/installer/targets/registry.js +91 -0
  329. package/lib/dist/installer/targets/registry.js.map +1 -0
  330. package/lib/dist/installer/targets/shared.d.ts +101 -0
  331. package/lib/dist/installer/targets/shared.d.ts.map +1 -0
  332. package/lib/dist/installer/targets/shared.js +264 -0
  333. package/lib/dist/installer/targets/shared.js.map +1 -0
  334. package/lib/dist/installer/targets/toml.d.ts +52 -0
  335. package/lib/dist/installer/targets/toml.d.ts.map +1 -0
  336. package/lib/dist/installer/targets/toml.js +147 -0
  337. package/lib/dist/installer/targets/toml.js.map +1 -0
  338. package/lib/dist/installer/targets/types.d.ts +108 -0
  339. package/lib/dist/installer/targets/types.d.ts.map +1 -0
  340. package/lib/dist/installer/targets/types.js +16 -0
  341. package/lib/dist/installer/targets/types.js.map +1 -0
  342. package/lib/dist/mcp/daemon-manager.d.ts +42 -0
  343. package/lib/dist/mcp/daemon-manager.d.ts.map +1 -0
  344. package/lib/dist/mcp/daemon-manager.js +129 -0
  345. package/lib/dist/mcp/daemon-manager.js.map +1 -0
  346. package/lib/dist/mcp/daemon-paths.d.ts +73 -0
  347. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -0
  348. package/lib/dist/mcp/daemon-paths.js +165 -0
  349. package/lib/dist/mcp/daemon-paths.js.map +1 -0
  350. package/lib/dist/mcp/daemon-registry.d.ts +47 -0
  351. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -0
  352. package/lib/dist/mcp/daemon-registry.js +233 -0
  353. package/lib/dist/mcp/daemon-registry.js.map +1 -0
  354. package/lib/dist/mcp/daemon.d.ts +290 -0
  355. package/lib/dist/mcp/daemon.d.ts.map +1 -0
  356. package/lib/dist/mcp/daemon.js +840 -0
  357. package/lib/dist/mcp/daemon.js.map +1 -0
  358. package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
  359. package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  360. package/lib/dist/mcp/dynamic-boundaries.js +360 -0
  361. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
  362. package/lib/dist/mcp/early-ppid.d.ts +26 -0
  363. package/lib/dist/mcp/early-ppid.d.ts.map +1 -0
  364. package/lib/dist/mcp/early-ppid.js +29 -0
  365. package/lib/dist/mcp/early-ppid.js.map +1 -0
  366. package/lib/dist/mcp/engine.d.ts +122 -0
  367. package/lib/dist/mcp/engine.d.ts.map +1 -0
  368. package/lib/dist/mcp/engine.js +350 -0
  369. package/lib/dist/mcp/engine.js.map +1 -0
  370. package/lib/dist/mcp/index.d.ts +113 -0
  371. package/lib/dist/mcp/index.d.ts.map +1 -0
  372. package/lib/dist/mcp/index.js +498 -0
  373. package/lib/dist/mcp/index.js.map +1 -0
  374. package/lib/dist/mcp/liveness-watchdog.d.ts +18 -0
  375. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  376. package/lib/dist/mcp/liveness-watchdog.js +207 -0
  377. package/lib/dist/mcp/liveness-watchdog.js.map +1 -0
  378. package/lib/dist/mcp/ppid-watchdog.d.ts +62 -0
  379. package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  380. package/lib/dist/mcp/ppid-watchdog.js +64 -0
  381. package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
  382. package/lib/dist/mcp/proxy.d.ts +87 -0
  383. package/lib/dist/mcp/proxy.d.ts.map +1 -0
  384. package/lib/dist/mcp/proxy.js +659 -0
  385. package/lib/dist/mcp/proxy.js.map +1 -0
  386. package/lib/dist/mcp/query-pool.d.ts +94 -0
  387. package/lib/dist/mcp/query-pool.d.ts.map +1 -0
  388. package/lib/dist/mcp/query-pool.js +297 -0
  389. package/lib/dist/mcp/query-pool.js.map +1 -0
  390. package/lib/dist/mcp/query-worker.d.ts +24 -0
  391. package/lib/dist/mcp/query-worker.d.ts.map +1 -0
  392. package/lib/dist/mcp/query-worker.js +87 -0
  393. package/lib/dist/mcp/query-worker.js.map +1 -0
  394. package/lib/dist/mcp/server-instructions.d.ts +34 -0
  395. package/lib/dist/mcp/server-instructions.d.ts.map +1 -0
  396. package/lib/dist/mcp/server-instructions.js +106 -0
  397. package/lib/dist/mcp/server-instructions.js.map +1 -0
  398. package/lib/dist/mcp/session.d.ts +79 -0
  399. package/lib/dist/mcp/session.d.ts.map +1 -0
  400. package/lib/dist/mcp/session.js +330 -0
  401. package/lib/dist/mcp/session.js.map +1 -0
  402. package/lib/dist/mcp/startup-handshake.d.ts +44 -0
  403. package/lib/dist/mcp/startup-handshake.d.ts.map +1 -0
  404. package/lib/dist/mcp/startup-handshake.js +73 -0
  405. package/lib/dist/mcp/startup-handshake.js.map +1 -0
  406. package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
  407. package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
  408. package/lib/dist/mcp/stdin-teardown.js +49 -0
  409. package/lib/dist/mcp/stdin-teardown.js.map +1 -0
  410. package/lib/dist/mcp/tools.d.ts +613 -0
  411. package/lib/dist/mcp/tools.d.ts.map +1 -0
  412. package/lib/dist/mcp/tools.js +4424 -0
  413. package/lib/dist/mcp/tools.js.map +1 -0
  414. package/lib/dist/mcp/transport.d.ts +188 -0
  415. package/lib/dist/mcp/transport.d.ts.map +1 -0
  416. package/lib/dist/mcp/transport.js +359 -0
  417. package/lib/dist/mcp/transport.js.map +1 -0
  418. package/lib/dist/mcp/version.d.ts +19 -0
  419. package/lib/dist/mcp/version.d.ts.map +1 -0
  420. package/lib/dist/mcp/version.js +71 -0
  421. package/lib/dist/mcp/version.js.map +1 -0
  422. package/lib/dist/project-config.d.ts +94 -0
  423. package/lib/dist/project-config.d.ts.map +1 -0
  424. package/lib/dist/project-config.js +374 -0
  425. package/lib/dist/project-config.js.map +1 -0
  426. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +5 -0
  427. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  428. package/lib/dist/resolution/c-fnptr-synthesizer.js +1038 -0
  429. package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  430. package/lib/dist/resolution/callback-synthesizer.d.ts +15 -0
  431. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  432. package/lib/dist/resolution/callback-synthesizer.js +3658 -0
  433. package/lib/dist/resolution/callback-synthesizer.js.map +1 -0
  434. package/lib/dist/resolution/cooperative-yield.d.ts +32 -0
  435. package/lib/dist/resolution/cooperative-yield.d.ts.map +1 -0
  436. package/lib/dist/resolution/cooperative-yield.js +42 -0
  437. package/lib/dist/resolution/cooperative-yield.js.map +1 -0
  438. package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
  439. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
  440. package/lib/dist/resolution/frameworks/astro.js +169 -0
  441. package/lib/dist/resolution/frameworks/astro.js.map +1 -0
  442. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  443. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  444. package/lib/dist/resolution/frameworks/cargo-workspace.js +225 -0
  445. package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  446. package/lib/dist/resolution/frameworks/cics.d.ts +20 -0
  447. package/lib/dist/resolution/frameworks/cics.d.ts.map +1 -0
  448. package/lib/dist/resolution/frameworks/cics.js +90 -0
  449. package/lib/dist/resolution/frameworks/cics.js.map +1 -0
  450. package/lib/dist/resolution/frameworks/csharp.d.ts +8 -0
  451. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  452. package/lib/dist/resolution/frameworks/csharp.js +241 -0
  453. package/lib/dist/resolution/frameworks/csharp.js.map +1 -0
  454. package/lib/dist/resolution/frameworks/drupal.d.ts +51 -0
  455. package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  456. package/lib/dist/resolution/frameworks/drupal.js +367 -0
  457. package/lib/dist/resolution/frameworks/drupal.js.map +1 -0
  458. package/lib/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  459. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  460. package/lib/dist/resolution/frameworks/expo-modules.js +148 -0
  461. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -0
  462. package/lib/dist/resolution/frameworks/express.d.ts +8 -0
  463. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -0
  464. package/lib/dist/resolution/frameworks/express.js +308 -0
  465. package/lib/dist/resolution/frameworks/express.js.map +1 -0
  466. package/lib/dist/resolution/frameworks/fabric.d.ts +3 -0
  467. package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  468. package/lib/dist/resolution/frameworks/fabric.js +354 -0
  469. package/lib/dist/resolution/frameworks/fabric.js.map +1 -0
  470. package/lib/dist/resolution/frameworks/go.d.ts +8 -0
  471. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -0
  472. package/lib/dist/resolution/frameworks/go.js +161 -0
  473. package/lib/dist/resolution/frameworks/go.js.map +1 -0
  474. package/lib/dist/resolution/frameworks/goframe.d.ts +41 -0
  475. package/lib/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  476. package/lib/dist/resolution/frameworks/goframe.js +112 -0
  477. package/lib/dist/resolution/frameworks/goframe.js.map +1 -0
  478. package/lib/dist/resolution/frameworks/index.d.ts +50 -0
  479. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -0
  480. package/lib/dist/resolution/frameworks/index.js +175 -0
  481. package/lib/dist/resolution/frameworks/index.js.map +1 -0
  482. package/lib/dist/resolution/frameworks/java.d.ts +8 -0
  483. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -0
  484. package/lib/dist/resolution/frameworks/java.js +517 -0
  485. package/lib/dist/resolution/frameworks/java.js.map +1 -0
  486. package/lib/dist/resolution/frameworks/laravel.d.ts +13 -0
  487. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  488. package/lib/dist/resolution/frameworks/laravel.js +257 -0
  489. package/lib/dist/resolution/frameworks/laravel.js.map +1 -0
  490. package/lib/dist/resolution/frameworks/nestjs.d.ts +26 -0
  491. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  492. package/lib/dist/resolution/frameworks/nestjs.js +698 -0
  493. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -0
  494. package/lib/dist/resolution/frameworks/play.d.ts +19 -0
  495. package/lib/dist/resolution/frameworks/play.d.ts.map +1 -0
  496. package/lib/dist/resolution/frameworks/play.js +111 -0
  497. package/lib/dist/resolution/frameworks/play.js.map +1 -0
  498. package/lib/dist/resolution/frameworks/python.d.ts +10 -0
  499. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -0
  500. package/lib/dist/resolution/frameworks/python.js +400 -0
  501. package/lib/dist/resolution/frameworks/python.js.map +1 -0
  502. package/lib/dist/resolution/frameworks/react-native.d.ts +3 -0
  503. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  504. package/lib/dist/resolution/frameworks/react-native.js +410 -0
  505. package/lib/dist/resolution/frameworks/react-native.js.map +1 -0
  506. package/lib/dist/resolution/frameworks/react.d.ts +8 -0
  507. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -0
  508. package/lib/dist/resolution/frameworks/react.js +334 -0
  509. package/lib/dist/resolution/frameworks/react.js.map +1 -0
  510. package/lib/dist/resolution/frameworks/ruby.d.ts +8 -0
  511. package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  512. package/lib/dist/resolution/frameworks/ruby.js +302 -0
  513. package/lib/dist/resolution/frameworks/ruby.js.map +1 -0
  514. package/lib/dist/resolution/frameworks/rust.d.ts +8 -0
  515. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -0
  516. package/lib/dist/resolution/frameworks/rust.js +304 -0
  517. package/lib/dist/resolution/frameworks/rust.js.map +1 -0
  518. package/lib/dist/resolution/frameworks/svelte.d.ts +9 -0
  519. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  520. package/lib/dist/resolution/frameworks/svelte.js +253 -0
  521. package/lib/dist/resolution/frameworks/svelte.js.map +1 -0
  522. package/lib/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  523. package/lib/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  524. package/lib/dist/resolution/frameworks/swift-objc.js +252 -0
  525. package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -0
  526. package/lib/dist/resolution/frameworks/swift.d.ts +10 -0
  527. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -0
  528. package/lib/dist/resolution/frameworks/swift.js +400 -0
  529. package/lib/dist/resolution/frameworks/swift.js.map +1 -0
  530. package/lib/dist/resolution/frameworks/terraform.d.ts +38 -0
  531. package/lib/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  532. package/lib/dist/resolution/frameworks/terraform.js +277 -0
  533. package/lib/dist/resolution/frameworks/terraform.js.map +1 -0
  534. package/lib/dist/resolution/frameworks/vue.d.ts +9 -0
  535. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -0
  536. package/lib/dist/resolution/frameworks/vue.js +303 -0
  537. package/lib/dist/resolution/frameworks/vue.js.map +1 -0
  538. package/lib/dist/resolution/go-module.d.ts +26 -0
  539. package/lib/dist/resolution/go-module.d.ts.map +1 -0
  540. package/lib/dist/resolution/go-module.js +78 -0
  541. package/lib/dist/resolution/go-module.js.map +1 -0
  542. package/lib/dist/resolution/goframe-synthesizer.d.ts +28 -0
  543. package/lib/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  544. package/lib/dist/resolution/goframe-synthesizer.js +158 -0
  545. package/lib/dist/resolution/goframe-synthesizer.js.map +1 -0
  546. package/lib/dist/resolution/import-resolver.d.ts +85 -0
  547. package/lib/dist/resolution/import-resolver.d.ts.map +1 -0
  548. package/lib/dist/resolution/import-resolver.js +1974 -0
  549. package/lib/dist/resolution/import-resolver.js.map +1 -0
  550. package/lib/dist/resolution/index.d.ts +238 -0
  551. package/lib/dist/resolution/index.d.ts.map +1 -0
  552. package/lib/dist/resolution/index.js +1633 -0
  553. package/lib/dist/resolution/index.js.map +1 -0
  554. package/lib/dist/resolution/lru-cache.d.ts +24 -0
  555. package/lib/dist/resolution/lru-cache.d.ts.map +1 -0
  556. package/lib/dist/resolution/lru-cache.js +62 -0
  557. package/lib/dist/resolution/lru-cache.js.map +1 -0
  558. package/lib/dist/resolution/name-matcher.d.ts +112 -0
  559. package/lib/dist/resolution/name-matcher.d.ts.map +1 -0
  560. package/lib/dist/resolution/name-matcher.js +1701 -0
  561. package/lib/dist/resolution/name-matcher.js.map +1 -0
  562. package/lib/dist/resolution/path-aliases.d.ts +68 -0
  563. package/lib/dist/resolution/path-aliases.d.ts.map +1 -0
  564. package/lib/dist/resolution/path-aliases.js +238 -0
  565. package/lib/dist/resolution/path-aliases.js.map +1 -0
  566. package/lib/dist/resolution/strip-comments.d.ts +27 -0
  567. package/lib/dist/resolution/strip-comments.d.ts.map +1 -0
  568. package/lib/dist/resolution/strip-comments.js +492 -0
  569. package/lib/dist/resolution/strip-comments.js.map +1 -0
  570. package/lib/dist/resolution/swift-objc-bridge.d.ts +134 -0
  571. package/lib/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  572. package/lib/dist/resolution/swift-objc-bridge.js +256 -0
  573. package/lib/dist/resolution/swift-objc-bridge.js.map +1 -0
  574. package/lib/dist/resolution/types.d.ts +253 -0
  575. package/lib/dist/resolution/types.d.ts.map +1 -0
  576. package/lib/dist/resolution/types.js +8 -0
  577. package/lib/dist/resolution/types.js.map +1 -0
  578. package/lib/dist/resolution/workspace-packages.d.ts +58 -0
  579. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
  580. package/lib/dist/resolution/workspace-packages.js +346 -0
  581. package/lib/dist/resolution/workspace-packages.js.map +1 -0
  582. package/lib/dist/search/identifier-segments.d.ts +60 -0
  583. package/lib/dist/search/identifier-segments.d.ts.map +1 -0
  584. package/lib/dist/search/identifier-segments.js +176 -0
  585. package/lib/dist/search/identifier-segments.js.map +1 -0
  586. package/lib/dist/search/query-parser.d.ts +57 -0
  587. package/lib/dist/search/query-parser.d.ts.map +1 -0
  588. package/lib/dist/search/query-parser.js +177 -0
  589. package/lib/dist/search/query-parser.js.map +1 -0
  590. package/lib/dist/search/query-utils.d.ts +87 -0
  591. package/lib/dist/search/query-utils.d.ts.map +1 -0
  592. package/lib/dist/search/query-utils.js +449 -0
  593. package/lib/dist/search/query-utils.js.map +1 -0
  594. package/lib/dist/sync/git-hooks.d.ts +45 -0
  595. package/lib/dist/sync/git-hooks.d.ts.map +1 -0
  596. package/lib/dist/sync/git-hooks.js +227 -0
  597. package/lib/dist/sync/git-hooks.js.map +1 -0
  598. package/lib/dist/sync/index.d.ts +19 -0
  599. package/lib/dist/sync/index.d.ts.map +1 -0
  600. package/lib/dist/sync/index.js +35 -0
  601. package/lib/dist/sync/index.js.map +1 -0
  602. package/lib/dist/sync/watch-policy.d.ts +48 -0
  603. package/lib/dist/sync/watch-policy.d.ts.map +1 -0
  604. package/lib/dist/sync/watch-policy.js +124 -0
  605. package/lib/dist/sync/watch-policy.js.map +1 -0
  606. package/lib/dist/sync/watcher.d.ts +355 -0
  607. package/lib/dist/sync/watcher.d.ts.map +1 -0
  608. package/lib/dist/sync/watcher.js +848 -0
  609. package/lib/dist/sync/watcher.js.map +1 -0
  610. package/lib/dist/sync/worktree.d.ts +63 -0
  611. package/lib/dist/sync/worktree.d.ts.map +1 -0
  612. package/lib/dist/sync/worktree.js +182 -0
  613. package/lib/dist/sync/worktree.js.map +1 -0
  614. package/lib/dist/telemetry/index.d.ts +143 -0
  615. package/lib/dist/telemetry/index.d.ts.map +1 -0
  616. package/lib/dist/telemetry/index.js +541 -0
  617. package/lib/dist/telemetry/index.js.map +1 -0
  618. package/lib/dist/types.d.ts +415 -0
  619. package/lib/dist/types.d.ts.map +1 -0
  620. package/lib/dist/types.js +91 -0
  621. package/lib/dist/types.js.map +1 -0
  622. package/lib/dist/ui/glyphs.d.ts +42 -0
  623. package/lib/dist/ui/glyphs.d.ts.map +1 -0
  624. package/lib/dist/ui/glyphs.js +78 -0
  625. package/lib/dist/ui/glyphs.js.map +1 -0
  626. package/lib/dist/ui/shimmer-progress.d.ts +11 -0
  627. package/lib/dist/ui/shimmer-progress.d.ts.map +1 -0
  628. package/lib/dist/ui/shimmer-progress.js +90 -0
  629. package/lib/dist/ui/shimmer-progress.js.map +1 -0
  630. package/lib/dist/ui/shimmer-worker.d.ts +2 -0
  631. package/lib/dist/ui/shimmer-worker.d.ts.map +1 -0
  632. package/lib/dist/ui/shimmer-worker.js +118 -0
  633. package/lib/dist/ui/shimmer-worker.js.map +1 -0
  634. package/lib/dist/ui/types.d.ts +17 -0
  635. package/lib/dist/ui/types.d.ts.map +1 -0
  636. package/lib/dist/ui/types.js +3 -0
  637. package/lib/dist/ui/types.js.map +1 -0
  638. package/lib/dist/upgrade/index.d.ts +132 -0
  639. package/lib/dist/upgrade/index.d.ts.map +1 -0
  640. package/lib/dist/upgrade/index.js +498 -0
  641. package/lib/dist/upgrade/index.js.map +1 -0
  642. package/lib/dist/utils.d.ts +224 -0
  643. package/lib/dist/utils.d.ts.map +1 -0
  644. package/lib/dist/utils.js +583 -0
  645. package/lib/dist/utils.js.map +1 -0
  646. package/lib/node_modules/.package-lock.json +125 -0
  647. package/lib/node_modules/@clack/core/CHANGELOG.md +348 -0
  648. package/lib/node_modules/@clack/core/LICENSE +9 -0
  649. package/lib/node_modules/@clack/core/README.md +22 -0
  650. package/lib/node_modules/@clack/core/dist/index.d.mts +363 -0
  651. package/lib/node_modules/@clack/core/dist/index.mjs +17 -0
  652. package/lib/node_modules/@clack/core/dist/index.mjs.map +1 -0
  653. package/lib/node_modules/@clack/core/package.json +63 -0
  654. package/lib/node_modules/@clack/prompts/CHANGELOG.md +591 -0
  655. package/lib/node_modules/@clack/prompts/LICENSE +9 -0
  656. package/lib/node_modules/@clack/prompts/README.md +375 -0
  657. package/lib/node_modules/@clack/prompts/dist/index.d.mts +396 -0
  658. package/lib/node_modules/@clack/prompts/dist/index.mjs +144 -0
  659. package/lib/node_modules/@clack/prompts/dist/index.mjs.map +1 -0
  660. package/lib/node_modules/@clack/prompts/package.json +68 -0
  661. package/lib/node_modules/commander/LICENSE +22 -0
  662. package/lib/node_modules/commander/Readme.md +1176 -0
  663. package/lib/node_modules/commander/esm.mjs +16 -0
  664. package/lib/node_modules/commander/index.js +24 -0
  665. package/lib/node_modules/commander/lib/argument.js +150 -0
  666. package/lib/node_modules/commander/lib/command.js +2777 -0
  667. package/lib/node_modules/commander/lib/error.js +39 -0
  668. package/lib/node_modules/commander/lib/help.js +747 -0
  669. package/lib/node_modules/commander/lib/option.js +380 -0
  670. package/lib/node_modules/commander/lib/suggestSimilar.js +101 -0
  671. package/lib/node_modules/commander/package-support.json +19 -0
  672. package/lib/node_modules/commander/package.json +82 -0
  673. package/lib/node_modules/commander/typings/esm.d.mts +3 -0
  674. package/lib/node_modules/commander/typings/index.d.ts +1113 -0
  675. package/lib/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  676. package/lib/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  677. package/lib/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  678. package/lib/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  679. package/lib/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  680. package/lib/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  681. package/lib/node_modules/fast-string-truncated-width/license +21 -0
  682. package/lib/node_modules/fast-string-truncated-width/package.json +35 -0
  683. package/lib/node_modules/fast-string-truncated-width/readme.md +59 -0
  684. package/lib/node_modules/fast-string-width/dist/index.d.ts +4 -0
  685. package/lib/node_modules/fast-string-width/dist/index.js +14 -0
  686. package/lib/node_modules/fast-string-width/license +21 -0
  687. package/lib/node_modules/fast-string-width/package.json +34 -0
  688. package/lib/node_modules/fast-string-width/readme.md +42 -0
  689. package/lib/node_modules/fast-wrap-ansi/LICENSE +23 -0
  690. package/lib/node_modules/fast-wrap-ansi/README.md +26 -0
  691. package/lib/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  692. package/lib/node_modules/fast-wrap-ansi/lib/main.js +219 -0
  693. package/lib/node_modules/fast-wrap-ansi/lib/main.js.map +1 -0
  694. package/lib/node_modules/fast-wrap-ansi/package.json +51 -0
  695. package/lib/node_modules/ignore/LICENSE-MIT +21 -0
  696. package/lib/node_modules/ignore/README.md +452 -0
  697. package/lib/node_modules/ignore/index.d.ts +81 -0
  698. package/lib/node_modules/ignore/index.js +784 -0
  699. package/lib/node_modules/ignore/legacy.js +681 -0
  700. package/lib/node_modules/ignore/package.json +87 -0
  701. package/lib/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  702. package/lib/node_modules/jsonc-parser/LICENSE.md +21 -0
  703. package/lib/node_modules/jsonc-parser/README.md +364 -0
  704. package/lib/node_modules/jsonc-parser/SECURITY.md +41 -0
  705. package/lib/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  706. package/lib/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  707. package/lib/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  708. package/lib/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  709. package/lib/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  710. package/lib/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  711. package/lib/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  712. package/lib/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  713. package/lib/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  714. package/lib/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  715. package/lib/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  716. package/lib/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  717. package/lib/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  718. package/lib/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  719. package/lib/node_modules/jsonc-parser/package.json +37 -0
  720. package/lib/node_modules/picomatch/LICENSE +21 -0
  721. package/lib/node_modules/picomatch/README.md +738 -0
  722. package/lib/node_modules/picomatch/index.js +17 -0
  723. package/lib/node_modules/picomatch/lib/constants.js +180 -0
  724. package/lib/node_modules/picomatch/lib/parse.js +1085 -0
  725. package/lib/node_modules/picomatch/lib/picomatch.js +341 -0
  726. package/lib/node_modules/picomatch/lib/scan.js +391 -0
  727. package/lib/node_modules/picomatch/lib/utils.js +72 -0
  728. package/lib/node_modules/picomatch/package.json +83 -0
  729. package/lib/node_modules/picomatch/posix.js +3 -0
  730. package/lib/node_modules/sisteransi/license +21 -0
  731. package/lib/node_modules/sisteransi/package.json +34 -0
  732. package/lib/node_modules/sisteransi/readme.md +113 -0
  733. package/lib/node_modules/sisteransi/src/index.js +58 -0
  734. package/lib/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  735. package/lib/node_modules/tree-sitter-wasms/LICENSE +24 -0
  736. package/lib/node_modules/tree-sitter-wasms/README.md +23 -0
  737. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
  738. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
  739. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
  740. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
  741. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
  742. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
  743. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
  744. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
  745. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
  746. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
  747. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
  748. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
  749. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
  750. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
  751. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
  752. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
  753. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
  754. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
  755. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
  756. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
  757. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
  758. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
  759. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
  760. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
  761. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
  762. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
  763. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
  764. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
  765. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
  766. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
  767. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
  768. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
  769. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
  770. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
  771. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
  772. package/lib/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
  773. package/lib/node_modules/tree-sitter-wasms/package.json +64 -0
  774. package/lib/node_modules/web-tree-sitter/LICENSE +21 -0
  775. package/lib/node_modules/web-tree-sitter/README.md +269 -0
  776. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs +4558 -0
  777. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.cjs.map +7 -0
  778. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js +4516 -0
  779. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.js.map +7 -0
  780. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm +0 -0
  781. package/lib/node_modules/web-tree-sitter/debug/tree-sitter.wasm.map +31 -0
  782. package/lib/node_modules/web-tree-sitter/lib/alloc.c +48 -0
  783. package/lib/node_modules/web-tree-sitter/lib/alloc.h +41 -0
  784. package/lib/node_modules/web-tree-sitter/lib/array.h +291 -0
  785. package/lib/node_modules/web-tree-sitter/lib/atomic.h +68 -0
  786. package/lib/node_modules/web-tree-sitter/lib/clock.h +146 -0
  787. package/lib/node_modules/web-tree-sitter/lib/error_costs.h +11 -0
  788. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.c +523 -0
  789. package/lib/node_modules/web-tree-sitter/lib/get_changed_ranges.h +36 -0
  790. package/lib/node_modules/web-tree-sitter/lib/host.h +21 -0
  791. package/lib/node_modules/web-tree-sitter/lib/language.c +293 -0
  792. package/lib/node_modules/web-tree-sitter/lib/language.h +293 -0
  793. package/lib/node_modules/web-tree-sitter/lib/length.h +52 -0
  794. package/lib/node_modules/web-tree-sitter/lib/lexer.c +483 -0
  795. package/lib/node_modules/web-tree-sitter/lib/lexer.h +54 -0
  796. package/lib/node_modules/web-tree-sitter/lib/lib.c +12 -0
  797. package/lib/node_modules/web-tree-sitter/lib/node.c +875 -0
  798. package/lib/node_modules/web-tree-sitter/lib/parser.c +2297 -0
  799. package/lib/node_modules/web-tree-sitter/lib/parser.h +286 -0
  800. package/lib/node_modules/web-tree-sitter/lib/point.h +48 -0
  801. package/lib/node_modules/web-tree-sitter/lib/query.c +4347 -0
  802. package/lib/node_modules/web-tree-sitter/lib/reduce_action.h +34 -0
  803. package/lib/node_modules/web-tree-sitter/lib/reusable_node.h +95 -0
  804. package/lib/node_modules/web-tree-sitter/lib/stack.c +912 -0
  805. package/lib/node_modules/web-tree-sitter/lib/stack.h +133 -0
  806. package/lib/node_modules/web-tree-sitter/lib/subtree.c +1034 -0
  807. package/lib/node_modules/web-tree-sitter/lib/subtree.h +399 -0
  808. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.c +987 -0
  809. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.cjs +2988 -0
  810. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm +0 -0
  811. package/lib/node_modules/web-tree-sitter/lib/tree-sitter.wasm.map +1 -0
  812. package/lib/node_modules/web-tree-sitter/lib/tree.c +170 -0
  813. package/lib/node_modules/web-tree-sitter/lib/tree.h +31 -0
  814. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.c +716 -0
  815. package/lib/node_modules/web-tree-sitter/lib/tree_cursor.h +48 -0
  816. package/lib/node_modules/web-tree-sitter/lib/ts_assert.h +11 -0
  817. package/lib/node_modules/web-tree-sitter/lib/unicode.h +75 -0
  818. package/lib/node_modules/web-tree-sitter/lib/wasm_store.c +1937 -0
  819. package/lib/node_modules/web-tree-sitter/lib/wasm_store.h +31 -0
  820. package/lib/node_modules/web-tree-sitter/package.json +98 -0
  821. package/lib/node_modules/web-tree-sitter/src/bindings.ts +26 -0
  822. package/lib/node_modules/web-tree-sitter/src/constants.ts +133 -0
  823. package/lib/node_modules/web-tree-sitter/src/index.ts +31 -0
  824. package/lib/node_modules/web-tree-sitter/src/language.ts +291 -0
  825. package/lib/node_modules/web-tree-sitter/src/lookahead_iterator.ts +75 -0
  826. package/lib/node_modules/web-tree-sitter/src/marshal.ts +176 -0
  827. package/lib/node_modules/web-tree-sitter/src/node.ts +646 -0
  828. package/lib/node_modules/web-tree-sitter/src/parser.ts +325 -0
  829. package/lib/node_modules/web-tree-sitter/src/query.ts +973 -0
  830. package/lib/node_modules/web-tree-sitter/src/tree.ts +145 -0
  831. package/lib/node_modules/web-tree-sitter/src/tree_cursor.ts +318 -0
  832. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs +4031 -0
  833. package/lib/node_modules/web-tree-sitter/tree-sitter.cjs.map +7 -0
  834. package/lib/node_modules/web-tree-sitter/tree-sitter.js +3980 -0
  835. package/lib/node_modules/web-tree-sitter/tree-sitter.js.map +7 -0
  836. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  837. package/lib/node_modules/web-tree-sitter/tree-sitter.wasm.map +30 -0
  838. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1030 -0
  839. package/lib/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +56 -0
  840. package/lib/package.json +64 -0
  841. package/node +0 -0
  842. package/package.json +17 -0
@@ -0,0 +1,1701 @@
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.resolveMethodOnType = resolveMethodOnType;
17
+ exports.matchCppCallChain = matchCppCallChain;
18
+ exports.matchScopedCallChain = matchScopedCallChain;
19
+ exports.matchDottedCallChain = matchDottedCallChain;
20
+ exports.matchMethodCall = matchMethodCall;
21
+ exports.matchFuzzy = matchFuzzy;
22
+ exports.matchReference = matchReference;
23
+ /**
24
+ * Ceiling on how many same-named definitions a FUZZY name-match strategy will
25
+ * score. A name defined more times than this is "ubiquitous" — a method/symbol
26
+ * re-declared across a vendored theme or SDK (e.g. `init`/`update`/`render` on
27
+ * every widget of a committed Metronic theme — #999). No directory-proximity or
28
+ * receiver-word-overlap score can reliably pick THE one true target among
29
+ * thousands, so the fuzzy strategies (matchByExactName's findBestMatch, and
30
+ * matchMethodCall Strategy 3) decline above the ceiling instead of emitting a
31
+ * low-confidence, almost-certainly-wrong edge. This also caps their per-ref cost
32
+ * at O(ceiling): without it, K same-named refs each scored K candidates — the
33
+ * O(K²) blow-up that pinned a core for 15-28 min at "Resolving refs … 94%" on a
34
+ * repo vendoring a large JS/TS theme (#999). The PRECISE strategies are
35
+ * unaffected: qualified-name, import-based, and class-name (Strategy 1/2)
36
+ * resolution all still run and resolve a ubiquitous name when the context names
37
+ * its exact target. Real repos top out near ~40 same-named methods, so a normal
38
+ * codebase never reaches this; only bulk-vendored code does. Tune via
39
+ * `BHGRAPH_AMBIGUOUS_NAME_CEILING`.
40
+ */
41
+ const DEFAULT_AMBIGUOUS_NAME_CEILING = 500;
42
+ function resolveAmbiguousNameCeiling() {
43
+ const raw = process.env.BHGRAPH_AMBIGUOUS_NAME_CEILING;
44
+ if (!raw)
45
+ return DEFAULT_AMBIGUOUS_NAME_CEILING;
46
+ const parsed = Number.parseInt(raw, 10);
47
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_AMBIGUOUS_NAME_CEILING;
48
+ }
49
+ const AMBIGUOUS_NAME_CEILING = resolveAmbiguousNameCeiling();
50
+ /**
51
+ * Try to resolve a path-like reference (e.g., "snippets/drawer-menu.liquid")
52
+ * by matching the filename against file nodes.
53
+ */
54
+ function matchByFilePath(ref, context) {
55
+ // Path-like (`a/b.liquid`) OR a bare filename ending in a short extension
56
+ // (`Foo.h` — an Objective-C `#import "Foo.h"`, resolved to the header by
57
+ // basename). A bare ref WITHOUT an extension is a symbol name, not a file, so
58
+ // leave it to the symbol-matching strategies.
59
+ if (!ref.referenceName.includes('/') && !/\.[A-Za-z][A-Za-z0-9]{0,3}$/.test(ref.referenceName)) {
60
+ return null;
61
+ }
62
+ // Extract the filename from the path
63
+ const fileName = ref.referenceName.split('/').pop();
64
+ if (!fileName)
65
+ return null;
66
+ // Search for file nodes with this name
67
+ const candidates = context.getNodesByName(fileName);
68
+ const fileNodes = candidates.filter(n => n.kind === 'file');
69
+ if (fileNodes.length === 0)
70
+ return null;
71
+ // Prefer exact path match on qualified_name
72
+ const exactMatch = fileNodes.find(n => n.qualifiedName === ref.referenceName || n.filePath === ref.referenceName);
73
+ if (exactMatch) {
74
+ return {
75
+ original: ref,
76
+ targetNodeId: exactMatch.id,
77
+ confidence: 0.95,
78
+ resolvedBy: 'file-path',
79
+ };
80
+ }
81
+ // Fall back to suffix match (e.g., ref="snippets/foo.liquid" matches
82
+ // "src/snippets/foo.liquid"). When several files share the basename — a
83
+ // `#include "RNCAsyncStorage.h"` with a same-named header on another platform
84
+ // (windows/code/ vs apple/) — prefer the one in the includer's own directory,
85
+ // then by directory proximity / same language family. A C/C++ include (and any
86
+ // bare-filename import) resolves relative to the including file, not to an
87
+ // arbitrary same-named header elsewhere in the tree.
88
+ const suffixMatches = fileNodes.filter(n => n.qualifiedName.endsWith(ref.referenceName) || n.filePath.endsWith(ref.referenceName));
89
+ if (suffixMatches.length > 0) {
90
+ return {
91
+ original: ref,
92
+ targetNodeId: pickClosestFileNode(suffixMatches, ref).id,
93
+ confidence: 0.85,
94
+ resolvedBy: 'file-path',
95
+ };
96
+ }
97
+ // If only one file node with this name, use it with lower confidence
98
+ if (fileNodes.length === 1) {
99
+ return {
100
+ original: ref,
101
+ targetNodeId: fileNodes[0].id,
102
+ confidence: 0.7,
103
+ resolvedBy: 'file-path',
104
+ };
105
+ }
106
+ return null;
107
+ }
108
+ /**
109
+ * Among several file nodes that all match a bare include/import by basename,
110
+ * pick the one closest to the referencing file: same directory first, then by
111
+ * directory-tree proximity, with the same language family as a tiebreak. A
112
+ * C/C++ `#include "X.h"` (and any bare-filename import) resolves relative to the
113
+ * including file — not to an arbitrary same-named header on another platform.
114
+ */
115
+ function pickClosestFileNode(candidates, ref) {
116
+ const dirOf = (p) => {
117
+ const i = p.lastIndexOf('/');
118
+ return i >= 0 ? p.slice(0, i) : '';
119
+ };
120
+ const refDir = dirOf(ref.filePath);
121
+ const sameDir = candidates.filter((c) => dirOf(c.filePath) === refDir);
122
+ const pool = sameDir.length > 0 ? sameDir : candidates;
123
+ let best = pool[0];
124
+ let bestScore = -Infinity;
125
+ for (const c of pool) {
126
+ const score = computePathProximity(ref.filePath, c.filePath) +
127
+ (sameLanguageFamily(c.language, ref.language) ? 5 : 0);
128
+ if (score > bestScore) {
129
+ bestScore = score;
130
+ best = c;
131
+ }
132
+ }
133
+ return best;
134
+ }
135
+ /**
136
+ * Language families that share a type system / runtime, so a same-language-only
137
+ * reference may still resolve across them (a Kotlin `Foo.BAR` can name a Java
138
+ * `Foo`). Anything not listed forms its own singleton family.
139
+ */
140
+ const LANGUAGE_FAMILY = {
141
+ java: 'jvm', kotlin: 'jvm', scala: 'jvm',
142
+ swift: 'apple', objc: 'apple',
143
+ // ArkTS is a TS superset — every HarmonyOS project mixes `.ets` UI with
144
+ // `.ts` logic modules, so refs must cross freely between them.
145
+ typescript: 'web', tsx: 'web', javascript: 'web', jsx: 'web', arkts: 'web',
146
+ c: 'c', cpp: 'c',
147
+ // Razor/Blazor markup names C# types — same family so `@model Foo` /
148
+ // `<MyComponent/>` resolve to their `.cs` class through the cross-family gate.
149
+ csharp: 'dotnet', razor: 'dotnet',
150
+ };
151
+ function sameLanguageFamily(a, b) {
152
+ if (a === b)
153
+ return true;
154
+ const fa = LANGUAGE_FAMILY[a];
155
+ return fa !== undefined && fa === LANGUAGE_FAMILY[b];
156
+ }
157
+ /**
158
+ * True when `lang` belongs to a known multi-language family (jvm/apple/web/c).
159
+ * Languages not listed (php, python, go, ruby, rust, dart, …) and config
160
+ * formats (yaml/xml/blade) form their own singleton families and return
161
+ * `false` — used to leave config↔code framework bridges (whose config side is
162
+ * never a known programming-language family) out of the cross-family gate.
163
+ */
164
+ function isKnownLanguageFamily(lang) {
165
+ return LANGUAGE_FAMILY[lang] !== undefined;
166
+ }
167
+ /**
168
+ * True when `a` and `b` are two DIFFERENT *known* language families — the
169
+ * signature of a coincidental cross-language name collision (a TS `import
170
+ * React` matching a Swift `import React`, a C++ `#include "X.h"` matching a
171
+ * same-named ObjC header on another platform). The both-*known* test is
172
+ * deliberately weaker than {@link sameLanguageFamily}'s negation: a
173
+ * single-file-component language that carries its own tag (`vue`/`svelte`)
174
+ * importing a `.ts` module, or any singleton-family language (php/go/ruby/…),
175
+ * returns `false` here and is left alone.
176
+ */
177
+ function crossesKnownFamily(a, b) {
178
+ return isKnownLanguageFamily(a) && isKnownLanguageFamily(b) && !sameLanguageFamily(a, b);
179
+ }
180
+ /**
181
+ * Drop cross-language candidates from a name lookup. Two regimes:
182
+ * - `references` (type-usage): a type named in language X resolves to a
183
+ * SAME-family type, never a coincidentally same-named symbol in another
184
+ * language (the Android `BatteryManager` system class vs a JS one). Strict
185
+ * same-family filter — cross-language communication is `calls`, not refs.
186
+ * - `imports` (import binding): an `import`/`#include` never crosses two
187
+ * KNOWN families (TS `import React` ↮ Swift `import React`). Weaker
188
+ * both-known filter so `.vue`/`.svelte` (own tag) importing `.ts` survives.
189
+ */
190
+ function applyLanguageGate(candidates, ref) {
191
+ if (ref.referenceKind === 'references' || ref.referenceKind === 'function_ref') {
192
+ return candidates.filter((c) => sameLanguageFamily(c.language, ref.language));
193
+ }
194
+ if (ref.referenceKind === 'imports') {
195
+ return candidates.filter((c) => !crossesKnownFamily(c.language, ref.language));
196
+ }
197
+ return candidates;
198
+ }
199
+ /**
200
+ * Resolve a function-as-value reference (#756) — a function name used as a
201
+ * callback/function-pointer value (`register(handler)`, `o->cb = handler`,
202
+ * `{ .cb = handler }`, `signal(SIGINT, handler)`). The ONLY strategy allowed
203
+ * for `function_ref` refs: exact name, function/method targets only, same
204
+ * language family, same-file first, and cross-file only when the match is
205
+ * UNIQUE. No fuzzy fallback, no qualified-name walking — a wrong callback
206
+ * edge is worse than none.
207
+ */
208
+ function matchFunctionRef(ref, context) {
209
+ // `this.<member>` refs are resolved ONLY by the class-scoped resolver in
210
+ // resolveOne (resolveThisMemberFnRef) — never by name matching here.
211
+ if (ref.referenceName.startsWith('this.'))
212
+ return null;
213
+ // In JS/TS/Python a bare identifier can never be a method value (methods
214
+ // are only reachable through a receiver — `this.m` / `self.m` /
215
+ // `Cls.m`), so bare fn-refs match FUNCTIONS only. This also sidesteps the
216
+ // pre-existing TS quirk of class fields extracting as method-kind nodes,
217
+ // which otherwise soaked up local names passed as arguments (excalidraw
218
+ // A/B finding; same pattern in vendored docopt.py). Python's `self.m`
219
+ // form keeps method targets via its own capture shape. C++ likewise: a
220
+ // bare identifier can only be a FREE function (member values need
221
+ // `&Cls::method`). PHP string callables name global FUNCTIONS (methods
222
+ // need the `[$obj, 'm']` array form, which carries its own shape). Other
223
+ // languages keep method targets: C# method groups, Swift/Dart
224
+ // implicit-self, Java/Kotlin method references.
225
+ const bareFnOnly = ref.language === 'typescript' || ref.language === 'tsx' ||
226
+ ref.language === 'javascript' || ref.language === 'jsx' ||
227
+ ref.language === 'arkts' ||
228
+ ref.language === 'cpp' || ref.language === 'python' ||
229
+ ref.language === 'php';
230
+ // Qualified member-pointer (`&Widget::on_click` → "Widget::on_click"):
231
+ // resolve the member ON THAT SCOPE — exempt from bareFnOnly (the `&Cls::m`
232
+ // shape is an explicit member reference). Unique-or-drop like everything else.
233
+ if (ref.referenceName.includes('::')) {
234
+ const memberName = ref.referenceName.slice(ref.referenceName.lastIndexOf('::') + 2);
235
+ const scoped = context
236
+ .getNodesByName(memberName)
237
+ .filter((n) => (n.kind === 'function' || n.kind === 'method') &&
238
+ sameLanguageFamily(n.language, ref.language) &&
239
+ n.id !== ref.fromNodeId &&
240
+ (n.qualifiedName === ref.referenceName ||
241
+ n.qualifiedName.endsWith(`::${ref.referenceName}`)));
242
+ if (scoped.length === 0)
243
+ return null;
244
+ const sameFileScoped = scoped.filter((n) => n.filePath === ref.filePath);
245
+ const pool = sameFileScoped.length > 0 ? sameFileScoped : scoped;
246
+ if (sameFileScoped.length === 0 && scoped.length > 1)
247
+ return null;
248
+ const target = pool.reduce((a, b) => (a.startLine <= b.startLine ? a : b));
249
+ return {
250
+ original: ref,
251
+ targetNodeId: target.id,
252
+ confidence: 0.9,
253
+ resolvedBy: 'function-ref',
254
+ };
255
+ }
256
+ let candidates = context
257
+ .getNodesByName(ref.referenceName)
258
+ .filter((n) => (n.kind === 'function' || (!bareFnOnly && n.kind === 'method')) &&
259
+ sameLanguageFamily(n.language, ref.language) &&
260
+ n.id !== ref.fromNodeId // a function registering itself is not a dependency edge
261
+ );
262
+ if (candidates.length === 0)
263
+ return null;
264
+ // Swift implicit-self: a bare identifier can name a METHOD only of the
265
+ // ENCLOSING type (`Button(action: handleTap)` written inside that type) —
266
+ // a same-named method on any OTHER class is a parameter collision
267
+ // (Alamofire: a `request` parameter resolving to EventMonitor::request).
268
+ // Scope method candidates to the from-symbol's type; top-level code has no
269
+ // implicit self, so method targets are excluded there entirely. Free
270
+ // functions are unaffected.
271
+ if (ref.language === 'swift' && candidates.some((n) => n.kind === 'method')) {
272
+ const fromNode = context.getNodeById?.(ref.fromNodeId);
273
+ const sep = fromNode ? fromNode.qualifiedName.lastIndexOf('::') : -1;
274
+ const classPrefix = fromNode && sep > 0 ? fromNode.qualifiedName.slice(0, sep) : null;
275
+ candidates = candidates.filter((n) => {
276
+ if (n.kind !== 'method')
277
+ return true;
278
+ if (!classPrefix)
279
+ return false;
280
+ const mSep = n.qualifiedName.lastIndexOf('::');
281
+ if (mSep <= 0)
282
+ return false;
283
+ const methodPrefix = n.qualifiedName.slice(0, mSep);
284
+ // Accept exact-scope matches plus suffix relationships either way, so
285
+ // extension-declared members (`Holder::m`) still match a nested
286
+ // from-scope (`Module::Holder::wire`) and vice versa.
287
+ return (methodPrefix === classPrefix ||
288
+ methodPrefix.endsWith(`::${classPrefix}`) ||
289
+ classPrefix.endsWith(`::${methodPrefix}`));
290
+ });
291
+ if (candidates.length === 0)
292
+ return null;
293
+ }
294
+ // Same-file definition wins — the extraction gate guarantees most survivors
295
+ // have one, and it's the dominant C pattern (static callback registered in
296
+ // a same-file ops struct).
297
+ const sameFile = candidates.filter((n) => n.filePath === ref.filePath);
298
+ if (sameFile.length > 0) {
299
+ // Swift: several same-named METHODS in one file is an API overload family
300
+ // (`Session.request(...)` × N), and a bare identifier hitting it is almost
301
+ // always a same-named parameter, not a method value (Alamofire A/B
302
+ // finding) — refuse rather than guess. A single method (SwiftUI's
303
+ // `action: handleTap`) still resolves.
304
+ if (ref.language === 'swift' &&
305
+ sameFile.length > 1 &&
306
+ sameFile.every((n) => n.kind === 'method')) {
307
+ return null;
308
+ }
309
+ // Same-name overloads in one file are the same conceptual symbol; pick
310
+ // the first by position for determinism.
311
+ const target = sameFile.reduce((a, b) => (a.startLine <= b.startLine ? a : b));
312
+ return {
313
+ original: ref,
314
+ targetNodeId: target.id,
315
+ confidence: sameFile.length === 1 ? 0.95 : 0.9,
316
+ resolvedBy: 'function-ref',
317
+ };
318
+ }
319
+ // Cross-file (imported names the import resolver didn't already claim):
320
+ // only an unambiguous match resolves.
321
+ if (candidates.length === 1) {
322
+ return {
323
+ original: ref,
324
+ targetNodeId: candidates[0].id,
325
+ confidence: 0.8,
326
+ resolvedBy: 'function-ref',
327
+ };
328
+ }
329
+ return null;
330
+ }
331
+ /**
332
+ * Try to resolve a reference by exact name match
333
+ */
334
+ function matchByExactName(ref, context) {
335
+ // `import`-kind nodes are import STATEMENTS, not definitions, so a reference
336
+ // resolving to a sibling file's `import` is a meaningless edge — the real
337
+ // import→definition resolution is the import resolver's job (resolveViaImport),
338
+ // never name-matching here. Excluding them also removes a quadratic blow-up:
339
+ // a ubiquitous package (`react`, `@superset-ui/core`, Python `logging`/`typing`)
340
+ // is re-declared as an `import` node in every file that imports it, so K
341
+ // unresolved import refs each scored K same-named import candidates through
342
+ // findBestMatch — O(K²) per package, the dominant cost of "Resolving refs" on
343
+ // large import-heavy (front-end + back-end) repos (#915).
344
+ const candidates = applyLanguageGate(context.getNodesByName(ref.referenceName), ref)
345
+ .filter((n) => n.kind !== 'import');
346
+ if (candidates.length === 0) {
347
+ return null;
348
+ }
349
+ // If only one match, use it — but penalize cross-language matches
350
+ if (candidates.length === 1) {
351
+ const isCrossLanguage = candidates[0].language !== ref.language;
352
+ return {
353
+ original: ref,
354
+ targetNodeId: candidates[0].id,
355
+ confidence: isCrossLanguage ? 0.5 : 0.9,
356
+ resolvedBy: 'exact-match',
357
+ };
358
+ }
359
+ // Ubiquitous-name ceiling (#999): above it, picking one target among K
360
+ // same-named defs by directory proximity is unreliable AND O(K) per ref — the
361
+ // quadratic behind the "Resolving refs" wedge on theme/SDK-vendoring repos.
362
+ // Decline; the precise strategies (qualified-name, import, class-name) already
363
+ // ran. Falls through to fuzzy, which itself only resolves a UNIQUE candidate.
364
+ if (candidates.length > AMBIGUOUS_NAME_CEILING) {
365
+ return null;
366
+ }
367
+ // Multiple matches - try to narrow down
368
+ const bestMatch = findBestMatch(ref, candidates, context);
369
+ if (bestMatch) {
370
+ // Lower confidence when the match is from a distant/unrelated module
371
+ const proximity = computePathProximity(ref.filePath, bestMatch.filePath);
372
+ const confidence = proximity >= 30 ? 0.7 : 0.4;
373
+ return {
374
+ original: ref,
375
+ targetNodeId: bestMatch.id,
376
+ confidence,
377
+ resolvedBy: 'exact-match',
378
+ };
379
+ }
380
+ return null;
381
+ }
382
+ /**
383
+ * Try to resolve by qualified name
384
+ */
385
+ function matchByQualifiedName(ref, context) {
386
+ // Check if the reference name looks qualified (contains :: or .)
387
+ if (!ref.referenceName.includes('::') && !ref.referenceName.includes('.')) {
388
+ return null;
389
+ }
390
+ // A method call `receiver.method()` can share an exact qualified name with a
391
+ // config-file key: `service.process()` (a `calls` ref named `service.process`)
392
+ // vs the yaml key `service.process`. Config keys are bound to their code refs
393
+ // upstream by the framework resolvers (`@Value` → `references`); a `calls` ref
394
+ // must never resolve to a yaml/properties config node — that's a wrong edge
395
+ // AND it hides the real callee. Drop those from both the exact and the partial
396
+ // candidate sets so resolution falls through to method resolution below (#1180).
397
+ const keepForRef = (nodes) => ref.referenceKind === 'calls'
398
+ ? nodes.filter((n) => !(n.kind === 'constant' && (n.language === 'yaml' || n.language === 'properties')))
399
+ : nodes;
400
+ const candidates = keepForRef(context.getNodesByQualifiedName(ref.referenceName));
401
+ if (candidates.length === 1) {
402
+ return {
403
+ original: ref,
404
+ targetNodeId: candidates[0].id,
405
+ confidence: 0.95,
406
+ resolvedBy: 'qualified-name',
407
+ };
408
+ }
409
+ // Several symbols share this exact qualified name (e.g. `Logger::log` declared
410
+ // in two files — an ODR clash or separate translation units): prefer the one
411
+ // in the call site's own file before the partial-match fallback below, else
412
+ // the first-indexed def wins and a call in `b/svc` targets `a/svc` (#1079).
413
+ if (candidates.length > 1) {
414
+ const ordered = preferCallSiteFile(candidates, ref.filePath);
415
+ if (ordered[0].filePath === ref.filePath) {
416
+ return {
417
+ original: ref,
418
+ targetNodeId: ordered[0].id,
419
+ confidence: 0.95,
420
+ resolvedBy: 'qualified-name',
421
+ };
422
+ }
423
+ }
424
+ // Try partial qualified name match — again preferring the call site's own
425
+ // file when more than one symbol's qualifiedName ends with the reference.
426
+ const parts = ref.referenceName.split(/[:.]/);
427
+ const lastName = parts[parts.length - 1];
428
+ if (lastName) {
429
+ const partialCandidates = keepForRef(context.getNodesByName(lastName))
430
+ .filter((candidate) => candidate.qualifiedName.endsWith(ref.referenceName));
431
+ const chosen = preferCallSiteFile(partialCandidates, ref.filePath)[0];
432
+ if (chosen) {
433
+ return {
434
+ original: ref,
435
+ targetNodeId: chosen.id,
436
+ confidence: 0.85,
437
+ resolvedBy: 'qualified-name',
438
+ };
439
+ }
440
+ }
441
+ return null;
442
+ }
443
+ /**
444
+ * When a symbol name is ambiguous across files, prefer the candidate(s) declared
445
+ * in the call site's own file, keeping the rest in their original order (#1079).
446
+ * A same-file definition is the strongest language-agnostic signal for which of
447
+ * several same-named symbols a call means; without it, resolution collapses onto
448
+ * whichever was indexed first, so a call in `b/svc` wrongly targets `a/svc`.
449
+ * No-op when there are <2 candidates or none share the call site's file.
450
+ */
451
+ function preferCallSiteFile(nodes, callSiteFile) {
452
+ if (nodes.length < 2)
453
+ return nodes;
454
+ const same = [];
455
+ const other = [];
456
+ for (const n of nodes) {
457
+ if (n.filePath === callSiteFile)
458
+ same.push(n);
459
+ else
460
+ other.push(n);
461
+ }
462
+ return same.length ? [...same, ...other] : nodes;
463
+ }
464
+ // Exported for the precedence unit tests (#1079): they assert the
465
+ // preferredFqn → same-file → matches[0] ordering directly.
466
+ function resolveMethodOnType(typeName, methodName, ref, context, confidence, resolvedBy,
467
+ /**
468
+ * Optional FQN that identifies WHICH class declaration `typeName`
469
+ * refers to in the caller's file. When multiple candidates share
470
+ * the same qualifiedName (`FooConverter::convert` in both
471
+ * `dao/converter/` and `service/converter/`), the FQN's
472
+ * file-path-suffix picks the right one — the disambiguation
473
+ * signal Java imports carry but the call site doesn't (#314).
474
+ */
475
+ preferredFqn,
476
+ /** Recursion guard for the supertype/conformance walk. */
477
+ depth = 0) {
478
+ // Look up methods by name and match by qualifiedName ending in
479
+ // `<typeName>::<methodName>`. This works whether the method is defined
480
+ // in-class (`class Foo { int bar() { ... } }`) or out-of-line in a separate
481
+ // file (`int Foo::bar() { ... }` in foo.cpp while class Foo is in foo.hpp).
482
+ // The previous same-file approach missed the latter — the typical C++ layout.
483
+ // Prefer the context's per-(type, method) memo: the raw name lookup fetches
484
+ // EVERY node sharing the method name — tens of thousands of rows for a
485
+ // collision-heavy Java name like `execute` — and re-filtering that per ref
486
+ // was a dominant term in the #1122 watchdog kill on large repos. Only the
487
+ // ref-independent filter is memoized; per-ref disambiguation stays below.
488
+ let matches;
489
+ if (context.getMethodMatches) {
490
+ matches = context.getMethodMatches(typeName, methodName, ref.language);
491
+ }
492
+ else {
493
+ const methodCandidates = context.getNodesByName(methodName);
494
+ const want = `${typeName}::${methodName}`;
495
+ matches = [];
496
+ for (const m of methodCandidates) {
497
+ if (m.kind !== 'method')
498
+ continue;
499
+ if (m.language !== ref.language)
500
+ continue;
501
+ const qn = m.qualifiedName;
502
+ if (qn === want || qn.endsWith(`::${want}`)) {
503
+ matches.push(m);
504
+ }
505
+ }
506
+ }
507
+ if (matches.length === 0) {
508
+ // Conformance fallback: the method may be defined on a supertype `typeName`
509
+ // extends, or on a protocol / trait it conforms to (e.g. a Swift protocol-
510
+ // extension method, a C# default-interface or extension method, a Kotlin
511
+ // extension on a supertype). Walk supertypes transitively (depth-capped) via
512
+ // the resolved implements/extends edges — empty in the first resolution pass,
513
+ // populated in the conformance pass. Still VALIDATED (the method must exist on
514
+ // a supertype), so a wrong inference produces no edge.
515
+ if (depth < 4 && context.getSupertypes) {
516
+ for (const supertype of context.getSupertypes(typeName, ref.language)) {
517
+ const via = resolveMethodOnType(supertype, methodName, ref, context, confidence, resolvedBy, preferredFqn, depth + 1);
518
+ if (via)
519
+ return via;
520
+ }
521
+ }
522
+ return null;
523
+ }
524
+ if (matches.length > 1 && preferredFqn) {
525
+ const ext = ref.language === 'kotlin' ? '.kt' : '.java';
526
+ const fqnPath = preferredFqn.replace(/\./g, '/') + ext;
527
+ const chosen = matches.find((m) => {
528
+ const fp = m.filePath.replace(/\\/g, '/');
529
+ return fp.endsWith(fqnPath) || fp.endsWith('/' + fqnPath);
530
+ });
531
+ if (chosen) {
532
+ return {
533
+ original: ref,
534
+ targetNodeId: chosen.id,
535
+ confidence,
536
+ resolvedBy,
537
+ };
538
+ }
539
+ }
540
+ // Language-agnostic disambiguation: when several same-named methods survive
541
+ // (e.g. two files each declaring `class Logger { void log(); }` — an ODR
542
+ // clash, an anonymous-namespace type, or separate translation units), prefer
543
+ // the definition in the CALL SITE's own file. Without this, every ambiguous
544
+ // call collapses onto the first-indexed definition, so a call in `b/svc.cpp`
545
+ // wrongly points at `a/svc.cpp` (#1079). This runs AFTER the `preferredFqn`
546
+ // block, so Java/Kotlin import disambiguation — whose target is intentionally
547
+ // in ANOTHER file (#314) — is unaffected: that block returns early whenever
548
+ // an import FQN pins the class.
549
+ const ordered = preferCallSiteFile(matches, ref.filePath);
550
+ return {
551
+ original: ref,
552
+ targetNodeId: ordered[0].id,
553
+ confidence,
554
+ resolvedBy,
555
+ };
556
+ }
557
+ // C++ keywords/control-flow tokens that can appear right before a receiver
558
+ // (e.g. `return ptr->m()`) and must NOT be treated as a type.
559
+ const CPP_NON_TYPE_TOKENS = new Set([
560
+ 'return', 'if', 'else', 'for', 'while', 'do', 'switch', 'case', 'default',
561
+ 'break', 'continue', 'goto', 'throw', 'new', 'delete', 'co_await', 'co_yield',
562
+ 'co_return', 'static_cast', 'const_cast', 'dynamic_cast', 'reinterpret_cast',
563
+ 'sizeof', 'alignof', 'typeid', 'and', 'or', 'not', 'xor',
564
+ ]);
565
+ function normalizeCppTypeName(typeName) {
566
+ const normalized = typeName
567
+ .replace(/\b(const|volatile|mutable|typename|class|struct)\b/g, ' ')
568
+ .replace(/[&*]+/g, ' ')
569
+ .replace(/<[^>]*>/g, ' ')
570
+ .replace(/\s+/g, ' ')
571
+ .trim();
572
+ if (!normalized)
573
+ return null;
574
+ const parts = normalized.split(/::/).filter(Boolean);
575
+ const last = parts[parts.length - 1];
576
+ if (!last)
577
+ return null;
578
+ if (CPP_NON_TYPE_TOKENS.has(last))
579
+ return null;
580
+ return last;
581
+ }
582
+ // Declarator regex: matches `Type receiver`, `Type* receiver`, `Type *receiver`,
583
+ // `Type*receiver`, `Type<X> receiver`, etc., REQUIRING a declarator terminator
584
+ // (`;`, `=`, `,`, `)`, `[`, `{`, `(`, or end-of-line) after the receiver. The
585
+ // terminator rules out uses like `return receiver->m()` where the preceding
586
+ // token is a keyword, not a type.
587
+ function buildDeclaratorRegex(escapedReceiver) {
588
+ return new RegExp(`([A-Za-z_][\\w:]*(?:\\s*<[^;=(){}]+>)?(?:\\s*[*&]+)?)\\s*\\b${escapedReceiver}\\b\\s*(?=[;=,)\\[{(]|$)`);
589
+ }
590
+ function inferCppReceiverType(receiverName, ref, context, depth = 0) {
591
+ // Per-file lines cache when available — this runs per `receiver->method()`
592
+ // ref and re-splitting the file each time is the same quadratic as the
593
+ // shared inferrer's (#1122).
594
+ const lines = context.getFileLines
595
+ ? context.getFileLines(ref.filePath)
596
+ : (context.readFile(ref.filePath)?.split(/\r?\n/) ?? null);
597
+ if (!lines || lines.length === 0)
598
+ return null;
599
+ const callLineIndex = Math.max(0, Math.min(lines.length - 1, ref.line - 1));
600
+ const escapedReceiver = receiverName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
601
+ const receiverPattern = new RegExp(`\\b${escapedReceiver}\\b`);
602
+ const declaratorRegex = buildDeclaratorRegex(escapedReceiver);
603
+ for (let i = callLineIndex; i >= 0; i--) {
604
+ const line = lines[i];
605
+ if (!line || !receiverPattern.test(line))
606
+ continue;
607
+ const declaratorMatch = line.match(declaratorRegex);
608
+ if (declaratorMatch) {
609
+ const normalized = normalizeCppTypeName(declaratorMatch[1] ?? '');
610
+ if (normalized === 'auto') {
611
+ // `auto x = Foo::instance();` — the declared type is deduced; recover it
612
+ // from the initializer (call return type / construction) (#645).
613
+ const initType = inferCppAutoInitializerType(line, receiverName, ref, context, depth);
614
+ if (initType)
615
+ return initType;
616
+ // No usable initializer on this line — keep scanning earlier ones.
617
+ }
618
+ else if (normalized) {
619
+ return normalized;
620
+ }
621
+ }
622
+ }
623
+ const headerCandidates = [
624
+ ref.filePath.replace(/\.(?:c|cc|cpp|cxx)$/i, '.h'),
625
+ ref.filePath.replace(/\.(?:c|cc|cpp|cxx)$/i, '.hpp'),
626
+ ref.filePath.replace(/\.(?:c|cc|cpp|cxx)$/i, '.hxx'),
627
+ ].filter((candidate, index, arr) => arr.indexOf(candidate) === index && candidate !== ref.filePath);
628
+ for (const headerPath of headerCandidates) {
629
+ if (!context.fileExists(headerPath))
630
+ continue;
631
+ const headerLines = context.getFileLines
632
+ ? context.getFileLines(headerPath)
633
+ : (context.readFile(headerPath)?.split(/\r?\n/) ?? null);
634
+ if (!headerLines)
635
+ continue;
636
+ for (const line of headerLines) {
637
+ if (!receiverPattern.test(line))
638
+ continue;
639
+ const declaratorMatch = line.match(declaratorRegex);
640
+ if (!declaratorMatch)
641
+ continue;
642
+ const normalized = normalizeCppTypeName(declaratorMatch[1] ?? '');
643
+ if (normalized && normalized !== 'auto')
644
+ return normalized;
645
+ }
646
+ }
647
+ return null;
648
+ }
649
+ /**
650
+ * Last `::`-separated segment of a (possibly namespace-qualified) C++ name.
651
+ */
652
+ function cppLastSegment(name) {
653
+ const parts = name.split('::').filter(Boolean);
654
+ return parts[parts.length - 1] ?? name;
655
+ }
656
+ /**
657
+ * Return type captured at extraction for `Class::method` (or a free function),
658
+ * read off the indexed node's `returnType` — used by the C++ (#645) and PHP
659
+ * (#608) chained-call resolvers. Language-filtered. Null when not indexed or no
660
+ * return type was recorded (a `void`/primitive return).
661
+ */
662
+ function lookupCalleeReturnType(callee, ref, context) {
663
+ let method = callee;
664
+ let cls = null;
665
+ if (callee.includes('::')) {
666
+ const parts = callee.split('::').filter(Boolean);
667
+ method = parts[parts.length - 1] ?? callee;
668
+ cls = parts.slice(0, -1).join('::');
669
+ }
670
+ const candidates = context.getNodesByName(method).filter((n) => (n.kind === 'method' || n.kind === 'function') &&
671
+ n.language === ref.language &&
672
+ !!n.returnType);
673
+ if (cls) {
674
+ const want = `${cls}::${method}`;
675
+ // The call site may name the class with MORE namespace qualification than
676
+ // the stored node (`details::registry::instance` at the call vs
677
+ // `registry::instance` on the node — the receiver type only carries the
678
+ // immediate class), or LESS. Accept an exact match or either being a
679
+ // namespace-suffix of the other; the shared `::<class>::<method>` tail keeps
680
+ // it specific.
681
+ const m = candidates.find((n) => n.qualifiedName === want ||
682
+ n.qualifiedName.endsWith(`::${want}`) ||
683
+ want.endsWith(`::${n.qualifiedName}`));
684
+ return m?.returnType ?? null;
685
+ }
686
+ return candidates.find((n) => n.kind === 'function')?.returnType ?? null;
687
+ }
688
+ /** Does the graph contain a class/struct named `name`'s last segment? */
689
+ function cppClassExists(name, ref, context) {
690
+ const last = cppLastSegment(name);
691
+ return context
692
+ .getNodesByName(last)
693
+ .some((n) => (n.kind === 'class' || n.kind === 'struct') && n.language === ref.language);
694
+ }
695
+ /**
696
+ * Infer the class produced by a C++ call/construction expression, using return
697
+ * types captured at extraction (#645). Handles, in order:
698
+ * - `make_unique<T>()` / `make_shared<T>()` → T
699
+ * - single-level member call `recv.method()` → recv's type, then method's return
700
+ * - `Class::method()` / free `func()` → the callee's recorded return type
701
+ * - direct construction `Type()` / `ns::Type()` → Type
702
+ * Returns null when undeterminable. Callers MUST still validate the outer method
703
+ * exists on the result before creating an edge, so a wrong guess stays silent.
704
+ */
705
+ function resolveCppCallResultType(inner, ref, context, depth = 0) {
706
+ if (depth > 3)
707
+ return null; // guard against pathological mutual recursion
708
+ const expr = inner.trim();
709
+ const make = expr.match(/(?:^|::)(?:make_unique|make_shared)\s*<\s*([A-Za-z_]\w*)/);
710
+ if (make)
711
+ return make[1] ?? null;
712
+ // Single-level member call `recv.method` (the `manager.view().render()` shape).
713
+ const dotIdx = expr.lastIndexOf('.');
714
+ if (dotIdx > 0) {
715
+ const recv = expr.slice(0, dotIdx);
716
+ const method = expr.slice(dotIdx + 1);
717
+ if (recv.includes('.') || recv.includes('(') || recv.includes('::'))
718
+ return null; // single level only
719
+ const recvType = inferCppReceiverType(recv, ref, context, depth + 1);
720
+ if (!recvType)
721
+ return null;
722
+ return lookupCalleeReturnType(`${recvType}::${method}`, ref, context);
723
+ }
724
+ const ret = lookupCalleeReturnType(expr, ref, context);
725
+ if (ret)
726
+ return ret;
727
+ // Direct construction — the callee itself names a class/struct.
728
+ if (cppClassExists(expr, ref, context))
729
+ return cppLastSegment(expr);
730
+ return null;
731
+ }
732
+ /**
733
+ * Recover the type of an `auto`-declared local from its initializer on the
734
+ * declaration line — `auto x = Foo::instance();`, `auto w = make_unique<W>();`,
735
+ * `auto p = new W();`, `auto w = Widget();` (#645).
736
+ */
737
+ function inferCppAutoInitializerType(line, receiverName, ref, context, depth) {
738
+ const escaped = receiverName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
739
+ const m = line.match(new RegExp(`\\b${escaped}\\b\\s*=\\s*([^;]+)`));
740
+ if (!m || !m[1])
741
+ return null;
742
+ const init = m[1].trim();
743
+ const neu = init.match(/^new\s+([A-Za-z_][\w:]*)/);
744
+ if (neu && neu[1])
745
+ return cppLastSegment(neu[1]);
746
+ // A call or construction: `Foo(...)`, `A::b(...)`, `make_unique<T>(...)`.
747
+ const call = init.match(/^([A-Za-z_][\w:]*(?:\s*<[^>;]*>)?)\s*\(/);
748
+ if (call && call[1])
749
+ return resolveCppCallResultType(call[1].replace(/\s+/g, ''), ref, context, depth + 1);
750
+ return null;
751
+ }
752
+ /**
753
+ * Resolve a C++ chained call whose receiver is itself a call — encoded by the
754
+ * extractor as `<innerCallee>().<method>` (#645). The receiver's type is what
755
+ * the inner call returns; the outer method is then resolved and VALIDATED on it
756
+ * (resolveMethodOnType requires `cls::method` to exist), so a wrong inference
757
+ * produces no edge rather than a wrong one.
758
+ */
759
+ function matchCppCallChain(ref, context) {
760
+ const m = ref.referenceName.match(/^(.+)\(\)\.(\w+)$/);
761
+ if (!m || !m[1] || !m[2])
762
+ return null;
763
+ const cls = resolveCppCallResultType(m[1], ref, context);
764
+ if (!cls)
765
+ return null;
766
+ return resolveMethodOnType(cls, m[2], ref, context, 0.85, 'instance-method');
767
+ }
768
+ /**
769
+ * Resolve a `::`-scoped factory chain whose receiver is a scoped/static call —
770
+ * PHP `Cls::for($x)->method()` (#608, the per-credential Laravel client idiom) or
771
+ * Rust `Foo::new().bar()` (an associated-function call) — both encoded by the
772
+ * extractor as `Cls::factory().method`. The receiver's type is what `Cls::factory`
773
+ * returns: a `self` marker (PHP `: self`/`: static`, Rust `-> Self`) resolves to
774
+ * the factory's own type, a concrete return type to that type. The outer method is
775
+ * then resolved and VALIDATED on it (resolveMethodOnType requires the method to
776
+ * exist on the type or a supertype it conforms to), so a wrong inference yields no
777
+ * edge rather than a wrong one. Shared by the `::`-receiver languages (PHP, Rust).
778
+ */
779
+ function matchScopedCallChain(ref, context) {
780
+ const m = ref.referenceName.match(/^(.+)\(\)\.(\w+)$/);
781
+ if (!m || !m[1] || !m[2])
782
+ return null;
783
+ const inner = m[1];
784
+ const method = m[2];
785
+ if (!inner.includes('::'))
786
+ return null; // only static-factory (`Cls::method`) chains
787
+ const factoryClass = inner.slice(0, inner.lastIndexOf('::'));
788
+ const ret = lookupCalleeReturnType(inner, ref, context);
789
+ if (!ret)
790
+ return null;
791
+ // `self` (the extractor's marker for self/static/$this) → the factory's class.
792
+ const resolvedClass = ret === 'self' ? factoryClass : ret;
793
+ return resolveMethodOnType(resolvedClass, method, ref, context, 0.85, 'instance-method');
794
+ }
795
+ /**
796
+ * Languages where an unprefixed capitalized call `Foo(args)` constructs the
797
+ * class (so a `Foo(args).method()` receiver's type is `Foo`). Java/C# need `new`,
798
+ * so a bare `Foo()` there is a method call, not construction — excluded. Scala's
799
+ * `Foo(args)` is a case-class / companion `apply`, which conventionally returns
800
+ * `Foo` — and resolveMethodOnType validates, so a non-conventional `apply` that
801
+ * returns another type simply yields no edge rather than a wrong one. Pascal/Delphi:
802
+ * a `TFoo(x)` is a TYPECAST whose result is a `TFoo`, so `TFoo(x).method()` resolves
803
+ * the method on `TFoo` — same shape, same validation.
804
+ */
805
+ const CONSTRUCTS_VIA_BARE_CALL = new Set(['kotlin', 'swift', 'scala', 'dart', 'pascal']);
806
+ /**
807
+ * Resolve a dotted chained call whose receiver is a static factory / fluent call —
808
+ * `Foo.getInstance().bar()`, encoded by the extractor as `Foo.getInstance().bar`
809
+ * (#645/#608 mechanism). The receiver's type is what `Foo.getInstance` returns
810
+ * (its declared return type); the outer method is then resolved and VALIDATED on
811
+ * it (resolveMethodOnType requires `Type::method` to exist), so a wrong inference
812
+ * yields no edge rather than a wrong one (e.g. a same-named `bar()` on an
813
+ * unrelated class is never matched). Shared by the dot-notation languages
814
+ * (Java, Kotlin, C#, Swift) — same receiver shape, same `Class::method` qualified names.
815
+ */
816
+ function matchDottedCallChain(ref, context) {
817
+ const m = ref.referenceName.match(/^(.+)\(\)\.(\w+)$/);
818
+ if (!m || !m[1] || !m[2])
819
+ return null;
820
+ const inner = m[1]; // `Foo.getInstance`
821
+ const method = m[2]; // `bar`
822
+ const lastDot = inner.lastIndexOf('.');
823
+ if (lastDot <= 0) {
824
+ // Go: bare package-level factory FUNCTION `New().method()` — the receiver's
825
+ // type is what `New` returns; resolve the method on that.
826
+ if (ref.language === 'go') {
827
+ const ret = lookupCalleeReturnType(inner, ref, context);
828
+ if (ret) {
829
+ return resolveMethodOnType(ret, method, ref, context, 0.85, 'instance-method', importedFqnOf(ret, ref, context));
830
+ }
831
+ // `inner` isn't a function with a captured return type — typically a
832
+ // package-level VARIABLE holding a function value (e.g. gin's `engine()`),
833
+ // whose type we can't recover. Fall back to bare-name resolution of the
834
+ // method so we don't DROP an edge the un-re-encoded bare path would have
835
+ // found. (When `inner` IS a real factory function but the method doesn't
836
+ // exist on its return type, `ret` is truthy and we returned no edge above —
837
+ // the absent-method safety guarantee is preserved.)
838
+ //
839
+ // CRITICAL: resolve the TARGET via a synthetic bare-name ref, but return the
840
+ // match tied to the ORIGINAL `ref` (referenceName `inner().method`). The
841
+ // batched resolver (resolveAndPersistBatched) reads unresolved rows from
842
+ // offset 0 every pass and relies on deleteSpecificResolvedReferences —
843
+ // keyed on referenceName — to clear each resolved row so the batch empties.
844
+ // If we propagated the synthetic ref's bare `method` as `.original`, the
845
+ // delete would never match the stored `inner().method` row, the batch would
846
+ // never drain, and the loop would re-resolve + re-insert forever (a runaway
847
+ // that grew gin's graph to 5M edges / 1.4 GB before this fix).
848
+ const bareRef = { ...ref, referenceName: method };
849
+ const bareMatch = matchByExactName(bareRef, context) ?? matchFuzzy(bareRef, context);
850
+ return bareMatch ? { ...bareMatch, original: ref } : null;
851
+ }
852
+ // Constructor receiver `Foo(args).method()` (encoded `Foo().method`): a bare,
853
+ // capitalized inner is a class construction, so the receiver's type is the
854
+ // class itself — resolve the method on it. Only in languages where an
855
+ // unprefixed capitalized call constructs the class (Kotlin, Swift); in Java/C#
856
+ // a bare `Foo()` is a method call (constructors need `new`), so we must not
857
+ // assume construction. A lowercase bare inner is a top-level `factory().method()`
858
+ // whose type we can't recover — bail.
859
+ if (!CONSTRUCTS_VIA_BARE_CALL.has(ref.language) || !/^[A-Z]/.test(inner))
860
+ return null;
861
+ return resolveMethodOnType(inner, method, ref, context, 0.85, 'instance-method', importedFqnOf(inner, ref, context));
862
+ }
863
+ // Factory/fluent receiver `Receiver.factory(args).method()`: the receiver's
864
+ // type is what `Receiver.factory` returns (its declared return type).
865
+ const factoryClass = inner.slice(0, lastDot).split('.').pop(); // simple class name
866
+ const factoryMethod = inner.slice(lastDot + 1);
867
+ if (!factoryClass || !factoryMethod)
868
+ return null;
869
+ const ret = lookupCalleeReturnType(`${factoryClass}::${factoryMethod}`, ref, context);
870
+ if (!ret) {
871
+ // Objective-C: a class-message factory — `[X alloc]`, `[X new]`,
872
+ // `[X sharedFoo]` — returns an instance of the RECEIVER class `X` by
873
+ // convention (`instancetype`). So when the factory's own return type isn't
874
+ // recoverable (its selector returns `instancetype`, or `alloc`/`new` aren't
875
+ // user-defined nodes at all), the receiver's type is the class `X` itself.
876
+ // This resolves the ubiquitous `[[X alloc] init]` and singleton chains.
877
+ // resolveMethodOnType validates against X (and its supertypes), so a class
878
+ // whose method actually lives elsewhere yields NO edge, not a wrong one — and
879
+ // crucially this does NOT fire when a concrete return type WAS captured but
880
+ // simply lacks the method (that already returned null above: absent-method
881
+ // safety, so a same-named decoy is still never matched).
882
+ if (ref.language === 'objc' && /^[A-Z]/.test(factoryClass)) {
883
+ return resolveMethodOnType(factoryClass, method, ref, context, 0.8, 'instance-method', importedFqnOf(factoryClass, ref, context));
884
+ }
885
+ // Pascal/Delphi: the extractor only re-encodes a `TFoo`/`IFoo`-prefixed chain
886
+ // (the type-naming convention), so `factoryClass` is always a real class here.
887
+ // A factory whose return type wasn't captured is a CONSTRUCTOR
888
+ // (`TFileMem.Create().SetCachePerformance` — `constructor Create` has no `:
889
+ // TBar` annotation but returns its own class) or an unannotated function. In
890
+ // both cases the receiver's type is the class itself, so resolve the method on
891
+ // `factoryClass`. resolveMethodOnType validates against it (and its
892
+ // supertypes), so a wrong inference yields no edge — and this never fires when
893
+ // a return type WAS captured but lacks the method (absent-method safety above).
894
+ if (ref.language === 'pascal' && /^[TI]/.test(factoryClass)) {
895
+ return resolveMethodOnType(factoryClass, method, ref, context, 0.8, 'instance-method', importedFqnOf(factoryClass, ref, context));
896
+ }
897
+ return null;
898
+ }
899
+ return resolveMethodOnType(ret, method, ref, context, 0.85, 'instance-method', importedFqnOf(ret, ref, context));
900
+ }
901
+ /**
902
+ * When several classes share a simple type name, the caller file's import of
903
+ * that type is the only signal that names WHICH one (#314). Returns the imported
904
+ * FQN for `typeName` in the ref's file, or undefined.
905
+ */
906
+ function importedFqnOf(typeName, ref, context) {
907
+ const imports = context.getImportMappings(ref.filePath, ref.language);
908
+ return imports.find((i) => i.localName === typeName)?.source;
909
+ }
910
+ /**
911
+ * Java/Kotlin: infer a receiver's declared type by walking field declarations
912
+ * in the class enclosing the call site. The field's `signature` is already in
913
+ * the form "<TypeName> <fieldName>" (set by tree-sitter.ts extractField), so we
914
+ * pull the type from there. Handles Spring `@Resource UserBO userbo;` /
915
+ * `@Autowired private UserService userService;` where the receiver field name
916
+ * doesn't match the class name by Java naming convention.
917
+ *
918
+ * Returns the bare type name (generics stripped, dotted package stripped) or
919
+ * null when no matching field is in the enclosing class.
920
+ */
921
+ function inferJavaFieldReceiverType(receiverName, ref, context) {
922
+ const inFile = context.getNodesInFile(ref.filePath);
923
+ if (inFile.length === 0)
924
+ return null;
925
+ // Find the class enclosing the call line (tightest match by latest start).
926
+ let enclosing = null;
927
+ for (const n of inFile) {
928
+ if (n.kind !== 'class' && n.kind !== 'interface')
929
+ continue;
930
+ if (n.language !== ref.language)
931
+ continue;
932
+ const end = n.endLine ?? n.startLine;
933
+ if (n.startLine <= ref.line && end >= ref.line) {
934
+ if (!enclosing || n.startLine >= enclosing.startLine)
935
+ enclosing = n;
936
+ }
937
+ }
938
+ if (!enclosing)
939
+ return null;
940
+ const enclosingEnd = enclosing.endLine ?? enclosing.startLine;
941
+ const field = inFile.find((n) => n.kind === 'field' &&
942
+ n.name === receiverName &&
943
+ n.language === ref.language &&
944
+ n.startLine >= enclosing.startLine &&
945
+ (n.endLine ?? n.startLine) <= enclosingEnd);
946
+ if (!field || !field.signature)
947
+ return null;
948
+ // Signature shape: "<TypeName> <fieldName>" (extractField). Pull the type,
949
+ // strip generics + dotted package, drop array/varargs markers.
950
+ const beforeName = field.signature.slice(0, field.signature.lastIndexOf(field.name));
951
+ const typeRaw = beforeName.trim();
952
+ if (!typeRaw)
953
+ return null;
954
+ const typeNoGenerics = typeRaw.replace(/<[^>]*>/g, '').trim();
955
+ const typeNoArray = typeNoGenerics.replace(/\[\s*\]/g, '').replace(/\.\.\.$/, '').trim();
956
+ const parts = typeNoArray.split(/[.\s]+/).filter(Boolean);
957
+ const lastPart = parts[parts.length - 1];
958
+ if (!lastPart)
959
+ return null;
960
+ if (!/^[A-Z]/.test(lastPart))
961
+ return null; // primitives / lowercase → skip
962
+ return lastPart;
963
+ }
964
+ // ── Local-variable receiver-type inference (#1108) ──────────────────────────
965
+ //
966
+ // Instance calls through a local variable (`const lg = new Logger(); lg.log()`)
967
+ // only resolved in C++ before this — no other language could learn the
968
+ // receiver's type. Local variables are not indexed as nodes (node-explosion),
969
+ // so, like the C++ inferrer above, we read the enclosing function's source and
970
+ // match the receiver's declaration/initializer to recover its type. The type is
971
+ // then handed to resolveMethodOnType, which VALIDATES that the type actually
972
+ // declares the method, so a mis-inference produces NO edge — the safety net
973
+ // that lets the patterns below stay simple. C++ keeps its dedicated inferrer
974
+ // (header scan + `auto`); this covers every other language.
975
+ // Tokens a loose pattern might capture that are never a user-defined type.
976
+ const NON_TYPE_RECEIVER_TOKENS = new Set([
977
+ 'this', 'self', 'super', 'new', 'return', 'await', 'yield', 'typeof',
978
+ 'null', 'nil', 'None', 'true', 'false', 'True', 'False', 'undefined',
979
+ ]);
980
+ /**
981
+ * Normalize a captured type expression to a simple type name: drop generic
982
+ * args and pointer/ref markers, take the last `.`/`::`-qualified segment, and
983
+ * reject obvious non-types.
984
+ */
985
+ function normalizeInferredTypeName(raw) {
986
+ const cleaned = raw.replace(/<[^>]*>/g, '').replace(/[&*]/g, '').trim();
987
+ const seg = cleaned.split(/[.:]+/).filter(Boolean).pop();
988
+ if (!seg)
989
+ return null;
990
+ if (NON_TYPE_RECEIVER_TOKENS.has(seg))
991
+ return null;
992
+ return seg;
993
+ }
994
+ /**
995
+ * Per-language patterns that recover a local variable's (or typed parameter's)
996
+ * type from its declaration/initializer. Each regex captures the type in group
997
+ * 1; `r` is the already-escaped receiver name. Ordered most-specific first.
998
+ * PascalCase is required in the capture where the language convention allows,
999
+ * as a cheap false-positive guard on top of resolveMethodOnType's validation.
1000
+ */
1001
+ function localReceiverTypePatterns(language, r) {
1002
+ switch (language) {
1003
+ case 'typescript':
1004
+ case 'javascript':
1005
+ case 'tsx':
1006
+ case 'jsx':
1007
+ case 'arkts':
1008
+ return [
1009
+ new RegExp(`\\b${r}\\b\\s*=\\s*new\\s+([A-Za-z_$][\\w.$]*)`), // = new Logger()
1010
+ // No keyword requirement, so this matches BOTH a local annotation
1011
+ // (`const lg: Logger`) and a typed parameter (`function use(lg: Logger)`
1012
+ // / `(lg: Logger) =>`) — the parameter case the old `const|let|var`
1013
+ // prefix excluded (#1125). Mirrors Kotlin/Swift/Scala; the capture stops
1014
+ // at `<` so a generic-typed param (`repo: Repository<User>`) still yields
1015
+ // `Repository`. resolveMethodOnType validates the type actually declares
1016
+ // the method, so the looser match produces no edge on a mis-inference.
1017
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.$]*)`), // lg: Logger (annotation or typed param)
1018
+ ];
1019
+ case 'python':
1020
+ return [
1021
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // lg = Logger(...)
1022
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // lg: Logger (PEP 526)
1023
+ ];
1024
+ case 'java':
1025
+ return [
1026
+ new RegExp(`\\b${r}\\b\\s*=\\s*new\\s+([A-Za-z_][\\w.]*)`), // = new Logger()
1027
+ new RegExp(`\\b([A-Z][\\w.]*)\\s+${r}\\b\\s*[=;,)]`), // Logger lg; / param
1028
+ ];
1029
+ case 'kotlin':
1030
+ return [
1031
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // val lg = Logger(...)
1032
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // val lg: Logger / param
1033
+ ];
1034
+ case 'csharp':
1035
+ return [
1036
+ new RegExp(`\\b${r}\\b\\s*=\\s*new\\s+([A-Za-z_][\\w.]*)`), // = new Logger()
1037
+ new RegExp(`\\b([A-Z][\\w.]*)\\s+${r}\\b\\s*[=;,)]`), // Logger lg; / param
1038
+ ];
1039
+ case 'swift':
1040
+ return [
1041
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // let lg = Logger(...)
1042
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // let lg: Logger / param
1043
+ ];
1044
+ case 'rust':
1045
+ return [
1046
+ new RegExp(`\\blet\\s+(?:mut\\s+)?${r}\\b(?:\\s*:[^=]+)?=\\s*&?(?:mut\\s+)?([A-Z][\\w]*)`), // let lg = Logger::new()/Logger{}/Logger
1047
+ // No `let`, so this covers a `let lg: Logger` binding AND a typed
1048
+ // parameter (`fn use(lg: &Logger)`, a closure `|lg: Logger|`) — the
1049
+ // parameter case the old `let`-anchored pattern excluded (#1125).
1050
+ new RegExp(`\\b${r}\\s*:\\s*&?(?:mut\\s+)?([A-Z][\\w]*)`), // lg: Logger (binding or typed param)
1051
+ ];
1052
+ case 'go':
1053
+ return [
1054
+ new RegExp(`\\b${r}\\b\\s*:=\\s*&?([A-Za-z_][\\w.]*)\\s*{`), // lg := Logger{} / &Logger{}
1055
+ new RegExp(`\\bvar\\s+${r}\\s+\\*?([A-Za-z_][\\w.]*)`), // var lg Logger / *Logger
1056
+ // A typed parameter / method receiver (`func use(lg Logger)`,
1057
+ // `func (l Logger) M()`) — name-before-type with no `var`/`:=` (#1125).
1058
+ // PascalCase-guarded (unlike the anchored patterns above) to keep the
1059
+ // keyword-free `ident Type` shape from matching unrelated pairs; the
1060
+ // enclosing-scope bound already excludes package-level struct fields.
1061
+ new RegExp(`\\b${r}\\s+\\*?([A-Z][\\w.]*)`), // func use(lg Logger) / (l Logger)
1062
+ ];
1063
+ case 'ruby':
1064
+ return [
1065
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w:]*)\\.new\\b`), // lg = Logger.new
1066
+ ];
1067
+ case 'scala':
1068
+ return [
1069
+ new RegExp(`\\b${r}\\b\\s*=\\s*(?:new\\s+)?([A-Z][\\w.]*)`), // val lg = new Logger / Logger(...)
1070
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // val lg: Logger / param
1071
+ ];
1072
+ case 'dart':
1073
+ return [
1074
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // var lg = Logger(...)
1075
+ // Trailing `[=;,)]` (not just `[=;]`) so a typed parameter — `Logger lg)`
1076
+ // / `Logger lg,` — matches too, not only `Logger lg = ...` / `Logger lg;`
1077
+ // (#1125). Mirrors Java/C#.
1078
+ new RegExp(`\\b([A-Z][\\w.]*)\\s+${r}\\b\\s*[=;,)]`), // Logger lg = ... / param
1079
+ ];
1080
+ case 'php':
1081
+ return [
1082
+ new RegExp(`\\$?${r}\\b\\s*=\\s*new\\s+([A-Za-z_\\\\][\\w\\\\]*)`), // $lg = new Logger()
1083
+ // A typed parameter (`function use(Logger $lg)`, `?Logger $lg`,
1084
+ // `\\App\\Logger $lg`, `&$lg` by-ref) and a typed `catch (E $e)` — the
1085
+ // type sits before the `$`-variable (#1125). Namespace `\\` allowed.
1086
+ new RegExp(`\\b([A-Za-z_\\\\][\\w\\\\]*)\\s+&?\\$${r}\\b`), // Logger $lg (typed param)
1087
+ ];
1088
+ case 'lua':
1089
+ case 'luau':
1090
+ return [
1091
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w]*)\\.new\\b`), // local lg = Logger.new()
1092
+ new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w]*)\\s*\\(`), // local lg = Logger(...) (callable table)
1093
+ // Luau annotation (`local lg: Logger`) / typed param — but Lua's
1094
+ // method-call syntax is the IDENTICAL `receiver:Name` shape, and the
1095
+ // backward scan starts on the call's own line, so without a gate any
1096
+ // PascalCase method call (`lg:Log()`, the Roblox convention)
1097
+ // self-matches as "type = Log" before the scan reaches the real
1098
+ // declaration (#1124). The lookahead rejects a capture followed by
1099
+ // any of Lua's three call forms — `(args)`, `"s"`/`'s'`/`[[s]]`,
1100
+ // `{t}` — and its leading `[\w.]` alternative stops backtracking from
1101
+ // shrinking the capture to dodge the gate (`lg:Log()` would otherwise
1102
+ // still match, as `Lo`).
1103
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)(?![\\w.]|\\s*[({"'\\[])`), // local lg: Logger / typed param
1104
+ ];
1105
+ case 'r':
1106
+ return [
1107
+ new RegExp(`\\b${r}\\b\\s*(?:<-|<<-|=)\\s*([A-Z][\\w.]*)\\$new\\b`), // lg <- Logger$new() (R6)
1108
+ ];
1109
+ case 'pascal':
1110
+ return [
1111
+ new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w]*)`), // var lg: TLogger / param lg: TLogger
1112
+ new RegExp(`\\b${r}\\b\\s*:=\\s*([A-Z][\\w.]*)\\.Create\\b`), // lg := TLogger.Create
1113
+ ];
1114
+ case 'cfml':
1115
+ case 'cfscript':
1116
+ return [
1117
+ // svc = new UserService() / new path.to.UserService() — dotted component
1118
+ // paths reduce to their final segment via normalizeInferredTypeName.
1119
+ // Also matches inside tag markup (`<cfset svc = new UserService()>`)
1120
+ // since the scan reads raw source lines.
1121
+ new RegExp(`\\b${r}\\b\\s*=\\s*new\\s+([A-Za-z_][\\w.]*)`),
1122
+ // The classic form: svc = createObject("component", "path.to.UserService")
1123
+ // (casing of createObject varies in the wild), plus the modern
1124
+ // single-argument form createObject("path.to.UserService").
1125
+ new RegExp(`\\b${r}\\b\\s*=\\s*[Cc]reate[Oo]bject\\s*\\(\\s*["']component["']\\s*,\\s*["']([\\w.]+)["']`),
1126
+ new RegExp(`\\b${r}\\b\\s*=\\s*[Cc]reate[Oo]bject\\s*\\(\\s*["']([\\w.]+)["']\\s*\\)`),
1127
+ // Typed cfscript parameter: `function save(UserService svc)` /
1128
+ // `required UserService svc` — CFML's built-in types (string, numeric,
1129
+ // any, struct…) are lowercase by convention, so the PascalCase guard
1130
+ // excludes them.
1131
+ new RegExp(`\\b([A-Z][\\w.]*)\\s+${r}\\b\\s*[=;,)]`),
1132
+ // Tag-form typed argument, either attribute order:
1133
+ // <cfargument name="svc" type="path.to.UserService">
1134
+ new RegExp(`\\bcfargument[^>\\n]*\\bname\\s*=\\s*["']${r}["'][^>\\n]*\\btype\\s*=\\s*["']([\\w.]+)["']`, 'i'),
1135
+ new RegExp(`\\bcfargument[^>\\n]*\\btype\\s*=\\s*["']([\\w.]+)["'][^>\\n]*\\bname\\s*=\\s*["']${r}["']`, 'i'),
1136
+ // Component property (incl. WireBox DI): `property name="svc"
1137
+ // inject="UserService";` / `<cfproperty name="svc" type="UserService">`,
1138
+ // either attribute order. An inject DSL value with a namespace
1139
+ // (`inject="svc@core"`) captures only the leading name and simply
1140
+ // fails type-validation — no edge, never a wrong one.
1141
+ new RegExp(`\\b(?:cf)?property\\b[^;\\n]*\\bname\\s*=\\s*["']${r}["'][^;\\n]*\\b(?:type|inject)\\s*=\\s*["']([\\w.]+)["']`, 'i'),
1142
+ new RegExp(`\\b(?:cf)?property\\b[^;\\n]*\\b(?:type|inject)\\s*=\\s*["']([\\w.]+)["'][^;\\n]*\\bname\\s*=\\s*["']${r}["']`, 'i'),
1143
+ ];
1144
+ default:
1145
+ return [];
1146
+ }
1147
+ }
1148
+ /** 1-based start line of the tightest function/method enclosing the call. */
1149
+ function enclosingScopeStartLine(ref, context) {
1150
+ let start = 1;
1151
+ for (const n of context.getNodesInFile(ref.filePath)) {
1152
+ if (n.kind !== 'function' && n.kind !== 'method')
1153
+ continue;
1154
+ if (n.language !== ref.language)
1155
+ continue;
1156
+ const end = n.endLine ?? n.startLine;
1157
+ if (n.startLine <= ref.line && end >= ref.line && n.startLine >= start) {
1158
+ start = n.startLine;
1159
+ }
1160
+ }
1161
+ return start;
1162
+ }
1163
+ /**
1164
+ * Infer a receiver's type from its local declaration/initializer in the
1165
+ * enclosing function body. Language-dispatched; returns null for languages
1166
+ * without patterns or when no declaration is found. Bounded to the enclosing
1167
+ * scope so a same-named variable in another function can't leak in.
1168
+ */
1169
+ function inferLocalReceiverType(receiverName, ref, context) {
1170
+ // CFML scope prefixes: `variables.svc` / `this.svc` name a COMPONENT-scoped
1171
+ // field whose assignment or `property` declaration usually lives outside the
1172
+ // calling function (the init-pseudoconstructor / WireBox-injection pattern),
1173
+ // and `local.svc` is an explicit function-local. Strip the prefix so the
1174
+ // declaration patterns match (`variables.svc = new X()`, `property
1175
+ // name="svc" …`, `var svc = …` all bind the bare name), and widen the scan
1176
+ // to the whole file for the component-scoped forms — nearest-declaration-
1177
+ // backward still wins, so a function-local shadowing the field is preferred.
1178
+ let scanReceiver = receiverName;
1179
+ let componentScoped = false;
1180
+ if (ref.language === 'cfml' || ref.language === 'cfscript') {
1181
+ const scoped = receiverName.match(/^(variables|this|local|arguments)\.(.+)$/i);
1182
+ if (scoped) {
1183
+ scanReceiver = scoped[2];
1184
+ const scope = scoped[1].toLowerCase();
1185
+ componentScoped = scope === 'variables' || scope === 'this';
1186
+ }
1187
+ }
1188
+ const patterns = localReceiverTypePatterns(ref.language, scanReceiver.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
1189
+ if (patterns.length === 0)
1190
+ return null;
1191
+ // Split through the context's per-file lines cache when available: this runs
1192
+ // for EVERY `receiver.method()` ref, and re-splitting the whole file per ref
1193
+ // was ~20% of total index CPU on Java-heavy repos (#1122).
1194
+ const lines = context.getFileLines
1195
+ ? context.getFileLines(ref.filePath)
1196
+ : (context.readFile(ref.filePath)?.split(/\r?\n/) ?? null);
1197
+ if (!lines || lines.length === 0)
1198
+ return null;
1199
+ const callIdx = Math.max(0, Math.min(lines.length - 1, ref.line - 1));
1200
+ const startIdx = componentScoped
1201
+ ? 0
1202
+ : Math.max(0, enclosingScopeStartLine(ref, context) - 1);
1203
+ const matchLine = (i) => {
1204
+ const line = lines[i];
1205
+ if (!line)
1206
+ return null;
1207
+ // A generated/minified line (one multi-KB statement) is not something a
1208
+ // human-written local declaration lives on, and regexing it per ref is
1209
+ // pure waste — skip it rather than scan it.
1210
+ if (line.length > 10_000)
1211
+ return null;
1212
+ for (const re of patterns) {
1213
+ const m = line.match(re);
1214
+ if (m && m[1]) {
1215
+ const type = normalizeInferredTypeName(m[1]);
1216
+ if (type)
1217
+ return type;
1218
+ }
1219
+ }
1220
+ return null;
1221
+ };
1222
+ // Nearest declaration wins: scan backward from the call to the scope start.
1223
+ for (let i = callIdx; i >= startIdx; i--) {
1224
+ const type = matchLine(i);
1225
+ if (type)
1226
+ return type;
1227
+ }
1228
+ // A component-scoped field's declaration is position-independent — the
1229
+ // `variables.svc = new X()` pseudoconstructor assignment or `property`
1230
+ // declaration may sit BELOW the calling function in the file — so when the
1231
+ // backward pass finds nothing, sweep the remainder of the file too.
1232
+ if (componentScoped) {
1233
+ for (let i = callIdx + 1; i < lines.length; i++) {
1234
+ const type = matchLine(i);
1235
+ if (type)
1236
+ return type;
1237
+ }
1238
+ }
1239
+ return null;
1240
+ }
1241
+ /**
1242
+ * Try to resolve by method name on a class/object
1243
+ */
1244
+ function matchMethodCall(ref, context) {
1245
+ // Parse method call patterns like "obj.method" or "Class::method". The method
1246
+ // part allows trailing `:` keywords so Objective-C selectors resolve
1247
+ // (`SDImageCache.storeImage:`, `obj.setX:y:`); colons never appear in other
1248
+ // languages' method refs, so this is a no-op for them.
1249
+ // The receiver allows dots (`builder.Services.AddCoreServices`) so a CHAINED
1250
+ // call resolves by its last segment — Strategy 3 below name-matches the method
1251
+ // (with its existing single-candidate / receiver-overlap guards). Without this
1252
+ // a multi-dot extension-method call (C# DI `builder.Services.AddCoreServices()`,
1253
+ // `Guard.Against.X()`) matched no pattern and never resolved.
1254
+ const dotMatch = ref.referenceName.match(/^([\w.]+)\.(\w+:?(?:\w+:)*)$/);
1255
+ const colonMatch = ref.referenceName.match(/^(\w+)::(\w+)$/);
1256
+ // Lua/Luau method calls use a single colon (`lg:log`); R uses `$` (`lg$log`).
1257
+ // Recognize these receiver/method separators so local-variable receiver-type
1258
+ // inference (#1108) applies to them too — extraction already emits the ref in
1259
+ // this shape, but the resolver otherwise only understood `.` and `::`.
1260
+ const luaColonMatch = (ref.language === 'lua' || ref.language === 'luau')
1261
+ ? ref.referenceName.match(/^([\w.]+):(\w+)$/)
1262
+ : null;
1263
+ const rDollarMatch = ref.language === 'r'
1264
+ ? ref.referenceName.match(/^([\w.]+)\$(\w+)$/)
1265
+ : null;
1266
+ const match = dotMatch || colonMatch || luaColonMatch || rDollarMatch;
1267
+ if (!match) {
1268
+ return null;
1269
+ }
1270
+ const [, objectOrClass, methodName] = match;
1271
+ // A simple `receiver.method` / `receiver:method` / `receiver$method` shape whose
1272
+ // receiver type we can try to infer from its local declaration.
1273
+ const inferableReceiver = dotMatch || luaColonMatch || rDollarMatch;
1274
+ // Infer the receiver's type from its local declaration/initializer in the
1275
+ // enclosing scope, then resolve the method on that type (#1108). C++ keeps its
1276
+ // dedicated inferrer (header scan + `auto`); every other language uses the
1277
+ // shared source-based inferrer. resolveMethodOnType validates the method
1278
+ // exists on the inferred type, so a mis-inference produces no edge.
1279
+ if (inferableReceiver) {
1280
+ const inferredType = ref.language === 'cpp'
1281
+ ? inferCppReceiverType(objectOrClass, ref, context)
1282
+ : inferLocalReceiverType(objectOrClass, ref, context);
1283
+ if (inferredType) {
1284
+ // Java/Kotlin: when two classes share the simple name, the file's import
1285
+ // pins WHICH one (#314). Other languages disambiguate by call-site file.
1286
+ const importedFqn = ref.language === 'java' || ref.language === 'kotlin'
1287
+ ? context
1288
+ .getImportMappings(ref.filePath, ref.language)
1289
+ .find((i) => i.localName === inferredType)?.source
1290
+ : undefined;
1291
+ const typedMatch = resolveMethodOnType(inferredType, methodName, ref, context, 0.9, 'instance-method', importedFqn);
1292
+ if (typedMatch) {
1293
+ return typedMatch;
1294
+ }
1295
+ }
1296
+ }
1297
+ // Java/Kotlin: receiver may be a field whose name doesn't match the type by
1298
+ // Java naming convention (`userbo` → class `UserBO`, abbreviated). Look up
1299
+ // the field in the enclosing class to get its declared type, then resolve
1300
+ // the method on that type. Covers Spring `@Resource`/`@Autowired` field
1301
+ // injection where the field type is the concrete bean class.
1302
+ if ((ref.language === 'java' || ref.language === 'kotlin') && dotMatch) {
1303
+ const inferredType = inferJavaFieldReceiverType(objectOrClass, ref, context);
1304
+ if (inferredType) {
1305
+ // When two classes share the same simple name, the caller file's
1306
+ // import is the only signal that names WHICH one — pass the
1307
+ // imported FQN so resolveMethodOnType can disambiguate (#314).
1308
+ const imports = context.getImportMappings(ref.filePath, ref.language);
1309
+ const importedFqn = imports.find((i) => i.localName === inferredType)?.source;
1310
+ const typedMatch = resolveMethodOnType(inferredType, methodName, ref, context, 0.9, 'instance-method', importedFqn);
1311
+ if (typedMatch) {
1312
+ return typedMatch;
1313
+ }
1314
+ }
1315
+ }
1316
+ // Strategy 1: Direct class name match (existing logic). When the receiver
1317
+ // names a class that exists in several files (`Logger.log()` / `Logger::log()`
1318
+ // with a `Logger` in both `a/` and `b/`), try the class in the call site's
1319
+ // own file first — otherwise the first-indexed class wins and a call in `b/`
1320
+ // resolves to `a/`'s method (#1079).
1321
+ const classCandidates = preferCallSiteFile(context.getNodesByName(objectOrClass), ref.filePath);
1322
+ for (const classNode of classCandidates) {
1323
+ if (classNode.kind === 'class' || classNode.kind === 'struct' || classNode.kind === 'interface') {
1324
+ // Skip cross-language class matches
1325
+ if (classNode.language !== ref.language)
1326
+ continue;
1327
+ const nodesInFile = context.getNodesInFile(classNode.filePath);
1328
+ const methodNode = nodesInFile.find((n) => n.kind === 'method' &&
1329
+ n.name === methodName &&
1330
+ n.qualifiedName.includes(classNode.name));
1331
+ if (methodNode) {
1332
+ return {
1333
+ original: ref,
1334
+ targetNodeId: methodNode.id,
1335
+ confidence: 0.85,
1336
+ resolvedBy: 'qualified-name',
1337
+ };
1338
+ }
1339
+ }
1340
+ }
1341
+ // Strategy 2: Instance variable receiver - try capitalized form to find class
1342
+ // e.g., "permissionEngine" → look for classes containing "PermissionEngine"
1343
+ const capitalizedReceiver = objectOrClass.charAt(0).toUpperCase() + objectOrClass.slice(1);
1344
+ if (capitalizedReceiver !== objectOrClass) {
1345
+ const fuzzyClassCandidates = preferCallSiteFile(context.getNodesByName(capitalizedReceiver), ref.filePath);
1346
+ for (const classNode of fuzzyClassCandidates) {
1347
+ if (classNode.kind === 'class' || classNode.kind === 'struct' || classNode.kind === 'interface') {
1348
+ // Skip cross-language class matches
1349
+ if (classNode.language !== ref.language)
1350
+ continue;
1351
+ const nodesInFile = context.getNodesInFile(classNode.filePath);
1352
+ const methodNode = nodesInFile.find((n) => n.kind === 'method' &&
1353
+ n.name === methodName &&
1354
+ n.qualifiedName.includes(classNode.name));
1355
+ if (methodNode) {
1356
+ return {
1357
+ original: ref,
1358
+ targetNodeId: methodNode.id,
1359
+ confidence: 0.8,
1360
+ resolvedBy: 'instance-method',
1361
+ };
1362
+ }
1363
+ }
1364
+ }
1365
+ }
1366
+ // Strategy 3: Find methods by name across the codebase, match by receiver
1367
+ // name similarity with the containing class. Handles abbreviated variable
1368
+ // names like permissionEngine → PermissionRuleEngine.
1369
+ if (methodName) {
1370
+ const methodCandidates = context.getNodesByName(methodName);
1371
+ // Ubiquitous-method ceiling (#999): a method name re-declared across a
1372
+ // vendored theme/SDK (Metronic's `init`/`update`/… on every widget) yields
1373
+ // K candidates that receiver-word overlap can't reliably disambiguate —
1374
+ // and filtering + scoring all K per call is the O(K²) cost that wedged
1375
+ // "Resolving refs" for 15-28 min. Bail before the O(K) work; Strategy 1/2
1376
+ // (class-name match) already had their precise shot above.
1377
+ if (methodCandidates.length > AMBIGUOUS_NAME_CEILING) {
1378
+ return null;
1379
+ }
1380
+ const methods = methodCandidates.filter((n) => n.kind === 'method' && n.name === methodName);
1381
+ // Filter to same-language candidates first
1382
+ const sameLanguageMethods = methods.filter(m => m.language === ref.language);
1383
+ const targetMethods = sameLanguageMethods.length > 0 ? sameLanguageMethods : methods;
1384
+ // If only one same-language method with this name exists, use it
1385
+ if (targetMethods.length === 1 && targetMethods[0].language === ref.language) {
1386
+ return {
1387
+ original: ref,
1388
+ targetNodeId: targetMethods[0].id,
1389
+ confidence: 0.7,
1390
+ resolvedBy: 'instance-method',
1391
+ };
1392
+ }
1393
+ // Multiple methods: score by receiver name word overlap with class name
1394
+ if (targetMethods.length > 1) {
1395
+ const receiverWords = splitCamelCase(objectOrClass);
1396
+ let bestMatch;
1397
+ let bestScore = 0;
1398
+ // Same-file candidates first, so a score tie (`score > bestScore` keeps
1399
+ // the first seen) resolves to the call site's own file rather than the
1400
+ // first-indexed duplicate (#1079).
1401
+ for (const method of preferCallSiteFile(targetMethods, ref.filePath)) {
1402
+ const classWords = splitCamelCase(method.qualifiedName);
1403
+ let score = receiverWords.filter(w => classWords.some(cw => cw.toLowerCase() === w.toLowerCase())).length;
1404
+ // Bonus for same language
1405
+ if (method.language === ref.language)
1406
+ score += 1;
1407
+ if (score > bestScore) {
1408
+ bestScore = score;
1409
+ bestMatch = method;
1410
+ }
1411
+ }
1412
+ if (bestMatch && bestScore >= 2) {
1413
+ return {
1414
+ original: ref,
1415
+ targetNodeId: bestMatch.id,
1416
+ confidence: 0.65,
1417
+ resolvedBy: 'instance-method',
1418
+ };
1419
+ }
1420
+ }
1421
+ }
1422
+ return null;
1423
+ }
1424
+ /**
1425
+ * Split a camelCase or PascalCase string into words.
1426
+ */
1427
+ function splitCamelCase(str) {
1428
+ return str.replace(/([a-z])([A-Z])/g, '$1 $2')
1429
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
1430
+ .split(/[\s._:\/\\]+/)
1431
+ .filter(w => w.length > 1);
1432
+ }
1433
+ /**
1434
+ * Compute directory proximity from a pre-split list of directory segments
1435
+ * (`filePath1` minus its filename) and a second file path.
1436
+ * Returns a score based on the number of shared leading directory segments.
1437
+ * Higher score = closer in directory tree.
1438
+ *
1439
+ * Split into a pre-split variant because findBestMatch scores every candidate
1440
+ * against the SAME `ref.filePath`; re-splitting it per candidate was a hot spot
1441
+ * on large repos (#915), so the caller splits it once and passes the segments.
1442
+ */
1443
+ function pathProximityFromDirs(dir1, filePath2) {
1444
+ const dir2 = filePath2.split('/');
1445
+ dir2.pop(); // drop filename — matches the original slice(0, -1) on both paths
1446
+ let shared = 0;
1447
+ const limit = Math.min(dir1.length, dir2.length);
1448
+ for (let i = 0; i < limit; i++) {
1449
+ if (dir1[i] === dir2[i]) {
1450
+ shared++;
1451
+ }
1452
+ else {
1453
+ break;
1454
+ }
1455
+ }
1456
+ // Each shared directory segment contributes 15 points, capped at 80
1457
+ return Math.min(shared * 15, 80);
1458
+ }
1459
+ /**
1460
+ * Compute directory proximity between two file paths.
1461
+ * Returns a score based on the number of shared directory segments.
1462
+ */
1463
+ function computePathProximity(filePath1, filePath2) {
1464
+ const dir1 = filePath1.split('/');
1465
+ dir1.pop();
1466
+ return pathProximityFromDirs(dir1, filePath2);
1467
+ }
1468
+ /**
1469
+ * Find the best matching node when there are multiple candidates
1470
+ */
1471
+ function findBestMatch(ref, candidates, _context) {
1472
+ // Prioritization rules:
1473
+ // 1. Same file > different file
1474
+ // 2. Directory proximity (same module/package > different module)
1475
+ // 3. Same language > different language
1476
+ // 4. Functions/methods > classes/types (for call references)
1477
+ // 5. Exported > non-exported
1478
+ let bestScore = -1;
1479
+ let bestNode = null;
1480
+ // Split the ref's path once (it's the same across every candidate) instead of
1481
+ // re-splitting it inside computePathProximity per candidate (#915 hot spot).
1482
+ const refDirs = ref.filePath.split('/');
1483
+ refDirs.pop();
1484
+ // A same-language candidate ALWAYS outscores a cross-language one: same-language
1485
+ // scores at least +50 (language bonus), while a cross-language candidate maxes
1486
+ // out at +35 (−80 language, +80 proximity, +25 kind, +10 exported; it can never
1487
+ // be in the same file). So when any same-language candidate exists, skip the
1488
+ // cross-language ones — provably the same winner, without paying the per-candidate
1489
+ // scoring. Cuts the candidate set to same-language size on mixed front-end +
1490
+ // back-end repos (#915). When ALL candidates are cross-language (a legitimate
1491
+ // cross-language `calls` bridge), none are skipped and behavior is unchanged.
1492
+ const hasSameLanguage = candidates.some((c) => c.language === ref.language);
1493
+ for (const candidate of candidates) {
1494
+ if (hasSameLanguage && candidate.language !== ref.language)
1495
+ continue;
1496
+ let score = 0;
1497
+ // Same file bonus
1498
+ if (candidate.filePath === ref.filePath) {
1499
+ score += 100;
1500
+ }
1501
+ // Directory proximity bonus — strongly prefer same module/package
1502
+ score += pathProximityFromDirs(refDirs, candidate.filePath);
1503
+ // Language matching: strongly prefer same language, penalize cross-language
1504
+ if (candidate.language === ref.language) {
1505
+ score += 50;
1506
+ }
1507
+ else {
1508
+ score -= 80;
1509
+ }
1510
+ // For call references, prefer functions/methods
1511
+ if (ref.referenceKind === 'calls') {
1512
+ if (candidate.kind === 'function' || candidate.kind === 'method') {
1513
+ score += 25;
1514
+ }
1515
+ }
1516
+ // For instantiation references (`new Foo()`), prefer class-like
1517
+ // targets — without this, a function named `Foo` in another module
1518
+ // could outscore the actual class.
1519
+ if (ref.referenceKind === 'instantiates') {
1520
+ if (candidate.kind === 'class' ||
1521
+ candidate.kind === 'struct' ||
1522
+ candidate.kind === 'interface') {
1523
+ score += 25;
1524
+ }
1525
+ }
1526
+ // For decorator references (`@Foo`), prefer functions. Class
1527
+ // decorators (Python `@SomeClass`, Java annotation interfaces)
1528
+ // also resolve here, hence the smaller class bonus.
1529
+ if (ref.referenceKind === 'decorates') {
1530
+ if (candidate.kind === 'function' || candidate.kind === 'method') {
1531
+ score += 25;
1532
+ }
1533
+ else if (candidate.kind === 'class' || candidate.kind === 'interface') {
1534
+ score += 15;
1535
+ }
1536
+ }
1537
+ // Exported bonus
1538
+ if (candidate.isExported) {
1539
+ score += 10;
1540
+ }
1541
+ // Closer line number (within same file)
1542
+ if (candidate.filePath === ref.filePath && candidate.startLine) {
1543
+ const distance = Math.abs(candidate.startLine - ref.line);
1544
+ score += Math.max(0, 20 - distance / 10);
1545
+ }
1546
+ if (score > bestScore) {
1547
+ bestScore = score;
1548
+ bestNode = candidate;
1549
+ }
1550
+ }
1551
+ return bestNode;
1552
+ }
1553
+ /**
1554
+ * Fuzzy match - last resort with lower confidence
1555
+ */
1556
+ function matchFuzzy(ref, context) {
1557
+ const lowerName = ref.referenceName.toLowerCase();
1558
+ // Use pre-built lowercase index for O(1) lookup instead of scanning all nodes
1559
+ const candidates = context.getNodesByLowerName(lowerName);
1560
+ // Filter to callable kinds only (function, method, class)
1561
+ const callableKinds = new Set(['function', 'method', 'class']);
1562
+ const callableCandidates = applyLanguageGate(candidates.filter((n) => callableKinds.has(n.kind)), ref);
1563
+ // Prefer same-language matches
1564
+ const sameLanguageCandidates = callableCandidates.filter(n => n.language === ref.language);
1565
+ const finalCandidates = sameLanguageCandidates.length > 0 ? sameLanguageCandidates : callableCandidates;
1566
+ if (finalCandidates.length === 1) {
1567
+ const isCrossLanguage = finalCandidates[0].language !== ref.language;
1568
+ return {
1569
+ original: ref,
1570
+ targetNodeId: finalCandidates[0].id,
1571
+ confidence: isCrossLanguage ? 0.3 : 0.5,
1572
+ resolvedBy: 'fuzzy',
1573
+ };
1574
+ }
1575
+ return null;
1576
+ }
1577
+ /**
1578
+ * Match all strategies in order of confidence
1579
+ */
1580
+ /** ArkUI attribute-helper decorators a `.attr(...)` chain may resolve to. */
1581
+ const ARKUI_ATTRIBUTE_DECORATORS = new Set(['Extend', 'Styles', 'AnimatableExtend', 'Builder']);
1582
+ function matchReference(ref, context) {
1583
+ // Function-as-value refs (#756) resolve ONLY through the dedicated matcher —
1584
+ // never the fuzzy/qualified fallthrough below (a wrong callback edge is
1585
+ // worse than none).
1586
+ if (ref.referenceKind === 'function_ref') {
1587
+ return matchFunctionRef(ref, context);
1588
+ }
1589
+ // ArkTS chained UI attributes — emitted with a leading dot (`.titleStyle`,
1590
+ // `.width`) by the extractor — resolve ONLY to decorator-marked attribute
1591
+ // helpers: `@Extend`/`@Styles`/`@AnimatableExtend` functions (and global
1592
+ // `@Builder`s used attribute-position). Framework attributes (`.width`,
1593
+ // `.fontSize` — on nearly every UI line) match no such helper and stay
1594
+ // unresolved, NEVER falling through to bare-name matching: on a samples
1595
+ // monorepo that fallthrough manufactured 36k wrong edges, giving single
1596
+ // same-named properties thousands of false callers. Ambiguity rule matches
1597
+ // the rest of the file: several same-named helpers → prefer the call-site
1598
+ // file, still ambiguous → drop the ref rather than guess.
1599
+ if (ref.language === 'arkts' && ref.referenceName.startsWith('.')) {
1600
+ const base = ref.referenceName.slice(1);
1601
+ const candidates = context
1602
+ .getNodesByName(base)
1603
+ .filter((n) => n.language === 'arkts' &&
1604
+ n.kind === 'function' &&
1605
+ (n.decorators ?? []).some((d) => ARKUI_ATTRIBUTE_DECORATORS.has(d)));
1606
+ const chosen = candidates.length > 1 ? preferCallSiteFile(candidates, ref.filePath) : candidates;
1607
+ if (chosen.length !== 1)
1608
+ return null;
1609
+ return {
1610
+ original: ref,
1611
+ targetNodeId: chosen[0].id,
1612
+ confidence: 0.85,
1613
+ resolvedBy: 'exact-match',
1614
+ };
1615
+ }
1616
+ // Erlang `-behaviour(m)` refs target a MODULE. Letting them fall through to
1617
+ // bare-name matching grabs any same-named symbol — on emqx,
1618
+ // `-behaviour(supervisor)` resolved to a `-define(supervisor, …)` macro
1619
+ // constant in an unrelated app. Resolve only to the behaviour module's
1620
+ // namespace; an out-of-repo behaviour (OTP's gen_server/supervisor) stays
1621
+ // unresolved rather than guessed. The same module-only rule applies to every
1622
+ // ref an `.app`/`.app.src` resource file emits — its `{mod, …}` callback and
1623
+ // `{applications, …}` dependency names can only mean modules, and on emqx
1624
+ // the `ssl` OTP app otherwise resolved to a test helper FUNCTION named ssl.
1625
+ if (ref.language === 'erlang' &&
1626
+ (ref.referenceKind === 'implements' || /\.app(?:\.src)?$/i.test(ref.filePath))) {
1627
+ const modules = context
1628
+ .getNodesByName(ref.referenceName)
1629
+ .filter((n) => n.language === 'erlang' && n.kind === 'namespace');
1630
+ const chosen = preferCallSiteFile(modules, ref.filePath)[0];
1631
+ if (!chosen)
1632
+ return null;
1633
+ return {
1634
+ original: ref,
1635
+ targetNodeId: chosen.id,
1636
+ confidence: 0.9,
1637
+ resolvedBy: 'exact-match',
1638
+ };
1639
+ }
1640
+ // Try strategies in order of confidence
1641
+ let result;
1642
+ // 0. File path match (e.g., "snippets/drawer-menu.liquid" → file node)
1643
+ result = matchByFilePath(ref, context);
1644
+ if (result)
1645
+ return result;
1646
+ // 1. Qualified name match (highest confidence)
1647
+ result = matchByQualifiedName(ref, context);
1648
+ if (result)
1649
+ return result;
1650
+ // 1b. C++ chained call whose receiver is another call — `Foo::instance().bar()`
1651
+ // encoded as `Foo::instance().bar` by the extractor (#645). Resolve the
1652
+ // receiver's type from what the inner call returns, then the method on it.
1653
+ if (ref.language === 'cpp' || ref.language === 'c') {
1654
+ result = matchCppCallChain(ref, context);
1655
+ if (result)
1656
+ return result;
1657
+ }
1658
+ // 1c. `::`-scoped factory chain — PHP `Cls::for($x)->method()` (#608) or Rust
1659
+ // `Foo::new().bar()`, both encoded as `Cls::factory().method`. The receiver's
1660
+ // type is the factory's `self` (PHP `: self`/`: static`, Rust `-> Self`) or
1661
+ // concrete return type.
1662
+ if (ref.language === 'php' || ref.language === 'rust') {
1663
+ result = matchScopedCallChain(ref, context);
1664
+ if (result)
1665
+ return result;
1666
+ }
1667
+ // 1d. Dotted chained static-factory / fluent call (Java / Kotlin / C# / Swift /
1668
+ // Go / Scala / Dart / Objective-C) — `Foo.getInstance().bar()` encoded as
1669
+ // `Foo.getInstance().bar`, Go's bare-factory `New().Method()` as `New().Method`,
1670
+ // Scala's companion factory, Dart's static factory / factory-constructor, or
1671
+ // ObjC's chained message send `[[Foo create] doIt]` encoded as `Foo.create().doIt`
1672
+ // (#645/#608 mechanism). Resolve the method's class from the inner call's
1673
+ // declared return type, then validate it.
1674
+ if (ref.language === 'java' ||
1675
+ ref.language === 'kotlin' ||
1676
+ ref.language === 'csharp' ||
1677
+ ref.language === 'swift' ||
1678
+ ref.language === 'go' ||
1679
+ ref.language === 'scala' ||
1680
+ ref.language === 'dart' ||
1681
+ ref.language === 'objc' ||
1682
+ ref.language === 'pascal') {
1683
+ result = matchDottedCallChain(ref, context);
1684
+ if (result)
1685
+ return result;
1686
+ }
1687
+ // 2. Method call pattern
1688
+ result = matchMethodCall(ref, context);
1689
+ if (result)
1690
+ return result;
1691
+ // 3. Exact name match
1692
+ result = matchByExactName(ref, context);
1693
+ if (result)
1694
+ return result;
1695
+ // 4. Fuzzy match (lowest confidence)
1696
+ result = matchFuzzy(ref, context);
1697
+ if (result)
1698
+ return result;
1699
+ return null;
1700
+ }
1701
+ //# sourceMappingURL=name-matcher.js.map