@lzehrung/codegraph 2.3.30 → 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 (416) 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 +42229 -28876
  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 -22
  74. package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts.map +1 -1
  75. package/dist/graphs/symbol-graph-detailed/receiver-calls.js +872 -125
  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 +12 -0
  85. package/dist/impact/call-compatibility/providers/index.d.ts.map +1 -1
  86. package/dist/impact/call-compatibility/providers/index.js +16 -22
  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 +316 -552
  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/member-resolution-coverage.d.ts.map +1 -1
  98. package/dist/impact/member-resolution-coverage.js +1 -1
  99. package/dist/impact/member-resolution-coverage.js.map +1 -1
  100. package/dist/impact/reference-cache.d.ts.map +1 -1
  101. package/dist/impact/reference-cache.js +2 -2
  102. package/dist/impact/reference-cache.js.map +1 -1
  103. package/dist/index.d.ts +1 -1
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +1 -1
  106. package/dist/index.js.map +1 -1
  107. package/dist/indexer/ambiguous-resolution.d.ts +11 -0
  108. package/dist/indexer/ambiguous-resolution.d.ts.map +1 -0
  109. package/dist/indexer/ambiguous-resolution.js +19 -0
  110. package/dist/indexer/ambiguous-resolution.js.map +1 -0
  111. package/dist/indexer/build-cache/module-cache.d.ts +38 -0
  112. package/dist/indexer/build-cache/module-cache.d.ts.map +1 -1
  113. package/dist/indexer/build-cache/module-cache.js +151 -9
  114. package/dist/indexer/build-cache/module-cache.js.map +1 -1
  115. package/dist/indexer/build-cache/options.d.ts +16 -43
  116. package/dist/indexer/build-cache/options.d.ts.map +1 -1
  117. package/dist/indexer/build-cache/options.js +16 -43
  118. package/dist/indexer/build-cache/options.js.map +1 -1
  119. package/dist/indexer/build-cache/project-snapshot.d.ts +1 -0
  120. package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -1
  121. package/dist/indexer/build-cache/project-snapshot.js +117 -24
  122. package/dist/indexer/build-cache/project-snapshot.js.map +1 -1
  123. package/dist/indexer/build-cache/resolver-environment.d.ts.map +1 -1
  124. package/dist/indexer/build-cache/resolver-environment.js +32 -2
  125. package/dist/indexer/build-cache/resolver-environment.js.map +1 -1
  126. package/dist/indexer/build-cache.d.ts +1 -1
  127. package/dist/indexer/build-cache.d.ts.map +1 -1
  128. package/dist/indexer/build-cache.js +1 -1
  129. package/dist/indexer/build-cache.js.map +1 -1
  130. package/dist/indexer/build-index.d.ts.map +1 -1
  131. package/dist/indexer/build-index.js +593 -22
  132. package/dist/indexer/build-index.js.map +1 -1
  133. package/dist/indexer/call-hierarchy.js +1 -1
  134. package/dist/indexer/call-hierarchy.js.map +1 -1
  135. package/dist/indexer/compilation-units.d.ts +101 -0
  136. package/dist/indexer/compilation-units.d.ts.map +1 -0
  137. package/dist/indexer/compilation-units.js +605 -0
  138. package/dist/indexer/compilation-units.js.map +1 -0
  139. package/dist/indexer/cpp-callables.d.ts +20 -0
  140. package/dist/indexer/cpp-callables.d.ts.map +1 -0
  141. package/dist/indexer/cpp-callables.js +554 -0
  142. package/dist/indexer/cpp-callables.js.map +1 -0
  143. package/dist/indexer/declaration-visibility.d.ts +36 -2
  144. package/dist/indexer/declaration-visibility.d.ts.map +1 -1
  145. package/dist/indexer/declaration-visibility.js +136 -2
  146. package/dist/indexer/declaration-visibility.js.map +1 -1
  147. package/dist/indexer/expand-star-imports.d.ts.map +1 -1
  148. package/dist/indexer/expand-star-imports.js +28 -6
  149. package/dist/indexer/expand-star-imports.js.map +1 -1
  150. package/dist/indexer/import-types.d.ts +37 -0
  151. package/dist/indexer/import-types.d.ts.map +1 -1
  152. package/dist/indexer/import-types.js +24 -1
  153. package/dist/indexer/import-types.js.map +1 -1
  154. package/dist/indexer/imports/binding-ranges.d.ts +1 -1
  155. package/dist/indexer/imports/binding-ranges.d.ts.map +1 -1
  156. package/dist/indexer/imports/context.d.ts +11 -1
  157. package/dist/indexer/imports/context.d.ts.map +1 -1
  158. package/dist/indexer/imports/import-binding-tables.d.ts +75 -0
  159. package/dist/indexer/imports/import-binding-tables.d.ts.map +1 -0
  160. package/dist/indexer/imports/import-binding-tables.js +544 -0
  161. package/dist/indexer/imports/import-binding-tables.js.map +1 -0
  162. package/dist/indexer/imports/js-text-imports.js +4 -4
  163. package/dist/indexer/imports/js-text-imports.js.map +1 -1
  164. package/dist/indexer/imports/language-specific.d.ts +3 -22
  165. package/dist/indexer/imports/language-specific.d.ts.map +1 -1
  166. package/dist/indexer/imports/language-specific.js +29 -362
  167. package/dist/indexer/imports/language-specific.js.map +1 -1
  168. package/dist/indexer/imports/native-captures.d.ts.map +1 -1
  169. package/dist/indexer/imports/native-captures.js +18 -6
  170. package/dist/indexer/imports/native-captures.js.map +1 -1
  171. package/dist/indexer/imports/python.d.ts +10 -2
  172. package/dist/indexer/imports/python.d.ts.map +1 -1
  173. package/dist/indexer/imports/python.js +91 -40
  174. package/dist/indexer/imports/python.js.map +1 -1
  175. package/dist/indexer/imports/text-import-extractors.d.ts.map +1 -1
  176. package/dist/indexer/imports/text-import-extractors.js +51 -12
  177. package/dist/indexer/imports/text-import-extractors.js.map +1 -1
  178. package/dist/indexer/imports.d.ts.map +1 -1
  179. package/dist/indexer/imports.js +25 -5
  180. package/dist/indexer/imports.js.map +1 -1
  181. package/dist/indexer/incremental-plan.d.ts +33 -0
  182. package/dist/indexer/incremental-plan.d.ts.map +1 -1
  183. package/dist/indexer/incremental-plan.js +187 -1
  184. package/dist/indexer/incremental-plan.js.map +1 -1
  185. package/dist/indexer/locals-and-exports.d.ts +2 -0
  186. package/dist/indexer/locals-and-exports.d.ts.map +1 -1
  187. package/dist/indexer/locals-and-exports.js +565 -54
  188. package/dist/indexer/locals-and-exports.js.map +1 -1
  189. package/dist/indexer/name-lookup-policies/c-family.d.ts +7 -0
  190. package/dist/indexer/name-lookup-policies/c-family.d.ts.map +1 -0
  191. package/dist/indexer/name-lookup-policies/c-family.js +117 -0
  192. package/dist/indexer/name-lookup-policies/c-family.js.map +1 -0
  193. package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts +11 -0
  194. package/dist/indexer/name-lookup-policies/csharp-using-static.d.ts.map +1 -0
  195. package/dist/indexer/name-lookup-policies/csharp-using-static.js +136 -0
  196. package/dist/indexer/name-lookup-policies/csharp-using-static.js.map +1 -0
  197. package/dist/indexer/name-lookup-policies/implicit-self.d.ts +10 -0
  198. package/dist/indexer/name-lookup-policies/implicit-self.d.ts.map +1 -0
  199. package/dist/indexer/name-lookup-policies/implicit-self.js +113 -0
  200. package/dist/indexer/name-lookup-policies/implicit-self.js.map +1 -0
  201. package/dist/indexer/name-lookup-policies/index.d.ts +3 -0
  202. package/dist/indexer/name-lookup-policies/index.d.ts.map +1 -0
  203. package/dist/indexer/name-lookup-policies/index.js +106 -0
  204. package/dist/indexer/name-lookup-policies/index.js.map +1 -0
  205. package/dist/indexer/name-lookup-policies/php.d.ts +3 -0
  206. package/dist/indexer/name-lookup-policies/php.d.ts.map +1 -0
  207. package/dist/indexer/name-lookup-policies/php.js +75 -0
  208. package/dist/indexer/name-lookup-policies/php.js.map +1 -0
  209. package/dist/indexer/name-resolution-types.d.ts +99 -0
  210. package/dist/indexer/name-resolution-types.d.ts.map +1 -0
  211. package/dist/indexer/name-resolution-types.js +2 -0
  212. package/dist/indexer/name-resolution-types.js.map +1 -0
  213. package/dist/indexer/name-resolution.d.ts +52 -0
  214. package/dist/indexer/name-resolution.d.ts.map +1 -0
  215. package/dist/indexer/name-resolution.js +189 -0
  216. package/dist/indexer/name-resolution.js.map +1 -0
  217. package/dist/indexer/navigation-cpp.d.ts +50 -0
  218. package/dist/indexer/navigation-cpp.d.ts.map +1 -0
  219. package/dist/indexer/navigation-cpp.js +654 -0
  220. package/dist/indexer/navigation-cpp.js.map +1 -0
  221. package/dist/indexer/navigation-goto.d.ts +107 -4
  222. package/dist/indexer/navigation-goto.d.ts.map +1 -1
  223. package/dist/indexer/navigation-goto.js +2075 -137
  224. package/dist/indexer/navigation-goto.js.map +1 -1
  225. package/dist/indexer/navigation-local.d.ts +18 -2
  226. package/dist/indexer/navigation-local.d.ts.map +1 -1
  227. package/dist/indexer/navigation-local.js +498 -61
  228. package/dist/indexer/navigation-local.js.map +1 -1
  229. package/dist/indexer/navigation-php.d.ts +66 -0
  230. package/dist/indexer/navigation-php.d.ts.map +1 -1
  231. package/dist/indexer/navigation-php.js +287 -4
  232. package/dist/indexer/navigation-php.js.map +1 -1
  233. package/dist/indexer/navigation-references.d.ts +72 -5
  234. package/dist/indexer/navigation-references.d.ts.map +1 -1
  235. package/dist/indexer/navigation-references.js +620 -54
  236. package/dist/indexer/navigation-references.js.map +1 -1
  237. package/dist/indexer/navigation-resolve.d.ts +33 -2
  238. package/dist/indexer/navigation-resolve.d.ts.map +1 -1
  239. package/dist/indexer/navigation-resolve.js +446 -193
  240. package/dist/indexer/navigation-resolve.js.map +1 -1
  241. package/dist/indexer/navigation.d.ts +28 -2
  242. package/dist/indexer/navigation.d.ts.map +1 -1
  243. package/dist/indexer/navigation.js +1082 -151
  244. package/dist/indexer/navigation.js.map +1 -1
  245. package/dist/indexer/php-namespace-symbols.d.ts +66 -0
  246. package/dist/indexer/php-namespace-symbols.d.ts.map +1 -0
  247. package/dist/indexer/php-namespace-symbols.js +342 -0
  248. package/dist/indexer/php-namespace-symbols.js.map +1 -0
  249. package/dist/indexer/reference-context.d.ts +2 -0
  250. package/dist/indexer/reference-context.d.ts.map +1 -1
  251. package/dist/indexer/reference-context.js +4 -0
  252. package/dist/indexer/reference-context.js.map +1 -1
  253. package/dist/indexer/scope-nodes.d.ts +92 -13
  254. package/dist/indexer/scope-nodes.d.ts.map +1 -1
  255. package/dist/indexer/scope-nodes.js +212 -20
  256. package/dist/indexer/scope-nodes.js.map +1 -1
  257. package/dist/indexer/scope-types.d.ts +25 -1
  258. package/dist/indexer/scope-types.d.ts.map +1 -1
  259. package/dist/indexer/scope.d.ts.map +1 -1
  260. package/dist/indexer/scope.js +894 -45
  261. package/dist/indexer/scope.js.map +1 -1
  262. package/dist/indexer/shared-owner-identity.d.ts +53 -0
  263. package/dist/indexer/shared-owner-identity.d.ts.map +1 -0
  264. package/dist/indexer/shared-owner-identity.js +460 -0
  265. package/dist/indexer/shared-owner-identity.js.map +1 -0
  266. package/dist/indexer/shared.d.ts +1 -1
  267. package/dist/indexer/shared.d.ts.map +1 -1
  268. package/dist/indexer/shared.js +1 -1
  269. package/dist/indexer/shared.js.map +1 -1
  270. package/dist/indexer/star-import-precedence.d.ts +114 -0
  271. package/dist/indexer/star-import-precedence.d.ts.map +1 -0
  272. package/dist/indexer/star-import-precedence.js +396 -0
  273. package/dist/indexer/star-import-precedence.js.map +1 -0
  274. package/dist/indexer/symbols.d.ts +3 -1
  275. package/dist/indexer/symbols.d.ts.map +1 -1
  276. package/dist/indexer/symbols.js +58 -18
  277. package/dist/indexer/symbols.js.map +1 -1
  278. package/dist/indexer/ts-callables.d.ts +51 -0
  279. package/dist/indexer/ts-callables.d.ts.map +1 -0
  280. package/dist/indexer/ts-callables.js +264 -0
  281. package/dist/indexer/ts-callables.js.map +1 -0
  282. package/dist/indexer/types.d.ts +23 -1
  283. package/dist/indexer/types.d.ts.map +1 -1
  284. package/dist/indexer/unused-exports.d.ts +13 -0
  285. package/dist/indexer/unused-exports.d.ts.map +1 -0
  286. package/dist/indexer/unused-exports.js +159 -0
  287. package/dist/indexer/unused-exports.js.map +1 -0
  288. package/dist/indexer/workspace-symbols.d.ts.map +1 -1
  289. package/dist/indexer/workspace-symbols.js +3 -2
  290. package/dist/indexer/workspace-symbols.js.map +1 -1
  291. package/dist/indexer.d.ts +2 -2
  292. package/dist/indexer.d.ts.map +1 -1
  293. package/dist/indexer.js +1 -1
  294. package/dist/indexer.js.map +1 -1
  295. package/dist/languages/callable-arity.d.ts +202 -0
  296. package/dist/languages/callable-arity.d.ts.map +1 -0
  297. package/dist/languages/callable-arity.js +1182 -0
  298. package/dist/languages/callable-arity.js.map +1 -0
  299. package/dist/languages/definitions/c-family.d.ts.map +1 -1
  300. package/dist/languages/definitions/c-family.js +30 -1
  301. package/dist/languages/definitions/c-family.js.map +1 -1
  302. package/dist/languages/definitions/c.d.ts +4 -0
  303. package/dist/languages/definitions/c.d.ts.map +1 -1
  304. package/dist/languages/definitions/c.js +19 -0
  305. package/dist/languages/definitions/c.js.map +1 -1
  306. package/dist/languages/definitions/cpp.d.ts.map +1 -1
  307. package/dist/languages/definitions/cpp.js +12 -0
  308. package/dist/languages/definitions/cpp.js.map +1 -1
  309. package/dist/languages/definitions/csharp.d.ts.map +1 -1
  310. package/dist/languages/definitions/csharp.js +2 -8
  311. package/dist/languages/definitions/csharp.js.map +1 -1
  312. package/dist/languages/definitions/go.d.ts.map +1 -1
  313. package/dist/languages/definitions/go.js +3 -0
  314. package/dist/languages/definitions/go.js.map +1 -1
  315. package/dist/languages/definitions/javascript.d.ts.map +1 -1
  316. package/dist/languages/definitions/javascript.js +10 -1
  317. package/dist/languages/definitions/javascript.js.map +1 -1
  318. package/dist/languages/definitions/js-family.d.ts +1 -1
  319. package/dist/languages/definitions/js-family.d.ts.map +1 -1
  320. package/dist/languages/definitions/js-family.js +7 -1
  321. package/dist/languages/definitions/js-family.js.map +1 -1
  322. package/dist/languages/definitions/php.d.ts.map +1 -1
  323. package/dist/languages/definitions/php.js +5 -1
  324. package/dist/languages/definitions/php.js.map +1 -1
  325. package/dist/languages/definitions/typescript.d.ts.map +1 -1
  326. package/dist/languages/definitions/typescript.js +8 -1
  327. package/dist/languages/definitions/typescript.js.map +1 -1
  328. package/dist/languages/definitions/zig.d.ts.map +1 -1
  329. package/dist/languages/definitions/zig.js +2 -0
  330. package/dist/languages/definitions/zig.js.map +1 -1
  331. package/dist/mcp/handlers.js +14 -7
  332. package/dist/mcp/handlers.js.map +1 -1
  333. package/dist/review/candidates.d.ts.map +1 -1
  334. package/dist/review/candidates.js +1 -1
  335. package/dist/review/candidates.js.map +1 -1
  336. package/dist/review/deleted.d.ts +3 -3
  337. package/dist/review/deleted.d.ts.map +1 -1
  338. package/dist/review/deleted.js +82 -32
  339. package/dist/review/deleted.js.map +1 -1
  340. package/dist/review/report.d.ts +1 -0
  341. package/dist/review/report.d.ts.map +1 -1
  342. package/dist/review/report.js +1 -1
  343. package/dist/review/report.js.map +1 -1
  344. package/dist/review.d.ts.map +1 -1
  345. package/dist/review.js +1 -0
  346. package/dist/review.js.map +1 -1
  347. package/dist/sql/navigation.d.ts.map +1 -1
  348. package/dist/sql/navigation.js +1 -0
  349. package/dist/sql/navigation.js.map +1 -1
  350. package/dist/sql/source-graph.d.ts.map +1 -1
  351. package/dist/sql/source-graph.js +2 -2
  352. package/dist/sql/source-graph.js.map +1 -1
  353. package/dist/sqlite/schema.d.ts +1 -1
  354. package/dist/sqlite/schema.d.ts.map +1 -1
  355. package/dist/sqlite/schema.js +8 -2
  356. package/dist/sqlite/schema.js.map +1 -1
  357. package/dist/sqlite/write.js +2 -2
  358. package/dist/sqlite/write.js.map +1 -1
  359. package/dist/types.d.ts +2 -0
  360. package/dist/types.d.ts.map +1 -1
  361. package/dist/util/bloom-filter.d.ts +7 -1
  362. package/dist/util/bloom-filter.d.ts.map +1 -1
  363. package/dist/util/bloom-filter.js +12 -2
  364. package/dist/util/bloom-filter.js.map +1 -1
  365. package/dist/util/dynamic-import-tables.d.ts +88 -0
  366. package/dist/util/dynamic-import-tables.d.ts.map +1 -0
  367. package/dist/util/dynamic-import-tables.js +100 -0
  368. package/dist/util/dynamic-import-tables.js.map +1 -0
  369. package/dist/util/graph-edges.d.ts +19 -1
  370. package/dist/util/graph-edges.d.ts.map +1 -1
  371. package/dist/util/graph-edges.js +30 -4
  372. package/dist/util/graph-edges.js.map +1 -1
  373. package/dist/util/identifiers.d.ts +15 -0
  374. package/dist/util/identifiers.d.ts.map +1 -1
  375. package/dist/util/identifiers.js +35 -0
  376. package/dist/util/identifiers.js.map +1 -1
  377. package/dist/util/member-access-tables.d.ts +129 -0
  378. package/dist/util/member-access-tables.d.ts.map +1 -0
  379. package/dist/util/member-access-tables.js +285 -0
  380. package/dist/util/member-access-tables.js.map +1 -0
  381. package/dist/util/member-access.d.ts +17 -0
  382. package/dist/util/member-access.d.ts.map +1 -1
  383. package/dist/util/member-access.js +138 -93
  384. package/dist/util/member-access.js.map +1 -1
  385. package/dist/util/resolution/cargo-targets.d.ts +11 -0
  386. package/dist/util/resolution/cargo-targets.d.ts.map +1 -1
  387. package/dist/util/resolution/cargo-targets.js +174 -13
  388. package/dist/util/resolution/cargo-targets.js.map +1 -1
  389. package/dist/util/resolution/csharp.d.ts +33 -1
  390. package/dist/util/resolution/csharp.d.ts.map +1 -1
  391. package/dist/util/resolution/csharp.js +145 -30
  392. package/dist/util/resolution/csharp.js.map +1 -1
  393. package/dist/util/resolution/php.d.ts.map +1 -1
  394. package/dist/util/resolution/php.js +35 -8
  395. package/dist/util/resolution/php.js.map +1 -1
  396. package/dist/util/resolution/python.d.ts +9 -0
  397. package/dist/util/resolution/python.d.ts.map +1 -1
  398. package/dist/util/resolution/python.js +46 -0
  399. package/dist/util/resolution/python.js.map +1 -1
  400. package/dist/util/resolution/rust.d.ts.map +1 -1
  401. package/dist/util/resolution/rust.js +95 -26
  402. package/dist/util/resolution/rust.js.map +1 -1
  403. package/dist/util/resolution-candidates.d.ts +5 -0
  404. package/dist/util/resolution-candidates.d.ts.map +1 -1
  405. package/dist/util/resolution-candidates.js +16 -3
  406. package/dist/util/resolution-candidates.js.map +1 -1
  407. package/dist/util/resolution.d.ts +2 -1
  408. package/dist/util/resolution.d.ts.map +1 -1
  409. package/dist/util/resolution.js +96 -5
  410. package/dist/util/resolution.js.map +1 -1
  411. package/dist/util/specifiers.d.ts +20 -0
  412. package/dist/util/specifiers.d.ts.map +1 -1
  413. package/dist/util/specifiers.js +39 -93
  414. package/dist/util/specifiers.js.map +1 -1
  415. package/docs/mcp.md +3 -2
  416. package/package.json +3 -3
