@lzehrung/codegraph 2.3.31 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (596) hide show
  1. package/README.md +33 -141
  2. package/codegraph-skill/codegraph/SKILL.md +8 -6
  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/call-hierarchy.js +2 -4
  7. package/dist/agent/call-hierarchy.js.map +1 -1
  8. package/dist/agent/explore.d.ts +1 -1
  9. package/dist/agent/explore.d.ts.map +1 -1
  10. package/dist/agent/explore.js +3 -2
  11. package/dist/agent/explore.js.map +1 -1
  12. package/dist/agent/refactor-plan.js +2 -4
  13. package/dist/agent/refactor-plan.js.map +1 -1
  14. package/dist/agent/rename-preview.d.ts.map +1 -1
  15. package/dist/agent/rename-preview.js +4 -3
  16. package/dist/agent/rename-preview.js.map +1 -1
  17. package/dist/agent/search.d.ts.map +1 -1
  18. package/dist/agent/search.js +5 -3
  19. package/dist/agent/search.js.map +1 -1
  20. package/dist/agent/semantic-symbols.d.ts.map +1 -1
  21. package/dist/agent/semantic-symbols.js +2 -3
  22. package/dist/agent/semantic-symbols.js.map +1 -1
  23. package/dist/agent/session.d.ts +3 -0
  24. package/dist/agent/session.d.ts.map +1 -1
  25. package/dist/agent/session.js +10 -2
  26. package/dist/agent/session.js.map +1 -1
  27. package/dist/agent/type-hierarchy.js +2 -4
  28. package/dist/agent/type-hierarchy.js.map +1 -1
  29. package/dist/agent/workspace-symbols.d.ts.map +1 -1
  30. package/dist/agent/workspace-symbols.js +2 -3
  31. package/dist/agent/workspace-symbols.js.map +1 -1
  32. package/dist/agent-tools.d.ts +0 -4
  33. package/dist/agent-tools.d.ts.map +1 -1
  34. package/dist/agent-tools.js +3 -6
  35. package/dist/agent-tools.js.map +1 -1
  36. package/dist/analysis-summary.d.ts +8 -4
  37. package/dist/analysis-summary.d.ts.map +1 -1
  38. package/dist/analysis-summary.js +15 -66
  39. package/dist/analysis-summary.js.map +1 -1
  40. package/dist/bin/cli.js +51145 -41770
  41. package/dist/bin/query-index-worker.js +122 -82
  42. package/dist/cli/affected.d.ts.map +1 -1
  43. package/dist/cli/affected.js +4 -1
  44. package/dist/cli/affected.js.map +1 -1
  45. package/dist/cli/command-catalog.js +1 -1
  46. package/dist/cli/command-catalog.js.map +1 -1
  47. package/dist/cli/command-table.d.ts.map +1 -1
  48. package/dist/cli/command-table.js +9 -17
  49. package/dist/cli/command-table.js.map +1 -1
  50. package/dist/cli/context.js +10 -10
  51. package/dist/cli/context.js.map +1 -1
  52. package/dist/cli/drift.d.ts +0 -2
  53. package/dist/cli/drift.d.ts.map +1 -1
  54. package/dist/cli/drift.js +0 -1
  55. package/dist/cli/drift.js.map +1 -1
  56. package/dist/cli/graph-delta.d.ts +0 -2
  57. package/dist/cli/graph-delta.d.ts.map +1 -1
  58. package/dist/cli/graph-delta.js +0 -4
  59. package/dist/cli/graph-delta.js.map +1 -1
  60. package/dist/cli/graph-queries.d.ts.map +1 -1
  61. package/dist/cli/graph-queries.js +27 -1
  62. package/dist/cli/graph-queries.js.map +1 -1
  63. package/dist/cli/graph.d.ts +0 -3
  64. package/dist/cli/graph.d.ts.map +1 -1
  65. package/dist/cli/graph.js +4 -14
  66. package/dist/cli/graph.js.map +1 -1
  67. package/dist/cli/help.d.ts +34 -34
  68. package/dist/cli/help.d.ts.map +1 -1
  69. package/dist/cli/help.js +9 -14
  70. package/dist/cli/help.js.map +1 -1
  71. package/dist/cli/impact.d.ts +0 -2
  72. package/dist/cli/impact.d.ts.map +1 -1
  73. package/dist/cli/impact.js +0 -1
  74. package/dist/cli/impact.js.map +1 -1
  75. package/dist/cli/index.d.ts +0 -2
  76. package/dist/cli/index.d.ts.map +1 -1
  77. package/dist/cli/index.js +5 -6
  78. package/dist/cli/index.js.map +1 -1
  79. package/dist/cli/inspect.d.ts +0 -2
  80. package/dist/cli/inspect.d.ts.map +1 -1
  81. package/dist/cli/inspect.js +5 -8
  82. package/dist/cli/inspect.js.map +1 -1
  83. package/dist/cli/invocation-context.d.ts +0 -3
  84. package/dist/cli/invocation-context.d.ts.map +1 -1
  85. package/dist/cli/invocation-context.js +4 -16
  86. package/dist/cli/invocation-context.js.map +1 -1
  87. package/dist/cli/navigation.d.ts +0 -2
  88. package/dist/cli/navigation.d.ts.map +1 -1
  89. package/dist/cli/navigation.js +0 -1
  90. package/dist/cli/navigation.js.map +1 -1
  91. package/dist/cli/options.d.ts.map +1 -1
  92. package/dist/cli/options.js +4 -14
  93. package/dist/cli/options.js.map +1 -1
  94. package/dist/cli/review.d.ts +0 -2
  95. package/dist/cli/review.d.ts.map +1 -1
  96. package/dist/cli/review.js +0 -5
  97. package/dist/cli/review.js.map +1 -1
  98. package/dist/cli/root-policy.d.ts +0 -2
  99. package/dist/cli/root-policy.d.ts.map +1 -1
  100. package/dist/cli/root-policy.js +0 -8
  101. package/dist/cli/root-policy.js.map +1 -1
  102. package/dist/cli/server.d.ts.map +1 -1
  103. package/dist/cli/server.js +0 -2
  104. package/dist/cli/server.js.map +1 -1
  105. package/dist/drift/artifact.d.ts.map +1 -1
  106. package/dist/drift/artifact.js +15 -18
  107. package/dist/drift/artifact.js.map +1 -1
  108. package/dist/drift/compare.js +1 -1
  109. package/dist/drift/compare.js.map +1 -1
  110. package/dist/drift/git.d.ts.map +1 -1
  111. package/dist/drift/git.js +0 -1
  112. package/dist/drift/git.js.map +1 -1
  113. package/dist/drift/snapshot.d.ts.map +1 -1
  114. package/dist/drift/snapshot.js +5 -7
  115. package/dist/drift/snapshot.js.map +1 -1
  116. package/dist/drift/types.d.ts +2 -2
  117. package/dist/drift/types.d.ts.map +1 -1
  118. package/dist/drift/types.js.map +1 -1
  119. package/dist/duplicates/unit-cache.d.ts +0 -1
  120. package/dist/duplicates/unit-cache.d.ts.map +1 -1
  121. package/dist/duplicates/unit-cache.js +3 -11
  122. package/dist/duplicates/unit-cache.js.map +1 -1
  123. package/dist/duplicates/units.d.ts +5 -5
  124. package/dist/duplicates/units.d.ts.map +1 -1
  125. package/dist/duplicates/units.js +25 -88
  126. package/dist/duplicates/units.js.map +1 -1
  127. package/dist/graph-builder.d.ts +0 -6
  128. package/dist/graph-builder.d.ts.map +1 -1
  129. package/dist/graph-builder.js +6 -11
  130. package/dist/graph-builder.js.map +1 -1
  131. package/dist/graph-edge-collector.d.ts +4 -6
  132. package/dist/graph-edge-collector.d.ts.map +1 -1
  133. package/dist/graph-edge-collector.js +31 -26
  134. package/dist/graph-edge-collector.js.map +1 -1
  135. package/dist/graphs/angularjs.d.ts.map +1 -1
  136. package/dist/graphs/angularjs.js +2 -1
  137. package/dist/graphs/angularjs.js.map +1 -1
  138. package/dist/graphs/edge-resolution.d.ts +4 -1
  139. package/dist/graphs/edge-resolution.d.ts.map +1 -1
  140. package/dist/graphs/edge-resolution.js +24 -76
  141. package/dist/graphs/edge-resolution.js.map +1 -1
  142. package/dist/graphs/specifiers.d.ts +4 -13
  143. package/dist/graphs/specifiers.d.ts.map +1 -1
  144. package/dist/graphs/specifiers.js +80 -173
  145. package/dist/graphs/specifiers.js.map +1 -1
  146. package/dist/graphs/symbol-graph-detailed/ast.d.ts +20 -0
  147. package/dist/graphs/symbol-graph-detailed/ast.d.ts.map +1 -1
  148. package/dist/graphs/symbol-graph-detailed/ast.js +154 -15
  149. package/dist/graphs/symbol-graph-detailed/ast.js.map +1 -1
  150. package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts +60 -8
  151. package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts.map +1 -1
  152. package/dist/graphs/symbol-graph-detailed/edge-passes.js +997 -168
  153. package/dist/graphs/symbol-graph-detailed/edge-passes.js.map +1 -1
  154. package/dist/graphs/symbol-graph-detailed/import-aliases.d.ts +2 -1
  155. package/dist/graphs/symbol-graph-detailed/import-aliases.d.ts.map +1 -1
  156. package/dist/graphs/symbol-graph-detailed/import-aliases.js +150 -7
  157. package/dist/graphs/symbol-graph-detailed/import-aliases.js.map +1 -1
  158. package/dist/graphs/symbol-graph-detailed/member-chains.d.ts +1 -0
  159. package/dist/graphs/symbol-graph-detailed/member-chains.d.ts.map +1 -1
  160. package/dist/graphs/symbol-graph-detailed/member-chains.js +3 -1
  161. package/dist/graphs/symbol-graph-detailed/member-chains.js.map +1 -1
  162. package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts +141 -25
  163. package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts.map +1 -1
  164. package/dist/graphs/symbol-graph-detailed/receiver-calls.js +1015 -166
  165. package/dist/graphs/symbol-graph-detailed/receiver-calls.js.map +1 -1
  166. package/dist/graphs/symbol-graph-detailed.d.ts.map +1 -1
  167. package/dist/graphs/symbol-graph-detailed.js +449 -46
  168. package/dist/graphs/symbol-graph-detailed.js.map +1 -1
  169. package/dist/graphs/symbol-graph.d.ts +2 -0
  170. package/dist/graphs/symbol-graph.d.ts.map +1 -1
  171. package/dist/graphs/symbol-graph.js +34 -16
  172. package/dist/graphs/symbol-graph.js.map +1 -1
  173. package/dist/graphs/types.d.ts +0 -4
  174. package/dist/graphs/types.d.ts.map +1 -1
  175. package/dist/graphs.d.ts +1 -1
  176. package/dist/graphs.d.ts.map +1 -1
  177. package/dist/impact/call-compatibility/providers/index.d.ts +4 -4
  178. package/dist/impact/call-compatibility/providers/index.d.ts.map +1 -1
  179. package/dist/impact/call-compatibility/providers/index.js +6 -6
  180. package/dist/impact/call-compatibility/providers/index.js.map +1 -1
  181. package/dist/impact/call-compatibility/providers/types.d.ts +2 -0
  182. package/dist/impact/call-compatibility/providers/types.d.ts.map +1 -1
  183. package/dist/impact/call-compatibility/types.d.ts +6 -0
  184. package/dist/impact/call-compatibility/types.d.ts.map +1 -1
  185. package/dist/impact/call-compatibility.d.ts.map +1 -1
  186. package/dist/impact/call-compatibility.js +316 -526
  187. package/dist/impact/call-compatibility.js.map +1 -1
  188. package/dist/impact/map.js +1 -0
  189. package/dist/impact/map.js.map +1 -1
  190. package/dist/impact/reference-cache.d.ts.map +1 -1
  191. package/dist/impact/reference-cache.js +2 -2
  192. package/dist/impact/reference-cache.js.map +1 -1
  193. package/dist/index.d.ts +2 -2
  194. package/dist/index.d.ts.map +1 -1
  195. package/dist/index.js +1 -1
  196. package/dist/index.js.map +1 -1
  197. package/dist/indexer/ambiguous-resolution.d.ts +11 -0
  198. package/dist/indexer/ambiguous-resolution.d.ts.map +1 -0
  199. package/dist/indexer/ambiguous-resolution.js +19 -0
  200. package/dist/indexer/ambiguous-resolution.js.map +1 -0
  201. package/dist/indexer/build-cache/module-cache.d.ts +39 -1
  202. package/dist/indexer/build-cache/module-cache.d.ts.map +1 -1
  203. package/dist/indexer/build-cache/module-cache.js +218 -21
  204. package/dist/indexer/build-cache/module-cache.js.map +1 -1
  205. package/dist/indexer/build-cache/options.d.ts +30 -44
  206. package/dist/indexer/build-cache/options.d.ts.map +1 -1
  207. package/dist/indexer/build-cache/options.js +32 -71
  208. package/dist/indexer/build-cache/options.js.map +1 -1
  209. package/dist/indexer/build-cache/project-snapshot.d.ts +3 -3
  210. package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -1
  211. package/dist/indexer/build-cache/project-snapshot.js +164 -84
  212. package/dist/indexer/build-cache/project-snapshot.js.map +1 -1
  213. package/dist/indexer/build-cache/reports.d.ts +0 -2
  214. package/dist/indexer/build-cache/reports.d.ts.map +1 -1
  215. package/dist/indexer/build-cache/reports.js +0 -97
  216. package/dist/indexer/build-cache/reports.js.map +1 -1
  217. package/dist/indexer/build-cache/resolver-environment.d.ts.map +1 -1
  218. package/dist/indexer/build-cache/resolver-environment.js +32 -2
  219. package/dist/indexer/build-cache/resolver-environment.js.map +1 -1
  220. package/dist/indexer/build-cache.d.ts +2 -2
  221. package/dist/indexer/build-cache.d.ts.map +1 -1
  222. package/dist/indexer/build-cache.js +2 -2
  223. package/dist/indexer/build-cache.js.map +1 -1
  224. package/dist/indexer/build-index.d.ts.map +1 -1
  225. package/dist/indexer/build-index.js +656 -71
  226. package/dist/indexer/build-index.js.map +1 -1
  227. package/dist/indexer/build-workers.d.ts.map +1 -1
  228. package/dist/indexer/build-workers.js +9 -9
  229. package/dist/indexer/build-workers.js.map +1 -1
  230. package/dist/indexer/call-hierarchy.js +1 -1
  231. package/dist/indexer/call-hierarchy.js.map +1 -1
  232. package/dist/indexer/callable-identity.d.ts +24 -0
  233. package/dist/indexer/callable-identity.d.ts.map +1 -0
  234. package/dist/indexer/callable-identity.js +111 -0
  235. package/dist/indexer/callable-identity.js.map +1 -0
  236. package/dist/indexer/compilation-units.d.ts +103 -0
  237. package/dist/indexer/compilation-units.d.ts.map +1 -0
  238. package/dist/indexer/compilation-units.js +607 -0
  239. package/dist/indexer/compilation-units.js.map +1 -0
  240. package/dist/indexer/cpp-callables.d.ts +25 -0
  241. package/dist/indexer/cpp-callables.d.ts.map +1 -0
  242. package/dist/indexer/cpp-callables.js +562 -0
  243. package/dist/indexer/cpp-callables.js.map +1 -0
  244. package/dist/indexer/declaration-visibility.d.ts +43 -2
  245. package/dist/indexer/declaration-visibility.d.ts.map +1 -1
  246. package/dist/indexer/declaration-visibility.js +158 -2
  247. package/dist/indexer/declaration-visibility.js.map +1 -1
  248. package/dist/indexer/expand-star-imports.d.ts +6 -1
  249. package/dist/indexer/expand-star-imports.d.ts.map +1 -1
  250. package/dist/indexer/expand-star-imports.js +131 -37
  251. package/dist/indexer/expand-star-imports.js.map +1 -1
  252. package/dist/indexer/finalize.d.ts.map +1 -1
  253. package/dist/indexer/finalize.js +0 -1
  254. package/dist/indexer/finalize.js.map +1 -1
  255. package/dist/indexer/import-resolution-tables.d.ts +72 -0
  256. package/dist/indexer/import-resolution-tables.d.ts.map +1 -0
  257. package/dist/indexer/import-resolution-tables.js +137 -0
  258. package/dist/indexer/import-resolution-tables.js.map +1 -0
  259. package/dist/indexer/import-types.d.ts +54 -0
  260. package/dist/indexer/import-types.d.ts.map +1 -1
  261. package/dist/indexer/import-types.js +24 -1
  262. package/dist/indexer/import-types.js.map +1 -1
  263. package/dist/indexer/imports/context.d.ts +16 -1
  264. package/dist/indexer/imports/context.d.ts.map +1 -1
  265. package/dist/indexer/imports/import-binding-tables.d.ts +13 -1
  266. package/dist/indexer/imports/import-binding-tables.d.ts.map +1 -1
  267. package/dist/indexer/imports/import-binding-tables.js +149 -30
  268. package/dist/indexer/imports/import-binding-tables.js.map +1 -1
  269. package/dist/indexer/imports/js-text-imports.js +4 -4
  270. package/dist/indexer/imports/js-text-imports.js.map +1 -1
  271. package/dist/indexer/imports/native-captures.d.ts.map +1 -1
  272. package/dist/indexer/imports/native-captures.js +24 -6
  273. package/dist/indexer/imports/native-captures.js.map +1 -1
  274. package/dist/indexer/imports/python.d.ts +10 -2
  275. package/dist/indexer/imports/python.d.ts.map +1 -1
  276. package/dist/indexer/imports/python.js +128 -112
  277. package/dist/indexer/imports/python.js.map +1 -1
  278. package/dist/indexer/imports/text-import-extractors.d.ts.map +1 -1
  279. package/dist/indexer/imports/text-import-extractors.js +68 -19
  280. package/dist/indexer/imports/text-import-extractors.js.map +1 -1
  281. package/dist/indexer/imports.d.ts +3 -4
  282. package/dist/indexer/imports.d.ts.map +1 -1
  283. package/dist/indexer/imports.js +116 -72
  284. package/dist/indexer/imports.js.map +1 -1
  285. package/dist/indexer/incremental-plan.d.ts +33 -0
  286. package/dist/indexer/incremental-plan.d.ts.map +1 -1
  287. package/dist/indexer/incremental-plan.js +203 -1
  288. package/dist/indexer/incremental-plan.js.map +1 -1
  289. package/dist/indexer/locals-and-exports.d.ts +3 -2
  290. package/dist/indexer/locals-and-exports.d.ts.map +1 -1
  291. package/dist/indexer/locals-and-exports.js +659 -78
  292. package/dist/indexer/locals-and-exports.js.map +1 -1
  293. package/dist/indexer/member-selection.d.ts +46 -0
  294. package/dist/indexer/member-selection.d.ts.map +1 -0
  295. package/dist/indexer/member-selection.js +169 -0
  296. package/dist/indexer/member-selection.js.map +1 -0
  297. package/dist/indexer/name-lookup-policies/c-family.d.ts +7 -0
  298. package/dist/indexer/name-lookup-policies/c-family.d.ts.map +1 -0
  299. package/dist/indexer/name-lookup-policies/c-family.js +137 -0
  300. package/dist/indexer/name-lookup-policies/c-family.js.map +1 -0
  301. package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts +11 -0
  302. package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts.map +1 -0
  303. package/dist/indexer/name-lookup-policies/csharp-using-static.js +136 -0
  304. package/dist/indexer/name-lookup-policies/csharp-using-static.js.map +1 -0
  305. package/dist/indexer/name-lookup-policies/implicit-self.d.ts +10 -0
  306. package/dist/indexer/name-lookup-policies/implicit-self.d.ts.map +1 -0
  307. package/dist/indexer/name-lookup-policies/implicit-self.js +119 -0
  308. package/dist/indexer/name-lookup-policies/implicit-self.js.map +1 -0
  309. package/dist/indexer/name-lookup-policies/index.d.ts +3 -0
  310. package/dist/indexer/name-lookup-policies/index.d.ts.map +1 -0
  311. package/dist/indexer/name-lookup-policies/index.js +132 -0
  312. package/dist/indexer/name-lookup-policies/index.js.map +1 -0
  313. package/dist/indexer/name-lookup-policies/php.d.ts +3 -0
  314. package/dist/indexer/name-lookup-policies/php.d.ts.map +1 -0
  315. package/dist/indexer/name-lookup-policies/php.js +82 -0
  316. package/dist/indexer/name-lookup-policies/php.js.map +1 -0
  317. package/dist/indexer/name-resolution-types.d.ts +101 -0
  318. package/dist/indexer/name-resolution-types.d.ts.map +1 -0
  319. package/dist/indexer/name-resolution-types.js +2 -0
  320. package/dist/indexer/name-resolution-types.js.map +1 -0
  321. package/dist/indexer/name-resolution.d.ts +57 -0
  322. package/dist/indexer/name-resolution.d.ts.map +1 -0
  323. package/dist/indexer/name-resolution.js +204 -0
  324. package/dist/indexer/name-resolution.js.map +1 -0
  325. package/dist/indexer/navigation-cpp.d.ts +58 -0
  326. package/dist/indexer/navigation-cpp.d.ts.map +1 -0
  327. package/dist/indexer/navigation-cpp.js +935 -0
  328. package/dist/indexer/navigation-cpp.js.map +1 -0
  329. package/dist/indexer/navigation-goto.d.ts +115 -3
  330. package/dist/indexer/navigation-goto.d.ts.map +1 -1
  331. package/dist/indexer/navigation-goto.js +2469 -190
  332. package/dist/indexer/navigation-goto.js.map +1 -1
  333. package/dist/indexer/navigation-local.d.ts +21 -2
  334. package/dist/indexer/navigation-local.d.ts.map +1 -1
  335. package/dist/indexer/navigation-local.js +520 -63
  336. package/dist/indexer/navigation-local.js.map +1 -1
  337. package/dist/indexer/navigation-php.d.ts +66 -0
  338. package/dist/indexer/navigation-php.d.ts.map +1 -1
  339. package/dist/indexer/navigation-php.js +287 -4
  340. package/dist/indexer/navigation-php.js.map +1 -1
  341. package/dist/indexer/navigation-provenance.d.ts +1 -1
  342. package/dist/indexer/navigation-provenance.d.ts.map +1 -1
  343. package/dist/indexer/navigation-provenance.js +4 -13
  344. package/dist/indexer/navigation-provenance.js.map +1 -1
  345. package/dist/indexer/navigation-references.d.ts +73 -6
  346. package/dist/indexer/navigation-references.d.ts.map +1 -1
  347. package/dist/indexer/navigation-references.js +661 -67
  348. package/dist/indexer/navigation-references.js.map +1 -1
  349. package/dist/indexer/navigation-resolve.d.ts +46 -2
  350. package/dist/indexer/navigation-resolve.d.ts.map +1 -1
  351. package/dist/indexer/navigation-resolve.js +599 -193
  352. package/dist/indexer/navigation-resolve.js.map +1 -1
  353. package/dist/indexer/navigation.d.ts +29 -2
  354. package/dist/indexer/navigation.d.ts.map +1 -1
  355. package/dist/indexer/navigation.js +1092 -153
  356. package/dist/indexer/navigation.js.map +1 -1
  357. package/dist/indexer/parse-context.d.ts +2 -3
  358. package/dist/indexer/parse-context.d.ts.map +1 -1
  359. package/dist/indexer/parse-context.js +8 -21
  360. package/dist/indexer/parse-context.js.map +1 -1
  361. package/dist/indexer/php-namespace-symbols.d.ts +66 -0
  362. package/dist/indexer/php-namespace-symbols.d.ts.map +1 -0
  363. package/dist/indexer/php-namespace-symbols.js +342 -0
  364. package/dist/indexer/php-namespace-symbols.js.map +1 -0
  365. package/dist/indexer/reference-candidates.d.ts.map +1 -1
  366. package/dist/indexer/reference-candidates.js +13 -7
  367. package/dist/indexer/reference-candidates.js.map +1 -1
  368. package/dist/indexer/reference-context.d.ts +2 -0
  369. package/dist/indexer/reference-context.d.ts.map +1 -1
  370. package/dist/indexer/reference-context.js +4 -0
  371. package/dist/indexer/reference-context.js.map +1 -1
  372. package/dist/indexer/scope-nodes.d.ts +92 -13
  373. package/dist/indexer/scope-nodes.d.ts.map +1 -1
  374. package/dist/indexer/scope-nodes.js +212 -20
  375. package/dist/indexer/scope-nodes.js.map +1 -1
  376. package/dist/indexer/scope-types.d.ts +29 -1
  377. package/dist/indexer/scope-types.d.ts.map +1 -1
  378. package/dist/indexer/scope.d.ts +2 -3
  379. package/dist/indexer/scope.d.ts.map +1 -1
  380. package/dist/indexer/scope.js +968 -47
  381. package/dist/indexer/scope.js.map +1 -1
  382. package/dist/indexer/shared-owner-identity.d.ts +53 -0
  383. package/dist/indexer/shared-owner-identity.d.ts.map +1 -0
  384. package/dist/indexer/shared-owner-identity.js +460 -0
  385. package/dist/indexer/shared-owner-identity.js.map +1 -0
  386. package/dist/indexer/shared.d.ts +1 -1
  387. package/dist/indexer/shared.d.ts.map +1 -1
  388. package/dist/indexer/shared.js +1 -1
  389. package/dist/indexer/shared.js.map +1 -1
  390. package/dist/indexer/star-import-precedence.d.ts +113 -0
  391. package/dist/indexer/star-import-precedence.d.ts.map +1 -0
  392. package/dist/indexer/star-import-precedence.js +402 -0
  393. package/dist/indexer/star-import-precedence.js.map +1 -0
  394. package/dist/indexer/symbols.d.ts +3 -1
  395. package/dist/indexer/symbols.d.ts.map +1 -1
  396. package/dist/indexer/symbols.js +58 -18
  397. package/dist/indexer/symbols.js.map +1 -1
  398. package/dist/indexer/ts-callables.d.ts +42 -0
  399. package/dist/indexer/ts-callables.d.ts.map +1 -0
  400. package/dist/indexer/ts-callables.js +233 -0
  401. package/dist/indexer/ts-callables.js.map +1 -0
  402. package/dist/indexer/types.d.ts +41 -26
  403. package/dist/indexer/types.d.ts.map +1 -1
  404. package/dist/indexer/unused-exports.d.ts +13 -0
  405. package/dist/indexer/unused-exports.d.ts.map +1 -0
  406. package/dist/indexer/unused-exports.js +159 -0
  407. package/dist/indexer/unused-exports.js.map +1 -0
  408. package/dist/indexer/workspace-symbols.d.ts.map +1 -1
  409. package/dist/indexer/workspace-symbols.js +3 -2
  410. package/dist/indexer/workspace-symbols.js.map +1 -1
  411. package/dist/indexer.d.ts +3 -8
  412. package/dist/indexer.d.ts.map +1 -1
  413. package/dist/indexer.js +1 -1
  414. package/dist/indexer.js.map +1 -1
  415. package/dist/languages/callable-arity.d.ts +223 -0
  416. package/dist/languages/callable-arity.d.ts.map +1 -0
  417. package/dist/languages/callable-arity.js +1199 -0
  418. package/dist/languages/callable-arity.js.map +1 -0
  419. package/dist/languages/definitions/c-family.d.ts.map +1 -1
  420. package/dist/languages/definitions/c-family.js +30 -1
  421. package/dist/languages/definitions/c-family.js.map +1 -1
  422. package/dist/languages/definitions/c.d.ts +4 -0
  423. package/dist/languages/definitions/c.d.ts.map +1 -1
  424. package/dist/languages/definitions/c.js +19 -0
  425. package/dist/languages/definitions/c.js.map +1 -1
  426. package/dist/languages/definitions/cpp.d.ts.map +1 -1
  427. package/dist/languages/definitions/cpp.js +12 -0
  428. package/dist/languages/definitions/cpp.js.map +1 -1
  429. package/dist/languages/definitions/csharp.d.ts.map +1 -1
  430. package/dist/languages/definitions/csharp.js +2 -8
  431. package/dist/languages/definitions/csharp.js.map +1 -1
  432. package/dist/languages/definitions/go.d.ts.map +1 -1
  433. package/dist/languages/definitions/go.js +3 -0
  434. package/dist/languages/definitions/go.js.map +1 -1
  435. package/dist/languages/definitions/javascript.d.ts.map +1 -1
  436. package/dist/languages/definitions/javascript.js +10 -1
  437. package/dist/languages/definitions/javascript.js.map +1 -1
  438. package/dist/languages/definitions/js-family.d.ts +1 -1
  439. package/dist/languages/definitions/js-family.d.ts.map +1 -1
  440. package/dist/languages/definitions/js-family.js +7 -1
  441. package/dist/languages/definitions/js-family.js.map +1 -1
  442. package/dist/languages/definitions/php.d.ts.map +1 -1
  443. package/dist/languages/definitions/php.js +5 -1
  444. package/dist/languages/definitions/php.js.map +1 -1
  445. package/dist/languages/definitions/typescript.d.ts.map +1 -1
  446. package/dist/languages/definitions/typescript.js +8 -1
  447. package/dist/languages/definitions/typescript.js.map +1 -1
  448. package/dist/languages/definitions/zig.d.ts.map +1 -1
  449. package/dist/languages/definitions/zig.js +8 -0
  450. package/dist/languages/definitions/zig.js.map +1 -1
  451. package/dist/lifecycle/manifest.d.ts.map +1 -1
  452. package/dist/lifecycle/manifest.js +0 -1
  453. package/dist/lifecycle/manifest.js.map +1 -1
  454. package/dist/mcp/handlers.js +14 -7
  455. package/dist/mcp/handlers.js.map +1 -1
  456. package/dist/native/byte-index.d.ts +6 -0
  457. package/dist/native/byte-index.d.ts.map +1 -1
  458. package/dist/native/byte-index.js +11 -6
  459. package/dist/native/byte-index.js.map +1 -1
  460. package/dist/native/contracts.d.ts +2 -3
  461. package/dist/native/contracts.d.ts.map +1 -1
  462. package/dist/native/execution.d.ts +9 -9
  463. package/dist/native/execution.d.ts.map +1 -1
  464. package/dist/native/execution.js +37 -77
  465. package/dist/native/execution.js.map +1 -1
  466. package/dist/native/js-bridge.d.ts +2 -15
  467. package/dist/native/js-bridge.d.ts.map +1 -1
  468. package/dist/native/js-bridge.js +2 -15
  469. package/dist/native/js-bridge.js.map +1 -1
  470. package/dist/native/query-results.js +2 -2
  471. package/dist/native/query-results.js.map +1 -1
  472. package/dist/native/runtime.d.ts +12 -12
  473. package/dist/native/runtime.d.ts.map +1 -1
  474. package/dist/native/runtime.js +24 -69
  475. package/dist/native/runtime.js.map +1 -1
  476. package/dist/native/tree-sitter-native.d.ts +3 -3
  477. package/dist/native/tree-sitter-native.d.ts.map +1 -1
  478. package/dist/native/tree-sitter-native.js +2 -2
  479. package/dist/native/tree-sitter-native.js.map +1 -1
  480. package/dist/presets.d.ts.map +1 -1
  481. package/dist/presets.js +0 -4
  482. package/dist/presets.js.map +1 -1
  483. package/dist/review/candidates.d.ts.map +1 -1
  484. package/dist/review/candidates.js +1 -1
  485. package/dist/review/candidates.js.map +1 -1
  486. package/dist/review/deleted.d.ts +3 -3
  487. package/dist/review/deleted.d.ts.map +1 -1
  488. package/dist/review/deleted.js +82 -32
  489. package/dist/review/deleted.js.map +1 -1
  490. package/dist/review/report.d.ts +1 -0
  491. package/dist/review/report.d.ts.map +1 -1
  492. package/dist/review/report.js +1 -1
  493. package/dist/review/report.js.map +1 -1
  494. package/dist/review.d.ts.map +1 -1
  495. package/dist/review.js +3 -20
  496. package/dist/review.js.map +1 -1
  497. package/dist/session.d.ts.map +1 -1
  498. package/dist/session.js +0 -5
  499. package/dist/session.js.map +1 -1
  500. package/dist/sql/navigation.d.ts.map +1 -1
  501. package/dist/sql/navigation.js +2 -1
  502. package/dist/sql/navigation.js.map +1 -1
  503. package/dist/sql/source-graph.d.ts.map +1 -1
  504. package/dist/sql/source-graph.js +2 -2
  505. package/dist/sql/source-graph.js.map +1 -1
  506. package/dist/sqlite/schema.d.ts +1 -1
  507. package/dist/sqlite/schema.d.ts.map +1 -1
  508. package/dist/sqlite/schema.js +8 -2
  509. package/dist/sqlite/schema.js.map +1 -1
  510. package/dist/sqlite/write.js +2 -2
  511. package/dist/sqlite/write.js.map +1 -1
  512. package/dist/types.d.ts +2 -0
  513. package/dist/types.d.ts.map +1 -1
  514. package/dist/util/bloom-filter.d.ts +8 -1
  515. package/dist/util/bloom-filter.d.ts.map +1 -1
  516. package/dist/util/bloom-filter.js +15 -2
  517. package/dist/util/bloom-filter.js.map +1 -1
  518. package/dist/util/glob.d.ts +32 -0
  519. package/dist/util/glob.d.ts.map +1 -0
  520. package/dist/util/glob.js +137 -0
  521. package/dist/util/glob.js.map +1 -0
  522. package/dist/util/graph-edges.d.ts +19 -1
  523. package/dist/util/graph-edges.d.ts.map +1 -1
  524. package/dist/util/graph-edges.js +30 -4
  525. package/dist/util/graph-edges.js.map +1 -1
  526. package/dist/util/identifiers.d.ts +15 -0
  527. package/dist/util/identifiers.d.ts.map +1 -1
  528. package/dist/util/identifiers.js +35 -0
  529. package/dist/util/identifiers.js.map +1 -1
  530. package/dist/util/member-access-tables.d.ts +61 -4
  531. package/dist/util/member-access-tables.d.ts.map +1 -1
  532. package/dist/util/member-access-tables.js +139 -19
  533. package/dist/util/member-access-tables.js.map +1 -1
  534. package/dist/util/member-access.d.ts +17 -0
  535. package/dist/util/member-access.d.ts.map +1 -1
  536. package/dist/util/member-access.js +98 -3
  537. package/dist/util/member-access.js.map +1 -1
  538. package/dist/util/project-files.d.ts +2 -10
  539. package/dist/util/project-files.d.ts.map +1 -1
  540. package/dist/util/project-files.js +29 -51
  541. package/dist/util/project-files.js.map +1 -1
  542. package/dist/util/python-type-checking.d.ts +18 -0
  543. package/dist/util/python-type-checking.d.ts.map +1 -0
  544. package/dist/util/python-type-checking.js +160 -0
  545. package/dist/util/python-type-checking.js.map +1 -0
  546. package/dist/util/resolution/cargo-targets.d.ts +11 -0
  547. package/dist/util/resolution/cargo-targets.d.ts.map +1 -1
  548. package/dist/util/resolution/cargo-targets.js +174 -13
  549. package/dist/util/resolution/cargo-targets.js.map +1 -1
  550. package/dist/util/resolution/csharp.d.ts +33 -1
  551. package/dist/util/resolution/csharp.d.ts.map +1 -1
  552. package/dist/util/resolution/csharp.js +145 -30
  553. package/dist/util/resolution/csharp.js.map +1 -1
  554. package/dist/util/resolution/jvm.d.ts +7 -3
  555. package/dist/util/resolution/jvm.d.ts.map +1 -1
  556. package/dist/util/resolution/jvm.js +56 -38
  557. package/dist/util/resolution/jvm.js.map +1 -1
  558. package/dist/util/resolution/php.d.ts.map +1 -1
  559. package/dist/util/resolution/php.js +35 -8
  560. package/dist/util/resolution/php.js.map +1 -1
  561. package/dist/util/resolution/python.d.ts +9 -0
  562. package/dist/util/resolution/python.d.ts.map +1 -1
  563. package/dist/util/resolution/python.js +46 -0
  564. package/dist/util/resolution/python.js.map +1 -1
  565. package/dist/util/resolution/rust.d.ts +0 -1
  566. package/dist/util/resolution/rust.d.ts.map +1 -1
  567. package/dist/util/resolution/rust.js +95 -35
  568. package/dist/util/resolution/rust.js.map +1 -1
  569. package/dist/util/resolution/specifier-targets.d.ts +44 -0
  570. package/dist/util/resolution/specifier-targets.d.ts.map +1 -0
  571. package/dist/util/resolution/specifier-targets.js +152 -0
  572. package/dist/util/resolution/specifier-targets.js.map +1 -0
  573. package/dist/util/resolution-candidates.d.ts +5 -0
  574. package/dist/util/resolution-candidates.d.ts.map +1 -1
  575. package/dist/util/resolution-candidates.js +16 -3
  576. package/dist/util/resolution-candidates.js.map +1 -1
  577. package/dist/util/resolution.d.ts +2 -1
  578. package/dist/util/resolution.d.ts.map +1 -1
  579. package/dist/util/resolution.js +101 -15
  580. package/dist/util/resolution.js.map +1 -1
  581. package/dist/util/specifiers.d.ts +29 -1
  582. package/dist/util/specifiers.d.ts.map +1 -1
  583. package/dist/util/specifiers.js +56 -8
  584. package/dist/util/specifiers.js.map +1 -1
  585. package/dist/util/trivia.d.ts.map +1 -1
  586. package/dist/util/trivia.js +49 -30
  587. package/dist/util/trivia.js.map +1 -1
  588. package/dist/util/workspace.d.ts.map +1 -1
  589. package/dist/util/workspace.js +32 -4
  590. package/dist/util/workspace.js.map +1 -1
  591. package/docs/mcp.md +3 -2
  592. package/package.json +5 -7
  593. package/dist/impact/call-compatibility/providers/profiles.d.ts +0 -80
  594. package/dist/impact/call-compatibility/providers/profiles.d.ts.map +0 -1
  595. package/dist/impact/call-compatibility/providers/profiles.js +0 -164
  596. package/dist/impact/call-compatibility/providers/profiles.js.map +0 -1
