@lzehrung/codegraph 2.3.31 → 2.4.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 (407) hide show
  1. package/README.md +30 -137
  2. package/codegraph-skill/codegraph/SKILL.md +5 -3
  3. package/dist/agent/artifact.d.ts +2 -0
  4. package/dist/agent/artifact.d.ts.map +1 -1
  5. package/dist/agent/artifact.js.map +1 -1
  6. package/dist/agent/search.d.ts.map +1 -1
  7. package/dist/agent/search.js +3 -0
  8. package/dist/agent/search.js.map +1 -1
  9. package/dist/agent/session.d.ts +3 -0
  10. package/dist/agent/session.d.ts.map +1 -1
  11. package/dist/agent/session.js +10 -2
  12. package/dist/agent/session.js.map +1 -1
  13. package/dist/bin/cli.js +42243 -29202
  14. package/dist/bin/query-index-worker.js +73 -11
  15. package/dist/cli/affected.d.ts.map +1 -1
  16. package/dist/cli/affected.js +4 -1
  17. package/dist/cli/affected.js.map +1 -1
  18. package/dist/cli/command-catalog.js +1 -1
  19. package/dist/cli/command-catalog.js.map +1 -1
  20. package/dist/cli/graph-queries.d.ts.map +1 -1
  21. package/dist/cli/graph-queries.js +27 -1
  22. package/dist/cli/graph-queries.js.map +1 -1
  23. package/dist/cli/help.d.ts +2 -2
  24. package/dist/cli/help.d.ts.map +1 -1
  25. package/dist/cli/help.js +4 -2
  26. package/dist/cli/help.js.map +1 -1
  27. package/dist/cli/options.js +2 -2
  28. package/dist/cli/options.js.map +1 -1
  29. package/dist/drift/artifact.d.ts.map +1 -1
  30. package/dist/drift/artifact.js +15 -18
  31. package/dist/drift/artifact.js.map +1 -1
  32. package/dist/drift/compare.js +1 -1
  33. package/dist/drift/compare.js.map +1 -1
  34. package/dist/drift/snapshot.d.ts.map +1 -1
  35. package/dist/drift/snapshot.js +5 -6
  36. package/dist/drift/snapshot.js.map +1 -1
  37. package/dist/drift/types.d.ts +2 -0
  38. package/dist/drift/types.d.ts.map +1 -1
  39. package/dist/drift/types.js.map +1 -1
  40. package/dist/graph-builder.d.ts.map +1 -1
  41. package/dist/graph-builder.js +4 -6
  42. package/dist/graph-builder.js.map +1 -1
  43. package/dist/graph-edge-collector.d.ts +3 -0
  44. package/dist/graph-edge-collector.d.ts.map +1 -1
  45. package/dist/graph-edge-collector.js +8 -5
  46. package/dist/graph-edge-collector.js.map +1 -1
  47. package/dist/graphs/angularjs.d.ts.map +1 -1
  48. package/dist/graphs/angularjs.js +2 -1
  49. package/dist/graphs/angularjs.js.map +1 -1
  50. package/dist/graphs/edge-resolution.d.ts +4 -1
  51. package/dist/graphs/edge-resolution.d.ts.map +1 -1
  52. package/dist/graphs/edge-resolution.js +26 -2
  53. package/dist/graphs/edge-resolution.js.map +1 -1
  54. package/dist/graphs/specifiers.d.ts.map +1 -1
  55. package/dist/graphs/specifiers.js +6 -2
  56. package/dist/graphs/specifiers.js.map +1 -1
  57. package/dist/graphs/symbol-graph-detailed/ast.d.ts +20 -0
  58. package/dist/graphs/symbol-graph-detailed/ast.d.ts.map +1 -1
  59. package/dist/graphs/symbol-graph-detailed/ast.js +154 -15
  60. package/dist/graphs/symbol-graph-detailed/ast.js.map +1 -1
  61. package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts +51 -8
  62. package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts.map +1 -1
  63. package/dist/graphs/symbol-graph-detailed/edge-passes.js +823 -132
  64. package/dist/graphs/symbol-graph-detailed/edge-passes.js.map +1 -1
  65. package/dist/graphs/symbol-graph-detailed/import-aliases.d.ts +2 -1
  66. package/dist/graphs/symbol-graph-detailed/import-aliases.d.ts.map +1 -1
  67. package/dist/graphs/symbol-graph-detailed/import-aliases.js +139 -7
  68. package/dist/graphs/symbol-graph-detailed/import-aliases.js.map +1 -1
  69. package/dist/graphs/symbol-graph-detailed/member-chains.d.ts +1 -0
  70. package/dist/graphs/symbol-graph-detailed/member-chains.d.ts.map +1 -1
  71. package/dist/graphs/symbol-graph-detailed/member-chains.js +3 -1
  72. package/dist/graphs/symbol-graph-detailed/member-chains.js.map +1 -1
  73. package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts +128 -15
  74. package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts.map +1 -1
  75. package/dist/graphs/symbol-graph-detailed/receiver-calls.js +873 -93
  76. package/dist/graphs/symbol-graph-detailed/receiver-calls.js.map +1 -1
  77. package/dist/graphs/symbol-graph-detailed.d.ts.map +1 -1
  78. package/dist/graphs/symbol-graph-detailed.js +434 -40
  79. package/dist/graphs/symbol-graph-detailed.js.map +1 -1
  80. package/dist/graphs/symbol-graph.d.ts +2 -0
  81. package/dist/graphs/symbol-graph.d.ts.map +1 -1
  82. package/dist/graphs/symbol-graph.js +34 -16
  83. package/dist/graphs/symbol-graph.js.map +1 -1
  84. package/dist/impact/call-compatibility/providers/index.d.ts +4 -4
  85. package/dist/impact/call-compatibility/providers/index.d.ts.map +1 -1
  86. package/dist/impact/call-compatibility/providers/index.js +6 -6
  87. package/dist/impact/call-compatibility/providers/index.js.map +1 -1
  88. package/dist/impact/call-compatibility/providers/types.d.ts +2 -0
  89. package/dist/impact/call-compatibility/providers/types.d.ts.map +1 -1
  90. package/dist/impact/call-compatibility/types.d.ts +6 -0
  91. package/dist/impact/call-compatibility/types.d.ts.map +1 -1
  92. package/dist/impact/call-compatibility.d.ts.map +1 -1
  93. package/dist/impact/call-compatibility.js +310 -516
  94. package/dist/impact/call-compatibility.js.map +1 -1
  95. package/dist/impact/map.js +1 -0
  96. package/dist/impact/map.js.map +1 -1
  97. package/dist/impact/reference-cache.d.ts.map +1 -1
  98. package/dist/impact/reference-cache.js +2 -2
  99. package/dist/impact/reference-cache.js.map +1 -1
  100. package/dist/index.d.ts +1 -1
  101. package/dist/index.d.ts.map +1 -1
  102. package/dist/index.js +1 -1
  103. package/dist/index.js.map +1 -1
  104. package/dist/indexer/ambiguous-resolution.d.ts +11 -0
  105. package/dist/indexer/ambiguous-resolution.d.ts.map +1 -0
  106. package/dist/indexer/ambiguous-resolution.js +19 -0
  107. package/dist/indexer/ambiguous-resolution.js.map +1 -0
  108. package/dist/indexer/build-cache/module-cache.d.ts +38 -0
  109. package/dist/indexer/build-cache/module-cache.d.ts.map +1 -1
  110. package/dist/indexer/build-cache/module-cache.js +151 -9
  111. package/dist/indexer/build-cache/module-cache.js.map +1 -1
  112. package/dist/indexer/build-cache/options.d.ts +16 -43
  113. package/dist/indexer/build-cache/options.d.ts.map +1 -1
  114. package/dist/indexer/build-cache/options.js +16 -43
  115. package/dist/indexer/build-cache/options.js.map +1 -1
  116. package/dist/indexer/build-cache/project-snapshot.d.ts +1 -0
  117. package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -1
  118. package/dist/indexer/build-cache/project-snapshot.js +117 -24
  119. package/dist/indexer/build-cache/project-snapshot.js.map +1 -1
  120. package/dist/indexer/build-cache/resolver-environment.d.ts.map +1 -1
  121. package/dist/indexer/build-cache/resolver-environment.js +32 -2
  122. package/dist/indexer/build-cache/resolver-environment.js.map +1 -1
  123. package/dist/indexer/build-cache.d.ts +1 -1
  124. package/dist/indexer/build-cache.d.ts.map +1 -1
  125. package/dist/indexer/build-cache.js +1 -1
  126. package/dist/indexer/build-cache.js.map +1 -1
  127. package/dist/indexer/build-index.d.ts.map +1 -1
  128. package/dist/indexer/build-index.js +593 -22
  129. package/dist/indexer/build-index.js.map +1 -1
  130. package/dist/indexer/call-hierarchy.js +1 -1
  131. package/dist/indexer/call-hierarchy.js.map +1 -1
  132. package/dist/indexer/compilation-units.d.ts +101 -0
  133. package/dist/indexer/compilation-units.d.ts.map +1 -0
  134. package/dist/indexer/compilation-units.js +605 -0
  135. package/dist/indexer/compilation-units.js.map +1 -0
  136. package/dist/indexer/cpp-callables.d.ts +20 -0
  137. package/dist/indexer/cpp-callables.d.ts.map +1 -0
  138. package/dist/indexer/cpp-callables.js +554 -0
  139. package/dist/indexer/cpp-callables.js.map +1 -0
  140. package/dist/indexer/declaration-visibility.d.ts +36 -2
  141. package/dist/indexer/declaration-visibility.d.ts.map +1 -1
  142. package/dist/indexer/declaration-visibility.js +136 -2
  143. package/dist/indexer/declaration-visibility.js.map +1 -1
  144. package/dist/indexer/expand-star-imports.d.ts.map +1 -1
  145. package/dist/indexer/expand-star-imports.js +28 -6
  146. package/dist/indexer/expand-star-imports.js.map +1 -1
  147. package/dist/indexer/import-types.d.ts +37 -0
  148. package/dist/indexer/import-types.d.ts.map +1 -1
  149. package/dist/indexer/import-types.js +24 -1
  150. package/dist/indexer/import-types.js.map +1 -1
  151. package/dist/indexer/imports/context.d.ts +11 -1
  152. package/dist/indexer/imports/context.d.ts.map +1 -1
  153. package/dist/indexer/imports/import-binding-tables.d.ts +12 -1
  154. package/dist/indexer/imports/import-binding-tables.d.ts.map +1 -1
  155. package/dist/indexer/imports/import-binding-tables.js +144 -19
  156. package/dist/indexer/imports/import-binding-tables.js.map +1 -1
  157. package/dist/indexer/imports/js-text-imports.js +4 -4
  158. package/dist/indexer/imports/js-text-imports.js.map +1 -1
  159. package/dist/indexer/imports/native-captures.d.ts.map +1 -1
  160. package/dist/indexer/imports/native-captures.js +18 -6
  161. package/dist/indexer/imports/native-captures.js.map +1 -1
  162. package/dist/indexer/imports/python.d.ts +10 -2
  163. package/dist/indexer/imports/python.d.ts.map +1 -1
  164. package/dist/indexer/imports/python.js +91 -40
  165. package/dist/indexer/imports/python.js.map +1 -1
  166. package/dist/indexer/imports/text-import-extractors.d.ts.map +1 -1
  167. package/dist/indexer/imports/text-import-extractors.js +51 -12
  168. package/dist/indexer/imports/text-import-extractors.js.map +1 -1
  169. package/dist/indexer/imports.d.ts.map +1 -1
  170. package/dist/indexer/imports.js +23 -4
  171. package/dist/indexer/imports.js.map +1 -1
  172. package/dist/indexer/incremental-plan.d.ts +33 -0
  173. package/dist/indexer/incremental-plan.d.ts.map +1 -1
  174. package/dist/indexer/incremental-plan.js +187 -1
  175. package/dist/indexer/incremental-plan.js.map +1 -1
  176. package/dist/indexer/locals-and-exports.d.ts +2 -0
  177. package/dist/indexer/locals-and-exports.d.ts.map +1 -1
  178. package/dist/indexer/locals-and-exports.js +565 -54
  179. package/dist/indexer/locals-and-exports.js.map +1 -1
  180. package/dist/indexer/name-lookup-policies/c-family.d.ts +7 -0
  181. package/dist/indexer/name-lookup-policies/c-family.d.ts.map +1 -0
  182. package/dist/indexer/name-lookup-policies/c-family.js +117 -0
  183. package/dist/indexer/name-lookup-policies/c-family.js.map +1 -0
  184. package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts +11 -0
  185. package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts.map +1 -0
  186. package/dist/indexer/name-lookup-policies/csharp-using-static.js +136 -0
  187. package/dist/indexer/name-lookup-policies/csharp-using-static.js.map +1 -0
  188. package/dist/indexer/name-lookup-policies/implicit-self.d.ts +10 -0
  189. package/dist/indexer/name-lookup-policies/implicit-self.d.ts.map +1 -0
  190. package/dist/indexer/name-lookup-policies/implicit-self.js +113 -0
  191. package/dist/indexer/name-lookup-policies/implicit-self.js.map +1 -0
  192. package/dist/indexer/name-lookup-policies/index.d.ts +3 -0
  193. package/dist/indexer/name-lookup-policies/index.d.ts.map +1 -0
  194. package/dist/indexer/name-lookup-policies/index.js +106 -0
  195. package/dist/indexer/name-lookup-policies/index.js.map +1 -0
  196. package/dist/indexer/name-lookup-policies/php.d.ts +3 -0
  197. package/dist/indexer/name-lookup-policies/php.d.ts.map +1 -0
  198. package/dist/indexer/name-lookup-policies/php.js +75 -0
  199. package/dist/indexer/name-lookup-policies/php.js.map +1 -0
  200. package/dist/indexer/name-resolution-types.d.ts +99 -0
  201. package/dist/indexer/name-resolution-types.d.ts.map +1 -0
  202. package/dist/indexer/name-resolution-types.js +2 -0
  203. package/dist/indexer/name-resolution-types.js.map +1 -0
  204. package/dist/indexer/name-resolution.d.ts +52 -0
  205. package/dist/indexer/name-resolution.d.ts.map +1 -0
  206. package/dist/indexer/name-resolution.js +189 -0
  207. package/dist/indexer/name-resolution.js.map +1 -0
  208. package/dist/indexer/navigation-cpp.d.ts +50 -0
  209. package/dist/indexer/navigation-cpp.d.ts.map +1 -0
  210. package/dist/indexer/navigation-cpp.js +654 -0
  211. package/dist/indexer/navigation-cpp.js.map +1 -0
  212. package/dist/indexer/navigation-goto.d.ts +106 -3
  213. package/dist/indexer/navigation-goto.d.ts.map +1 -1
  214. package/dist/indexer/navigation-goto.js +2074 -137
  215. package/dist/indexer/navigation-goto.js.map +1 -1
  216. package/dist/indexer/navigation-local.d.ts +18 -2
  217. package/dist/indexer/navigation-local.d.ts.map +1 -1
  218. package/dist/indexer/navigation-local.js +498 -61
  219. package/dist/indexer/navigation-local.js.map +1 -1
  220. package/dist/indexer/navigation-php.d.ts +66 -0
  221. package/dist/indexer/navigation-php.d.ts.map +1 -1
  222. package/dist/indexer/navigation-php.js +287 -4
  223. package/dist/indexer/navigation-php.js.map +1 -1
  224. package/dist/indexer/navigation-references.d.ts +72 -5
  225. package/dist/indexer/navigation-references.d.ts.map +1 -1
  226. package/dist/indexer/navigation-references.js +620 -54
  227. package/dist/indexer/navigation-references.js.map +1 -1
  228. package/dist/indexer/navigation-resolve.d.ts +33 -2
  229. package/dist/indexer/navigation-resolve.d.ts.map +1 -1
  230. package/dist/indexer/navigation-resolve.js +446 -193
  231. package/dist/indexer/navigation-resolve.js.map +1 -1
  232. package/dist/indexer/navigation.d.ts +28 -2
  233. package/dist/indexer/navigation.d.ts.map +1 -1
  234. package/dist/indexer/navigation.js +1082 -151
  235. package/dist/indexer/navigation.js.map +1 -1
  236. package/dist/indexer/php-namespace-symbols.d.ts +66 -0
  237. package/dist/indexer/php-namespace-symbols.d.ts.map +1 -0
  238. package/dist/indexer/php-namespace-symbols.js +342 -0
  239. package/dist/indexer/php-namespace-symbols.js.map +1 -0
  240. package/dist/indexer/reference-context.d.ts +2 -0
  241. package/dist/indexer/reference-context.d.ts.map +1 -1
  242. package/dist/indexer/reference-context.js +4 -0
  243. package/dist/indexer/reference-context.js.map +1 -1
  244. package/dist/indexer/scope-nodes.d.ts +92 -13
  245. package/dist/indexer/scope-nodes.d.ts.map +1 -1
  246. package/dist/indexer/scope-nodes.js +212 -20
  247. package/dist/indexer/scope-nodes.js.map +1 -1
  248. package/dist/indexer/scope-types.d.ts +25 -1
  249. package/dist/indexer/scope-types.d.ts.map +1 -1
  250. package/dist/indexer/scope.d.ts.map +1 -1
  251. package/dist/indexer/scope.js +894 -45
  252. package/dist/indexer/scope.js.map +1 -1
  253. package/dist/indexer/shared-owner-identity.d.ts +53 -0
  254. package/dist/indexer/shared-owner-identity.d.ts.map +1 -0
  255. package/dist/indexer/shared-owner-identity.js +460 -0
  256. package/dist/indexer/shared-owner-identity.js.map +1 -0
  257. package/dist/indexer/shared.d.ts +1 -1
  258. package/dist/indexer/shared.d.ts.map +1 -1
  259. package/dist/indexer/shared.js +1 -1
  260. package/dist/indexer/shared.js.map +1 -1
  261. package/dist/indexer/star-import-precedence.d.ts +114 -0
  262. package/dist/indexer/star-import-precedence.d.ts.map +1 -0
  263. package/dist/indexer/star-import-precedence.js +396 -0
  264. package/dist/indexer/star-import-precedence.js.map +1 -0
  265. package/dist/indexer/symbols.d.ts +3 -1
  266. package/dist/indexer/symbols.d.ts.map +1 -1
  267. package/dist/indexer/symbols.js +58 -18
  268. package/dist/indexer/symbols.js.map +1 -1
  269. package/dist/indexer/ts-callables.d.ts +51 -0
  270. package/dist/indexer/ts-callables.d.ts.map +1 -0
  271. package/dist/indexer/ts-callables.js +264 -0
  272. package/dist/indexer/ts-callables.js.map +1 -0
  273. package/dist/indexer/types.d.ts +23 -1
  274. package/dist/indexer/types.d.ts.map +1 -1
  275. package/dist/indexer/unused-exports.d.ts +13 -0
  276. package/dist/indexer/unused-exports.d.ts.map +1 -0
  277. package/dist/indexer/unused-exports.js +159 -0
  278. package/dist/indexer/unused-exports.js.map +1 -0
  279. package/dist/indexer/workspace-symbols.d.ts.map +1 -1
  280. package/dist/indexer/workspace-symbols.js +3 -2
  281. package/dist/indexer/workspace-symbols.js.map +1 -1
  282. package/dist/indexer.d.ts +2 -2
  283. package/dist/indexer.d.ts.map +1 -1
  284. package/dist/indexer.js +1 -1
  285. package/dist/indexer.js.map +1 -1
  286. package/dist/languages/callable-arity.d.ts +202 -0
  287. package/dist/languages/callable-arity.d.ts.map +1 -0
  288. package/dist/languages/callable-arity.js +1182 -0
  289. package/dist/languages/callable-arity.js.map +1 -0
  290. package/dist/languages/definitions/c-family.d.ts.map +1 -1
  291. package/dist/languages/definitions/c-family.js +30 -1
  292. package/dist/languages/definitions/c-family.js.map +1 -1
  293. package/dist/languages/definitions/c.d.ts +4 -0
  294. package/dist/languages/definitions/c.d.ts.map +1 -1
  295. package/dist/languages/definitions/c.js +19 -0
  296. package/dist/languages/definitions/c.js.map +1 -1
  297. package/dist/languages/definitions/cpp.d.ts.map +1 -1
  298. package/dist/languages/definitions/cpp.js +12 -0
  299. package/dist/languages/definitions/cpp.js.map +1 -1
  300. package/dist/languages/definitions/csharp.d.ts.map +1 -1
  301. package/dist/languages/definitions/csharp.js +2 -8
  302. package/dist/languages/definitions/csharp.js.map +1 -1
  303. package/dist/languages/definitions/go.d.ts.map +1 -1
  304. package/dist/languages/definitions/go.js +3 -0
  305. package/dist/languages/definitions/go.js.map +1 -1
  306. package/dist/languages/definitions/javascript.d.ts.map +1 -1
  307. package/dist/languages/definitions/javascript.js +10 -1
  308. package/dist/languages/definitions/javascript.js.map +1 -1
  309. package/dist/languages/definitions/js-family.d.ts +1 -1
  310. package/dist/languages/definitions/js-family.d.ts.map +1 -1
  311. package/dist/languages/definitions/js-family.js +7 -1
  312. package/dist/languages/definitions/js-family.js.map +1 -1
  313. package/dist/languages/definitions/php.d.ts.map +1 -1
  314. package/dist/languages/definitions/php.js +5 -1
  315. package/dist/languages/definitions/php.js.map +1 -1
  316. package/dist/languages/definitions/typescript.d.ts.map +1 -1
  317. package/dist/languages/definitions/typescript.js +8 -1
  318. package/dist/languages/definitions/typescript.js.map +1 -1
  319. package/dist/languages/definitions/zig.d.ts.map +1 -1
  320. package/dist/languages/definitions/zig.js +2 -0
  321. package/dist/languages/definitions/zig.js.map +1 -1
  322. package/dist/mcp/handlers.js +14 -7
  323. package/dist/mcp/handlers.js.map +1 -1
  324. package/dist/review/candidates.d.ts.map +1 -1
  325. package/dist/review/candidates.js +1 -1
  326. package/dist/review/candidates.js.map +1 -1
  327. package/dist/review/deleted.d.ts +3 -3
  328. package/dist/review/deleted.d.ts.map +1 -1
  329. package/dist/review/deleted.js +82 -32
  330. package/dist/review/deleted.js.map +1 -1
  331. package/dist/review/report.d.ts +1 -0
  332. package/dist/review/report.d.ts.map +1 -1
  333. package/dist/review/report.js +1 -1
  334. package/dist/review/report.js.map +1 -1
  335. package/dist/review.d.ts.map +1 -1
  336. package/dist/review.js +1 -0
  337. package/dist/review.js.map +1 -1
  338. package/dist/sql/navigation.d.ts.map +1 -1
  339. package/dist/sql/navigation.js +1 -0
  340. package/dist/sql/navigation.js.map +1 -1
  341. package/dist/sql/source-graph.d.ts.map +1 -1
  342. package/dist/sql/source-graph.js +2 -2
  343. package/dist/sql/source-graph.js.map +1 -1
  344. package/dist/sqlite/schema.d.ts +1 -1
  345. package/dist/sqlite/schema.d.ts.map +1 -1
  346. package/dist/sqlite/schema.js +8 -2
  347. package/dist/sqlite/schema.js.map +1 -1
  348. package/dist/sqlite/write.js +2 -2
  349. package/dist/sqlite/write.js.map +1 -1
  350. package/dist/types.d.ts +2 -0
  351. package/dist/types.d.ts.map +1 -1
  352. package/dist/util/bloom-filter.d.ts +7 -1
  353. package/dist/util/bloom-filter.d.ts.map +1 -1
  354. package/dist/util/bloom-filter.js +12 -2
  355. package/dist/util/bloom-filter.js.map +1 -1
  356. package/dist/util/graph-edges.d.ts +19 -1
  357. package/dist/util/graph-edges.d.ts.map +1 -1
  358. package/dist/util/graph-edges.js +30 -4
  359. package/dist/util/graph-edges.js.map +1 -1
  360. package/dist/util/identifiers.d.ts +15 -0
  361. package/dist/util/identifiers.d.ts.map +1 -1
  362. package/dist/util/identifiers.js +35 -0
  363. package/dist/util/identifiers.js.map +1 -1
  364. package/dist/util/member-access-tables.d.ts +61 -4
  365. package/dist/util/member-access-tables.d.ts.map +1 -1
  366. package/dist/util/member-access-tables.js +137 -19
  367. package/dist/util/member-access-tables.js.map +1 -1
  368. package/dist/util/member-access.d.ts +17 -0
  369. package/dist/util/member-access.d.ts.map +1 -1
  370. package/dist/util/member-access.js +95 -3
  371. package/dist/util/member-access.js.map +1 -1
  372. package/dist/util/resolution/cargo-targets.d.ts +11 -0
  373. package/dist/util/resolution/cargo-targets.d.ts.map +1 -1
  374. package/dist/util/resolution/cargo-targets.js +174 -13
  375. package/dist/util/resolution/cargo-targets.js.map +1 -1
  376. package/dist/util/resolution/csharp.d.ts +33 -1
  377. package/dist/util/resolution/csharp.d.ts.map +1 -1
  378. package/dist/util/resolution/csharp.js +145 -30
  379. package/dist/util/resolution/csharp.js.map +1 -1
  380. package/dist/util/resolution/php.d.ts.map +1 -1
  381. package/dist/util/resolution/php.js +35 -8
  382. package/dist/util/resolution/php.js.map +1 -1
  383. package/dist/util/resolution/python.d.ts +9 -0
  384. package/dist/util/resolution/python.d.ts.map +1 -1
  385. package/dist/util/resolution/python.js +46 -0
  386. package/dist/util/resolution/python.js.map +1 -1
  387. package/dist/util/resolution/rust.d.ts.map +1 -1
  388. package/dist/util/resolution/rust.js +95 -26
  389. package/dist/util/resolution/rust.js.map +1 -1
  390. package/dist/util/resolution-candidates.d.ts +5 -0
  391. package/dist/util/resolution-candidates.d.ts.map +1 -1
  392. package/dist/util/resolution-candidates.js +16 -3
  393. package/dist/util/resolution-candidates.js.map +1 -1
  394. package/dist/util/resolution.d.ts +2 -1
  395. package/dist/util/resolution.d.ts.map +1 -1
  396. package/dist/util/resolution.js +96 -5
  397. package/dist/util/resolution.js.map +1 -1
  398. package/dist/util/specifiers.d.ts +20 -0
  399. package/dist/util/specifiers.d.ts.map +1 -1
  400. package/dist/util/specifiers.js +29 -0
  401. package/dist/util/specifiers.js.map +1 -1
  402. package/docs/mcp.md +3 -2
  403. package/package.json +3 -3
  404. package/dist/impact/call-compatibility/providers/profiles.d.ts +0 -80
  405. package/dist/impact/call-compatibility/providers/profiles.d.ts.map +0 -1
  406. package/dist/impact/call-compatibility/providers/profiles.js +0 -164
  407. package/dist/impact/call-compatibility/providers/profiles.js.map +0 -1