@@ -1,8 +1,60 @@
1
1
  import { sliceText, toRange } from "../util/ast.js";
2
2
  import { getNativeSyntaxTreeExecution } from "../native/tree-sitter-native.js";
3
3
  import { ProjectedSyntaxTree } from "../native/projected-tree.js";
4
+ import { getMemberAccessParts, isMemberAccessNode } from "../util/member-access.js";
4
5
  import { declarationKindToBindingKind } from "./declarations.js";
5
- import { scopeNodesFor } from "./scope-nodes.js";
6
+ import { cppBindingCallableShape, cppSelectCallableBinding } from "./cpp-callables.js";
7
+ import { typescriptCallableCandidatesInContainer, typescriptCallableRole } from "./ts-callables.js";
8
+ import { cppQualifiedNameSegments } from "../graphs/symbol-graph-detailed/receiver-calls.js";
9
+ import { phpConstructorPromotedVariable } from "./navigation-php.js";
10
+ import { cScopeName, cTagRole } from "../languages/definitions/c.js";
11
+ import { bindingCoversUse, isExplicitMethodCall, laterLocalBlocksOuterUse, scopeAllowsUse, scopeIdentifierKey, scopeNodesFor, } from "./scope-nodes.js";
12
+ const FUNCTION_DECLARATOR_NAME_TYPES = {
13
+ identifier: true,
14
+ field_identifier: true,
15
+ destructor_name: true,
16
+ operator_name: true,
17
+ };
18
+ function nestedFunctionDeclaratorName(node) {
19
+ let current = node;
20
+ for (let depth = 0; current && depth < 8; depth += 1) {
21
+ if (FUNCTION_DECLARATOR_NAME_TYPES[current.type])
22
+ return current;
23
+ current = current.childForFieldName("name");
24
+ }
25
+ return null;
26
+ }
27
+ function declaredNameNode(node, row) {
28
+ const directName = node.childForFieldName("name");
29
+ if (directName)
30
+ return directName;
31
+ if (!row.functionNameTypes?.has(node.type))
32
+ return null;
33
+ let current = node.childForFieldName("declarator");
34
+ for (let depth = 0; current && depth < 8; depth += 1) {
35
+ const name = current.childForFieldName("name");
36
+ const declaredName = name ? nestedFunctionDeclaratorName(name) : nestedFunctionDeclaratorName(current);
37
+ if (declaredName)
38
+ return declaredName;
39
+ current =
40
+ current.childForFieldName("declarator") ??
41
+ (current.type === "reference_declarator" ? (current.namedChildren[0] ?? null) : null);
42
+ }
43
+ return null;
44
+ }
45
+ function qualifiedCppIdentifierForName(nameNode, boundary) {
46
+ let current = nameNode.parent;
47
+ while (current && current !== boundary) {
48
+ if (current.type === "qualified_identifier") {
49
+ const memberName = current.childForFieldName("name");
50
+ const containsName = memberName && memberName.startIndex <= nameNode.startIndex && memberName.endIndex >= nameNode.endIndex;
51
+ if (containsName && current.parent?.type !== "qualified_identifier")
52
+ return current;
53
+ }
54
+ current = current.parent;
55
+ }
56
+ return null;
57
+ }
6
58
  export function buildScopeIndexFromSource(file, source, support, imports = [], opts) {
7
59
  let tree = opts?.tree ?? null;
8
60
  if (!tree) {
@@ -22,13 +74,42 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
22
74
  };
23
75
  const stack = [rootScope];
24
76
  const allScopes = [rootScope];
77
+ const cppNamespaceMaps = new Map();
78
+ const cppNamespaceScopes = new Map();
79
+ const cppNamespacePath = [];
80
+ const cppNamespacePathByMap = new WeakMap();
25
81
  const extraBindings = [];
82
+ const cppQualifiedMemberBindings = new Map();
83
+ const cppQualifiedMemberOccurrences = new Map();
84
+ const cppFunctionCollisionGroups = new Set();
85
+ const cppFunctionOccurrences = [];
86
+ // Retain imported C tag forwards only when a later same-file declaration completes the tag.
87
+ let cImportedForwardTags;
88
+ const extraBindingSpans = new Set();
89
+ const bindingSpanKey = (binding) => {
90
+ const start = binding.def?.start.index;
91
+ const end = binding.def?.end.index;
92
+ return `${binding.canonicalName}:${start ?? ""}:${end ?? ""}`;
93
+ };
94
+ const preserveExtraBinding = (binding) => {
95
+ const key = bindingSpanKey(binding);
96
+ if (extraBindingSpans.has(key))
97
+ return;
98
+ extraBindingSpans.add(key);
99
+ extraBindings.push(binding);
100
+ };
101
+ /**
102
+ * Name nodes already registered before their construct's own scope was pushed. Keyed by source
103
+ * span rather than `node.id`, which the projected tree leaves optional.
104
+ */
105
+ const preRegisteredNameSpans = new Set();
106
+ const nameSpanKey = (node) => `${node.startIndex}:${node.endIndex}`;
26
107
  const normalizeIdentifier = support.normalizeIdentifier;
27
108
  const buildBinding = (nameNode, kind) => {
28
109
  const name = sliceText(nameNode, source);
29
110
  return {
30
111
  name,
31
- canonicalName: normalizeIdentifier(name),
112
+ canonicalName: scopeIdentifierKey(row, name, nameNode, normalizeIdentifier),
32
113
  kind,
33
114
  def: toRange(nameNode),
34
115
  node: nameNode,
@@ -43,7 +124,10 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
43
124
  occurrences: [],
44
125
  import: importBinding,
45
126
  };
46
- rootScope.map.set(binding.canonicalName, binding);
127
+ const key = support.id === "c" && importBinding.kind === "named" && importBinding.cNamespace === "tag"
128
+ ? cScopeName(binding.canonicalName, "tag")
129
+ : binding.canonicalName;
130
+ rootScope.map.set(key, binding);
47
131
  };
48
132
  for (const imp of imports) {
49
133
  if (imp.kind === "default") {
@@ -57,6 +141,28 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
57
141
  }
58
142
  }
59
143
  const row = scopeNodesFor(support.id);
144
+ /** Covering-declaration names collected before a scope's body is walked, keyed by syntax node id. */
145
+ const pendingNamesByNodeId = new Map();
146
+ /**
147
+ * JS and TS record let/const/class/type names during the existing hoist walk. A use defers only
148
+ * when one of those names is still ahead, so the queue stays the forward references.
149
+ */
150
+ const tracksLexicalNames = !!(row.hoistedFunctionTypes || row.hoistedVariableDeclarationTypes);
151
+ const canDeferForward = !tracksLexicalNames &&
152
+ (!!row.wholeScopeKinds?.size ||
153
+ !!row.wholeScopeDeclarationTypes?.size ||
154
+ !!row.variableTargetScopeKinds?.size ||
155
+ !!row.laterLocalBlocksOuterKinds?.size ||
156
+ !!row.moduleBindingsAtFunctionRuntime);
157
+ const nodeById = (id) => tree instanceof ProjectedSyntaxTree ? tree.nodeById(id) : undefined;
158
+ const attachPendingNames = (scope) => {
159
+ const nodeId = scope.node.id;
160
+ if (nodeId === undefined)
161
+ return;
162
+ const names = pendingNamesByNodeId.get(nodeId);
163
+ if (names && names.size > 0)
164
+ scope.pendingCoveringNames = names;
165
+ };
60
166
  const idSet = new Set([...support.nodeTypes.identifier, ...(support.nodeTypes.shorthandPropertyIdentifier ?? [])]);
61
167
  const scopeDeclarationNames = support.scopeDeclarationNames;
62
168
  const isParamNode = (node) => {
@@ -68,9 +174,216 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
68
174
  }
69
175
  return false;
70
176
  };