@@ -1,29 +1,19 @@
1
- import fs from "node:fs";
2
1
  import path from "node:path";
3
2
  import { supportForFileWithoutHeaderSample } from "../languages.js";
4
- import { languageHasDeclarationVisibility } from "./declaration-visibility.js";
5
- import { GO_IDENTIFIER_SOURCE, JAVA_IDENTIFIER_SOURCE, KOTLIN_IDENTIFIER_SOURCE } from "../util/identifiers.js";
3
+ import { isJvmPackageSymbolVisible, languageHasDeclarationVisibility } from "./declaration-visibility.js";
4
+ import { isJvmStaticWildcardMember, isJvmTypeWildcardMember, jvmWildcardTypeOwner } from "./expand-star-imports.js";
5
+ import { foldPhpIdentifierCase, normalizeCsharpIdentifier, normalizeCsharpQualifiedName } from "../util/identifiers.js";
6
6
  import { fileIdentityKey, normalizePath } from "../util/paths.js";
7
+ import { getCompilationUnitPeers, IMPLICIT_UNIT_LANGUAGES, isUnitBareNameVisible } from "./compilation-units.js";
8
+ import { phpNamedImportRole } from "./import-types.js";
9
+ import { resolvePythonSubmoduleExact } from "../util/resolution/python.js";
10
+ import { PHP_CLASS_LIKE_KINDS } from "./php-namespace-symbols.js";
11
+ import { coalesceEquivalentCsharpPartialExports } from "./shared-owner-identity.js";
7
12
  import { SymbolKind, } from "./types.js";
