@quolu/lattice 0.1.0

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