177
+ const declarationCoversScope = (nameNode) => {
178
+ const types = row.wholeScopeDeclarationTypes;
179
+ const memberTypes = row.wholeScopeMemberDeclarationTypes;
180
+ if (!types && !memberTypes)
181
+ return false;
182
+ let current = nameNode.parent;
183
+ for (let depth = 0; current && depth < 8; depth += 1) {
184
+ const functionScope = support.createsFunctionScope(current);
185
+ if (functionScope) {
186
+ const declaredName = current.childForFieldName("name");
187
+ if (!declaredName ||
188
+ declaredName.startIndex !== nameNode.startIndex ||
189
+ declaredName.endIndex !== nameNode.endIndex)
190
+ break;
191
+ }
192
+ if (types?.has(current.type))
193
+ return true;
194
+ if (memberTypes?.has(current.type) && current.parent && row.memberContainerTypes?.has(current.parent.type)) {
195
+ return true;
196
+ }
197
+ if (current.type === "variable_declarator" && current.parent && types?.has(current.parent.type))
198
+ return true;
199
+ // A local inside a function is not the function's own declaration.
200
+ if (functionScope || support.createsBlockScope(current))
201
+ break;
202
+ current = current.parent;
203
+ }
204
+ return false;
205
+ };
206
+ const stealCoveredOccurrences = (target, binding, key) => {
207
+ if (!binding.coversEnclosingScope)
208
+ return;
209
+ const sources = [];
210
+ const pushChain = (found) => {
211
+ let current = found;
212
+ while (current && current !== binding) {
213
+ sources.push(current);
214
+ current = current.earlierSameScope;
215
+ }
216
+ };
217
+ // A same-scope redeclaration keeps its own uses. Only an outer binding can be shadowed.
218
+ let parent = target.parent;
219
+ while (parent) {
220
+ const found = parent.map.get(key);
221
+ if (found) {
222
+ pushChain(found);
223
+ break;
224
+ }
225
+ parent = parent.parent;
226
+ }
227
+ const start = target.node.startIndex;
228
+ const end = target.node.endIndex;
229
+ const seen = new Set();
230
+ for (const source of sources) {
231
+ if (seen.has(source.occurrences))
232
+ continue;
233
+ seen.add(source.occurrences);
234
+ const occurrences = source.occurrences;
235
+ let write = 0;
236
+ let moved = 0;
237
+ for (let index = 0; index < occurrences.length; index += 1) {
238
+ const occurrence = occurrences[index];
239
+ const occurrenceStart = occurrence.start.index;
240
+ const occurrenceEnd = occurrence.end.index;
241
+ if (occurrenceStart !== undefined &&
242
+ occurrenceEnd !== undefined &&
243
+ occurrenceStart >= start &&
244
+ occurrenceEnd <= end) {
245
+ binding.occurrences.push(occurrence);
246
+ moved += 1;
247
+ }
248
+ else {
249
+ occurrences[write++] = occurrence;
250
+ }
251
+ }
252
+ if (moved > 0)
253
+ occurrences.length = write;
254
+ }
255
+ };
71
256
  const addBinding = (target, nameNode, kind) => {
72
257
  const binding = buildBinding(nameNode, kind);
73
- target.map.set(binding.canonicalName, binding);
258
+ if (row.wholeScopeKinds?.has(target.kind) || declarationCoversScope(nameNode)) {
259
+ binding.coversEnclosingScope = true;
260
+ }
261
+ const tagRole = support.id === "c" ? cTagRole(nameNode) : undefined;
262
+ const key = tagRole ? cScopeName(binding.canonicalName, "tag") : binding.canonicalName;
263
+ if (tagRole === "reference") {
264
+ const visible = lookup(binding.name, nameNode);
265
+ if (visible) {
266
+ visible.occurrences.push(binding.def);
267
+ return;
268
+ }
269
+ }
270
+ const existing = target.map.get(key);
271
+ if (tagRole === "forward" && existing?.import) {
272
+ existing.occurrences.push(binding.def);
273
+ cImportedForwardTags ??= new Map();
274
+ if (!cImportedForwardTags.has(existing))
275
+ cImportedForwardTags.set(existing, binding);
276
+ return;
277
+ }
278
+ if (tagRole === "declaration" && existing?.import) {
279
+ binding.occurrences = existing.occurrences;
280
+ const forward = cImportedForwardTags?.get(existing);
281
+ if (forward) {
282
+ forward.occurrences = binding.occurrences;
283
+ binding.earlierSameScope = forward;
284
+ }
285
+ binding.occurrences.push(binding.def);
286
+ preserveExtraBinding(existing);
287
+ }
288
+ if (tagRole && existing?.def) {
289
+ if (existing.def.start.index === binding.def?.start.index)
290
+ return;
291
+ binding.occurrences = existing.occurrences;
292
+ if (tagRole === "declaration" && existing.node && cTagRole(existing.node) !== "declaration") {
293
+ binding.occurrences.push(existing.def);
294
+ preserveExtraBinding(existing);
295
+ // The forward tag remains visible from its declaration until this completion.
296
+ binding.earlierSameScope = existing;
297
+ target.map.set(key, binding);
298
+ return;
299
+ }
300
+ binding.occurrences.push(binding.def);
301
+ preserveExtraBinding(binding);
302
+ return;
303
+ }
304
+ if (kind === "function" && existing?.kind === "function") {
305
+ if (support.id === "c") {
306
+ // C prototypes and their definitions are declarations of one function. Keep each
307
+ // declaration addressable while sharing the occurrence list collected for that name.
308
+ binding.occurrences = existing.occurrences;
309
+ preserveExtraBinding(binding);
310
+ return;
311
+ }
312
+ if (support.id === "cpp") {
313
+ const collisions = existing.sameScopeFunctionBindings ?? [existing];
314
+ collisions.push(binding);
315
+ for (const collision of collisions)
316
+ collision.sameScopeFunctionBindings = collisions;
317
+ cppFunctionCollisionGroups.add(collisions);
318
+ preserveExtraBinding(existing);
319
+ }
320
+ if (support.id === "ts" || support.id === "tsx") {
321
+ const candidates = existing.sameScopeFunctionBindings ?? [existing];
322
+ const collisions = typescriptCallableCandidatesInContainer(candidates, tree, (candidate) => candidate.def, nameNode.startIndex, nameNode.endIndex);
323
+ if (collisions.includes(existing)) {
324
+ let grouped = candidates;
325
+ if (collisions !== candidates)
326
+ grouped = [...collisions];
327
+ grouped.push(binding);
328
+ for (const collision of grouped)
329
+ collision.sameScopeFunctionBindings = grouped;
330
+ const existingRole = existing.node ? typescriptCallableRole(existing.node) : "other";
331
+ const nextRole = typescriptCallableRole(nameNode);
332
+ if (existingRole === "implementation" && nextRole === "signature") {
333
+ preserveExtraBinding(binding);
334
+ return;
335
+ }
336
+ if (existingRole === "signature" && nextRole === "implementation") {
337
+ preserveExtraBinding(existing);
338
+ }
339
+ else if (existingRole === "signature" && nextRole === "signature") {
340
+ preserveExtraBinding(binding);
341
+ return;
342
+ }
343
+ }
344
+ }
345
+ }
346
+ const sameSpan = !!existing?.def &&
347
+ !!binding.def &&
348
+ existing.def.start.index === binding.def.start.index &&
349
+ existing.def.end.index === binding.def.end.index;
350
+ // Pattern walks can register one name node twice. A second pass with a different kind is the
351
+ // real classification (`module` is pre-registered as a class, then as a type) and replaces it.
352
+ if (sameSpan && existing?.kind === kind)
353
+ return;
354
+ // A second local in a whole-scope scope is the same binding (Python assignments). Keep the
355
+ // first declaration and record the later one as an occurrence so an earlier use does not get
356
+ // attached only to the textually last declaration.
357
+ if (!sameSpan &&
358
+ existing &&
359
+ kind === "local" &&
360
+ existing.kind === "local" &&
361
+ !tagRole &&
362
+ !!row.variableTargetScopeKinds &&
363
+ row.wholeScopeKinds?.has(target.kind)) {
364
+ if (binding.def)
365
+ existing.occurrences.push(binding.def);
366
+ return;
367
+ }
368
+ // Preserving an overload as an extra binding must not hide it from earlier C++ uses.
369
+ if (!sameSpan &&
370
+ existing &&
371
+ (!extraBindingSpans.has(bindingSpanKey(existing)) ||
372
+ (support.id === "cpp" && kind === "function" && existing.kind === "function"))) {
373
+ binding.earlierSameScope = existing;
374
+ }
375
+ target.map.set(key, binding);
376
+ if (binding.coversEnclosingScope)
377
+ target.pendingCoveringNames?.delete(binding.canonicalName);
378
+ if (!tracksLexicalNames)
379
+ stealCoveredOccurrences(target, binding, key);
380
+ const cppNamespace = cppNamespacePathByMap.get(target.map);
381
+ if (support.id === "cpp" && kind === "function" && cppNamespace) {
382
+ const qualifiedKey = `${cppNamespace}::${binding.name}`;
383
+ const qualifiedBindings = cppQualifiedMemberBindings.get(qualifiedKey) ?? [];
384
+ qualifiedBindings.push(binding);
385
+ cppQualifiedMemberBindings.set(qualifiedKey, qualifiedBindings);
386
+ }
74
387
  };