8
- const GO_PACKAGE_PATTERN = new RegExp(String.raw `^\s*package\s+(${GO_IDENTIFIER_SOURCE})`, "mu");
9
- const JAVA_PACKAGE_NAME_PATTERN = new RegExp(String.raw `^\s*package\s+(${JAVA_IDENTIFIER_SOURCE}(?:\.${JAVA_IDENTIFIER_SOURCE})*)\s*;`, "mu");
10
- const KOTLIN_PACKAGE_NAME_PATTERN = new RegExp(String.raw `^\s*package\s+(${KOTLIN_IDENTIFIER_SOURCE}(?:\.${KOTLIN_IDENTIFIER_SOURCE})*)`, "mu");
11
- /**
12
- * Files that can carry the package declaration each lookup language searches for. Java and Kotlin
13
- * stay one group because they share a JVM package namespace and each pattern already accepts the
14
- * other's declaration; every other language is skipped instead of read for a keyword it never uses.
15
- */
16
- const PACKAGE_DECLARING_LANGUAGE_IDS = {
17
- go: new Set(["go"]),
18
- java: new Set(["java", "kotlin"]),
19
- kotlin: new Set(["java", "kotlin"]),
20
- };
21
13
  function cacheKey(file, canonicalName) {
22
14
  return `${fileIdentityKey(file)}::canonical::${canonicalName}`;
23
15
  }