@@ -1,19 +1,108 @@
1
+ import { getCallArgumentCount } from "../languages/callable-arity.js";
1
2
  import { fileIdentityKey, normalizePath } from "../util/paths.js";
2
3
  import { okGoToResult } from "./navigation-provenance.js";
4
+ import { cppBindingCallableShape, cppSelectCallableBinding } from "./cpp-callables.js";
5
+ import { typescriptCallableCandidatesInContainer, typescriptSelectOverloadCandidate } from "./ts-callables.js";
6
+ import { cScopeName, cTagRole } from "../languages/definitions/c.js";
7
+ import { bindingCoversUse, fileScopeDefinitionCoversUse, isExplicitMethodCall, laterLocalBlocksOuterUse, scopeAllowsUse, scopeIdentifierKey, scopeNodesFor, closestContainingScope, } from "./scope-nodes.js";
3
8
  import { buildScopeIndexFromSource } from "./scope.js";
4
- import { resolveExport, resolveImported } from "./navigation-resolve.js";
5
- import { SymbolKind } from "./types.js";
9
+ import { cjsRequireValueBinding, resolveExport, resolveImported } from "./navigation-resolve.js";
10
+ import { phpNamedImportRole } from "./import-types.js";
11
+ import { resolvePhpExplicitImport } from "./php-namespace-symbols.js";
12
+ import { AMBIGUOUS_STAR_IMPORT_REASON } from "./ambiguous-resolution.js";
13
+ import { decideStarImportCandidates, effectiveExplicitOrLocalBinding, isExpandedStarBinding, resolveStarImportedDefinition, starImportPrecedence, } from "./star-import-precedence.js";
14
+ import { SymbolKind, } from "./types.js";
15
+ /** Follow a C# name token through generic arguments and qualified-name segments. */
16
+ export function csharpQualifiedNameNode(node) {
17
+ let qualified = node;
18
+ while (qualified.parent) {
19
+ const parent = qualified.parent;
20
+ if (parent.type === "generic_name") {
21
+ const name = parent.childForFieldName("name") ?? parent.namedChildren[0];
22
+ if (name && name.startIndex === qualified.startIndex && name.endIndex === qualified.endIndex) {
23
+ qualified = parent;
24
+ continue;
25
+ }
26
+ }
27
+ if ((parent.type === "qualified_name" || parent.type === "alias_qualified_name") &&
28
+ parent.endIndex === qualified.endIndex) {
29
+ qualified = parent;
30
+ continue;
31
+ }
32
+ break;
33
+ }
34
+ return qualified.type === "qualified_name" || qualified.type === "alias_qualified_name" ? qualified : null;
35
+ }
36
+ /** Preserve the full C# namespace or alias path, excluding generic type arguments. */
37
+ export function csharpLookupName(node, source, fallback) {
38
+ const qualified = csharpQualifiedNameNode(node);
39
+ if (!qualified)
40
+ return fallback;
41
+ const text = source.slice(qualified.startIndex, qualified.endIndex);
42
+ if (!text.includes("<"))
43
+ return text.replace(/\s+/gu, "");
44
+ const argumentsNodes = [];
45
+ const collect = (current) => {
46
+ if (current.type === "generic_name") {
47
+ const argumentsNode = (current.namedChildren ?? []).find((child) => child.type === "type_argument_list");
48
+ if (argumentsNode)
49
+ argumentsNodes.push(argumentsNode);
50
+ return;
51
+ }
52
+ for (const child of current.namedChildren ?? []) {
53
+ if (child.type === "generic_name" || child.type === "qualified_name" || child.type === "alias_qualified_name") {
54
+ collect(child);
55
+ }
56
+ }
57
+ };
58
+ collect(qualified);
59
+ let result = "";
60
+ let from = qualified.startIndex;
61
+ for (const argumentsNode of argumentsNodes) {
62
+ result += source.slice(from, argumentsNode.startIndex);
63
+ from = argumentsNode.endIndex;
64
+ }
65
+ return (result + source.slice(from, qualified.endIndex)).replace(/\s+/gu, "");
66
+ }
67
+ const FALLBACK_DECLARATION_TYPES = new Set([
68
+ "function_declaration",
69
+ "class_declaration",
70
+ "variable_declarator",
71
+ "interface_declaration",
72
+ "type_alias_declaration",
73
+ "function_definition",
74
+ "class_definition",
75
+ "assignment",
76
+ ]);
77
+ const FALLBACK_CLASS_TYPES = new Set(["class_declaration", "class_definition"]);
78
+ /** Ordinary JavaScript functions rebind `this`; arrow functions and class methods do not. */
79
+ const DYNAMIC_THIS_FUNCTION_TYPES = new Set([
80
+ "function_declaration",
81
+ "function_expression",
82
+ "function",
83
+ "generator_function",
84
+ "generator_function_declaration",
85
+ ]);
86
+ /**
87
+ * The declared name for a position on a declaration's own header (its keywords, name, or the
88
+ * space between them), and the enclosing class name for a JavaScript/TypeScript `this` whose
89
+ * value is lexically that class (not inside an ordinary nested function).
90
+ *
91
+ * A position inside the body or initializer is a use, not the declaration: `trim` in
92
+ * `const handle = value?.trim()` must never resolve to `handle`.
93
+ */
6
94
  export function findDeclarationNameNode(sup, currentNode) {
95
+ if (!currentNode)
96
+ return null;
97
+ const isThis = currentNode.type === "this";
7
98
  let current = currentNode;
8
99
  while (current) {
9
- if (current.type === "function_declaration" ||
10
- current.type === "class_declaration" ||
11
- current.type === "variable_declarator" ||
12
- current.type === "interface_declaration" ||
13
- current.type === "type_alias_declaration" ||
14
- current.type === "function_definition" ||
15
- current.type === "class_definition" ||
16
- current.type === "assignment") {
100
+ if (isThis && current !== currentNode && DYNAMIC_THIS_FUNCTION_TYPES.has(current.type))
101
+ return null;
102
+ // An object-literal method binds `this` to that object, not to the enclosing class.
103
+ if (isThis && current.type === "method_definition" && current.parent?.type !== "class_body")
104
+ return null;
105
+ if (FALLBACK_DECLARATION_TYPES.has(current.type)) {
17
106
  let named = current.childForFieldName("name");
18
107
  if (!named && current.type === "assignment") {
19
108
  const left = current.child(0);
@@ -21,7 +110,13 @@ export function findDeclarationNameNode(sup, currentNode) {
21
110
  named = left;
22
111
  }
23
112
  }
24
- if (named && sup.nodeTypes.identifier.includes(named.type)) {
113
+ const tail = current.childForFieldName("body") ??
114
+ current.childForFieldName("value") ??
115
+ (current.type === "assignment" ? current.childForFieldName("right") : null);
116
+ const headerEnd = tail ? tail.startIndex : current.endIndex;
117
+ const onHeader = currentNode === current || currentNode.endIndex <= headerEnd;
118
+ const ownClass = isThis && FALLBACK_CLASS_TYPES.has(current.type);
119
+ if (named && sup.nodeTypes.identifier.includes(named.type) && (onHeader || ownClass)) {
25
120
  return named;
26
121
  }
27
122
  }
@@ -38,37 +133,171 @@ export function getOrBuildScopeIndex(index, file, source, sup, mod, tree) {
38
133
  index.scopeCache.set(fileKey, scopeIndex);
39
134
  return scopeIndex;
40
135
  }
136
+ /** Python function bodies resolve module names when called, after module initialization. */
137
+ function pythonModuleLookupUsesRuntimeBindings(scope, node) {
138
+ for (let current = scope; current; current = current.parent) {
139
+ if (current.kind !== "function")
140
+ continue;
141
+ const body = current.node.childForFieldName("body");
142
+ if (!body)
143
+ return false;
144
+ return node.startIndex >= body.startIndex && node.endIndex <= body.endIndex;
145
+ }
146
+ return false;
147
+ }
148
+ function effectivePythonModuleScopeBinding(binding, useStartIndex, moduleLookupAtRuntime) {
149
+ let importBinding;
150
+ let importSource;
151
+ let localBinding;
152
+ let latestLocalStart = -1;
153
+ for (let candidate = binding; candidate; candidate = candidate.earlierSameScope) {
154
+ const localStart = candidate.def?.start.index;
155
+ if (localStart !== undefined &&
156
+ (moduleLookupAtRuntime || localStart <= useStartIndex) &&
157
+ localStart > latestLocalStart) {
158
+ localBinding = candidate;
159
+ latestLocalStart = localStart;
160
+ }
161
+ if (!importBinding && candidate.import) {
162
+ importBinding = candidate.import;
163
+ importSource = candidate;
164
+ }
165
+ }
166
+ const imports = importBinding ? [importBinding] : [];
167
+ const effective = effectiveExplicitOrLocalBinding(imports, "python", () => true, localBinding?.def?.start.index, useStartIndex, moduleLookupAtRuntime);
168
+ if (effective?.kind === "local")
169
+ return localBinding ?? null;
170
+ if (effective?.kind === "explicit")
171
+ return importSource ?? null;
172
+ return null;
173
+ }
41
174
  export function findClosestScopeBinding(scopeIndex, bindingName, currentNode, support) {
42
- const normalizedName = support.normalizeIdentifier(bindingName);
43
- let currentScope = scopeIndex.allScopes.find((scope) => {
44
- const start = scope.node.startIndex;
45
- const end = scope.node.endIndex;
46
- return currentNode.startIndex >= start && currentNode.endIndex <= end;
47
- });
48
- if (currentScope) {
49
- let best = currentScope;
50
- for (const scope of scopeIndex.allScopes) {
51
- if (currentNode.startIndex >= scope.node.startIndex &&
52
- currentNode.endIndex <= scope.node.endIndex &&
53
- scope.node.startIndex >= best.node.startIndex &&
54
- scope.node.endIndex <= best.node.endIndex) {
55
- best = scope;
56
- }
175
+ if (support.id === "csharp" && bindingName.includes(".")) {
176
+ const names = bindingName.split(".");
177
+ const first = names.shift();
178
+ let owner = findClosestScopeBinding(scopeIndex, first, currentNode, support);
179
+ for (const name of names) {
180
+ if (owner?.kind !== "class")
181
+ return null;
182
+ const body = owner.node?.parent?.childForFieldName("body");
183
+ if (!body)
184
+ return null;
185
+ const bodyScope = scopeIndex.allScopes.find((scope) => scope.node.id === body.id);
186
+ owner = bodyScope?.map.get(support.normalizeIdentifier(name)) ?? null;
57
187
  }
58
- currentScope = best;
188
+ return owner;
59
189
  }
190
+ const row = scopeNodesFor(support.id);
191
+ const canonicalName = scopeIdentifierKey(row, bindingName, currentNode, support.normalizeIdentifier);
192
+ const normalizedName = support.id === "c" && cTagRole(currentNode) ? cScopeName(canonicalName, "tag") : canonicalName;
193
+ let currentScope = closestContainingScope(scopeIndex, currentNode);
194
+ const methodCall = isExplicitMethodCall(row, currentNode);
195
+ const pythonModuleLookupAtRuntime = !!row.moduleBindingsAtFunctionRuntime && pythonModuleLookupUsesRuntimeBindings(currentScope, currentNode);
60
196
  while (currentScope) {
61
- const binding = currentScope.map.get(normalizedName);
197
+ if (!scopeAllowsUse(row, currentScope, currentNode)) {
198
+ currentScope = currentScope.parent;
199
+ continue;
200
+ }
201
+ let binding = currentScope.map.get(normalizedName);
202
+ if (!pythonModuleLookupAtRuntime || currentScope.kind !== "module" || methodCall) {
203
+ while (binding &&
204
+ ((methodCall && binding.kind === "local") ||
205
+ ((!pythonModuleLookupAtRuntime || currentScope.kind !== "module") &&
206
+ !bindingCoversUse(row, currentScope.kind, binding, currentNode.startIndex)))) {
207
+ binding = binding.earlierSameScope;
208
+ }
209
+ }
210
+ if (support.id === "python" && currentScope.kind === "module" && binding) {
211
+ const effectiveBinding = effectivePythonModuleScopeBinding(binding, currentNode.startIndex, pythonModuleLookupAtRuntime);
212
+ if (effectiveBinding)
213
+ return effectiveBinding;
214
+ currentScope = currentScope.parent;
215
+ continue;
216
+ }
62
217
  if (binding)
63
218
  return binding;
219
+ if (laterLocalBlocksOuterUse(row, currentScope, normalizedName, currentNode.startIndex))
220
+ return null;
64
221
  currentScope = currentScope.parent;
65
222
  }
66
223
  return null;
67
224
  }
68
- export function findClosestBinding(scopeIndex, file, bindingName, currentNode, support) {
225
+ /** A later C# local makes an earlier use invalid rather than binding to an outer member. */
226
+ export function laterLocalShadowsUse(scopeIndex, bindingName, currentNode, support) {
227
+ const row = scopeNodesFor(support.id);
228
+ if (!row.laterLocalBlocksOuterKinds)
229
+ return false;
230
+ const canonicalName = scopeIdentifierKey(row, bindingName, currentNode, support.normalizeIdentifier);
231
+ let scope = closestContainingScope(scopeIndex, currentNode);
232
+ while (scope) {
233
+ if (!scopeAllowsUse(row, scope, currentNode)) {
234
+ scope = scope.parent;
235
+ continue;
236
+ }
237
+ if (laterLocalBlocksOuterUse(row, scope, canonicalName, currentNode.startIndex))
238
+ return true;
239
+ let binding = scope.map.get(canonicalName);
240
+ while (binding && !bindingCoversUse(row, scope.kind, binding, currentNode.startIndex)) {
241
+ binding = binding.earlierSameScope;
242
+ }
243
+ if (binding)
244
+ return false;
245
+ scope = scope.parent;
246
+ }
247
+ return false;
248
+ }
249
+ function selectTypeScriptOverloadBinding(binding, file, currentNode, source, tree, languageId) {
250
+ const call = currentNode.parent;
251
+ if (!call || call.type !== "call_expression")
252
+ return binding;
253
+ const start = binding.def.start.index ?? 0;
254
+ const end = binding.def.end.index ?? start;
255
+ const candidates = typescriptCallableCandidatesInContainer(binding.sameScopeFunctionBindings ?? [binding], tree, (candidate) => candidate.def, start, end);
256
+ const selected = typescriptSelectOverloadCandidate({
257
+ group: candidates,
258
+ tree,
259
+ definitionOf: (candidate) => ({
260
+ file,
261
+ localName: candidate.name,
262
+ kind: SymbolKind.Function,
263
+ range: candidate.def,
264
+ }),
265
+ declarationOf: (candidate) => candidate.node?.parent,
266
+ source,
267
+ languageId,
268
+ argumentCount: getCallArgumentCount({ languageId, source, call }),
269
+ });
270
+ return selected ?? null;
271
+ }
272
+ export function findClosestBinding(scopeIndex, file, bindingName, currentNode, support, source, tree) {
69
273
  const binding = findClosestScopeBinding(scopeIndex, bindingName, currentNode, support);
70
- if (!binding?.def)
274
+ return binding ? definitionForBinding(binding, file, currentNode, support, source, tree) : null;
275
+ }
276
+ /** The definition a scope binding names at a use, choosing C++ and TypeScript overloads by arity. */
277
+ export function definitionForBinding(closest, file, currentNode, support, source, tree) {
278
+ let binding = closest;
279
+ if (!binding.def)
71
280
  return null;
281
+ if (support.id === "cpp" && binding.kind === "function" && source) {
282
+ const collisions = binding.sameScopeFunctionBindings ?? [binding];
283
+ if (collisions.length > 1 || cppBindingCallableShape(binding)) {
284
+ const selected = cppSelectCallableBinding(collisions, currentNode, source, file, file);
285
+ if (!selected?.def)
286
+ return null;
287
+ return {
288
+ file,
289
+ localName: selected.name,
290
+ kind: SymbolKind.Function,
291
+ range: selected.def,
292
+ };
293
+ }
294
+ }
295
+ if ((support.id === "ts" || support.id === "tsx") && binding.kind === "function" && source && tree) {
296
+ const selected = selectTypeScriptOverloadBinding(binding, file, currentNode, source, tree, support.id);
297
+ if (!selected?.def)
298
+ return null;
299
+ binding = selected;
300
+ }
72
301
  let kind = SymbolKind.Variable;
73
302
  if (binding.kind === "function") {
74
303
  kind = SymbolKind.Function;
@@ -79,11 +308,16 @@ export function findClosestBinding(scopeIndex, file, bindingName, currentNode, s
79
308
  else if (binding.kind === "type") {
80
309
  kind = SymbolKind.TypeAlias;
81
310
  }
311
+ const range = binding.def;
312
+ if (!range)
313
+ return null;
314
+ const tagRole = support.id === "c" && binding.node ? cTagRole(binding.node) : undefined;
82
315
  return {
83
316
  file,
84
317
  localName: binding.name,
85
318
  kind,
86
- range: binding.def,
319
+ range,
320
+ ...(tagRole ? { cTag: tagRole } : {}),
87
321
  };
88
322
  }
89
323
  export function toModuleRef(resolved) {
@@ -91,25 +325,95 @@ export function toModuleRef(resolved) {
91
325
  return undefined;
92
326
  return typeof resolved === "string" ? resolved : resolved.external;
93
327
  }
94
- export function resolveNamedDefinition(index, mod, file, support, name) {
328
+ function importBindingCoversIndex(imp, index) {
329
+ const ranges = [];
330
+ if ((imp.kind === "named" || imp.kind === "default" || imp.kind === "namespace") && imp.localRange) {
331
+ ranges.push(imp.localRange);
332
+ }
333
+ if (imp.kind === "named" && imp.importedRange)
334
+ ranges.push(imp.importedRange);
335
+ return ranges.some((range) => {
336
+ const start = range.start.index;
337
+ const end = range.end.index;
338
+ return start !== undefined && end !== undefined && index >= start && index < end;
339
+ });
340
+ }
341
+ function starImportGoTo(index, imp, def, name) {
342
+ return okGoToResult(index, def, {
343
+ via: {
344
+ ...(toModuleRef(imp.resolved) ? { importedFrom: toModuleRef(imp.resolved) } : {}),
345
+ exportedName: name,
346
+ },
347
+ resolution: "import-star",
348
+ confidence: "medium",
349
+ });
350
+ }
351
+ export function resolveNamedDefinition(index, mod, file, support, name, cNamespace, referenceIndex) {
95
352
  const normalizedName = support.normalizeIdentifier(name);
96
353
  const requiresExplicitReceiver = !support.membersAreImplicitlyInScope;
97
- const directExport = requiresExplicitReceiver
354
+ const directExport = requiresExplicitReceiver && support.id !== "c"
98
355
  ? mod.exports.find((entry) => entry.type === "local" &&
99
356
  support.normalizeIdentifier(entry.exportedAs) === normalizedName &&
100
357
  !entry.target.isMember)
101
358
  : undefined;
102
- const hit = directExport && directExport.type === "local"
103
- ? { kind: "resolved", def: directExport.target }
104
- : resolveExport(index, file, name, { allowLocalFallback: support.membersAreImplicitlyInScope });
105
- if (hit?.kind === "resolved" && (!requiresExplicitReceiver || !hit.def.isMember)) {
106
- return okGoToResult(index, hit.def, {
107
- via: { exportedName: name },
108
- resolution: "exact",
109
- confidence: "high",
359
+ const suppressCppUnqualifiedLocalExport = support.id === "cpp" && !name.includes("::");
360
+ let hit = null;
361
+ const precedence = starImportPrecedence(support.id);
362
+ const matchesExplicitBinding = (imp) => {
363
+ if (isExpandedStarBinding(imp, mod.imports))
364
+ return false;
365
+ if (imp.kind === "default")
366
+ return support.normalizeIdentifier(imp.local) === normalizedName;
367
+ if (imp.kind === "named")
368
+ return !imp.cNamespace && support.normalizeIdentifier(imp.local) === normalizedName;
369
+ return imp.kind === "namespace" && support.normalizeIdentifier(imp.localNS) === normalizedName;
370
+ };
371
+ // Explicit-beats-star languages: an explicit import, then the compilation unit (Java and
372
+ // Kotlin same-package peers), then a wildcard. resolveExport's compilation-unit hit must wait
373
+ // until explicit imports have had a chance to win and must still beat star imports. In Rust a
374
+ // `use` and a same-named local item are a compile error, so the order changes nothing there.
375
+ const deferCompilationUnitPeers = precedence === "explicit-beats-star";
376
+ if (!suppressCppUnqualifiedLocalExport) {
377
+ if (directExport && directExport.type === "local") {
378
+ hit = { kind: "resolved", def: directExport.target };
379
+ }
380
+ else if (!deferCompilationUnitPeers) {
381
+ hit = resolveExport(index, file, name, {
382
+ allowLocalFallback: support.membersAreImplicitlyInScope,
383
+ ...(cNamespace ? { cNamespace } : {}),
384
+ ...(support.id === "csharp" && referenceIndex !== undefined ? { referenceIndex } : {}),
385
+ });
386
+ }
387
+ }
388
+ const row = scopeNodesFor(support.id);
389
+ const moduleLookupAtRuntime = !!row.moduleBindingsAtFunctionRuntime &&
390
+ hit?.kind === "resolved" &&
391
+ referenceIndex !== undefined &&
392
+ fileIdentityKey(file) === fileIdentityKey(hit.def.file) &&
393
+ !!index.scopeCache.get(fileIdentityKey(file))?.allScopes.some((scope) => {
394
+ if (scope.kind !== "function")
395
+ return false;
396
+ const body = scope.node.childForFieldName("body");
397
+ return !!body && referenceIndex >= body.startIndex && referenceIndex < body.endIndex;
110
398
  });
399
+ const effectiveBinding = effectiveExplicitOrLocalBinding(mod.imports, support.id, matchesExplicitBinding, hit?.kind === "resolved" ? hit.def.range.start.index : undefined, referenceIndex, moduleLookupAtRuntime);
400
+ const effectiveExplicitImport = effectiveBinding?.kind === "explicit" ? effectiveBinding.binding : undefined;
401
+ if (hit?.kind === "resolved" && (!requiresExplicitReceiver || !hit.def.isMember)) {
402
+ const sameFileFallback = referenceIndex !== undefined && fileIdentityKey(file) === fileIdentityKey(hit.def.file);
403
+ if (sameFileFallback &&
404
+ !fileScopeDefinitionCoversUse(support.id, hit.def.range, referenceIndex, hit.def.kind, moduleLookupAtRuntime)) {
405
+ return null;
406
+ }
407
+ if (support.id !== "python" || effectiveBinding?.kind === "local") {
408
+ const importedFrom = support.id === "c" && fileIdentityKey(file) !== fileIdentityKey(hit.def.file) ? hit.def.file : undefined;
409
+ return okGoToResult(index, hit.def, {
410
+ via: { exportedName: name, ...(importedFrom ? { importedFrom } : {}) },
411
+ resolution: importedFrom ? "import" : "exact",
412
+ confidence: "high",
413
+ });
414
+ }
111
415
  }
112
- if (hit?.kind === "namespace") {
416
+ if (hit?.kind === "namespace" && effectiveBinding?.kind !== "explicit") {
113
417
  const targetMod = index.byFile.get(fileIdentityKey(hit.file));
114
418
  const firstExport = targetMod?.exports.find((entry) => entry.type === "local");
115
419
  if (firstExport) {
@@ -120,11 +424,32 @@ export function resolveNamedDefinition(index, mod, file, support, name) {
120
424
  });
121
425
  }
122
426
  }
427
+ const starCandidates = [];
428
+ let lastWinsResult = null;
429
+ const acceptBinding = (result, imp) => {
430
+ // A click on the binding's own token names that import, not a later rebinding.
431
+ if (precedence === "last-wins" && referenceIndex !== undefined && importBindingCoversIndex(imp, referenceIndex)) {
432
+ return result;
433
+ }
434
+ if (precedence === "last-wins") {
435
+ lastWinsResult = result;
436
+ return null;
437
+ }
438
+ return result;
439
+ };
123
440
  for (const imp of mod.imports) {
441
+ // Star expansion republishes the same names. Judging those copies as explicit
442
+ // imports would hide a second star import behind the first expanded binding.
443
+ if (isExpandedStarBinding(imp, mod.imports))
444
+ continue;
445
+ const matchesExplicit = matchesExplicitBinding(imp);
446
+ if (matchesExplicit && effectiveExplicitImport !== imp)
447
+ continue;
448
+ let matched = null;
124
449
  if (imp.kind === "default" && support.normalizeIdentifier(imp.local) === normalizedName) {
125
450
  const result = resolveImported(index, imp, "default");
126
451
  if (result && !("namespace" in result)) {
127
- return okGoToResult(index, result, {
452
+ matched = okGoToResult(index, result, {
128
453
  via: {
129
454
  ...(toModuleRef(imp.resolved) ? { importedFrom: toModuleRef(imp.resolved) } : {}),
130
455
  exportedName: "default",
@@ -135,9 +460,26 @@ export function resolveNamedDefinition(index, mod, file, support, name) {
135
460
  }
136
461
  }
137
462
  else if (imp.kind === "named" && support.normalizeIdentifier(imp.local) === normalizedName) {
138
- const result = resolveImported(index, imp, imp.imported);
463
+ const phpRole = phpNamedImportRole(imp);
464
+ let result;
465
+ if (phpRole) {
466
+ // This role-blind fallback cannot choose between PHP class, function, and constant aliases.
467
+ const hasPhpRoleCollision = mod.imports.some((candidate) => candidate !== imp &&
468
+ candidate.kind === "named" &&
469
+ phpNamedImportRole(candidate) !== undefined &&
470
+ support.normalizeIdentifier(candidate.local) === normalizedName);
471
+ if (hasPhpRoleCollision) {
472
+ result = null;
473
+ }
474
+ else {
475
+ result = resolvePhpExplicitImport(index, imp, phpRole);
476
+ }
477
+ }
478
+ else {
479
+ result = resolveImported(index, imp, imp.imported, cNamespace ? { cNamespace } : undefined);
480
+ }
139
481
  if (result && !("namespace" in result)) {
140
- return okGoToResult(index, result, {
482
+ matched = okGoToResult(index, result, {
141
483
  via: {
142
484
  ...(toModuleRef(imp.resolved) ? { importedFrom: toModuleRef(imp.resolved) } : {}),
143
485
  exportedName: imp.imported,
@@ -148,32 +490,127 @@ export function resolveNamedDefinition(index, mod, file, support, name) {
148
490
  }
149
491
  }
150
492
  else if (imp.kind === "star") {
151
- const result = resolveImported(index, imp, name);
493
+ const def = resolveStarImportedDefinition(index, imp, name, support.id, cNamespace);
494
+ if (def) {
495
+ const starResult = starImportGoTo(index, imp, def, name);
496
+ if (precedence === "last-wins") {
497
+ const taken = acceptBinding(starResult, imp);
498
+ if (taken)
499
+ return taken;
500
+ }
501
+ else {
502
+ starCandidates.push({ imp, def });
503
+ }
504
+ }
505
+ }
506
+ else if (imp.kind === "namespace" && support.normalizeIdentifier(imp.localNS) === normalizedName) {
507
+ const targetFile = typeof imp.resolved === "string" ? normalizePath(imp.resolved) : undefined;
508
+ if (imp.mechanism === "cjs" && targetFile) {
509
+ const classValue = cjsRequireValueBinding(index, targetFile);
510
+ if (classValue) {
511
+ matched = okGoToResult(index, classValue, {
512
+ via: {
513
+ ...(toModuleRef(imp.resolved) ? { importedFrom: toModuleRef(imp.resolved) } : {}),
514
+ exportedName: classValue.localName,
515
+ },
516
+ resolution: "import",
517
+ confidence: "high",
518
+ });
519
+ }
520
+ }
521
+ if (!matched) {
522
+ const targetMod = targetFile ? index.byFile.get(fileIdentityKey(targetFile)) : undefined;
523
+ const firstExport = targetMod?.exports.find((entry) => entry.type === "local");
524
+ if (firstExport) {
525
+ matched = okGoToResult(index, firstExport.target, {
526
+ via: {
527
+ ...(toModuleRef(imp.resolved) ? { importedFrom: toModuleRef(imp.resolved) } : {}),
528
+ exportedName: firstExport.exportedAs,
529
+ },
530
+ resolution: "namespace",
531
+ confidence: "medium",
532
+ });
533
+ }
534
+ }
535
+ }
536
+ if (!matched) {
537
+ if (matchesExplicit && effectiveExplicitImport === imp) {
538
+ if (precedence !== "last-wins")
539
+ return null;
540
+ lastWinsResult = null;
541
+ }
542
+ continue;
543
+ }
544
+ const taken = acceptBinding(matched, imp);
545
+ if (taken)
546
+ return taken;
547
+ }
548
+ // A local binding name always wins above so a grouped import's own aliases never collide with
549
+ // each other. An aliased import's source spelling is not itself a bound name anywhere in the
550
+ // file (Python: `from a import helper as h` binds only `h`; a bare `helper()` elsewhere is
551
+ // unbound and must stay not_found), so only resolve it when the click falls inside that exact
552
+ // import statement's own source-name token, never by re-matching the spelling anywhere else.
553
+ if (referenceIndex !== undefined) {
554
+ for (const imp of mod.imports) {
555
+ if (imp.kind !== "named" ||
556
+ imp.local === imp.imported ||
557
+ support.normalizeIdentifier(imp.imported) !== normalizedName ||
558
+ !imp.importedRange ||
559
+ imp.importedRange.start.index === undefined ||
560
+ imp.importedRange.end.index === undefined ||
561
+ referenceIndex < imp.importedRange.start.index ||
562
+ referenceIndex >= imp.importedRange.end.index) {
563
+ continue;
564
+ }
565
+ const result = resolveImported(index, imp, imp.imported, cNamespace ? { cNamespace } : undefined);
152
566
  if (result && !("namespace" in result)) {
153
567
  return okGoToResult(index, result, {
154
568
  via: {
155
569
  ...(toModuleRef(imp.resolved) ? { importedFrom: toModuleRef(imp.resolved) } : {}),
156
- exportedName: name,
570
+ exportedName: imp.imported,
157
571
  },
158
- resolution: "import-star",
159
- confidence: "medium",
572
+ resolution: "import",
573
+ confidence: "high",
160
574
  });
161
575
  }
162
576
  }
163
- else if (imp.kind === "namespace" && support.normalizeIdentifier(imp.localNS) === normalizedName) {
164
- const targetFile = typeof imp.resolved === "string" ? normalizePath(imp.resolved) : undefined;
165
- const targetMod = targetFile ? index.byFile.get(fileIdentityKey(targetFile)) : undefined;
166
- const firstExport = targetMod?.exports.find((entry) => entry.type === "local");
167
- if (firstExport) {
168
- return okGoToResult(index, firstExport.target, {
169
- via: {
170
- ...(toModuleRef(imp.resolved) ? { importedFrom: toModuleRef(imp.resolved) } : {}),
171
- exportedName: firstExport.exportedAs,
172
- },
173
- resolution: "namespace",
174
- confidence: "medium",
577
+ }
578
+ if (precedence === "last-wins") {
579
+ if (lastWinsResult)
580
+ return lastWinsResult;
581
+ }
582
+ else {
583
+ if (deferCompilationUnitPeers) {
584
+ const unitHit = resolveExport(index, file, name, {
585
+ allowLocalFallback: support.membersAreImplicitlyInScope,
586
+ });
587
+ if (unitHit?.kind === "resolved" && (!requiresExplicitReceiver || !unitHit.def.isMember)) {
588
+ return okGoToResult(index, unitHit.def, {
589
+ via: { exportedName: name },
590
+ resolution: "exact",
591
+ confidence: "high",
175
592
  });
176
593
  }
594
+ if (unitHit?.kind === "namespace") {
595
+ const targetMod = index.byFile.get(fileIdentityKey(unitHit.file));
596
+ const firstExport = targetMod?.exports.find((entry) => entry.type === "local");
597
+ if (firstExport) {
598
+ return okGoToResult(index, firstExport.target, {
599
+ via: { exportedName: name },
600
+ resolution: "namespace",
601
+ confidence: "medium",
602
+ });
603
+ }
604
+ }
605
+ }
606
+ if (!starCandidates.length)
607
+ return null;
608
+ const decision = decideStarImportCandidates(index, support.id, starCandidates, file);
609
+ if (decision.status === "ambiguous") {
610
+ return { status: "not_found", reason: AMBIGUOUS_STAR_IMPORT_REASON };
611
+ }
612
+ if (decision.status === "resolved") {
613
+ return starImportGoTo(index, decision.imp, decision.definition, name);
177
614
  }
178
615
  }
179
616
  return null;