75
388
  const addDecl = (nameNode, kind) => {
76
389
  const target = stack[stack.length - 1];
@@ -89,26 +402,119 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
89
402
  // type parameter: Go struct fields are accessed through a receiver from
90
403
  // anywhere in the file, unlike a type parameter, which is scoped to its own
91
404
  // declaration.
405
+ const variableDeclarationScope = () => {
406
+ const current = stack[stack.length - 1] ?? rootScope;
407
+ const targetKinds = row.variableTargetScopeKinds;
408
+ if (!targetKinds)
409
+ return current;
410
+ const boundary = row.variableScopeBoundaryTypes;
411
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
412
+ const scope = stack[index];
413
+ if (boundary) {
414
+ const parentType = scope.node.parent?.type;
415
+ if (boundary.has(scope.node.type) || (parentType !== undefined && boundary.has(parentType)))
416
+ return scope;
417
+ }
418
+ if (targetKinds.has(scope.kind))
419
+ return scope;
420
+ }
421
+ return current;
422
+ };
423
+ const addVariableDecl = (nameNode, kind) => {
424
+ addBinding(variableDeclarationScope(), nameNode, kind);
425
+ };
92
426
  const addDeclSkippingTypeScope = (nameNode, kind) => {
427
+ if (kind === "local" && row.variableTargetScopeKinds) {
428
+ addVariableDecl(nameNode, kind);
429
+ return;
430
+ }
93
431
  const target = [...stack].reverse().find((scope) => scope.kind !== "type") ?? rootScope;
94
432
  addBinding(target, nameNode, kind);
95
433
  };