24
16
  const moduleNameLookups = new WeakMap();
25
- const packageDirectoryLookups = new WeakMap();
26
- const packageNameCaches = new WeakMap();
27
17
  function moduleFor(index, file) {
28
18
  return index.byFile.get(fileIdentityKey(file));
29
19
  }
@@ -123,175 +113,191 @@ function sameResolvedExport(index, left, right) {
123
113
  }
124
114
  return false;
125
115
  }
126
- function packageNameCacheFor(index) {
127
- let caches = packageNameCaches.get(index);
128
- if (!caches) {
129
- caches = { go: new Map(), jvm: new Map() };
130
- packageNameCaches.set(index, caches);
131
- }
132
- return caches;
133
- }
134
116
  /**
135
- * Source to read a package declaration from: the text the index already parsed when it retained
136
- * one, and otherwise the file itself. Reusing the retained text keeps the package name consistent
137
- * with the symbols resolved from that same snapshot.
117
+ * Unique same-compilation-unit match for a bare name. Go, the JVM languages, C#, and Swift can
118
+ * name top-level declarations of their package, namespace, or module without an import;
119
+ * candidates come from the same proven unit relation used for reference-candidate discovery
120
+ * (`getCompilationUnitPeers`), never from a project-wide name scan. A name matching more than
121
+ * one unit declaration is ambiguous and stays unresolved, except proven-equivalent C# `partial`
122
+ * type parts, which collapse to one representative before uniqueness is judged. Members are
123
+ * excluded because they resolve through receiver/owner identity rather than as bare unit names.
138
124
  */