96
- const lookup = (name) => {
97
- const canonicalName = normalizeIdentifier(name);
434
+ const lookup = (name, node) => {
435
+ const normalizedName = node ? scopeIdentifierKey(row, name, node, normalizeIdentifier) : normalizeIdentifier(name);
436
+ const canonicalName = support.id === "c" && node && cTagRole(node) ? cScopeName(normalizedName, "tag") : normalizedName;
437
+ const methodCall = !!node && isExplicitMethodCall(row, node);
98
438
  for (let index = stack.length - 1; index >= 0; index--) {
99
- const hit = stack[index].map.get(canonicalName);
439
+ const scope = stack[index];
440
+ if (node && !scopeAllowsUse(row, scope, node))
441
+ continue;
442
+ let hit = scope.map.get(canonicalName);
443
+ while (methodCall && hit?.kind === "local")
444
+ hit = hit.earlierSameScope;
445
+ if (hit)
446
+ return hit;
447
+ }
448
+ let root = rootScope.map.get(canonicalName);
449
+ while (methodCall && root?.kind === "local")
450
+ root = root.earlierSameScope;
451
+ return root;
452
+ };
453
+ const lookupOutsideFunctions = (name) => {
454
+ const canonicalName = `$${normalizeIdentifier(name)}`;
455
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
456
+ const scope = stack[index];
457
+ if (scope.kind === "function")
458
+ continue;
459
+ const hit = scope.map.get(canonicalName);
100
460
  if (hit)
101
461
  return hit;
102
462
  }
103
463
  return rootScope.map.get(canonicalName);
104
464
  };
465
+ const isPhpThisPropertyName = (nameNode) => {
466
+ const parent = nameNode.parent;
467
+ if (!parent || parent.type !== "member_access_expression")
468
+ return false;
469
+ const property = parent.childForFieldName("name") ?? parent.namedChildren.find((child) => child.type === "name") ?? null;
470
+ if (!property || property.startIndex !== nameNode.startIndex || property.endIndex !== nameNode.endIndex) {
471
+ return false;
472
+ }
473
+ const object = parent.childForFieldName("object") ?? parent.namedChildren[0] ?? null;
474
+ if (!object || object.startIndex === property.startIndex)
475
+ return false;
476
+ return sliceText(object, source) === "$this";
477
+ };
478
+ const promotedVariablesInClass = (classNode) => {
479
+ const variables = [];
480
+ const visit = (current) => {
481
+ if (current !== classNode &&
482
+ (current.type === "class_declaration" ||
483
+ current.type === "trait_declaration" ||
484
+ current.type === "enum_declaration" ||
485
+ current.type === "function_definition")) {
486
+ return;
487
+ }
488
+ if (current.type === "method_declaration") {
489
+ const name = current.childForFieldName("name");
490
+ if (!name || sliceText(name, source) !== "__construct")
491
+ return;
492
+ const params = current.childForFieldName("parameters");
493
+ for (const child of params?.namedChildren ?? []) {
494
+ const variable = phpConstructorPromotedVariable(child, source);
495
+ if (variable)
496
+ variables.push(variable);
497
+ }
498
+ return;
499
+ }
500
+ for (const child of current.namedChildren)
501
+ visit(child);
502
+ };
503
+ visit(classNode);
504
+ return variables;
505
+ };
105
506
  const addPatternDecls = (pattern, kind, addBindingToScope = addDecl) => {
507
+ if (pattern.type === "property_promotion_parameter" && phpConstructorPromotedVariable(pattern, source)) {
508
+ return;
509
+ }
106
510
  if (idSet.has(pattern.type)) {
107
511
  addBindingToScope(pattern, kind);
108
512
  return;
109
513
  }
110
- // Parameter nodes put names and types as siblings. Walking the whole subtree
111
- // would register type-position identifiers (`int`, `T`, package qualifiers).
514
+ // Parameter nodes put names and types as siblings. Walking the whole subtree for bindings
515
+ // would register type-position identifiers (`int`, `T`, package qualifiers) as new locals;
516
+ // `walk` still visits the type field so a proven declaration (e.g. a struct name used as a
517
+ // parameter type) records this position as one of its occurrences.
112
518
  if (row.destructuringTypeFieldTypes?.has(pattern.type)) {
113
519
  const typeNode = pattern.childForFieldName("type");
114
520
  for (const child of pattern.namedChildren) {
@@ -116,6 +522,8 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
116
522
  continue;
117
523
  addPatternDecls(child, kind, addBindingToScope);
118
524
  }
525
+ if (typeNode)
526
+ walk(typeNode);
119
527
  return;
120
528
  }
121
529
  if (row.destructuringPairPatternTypes?.has(pattern.type)) {
@@ -129,6 +537,15 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
129
537
  addPatternDecls(child, kind, addBindingToScope);
130
538
  }
131
539
  };
540
+ const isAwaitedDynamicImport = (node) => {
541
+ if (!node || node.type !== "await_expression")
542
+ return false;
543
+ const call = node.namedChildren.find((child) => child.type === "call_expression");
544
+ if (!call)
545
+ return false;
546
+ const callee = call.childForFieldName("function") ?? call.child(0);
547
+ return callee?.type === "import";
548
+ };
132
549
  const isStaticRequireCall = (node) => {
133
550
  const requireCall = row.requireCall;
134
551
  if (!node || !requireCall?.callTypes.has(node.type))
@@ -209,13 +626,19 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
209
626
  const name = child.childForFieldName("name");
210
627
  const value = child.childForFieldName("value");
211
628
  if (name) {
212
- if (isStaticRequireCall(value))
629
+ if (isStaticRequireCall(value) || isAwaitedDynamicImport(value)) {
213
630
  addUnsupportedRequirePatternDecls(name, addBindingToScope);
631
+ }
214
632
  else
215
633
  addPatternDecls(name, "local", addBindingToScope);
216
634
  }
217
635
  }
218
636
  else if (row.assignmentIdentifierTypes?.has(child.type) && row.assignmentDeclarationTypes?.has(node.type)) {
637
+ const left = node.childForFieldName("left");
638
+ // `y = x` names both identifiers. Only the left-hand side declares; the right-hand side
639
+ // is a use and must not become a same-scope binding that hides the real declaration.
640
+ if (left && (left.startIndex !== child.startIndex || left.endIndex !== child.endIndex))
641
+ continue;
219
642
  addBindingToScope(child, "local");
220
643
  }
221
644
  else if (row.patternBindingTypes?.has(node.type)) {
@@ -225,11 +648,55 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
225
648
  }
226
649
  }
227
650
  };
651
+ const rememberPatternNames = (pattern, names) => {
652
+ if (idSet.has(pattern.type)) {
653
+ names.add(normalizeIdentifier(sliceText(pattern, source)));
654
+ return;
655
+ }
656
+ if (row.destructuringTypeFieldTypes?.has(pattern.type)) {
657
+ const typeNode = pattern.childForFieldName("type");
658
+ for (const child of pattern.namedChildren) {
659
+ if (typeNode && child.startIndex === typeNode.startIndex && child.endIndex === typeNode.endIndex)
660
+ continue;
661
+ rememberPatternNames(child, names);
662
+ }
663
+ return;
664
+ }
665
+ if (row.destructuringPairPatternTypes?.has(pattern.type)) {
666
+ const value = pattern.childForFieldName("value");
667
+ if (value)
668
+ rememberPatternNames(value, names);
669
+ return;
670
+ }
671
+ for (const child of pattern.namedChildren)
672
+ rememberPatternNames(child, names);
673
+ };
674
+ const rememberLexicalNames = (declaration, names) => {
675
+ for (const child of declaration.namedChildren) {
676
+ if (!row.variableDeclaratorTypes?.has(child.type))
677
+ continue;
678
+ const name = child.childForFieldName("name");
679
+ if (name)
680
+ rememberPatternNames(name, names);
681
+ }
682
+ };
228
683
  const collectHoistedDeclarations = (scopeNode) => {
229
684
  if (!row.hoistedFunctionTypes && !row.hoistedVariableDeclarationTypes)
230
685
  return;
686
+ let pending;
687
+ const ensurePending = () => {
688
+ if (!pending) {
689
+ pending = new Set();
690
+ if (scopeNode.id !== undefined)
691
+ pendingNamesByNodeId.set(scopeNode.id, pending);
692
+ }
693
+ return pending;
694
+ };
695
+ const addPending = (nameNode) => {
696
+ ensurePending().add(normalizeIdentifier(sliceText(nameNode, source)));
697
+ };
231
698
  const visit = (node) => {
232
- if (support.createsFunctionScope(node)) {
699
+ if (node !== scopeNode && support.createsFunctionScope(node)) {
233
700
  if (row.hoistedFunctionTypes?.has(node.type)) {
234
701
  const name = node.childForFieldName("name");
235
702
  if (name)
@@ -237,16 +704,40 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
237
704
  }
238
705
  return;
239
706
  }
707
+ if (node !== scopeNode &&
708
+ !row.moduleRootTypes?.has(node.type) &&
709
+ (support.createsBlockScope(node) || !!row.typeScopeTypes?.has(node.type))) {
710
+ collectHoistedDeclarations(node);
711
+ return;
712
+ }
240
713
  if (row.hoistedVariableDeclarationTypes?.has(node.type)) {
241
714
  addVariableDeclarations(node, addHoistedDecl);
242
715
  }
243
- for (const child of node.namedChildren) {
244
- visit(child);
716
+ else if (row.variableDeclarationTypes?.has(node.type)) {
717
+ rememberLexicalNames(node, ensurePending());
718
+ }
719
+ if (row.classNameTypes?.has(node.type) || row.typeNameTypes?.has(node.type)) {
720
+ const name = node.childForFieldName("name");
721
+ if (name)
722
+ addPending(name);
723
+ }
724
+ if (row.enumAssignmentTypes?.has(node.type)) {
725
+ const name = node.childForFieldName("name");
726
+ if (name)
727
+ addPending(name);
728
+ }
729
+ else if (row.enumBodyMemberTypes?.has(node.type) &&
730
+ node.parent &&
731
+ row.enumBodyParentTypes?.has(node.parent.type)) {
732
+ addPending(node);
245
733
  }
734
+ if (idSet.has(node.type) && scopeDeclarationNames(node))
735
+ addPending(node);
736
+ for (const child of node.namedChildren)
737
+ visit(child);
246
738
  };
247
- for (const child of scopeNode.namedChildren) {
739
+ for (const child of scopeNode.namedChildren)
248
740
  visit(child);
249
- }
250
741
  };
251
742
  const isMemberFunction = (node) => {
252
743
  if (row.memberFunctionTypes?.has(node.type)) {
@@ -261,18 +752,188 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
261
752
  }
262
753
  return false;
263
754
  };
755
+ const canonicalUseName = (name, node) => {
756
+ const normalized = scopeIdentifierKey(row, name, node, normalizeIdentifier);
757
+ if (support.id === "php" && isPhpThisPropertyName(node))
758
+ return `$${normalized}`;
759
+ return support.id === "c" && cTagRole(node) ? cScopeName(normalized, "tag") : normalized;
760
+ };
761
+ const scopeOwnsBinding = (scope, canonical, binding) => {
762
+ let current = scope.map.get(canonical);
763
+ while (current) {
764
+ if (current === binding)
765
+ return true;
766
+ current = current.earlierSameScope;
767
+ }
768
+ return false;
769
+ };
770
+ const deferToScope = (canonical, binding) => {
771
+ if (row.variableTargetScopeKinds) {
772
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
773
+ const scope = stack[index];
774
+ if (binding && scopeOwnsBinding(scope, canonical, binding))
775
+ return undefined;
776
+ if (row.variableTargetScopeKinds.has(scope.kind))
777
+ return scope;
778
+ }
779
+ }
780
+ if (row.laterLocalBlocksOuterKinds) {
781
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
782
+ const scope = stack[index];
783
+ if (binding && scopeOwnsBinding(scope, canonical, binding))
784
+ return undefined;
785
+ if (row.laterLocalBlocksOuterKinds.has(scope.kind))
786
+ return scope;
787
+ }
788
+ }
789
+ if (tracksLexicalNames) {
790
+ const current = stack[stack.length - 1] ?? rootScope;
791
+ // A covering declaration still ahead in this scope shadows an outer binding (TDZ, hoisting).
792
+ if (current.pendingCoveringNames?.has(canonical))
793
+ return current;
794
+ if (binding && current.map.get(canonical) === binding)
795
+ return undefined;
796
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
797
+ const scope = stack[index];
798
+ if (binding && scopeOwnsBinding(scope, canonical, binding))
799
+ return undefined;
800
+ if (scope.pendingCoveringNames?.has(canonical))
801
+ return scope;
802
+ }
803
+ return undefined;
804
+ }
805
+ if (!binding && canDeferForward) {
806
+ for (let index = stack.length - 1; index >= 0; index -= 1) {
807
+ const scope = stack[index];
808
+ if (scopeCanGainCoveringBinding(scope))
809
+ return scope;
810
+ }
811
+ }
812
+ return undefined;
813
+ };
814
+ const scopeCanGainCoveringBinding = (scope) => !!row.wholeScopeKinds?.has(scope.kind) ||
815
+ !!row.variableTargetScopeKinds?.has(scope.kind) ||
816
+ !!row.laterLocalBlocksOuterKinds?.has(scope.kind) ||
817
+ !!row.wholeScopeDeclarationTypes?.size ||
818
+ (scope.kind === "module" && !!row.moduleBindingsAtFunctionRuntime);
819
+ const moduleBindingAtFunctionRuntime = (useNode) => {
820
+ if (!row.moduleBindingsAtFunctionRuntime)
821
+ return false;
822
+ for (let current = useNode.parent; current; current = current.parent) {
823
+ if (!support.createsFunctionScope(current))
824
+ continue;
825
+ const body = current.childForFieldName("body");
826
+ return !!body && useNode.startIndex >= body.startIndex && useNode.endIndex <= body.endIndex;
827
+ }
828
+ return false;
829
+ };
830
+ const lookupCovering = (start, useNode, canonical, phpThis) => {
831
+ const useStart = useNode.startIndex;
832
+ const methodCall = isExplicitMethodCall(row, useNode);
833
+ let scope = start;
834
+ while (scope) {
835
+ if (!scopeAllowsUse(row, scope, useNode)) {
836
+ scope = scope.parent;
837
+ continue;
838
+ }
839
+ if (!(phpThis && scope.kind === "function")) {
840
+ let binding = scope.map.get(canonical);
841
+ const atModuleRuntime = scope.kind === "module" && moduleBindingAtFunctionRuntime(useNode);
842
+ while (binding &&
843
+ ((methodCall && binding.kind === "local") ||
844
+ (!atModuleRuntime && !bindingCoversUse(row, scope.kind, binding, useStart)))) {
845
+ binding = binding.earlierSameScope;
846
+ }
847
+ if (binding)
848
+ return binding;
849
+ }
850
+ if (laterLocalBlocksOuterUse(row, scope, canonical, useStart))
851
+ return undefined;
852
+ scope = scope.parent;
853
+ }
854
+ return undefined;
855
+ };
856
+ const attachOccurrence = (binding, useNode) => {
857
+ const range = toRange(useNode);
858
+ if (support.id === "cpp" && binding.kind === "function") {
859
+ cppFunctionOccurrences.push({ binding, node: useNode, range });
860
+ }
861
+ else {
862
+ binding.occurrences.push(range);
863
+ }
864
+ };
865
+ const queueUse = (scope, id) => {
866
+ let queued = scope.queuedUseIds;
867
+ if (!queued)
868
+ scope.queuedUseIds = queued = [];
869
+ queued.push(id);
870
+ };
871
+ const closeScope = (scope) => {
872
+ const queued = scope.queuedUseIds;
873
+ if (!queued)
874
+ return;
875
+ delete scope.queuedUseIds;
876
+ let receiver;
877
+ if (!tracksLexicalNames) {
878
+ receiver = scope.parent;
879
+ while (receiver && !scopeCanGainCoveringBinding(receiver))
880
+ receiver = receiver.parent;
881
+ }
882
+ for (let index = 0; index < queued.length; index += 1) {
883
+ const id = queued[index];
884
+ const useNode = nodeById(id);
885
+ if (!useNode)
886
+ continue;
887
+ const phpThis = support.id === "php" && isPhpThisPropertyName(useNode);
888
+ const canonical = canonicalUseName(sliceText(useNode, source), useNode);
889
+ const binding = lookupCovering(scope, useNode, canonical, phpThis);
890
+ if (!binding) {
891
+ if (laterLocalBlocksOuterUse(row, scope, canonical, useNode.startIndex))
892
+ continue;
893
+ if (receiver)
894
+ queueUse(receiver, id);
895
+ continue;
896
+ }
897
+ if (receiver && !scopeOwnsBinding(scope, canonical, binding)) {
898
+ queueUse(receiver, id);
899
+ continue;
900
+ }
901
+ attachOccurrence(binding, useNode);
902
+ }
903
+ };
264
904
  const walk = (node) => {
905
+ let scopedFunctionName = null;
906
+ let qualifiedNamespaceScope;
265
907
  // A name-registering node puts its name in the *current* (enclosing) scope before the push
266
908
  // below creates the node's own scope. C# local functions need that: they are callable from
267
909
  // sibling statements in the enclosing method, unlike a JS named function expression's
268
910
  // self-only visibility, which the language's `scopeDeclarationNames` hook handles instead.
269
911
  if (row.functionNameTypes?.has(node.type)) {
270
- const name = node.childForFieldName("name");
912
+ const name = declaredNameNode(node, row);
271
913
  if (name && (support.membersAreImplicitlyInScope || !isMemberFunction(node))) {
272
- if (row.hoistedFunctionTypes?.has(node.type))
914
+ // The declarator chain that carries a C-family function name also carries its parameter
915
+ // list, so the child walk must still descend into it. Remember the exact name node instead
916
+ // and skip only that node below, which keeps one binding per function without hiding
917
+ // `function_declarator > parameter_list` from parameter registration.
918
+ preRegisteredNameSpans.add(nameSpanKey(name));
919
+ const qualifiedName = support.id === "cpp" ? qualifiedCppIdentifierForName(name, node) : null;
920
+ if (qualifiedName) {
921
+ const qualifiedKey = cppQualifiedNameSegments(qualifiedName, source).join("::");
922
+ const ownerKey = qualifiedKey.slice(0, qualifiedKey.lastIndexOf("::"));
923
+ qualifiedNamespaceScope = cppNamespaceScopes.get(ownerKey);
924
+ if (qualifiedNamespaceScope) {
925
+ addBinding(qualifiedNamespaceScope, name, "function");
926
+ }
927
+ else {
928
+ scopedFunctionName = { node: name, qualifiedKey };
929
+ }
930
+ }
931
+ else if (row.hoistedFunctionTypes?.has(node.type)) {
273
932
  addHoistedDecl(name, "function");
274
- else
933
+ }
934
+ else {
275
935
  addDecl(name, "function");
936
+ }
276
937
  }
277
938
  }
278
939
  if (row.classNameTypes?.has(node.type)) {
@@ -305,32 +966,78 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
305
966
  addDecl(node, "local");
306
967
  }
307
968
  let pushed = false;
308
- if (support.createsFunctionScope(node)) {
969
+ let pushedScopeCount = 0;
970
+ const namespacePathStart = cppNamespacePath.length;
971
+ const cppNamespaceName = support.id === "cpp" && node.type === "namespace_definition" ? node.childForFieldName("name") : null;
972
+ const cppNamespaceIsInline = !!cppNamespaceName && /^\s*inline\s+namespace\b/u.test(sliceText(node, source));
973
+ const createsCppNamespaceScope = !!cppNamespaceName && !cppNamespaceIsInline;
974
+ const createsMemberScope = !!row.memberScopeTypes?.has(node.type);
975
+ if (createsCppNamespaceScope) {
976
+ const name = cppNamespaceName;
977
+ const segments = sliceText(name, source).replace(/\s+/gu, "").split("::").filter(Boolean);
978
+ for (const segment of segments) {
979
+ cppNamespacePath.push(segment);
980
+ const key = cppNamespacePath.join("::");
981
+ const map = cppNamespaceMaps.get(key) ?? new Map();
982
+ cppNamespaceMaps.set(key, map);
983
+ cppNamespacePathByMap.set(map, key);
984
+ const scope = {
985
+ kind: "block",
986
+ map,
987
+ node,
988
+ parent: stack[stack.length - 1],
989
+ };
990
+ stack.push(scope);
991
+ allScopes.push(scope);
992
+ if (!cppNamespaceScopes.has(key))
993
+ cppNamespaceScopes.set(key, scope);
994
+ pushed = true;
995
+ pushedScopeCount += 1;
996
+ }
997
+ }
998
+ else if (support.createsFunctionScope(node)) {
309
999
  const scope = {
310
1000
  kind: "function",
311
1001
  map: new Map(),
312
1002
  node,
313
- parent: stack[stack.length - 1],
1003
+ parent: qualifiedNamespaceScope ?? stack[stack.length - 1],
314
1004
  };
315
1005
  stack.push(scope);
316
1006
  allScopes.push(scope);
317
1007
  pushed = true;
1008
+ pushedScopeCount = 1;
1009
+ if (scopedFunctionName) {
1010
+ addDecl(scopedFunctionName.node, "function");
1011
+ const binding = scope.map.get(normalizeIdentifier(sliceText(scopedFunctionName.node, source)));
1012
+ if (binding) {
1013
+ const bindings = cppQualifiedMemberBindings.get(scopedFunctionName.qualifiedKey) ?? [];
1014
+ bindings.push(binding);
1015
+ cppQualifiedMemberBindings.set(scopedFunctionName.qualifiedKey, bindings);
1016
+ }
1017
+ }
318
1018
  const params = node.childForFieldName("parameters");
319
1019
  if (params)
320
1020
  addPatternDecls(params, "param");
321
1021
  collectHoistedDeclarations(node);
1022
+ attachPendingNames(scope);
322
1023
  }
323
- else if (support.createsBlockScope(node)) {
1024
+ else if (support.createsBlockScope(node) || createsMemberScope) {
324
1025
  if (!row.moduleRootTypes?.has(node.type)) {
325
1026
  const scope = {
326
- kind: "block",
1027
+ kind: createsMemberScope ? "member" : "block",
327
1028
  map: new Map(),
328
1029
  node,
329
1030
  parent: stack[stack.length - 1],
330
1031
  };
1032
+ attachPendingNames(scope);
331
1033
  stack.push(scope);
332
1034
  allScopes.push(scope);
333
1035
  pushed = true;
1036
+ pushedScopeCount = 1;
1037
+ const blockParams = node.childForFieldName("parameters");
1038
+ if (blockParams && (blockParams.type === "block_parameters" || blockParams.type === "lambda_parameters")) {
1039
+ addPatternDecls(blockParams, "param");
1040
+ }
334
1041
  }
335
1042
  }
336
1043
  else if (row.typeScopeTypes?.has(node.type)) {
@@ -345,12 +1052,14 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
345
1052
  node,
346
1053
  parent: stack[stack.length - 1],
347
1054
  };
1055
+ attachPendingNames(scope);
348
1056
  stack.push(scope);
349
1057
  allScopes.push(scope);
350
1058
  pushed = true;
1059
+ pushedScopeCount = 1;
351
1060
  }
352
1061
  if (row.variableDeclarationTypes?.has(node.type)) {
353
- addVariableDeclarations(node, row.hoistedVariableDeclarationTypes?.has(node.type) ? addHoistedDecl : addDecl);
1062
+ addVariableDeclarations(node, row.hoistedVariableDeclarationTypes?.has(node.type) ? addHoistedDecl : addVariableDecl);
354
1063
  }
355
1064
  if (row.declarationPatternTypes?.has(node.type)) {
356
1065
  // C# is-pattern bound variable: `if (o is string text)`. The walker registers the bound name
@@ -369,54 +1078,194 @@ export function buildScopeIndexFromSource(file, source, support, imports = [], o
369
1078
  if (name)
370
1079
  addDecl(name, "type");
371
1080
  }
1081
+ let declarationName = idSet.has(node.type) && support.isDeclarationName(node);
1082
+ if (declarationName && row.shortVariableDeclarationTypes) {
1083
+ for (let current = node.parent; current; current = current.parent) {
1084
+ if (row.shortVariableDeclarationTypes.has(current.type)) {
1085
+ const left = current.childForFieldName("left");
1086
+ declarationName = !!left && node.startIndex >= left.startIndex && node.endIndex <= left.endIndex;
1087
+ break;
1088
+ }
1089
+ if (support.createsFunctionScope(current) || support.createsBlockScope(current))
1090
+ break;
1091
+ }
1092
+ }
372
1093
  if (scopeDeclarationNames(node) &&
373
- idSet.has(node.type) &&
374
- support.isDeclarationName(node) &&
375
- !isScopedEnumeratorName(node)) {
1094
+ declarationName &&
1095
+ !isScopedEnumeratorName(node) &&
1096
+ !preRegisteredNameSpans.has(nameSpanKey(node))) {
376
1097
  const kind = isParamNode(node) ? "param" : declarationKindToBindingKind(support.classifyDefinition(node));
377
1098
  addDeclSkippingTypeScope(node, kind);
378
1099
  }
379
- if (idSet.has(node.type) && !support.isDeclarationName(node)) {
380
- const binding = lookup(sliceText(node, source));
381
- if (binding) {
382
- binding.occurrences.push(toRange(node));
1100
+ const nestedIdentifier = node.parent && idSet.has(node.parent.type) && row.childSkipNameTypes?.has(node.type);
1101
+ if (idSet.has(node.type) && !declarationName && !nestedIdentifier) {
1102
+ const qualifiedName = support.id === "cpp" ? qualifiedCppIdentifierForName(node) : null;
1103
+ if (qualifiedName) {
1104
+ const key = cppQualifiedNameSegments(qualifiedName, source).join("::");
1105
+ const occurrences = cppQualifiedMemberOccurrences.get(key) ?? [];
1106
+ const fallback = lookup(sliceText(node, source));
1107
+ occurrences.push({ node, range: toRange(node), ...(fallback ? { fallback } : {}) });
1108
+ cppQualifiedMemberOccurrences.set(key, occurrences);
383
1109
  }
1110
+ else {
1111
+ const parent = node.parent;
1112
+ const memberProperty = parent &&
1113
+ (row.nonLexicalMemberPropertyTypes?.has(parent.type) ||
1114
+ (support.id === "cpp" && isMemberAccessNode(support, parent)))
1115
+ ? getMemberAccessParts(support, parent).property
1116
+ : null;
1117
+ const isMemberProperty = !!memberProperty && memberProperty.startIndex <= node.startIndex && memberProperty.endIndex >= node.endIndex;
1118
+ if (!isMemberProperty) {
1119
+ const phpThis = support.id === "php" && isPhpThisPropertyName(node);
1120
+ const name = sliceText(node, source);
1121
+ const binding = phpThis ? lookupOutsideFunctions(name) : lookup(name, node);
1122
+ const canonical = canonicalUseName(name, node);
1123
+ const deferred = deferToScope(canonical, binding);
1124
+ const useId = node.id;
1125
+ if (deferred && useId !== undefined)
1126
+ queueUse(deferred, useId);
1127
+ else if (binding)
1128
+ attachOccurrence(binding, node);
1129
+ }
1130
+ }
1131
+ }
1132
+ if (support.id === "php" && node.type === "class_declaration") {
1133
+ const target = stack[stack.length - 1] ?? rootScope;
1134
+ for (const variable of promotedVariablesInClass(node))
1135
+ addBinding(target, variable, "local");
384
1136
  }
385
1137
  for (const child of node.namedChildren) {
386
1138
  if (pushed) {
387
1139
  const params = node.childForFieldName("parameters");
388
1140
  const skipsFunctionParameters = support.createsFunctionScope(node) && params?.id === child.id;
1141
+ const skipsBlockParameters = support.createsBlockScope(node) &&
1142
+ (child.type === "block_parameters" || child.type === "lambda_parameters") &&
1143
+ params?.startIndex === child.startIndex &&
1144
+ params.endIndex === child.endIndex;
389
1145
  const skipsNameOrParameters = (row.functionNameTypes?.has(node.type) || row.classNameTypes?.has(node.type)) &&
390
1146
  row.childSkipNameTypes?.has(child.type);
391
- if (skipsFunctionParameters || skipsNameOrParameters) {
1147
+ const skipsCppNamespaceName = createsCppNamespaceScope && node.childForFieldName("name")?.id === child.id;
1148
+ if (skipsFunctionParameters || skipsBlockParameters || skipsNameOrParameters || skipsCppNamespaceName) {
392
1149
  continue;
393
1150
  }
394
1151
  }
395
1152
  walk(child);
396
1153
  }
397
- if (pushed)
1154
+ for (let index = 0; index < pushedScopeCount; index += 1) {
1155
+ const closed = stack[stack.length - 1];
1156
+ if (closed)
1157
+ closeScope(closed);
398
1158
  stack.pop();
1159
+ }
1160
+ cppNamespacePath.length = namespacePathStart;
1161
+ };
1162
+ const prepareCppCallableBindings = (bindings) => {
1163
+ const bySignature = new Map();
1164
+ for (const binding of bindings) {
1165
+ const shape = cppBindingCallableShape(binding);
1166
+ if (!shape) {
1167
+ for (const candidate of bindings)
1168
+ candidate.occurrencesComplete = false;
1169
+ return false;
1170
+ }
1171
+ const entity = bySignature.get(shape.signature) ?? [];
1172
+ entity.push(binding);
1173
+ bySignature.set(shape.signature, entity);
1174
+ }
1175
+ for (const entity of bySignature.values()) {
1176
+ const occurrences = entity.flatMap((binding) => (binding.def ? [binding.def] : []));
1177
+ for (const binding of entity) {
1178
+ binding.occurrences = occurrences;
1179
+ delete binding.occurrencesComplete;
1180
+ }
1181
+ }
1182
+ return true;
1183
+ };
1184
+ const assignCppCallableOccurrence = (bindings, node, range) => {
1185
+ const selected = cppSelectCallableBinding(bindings, node, source, file, file);
1186
+ if (selected) {
1187
+ selected.occurrences.push(range);
1188
+ return;
1189
+ }
1190
+ for (const binding of bindings)
1191
+ binding.occurrencesComplete = false;
1192
+ };
1193
+ const cppOccurrenceBindings = (binding) => {
1194
+ const collisions = binding.sameScopeFunctionBindings ?? [binding];
1195
+ if (collisions.length > 1 || cppBindingCallableShape(binding))
1196
+ return collisions;
1197
+ return null;
399
1198
  };
400
1199
  collectHoistedDeclarations(tree.rootNode);
1200
+ attachPendingNames(rootScope);
401
1201
  walk(tree.rootNode);
1202
+ closeScope(rootScope);
1203
+ for (const collisions of cppFunctionCollisionGroups)
1204
+ prepareCppCallableBindings(collisions);
1205
+ const cppQualifiedCallableBindings = new Map();
1206
+ for (const [key, memberBindings] of cppQualifiedMemberBindings) {
1207
+ const callableBindings = [
1208
+ ...new Set(memberBindings.flatMap((binding) => binding.sameScopeFunctionBindings ?? [binding])),
1209
+ ];
1210
+ if (prepareCppCallableBindings(callableBindings))
1211
+ cppQualifiedCallableBindings.set(key, callableBindings);
1212
+ }
1213
+ for (const occurrence of cppFunctionOccurrences) {
1214
+ const group = cppOccurrenceBindings(occurrence.binding);
1215
+ if (group) {
1216
+ assignCppCallableOccurrence(group, occurrence.node, occurrence.range);
1217
+ }
1218
+ else {
1219
+ occurrence.binding.occurrences.push(occurrence.range);
1220
+ }
1221
+ }
1222
+ for (const [key, callableBindings] of cppQualifiedCallableBindings) {
1223
+ for (const occurrence of cppQualifiedMemberOccurrences.get(key) ?? []) {
1224
+ assignCppCallableOccurrence(callableBindings, occurrence.node, occurrence.range);
1225
+ }
1226
+ }
1227
+ for (const [key, occurrences] of cppQualifiedMemberOccurrences) {
1228
+ if (cppQualifiedCallableBindings.has(key))
1229
+ continue;
1230
+ for (const occurrence of occurrences) {
1231
+ const fallback = occurrence.fallback;
1232
+ if (!fallback)
1233
+ continue;
1234
+ const group = cppOccurrenceBindings(fallback);
1235
+ if (group) {
1236
+ assignCppCallableOccurrence(group, occurrence.node, occurrence.range);
1237
+ }
1238
+ else {
1239
+ fallback.occurrences.push(occurrence.range);
1240
+ }
1241
+ }
1242
+ }
402
1243
  const bindings = new Map();
403
1244
  const all = [];
404
- const flush = (scope) => {
405
- for (const binding of scope.map.values()) {
406
- if (!bindings.has(binding.canonicalName))
407
- bindings.set(binding.canonicalName, []);
408
- bindings.get(binding.canonicalName).push(binding);
409
- all.push(binding);
410
- }
411
- };
412
- for (const scope of allScopes)
413
- flush(scope);
414
- for (const binding of extraBindings) {
1245
+ const flushedMaps = new Set();
1246
+ const seenBindings = new Set();
1247
+ const pushBinding = (binding) => {
1248
+ if (seenBindings.has(binding))
1249
+ return;
1250
+ seenBindings.add(binding);
415
1251
  if (!bindings.has(binding.canonicalName))
416
1252
  bindings.set(binding.canonicalName, []);
417
1253
  bindings.get(binding.canonicalName).push(binding);
418
1254
  all.push(binding);
419
- }
420
- return { bindings, all, allScopes };
1255
+ if (binding.earlierSameScope)
1256
+ pushBinding(binding.earlierSameScope);
1257
+ };
1258
+ const flush = (scope) => {
1259
+ if (flushedMaps.has(scope.map))
1260
+ return;
1261
+ flushedMaps.add(scope.map);
1262
+ for (const binding of scope.map.values())
1263
+ pushBinding(binding);
1264
+ };
1265
+ for (const scope of allScopes)
1266
+ flush(scope);
1267
+ for (const binding of extraBindings)
1268
+ pushBinding(binding);
1269
+ return { bindings, all, allScopes, cppQualifiedFunctionBindings: cppQualifiedCallableBindings };
421
1270
  }
422
1271
  //# sourceMappingURL=scope.js.map