139
- function packageDeclarationSource(index, filePath, fileKey) {
140
- const retained = index.parsed?.get(fileKey)?.source;
141
- if (retained !== undefined)
142
- return retained;
143
- try {
144
- return fs.readFileSync(filePath, "utf8");
145
- }
146
- catch {
125
+ function resolveImplicitUnitExport(index, file, exportedName, matchesOptions, namespace, useIndex, qualification) {
126
+ // Only the implicit compilation-unit languages have bare-name unit visibility. C and C++
127
+ // keep their include-scope tag precedence and PHP its case-folded namespaces; the unit
128
+ // lookup must not preempt those established fallbacks.
129
+ const languageId = supportForFileWithoutHeaderSample(file, index.languageExtensions)?.id;
130
+ if (!languageId || !IMPLICIT_UNIT_LANGUAGES[languageId])
147
131
  return null;
148
- }
149
- }
150
- function readGoPackageName(index, filePath) {
151
- const cache = packageNameCacheFor(index).go;
152
- const key = fileIdentityKey(filePath);
153
- const cached = cache.get(key);
154
- if (cached !== undefined)
155
- return cached;
156
- const source = packageDeclarationSource(index, filePath, key);
157
- if (source === null) {
158
- cache.set(key, null);
159
- return null;
160
- }
161
- const packageName = GO_PACKAGE_PATTERN.exec(source)?.[1] ?? null;
162
- cache.set(key, packageName);
163
- return packageName;
164
- }
165
- function resolveGoPackageExport(index, file, exportedName) {
166
- if (supportForFileWithoutHeaderSample(file, index.languageExtensions)?.id !== "go")
167
- return null;
168
- const directory = packageDirectoryLookup(index, "go").get(fileIdentityKey(path.dirname(file)));
169
- if (!directory)
170
- return null;
171
- const sourcePackage = readGoPackageName(index, file);
172
- const candidates = sourcePackage ? (directory.byName.get(sourcePackage) ?? []) : directory.all;
173
132
  const matches = [];
174
- for (const moduleEntry of candidates) {
175
- const names = moduleNameLookup(index, moduleEntry.file);
133
+ const peers = getCompilationUnitPeers(index, file, languageId === "csharp" && qualification !== undefined ? { csharpQualifiedName: true } : undefined);
134
+ for (const peerFile of peers.files) {
135
+ const names = moduleNameLookup(index, peerFile);
176
136
  if (!names)
177
137
  continue;
178
138
  for (const target of names.localExports.get(names.normalizeIdentifier(exportedName)) ?? []) {
139
+ if (target.isMember || !matchesOptions(target, namespace))
140
+ continue;
141
+ if (!isUnitBareNameVisible({
142
+ index,
143
+ declarationFile: target.file,
144
+ declaration: target.range,
145
+ useFile: file,
146
+ ...(useIndex !== undefined ? { useIndex } : {}),
147
+ ...(qualification !== undefined ? { qualification } : {}),
148
+ })) {
149
+ continue;
150
+ }
179
151
  if (!matches.some((candidate) => sameSymbolDef(index, candidate, target))) {
180
152
  matches.push(target);
181
153
  }
182
154
  }
183
155
  }
184
- return matches.length === 1 ? (matches[0] ?? null) : null;
156
+ const unique = languageId === "csharp" ? coalesceEquivalentCsharpPartialExports(index, matches) : matches;
157
+ return unique.length === 1 ? (unique[0] ?? null) : null;
185
158
  }
186
- function readPackageNameForLanguage(index, filePath, languageId) {
187
- const cache = packageNameCacheFor(index).jvm;
188
- const fileKey = fileIdentityKey(filePath);
189
- const key = `${languageId}::${fileKey}`;
190
- const cached = cache.get(key);
191
- if (cached !== undefined)
192
- return cached;
193
- const source = packageDeclarationSource(index, filePath, fileKey);
194
- if (source === null) {
195
- cache.set(key, null);
196
- return null;
197
- }
198
- const pattern = languageId === "kotlin" ? KOTLIN_PACKAGE_NAME_PATTERN : JAVA_PACKAGE_NAME_PATTERN;
199
- const packageName = pattern.exec(source)?.[1] ?? null;
200
- cache.set(key, packageName);
201
- return packageName;
202
- }
203
- function packageDirectoryLookup(index, languageId) {
204
- let byLanguage = packageDirectoryLookups.get(index);
205
- if (!byLanguage) {
206
- byLanguage = new Map();
207
- packageDirectoryLookups.set(index, byLanguage);
208
- }
209
- const cached = byLanguage.get(languageId);
210
- if (cached)
211
- return cached;
212
- const directories = new Map();
213
- for (const moduleEntry of index.byFile.values()) {
214
- const directoryKey = fileIdentityKey(path.dirname(moduleEntry.file));
215
- let directory = directories.get(directoryKey);
216
- if (!directory) {
217
- directory = { all: [], byName: new Map() };
218
- directories.set(directoryKey, directory);
219
- }
220
- directory.all.push(moduleEntry);
221
- const moduleLanguageId = supportForFileWithoutHeaderSample(moduleEntry.file, index.languageExtensions)?.id;
222
- if (!moduleLanguageId || !PACKAGE_DECLARING_LANGUAGE_IDS[languageId].has(moduleLanguageId))
223
- continue;
224
- const packageName = languageId === "go"
225
- ? readGoPackageName(index, moduleEntry.file)
226
- : readPackageNameForLanguage(index, moduleEntry.file, languageId);
227
- if (!packageName)
228
- continue;
229
- const entries = directory.byName.get(packageName) ?? [];
230
- entries.push(moduleEntry);
231
- directory.byName.set(packageName, entries);
232
- }
233
- byLanguage.set(languageId, directories);
234
- return directories;
235
- }
236
- function resolveSiblingPackageExport(index, targetFile, exportedName, languageId) {
237
- const packageName = readPackageNameForLanguage(index, targetFile, languageId);
238
- if (!packageName)
239
- return null;
240
- const directory = packageDirectoryLookup(index, languageId).get(fileIdentityKey(path.dirname(targetFile)));
241
- if (!directory)
159
+ /**
160
+ * Same-package Java/Kotlin export that the bare-name unit scan does not answer (a member, for
161
+ * example). Peers come from `getCompilationUnitPeers`, so Java and Kotlin share one package
162
+ * rule. An incomplete set (an unreadable peer, or the same package outside this directory)
163
+ * is not a proven unique answer.
164
+ */
165
+ function resolveSiblingPackageExport(index, targetFile, exportedName) {
166
+ const peers = getCompilationUnitPeers(index, targetFile);
167
+ if (!peers.complete)
242
168
  return null;
243
169
  const targetFileKey = fileIdentityKey(targetFile);
244
170
  const matches = [];
245
- for (const moduleEntry of directory.byName.get(packageName) ?? []) {
246
- if (fileIdentityKey(moduleEntry.file) === targetFileKey)
171
+ for (const peerFile of peers.files) {
172
+ if (fileIdentityKey(peerFile) === targetFileKey)
247
173
  continue;
248
- const hit = resolveExport(index, moduleEntry.file, exportedName);
174
+ const hit = resolveExport(index, peerFile, exportedName);
249
175
  if (hit && !matches.some((candidate) => sameResolvedExport(index, candidate, hit))) {
250
176
  matches.push(hit);
251
177
  }
252
178
  }
253
179
  return matches.length === 1 ? (matches[0] ?? null) : null;
254
180
  }
255
- function resolvePythonSubmodule(targetFile, exportedName) {
256
- let baseDir;
257
- try {
258
- const targetStat = fs.statSync(targetFile);
259
- if (targetStat.isDirectory()) {
260
- baseDir = targetFile;
261
- }
262
- else if (path.basename(targetFile) === "__init__.py" || path.basename(targetFile) === "__init__.pyi") {
263
- baseDir = path.dirname(targetFile);
264
- }
265
- else {
266
- return null;
267
- }
268
- }
269
- catch {
181
+ function declaresMemberKind(def) {
182
+ return def.kind === SymbolKind.Class || def.kind === SymbolKind.Interface || def.kind === SymbolKind.TypeAlias;
183
+ }
184
+ /**
185
+ * One function from an overload set, or null when the count is not accepted by exactly one.
186
+ * Only indexed `callable.arity` is consulted: a missing arity does not accept, and a count
187
+ * two overloads both accept stays unresolved.
188
+ */
189
+ function selectFunctionOverloadByArity(candidates, argumentCount) {
190
+ if (candidates.length < 2 || candidates.some((candidate) => candidate.kind !== SymbolKind.Function))
270
191
  return null;
192
+ const accepting = candidates.filter((candidate) => {
193
+ const arity = candidate.callable?.arity;
194
+ return !!arity && argumentCount >= arity.minArgs && (arity.maxArgs === null || argumentCount <= arity.maxArgs);
195
+ });
196
+ return accepting.length === 1 ? (accepting[0] ?? null) : null;
197
+ }
198
+ /**
199
+ * `def` is one function of a Java or Kotlin overload set exported as `exportedName`.
200
+ * A call chooses among them by argument count; the import itself names the whole set, so
201
+ * reference search must still treat the import as able to reach each overload.
202
+ */
203
+ export function javaKotlinFunctionOverloadIncludes(index, file, exportedName, def) {
204
+ if (def.kind !== SymbolKind.Function)
205
+ return false;
206
+ const languageId = supportForFileWithoutHeaderSample(file, index.languageExtensions)?.id;
207
+ if (languageId !== "java" && languageId !== "kotlin")
208
+ return false;
209
+ const moduleEntry = moduleFor(index, file);
210
+ if (!moduleEntry)
211
+ return false;
212
+ const names = moduleNameLookup(index, moduleEntry.file);
213
+ if (!names)
214
+ return false;
215
+ const exported = names.localExports.get(names.normalizeIdentifier(exportedName)) ?? [];
216
+ if (exported.length < 2 || exported.some((candidate) => candidate.kind !== SymbolKind.Function))
217
+ return false;
218
+ return exported.some((candidate) => sameSymbolDef(index, candidate, def));
219
+ }
220
+ /**
221
+ * A default-export wrapper keeps `SymbolKind.Default` so the export name stays `default`.
222
+ * Member lookup needs the class, interface, or type alias that wrapper was copied from.
223
+ */
224
+ export function memberContainerForDefinition(index, def) {
225
+ if (declaresMemberKind(def))
226
+ return def;
227
+ if (def.kind !== SymbolKind.Default)
228
+ return undefined;
229
+ const moduleEntry = index.byFile.get(fileIdentityKey(def.file));
230
+ if (!moduleEntry)
231
+ return undefined;
232
+ const sameRange = moduleEntry.locals.filter((local) => declaresMemberKind(local) &&
233
+ local.range.start.line === def.range.start.line &&
234
+ local.range.start.column === def.range.start.column);
235
+ if (sameRange.length === 1)
236
+ return sameRange[0];
237
+ }
238
+ /** The export entry that proves a direct CommonJS or TypeScript module value, whatever its public name. */
239
+ export function directModuleValueEntry(moduleEntry) {
240
+ return moduleEntry.exports.find((entry) => entry.type === "local" && (entry.mechanism === "cjs-module-value" || entry.mechanism === "ts-export-assignment"));
241
+ }
242
+ /**
243
+ * `require()` and `import x = require()` return a proven direct `module.exports = X` or
244
+ * TypeScript `export = X` value. A default export accompanied by named exports instead returns
245
+ * a namespace object, including non-local and star re-exports.
246
+ */
247
+ export function cjsRequireValueBinding(index, targetFile) {
248
+ const moduleEntry = index.byFile.get(fileIdentityKey(targetFile));
249
+ const directValue = moduleEntry && directModuleValueEntry(moduleEntry);
250
+ if (directValue)
251
+ return memberContainerForDefinition(index, directValue.target) ?? directValue.target;
252
+ const resolved = resolveExport(index, targetFile, "default");
253
+ if (resolved?.kind !== "resolved")
254
+ return undefined;
255
+ const hasNamedExport = moduleEntry?.exports.some((entry) => {
256
+ if (entry.type === "exportStar")
257
+ return !entry.typeOnly;
258
+ if (entry.type === "local")
259
+ return entry.exportedAs !== "default" && !entry.target.isMember;
260
+ return entry.exportedAs !== "default" && !entry.typeOnly;
261
+ });
262
+ if (hasNamedExport)
263
+ return undefined;
264
+ return memberContainerForDefinition(index, resolved.def) ?? resolved.def;
265
+ }
266
+ const fileEdgeTargetsCache = new WeakMap();
267
+ /** First resolved file target per importer and raw specifier; rebuilt when the edge list changes. */
268
+ function fileEdgeTargetsFor(index) {
269
+ const edges = index.graph.edges;
270
+ const cached = fileEdgeTargetsCache.get(index);
271
+ if (cached && cached.edges === edges && cached.length === edges.length)
272
+ return cached.targets;
273
+ const targets = new Map();
274
+ for (const edge of edges) {
275
+ if (edge.to.type !== "file")
276
+ continue;
277
+ const key = `${fileIdentityKey(edge.from)}\0${edge.raw}`;
278
+ if (!targets.has(key))
279
+ targets.set(key, edge.to.path);
271
280
  }
272
- const moduleFile = path.join(baseDir, `${exportedName}.py`);
273
- const stubModuleFile = path.join(baseDir, `${exportedName}.pyi`);
274
- const packageInit = path.join(baseDir, exportedName, "__init__.py");
275
- const stubPackageInit = path.join(baseDir, exportedName, "__init__.pyi");
276
- const namespacePackage = path.join(baseDir, exportedName);
277
- for (const candidate of [moduleFile, stubModuleFile, packageInit, stubPackageInit, namespacePackage]) {
278
- try {
279
- const candidateStat = fs.statSync(candidate);
280
- if (candidate === namespacePackage ? candidateStat.isDirectory() : candidateStat.isFile()) {
281
- return normalizePath(candidate);
282
- }
283
- }
284
- catch {
285
- // The next candidate can still be a real submodule.
286
- }
287
- }
288
- return null;
281
+ fileEdgeTargetsCache.set(index, { edges, length: edges.length, targets });
282
+ return targets;
283
+ }
284
+ /**
285
+ * A member of the module a `typeof import("spec")` receiver holds, resolved through the file
286
+ * dependency edge the index recorded for that specifier.
287
+ */
288
+ export function resolveImportTypeMember(index, fromFile, specifier, member) {
289
+ const target = fileEdgeTargetsFor(index).get(`${fileIdentityKey(fromFile)}\0${specifier}`);
290
+ if (!target)
291
+ return null;
292
+ const hit = resolveExport(index, target, member);
293
+ return hit?.kind === "resolved" ? hit.def : null;
289
294
  }
290
295
  export function resolveExport(index, file, exportedName, opts) {
291
296
  const visited = new Set();
292
- const matchesPreferredKind = (def) => !opts?.preferredKind || def.kind === opts.preferredKind;
297
+ const matchesOptions = (def, namespace) => (!opts?.preferredKind || def.kind === opts.preferredKind) &&
298
+ (namespace === undefined || (def.cTag ? "tag" : "ordinary") === namespace);
293
299
  const allowLocalFallback = opts?.allowLocalFallback ?? true;
294
- function resolveFromFile(fileInner, name) {
300
+ function resolveFromFile(fileInner, name, namespace = opts?.cNamespace) {
295
301
  const moduleEntry = moduleFor(index, fileInner);
296
302
  if (!moduleEntry)
297
303
  return null;
@@ -299,29 +305,82 @@ export function resolveExport(index, file, exportedName, opts) {
299
305
  if (!names)
300
306
  return null;
301
307
  const normalizedFile = normalizePath(moduleEntry.file);
302
- const canonicalName = names.normalizeIdentifier(name);
303
- const key = opts?.preferredKind
304
- ? `${cacheKey(normalizedFile, canonicalName)}::${opts.preferredKind}::${allowLocalFallback ? "local" : "export"}`
305
- : `${cacheKey(normalizedFile, canonicalName)}::${allowLocalFallback ? "local" : "export"}`;
308
+ const referenceIndex = fileIdentityKey(fileInner) === fileIdentityKey(file) ? opts?.referenceIndex : undefined;
309
+ const languageId = supportForFileWithoutHeaderSample(normalizedFile, index.languageExtensions)?.id;
310
+ const csharpFile = languageId === "csharp";
311
+ // A dotted name is a namespace path even when the caller has no source position
312
+ // (`using PT = N.Inner.Point` resolves through the bound file, not a use site).
313
+ // A bare name still needs a source position before namespace visibility applies.
314
+ const filtersUseNamespace = csharpFile && (referenceIndex !== undefined || name.includes(".") || name.startsWith("global::"));
315
+ const separator = filtersUseNamespace ? name.lastIndexOf(".") : -1;
316
+ let qualification;
317
+ let unqualifiedName = name;
318
+ if (separator >= 0) {
319
+ // `@P.Target` and `P.Target` name the same namespace path.
320
+ qualification = normalizeCsharpQualifiedName(name.slice(0, separator));
321
+ unqualifiedName = name.slice(separator + 1);
322
+ }
323
+ else if (filtersUseNamespace && name.startsWith("global::")) {
324
+ qualification = "global::";
325
+ unqualifiedName = name.slice("global::".length);
326
+ }
327
+ const canonicalName = names.normalizeIdentifier(unqualifiedName);
328
+ const argumentCountKey = opts?.argumentCount === undefined ? "" : String(opts.argumentCount);
329
+ const key = `${cacheKey(normalizedFile, names.normalizeIdentifier(name))}::${opts?.preferredKind ?? ""}::${namespace ?? ""}::${allowLocalFallback ? "local" : "export"}::${referenceIndex ?? ""}::${argumentCountKey}`;
306
330
  if (index.exportCache.has(key))
307
331
  return index.exportCache.get(key);
308
- const cycleKey = cacheKey(normalizedFile, canonicalName);
332
+ const cycleKey = `${cacheKey(normalizedFile, canonicalName)}::${namespace ?? ""}`;
309
333
  if (visited.has(cycleKey))
310
334
  return null;
311
335
  visited.add(cycleKey);
312
- const goPackageExport = resolveGoPackageExport(index, normalizedFile, canonicalName);
313
- if (goPackageExport && matchesPreferredKind(goPackageExport)) {
314
- const result = { kind: "resolved", def: goPackageExport };
336
+ const implicitUnitExport = resolveImplicitUnitExport(index, normalizedFile, canonicalName, matchesOptions, namespace, referenceIndex, qualification);
337
+ if (implicitUnitExport) {
338
+ const result = { kind: "resolved", def: implicitUnitExport };
315
339
  index.exportCache.set(key, result);
316
340
  return result;
317
341
  }
318
342
  const localCandidates = [];
319
343
  for (const target of names.localExports.get(canonicalName) ?? []) {
320
- if (matchesPreferredKind(target) &&
344
+ if (matchesOptions(target, namespace) &&
345
+ // Nested types resolve through their owner, not as bare namespace names.
346
+ (!filtersUseNamespace ||
347
+ (!target.isMember &&
348
+ isUnitBareNameVisible({
349
+ index,
350
+ declarationFile: target.file,
351
+ declaration: target.range,
352
+ useFile: file,
353
+ ...(referenceIndex !== undefined ? { useIndex: referenceIndex } : {}),
354
+ ...(qualification !== undefined ? { qualification } : {}),
355
+ }))) &&
321
356
  !localCandidates.some((candidate) => sameSymbolDef(index, candidate, target))) {
322
357
  localCandidates.push(target);
323
358
  }
324
359
  }
360
+ // A bodyless C tag use can introduce an incomplete tag, but must reuse a tag
361
+ // already brought into scope by an include. Do not let that use hide its header.
362
+ if (namespace &&
363
+ (!localCandidates.length ||
364
+ localCandidates.every((candidate) => candidate.cTag === "reference" || candidate.cTag === "forward"))) {
365
+ const included = [];
366
+ for (const imp of moduleEntry.imports) {
367
+ if (typeof imp.resolved !== "string")
368
+ continue;
369
+ if (imp.kind !== "star" && !(imp.kind === "named" && imp.local === name))
370
+ continue;
371
+ if (imp.kind === "named" && (imp.cNamespace ?? "ordinary") !== namespace)
372
+ continue;
373
+ const downstream = resolveFromFile(imp.resolved, imp.kind === "named" ? imp.imported : name, namespace);
374
+ if (downstream && !included.some((candidate) => sameResolvedExport(index, candidate, downstream))) {
375
+ included.push(downstream);
376
+ }
377
+ }
378
+ if (included.length) {
379
+ const result = included.length === 1 ? included[0] : null;
380
+ index.exportCache.set(key, result);
381
+ return result;
382
+ }
383
+ }
325
384
  if (localCandidates.length === 1) {
326
385
  const target = localCandidates[0];
327
386
  const result = { kind: "resolved", def: target };
@@ -329,6 +388,16 @@ export function resolveExport(index, file, exportedName, opts) {
329
388
  return result;
330
389
  }
331
390
  if (localCandidates.length) {
391
+ // Several same-named functions are an overload set, not a failed lookup. Java static
392
+ // imports and Kotlin package imports both land here; arity picks the unique acceptor.
393
+ const selected = opts?.argumentCount !== undefined && (languageId === "java" || languageId === "kotlin")
394
+ ? selectFunctionOverloadByArity(localCandidates, opts.argumentCount)
395
+ : null;
396
+ if (selected) {
397
+ const result = { kind: "resolved", def: selected };
398
+ index.exportCache.set(key, result);
399
+ return result;
400
+ }
332
401
  index.exportCache.set(key, null);
333
402
  return null;
334
403
  }
@@ -348,8 +417,9 @@ export function resolveExport(index, file, exportedName, opts) {
348
417
  }
349
418
  const reexportCandidates = [];
350
419
  for (const entry of names.reexports.get(canonicalName) ?? []) {
351
- const downstream = resolveFromFile(entry.fromModule, entry.sourceSpecifier || canonicalName) ??
352
- resolveFromFile(entry.fromModule, canonicalName);
420
+ const downstream = resolveFromFile(entry.fromModule, entry.sourceSpecifier || canonicalName, namespace) ??
421
+ // A qualified using target cannot fall back to an unrelated bare export.
422
+ (entry.sourceSpecifier.includes("::") ? null : resolveFromFile(entry.fromModule, canonicalName, namespace));
353
423
  if (downstream && !reexportCandidates.some((candidate) => sameResolvedExport(index, candidate, downstream))) {
354
424
  reexportCandidates.push(downstream);
355
425
  }
@@ -367,7 +437,7 @@ export function resolveExport(index, file, exportedName, opts) {
367
437
  for (const entry of moduleEntry.exports) {
368
438
  if (entry.type !== "exportStar")
369
439
  continue;
370
- const downstream = resolveFromFile(entry.fromModule, canonicalName);
440
+ const downstream = resolveFromFile(entry.fromModule, canonicalName, namespace);
371
441
  if (downstream && !starCandidates.some((candidate) => sameResolvedExport(index, candidate, downstream))) {
372
442
  starCandidates.push(downstream);
373
443
  }
@@ -382,21 +452,44 @@ export function resolveExport(index, file, exportedName, opts) {
382
452
  return null;
383
453
  }
384
454
  const localFallbackCandidates = [];
385
- if (allowLocalFallback && !shouldSkipVisibilityLocalFallback(index, moduleEntry)) {
455
+ // C# lexical bindings have already been checked. Only namespace-level types
456
+ // can remain visible from another region without a shared lexical scope.
457
+ if (allowLocalFallback && (filtersUseNamespace || !shouldSkipVisibilityLocalFallback(index, moduleEntry))) {
386
458
  for (const local of names.locals.get(canonicalName) ?? []) {
387
- if (matchesPreferredKind(local) &&
459
+ if (filtersUseNamespace &&
460
+ (local.isMember ||
461
+ (local.kind !== SymbolKind.Class &&
462
+ local.kind !== SymbolKind.Interface &&
463
+ local.kind !== SymbolKind.TypeAlias) ||
464
+ !isUnitBareNameVisible({
465
+ index,
466
+ declarationFile: local.file,
467
+ declaration: local.range,
468
+ useFile: file,
469
+ ...(referenceIndex !== undefined ? { useIndex: referenceIndex } : {}),
470
+ ...(qualification !== undefined ? { qualification } : {}),
471
+ }))) {
472
+ continue;
473
+ }
474
+ if (matchesOptions(local, namespace) &&
388
475
  !localFallbackCandidates.some((candidate) => sameSymbolDef(index, candidate, local))) {
389
476
  localFallbackCandidates.push(local);
390
477
  }
391
478
  }
392
479
  }
393
- if (localFallbackCandidates.length === 1) {
394
- const local = localFallbackCandidates[0];
480
+ // Hidden same-file C# types are omitted from exports, so equivalent internal
481
+ // `partial` parts both land here. Collapse them with the same shared-owner
482
+ // identity used for exported candidates before uniqueness is judged.
483
+ const uniqueLocalFallback = filtersUseNamespace
484
+ ? coalesceEquivalentCsharpPartialExports(index, localFallbackCandidates)
485
+ : localFallbackCandidates;
486
+ if (uniqueLocalFallback.length === 1) {
487
+ const local = uniqueLocalFallback[0];
395
488
  const result = { kind: "resolved", def: local };
396
489
  index.exportCache.set(key, result);
397
490
  return result;
398
491
  }
399
- if (localFallbackCandidates.length) {
492
+ if (uniqueLocalFallback.length) {
400
493
  index.exportCache.set(key, null);
401
494
  return null;
402
495
  }
@@ -405,6 +498,63 @@ export function resolveExport(index, file, exportedName, opts) {
405
498
  }
406
499
  return resolveFromFile(file, exportedName);
407
500
  }
501
+ function resolvePhpCaseInsensitiveExport(index, targetFile, exportedName, preferredKind) {
502
+ const exactExport = resolveExport(index, targetFile, exportedName, { preferredKind, allowLocalFallback: false });
503
+ if (exactExport)
504
+ return exactExport;
505
+ const moduleEntry = moduleFor(index, targetFile);
506
+ if (!moduleEntry)
507
+ return null;
508
+ const foldedName = foldPhpIdentifierCase(exportedName);
509
+ const resolveUnique = (sourceSpellings, allowLocalFallback) => {
510
+ const matches = [];
511
+ for (const sourceSpelling of sourceSpellings) {
512
+ const hit = resolveExport(index, targetFile, sourceSpelling, { preferredKind, allowLocalFallback });
513
+ if (hit && !matches.some((candidate) => sameResolvedExport(index, candidate, hit))) {
514
+ matches.push(hit);
515
+ }
516
+ }
517
+ return matches.length === 1 ? matches[0] : null;
518
+ };
519
+ const exportSpellings = new Set();
520
+ for (const entry of moduleEntry.exports) {
521
+ if (entry.type === "local" &&
522
+ entry.target.kind === preferredKind &&
523
+ foldPhpIdentifierCase(entry.exportedAs) === foldedName) {
524
+ exportSpellings.add(entry.exportedAs);
525
+ }
526
+ }
527
+ if (exportSpellings.size)
528
+ return resolveUnique(exportSpellings, false);
529
+ const exactLocal = resolveExport(index, targetFile, exportedName, { preferredKind });
530
+ if (exactLocal)
531
+ return exactLocal;
532
+ const localSpellings = new Set();
533
+ for (const local of moduleEntry.locals) {
534
+ if (local.kind === preferredKind && foldPhpIdentifierCase(local.localName) === foldedName) {
535
+ localSpellings.add(local.localName);
536
+ }
537
+ }
538
+ return resolveUnique(localSpellings, true);
539
+ }
540
+ /** Resolves a PHP symbol through its separate class, function, or constant import namespace. */
541
+ export function resolvePhpExportByImportType(index, targetFile, exportedName, importType) {
542
+ if (importType === "class") {
543
+ for (const preferredKind of PHP_CLASS_LIKE_KINDS) {
544
+ const hit = resolvePhpCaseInsensitiveExport(index, targetFile, exportedName, preferredKind);
545
+ if (hit)
546
+ return hit;
547
+ }
548
+ return null;
549
+ }
550
+ if (importType === "function") {
551
+ return resolvePhpCaseInsensitiveExport(index, targetFile, exportedName, SymbolKind.Function);
552
+ }
553
+ if (importType === "const") {
554
+ return resolveExport(index, targetFile, exportedName, { preferredKind: SymbolKind.Variable });
555
+ }
556
+ return resolveExport(index, targetFile, exportedName);
557
+ }
408
558
  function collectExportedNames(index, file, includeLocalFallback, names, visited) {
409
559
  const fileKey = fileIdentityKey(file);
410
560
  if (visited.has(fileKey))
@@ -439,41 +589,297 @@ export function resolveModuleExports(index, file, opts) {
439
589
  }
440
590
  return resolved;
441
591
  }
442
- export function resolveImported(index, imp, exportedName) {
592
+ /**
593
+ * Qualified name a C# using-alias binds. `from` is either the namespace (`N.Inner`
594
+ * for `using PT = N.Inner.Point`) or the full dotted type when an earlier resolver
595
+ * already kept it (`Utils.UtilsClass`). A bare imported name must not be searched on
596
+ * its own: compilation-unit lookup would accept a same-named type in another namespace.
597
+ */
598
+ function csharpNamedImportLookupName(from, exportedName) {
599
+ if (!exportedName || exportedName.includes(".") || exportedName.startsWith("global::"))
600
+ return exportedName;
601
+ const normalizedFrom = from.trim();
602
+ if (!normalizedFrom)
603
+ return exportedName;
604
+ const parts = normalizedFrom.split(".").filter(Boolean);
605
+ const tail = parts[parts.length - 1];
606
+ if (!tail)
607
+ return exportedName;
608
+ if (normalizeCsharpIdentifier(tail) === normalizeCsharpIdentifier(exportedName))
609
+ return normalizedFrom;
610
+ return `${normalizedFrom}.${exportedName}`;
611
+ }
612
+ /**
613
+ * The name a C# binding looks up. A named binding qualifies with its alias target. A `using N;`
614
+ * star binding qualifies with `N`: its resolved file is one of the files that declare `N`, and
615
+ * the qualified lookup reaches exactly the types of `N` in every declaring file, not types of
616
+ * other namespaces the bound file also declares.
617
+ */
618
+ function csharpImportLookupName(imp, exportedName) {
619
+ if (imp.kind === "named")
620
+ return csharpNamedImportLookupName(imp.from, exportedName);
621
+ if (imp.kind !== "star" || imp.staticMembersOf)
622
+ return exportedName;
623
+ if (!exportedName || exportedName.includes(".") || exportedName.startsWith("global::"))
624
+ return exportedName;
625
+ const namespaceName = imp.from.trim();
626
+ return namespaceName ? `${namespaceName}.${exportedName}` : exportedName;
627
+ }
628
+ const csharpNamespaceImportDirectoryFiles = new WeakMap();
629
+ /**
630
+ * For each C# `using N;` binding, one declaring file per directory. The file graph links each
631
+ * directive to every file that declares `N` within the importer's own project, so the set is
632
+ * kept per binding: two importers in different projects never share one. A qualified lookup from
633
+ * one file reaches the rest of its directory, so one file per directory covers every declaration
634
+ * of `N`. Built once per index.
635
+ */
636
+ function csharpNamespaceImportDirectories(index) {
637
+ const cached = csharpNamespaceImportDirectoryFiles.get(index);
638
+ if (cached)
639
+ return cached;
640
+ const edgesByImporter = new Map();
641
+ for (const edge of index.graph.edges) {
642
+ if (edge.to.type !== "file")
643
+ continue;
644
+ if (supportForFileWithoutHeaderSample(edge.to.path, index.languageExtensions)?.id !== "csharp")
645
+ continue;
646
+ const importerKey = fileIdentityKey(edge.from);
647
+ let byRaw = edgesByImporter.get(importerKey);
648
+ if (!byRaw)
649
+ edgesByImporter.set(importerKey, (byRaw = new Map()));
650
+ const raw = normalizeCsharpQualifiedName(edge.raw);
651
+ let byDirectory = byRaw.get(raw);
652
+ if (!byDirectory)
653
+ byRaw.set(raw, (byDirectory = new Map()));
654
+ const directoryKey = fileIdentityKey(path.posix.dirname(normalizePath(edge.to.path)));
655
+ if (!byDirectory.has(directoryKey))
656
+ byDirectory.set(directoryKey, edge.to.path);
657
+ }
658
+ const result = new Map();
659
+ for (const mod of index.byFile.values()) {
660
+ for (const imp of mod.imports) {
661
+ if (imp.kind !== "star" || imp.staticMembersOf || typeof imp.resolved !== "string")
662
+ continue;
663
+ if (supportForFileWithoutHeaderSample(imp.resolved, index.languageExtensions)?.id !== "csharp")
664
+ continue;
665
+ const files = new Map([
666
+ [fileIdentityKey(path.posix.dirname(normalizePath(imp.resolved))), imp.resolved],
667
+ ]);
668
+ const targets = edgesByImporter.get(fileIdentityKey(mod.file))?.get(normalizeCsharpQualifiedName(imp.from));
669
+ for (const [directoryKey, file] of targets ?? [])
670
+ if (!files.has(directoryKey))
671
+ files.set(directoryKey, file);
672
+ result.set(imp, [...files.values()]);
673
+ }
674
+ }
675
+ csharpNamespaceImportDirectoryFiles.set(index, result);
676
+ return result;
677
+ }
678
+ /**
679
+ * A name imported by C# `using N;`, looked up as `N.Name` from one declaring file per
680
+ * directory. Distinct declarations (other than parts of one partial type) are ambiguous. Only
681
+ * exported types count: local fallback would expose an `internal` type the exports omit, for
682
+ * both the bare name and the qualified `N.Name` form.
683
+ */
684
+ function resolveCsharpNamespaceImport(index, imp, boundFile, lookupName, opts) {
685
+ // A binding that is not one of the index's own (a copy) falls back to the bound file's directory.
686
+ const files = csharpNamespaceImportDirectories(index).get(imp) ?? [boundFile];
687
+ const matches = [];
688
+ let namespaceHit;
689
+ for (const file of files) {
690
+ const hit = resolveExport(index, file, lookupName, { ...opts, allowLocalFallback: false });
691
+ if (hit?.kind === "namespace")
692
+ namespaceHit ??= hit.file;
693
+ if (hit?.kind !== "resolved" || matches.some((candidate) => sameSymbolDef(index, candidate, hit.def)))
694
+ continue;
695
+ matches.push(hit.def);
696
+ }
697
+ const unique = coalesceEquivalentCsharpPartialExports(index, matches);
698
+ if (unique.length === 1)
699
+ return unique[0];
700
+ if (unique.length)
701
+ return null;
702
+ return namespaceHit ? { namespace: namespaceHit } : null;
703
+ }
704
+ /**
705
+ * A C# namespace-qualified type name (`N.Type`) used in `mod`. Qualified export lookup from the
706
+ * use file covers its own directory; a `using N;` in the file also reaches every other directory
707
+ * that declares `N`, as the unqualified name does.
708
+ */
709
+ export function resolveCsharpQualifiedName(index, mod, qualifiedName, referenceIndex) {
710
+ const direct = resolveExport(index, mod.file, qualifiedName, { referenceIndex });
711
+ if (direct)
712
+ return direct;
713
+ const separator = qualifiedName.lastIndexOf(".");
714
+ if (separator <= 0)
715
+ return null;
716
+ const namespaceName = normalizeCsharpQualifiedName(qualifiedName.slice(0, separator)).replace(/^global::/u, "");
717
+ const typeName = qualifiedName.slice(separator + 1);
718
+ for (const imp of mod.imports) {
719
+ if (imp.kind !== "star" || imp.staticMembersOf || typeof imp.resolved !== "string")
720
+ continue;
721
+ if (normalizeCsharpQualifiedName(imp.from).replace(/^global::/u, "") !== namespaceName)
722
+ continue;
723
+ const hit = resolveImported(index, imp, typeName);
724
+ if (!hit)
725
+ return null;
726
+ return "namespace" in hit ? { kind: "namespace", file: hit.namespace } : { kind: "resolved", def: hit };
727
+ }
728
+ return null;
729
+ }
730
+ /** Select from the entire wildcard package before any representative file can win. */
731
+ function resolveJvmPackageExport(index, files, name, argumentCount, importerLanguageId, samePackage) {
732
+ const candidates = [];
733
+ for (const file of files) {
734
+ const targetLanguage = supportForFileWithoutHeaderSample(file, index.languageExtensions)?.id;
735
+ if (targetLanguage !== "java" && targetLanguage !== "kotlin")
736
+ continue;
737
+ const names = moduleNameLookup(index, file);
738
+ if (!names)
739
+ continue;
740
+ for (const target of names.localExports.get(names.normalizeIdentifier(name)) ?? []) {
741
+ if (target.isMember ||
742
+ !isJvmPackageSymbolVisible(target, targetLanguage, importerLanguageId ?? targetLanguage, !!samePackage) ||
743
+ candidates.some((candidate) => sameSymbolDef(index, candidate, target)))
744
+ continue;
745
+ candidates.push(target);
746
+ }
747
+ }
748
+ if (candidates.length === 1)
749
+ return candidates[0];
750
+ return argumentCount === undefined ? null : selectFunctionOverloadByArity(candidates, argumentCount);
751
+ }
752
+ /** Whether a Java named static import can expose this exact direct member. */
753
+ export function javaStaticNamedImportIncludes(index, imp, def) {
754
+ if (imp.kind !== "named" || !imp.jvmStaticWildcardName)
755
+ return false;
756
+ const targetFile = typeof imp.resolved === "string" ? imp.resolved : undefined;
757
+ if (!targetFile || fileIdentityKey(targetFile) !== fileIdentityKey(def.file))
758
+ return false;
759
+ const target = moduleFor(index, targetFile);
760
+ if (!target)
761
+ return false;
762
+ const owner = jvmWildcardTypeOwner(target, imp.jvmStaticWildcardName, "java");
763
+ if (!owner || owner.range.start.index === undefined || (owner.javaPackagePrivate && !imp.jvmSamePackage))
764
+ return false;
765
+ if (!isJvmStaticWildcardMember(def, owner.range.start.index) || (def.javaPackagePrivate && !imp.jvmSamePackage))
766
+ return false;
767
+ const names = moduleNameLookup(index, targetFile);
768
+ if (!names || names.normalizeIdentifier(imp.imported) !== names.normalizeIdentifier(def.localName))
769
+ return false;
770
+ return (names.localExports
771
+ .get(names.normalizeIdentifier(imp.imported))
772
+ ?.some((candidate) => sameSymbolDef(index, candidate, def)) ?? false);
773
+ }
774
+ export function resolveImported(index, imp, exportedName, opts) {
443
775
  const targetFile = typeof imp.resolved === "string" ? imp.resolved : undefined;
444
776
  if (!targetFile)
445
777
  return null;
446
- let preferredKind;
447
- if (imp.kind === "named") {
448
- if (imp.phpImportType === "function") {
449
- preferredKind = SymbolKind.Function;
778
+ if (imp.kind === "star" && imp.jvmPackageFiles) {
779
+ return resolveJvmPackageExport(index, imp.jvmPackageFiles, exportedName, opts?.argumentCount, imp.jvmPackageLanguageId, imp.jvmSamePackage);
780
+ }
781
+ if ((imp.kind === "star" && (imp.jvmTypeWildcardName || imp.jvmStaticWildcardName)) ||
782
+ (imp.kind === "named" && (imp.jvmTypeOwnerStartIndex !== undefined || imp.jvmStaticWildcardName !== undefined))) {
783
+ const target = moduleFor(index, targetFile);
784
+ if (!target)
785
+ return null;
786
+ const targetLanguageId = supportForFileWithoutHeaderSample(targetFile, index.languageExtensions)?.id;
787
+ let ownerStartIndex;
788
+ if (imp.kind === "star" || imp.jvmTypeOwnerStartIndex === undefined) {
789
+ const ownerName = imp.kind === "star" ? (imp.jvmTypeWildcardName ?? imp.jvmStaticWildcardName) : imp.jvmStaticWildcardName;
790
+ const owner = ownerName && jvmWildcardTypeOwner(target, ownerName, targetLanguageId);
791
+ if (!owner || (owner.javaPackagePrivate && !imp.jvmSamePackage))
792
+ return null;
793
+ ownerStartIndex = owner.range.start.index;
794
+ }
795
+ else {
796
+ ownerStartIndex = imp.jvmTypeOwnerStartIndex;
450
797
  }
451
- else if (imp.phpImportType === "class") {
452
- preferredKind = SymbolKind.Class;
798
+ if (ownerStartIndex === undefined)
799
+ return null;
800
+ const names = moduleNameLookup(index, targetFile);
801
+ if (!names)
802
+ return null;
803
+ let match;
804
+ let overloads;
805
+ for (const candidate of names.localExports.get(names.normalizeIdentifier(exportedName)) ?? []) {
806
+ if ((imp.jvmStaticWildcardName
807
+ ? !isJvmStaticWildcardMember(candidate, ownerStartIndex)
808
+ : !isJvmTypeWildcardMember(candidate, ownerStartIndex, targetLanguageId)) ||
809
+ (candidate.javaPackagePrivate && !imp.jvmSamePackage))
810
+ continue;
811
+ if (match && !sameSymbolDef(index, candidate, match)) {
812
+ if (imp.kind !== "named" || !imp.jvmStaticWildcardName || opts?.argumentCount === undefined)
813
+ return null;
814
+ if (!overloads)
815
+ overloads = [match];
816
+ overloads.push(candidate);
817
+ }
818
+ else {
819
+ match = candidate;
820
+ }
453
821
  }
454
- else if (imp.phpImportType === "const") {
455
- preferredKind = SymbolKind.Variable;
822
+ if (overloads && opts?.argumentCount !== undefined)
823
+ return selectFunctionOverloadByArity(overloads, opts.argumentCount);
824
+ if (match && imp.kind === "named" && imp.jvmStaticWildcardName && opts?.argumentCount !== undefined) {
825
+ const arity = match.callable?.arity;
826
+ if (arity &&
827
+ (opts.argumentCount < arity.minArgs || (arity.maxArgs !== null && opts.argumentCount > arity.maxArgs)))
828
+ return null;
456
829
  }
830
+ return match ?? null;
457
831
  }
458
- const hit = resolveExport(index, targetFile, exportedName, {
459
- ...(preferredKind ? { preferredKind } : {}),
460
- });
461
- if (hit?.kind === "resolved")
832
+ const namespace = opts?.cNamespace ?? (imp.kind === "named" ? imp.cNamespace : undefined);
833
+ if (opts?.cNamespace && imp.kind === "named" && (imp.cNamespace ?? "ordinary") !== opts.cNamespace)
834
+ return null;
835
+ const phpRole = phpNamedImportRole(imp);
836
+ // A C# `using PT = N.Inner.Point` stores the namespace in `from` and the type in
837
+ // `imported`. A bare `Point` lookup is an implicit compilation-unit search, so a peer
838
+ // `N.Point` is the only bare-visible match when this file also declares outer `N`.
839
+ // The alias names one namespace, and that qualified name is what every consumer resolves.
840
+ const support = supportForFileWithoutHeaderSample(targetFile, index.languageExtensions);
841
+ const lookupName = support?.id === "csharp" ? csharpImportLookupName(imp, exportedName) : exportedName;
842
+ if (support?.id === "csharp" && imp.kind === "star" && !imp.staticMembersOf) {
843
+ return resolveCsharpNamespaceImport(index, imp, targetFile, lookupName, {
844
+ ...opts,
845
+ ...(namespace ? { cNamespace: namespace } : {}),
846
+ });
847
+ }
848
+ const hit = phpRole
849
+ ? resolvePhpExportByImportType(index, targetFile, exportedName, phpRole)
850
+ : resolveExport(index, targetFile, lookupName, {
851
+ ...opts,
852
+ ...(namespace ? { cNamespace: namespace } : {}),
853
+ });
854
+ if (hit?.kind === "resolved") {
855
+ if (imp.kind === "named" && hit.def.javaPackagePrivate && !imp.jvmSamePackage)
856
+ return null;
462
857
  return hit.def;
858
+ }
463
859
  if (hit?.kind === "namespace")
464
860
  return { namespace: hit.file };
861
+ if (imp.kind === "default" && exportedName === "default") {
862
+ const moduleEntry = moduleFor(index, targetFile);
863
+ const directValue = moduleEntry && directModuleValueEntry(moduleEntry);
864
+ if (directValue)
865
+ return directValue.target;
866
+ }
465
867
  // Only Java, Kotlin, and Python matter below, so a `.h` target never needs its sample read.
466
- const support = supportForFileWithoutHeaderSample(targetFile, index.languageExtensions);
467
868
  if (support?.id === "java" || support?.id === "kotlin") {
468
- const siblingHit = resolveSiblingPackageExport(index, targetFile, exportedName, support.id);
469
- if (siblingHit?.kind === "resolved")
869
+ const siblingHit = resolveSiblingPackageExport(index, targetFile, exportedName);
870
+ if (siblingHit?.kind === "resolved") {
871
+ if (imp.kind === "named" && siblingHit.def.javaPackagePrivate && !imp.jvmSamePackage)
872
+ return null;
470
873
  return siblingHit.def;
874
+ }
471
875
  if (siblingHit?.kind === "namespace") {
472
876
  return { namespace: siblingHit.file };
473
877
  }
474
878
  }
475
- if (support?.id === "python") {
476
- const submodule = resolvePythonSubmodule(targetFile, exportedName);
879
+ // A named `from pkg import child` may load child as a submodule. A plain
880
+ // namespace import of pkg cannot gain child solely because child.py exists.
881
+ if (support?.id === "python" && imp.kind === "named" && imp.mechanism === "python") {
882
+ const submodule = resolvePythonSubmoduleExact(targetFile, exportedName);
477
883
  if (submodule)
478
884
  return { namespace: submodule };
479
885
  }