@colbymchenry/codegraph-win32-arm64 1.6.1 → 1.6.3

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 (1094) hide show
  1. package/bin/codegraph +1 -1
  2. package/bin/codegraph.cmd +1 -1
  3. package/lib/dist/.test-build-engine.json +1 -1
  4. package/lib/dist/.test-build-viewer.json +1 -1
  5. package/lib/dist/bin/codegraph.d.ts +3 -0
  6. package/lib/dist/bin/codegraph.d.ts.map +1 -1
  7. package/lib/dist/bin/codegraph.js +427 -684
  8. package/lib/dist/bin/codegraph.js.map +1 -1
  9. package/lib/dist/bin/command-supervision.d.ts +7 -0
  10. package/lib/dist/bin/command-supervision.d.ts.map +1 -1
  11. package/lib/dist/bin/command-supervision.js +30 -74
  12. package/lib/dist/bin/command-supervision.js.map +1 -1
  13. package/lib/dist/bin/fatal-handler.js +0 -46
  14. package/lib/dist/bin/fatal-handler.js.map +1 -1
  15. package/lib/dist/bin/node-version-check.js +0 -33
  16. package/lib/dist/bin/node-version-check.js.map +1 -1
  17. package/lib/dist/bin/uninstall.js +0 -19
  18. package/lib/dist/bin/uninstall.js.map +1 -1
  19. package/lib/dist/bin/viewer-gate.js +0 -14
  20. package/lib/dist/bin/viewer-gate.js.map +1 -1
  21. package/lib/dist/compile-cache.d.ts +2 -0
  22. package/lib/dist/compile-cache.d.ts.map +1 -0
  23. package/lib/dist/compile-cache.js +45 -0
  24. package/lib/dist/compile-cache.js.map +1 -0
  25. package/lib/dist/context/formatter.js +3 -66
  26. package/lib/dist/context/formatter.js.map +1 -1
  27. package/lib/dist/context/index.d.ts +44 -1
  28. package/lib/dist/context/index.d.ts.map +1 -1
  29. package/lib/dist/context/index.js +123 -430
  30. package/lib/dist/context/index.js.map +1 -1
  31. package/lib/dist/context/markers.js +0 -17
  32. package/lib/dist/context/markers.js.map +1 -1
  33. package/lib/dist/db/index.d.ts +44 -1
  34. package/lib/dist/db/index.d.ts.map +1 -1
  35. package/lib/dist/db/index.js +123 -395
  36. package/lib/dist/db/index.js.map +1 -1
  37. package/lib/dist/db/migrations.d.ts +11 -1
  38. package/lib/dist/db/migrations.d.ts.map +1 -1
  39. package/lib/dist/db/migrations.js +71 -79
  40. package/lib/dist/db/migrations.js.map +1 -1
  41. package/lib/dist/db/name-substring-index.d.ts +63 -0
  42. package/lib/dist/db/name-substring-index.d.ts.map +1 -0
  43. package/lib/dist/db/name-substring-index.js +151 -0
  44. package/lib/dist/db/name-substring-index.js.map +1 -0
  45. package/lib/dist/db/node-sqlite.d.ts +19 -0
  46. package/lib/dist/db/node-sqlite.d.ts.map +1 -0
  47. package/lib/dist/db/node-sqlite.js +23 -0
  48. package/lib/dist/db/node-sqlite.js.map +1 -0
  49. package/lib/dist/db/open-error.d.ts +36 -0
  50. package/lib/dist/db/open-error.d.ts.map +1 -0
  51. package/lib/dist/db/open-error.js +63 -0
  52. package/lib/dist/db/open-error.js.map +1 -0
  53. package/lib/dist/db/parameter-flow-queries.d.ts +120 -0
  54. package/lib/dist/db/parameter-flow-queries.d.ts.map +1 -0
  55. package/lib/dist/db/parameter-flow-queries.js +168 -0
  56. package/lib/dist/db/parameter-flow-queries.js.map +1 -0
  57. package/lib/dist/db/queries.d.ts +641 -40
  58. package/lib/dist/db/queries.d.ts.map +1 -1
  59. package/lib/dist/db/queries.js +1370 -1398
  60. package/lib/dist/db/queries.js.map +1 -1
  61. package/lib/dist/db/reference-tail.d.ts +83 -0
  62. package/lib/dist/db/reference-tail.d.ts.map +1 -0
  63. package/lib/dist/db/reference-tail.js +68 -0
  64. package/lib/dist/db/reference-tail.js.map +1 -0
  65. package/lib/dist/db/schema.sql +18 -2
  66. package/lib/dist/db/sqlite-adapter.d.ts +18 -1
  67. package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
  68. package/lib/dist/db/sqlite-adapter.js +12 -62
  69. package/lib/dist/db/sqlite-adapter.js.map +1 -1
  70. package/lib/dist/db/synthesis-stage.d.ts.map +1 -1
  71. package/lib/dist/db/synthesis-stage.js +2 -6
  72. package/lib/dist/db/synthesis-stage.js.map +1 -1
  73. package/lib/dist/db/wal-valve.js +1 -153
  74. package/lib/dist/db/wal-valve.js.map +1 -1
  75. package/lib/dist/db/wsl-shared-index.js +0 -37
  76. package/lib/dist/db/wsl-shared-index.js.map +1 -1
  77. package/lib/dist/directory.d.ts +81 -0
  78. package/lib/dist/directory.d.ts.map +1 -1
  79. package/lib/dist/directory.js +91 -500
  80. package/lib/dist/directory.js.map +1 -1
  81. package/lib/dist/engine.d.ts +15 -0
  82. package/lib/dist/engine.d.ts.map +1 -0
  83. package/lib/dist/engine.js +34 -0
  84. package/lib/dist/engine.js.map +1 -0
  85. package/lib/dist/errors.d.ts +10 -0
  86. package/lib/dist/errors.d.ts.map +1 -1
  87. package/lib/dist/errors.js +8 -101
  88. package/lib/dist/errors.js.map +1 -1
  89. package/lib/dist/extraction/astro-extractor.d.ts.map +1 -1
  90. package/lib/dist/extraction/astro-extractor.js +15 -133
  91. package/lib/dist/extraction/astro-extractor.js.map +1 -1
  92. package/lib/dist/extraction/cfml-extractor.d.ts +102 -10
  93. package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
  94. package/lib/dist/extraction/cfml-extractor.js +260 -179
  95. package/lib/dist/extraction/cfml-extractor.js.map +1 -1
  96. package/lib/dist/extraction/commonjs-requires.d.ts +23 -0
  97. package/lib/dist/extraction/commonjs-requires.d.ts.map +1 -0
  98. package/lib/dist/extraction/commonjs-requires.js +37 -0
  99. package/lib/dist/extraction/commonjs-requires.js.map +1 -0
  100. package/lib/dist/extraction/dfm-extractor.js +0 -21
  101. package/lib/dist/extraction/dfm-extractor.js.map +1 -1
  102. package/lib/dist/extraction/extraction-version.d.ts +1 -1
  103. package/lib/dist/extraction/extraction-version.js +1 -24
  104. package/lib/dist/extraction/extraction-version.js.map +1 -1
  105. package/lib/dist/extraction/function-ref.d.ts +40 -0
  106. package/lib/dist/extraction/function-ref.d.ts.map +1 -1
  107. package/lib/dist/extraction/function-ref.js +145 -206
  108. package/lib/dist/extraction/function-ref.js.map +1 -1
  109. package/lib/dist/extraction/generated-detection.d.ts +9 -0
  110. package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
  111. package/lib/dist/extraction/generated-detection.js +29 -154
  112. package/lib/dist/extraction/generated-detection.js.map +1 -1
  113. package/lib/dist/extraction/grammars.d.ts +47 -4
  114. package/lib/dist/extraction/grammars.d.ts.map +1 -1
  115. package/lib/dist/extraction/grammars.js +91 -374
  116. package/lib/dist/extraction/grammars.js.map +1 -1
  117. package/lib/dist/extraction/index.d.ts +216 -11
  118. package/lib/dist/extraction/index.d.ts.map +1 -1
  119. package/lib/dist/extraction/index.js +703 -1368
  120. package/lib/dist/extraction/index.js.map +1 -1
  121. package/lib/dist/extraction/kernel/decode.js +0 -16
  122. package/lib/dist/extraction/kernel/decode.js.map +1 -1
  123. package/lib/dist/extraction/kernel/index.d.ts +3 -1
  124. package/lib/dist/extraction/kernel/index.d.ts.map +1 -1
  125. package/lib/dist/extraction/kernel/index.js +29 -131
  126. package/lib/dist/extraction/kernel/index.js.map +1 -1
  127. package/lib/dist/extraction/kernel/layout.js +42 -76
  128. package/lib/dist/extraction/kernel/layout.js.map +1 -1
  129. package/lib/dist/extraction/kernel/loader.js +0 -37
  130. package/lib/dist/extraction/kernel/loader.js.map +1 -1
  131. package/lib/dist/extraction/languages/arkts.js +0 -59
  132. package/lib/dist/extraction/languages/arkts.js.map +1 -1
  133. package/lib/dist/extraction/languages/c-cpp.d.ts +140 -28
  134. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  135. package/lib/dist/extraction/languages/c-cpp.js +876 -823
  136. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  137. package/lib/dist/extraction/languages/cfquery.js +0 -9
  138. package/lib/dist/extraction/languages/cfquery.js.map +1 -1
  139. package/lib/dist/extraction/languages/cfscript.d.ts +20 -0
  140. package/lib/dist/extraction/languages/cfscript.d.ts.map +1 -1
  141. package/lib/dist/extraction/languages/cfscript.js +80 -9
  142. package/lib/dist/extraction/languages/cfscript.js.map +1 -1
  143. package/lib/dist/extraction/languages/cobol.js +0 -114
  144. package/lib/dist/extraction/languages/cobol.js.map +1 -1
  145. package/lib/dist/extraction/languages/cpp-brace-scopes.d.ts +66 -0
  146. package/lib/dist/extraction/languages/cpp-brace-scopes.d.ts.map +1 -0
  147. package/lib/dist/extraction/languages/cpp-brace-scopes.js +343 -0
  148. package/lib/dist/extraction/languages/cpp-brace-scopes.js.map +1 -0
  149. package/lib/dist/extraction/languages/cpp-macro-methods.d.ts +41 -0
  150. package/lib/dist/extraction/languages/cpp-macro-methods.d.ts.map +1 -0
  151. package/lib/dist/extraction/languages/cpp-macro-methods.js +487 -0
  152. package/lib/dist/extraction/languages/cpp-macro-methods.js.map +1 -0
  153. package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
  154. package/lib/dist/extraction/languages/csharp.js +11 -54
  155. package/lib/dist/extraction/languages/csharp.js.map +1 -1
  156. package/lib/dist/extraction/languages/dart.d.ts +84 -0
  157. package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
  158. package/lib/dist/extraction/languages/dart.js +335 -159
  159. package/lib/dist/extraction/languages/dart.js.map +1 -1
  160. package/lib/dist/extraction/languages/erlang.d.ts.map +1 -1
  161. package/lib/dist/extraction/languages/erlang.js +15 -102
  162. package/lib/dist/extraction/languages/erlang.js.map +1 -1
  163. package/lib/dist/extraction/languages/go.d.ts +48 -0
  164. package/lib/dist/extraction/languages/go.d.ts.map +1 -1
  165. package/lib/dist/extraction/languages/go.js +102 -31
  166. package/lib/dist/extraction/languages/go.js.map +1 -1
  167. package/lib/dist/extraction/languages/index.js +0 -6
  168. package/lib/dist/extraction/languages/index.js.map +1 -1
  169. package/lib/dist/extraction/languages/java.d.ts.map +1 -1
  170. package/lib/dist/extraction/languages/java.js +67 -78
  171. package/lib/dist/extraction/languages/java.js.map +1 -1
  172. package/lib/dist/extraction/languages/javascript.d.ts.map +1 -1
  173. package/lib/dist/extraction/languages/javascript.js +2 -12
  174. package/lib/dist/extraction/languages/javascript.js.map +1 -1
  175. package/lib/dist/extraction/languages/kotlin.d.ts +15 -0
  176. package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
  177. package/lib/dist/extraction/languages/kotlin.js +69 -150
  178. package/lib/dist/extraction/languages/kotlin.js.map +1 -1
  179. package/lib/dist/extraction/languages/lua.js +2 -39
  180. package/lib/dist/extraction/languages/lua.js.map +1 -1
  181. package/lib/dist/extraction/languages/luau.js +0 -14
  182. package/lib/dist/extraction/languages/luau.js.map +1 -1
  183. package/lib/dist/extraction/languages/nix.js +0 -16
  184. package/lib/dist/extraction/languages/nix.js.map +1 -1
  185. package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
  186. package/lib/dist/extraction/languages/objc.js +5 -16
  187. package/lib/dist/extraction/languages/objc.js.map +1 -1
  188. package/lib/dist/extraction/languages/pascal-preparse.d.ts +66 -0
  189. package/lib/dist/extraction/languages/pascal-preparse.d.ts.map +1 -0
  190. package/lib/dist/extraction/languages/pascal-preparse.js +958 -0
  191. package/lib/dist/extraction/languages/pascal-preparse.js.map +1 -0
  192. package/lib/dist/extraction/languages/pascal-system.d.ts +11 -0
  193. package/lib/dist/extraction/languages/pascal-system.d.ts.map +1 -0
  194. package/lib/dist/extraction/languages/pascal-system.js +23 -0
  195. package/lib/dist/extraction/languages/pascal-system.js.map +1 -0
  196. package/lib/dist/extraction/languages/pascal.d.ts.map +1 -1
  197. package/lib/dist/extraction/languages/pascal.js +3 -4
  198. package/lib/dist/extraction/languages/pascal.js.map +1 -1
  199. package/lib/dist/extraction/languages/php.js +5 -42
  200. package/lib/dist/extraction/languages/php.js.map +1 -1
  201. package/lib/dist/extraction/languages/python.js +2 -20
  202. package/lib/dist/extraction/languages/python.js.map +1 -1
  203. package/lib/dist/extraction/languages/r.js +8 -78
  204. package/lib/dist/extraction/languages/r.js.map +1 -1
  205. package/lib/dist/extraction/languages/ruby.d.ts.map +1 -1
  206. package/lib/dist/extraction/languages/ruby.js +17 -25
  207. package/lib/dist/extraction/languages/ruby.js.map +1 -1
  208. package/lib/dist/extraction/languages/rust.d.ts +10 -0
  209. package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
  210. package/lib/dist/extraction/languages/rust.js +15 -47
  211. package/lib/dist/extraction/languages/rust.js.map +1 -1
  212. package/lib/dist/extraction/languages/scala.js +5 -41
  213. package/lib/dist/extraction/languages/scala.js.map +1 -1
  214. package/lib/dist/extraction/languages/solidity.js +1 -82
  215. package/lib/dist/extraction/languages/solidity.js.map +1 -1
  216. package/lib/dist/extraction/languages/swift.d.ts +15 -0
  217. package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
  218. package/lib/dist/extraction/languages/swift.js +33 -27
  219. package/lib/dist/extraction/languages/swift.js.map +1 -1
  220. package/lib/dist/extraction/languages/terraform.js +6 -152
  221. package/lib/dist/extraction/languages/terraform.js.map +1 -1
  222. package/lib/dist/extraction/languages/typescript.d.ts +71 -0
  223. package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
  224. package/lib/dist/extraction/languages/typescript.js +86 -41
  225. package/lib/dist/extraction/languages/typescript.js.map +1 -1
  226. package/lib/dist/extraction/languages/vbnet.d.ts.map +1 -1
  227. package/lib/dist/extraction/languages/vbnet.js +9 -42
  228. package/lib/dist/extraction/languages/vbnet.js.map +1 -1
  229. package/lib/dist/extraction/lazy-frameworks.d.ts +15 -0
  230. package/lib/dist/extraction/lazy-frameworks.d.ts.map +1 -0
  231. package/lib/dist/extraction/lazy-frameworks.js +8 -0
  232. package/lib/dist/extraction/lazy-frameworks.js.map +1 -0
  233. package/lib/dist/extraction/liquid-extractor.d.ts +29 -3
  234. package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
  235. package/lib/dist/extraction/liquid-extractor.js +89 -148
  236. package/lib/dist/extraction/liquid-extractor.js.map +1 -1
  237. package/lib/dist/extraction/mybatis-extractor.js +0 -78
  238. package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
  239. package/lib/dist/extraction/parse-budget.d.ts +16 -0
  240. package/lib/dist/extraction/parse-budget.d.ts.map +1 -0
  241. package/lib/dist/extraction/parse-budget.js +11 -0
  242. package/lib/dist/extraction/parse-budget.js.map +1 -0
  243. package/lib/dist/extraction/parse-pool.d.ts +41 -5
  244. package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
  245. package/lib/dist/extraction/parse-pool.js +74 -158
  246. package/lib/dist/extraction/parse-pool.js.map +1 -1
  247. package/lib/dist/extraction/parse-worker.d.ts +1 -1
  248. package/lib/dist/extraction/parse-worker.d.ts.map +1 -1
  249. package/lib/dist/extraction/parse-worker.js +7 -58
  250. package/lib/dist/extraction/parse-worker.js.map +1 -1
  251. package/lib/dist/extraction/razor-extractor.d.ts +9 -0
  252. package/lib/dist/extraction/razor-extractor.d.ts.map +1 -1
  253. package/lib/dist/extraction/razor-extractor.js +45 -69
  254. package/lib/dist/extraction/razor-extractor.js.map +1 -1
  255. package/lib/dist/extraction/razor-script.d.ts +23 -0
  256. package/lib/dist/extraction/razor-script.d.ts.map +1 -0
  257. package/lib/dist/extraction/razor-script.js +244 -0
  258. package/lib/dist/extraction/razor-script.js.map +1 -0
  259. package/lib/dist/extraction/sfc-script.d.ts +85 -0
  260. package/lib/dist/extraction/sfc-script.d.ts.map +1 -0
  261. package/lib/dist/extraction/sfc-script.js +136 -0
  262. package/lib/dist/extraction/sfc-script.js.map +1 -0
  263. package/lib/dist/extraction/store-worker.d.ts +1 -1
  264. package/lib/dist/extraction/store-worker.d.ts.map +1 -1
  265. package/lib/dist/extraction/store-worker.js +5 -37
  266. package/lib/dist/extraction/store-worker.js.map +1 -1
  267. package/lib/dist/extraction/store-writer.d.ts +10 -2
  268. package/lib/dist/extraction/store-writer.d.ts.map +1 -1
  269. package/lib/dist/extraction/store-writer.js +8 -32
  270. package/lib/dist/extraction/store-writer.js.map +1 -1
  271. package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
  272. package/lib/dist/extraction/svelte-extractor.js +16 -122
  273. package/lib/dist/extraction/svelte-extractor.js.map +1 -1
  274. package/lib/dist/extraction/syntax-tokens.d.ts +6 -5
  275. package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -1
  276. package/lib/dist/extraction/syntax-tokens.js +6 -153
  277. package/lib/dist/extraction/syntax-tokens.js.map +1 -1
  278. package/lib/dist/extraction/tree-sitter-helpers.d.ts +37 -1
  279. package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  280. package/lib/dist/extraction/tree-sitter-helpers.js +76 -68
  281. package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
  282. package/lib/dist/extraction/tree-sitter-types.d.ts +102 -22
  283. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  284. package/lib/dist/extraction/tree-sitter-types.js +0 -7
  285. package/lib/dist/extraction/tree-sitter-types.js.map +1 -1
  286. package/lib/dist/extraction/tree-sitter.d.ts +455 -9
  287. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  288. package/lib/dist/extraction/tree-sitter.js +1998 -2517
  289. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  290. package/lib/dist/extraction/vue-extractor.d.ts +20 -0
  291. package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
  292. package/lib/dist/extraction/vue-extractor.js +113 -115
  293. package/lib/dist/extraction/vue-extractor.js.map +1 -1
  294. package/lib/dist/extraction/vue-options-api.d.ts +28 -0
  295. package/lib/dist/extraction/vue-options-api.d.ts.map +1 -0
  296. package/lib/dist/extraction/vue-options-api.js +164 -0
  297. package/lib/dist/extraction/vue-options-api.js.map +1 -0
  298. package/lib/dist/extraction/vue-template-calls.d.ts +37 -0
  299. package/lib/dist/extraction/vue-template-calls.d.ts.map +1 -0
  300. package/lib/dist/extraction/vue-template-calls.js +497 -0
  301. package/lib/dist/extraction/vue-template-calls.js.map +1 -0
  302. package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  303. package/lib/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  304. package/lib/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  305. package/lib/dist/extraction/wasm-runtime-flags.d.ts +6 -0
  306. package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
  307. package/lib/dist/extraction/wasm-runtime-flags.js +1 -88
  308. package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -1
  309. package/lib/dist/file-limits.d.ts +8 -0
  310. package/lib/dist/file-limits.d.ts.map +1 -1
  311. package/lib/dist/file-limits.js +13 -28
  312. package/lib/dist/file-limits.js.map +1 -1
  313. package/lib/dist/graph/branch-guards.d.ts +17 -0
  314. package/lib/dist/graph/branch-guards.d.ts.map +1 -1
  315. package/lib/dist/graph/branch-guards.js +98 -250
  316. package/lib/dist/graph/branch-guards.js.map +1 -1
  317. package/lib/dist/graph/call-sites.d.ts +12 -0
  318. package/lib/dist/graph/call-sites.d.ts.map +1 -0
  319. package/lib/dist/graph/call-sites.js +17 -0
  320. package/lib/dist/graph/call-sites.js.map +1 -0
  321. package/lib/dist/graph/cobol-copybooks.d.ts +75 -0
  322. package/lib/dist/graph/cobol-copybooks.d.ts.map +1 -0
  323. package/lib/dist/graph/cobol-copybooks.js +45 -0
  324. package/lib/dist/graph/cobol-copybooks.js.map +1 -0
  325. package/lib/dist/graph/dead-code.d.ts +26 -4
  326. package/lib/dist/graph/dead-code.d.ts.map +1 -1
  327. package/lib/dist/graph/dead-code.js +157 -311
  328. package/lib/dist/graph/dead-code.js.map +1 -1
  329. package/lib/dist/graph/dynamic-boundary-report.js +1 -88
  330. package/lib/dist/graph/dynamic-boundary-report.js.map +1 -1
  331. package/lib/dist/graph/file-cycles.d.ts +20 -0
  332. package/lib/dist/graph/file-cycles.d.ts.map +1 -0
  333. package/lib/dist/graph/file-cycles.js +79 -0
  334. package/lib/dist/graph/file-cycles.js.map +1 -0
  335. package/lib/dist/graph/go-package.d.ts +27 -0
  336. package/lib/dist/graph/go-package.d.ts.map +1 -0
  337. package/lib/dist/graph/go-package.js +49 -0
  338. package/lib/dist/graph/go-package.js.map +1 -0
  339. package/lib/dist/graph/index.d.ts +2 -0
  340. package/lib/dist/graph/index.d.ts.map +1 -1
  341. package/lib/dist/graph/index.js +4 -6
  342. package/lib/dist/graph/index.js.map +1 -1
  343. package/lib/dist/graph/named-symbol-flow.d.ts +5 -1
  344. package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -1
  345. package/lib/dist/graph/named-symbol-flow.js +85 -219
  346. package/lib/dist/graph/named-symbol-flow.js.map +1 -1
  347. package/lib/dist/graph/owning-package.d.ts +59 -0
  348. package/lib/dist/graph/owning-package.d.ts.map +1 -0
  349. package/lib/dist/graph/owning-package.js +120 -0
  350. package/lib/dist/graph/owning-package.js.map +1 -0
  351. package/lib/dist/graph/queries.d.ts +2 -2
  352. package/lib/dist/graph/queries.d.ts.map +1 -1
  353. package/lib/dist/graph/queries.js +2 -135
  354. package/lib/dist/graph/queries.js.map +1 -1
  355. package/lib/dist/graph/symbol-lookup.d.ts +15 -3
  356. package/lib/dist/graph/symbol-lookup.d.ts.map +1 -1
  357. package/lib/dist/graph/symbol-lookup.js +47 -89
  358. package/lib/dist/graph/symbol-lookup.js.map +1 -1
  359. package/lib/dist/graph/synthesized-hop.d.ts +37 -0
  360. package/lib/dist/graph/synthesized-hop.d.ts.map +1 -0
  361. package/lib/dist/graph/synthesized-hop.js +62 -0
  362. package/lib/dist/graph/synthesized-hop.js.map +1 -0
  363. package/lib/dist/graph/test-code.d.ts +21 -0
  364. package/lib/dist/graph/test-code.d.ts.map +1 -0
  365. package/lib/dist/graph/test-code.js +50 -0
  366. package/lib/dist/graph/test-code.js.map +1 -0
  367. package/lib/dist/graph/traversal.d.ts +31 -2
  368. package/lib/dist/graph/traversal.d.ts.map +1 -1
  369. package/lib/dist/graph/traversal.js +98 -226
  370. package/lib/dist/graph/traversal.js.map +1 -1
  371. package/lib/dist/graph/type-hierarchy.js +0 -138
  372. package/lib/dist/graph/type-hierarchy.js.map +1 -1
  373. package/lib/dist/index.d.ts +195 -25
  374. package/lib/dist/index.d.ts.map +1 -1
  375. package/lib/dist/index.js +697 -1105
  376. package/lib/dist/index.js.map +1 -1
  377. package/lib/dist/installer/beta-signup.js +0 -39
  378. package/lib/dist/installer/beta-signup.js.map +1 -1
  379. package/lib/dist/installer/config-writer.js +0 -24
  380. package/lib/dist/installer/config-writer.js.map +1 -1
  381. package/lib/dist/installer/index.d.ts +9 -5
  382. package/lib/dist/installer/index.d.ts.map +1 -1
  383. package/lib/dist/installer/index.js +25 -159
  384. package/lib/dist/installer/index.js.map +1 -1
  385. package/lib/dist/installer/instructions-template.d.ts +1 -1
  386. package/lib/dist/installer/instructions-template.js +0 -37
  387. package/lib/dist/installer/instructions-template.js.map +1 -1
  388. package/lib/dist/installer/targets/antigravity.js +0 -113
  389. package/lib/dist/installer/targets/antigravity.js.map +1 -1
  390. package/lib/dist/installer/targets/bob.d.ts +20 -0
  391. package/lib/dist/installer/targets/bob.d.ts.map +1 -0
  392. package/lib/dist/installer/targets/bob.js +83 -0
  393. package/lib/dist/installer/targets/bob.js.map +1 -0
  394. package/lib/dist/installer/targets/claude.d.ts.map +1 -1
  395. package/lib/dist/installer/targets/claude.js +1 -185
  396. package/lib/dist/installer/targets/claude.js.map +1 -1
  397. package/lib/dist/installer/targets/codex.d.ts.map +1 -1
  398. package/lib/dist/installer/targets/codex.js +17 -109
  399. package/lib/dist/installer/targets/codex.js.map +1 -1
  400. package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -1
  401. package/lib/dist/installer/targets/copilot-cli.js +2 -54
  402. package/lib/dist/installer/targets/copilot-cli.js.map +1 -1
  403. package/lib/dist/installer/targets/copilot-jetbrains.js +0 -57
  404. package/lib/dist/installer/targets/copilot-jetbrains.js.map +1 -1
  405. package/lib/dist/installer/targets/copilot-vscode.js +0 -58
  406. package/lib/dist/installer/targets/copilot-vscode.js.map +1 -1
  407. package/lib/dist/installer/targets/cursor.js +7 -88
  408. package/lib/dist/installer/targets/cursor.js.map +1 -1
  409. package/lib/dist/installer/targets/droid.d.ts +18 -0
  410. package/lib/dist/installer/targets/droid.d.ts.map +1 -0
  411. package/lib/dist/installer/targets/droid.js +92 -0
  412. package/lib/dist/installer/targets/droid.js.map +1 -0
  413. package/lib/dist/installer/targets/dsh.d.ts +35 -0
  414. package/lib/dist/installer/targets/dsh.d.ts.map +1 -0
  415. package/lib/dist/installer/targets/dsh.js +267 -0
  416. package/lib/dist/installer/targets/dsh.js.map +1 -0
  417. package/lib/dist/installer/targets/gemini.js +0 -37
  418. package/lib/dist/installer/targets/gemini.js.map +1 -1
  419. package/lib/dist/installer/targets/grok.d.ts +25 -0
  420. package/lib/dist/installer/targets/grok.d.ts.map +1 -0
  421. package/lib/dist/installer/targets/grok.js +96 -0
  422. package/lib/dist/installer/targets/grok.js.map +1 -0
  423. package/lib/dist/installer/targets/hermes.d.ts +19 -7
  424. package/lib/dist/installer/targets/hermes.d.ts.map +1 -1
  425. package/lib/dist/installer/targets/hermes.js +218 -214
  426. package/lib/dist/installer/targets/hermes.js.map +1 -1
  427. package/lib/dist/installer/targets/json-config.d.ts +45 -0
  428. package/lib/dist/installer/targets/json-config.d.ts.map +1 -0
  429. package/lib/dist/installer/targets/json-config.js +128 -0
  430. package/lib/dist/installer/targets/json-config.js.map +1 -0
  431. package/lib/dist/installer/targets/kimi.d.ts +21 -0
  432. package/lib/dist/installer/targets/kimi.d.ts.map +1 -0
  433. package/lib/dist/installer/targets/kimi.js +97 -0
  434. package/lib/dist/installer/targets/kimi.js.map +1 -0
  435. package/lib/dist/installer/targets/kiro.js +1 -41
  436. package/lib/dist/installer/targets/kiro.js.map +1 -1
  437. package/lib/dist/installer/targets/opencode.js +0 -102
  438. package/lib/dist/installer/targets/opencode.js.map +1 -1
  439. package/lib/dist/installer/targets/pi.d.ts +24 -0
  440. package/lib/dist/installer/targets/pi.d.ts.map +1 -0
  441. package/lib/dist/installer/targets/pi.js +100 -0
  442. package/lib/dist/installer/targets/pi.js.map +1 -0
  443. package/lib/dist/installer/targets/qoder.d.ts +23 -0
  444. package/lib/dist/installer/targets/qoder.d.ts.map +1 -0
  445. package/lib/dist/installer/targets/qoder.js +83 -0
  446. package/lib/dist/installer/targets/qoder.js.map +1 -0
  447. package/lib/dist/installer/targets/qwen.d.ts +21 -0
  448. package/lib/dist/installer/targets/qwen.d.ts.map +1 -0
  449. package/lib/dist/installer/targets/qwen.js +115 -0
  450. package/lib/dist/installer/targets/qwen.js.map +1 -0
  451. package/lib/dist/installer/targets/registry.d.ts.map +1 -1
  452. package/lib/dist/installer/targets/registry.js +18 -25
  453. package/lib/dist/installer/targets/registry.js.map +1 -1
  454. package/lib/dist/installer/targets/shared.d.ts +81 -11
  455. package/lib/dist/installer/targets/shared.d.ts.map +1 -1
  456. package/lib/dist/installer/targets/shared.js +183 -129
  457. package/lib/dist/installer/targets/shared.js.map +1 -1
  458. package/lib/dist/installer/targets/toml.d.ts +82 -6
  459. package/lib/dist/installer/targets/toml.d.ts.map +1 -1
  460. package/lib/dist/installer/targets/toml.js +318 -112
  461. package/lib/dist/installer/targets/toml.js.map +1 -1
  462. package/lib/dist/installer/targets/types.d.ts +1 -1
  463. package/lib/dist/installer/targets/types.d.ts.map +1 -1
  464. package/lib/dist/installer/targets/types.js +0 -13
  465. package/lib/dist/installer/targets/types.js.map +1 -1
  466. package/lib/dist/installer/targets/windsurf.d.ts +22 -0
  467. package/lib/dist/installer/targets/windsurf.d.ts.map +1 -0
  468. package/lib/dist/installer/targets/windsurf.js +90 -0
  469. package/lib/dist/installer/targets/windsurf.js.map +1 -0
  470. package/lib/dist/lazy-engine.d.ts +22 -0
  471. package/lib/dist/lazy-engine.d.ts.map +1 -0
  472. package/lib/dist/lazy-engine.js +16 -0
  473. package/lib/dist/lazy-engine.js.map +1 -0
  474. package/lib/dist/mcp/answer-freshness.js +0 -6
  475. package/lib/dist/mcp/answer-freshness.js.map +1 -1
  476. package/lib/dist/mcp/daemon-manager.js +2 -23
  477. package/lib/dist/mcp/daemon-manager.js.map +1 -1
  478. package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
  479. package/lib/dist/mcp/daemon-paths.js +2 -79
  480. package/lib/dist/mcp/daemon-paths.js.map +1 -1
  481. package/lib/dist/mcp/daemon-registry.d.ts +44 -0
  482. package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
  483. package/lib/dist/mcp/daemon-registry.js +189 -118
  484. package/lib/dist/mcp/daemon-registry.js.map +1 -1
  485. package/lib/dist/mcp/daemon.d.ts +23 -0
  486. package/lib/dist/mcp/daemon.d.ts.map +1 -1
  487. package/lib/dist/mcp/daemon.js +89 -373
  488. package/lib/dist/mcp/daemon.js.map +1 -1
  489. package/lib/dist/mcp/dynamic-boundaries.js +4 -78
  490. package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
  491. package/lib/dist/mcp/early-ppid.js +0 -24
  492. package/lib/dist/mcp/early-ppid.js.map +1 -1
  493. package/lib/dist/mcp/engine.d.ts +10 -0
  494. package/lib/dist/mcp/engine.d.ts.map +1 -1
  495. package/lib/dist/mcp/engine.js +41 -152
  496. package/lib/dist/mcp/engine.js.map +1 -1
  497. package/lib/dist/mcp/explore-dedup.js +0 -108
  498. package/lib/dist/mcp/explore-dedup.js.map +1 -1
  499. package/lib/dist/mcp/explore-diagnostics.js +0 -116
  500. package/lib/dist/mcp/explore-diagnostics.js.map +1 -1
  501. package/lib/dist/mcp/explore-session-state.js +0 -129
  502. package/lib/dist/mcp/explore-session-state.js.map +1 -1
  503. package/lib/dist/mcp/index-freshness-worker.js +5 -4
  504. package/lib/dist/mcp/index-freshness-worker.js.map +1 -1
  505. package/lib/dist/mcp/index-freshness.d.ts +7 -1
  506. package/lib/dist/mcp/index-freshness.d.ts.map +1 -1
  507. package/lib/dist/mcp/index-freshness.js +20 -12
  508. package/lib/dist/mcp/index-freshness.js.map +1 -1
  509. package/lib/dist/mcp/index-version-warning.d.ts +21 -0
  510. package/lib/dist/mcp/index-version-warning.d.ts.map +1 -0
  511. package/lib/dist/mcp/index-version-warning.js +38 -0
  512. package/lib/dist/mcp/index-version-warning.js.map +1 -0
  513. package/lib/dist/mcp/index.d.ts +19 -1
  514. package/lib/dist/mcp/index.d.ts.map +1 -1
  515. package/lib/dist/mcp/index.js +118 -293
  516. package/lib/dist/mcp/index.js.map +1 -1
  517. package/lib/dist/mcp/liveness-watchdog.d.ts +13 -3
  518. package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  519. package/lib/dist/mcp/liveness-watchdog.js +106 -121
  520. package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
  521. package/lib/dist/mcp/ppid-watchdog.js +0 -24
  522. package/lib/dist/mcp/ppid-watchdog.js.map +1 -1
  523. package/lib/dist/mcp/process-identity.d.ts +42 -0
  524. package/lib/dist/mcp/process-identity.d.ts.map +1 -0
  525. package/lib/dist/mcp/process-identity.js +130 -0
  526. package/lib/dist/mcp/process-identity.js.map +1 -0
  527. package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -1
  528. package/lib/dist/mcp/project-lifecycle.js +55 -21
  529. package/lib/dist/mcp/project-lifecycle.js.map +1 -1
  530. package/lib/dist/mcp/proxy.d.ts +26 -8
  531. package/lib/dist/mcp/proxy.d.ts.map +1 -1
  532. package/lib/dist/mcp/proxy.js +209 -223
  533. package/lib/dist/mcp/proxy.js.map +1 -1
  534. package/lib/dist/mcp/query-pool.d.ts +58 -3
  535. package/lib/dist/mcp/query-pool.d.ts.map +1 -1
  536. package/lib/dist/mcp/query-pool.js +140 -100
  537. package/lib/dist/mcp/query-pool.js.map +1 -1
  538. package/lib/dist/mcp/query-worker.js +24 -36
  539. package/lib/dist/mcp/query-worker.js.map +1 -1
  540. package/lib/dist/mcp/server-instructions.js +0 -31
  541. package/lib/dist/mcp/server-instructions.js.map +1 -1
  542. package/lib/dist/mcp/session.d.ts +27 -0
  543. package/lib/dist/mcp/session.d.ts.map +1 -1
  544. package/lib/dist/mcp/session.js +29 -130
  545. package/lib/dist/mcp/session.js.map +1 -1
  546. package/lib/dist/mcp/startup-handshake.js +1 -48
  547. package/lib/dist/mcp/startup-handshake.js.map +1 -1
  548. package/lib/dist/mcp/stdin-teardown.js +0 -28
  549. package/lib/dist/mcp/stdin-teardown.js.map +1 -1
  550. package/lib/dist/mcp/stdout-teardown.d.ts +26 -0
  551. package/lib/dist/mcp/stdout-teardown.d.ts.map +1 -0
  552. package/lib/dist/mcp/stdout-teardown.js +20 -0
  553. package/lib/dist/mcp/stdout-teardown.js.map +1 -0
  554. package/lib/dist/mcp/tools.d.ts +159 -20
  555. package/lib/dist/mcp/tools.d.ts.map +1 -1
  556. package/lib/dist/mcp/tools.js +730 -3545
  557. package/lib/dist/mcp/tools.js.map +1 -1
  558. package/lib/dist/mcp/transport.d.ts.map +1 -1
  559. package/lib/dist/mcp/transport.js +4 -96
  560. package/lib/dist/mcp/transport.js.map +1 -1
  561. package/lib/dist/mcp/version.d.ts +13 -1
  562. package/lib/dist/mcp/version.d.ts.map +1 -1
  563. package/lib/dist/mcp/version.js +19 -21
  564. package/lib/dist/mcp/version.js.map +1 -1
  565. package/lib/dist/mcp/writer-lock.d.ts +11 -0
  566. package/lib/dist/mcp/writer-lock.d.ts.map +1 -1
  567. package/lib/dist/mcp/writer-lock.js +49 -46
  568. package/lib/dist/mcp/writer-lock.js.map +1 -1
  569. package/lib/dist/project-config.js +1 -138
  570. package/lib/dist/project-config.js.map +1 -1
  571. package/lib/dist/resolution/alias-binding.d.ts +7 -0
  572. package/lib/dist/resolution/alias-binding.d.ts.map +1 -1
  573. package/lib/dist/resolution/alias-binding.js +19 -52
  574. package/lib/dist/resolution/alias-binding.js.map +1 -1
  575. package/lib/dist/resolution/ambient-modules.d.ts +185 -0
  576. package/lib/dist/resolution/ambient-modules.d.ts.map +1 -0
  577. package/lib/dist/resolution/ambient-modules.js +732 -0
  578. package/lib/dist/resolution/ambient-modules.js.map +1 -0
  579. package/lib/dist/resolution/angular-template-synthesizer.d.ts +96 -0
  580. package/lib/dist/resolution/angular-template-synthesizer.d.ts.map +1 -0
  581. package/lib/dist/resolution/angular-template-synthesizer.js +695 -0
  582. package/lib/dist/resolution/angular-template-synthesizer.js.map +1 -0
  583. package/lib/dist/resolution/c-feature-variants.d.ts +40 -0
  584. package/lib/dist/resolution/c-feature-variants.d.ts.map +1 -0
  585. package/lib/dist/resolution/c-feature-variants.js +249 -0
  586. package/lib/dist/resolution/c-feature-variants.js.map +1 -0
  587. package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
  588. package/lib/dist/resolution/c-fnptr-synthesizer.js +23 -391
  589. package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
  590. package/lib/dist/resolution/c-macro-renames.d.ts +25 -0
  591. package/lib/dist/resolution/c-macro-renames.d.ts.map +1 -0
  592. package/lib/dist/resolution/c-macro-renames.js +95 -0
  593. package/lib/dist/resolution/c-macro-renames.js.map +1 -0
  594. package/lib/dist/resolution/callback-synthesizer.d.ts +15 -1
  595. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  596. package/lib/dist/resolution/callback-synthesizer.js +1487 -1234
  597. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  598. package/lib/dist/resolution/const-alias-synthesizer.d.ts +48 -0
  599. package/lib/dist/resolution/const-alias-synthesizer.d.ts.map +1 -0
  600. package/lib/dist/resolution/const-alias-synthesizer.js +234 -0
  601. package/lib/dist/resolution/const-alias-synthesizer.js.map +1 -0
  602. package/lib/dist/resolution/cooperative-yield.js +0 -27
  603. package/lib/dist/resolution/cooperative-yield.js.map +1 -1
  604. package/lib/dist/resolution/cpp-constructor.d.ts.map +1 -1
  605. package/lib/dist/resolution/cpp-constructor.js +15 -17
  606. package/lib/dist/resolution/cpp-constructor.js.map +1 -1
  607. package/lib/dist/resolution/cpp-includers.d.ts +46 -0
  608. package/lib/dist/resolution/cpp-includers.d.ts.map +1 -0
  609. package/lib/dist/resolution/cpp-includers.js +153 -0
  610. package/lib/dist/resolution/cpp-includers.js.map +1 -0
  611. package/lib/dist/resolution/cpp-macro-visibility.d.ts +16 -0
  612. package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -1
  613. package/lib/dist/resolution/cpp-macro-visibility.js +60 -61
  614. package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -1
  615. package/lib/dist/resolution/cpp-namespaces.d.ts +54 -0
  616. package/lib/dist/resolution/cpp-namespaces.d.ts.map +1 -0
  617. package/lib/dist/resolution/cpp-namespaces.js +151 -0
  618. package/lib/dist/resolution/cpp-namespaces.js.map +1 -0
  619. package/lib/dist/resolution/cpp-raw-strings.d.ts +33 -0
  620. package/lib/dist/resolution/cpp-raw-strings.d.ts.map +1 -0
  621. package/lib/dist/resolution/cpp-raw-strings.js +167 -0
  622. package/lib/dist/resolution/cpp-raw-strings.js.map +1 -0
  623. package/lib/dist/resolution/cpp-supertypes.d.ts +118 -0
  624. package/lib/dist/resolution/cpp-supertypes.d.ts.map +1 -0
  625. package/lib/dist/resolution/cpp-supertypes.js +322 -0
  626. package/lib/dist/resolution/cpp-supertypes.js.map +1 -0
  627. package/lib/dist/resolution/cpp-template-instantiations.d.ts +83 -0
  628. package/lib/dist/resolution/cpp-template-instantiations.d.ts.map +1 -0
  629. package/lib/dist/resolution/cpp-template-instantiations.js +983 -0
  630. package/lib/dist/resolution/cpp-template-instantiations.js.map +1 -0
  631. package/lib/dist/resolution/cpp-type-aliases.d.ts +194 -0
  632. package/lib/dist/resolution/cpp-type-aliases.d.ts.map +1 -0
  633. package/lib/dist/resolution/cpp-type-aliases.js +648 -0
  634. package/lib/dist/resolution/cpp-type-aliases.js.map +1 -0
  635. package/lib/dist/resolution/dart-libraries.d.ts +75 -0
  636. package/lib/dist/resolution/dart-libraries.d.ts.map +1 -0
  637. package/lib/dist/resolution/dart-libraries.js +721 -0
  638. package/lib/dist/resolution/dart-libraries.js.map +1 -0
  639. package/lib/dist/resolution/dart-local-scope.d.ts +41 -0
  640. package/lib/dist/resolution/dart-local-scope.d.ts.map +1 -0
  641. package/lib/dist/resolution/dart-local-scope.js +565 -0
  642. package/lib/dist/resolution/dart-local-scope.js.map +1 -0
  643. package/lib/dist/resolution/expo-router-synthesizer.js +0 -52
  644. package/lib/dist/resolution/expo-router-synthesizer.js.map +1 -1
  645. package/lib/dist/resolution/frameworks/angular-router.d.ts +142 -0
  646. package/lib/dist/resolution/frameworks/angular-router.d.ts.map +1 -0
  647. package/lib/dist/resolution/frameworks/angular-router.js +959 -0
  648. package/lib/dist/resolution/frameworks/angular-router.js.map +1 -0
  649. package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -1
  650. package/lib/dist/resolution/frameworks/astro.js +30 -60
  651. package/lib/dist/resolution/frameworks/astro.js.map +1 -1
  652. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts +18 -1
  653. package/lib/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -1
  654. package/lib/dist/resolution/frameworks/cargo-workspace.js +65 -15
  655. package/lib/dist/resolution/frameworks/cargo-workspace.js.map +1 -1
  656. package/lib/dist/resolution/frameworks/cics.d.ts.map +1 -1
  657. package/lib/dist/resolution/frameworks/cics.js +7 -33
  658. package/lib/dist/resolution/frameworks/cics.js.map +1 -1
  659. package/lib/dist/resolution/frameworks/codeigniter.d.ts +23 -0
  660. package/lib/dist/resolution/frameworks/codeigniter.d.ts.map +1 -0
  661. package/lib/dist/resolution/frameworks/codeigniter.js +271 -0
  662. package/lib/dist/resolution/frameworks/codeigniter.js.map +1 -0
  663. package/lib/dist/resolution/frameworks/component-folder.d.ts +17 -0
  664. package/lib/dist/resolution/frameworks/component-folder.d.ts.map +1 -0
  665. package/lib/dist/resolution/frameworks/component-folder.js +11 -0
  666. package/lib/dist/resolution/frameworks/component-folder.js.map +1 -0
  667. package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
  668. package/lib/dist/resolution/frameworks/csharp.js +106 -101
  669. package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
  670. package/lib/dist/resolution/frameworks/drupal.d.ts +17 -8
  671. package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -1
  672. package/lib/dist/resolution/frameworks/drupal.js +377 -142
  673. package/lib/dist/resolution/frameworks/drupal.js.map +1 -1
  674. package/lib/dist/resolution/frameworks/expo-modules.d.ts +10 -0
  675. package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
  676. package/lib/dist/resolution/frameworks/expo-modules.js +79 -65
  677. package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
  678. package/lib/dist/resolution/frameworks/expo-router.d.ts +6 -0
  679. package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -1
  680. package/lib/dist/resolution/frameworks/expo-router.js +64 -183
  681. package/lib/dist/resolution/frameworks/expo-router.js.map +1 -1
  682. package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
  683. package/lib/dist/resolution/frameworks/express.js +215 -173
  684. package/lib/dist/resolution/frameworks/express.js.map +1 -1
  685. package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -1
  686. package/lib/dist/resolution/frameworks/fabric.js +11 -112
  687. package/lib/dist/resolution/frameworks/fabric.js.map +1 -1
  688. package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
  689. package/lib/dist/resolution/frameworks/go.js +15 -61
  690. package/lib/dist/resolution/frameworks/go.js.map +1 -1
  691. package/lib/dist/resolution/frameworks/goframe.js +1 -55
  692. package/lib/dist/resolution/frameworks/goframe.js.map +1 -1
  693. package/lib/dist/resolution/frameworks/index.d.ts +16 -2
  694. package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
  695. package/lib/dist/resolution/frameworks/index.js +20 -48
  696. package/lib/dist/resolution/frameworks/index.js.map +1 -1
  697. package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
  698. package/lib/dist/resolution/frameworks/java.js +209 -147
  699. package/lib/dist/resolution/frameworks/java.js.map +1 -1
  700. package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -1
  701. package/lib/dist/resolution/frameworks/laravel.js +291 -71
  702. package/lib/dist/resolution/frameworks/laravel.js.map +1 -1
  703. package/lib/dist/resolution/frameworks/name-heuristic.d.ts +35 -0
  704. package/lib/dist/resolution/frameworks/name-heuristic.d.ts.map +1 -0
  705. package/lib/dist/resolution/frameworks/name-heuristic.js +33 -0
  706. package/lib/dist/resolution/frameworks/name-heuristic.js.map +1 -0
  707. package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
  708. package/lib/dist/resolution/frameworks/nestjs.js +236 -192
  709. package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
  710. package/lib/dist/resolution/frameworks/next-proxy.d.ts +67 -0
  711. package/lib/dist/resolution/frameworks/next-proxy.d.ts.map +1 -0
  712. package/lib/dist/resolution/frameworks/next-proxy.js +239 -0
  713. package/lib/dist/resolution/frameworks/next-proxy.js.map +1 -0
  714. package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -1
  715. package/lib/dist/resolution/frameworks/nextjs.js +11 -66
  716. package/lib/dist/resolution/frameworks/nextjs.js.map +1 -1
  717. package/lib/dist/resolution/frameworks/object-literal.js +0 -21
  718. package/lib/dist/resolution/frameworks/object-literal.js.map +1 -1
  719. package/lib/dist/resolution/frameworks/package-deps.d.ts +11 -7
  720. package/lib/dist/resolution/frameworks/package-deps.d.ts.map +1 -1
  721. package/lib/dist/resolution/frameworks/package-deps.js +35 -26
  722. package/lib/dist/resolution/frameworks/package-deps.js.map +1 -1
  723. package/lib/dist/resolution/frameworks/page-component.d.ts +20 -0
  724. package/lib/dist/resolution/frameworks/page-component.d.ts.map +1 -0
  725. package/lib/dist/resolution/frameworks/page-component.js +31 -0
  726. package/lib/dist/resolution/frameworks/page-component.js.map +1 -0
  727. package/lib/dist/resolution/frameworks/play.d.ts.map +1 -1
  728. package/lib/dist/resolution/frameworks/play.js +27 -33
  729. package/lib/dist/resolution/frameworks/play.js.map +1 -1
  730. package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
  731. package/lib/dist/resolution/frameworks/python.js +106 -116
  732. package/lib/dist/resolution/frameworks/python.js.map +1 -1
  733. package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
  734. package/lib/dist/resolution/frameworks/react-native.js +1 -166
  735. package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
  736. package/lib/dist/resolution/frameworks/react-router.d.ts +17 -7
  737. package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -1
  738. package/lib/dist/resolution/frameworks/react-router.js +21 -79
  739. package/lib/dist/resolution/frameworks/react-router.js.map +1 -1
  740. package/lib/dist/resolution/frameworks/react.d.ts +68 -1
  741. package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
  742. package/lib/dist/resolution/frameworks/react.js +1721 -114
  743. package/lib/dist/resolution/frameworks/react.js.map +1 -1
  744. package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -1
  745. package/lib/dist/resolution/frameworks/ruby.js +152 -52
  746. package/lib/dist/resolution/frameworks/ruby.js.map +1 -1
  747. package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -1
  748. package/lib/dist/resolution/frameworks/rust.js +51 -70
  749. package/lib/dist/resolution/frameworks/rust.js.map +1 -1
  750. package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -1
  751. package/lib/dist/resolution/frameworks/svelte.js +9 -74
  752. package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
  753. package/lib/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -1
  754. package/lib/dist/resolution/frameworks/sveltekit-router.js +8 -46
  755. package/lib/dist/resolution/frameworks/sveltekit-router.js.map +1 -1
  756. package/lib/dist/resolution/frameworks/swift-objc.js +0 -97
  757. package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -1
  758. package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -1
  759. package/lib/dist/resolution/frameworks/swift.js +199 -167
  760. package/lib/dist/resolution/frameworks/swift.js.map +1 -1
  761. package/lib/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -1
  762. package/lib/dist/resolution/frameworks/tanstack-router.js +9 -130
  763. package/lib/dist/resolution/frameworks/tanstack-router.js.map +1 -1
  764. package/lib/dist/resolution/frameworks/terraform.js +1 -85
  765. package/lib/dist/resolution/frameworks/terraform.js.map +1 -1
  766. package/lib/dist/resolution/frameworks/vue-router.d.ts +26 -10
  767. package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -1
  768. package/lib/dist/resolution/frameworks/vue-router.js +147 -147
  769. package/lib/dist/resolution/frameworks/vue-router.js.map +1 -1
  770. package/lib/dist/resolution/frameworks/vue.d.ts +9 -2
  771. package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -1
  772. package/lib/dist/resolution/frameworks/vue.js +69 -107
  773. package/lib/dist/resolution/frameworks/vue.js.map +1 -1
  774. package/lib/dist/resolution/go-func-field-synthesizer.d.ts +58 -0
  775. package/lib/dist/resolution/go-func-field-synthesizer.d.ts.map +1 -0
  776. package/lib/dist/resolution/go-func-field-synthesizer.js +696 -0
  777. package/lib/dist/resolution/go-func-field-synthesizer.js.map +1 -0
  778. package/lib/dist/resolution/go-module.d.ts +23 -7
  779. package/lib/dist/resolution/go-module.d.ts.map +1 -1
  780. package/lib/dist/resolution/go-module.js +21 -24
  781. package/lib/dist/resolution/go-module.js.map +1 -1
  782. package/lib/dist/resolution/go-stdlib-methods.d.ts +9 -0
  783. package/lib/dist/resolution/go-stdlib-methods.d.ts.map +1 -0
  784. package/lib/dist/resolution/go-stdlib-methods.js +224 -0
  785. package/lib/dist/resolution/go-stdlib-methods.js.map +1 -0
  786. package/lib/dist/resolution/goframe-synthesizer.js +2 -53
  787. package/lib/dist/resolution/goframe-synthesizer.js.map +1 -1
  788. package/lib/dist/resolution/import-resolver.d.ts +298 -23
  789. package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
  790. package/lib/dist/resolution/import-resolver.js +1802 -1280
  791. package/lib/dist/resolution/import-resolver.js.map +1 -1
  792. package/lib/dist/resolution/index.d.ts +449 -5
  793. package/lib/dist/resolution/index.d.ts.map +1 -1
  794. package/lib/dist/resolution/index.js +1477 -981
  795. package/lib/dist/resolution/index.js.map +1 -1
  796. package/lib/dist/resolution/js-builtins.d.ts +14 -0
  797. package/lib/dist/resolution/js-builtins.d.ts.map +1 -1
  798. package/lib/dist/resolution/js-builtins.js +15 -13
  799. package/lib/dist/resolution/js-builtins.js.map +1 -1
  800. package/lib/dist/resolution/js-class-expressions.d.ts +48 -0
  801. package/lib/dist/resolution/js-class-expressions.d.ts.map +1 -0
  802. package/lib/dist/resolution/js-class-expressions.js +25 -0
  803. package/lib/dist/resolution/js-class-expressions.js.map +1 -0
  804. package/lib/dist/resolution/js-super-calls.d.ts +18 -0
  805. package/lib/dist/resolution/js-super-calls.d.ts.map +1 -0
  806. package/lib/dist/resolution/js-super-calls.js +94 -0
  807. package/lib/dist/resolution/js-super-calls.js.map +1 -0
  808. package/lib/dist/resolution/jsx-code.d.ts +28 -0
  809. package/lib/dist/resolution/jsx-code.d.ts.map +1 -0
  810. package/lib/dist/resolution/jsx-code.js +459 -0
  811. package/lib/dist/resolution/jsx-code.js.map +1 -0
  812. package/lib/dist/resolution/lru-cache.d.ts +5 -13
  813. package/lib/dist/resolution/lru-cache.d.ts.map +1 -1
  814. package/lib/dist/resolution/lru-cache.js +43 -32
  815. package/lib/dist/resolution/lru-cache.js.map +1 -1
  816. package/lib/dist/resolution/memory-budget.js +0 -52
  817. package/lib/dist/resolution/memory-budget.js.map +1 -1
  818. package/lib/dist/resolution/module-importers.d.ts +185 -0
  819. package/lib/dist/resolution/module-importers.d.ts.map +1 -0
  820. package/lib/dist/resolution/module-importers.js +588 -0
  821. package/lib/dist/resolution/module-importers.js.map +1 -0
  822. package/lib/dist/resolution/name-matcher.d.ts +891 -8
  823. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  824. package/lib/dist/resolution/name-matcher.js +25013 -2928
  825. package/lib/dist/resolution/name-matcher.js.map +1 -1
  826. package/lib/dist/resolution/next-router-synthesizer.d.ts +19 -0
  827. package/lib/dist/resolution/next-router-synthesizer.d.ts.map +1 -1
  828. package/lib/dist/resolution/next-router-synthesizer.js +46 -28
  829. package/lib/dist/resolution/next-router-synthesizer.js.map +1 -1
  830. package/lib/dist/resolution/override-parameters.d.ts +40 -0
  831. package/lib/dist/resolution/override-parameters.d.ts.map +1 -0
  832. package/lib/dist/resolution/override-parameters.js +339 -0
  833. package/lib/dist/resolution/override-parameters.js.map +1 -0
  834. package/lib/dist/resolution/parameter-flow.d.ts +218 -0
  835. package/lib/dist/resolution/parameter-flow.d.ts.map +1 -0
  836. package/lib/dist/resolution/parameter-flow.js +474 -0
  837. package/lib/dist/resolution/parameter-flow.js.map +1 -0
  838. package/lib/dist/resolution/pascal-scope.d.ts +91 -0
  839. package/lib/dist/resolution/pascal-scope.d.ts.map +1 -0
  840. package/lib/dist/resolution/pascal-scope.js +961 -0
  841. package/lib/dist/resolution/pascal-scope.js.map +1 -0
  842. package/lib/dist/resolution/path-aliases.d.ts +32 -4
  843. package/lib/dist/resolution/path-aliases.d.ts.map +1 -1
  844. package/lib/dist/resolution/path-aliases.js +43 -110
  845. package/lib/dist/resolution/path-aliases.js.map +1 -1
  846. package/lib/dist/resolution/project-scans.d.ts +38 -0
  847. package/lib/dist/resolution/project-scans.d.ts.map +1 -0
  848. package/lib/dist/resolution/project-scans.js +30 -0
  849. package/lib/dist/resolution/project-scans.js.map +1 -0
  850. package/lib/dist/resolution/react-router-synthesizer.d.ts +2 -0
  851. package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -1
  852. package/lib/dist/resolution/react-router-synthesizer.js +67 -48
  853. package/lib/dist/resolution/react-router-synthesizer.js.map +1 -1
  854. package/lib/dist/resolution/resolver-pool.d.ts +43 -3
  855. package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
  856. package/lib/dist/resolution/resolver-pool.js +55 -97
  857. package/lib/dist/resolution/resolver-pool.js.map +1 -1
  858. package/lib/dist/resolution/resolver-worker.d.ts +1 -1
  859. package/lib/dist/resolution/resolver-worker.d.ts.map +1 -1
  860. package/lib/dist/resolution/resolver-worker.js +10 -36
  861. package/lib/dist/resolution/resolver-worker.js.map +1 -1
  862. package/lib/dist/resolution/resurrect-ref.d.ts +25 -0
  863. package/lib/dist/resolution/resurrect-ref.d.ts.map +1 -0
  864. package/lib/dist/resolution/resurrect-ref.js +19 -0
  865. package/lib/dist/resolution/resurrect-ref.js.map +1 -0
  866. package/lib/dist/resolution/ruby-constant-paths.d.ts +56 -0
  867. package/lib/dist/resolution/ruby-constant-paths.d.ts.map +1 -0
  868. package/lib/dist/resolution/ruby-constant-paths.js +255 -0
  869. package/lib/dist/resolution/ruby-constant-paths.js.map +1 -0
  870. package/lib/dist/resolution/ruby-parameter-flow.d.ts +10 -0
  871. package/lib/dist/resolution/ruby-parameter-flow.d.ts.map +1 -0
  872. package/lib/dist/resolution/ruby-parameter-flow.js +801 -0
  873. package/lib/dist/resolution/ruby-parameter-flow.js.map +1 -0
  874. package/lib/dist/resolution/rust-scopes.d.ts +120 -0
  875. package/lib/dist/resolution/rust-scopes.d.ts.map +1 -0
  876. package/lib/dist/resolution/rust-scopes.js +730 -0
  877. package/lib/dist/resolution/rust-scopes.js.map +1 -0
  878. package/lib/dist/resolution/shopify-themes.d.ts +10 -0
  879. package/lib/dist/resolution/shopify-themes.d.ts.map +1 -0
  880. package/lib/dist/resolution/shopify-themes.js +19 -0
  881. package/lib/dist/resolution/shopify-themes.js.map +1 -0
  882. package/lib/dist/resolution/strip-comments.d.ts +20 -1
  883. package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
  884. package/lib/dist/resolution/strip-comments.js +164 -119
  885. package/lib/dist/resolution/strip-comments.js.map +1 -1
  886. package/lib/dist/resolution/sveltekit-synthesizer.js +0 -64
  887. package/lib/dist/resolution/sveltekit-synthesizer.js.map +1 -1
  888. package/lib/dist/resolution/swift-objc-bridge.js +0 -160
  889. package/lib/dist/resolution/swift-objc-bridge.js.map +1 -1
  890. package/lib/dist/resolution/swift-type-visibility.d.ts +68 -0
  891. package/lib/dist/resolution/swift-type-visibility.d.ts.map +1 -0
  892. package/lib/dist/resolution/swift-type-visibility.js +355 -0
  893. package/lib/dist/resolution/swift-type-visibility.js.map +1 -0
  894. package/lib/dist/resolution/synth-utils.js +1 -22
  895. package/lib/dist/resolution/synth-utils.js.map +1 -1
  896. package/lib/dist/resolution/tanstack-router-synthesizer.js +0 -32
  897. package/lib/dist/resolution/tanstack-router-synthesizer.js.map +1 -1
  898. package/lib/dist/resolution/tauri-synthesizer.d.ts +37 -0
  899. package/lib/dist/resolution/tauri-synthesizer.d.ts.map +1 -0
  900. package/lib/dist/resolution/tauri-synthesizer.js +1038 -0
  901. package/lib/dist/resolution/tauri-synthesizer.js.map +1 -0
  902. package/lib/dist/resolution/tier-synthesizer.d.ts +7 -2
  903. package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -1
  904. package/lib/dist/resolution/tier-synthesizer.js +318 -121
  905. package/lib/dist/resolution/tier-synthesizer.js.map +1 -1
  906. package/lib/dist/resolution/type-parameters.d.ts +34 -0
  907. package/lib/dist/resolution/type-parameters.d.ts.map +1 -0
  908. package/lib/dist/resolution/type-parameters.js +285 -0
  909. package/lib/dist/resolution/type-parameters.js.map +1 -0
  910. package/lib/dist/resolution/types.d.ts +209 -10
  911. package/lib/dist/resolution/types.d.ts.map +1 -1
  912. package/lib/dist/resolution/types.js +0 -47
  913. package/lib/dist/resolution/types.js.map +1 -1
  914. package/lib/dist/resolution/vbnet-receivers.d.ts +92 -0
  915. package/lib/dist/resolution/vbnet-receivers.d.ts.map +1 -0
  916. package/lib/dist/resolution/vbnet-receivers.js +1482 -0
  917. package/lib/dist/resolution/vbnet-receivers.js.map +1 -0
  918. package/lib/dist/resolution/vue-router-synthesizer.js +0 -31
  919. package/lib/dist/resolution/vue-router-synthesizer.js.map +1 -1
  920. package/lib/dist/resolution/workspace-packages.d.ts +206 -15
  921. package/lib/dist/resolution/workspace-packages.d.ts.map +1 -1
  922. package/lib/dist/resolution/workspace-packages.js +570 -152
  923. package/lib/dist/resolution/workspace-packages.js.map +1 -1
  924. package/lib/dist/search/identifier-segments.js +2 -93
  925. package/lib/dist/search/identifier-segments.js.map +1 -1
  926. package/lib/dist/search/query-parser.js +0 -54
  927. package/lib/dist/search/query-parser.js.map +1 -1
  928. package/lib/dist/search/query-paths.js +0 -167
  929. package/lib/dist/search/query-paths.js.map +1 -1
  930. package/lib/dist/search/query-utils.d.ts +44 -0
  931. package/lib/dist/search/query-utils.d.ts.map +1 -1
  932. package/lib/dist/search/query-utils.js +120 -198
  933. package/lib/dist/search/query-utils.js.map +1 -1
  934. package/lib/dist/sync/git-hooks.d.ts +14 -5
  935. package/lib/dist/sync/git-hooks.d.ts.map +1 -1
  936. package/lib/dist/sync/git-hooks.js +118 -65
  937. package/lib/dist/sync/git-hooks.js.map +1 -1
  938. package/lib/dist/sync/index.js +0 -14
  939. package/lib/dist/sync/index.js.map +1 -1
  940. package/lib/dist/sync/watch-policy.js +0 -45
  941. package/lib/dist/sync/watch-policy.js.map +1 -1
  942. package/lib/dist/sync/watcher.d.ts +29 -11
  943. package/lib/dist/sync/watcher.d.ts.map +1 -1
  944. package/lib/dist/sync/watcher.js +83 -487
  945. package/lib/dist/sync/watcher.js.map +1 -1
  946. package/lib/dist/sync/worktree.d.ts +29 -2
  947. package/lib/dist/sync/worktree.d.ts.map +1 -1
  948. package/lib/dist/sync/worktree.js +59 -78
  949. package/lib/dist/sync/worktree.js.map +1 -1
  950. package/lib/dist/telemetry/index.d.ts.map +1 -1
  951. package/lib/dist/telemetry/index.js +68 -146
  952. package/lib/dist/telemetry/index.js.map +1 -1
  953. package/lib/dist/types.d.ts +46 -0
  954. package/lib/dist/types.d.ts.map +1 -1
  955. package/lib/dist/types.js +15 -44
  956. package/lib/dist/types.js.map +1 -1
  957. package/lib/dist/ui/color.js +0 -19
  958. package/lib/dist/ui/color.js.map +1 -1
  959. package/lib/dist/ui/glyphs.js +2 -45
  960. package/lib/dist/ui/glyphs.js.map +1 -1
  961. package/lib/dist/ui/shimmer-progress.js +0 -21
  962. package/lib/dist/ui/shimmer-progress.js.map +1 -1
  963. package/lib/dist/ui/shimmer-worker.js +0 -22
  964. package/lib/dist/ui/shimmer-worker.js.map +1 -1
  965. package/lib/dist/ui-server/api/deadcode.d.ts.map +1 -1
  966. package/lib/dist/ui-server/api/deadcode.js +2 -31
  967. package/lib/dist/ui-server/api/deadcode.js.map +1 -1
  968. package/lib/dist/ui-server/api/effects.d.ts +7 -0
  969. package/lib/dist/ui-server/api/effects.d.ts.map +1 -1
  970. package/lib/dist/ui-server/api/effects.js +20 -103
  971. package/lib/dist/ui-server/api/effects.js.map +1 -1
  972. package/lib/dist/ui-server/api/entrypoints.d.ts +6 -0
  973. package/lib/dist/ui-server/api/entrypoints.d.ts.map +1 -1
  974. package/lib/dist/ui-server/api/entrypoints.js +73 -130
  975. package/lib/dist/ui-server/api/entrypoints.js.map +1 -1
  976. package/lib/dist/ui-server/api/events.js +0 -145
  977. package/lib/dist/ui-server/api/events.js.map +1 -1
  978. package/lib/dist/ui-server/api/file.js +0 -80
  979. package/lib/dist/ui-server/api/file.js.map +1 -1
  980. package/lib/dist/ui-server/api/filecode.js +0 -95
  981. package/lib/dist/ui-server/api/filecode.js.map +1 -1
  982. package/lib/dist/ui-server/api/flow.js +0 -149
  983. package/lib/dist/ui-server/api/flow.js.map +1 -1
  984. package/lib/dist/ui-server/api/hierarchy.js +0 -28
  985. package/lib/dist/ui-server/api/hierarchy.js.map +1 -1
  986. package/lib/dist/ui-server/api/index.js +0 -88
  987. package/lib/dist/ui-server/api/index.js.map +1 -1
  988. package/lib/dist/ui-server/api/map.d.ts +41 -6
  989. package/lib/dist/ui-server/api/map.d.ts.map +1 -1
  990. package/lib/dist/ui-server/api/map.js +95 -308
  991. package/lib/dist/ui-server/api/map.js.map +1 -1
  992. package/lib/dist/ui-server/api/node.d.ts.map +1 -1
  993. package/lib/dist/ui-server/api/node.js +4 -109
  994. package/lib/dist/ui-server/api/node.js.map +1 -1
  995. package/lib/dist/ui-server/api/nodes.js +0 -16
  996. package/lib/dist/ui-server/api/nodes.js.map +1 -1
  997. package/lib/dist/ui-server/api/program.js +0 -90
  998. package/lib/dist/ui-server/api/program.js.map +1 -1
  999. package/lib/dist/ui-server/api/respond.js +0 -60
  1000. package/lib/dist/ui-server/api/respond.js.map +1 -1
  1001. package/lib/dist/ui-server/api/route-roots.d.ts +6 -0
  1002. package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -1
  1003. package/lib/dist/ui-server/api/route-roots.js +18 -39
  1004. package/lib/dist/ui-server/api/route-roots.js.map +1 -1
  1005. package/lib/dist/ui-server/api/routes.d.ts +2 -0
  1006. package/lib/dist/ui-server/api/routes.d.ts.map +1 -1
  1007. package/lib/dist/ui-server/api/routes.js +47 -47
  1008. package/lib/dist/ui-server/api/routes.js.map +1 -1
  1009. package/lib/dist/ui-server/api/screens.d.ts.map +1 -1
  1010. package/lib/dist/ui-server/api/screens.js +16 -171
  1011. package/lib/dist/ui-server/api/screens.js.map +1 -1
  1012. package/lib/dist/ui-server/api/search.js +0 -62
  1013. package/lib/dist/ui-server/api/search.js.map +1 -1
  1014. package/lib/dist/ui-server/api/session.js +0 -58
  1015. package/lib/dist/ui-server/api/session.js.map +1 -1
  1016. package/lib/dist/ui-server/api/source.d.ts.map +1 -1
  1017. package/lib/dist/ui-server/api/source.js +0 -161
  1018. package/lib/dist/ui-server/api/source.js.map +1 -1
  1019. package/lib/dist/ui-server/api/stats.js +0 -58
  1020. package/lib/dist/ui-server/api/stats.js.map +1 -1
  1021. package/lib/dist/ui-server/api/steps.d.ts.map +1 -1
  1022. package/lib/dist/ui-server/api/steps.js +105 -373
  1023. package/lib/dist/ui-server/api/steps.js.map +1 -1
  1024. package/lib/dist/ui-server/api/trail-store.d.ts +3 -3
  1025. package/lib/dist/ui-server/api/trail-store.d.ts.map +1 -1
  1026. package/lib/dist/ui-server/api/trail-store.js +24 -106
  1027. package/lib/dist/ui-server/api/trail-store.js.map +1 -1
  1028. package/lib/dist/ui-server/api/trails.d.ts.map +1 -1
  1029. package/lib/dist/ui-server/api/trails.js +20 -94
  1030. package/lib/dist/ui-server/api/trails.js.map +1 -1
  1031. package/lib/dist/ui-server/api/when.d.ts +10 -2
  1032. package/lib/dist/ui-server/api/when.d.ts.map +1 -1
  1033. package/lib/dist/ui-server/api/when.js +32 -44
  1034. package/lib/dist/ui-server/api/when.js.map +1 -1
  1035. package/lib/dist/ui-server/api/wire.js +0 -58
  1036. package/lib/dist/ui-server/api/wire.js.map +1 -1
  1037. package/lib/dist/ui-server/assets.js +0 -35
  1038. package/lib/dist/ui-server/assets.js.map +1 -1
  1039. package/lib/dist/ui-server/constants.js +0 -26
  1040. package/lib/dist/ui-server/constants.js.map +1 -1
  1041. package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts +28 -0
  1042. package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts.map +1 -0
  1043. package/lib/dist/ui-server/highlight/bounded-tokenize.js +114 -0
  1044. package/lib/dist/ui-server/highlight/bounded-tokenize.js.map +1 -0
  1045. package/lib/dist/ui-server/highlight/index.d.ts.map +1 -1
  1046. package/lib/dist/ui-server/highlight/index.js +7 -133
  1047. package/lib/dist/ui-server/highlight/index.js.map +1 -1
  1048. package/lib/dist/ui-server/highlight/languages.d.ts +3 -3
  1049. package/lib/dist/ui-server/highlight/languages.js +0 -31
  1050. package/lib/dist/ui-server/highlight/languages.js.map +1 -1
  1051. package/lib/dist/ui-server/highlight/tokenize-worker.d.ts +7 -0
  1052. package/lib/dist/ui-server/highlight/tokenize-worker.d.ts.map +1 -0
  1053. package/lib/dist/ui-server/highlight/tokenize-worker.js +15 -0
  1054. package/lib/dist/ui-server/highlight/tokenize-worker.js.map +1 -0
  1055. package/lib/dist/ui-server/index.d.ts +25 -0
  1056. package/lib/dist/ui-server/index.d.ts.map +1 -1
  1057. package/lib/dist/ui-server/index.js +35 -103
  1058. package/lib/dist/ui-server/index.js.map +1 -1
  1059. package/lib/dist/ui-server/open-browser.js +0 -34
  1060. package/lib/dist/ui-server/open-browser.js.map +1 -1
  1061. package/lib/dist/ui-server/security.d.ts +5 -0
  1062. package/lib/dist/ui-server/security.d.ts.map +1 -1
  1063. package/lib/dist/ui-server/security.js +11 -147
  1064. package/lib/dist/ui-server/security.js.map +1 -1
  1065. package/lib/dist/ui-server/static.js +0 -41
  1066. package/lib/dist/ui-server/static.js.map +1 -1
  1067. package/lib/dist/upgrade/index.d.ts +61 -10
  1068. package/lib/dist/upgrade/index.d.ts.map +1 -1
  1069. package/lib/dist/upgrade/index.js +191 -225
  1070. package/lib/dist/upgrade/index.js.map +1 -1
  1071. package/lib/dist/upgrade/remove-binary.js +2 -67
  1072. package/lib/dist/upgrade/remove-binary.js.map +1 -1
  1073. package/lib/dist/upgrade/update-check.js +1 -81
  1074. package/lib/dist/upgrade/update-check.js.map +1 -1
  1075. package/lib/dist/utils.d.ts +69 -1
  1076. package/lib/dist/utils.d.ts.map +1 -1
  1077. package/lib/dist/utils.js +224 -266
  1078. package/lib/dist/utils.js.map +1 -1
  1079. package/lib/dist/viewer/assets/{index-D4S7YUPf.js → index-BSGpxBr9.js} +60 -58
  1080. package/lib/dist/viewer/index.html +1 -1
  1081. package/lib/dist/worker-teardown.d.ts +48 -0
  1082. package/lib/dist/worker-teardown.d.ts.map +1 -0
  1083. package/lib/dist/worker-teardown.js +53 -0
  1084. package/lib/dist/worker-teardown.js.map +1 -0
  1085. package/lib/kernel/codegraph-kernel.node +2 -2
  1086. package/lib/node_modules/.package-lock.json +4 -4
  1087. package/lib/node_modules/ignore/README.md +138 -8
  1088. package/lib/node_modules/ignore/index.d.ts +56 -20
  1089. package/lib/node_modules/ignore/index.js +1033 -221
  1090. package/lib/node_modules/ignore/legacy.js +871 -178
  1091. package/lib/node_modules/ignore/package.json +10 -4
  1092. package/lib/package.json +14 -8
  1093. package/node.exe +2 -2
  1094. package/package.json +1 -1
@@ -1,10 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cppExtractor = exports.cExtractor = void 0;
3
+ exports.cppExtractor = exports.OBJC_LONE_MACROS = exports.cExtractor = void 0;
4
+ exports.cDeclaratorIdentifier = cDeclaratorIdentifier;
5
+ exports.isConstDeclaration = isConstDeclaration;
6
+ exports.isUnnamedMemberType = isUnnamedMemberType;
7
+ exports.cMemberTypeNames = cMemberTypeNames;
8
+ exports.cAliasTypeNames = cAliasTypeNames;
9
+ exports.isClassLikeDefinition = isClassLikeDefinition;
10
+ exports.definingDeclaration = definingDeclaration;
11
+ exports.unnamedTypeVariableName = unnamedTypeVariableName;
4
12
  exports.normalizeCppReturnType = normalizeCppReturnType;
5
13
  exports.stripCppTemplateArgs = stripCppTemplateArgs;
6
14
  exports.isCppPureVirtualMethodDecl = isCppPureVirtualMethodDecl;
7
15
  exports.blankCppExportMacros = blankCppExportMacros;
16
+ exports.blankCppPointerAnnotationMacros = blankCppPointerAnnotationMacros;
17
+ exports.blankCppTrailingAttributeMacros = blankCppTrailingAttributeMacros;
18
+ exports.blankCppDeclaratorAttributeMacros = blankCppDeclaratorAttributeMacros;
19
+ exports.blankCppLeadingAttributeMacros = blankCppLeadingAttributeMacros;
8
20
  exports.blankCppInlineMacros = blankCppInlineMacros;
9
21
  exports.recoverMangledCppName = recoverMangledCppName;
10
22
  exports.blankMetalAttributes = blankMetalAttributes;
@@ -14,6 +26,9 @@ exports.blankLoneMacroLines = blankLoneMacroLines;
14
26
  exports.blankCppApiPrefixMacros = blankCppApiPrefixMacros;
15
27
  exports.blankCppInlineAnnotationMacros = blankCppInlineAnnotationMacros;
16
28
  exports.blankCudaConstructs = blankCudaConstructs;
29
+ exports.rewriteCppAccessMacros = rewriteCppAccessMacros;
30
+ exports.flattenMidStatementConditionals = flattenMidStatementConditionals;
31
+ exports.rewriteFoundationEnumMacros = rewriteFoundationEnumMacros;
17
32
  exports.blankCLeadingAttrMacros = blankCLeadingAttrMacros;
18
33
  exports.blankCCplusplusGuardBodies = blankCCplusplusGuardBodies;
19
34
  exports.blankCStatementMacroCalls = blankCStatementMacroCalls;
@@ -28,16 +43,153 @@ exports.rewriteCPrefixedDeclMacroInitializers = rewriteCPrefixedDeclMacroInitial
28
43
  exports.blankCVaArgQualifiedTypeArgs = blankCVaArgQualifiedTypeArgs;
29
44
  exports.blankCNamedVariadicDefineDots = blankCNamedVariadicDefineDots;
30
45
  exports.blankCDesignatedMacroArgs = blankCDesignatedMacroArgs;
46
+ exports.blankCUnbalancedConditionalBranches = blankCUnbalancedConditionalBranches;
31
47
  exports.isCppConstructorDeclaration = isCppConstructorDeclaration;
32
48
  const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
33
- /**
34
- * Find the function NAME's `qualified_identifier` (`Foo::bar`) inside a
35
- * declarator, skipping the `parameter_list` — a parameter with a qualified type
36
- * (`const std::string& x`) must NOT be mistaken for the method name. Without the
37
- * skip, a plain free function `std::string TableFileName(const std::string&...)`
38
- * was named `string` (from the parameter type), so calls to it never resolved
39
- * and its file looked like nothing depended on it.
40
- */
49
+ function cDeclaratorIdentifier(node) {
50
+ let cur = node;
51
+ let guard = 0;
52
+ while (cur && guard++ < 12) {
53
+ switch (cur.type) {
54
+ case 'identifier':
55
+ return cur;
56
+ case 'function_declarator':
57
+ return null;
58
+ case 'init_declarator':
59
+ case 'pointer_declarator':
60
+ case 'array_declarator':
61
+ case 'parenthesized_declarator':
62
+ cur = (0, tree_sitter_helpers_1.getChildByField)(cur, 'declarator');
63
+ break;
64
+ default:
65
+ return null;
66
+ }
67
+ }
68
+ return null;
69
+ }
70
+ function isConstDeclaration(node) {
71
+ return node.namedChildren.some((c) => c.type === 'type_qualifier' && c.text === 'const');
72
+ }
73
+ const CLASS_LIKE_SPECIFIERS = new Set(['class_specifier', 'struct_specifier', 'union_specifier', 'enum_specifier']);
74
+ const MEMBER_CONDITIONALS = new Set(['preproc_if', 'preproc_ifdef', 'preproc_else', 'preproc_elif', 'preproc_elifdef']);
75
+ const COMPUTED_TYPE_SPECIFIERS = new Set(['decltype', 'placeholder_type_specifier']);
76
+ const C_STANDARD_TYPE_NAME = /^(?:(?:::\s*)?std\s*::|(?:_Bool|_Complex|wchar_t|char(?:8|16|32)_t|u?intmax_t|u?int_(?:least|fast)\d+_t|max_align_t|nullptr_t)$)/;
77
+ function innerDeclarator(declarator) {
78
+ return (0, tree_sitter_helpers_1.getChildByField)(declarator, 'declarator') ?? declarator.namedChild(0);
79
+ }
80
+ function declaresMemberFunction(declarator) {
81
+ let d = declarator;
82
+ while (d && (d.type === 'pointer_declarator' || d.type === 'reference_declarator'))
83
+ d = innerDeclarator(d);
84
+ return d?.type === 'function_declarator' && (0, tree_sitter_helpers_1.getChildByField)(d, 'declarator')?.type !== 'parenthesized_declarator';
85
+ }
86
+ function isUnnamedMemberType(specifier) {
87
+ return !(0, tree_sitter_helpers_1.getChildByField)(specifier, 'name') && specifier.parent?.type === 'field_declaration';
88
+ }
89
+ function cMemberTypeNames(specifier, ownName, source) {
90
+ const names = [];
91
+ const own = new Set([ownName]);
92
+ const tag = (0, tree_sitter_helpers_1.getChildByField)(specifier, 'name');
93
+ if (tag)
94
+ own.add(stripCppTemplateArgs((0, tree_sitter_helpers_1.getNodeText)(tag, source)));
95
+ const body = (0, tree_sitter_helpers_1.getChildByField)(specifier, 'body');
96
+ if (body)
97
+ collectMemberTypeNames(body, own, source, names);
98
+ return names;
99
+ }
100
+ function cAliasTypeNames(alias, ownName, source) {
101
+ const names = [];
102
+ const own = new Set([ownName]);
103
+ const type = (0, tree_sitter_helpers_1.getChildByField)(alias, 'type');
104
+ if (type)
105
+ collectCTypeNames(type, own, source, names);
106
+ for (const declarator of alias.childrenForFieldName('declarator')) {
107
+ if (declarator)
108
+ collectDeclaratorTypeNames(declarator, own, source, names);
109
+ }
110
+ return names;
111
+ }
112
+ function collectMemberTypeNames(list, own, source, names) {
113
+ for (const child of list.namedChildren) {
114
+ if (MEMBER_CONDITIONALS.has(child.type)) {
115
+ collectMemberTypeNames(child, own, source, names);
116
+ continue;
117
+ }
118
+ if (child.type !== 'field_declaration')
119
+ continue;
120
+ const type = (0, tree_sitter_helpers_1.getChildByField)(child, 'type');
121
+ if (!type)
122
+ continue;
123
+ const declarators = child.childrenForFieldName('declarator').filter((d) => !!d);
124
+ const unnamedBody = CLASS_LIKE_SPECIFIERS.has(type.type) && !(0, tree_sitter_helpers_1.getChildByField)(type, 'name')
125
+ ? (0, tree_sitter_helpers_1.getChildByField)(type, 'body')
126
+ : null;
127
+ if (unnamedBody)
128
+ collectMemberTypeNames(unnamedBody, own, source, names);
129
+ else if (declarators.length > 0)
130
+ collectCTypeNames(type, own, source, names);
131
+ for (const declarator of declarators) {
132
+ if (!declaresMemberFunction(declarator))
133
+ collectDeclaratorTypeNames(declarator, own, source, names);
134
+ }
135
+ }
136
+ }
137
+ function collectDeclaratorTypeNames(declarator, own, source, names) {
138
+ if (declarator.type === 'function_declarator') {
139
+ const parameters = (0, tree_sitter_helpers_1.getChildByField)(declarator, 'parameters');
140
+ if (parameters)
141
+ collectCTypeNames(parameters, own, source, names);
142
+ }
143
+ if (!declarator.type.endsWith('declarator'))
144
+ return;
145
+ const inner = innerDeclarator(declarator);
146
+ if (inner)
147
+ collectDeclaratorTypeNames(inner, own, source, names);
148
+ }
149
+ function collectCTypeNames(node, own, source, names) {
150
+ if (COMPUTED_TYPE_SPECIFIERS.has(node.type))
151
+ return;
152
+ if (node.type === 'type_identifier' || node.type === 'qualified_identifier' || node.type === 'template_type') {
153
+ const name = stripCppTemplateArgs((0, tree_sitter_helpers_1.getNodeText)(node, source)).trim();
154
+ if (name && !own.has(name) && !C_STANDARD_TYPE_NAME.test(name))
155
+ names.push({ name, node });
156
+ collectTemplateArguments(node, own, source, names);
157
+ return;
158
+ }
159
+ const tag = CLASS_LIKE_SPECIFIERS.has(node.type) ? (0, tree_sitter_helpers_1.getChildByField)(node, 'name') : null;
160
+ for (const c of tag ? [tag] : node.namedChildren)
161
+ collectCTypeNames(c, own, source, names);
162
+ }
163
+ function collectTemplateArguments(node, own, source, names) {
164
+ for (const c of node.namedChildren) {
165
+ if (c.type === 'template_argument_list')
166
+ collectCTypeNames(c, own, source, names);
167
+ else if (c.type === 'qualified_identifier' || c.type === 'template_type')
168
+ collectTemplateArguments(c, own, source, names);
169
+ }
170
+ }
171
+ function isClassLikeDefinition(node) {
172
+ return CLASS_LIKE_SPECIFIERS.has(node.type) && (0, tree_sitter_helpers_1.getChildByField)(node, 'body') !== null;
173
+ }
174
+ function definingDeclaration(node) {
175
+ if (!isClassLikeDefinition(node))
176
+ return null;
177
+ const parent = node.parent;
178
+ return parent?.type === 'declaration' && (0, tree_sitter_helpers_1.getChildByField)(parent, 'type')?.id === node.id ? parent : null;
179
+ }
180
+ function unnamedTypeVariableName(node, source) {
181
+ if ((0, tree_sitter_helpers_1.getChildByField)(node, 'name'))
182
+ return undefined;
183
+ const declaration = definingDeclaration(node);
184
+ if (!declaration)
185
+ return undefined;
186
+ for (const declarator of declaration.childrenForFieldName('declarator')) {
187
+ const identifier = cDeclaratorIdentifier(declarator);
188
+ if (identifier)
189
+ return (0, tree_sitter_helpers_1.getNodeText)(identifier, source);
190
+ }
191
+ return undefined;
192
+ }
41
193
  function findDeclaratorQualifiedId(declarator) {
42
194
  const queue = [declarator];
43
195
  while (queue.length > 0) {
@@ -46,21 +198,16 @@ function findDeclaratorQualifiedId(declarator) {
46
198
  return current;
47
199
  for (let i = 0; i < current.namedChildCount; i++) {
48
200
  const child = current.namedChild(i);
49
- // Don't descend into parameters or the trailing return type — their types
50
- // (`const std::string&`, `-> std::string`) aren't the function name.
51
- if (child && child.type !== 'parameter_list' && child.type !== 'trailing_return_type') {
201
+ if (child && !DECLARATOR_NON_NAME_PARTS.has(child.type)) {
52
202
  queue.push(child);
53
203
  }
54
204
  }
55
205
  }
56
206
  return undefined;
57
207
  }
58
- /**
59
- * Single-argument macros are ambiguous without their definition (#1373).
60
- * Require a preceding local #define whose replacement uses its sole parameter
61
- * as the function declarator; registration, token-pasting, and K&R forms stay
62
- * untouched. Walk enclosing scopes, but never guess across conditional macros.
63
- */
208
+ const DECLARATOR_NON_NAME_PARTS = new Set([
209
+ 'parameter_list', 'trailing_return_type', 'noexcept', 'throw_specifier', 'requires_clause',
210
+ ]);
64
211
  function recoverSingleArgMacroDefinedName(node, source) {
65
212
  if (node.type !== 'function_definition')
66
213
  return undefined;
@@ -68,14 +215,12 @@ function recoverSingleArgMacroDefinedName(node, source) {
68
215
  let macro = null;
69
216
  let argument = null;
70
217
  if (declarator?.type === 'parenthesized_declarator' && declarator.namedChildCount === 1) {
71
- // C: NATIVE_FN is parsed as the return type, (name) as the declarator.
72
218
  macro = (0, tree_sitter_helpers_1.getChildByField)(node, 'type');
73
219
  argument = declarator.namedChild(0);
74
220
  if (macro?.type !== 'type_identifier' || argument?.type !== 'identifier')
75
221
  return undefined;
76
222
  }
77
223
  else if (declarator?.type === 'function_declarator' && !(0, tree_sitter_helpers_1.getChildByField)(node, 'type')) {
78
- // C++: NATIVE_FN(name) is parsed as an implicit-return-type function.
79
224
  macro = (0, tree_sitter_helpers_1.getChildByField)(declarator, 'declarator');
80
225
  const params = (0, tree_sitter_helpers_1.getChildByField)(declarator, 'parameters');
81
226
  const param = params?.namedChild(0);
@@ -116,25 +261,6 @@ function recoverSingleArgMacroDefinedName(node, source) {
116
261
  }
117
262
  return undefined;
118
263
  }
119
- /**
120
- * Recover the real function name from the macro-definition idiom
121
- * `MACRO_NAME(real_name, typed args…) { body }` — flash-attention's
122
- * `DEFINE_FLASH_FORWARD_KERNEL(flash_fwd_kernel, bool Is_dropout, …) { … }`
123
- * being the motivating case: tree-sitter parses the invocation as a
124
- * function_definition NAMED after the macro, so every such kernel shared one
125
- * name (`DEFINE_FLASH_FORWARD_KERNEL`) and the launch sites' calls to the real
126
- * names (`flash_fwd_kernel<…><<<…>>>`) could never resolve.
127
- *
128
- * Deliberately narrow so name-in-first-arg is unambiguous — ALL of:
129
- * - the parsed name is macro-shaped: ALL-CAPS with at least one underscore
130
- * (`TEST` never matches; K&R C definitions have lowercase names);
131
- * - the first "parameter" is a LONE identifier (no type, no declarator)
132
- * containing a lowercase letter — the name being defined;
133
- * - at least one more parameter follows and NONE of them is another lone
134
- * identifier — a second bare arg means the first isn't the name (gtest's
135
- * `TEST_F(Fixture, Name)`, `PYBIND11_MODULE(ext, m)`,
136
- * google-benchmark's `BENCHMARK_DEFINE_F(Fix, name)` all bail here).
137
- */
138
264
  function recoverCppMacroDefinedName(node, source) {
139
265
  if (node.type !== 'function_definition')
140
266
  return undefined;
@@ -166,6 +292,31 @@ function recoverCppMacroDefinedName(node, source) {
166
292
  }
167
293
  return name;
168
294
  }
295
+ const CPP_CLASS_SPECIFIERS = new Set(['class_specifier', 'struct_specifier', 'union_specifier']);
296
+ function cppWrittenClassParts(node, source) {
297
+ if (!CPP_CLASS_SPECIFIERS.has(node.type))
298
+ return undefined;
299
+ const written = (0, tree_sitter_helpers_1.getChildByField)(node, 'name');
300
+ if (written?.type !== 'qualified_identifier')
301
+ return undefined;
302
+ let innermost = written;
303
+ while (innermost?.type === 'qualified_identifier')
304
+ innermost = (0, tree_sitter_helpers_1.getChildByField)(innermost, 'name');
305
+ if (innermost?.type !== 'type_identifier')
306
+ return undefined;
307
+ const parts = stripCppTemplateArgs((0, tree_sitter_helpers_1.getNodeText)(written, source)).split('::').map((p) => p.trim()).filter(Boolean);
308
+ return parts.length > 0 && parts.every((p) => /^[A-Za-z_]\w*$/.test(p)) ? parts : undefined;
309
+ }
310
+ function cppQualifiedIdName(qid) {
311
+ let name = qid;
312
+ while (name?.type === 'qualified_identifier')
313
+ name = (0, tree_sitter_helpers_1.getChildByField)(name, 'name');
314
+ return name;
315
+ }
316
+ function cppDefinedName(name, source) {
317
+ const own = name.type === 'template_function' ? (0, tree_sitter_helpers_1.getChildByField)(name, 'name') : null;
318
+ return (0, tree_sitter_helpers_1.getNodeText)(own ?? name, source).trim();
319
+ }
169
320
  function extractCppQualifiedMethodName(node, source) {
170
321
  const macroDefined = recoverSingleArgMacroDefinedName(node, source) ?? recoverCppMacroDefinedName(node, source);
171
322
  if (macroDefined)
@@ -176,9 +327,24 @@ function extractCppQualifiedMethodName(node, source) {
176
327
  const qid = findDeclaratorQualifiedId(declarator);
177
328
  if (!qid)
178
329
  return undefined;
330
+ const name = cppQualifiedIdName(qid);
331
+ if (name)
332
+ return cppDefinedName(name, source);
179
333
  const parts = (0, tree_sitter_helpers_1.getNodeText)(qid, source).trim().split('::').filter(Boolean);
180
334
  return parts[parts.length - 1];
181
335
  }
336
+ function cppSpecializedFunctionName(node, source) {
337
+ if (node.type !== 'function_definition')
338
+ return undefined;
339
+ let declarator = (0, tree_sitter_helpers_1.getChildByField)(node, 'declarator');
340
+ while (declarator && (declarator.type === 'pointer_declarator' || declarator.type === 'reference_declarator')) {
341
+ declarator = (0, tree_sitter_helpers_1.getChildByField)(declarator, 'declarator') || declarator.namedChild(0);
342
+ }
343
+ if (declarator?.type !== 'function_declarator')
344
+ return undefined;
345
+ const inner = (0, tree_sitter_helpers_1.getChildByField)(declarator, 'declarator');
346
+ return inner?.type === 'template_function' ? cppDefinedName(inner, source) : undefined;
347
+ }
182
348
  function extractCppReceiverType(node, source) {
183
349
  const declarator = (0, tree_sitter_helpers_1.getChildByField)(node, 'declarator');
184
350
  if (!declarator)
@@ -186,41 +352,29 @@ function extractCppReceiverType(node, source) {
186
352
  const qid = findDeclaratorQualifiedId(declarator);
187
353
  if (!qid)
188
354
  return undefined;
189
- const parts = (0, tree_sitter_helpers_1.getNodeText)(qid, source).trim().split('::').filter(Boolean);
190
- if (parts.length <= 1)
355
+ const name = cppQualifiedIdName(qid);
356
+ let scopes = (0, tree_sitter_helpers_1.getNodeText)(qid, source).trim().split('::').filter(Boolean).slice(0, -1).join('::');
357
+ if (name) {
358
+ scopes = source.slice(qid.startIndex, name.startIndex).trimEnd();
359
+ if (!scopes.endsWith('::'))
360
+ return undefined;
361
+ }
362
+ const parts = scopes.split('::').filter(Boolean);
363
+ if (parts.length === 0)
191
364
  return undefined;
192
- // An out-of-line template method definition carries the class's template
193
- // parameter list in the qualifier (`template<typename T> T Box<T>::get()`),
194
- // but the class node is indexed as bare `Box` — strip `<…>` so the receiver
195
- // matches it, the same normalization #1043 applies to base-class refs.
196
- // Multi-line parameter lists otherwise leak whole `<…>` blocks (newlines
197
- // included) into qualified_name, which can exceed NAME_MAX (#1286).
198
- const receiver = stripCppTemplateArgs(parts.slice(0, -1).join('::'));
365
+ const receiver = stripCppTemplateArgs(parts.join('::'));
199
366
  return receiver || undefined;
200
367
  }
201
- /**
202
- * Built-in / non-class return types that can never be a method receiver. We
203
- * store no `returnType` for these so resolution never tries to resolve a method
204
- * on `void` / `int` / etc.
205
- */
206
368
  const CPP_NON_CLASS_RETURN = new Set([
207
369
  'void', 'bool', 'char', 'short', 'int', 'long', 'float', 'double', 'unsigned',
208
370
  'signed', 'size_t', 'ssize_t', 'auto', 'wchar_t', 'char8_t', 'char16_t',
209
371
  'char32_t', 'int8_t', 'int16_t', 'int32_t', 'int64_t', 'uint8_t', 'uint16_t',
210
372
  'uint32_t', 'uint64_t', 'intptr_t', 'uintptr_t', 'nullptr_t',
211
373
  ]);
212
- /**
213
- * Normalize a C++ return type to the bare class name a method could be called
214
- * on. Unwraps smart-pointer / optional wrappers to their element type
215
- * (`std::unique_ptr<Widget>` → `Widget`) so a factory's `->method()` resolves on
216
- * the pointee. Strips cv-qualifiers, `&`/`*`, namespace qualifiers, and other
217
- * template args. Returns undefined for primitives / void / `auto` / empty.
218
- */
219
374
  function normalizeCppReturnType(raw) {
220
375
  let t = raw.trim();
221
376
  if (!t)
222
377
  return undefined;
223
- // Unwrap smart pointers / optional to their pointee (the thing you call `->` on).
224
378
  const wrapper = t.match(/\b(?:std\s*::\s*)?(?:unique_ptr|shared_ptr|weak_ptr|optional)\s*<\s*([^,>]+?)\s*>/);
225
379
  if (wrapper && wrapper[1])
226
380
  t = wrapper[1];
@@ -241,21 +395,6 @@ function normalizeCppReturnType(raw) {
241
395
  return undefined;
242
396
  return last;
243
397
  }
244
- /**
245
- * Strip C++ template arguments from a base-type reference name so it matches the
246
- * bare class/struct the template was DEFINED as. `template<typename T> class
247
- * Base { … }` is indexed as a node named `Base`, but a derived class
248
- * `class D : public Base<int>` records its base as the full `Base<int>` (and
249
- * `class Q : public ns::Tpl<int>` as `ns::Tpl<int>`) — neither name-matches
250
- * `Base` / `ns::Tpl`, so the `extends` edge never resolves and the derived class
251
- * looks like it inherits from nothing (#1043).
252
- *
253
- * Removes every balanced `<…>` group regardless of nesting or position, so
254
- * `Base<int>` → `Base`, `ns::Tpl<Foo<int>>` → `ns::Tpl`, and the rare
255
- * `Outer<int>::Inner` → `Outer::Inner`. The remaining qualified head is exactly
256
- * what the non-templated base case already produces, so resolution treats them
257
- * identically. A name with no template args passes through unchanged.
258
- */
259
398
  function stripCppTemplateArgs(name) {
260
399
  if (!name.includes('<'))
261
400
  return name;
@@ -273,15 +412,6 @@ function stripCppTemplateArgs(name) {
273
412
  }
274
413
  return out.trim();
275
414
  }
276
- /**
277
- * Is this C++ `field_declaration` a pure-virtual method (`virtual int read(int key) = 0;`)?
278
- * tree-sitter-cpp shapes those as a field_declaration whose declarator unwraps to a
279
- * `function_declarator`, with the pure-virtual `= 0` as a DIRECT `number_literal` "0"
280
- * child of the field_declaration (default-arg `= 0` lives inside parameter_declaration
281
- * and must not match). Bodiless method prototypes (`int foo();`) and data members
282
- * (`int x = 0;`) are excluded — prototypes usually have an out-of-line definition that
283
- * already mints the method node; pure virtuals never do (#1727).
284
- */
285
415
  function isCppPureVirtualMethodDecl(node) {
286
416
  if (node.type !== 'field_declaration')
287
417
  return false;
@@ -299,11 +429,6 @@ function isCppPureVirtualMethodDecl(node) {
299
429
  return false;
300
430
  return node.namedChildren.some((c) => c.type === 'number_literal' && c.text === '0');
301
431
  }
302
- /**
303
- * A function/method's return type lives in the `function_definition`'s `type`
304
- * field (`Metrics& Metrics::instance()` → `Metrics`). Constructors, destructors,
305
- * and conversion operators have no `type` field → undefined.
306
- */
307
432
  function extractCppReturnType(node, source) {
308
433
  const typeNode = (0, tree_sitter_helpers_1.getChildByField)(node, 'type');
309
434
  if (!typeNode)
@@ -311,39 +436,28 @@ function extractCppReturnType(node, source) {
311
436
  return normalizeCppReturnType((0, tree_sitter_helpers_1.getNodeText)(typeNode, source));
312
437
  }
313
438
  exports.cExtractor = {
314
- resolveName: recoverSingleArgMacroDefinedName,
315
- // CUDA in C-detected headers (content-gated blank; see preParseCSource).
439
+ resolveName: (node, source) => recoverSingleArgMacroDefinedName(node, source) ?? unnamedTypeVariableName(node, source),
440
+ getDeclarationWrapper: (node) => definingDeclaration(node) ?? undefined,
316
441
  preParse: preParseCSource,
317
- // Universal net: recover a real name from any macro-mangled function name.
318
442
  recoverMangledName: recoverMangledCppName,
319
443
  functionTypes: ['function_definition'],
320
444
  classTypes: [],
321
445
  methodTypes: [],
322
446
  interfaceTypes: [],
323
447
  structTypes: ['struct_specifier'],
324
- // A bodiless `union U;` is a forward declaration; the aggregate extractor
325
- // applies the same body requirement it uses for C structs.
326
448
  unionTypes: ['union_specifier'],
327
449
  enumTypes: ['enum_specifier'],
328
450
  enumMemberTypes: ['enumerator'],
329
- typeAliasTypes: ['type_definition'], // typedef
451
+ typeAliasTypes: ['type_definition'],
330
452
  importTypes: ['preproc_include'],
331
453
  callTypes: ['call_expression'],
332
454
  variableTypes: ['declaration'],
333
455
  nameField: 'declarator',
334
456
  bodyField: 'body',
335
457
  paramsField: 'parameters',
336
- // A `const`/`static const` file-scope declaration carries a `type_qualifier`
337
- // child reading "const" — extract those as `constant`, plain globals as
338
- // `variable`.
339
- isConst: (node) => node.namedChildren.some((c) => c.type === 'type_qualifier' && c.text === 'const'),
458
+ isConst: isConstDeclaration,
340
459
  getReturnType: extractCppReturnType,
341
460
  resolveTypeAliasKind: (node, _source) => {
342
- // C typedef: `typedef enum { ... } name;` or `typedef struct { ... } name;`
343
- // The inner enum_specifier/struct_specifier is anonymous, but we want the typedef name
344
- // to become the enum/struct node name. `typedef union { ... } name;` takes the
345
- // same route — otherwise the union body would mint a second, `<anonymous>` node
346
- // beside the alias.
347
461
  for (let i = 0; i < node.namedChildCount; i++) {
348
462
  const child = node.namedChild(i);
349
463
  if (!child)
@@ -360,7 +474,6 @@ exports.cExtractor = {
360
474
  },
361
475
  extractImport: (node, source) => {
362
476
  const importText = source.substring(node.startIndex, node.endIndex).trim();
363
- // C includes: #include <stdio.h>, #include "myheader.h"
364
477
  const systemLib = node.namedChildren.find((c) => c.type === 'system_lib_string');
365
478
  if (systemLib) {
366
479
  return { moduleName: (0, tree_sitter_helpers_1.getNodeText)(systemLib, source).replace(/^<|>$/g, ''), signature: importText };
@@ -375,30 +488,6 @@ exports.cExtractor = {
375
488
  return null;
376
489
  },
377
490
  };
378
- /**
379
- * Detect tree-sitter's misparse of a macro-annotated class/struct, e.g.
380
- * `class MACRO Name { … }` or `class MACRO Name : public Base { … }` (#946).
381
- * Not knowing `MACRO` is a macro, tree-sitter reads `class MACRO` as an
382
- * *elaborated type specifier* (a bodyless `class_specifier`/`struct_specifier`
383
- * whose "type name" is the macro) and the rest as a function: `Name` becomes the
384
- * declarator and the `{ … }` a function body — so the whole declaration surfaces
385
- * as a `function_definition` named after the class, with a line range spanning
386
- * the entire class body. (A base clause, when present, additionally lands in an
387
- * `ERROR` node, but it isn't required — the leading macro alone triggers this.)
388
- *
389
- * Two structural signals pin it down with no risk to genuine code:
390
- * - the `type` field is a *bodyless* class/struct specifier — an elaborated
391
- * type, not a real inline-defined return type like
392
- * `struct P { int x; } makeP() { … }` (which carries a field list); and
393
- * - the declarator is not a `function_declarator` — a real function definition
394
- * always has one, which also leaves the legal-but-rare `class Foo f() { … }`
395
- * (an elaborated return type on a genuine function) alone.
396
- *
397
- * The class body is mangled by the same misparse and is unrecoverable, so —
398
- * matching how macro-prefixed C prototypes are handled — we drop the spurious
399
- * node rather than mint a misleading whole-body `function` that pollutes
400
- * callers/impact and skews kind statistics.
401
- */
402
491
  function isMacroMisparsedTypeDecl(node) {
403
492
  const typeNode = (0, tree_sitter_helpers_1.getChildByField)(node, 'type');
404
493
  if (!typeNode)
@@ -412,139 +501,319 @@ function isMacroMisparsedTypeDecl(node) {
412
501
  return false;
413
502
  return true;
414
503
  }
415
- /**
416
- * Blank an export/visibility macro in a `class/struct EXPORT_MACRO Name …`
417
- * *definition* header before parsing. Not knowing the macro, tree-sitter reads
418
- * `class EXPORT_MACRO` as an elaborated type specifier and the rest as a
419
- * function, so the whole class — its name, base clause, and members — drops out
420
- * of the index (#946 catches the resulting phantom function but can't recover
421
- * the class), which silently breaks type-hierarchy / inheritance-impact queries
422
- * for effectively every Unreal-Engine (`*_API`), Qt/Boost (`*_EXPORT`), LLVM
423
- * (`*_ABI`), … class. Replacing the macro with equal-length spaces preserves
424
- * every byte offset (and thus line/column), so the declaration then parses as a
425
- * normal class_specifier and the existing extraction emits the node, members,
426
- * and `extends` edge. (#1061, follow-up to #946.)
427
- *
428
- * Matched tightly so it can't touch the same macro used as an ordinary value
429
- * elsewhere (`int x = SOME_API;`): the macro is the ALL-CAPS token sitting
430
- * *between* `class`/`struct` and the type name, and the trailing `[:{]`
431
- * definition-guard fires only when a base clause or body follows — the only
432
- * shape that misparses. That guard also leaves elaborated-type variable
433
- * declarations (`struct FOO var;`, `class FOO obj = …`) untouched, since those
434
- * end in `;` / `=` / `[`, never `:` / `{`. C++-only (wired into cppExtractor),
435
- * so C's heavier use of `struct TAG var;` never reaches it.
436
- */
504
+ const CPP_CLASS_HEAD_MACROS_RE = /\b(?:class|struct)\s+((?:[A-Z][A-Z0-9_]+(?:\s*\((?:[^()]|\([^()]*\))*\))?\s+)+)(?!final\b)[A-Za-z_]\w*(?:\s*::\s*[A-Za-z_]\w*)*/g;
437
505
  function blankCppExportMacros(source) {
438
506
  if (source.indexOf('class') === -1 && source.indexOf('struct') === -1)
439
507
  return source;
440
- return source.replace(/\b(class|struct)(\s+)([A-Z][A-Z0-9_]+)(?=\s+[A-Za-z_]\w*(?:\s+final)?\s*[:{])/g, (_m, kw, ws, macro) => kw + ws + ' '.repeat(macro.length));
441
- }
442
- /**
443
- * Blank a known inline-specifier macro sitting in front of a function's return
444
- * type (`FORCEINLINE FString GetName(…)`), before parsing. Not knowing the
445
- * macro, tree-sitter can't reconcile `MACRO <return-type> <name>(` — an extra
446
- * type-like token before the name — and drops into error recovery: the macro
447
- * becomes the return type and, for a non-primitive return, the return type gets
448
- * glued onto the name (`GetName` → `"FString GetName"`), so the function can't
449
- * be found by name and its callers don't link. This is pervasive in Unreal
450
- * Engine (`FORCEINLINE <ret> <name>(…)`) and in vendored third-party libraries
451
- * that define their own inline macro (pugixml's `PUGI__FN`, Godot's
452
- * `_FORCE_INLINE_`, Boost's `BOOST_FORCEINLINE`, …). Replacing the macro with
453
- * equal-length spaces preserves every byte offset (so line/column stay exact)
454
- * and the declaration then parses as an ordinary function — recovering the real
455
- * name AND the return type — mirroring how `blankCppExportMacros` recovers
456
- * macro-annotated classes (#946/#1061).
457
- *
458
- * Matched tightly so it can't touch an ordinary identifier: only the exact,
459
- * curated inline-specifier tokens below (never an arbitrary all-caps token, so a
460
- * real return type like `HRESULT DoIt()` is untouched), and only in specifier
461
- * position — immediately followed by whitespace and the identifier that starts
462
- * the return type or name. That lookahead leaves value/expression uses
463
- * (`x = FORCEINLINE ? …`), string literals, and longer words
464
- * (`FORCEINLINE_SOMETHINGELSE`, word-boundary) alone. To cover a new codebase's
465
- * inline macro, add its exact token to the list.
466
- */
508
+ if (!/\b(?:class|struct)\s+[A-Z][A-Z0-9_]/.test(source))
509
+ return source;
510
+ const code = maskCppCode(source);
511
+ const spans = [];
512
+ const re = new RegExp(CPP_CLASS_HEAD_MACROS_RE.source, 'g');
513
+ let m;
514
+ while ((m = re.exec(code)) !== null) {
515
+ let i = skipCppSpace(code, m.index + m[0].length);
516
+ if (code[i] === '<') {
517
+ i = skipCppAngleArgs(code, i);
518
+ if (i < 0)
519
+ continue;
520
+ i = skipCppSpace(code, i);
521
+ }
522
+ if (/^final\b/.test(code.slice(i, i + 6)))
523
+ i = skipCppSpace(code, i + 5);
524
+ if (code[i] !== '{' && !(code[i] === ':' && code[i + 1] !== ':'))
525
+ continue;
526
+ const run = m[1];
527
+ const start = m.index + m[0].indexOf(run);
528
+ pushCppRunTokens(spans, run, start);
529
+ }
530
+ return blankCppSpans(source, spans, code);
531
+ }
532
+ const CPP_COMMENT_OR_LITERAL_RE = /\/\/(?:\\\r?\n|[^\r\n])*|\/\*[\s\S]*?(?:\*\/|$)|"(?:\\[\s\S]|[^"\\])*(?:"|$)|(?<!\w)(?:u8|[LuU])?'(?:\\[\s\S]|[^'\\])*(?:'|$)/g;
533
+ function maskCppCommentsAndLiterals(source) {
534
+ return source.replace(CPP_COMMENT_OR_LITERAL_RE, (m) => (m.includes('\n') || m.includes('\r') ? m.replace(/[^\r\n]/g, ' ') : ' '.repeat(m.length)));
535
+ }
536
+ function maskCppCode(source) {
537
+ if (cppMaskMemo !== null && cppMaskMemo.source === source)
538
+ return cppMaskMemo.code;
539
+ const code = source
540
+ .replace(CPP_COMMENT_OR_LITERAL_RE, (m) => m.replace(/[^\r\n]/g, m.startsWith('/') ? ' ' : '\x01'))
541
+ .replace(/^[ \t]*#(?:\\\r?\n|[^\r\n])*/gm, (m) => m.replace(/[^\r\n]/g, ' '));
542
+ cppMaskMemo = { source, code };
543
+ return code;
544
+ }
545
+ let cppMaskMemo = null;
546
+ const CPP_RUN_TOKEN_RE = /[A-Z][A-Z0-9_]*(?:\s*\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\))?/g;
547
+ function pushCppRunTokens(spans, run, start) {
548
+ for (const t of run.matchAll(CPP_RUN_TOKEN_RE))
549
+ spans.push([start + t.index, start + t.index + t[0].length]);
550
+ }
551
+ function blankCppSpans(source, spans, code) {
552
+ if (spans.length === 0)
553
+ return source;
554
+ const ordered = [...spans].sort((a, b) => a[0] - b[0]);
555
+ const blank = (text) => {
556
+ let out = '';
557
+ let at = 0;
558
+ for (const [start, end] of ordered) {
559
+ const from = Math.max(start, at);
560
+ if (from >= end)
561
+ continue;
562
+ const span = text.slice(from, end);
563
+ out += text.slice(at, from) + (span.includes('\n') || span.includes('\r') ? span.replace(/[^\r\n]/g, ' ') : ' '.repeat(span.length));
564
+ at = end;
565
+ }
566
+ return out + text.slice(at);
567
+ };
568
+ const out = blank(source);
569
+ if (code !== undefined)
570
+ cppMaskMemo = { source: out, code: blank(code) };
571
+ return out;
572
+ }
573
+ function skipCppSpace(code, i) {
574
+ while (i < code.length && /\s/.test(code[i]))
575
+ i++;
576
+ return i;
577
+ }
578
+ function skipCppAngleArgs(code, open) {
579
+ let angles = 0;
580
+ let parens = 0;
581
+ const limit = Math.min(code.length, open + 4000);
582
+ for (let i = open; i < limit; i++) {
583
+ const c = code[i];
584
+ if (c === '(')
585
+ parens++;
586
+ else if (c === ')') {
587
+ if (--parens < 0)
588
+ return -1;
589
+ }
590
+ else if (c === ';' || c === '{' || c === '}')
591
+ return -1;
592
+ else if (parens === 0 && c === '<')
593
+ angles++;
594
+ else if (parens === 0 && c === '>' && code[i - 1] !== '-') {
595
+ if (--angles === 0)
596
+ return i + 1;
597
+ }
598
+ }
599
+ return -1;
600
+ }
601
+ const CPP_POINTER_ANNOTATION_RE = /([*&])\s*((?:[A-Z][A-Z0-9]*_[A-Z0-9_]*(?:\s+|(?=\*)))+)(?=\*|::|(?!(?:and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq)\b)[A-Za-z_~])/g;
602
+ function blankCppPointerAnnotationMacros(source) {
603
+ if (!/[*&]\s*[A-Z][A-Z0-9]*_/.test(source))
604
+ return source;
605
+ const code = maskCppCode(source);
606
+ const spans = [];
607
+ const re = new RegExp(CPP_POINTER_ANNOTATION_RE.source, 'g');
608
+ let m;
609
+ while ((m = re.exec(code)) !== null) {
610
+ const run = m[2];
611
+ const start = m.index + m[0].length - run.length;
612
+ if (m[1] === '&' && code[start + run.length] === '*')
613
+ continue;
614
+ if (/(?:[)\]]|\b\d[\w.]*)\s*$/.test(code.slice(Math.max(0, m.index - 40), m.index)))
615
+ continue;
616
+ pushCppRunTokens(spans, run, start);
617
+ }
618
+ return blankCppSpans(source, spans, code);
619
+ }
620
+ const CPP_PAREN_KEYWORDS = new Set([
621
+ 'if', 'while', 'for', 'switch', 'catch', 'return', 'sizeof', 'alignof', 'alignas', 'decltype',
622
+ 'typeid', 'noexcept', 'throw', 'static_assert', 'new', 'delete', 'case', 'requires', 'co_await',
623
+ 'co_yield', 'co_return', 'asm', '__asm__', '__attribute__', '__attribute', '__declspec', '_Pragma',
624
+ 'else', 'do', 'constexpr', 'consteval', 'explicit', 'typeof', '__typeof__', '__typeof', '_Alignof',
625
+ '__alignof__', 'volatile', '__volatile__',
626
+ ]);
627
+ const CPP_TRAILING_ATTR_CANDIDATE_RE = /\)((?:\s*(?:const|volatile|noexcept|override|final|&&|&)(?![\w]))*)\s*(?=[A-Z][A-Z0-9_]{2,}\b)/g;
628
+ const CPP_TRAILING_ATTR_RUN_RE = /(?:[A-Z][A-Z0-9_]{2,}\b(?:\s*\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\))?\s*)+/y;
629
+ const CPP_TRAILING_ATTR_FOLLOW_RE = /(?:\{|;|=(?!=)|:(?!:)|->|(?:override|final|const|noexcept)\b)/y;
630
+ function blankCppTrailingAttributeMacros(source) {
631
+ if (!/\)[\s\w&]*?\b[A-Z][A-Z0-9_]{2,}\b/.test(source))
632
+ return source;
633
+ const code = maskCppCode(source);
634
+ const spans = [];
635
+ const re = new RegExp(CPP_TRAILING_ATTR_CANDIDATE_RE.source, 'g');
636
+ const run = new RegExp(CPP_TRAILING_ATTR_RUN_RE.source, 'y');
637
+ const follow = new RegExp(CPP_TRAILING_ATTR_FOLLOW_RE.source, 'y');
638
+ let m;
639
+ while ((m = re.exec(code)) !== null) {
640
+ const macroStart = m.index + m[0].length;
641
+ if (/\n[ \t]*\r?\n/.test(m[0]))
642
+ continue;
643
+ run.lastIndex = macroStart;
644
+ const r = run.exec(code);
645
+ if (!r)
646
+ continue;
647
+ follow.lastIndex = macroStart + r[0].length;
648
+ if (!follow.test(code))
649
+ continue;
650
+ if (!closesParameterList(code, m.index))
651
+ continue;
652
+ pushCppRunTokens(spans, r[0], macroStart);
653
+ re.lastIndex = macroStart + r[0].length;
654
+ }
655
+ return blankCppSpans(source, spans, code);
656
+ }
657
+ const CPP_TYPE_KEYWORDS = new Set([
658
+ 'void', 'bool', 'char', 'char8_t', 'char16_t', 'char32_t', 'wchar_t', 'short', 'int', 'long', 'float',
659
+ 'double', 'signed', 'unsigned', 'auto',
660
+ ]);
661
+ const CPP_KEYWORDS = new Set([
662
+ ...CPP_TYPE_KEYWORDS, ...CPP_PAREN_KEYWORDS, 'const', 'volatile', 'static', 'extern', 'inline', 'virtual',
663
+ 'explicit', 'constexpr', 'consteval', 'constinit', 'friend', 'mutable', 'thread_local', 'register',
664
+ 'typedef', 'using', 'template', 'typename', 'class', 'struct', 'union', 'enum', 'namespace', 'operator',
665
+ 'goto', 'break', 'continue', 'default', 'public', 'private', 'protected', 'this', 'true', 'false',
666
+ 'nullptr', 'and', 'or', 'not', 'xor', 'bitand', 'bitor', 'compl', 'and_eq', 'or_eq', 'xor_eq', 'not_eq',
667
+ ]);
668
+ const CPP_DECLARATOR_ATTR_CANDIDATE_RE = /(?<![\w$])[A-Z][A-Z0-9]*_[A-Z0-9_]*\b/g;
669
+ const CPP_DECLARATOR_ATTR_RUN_RE = /(?:[A-Z][A-Z0-9]*_[A-Z0-9_]*\b(?:\s*\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\))?\s*)+/y;
670
+ function blankCppDeclaratorAttributeMacros(source) {
671
+ if (!/[\w\]]\s+[A-Z][A-Z0-9]*_[A-Z0-9_]*\s*[(;=,)]/.test(source))
672
+ return source;
673
+ const code = maskCppCode(source);
674
+ const spans = [];
675
+ const re = new RegExp(CPP_DECLARATOR_ATTR_CANDIDATE_RE.source, 'g');
676
+ const run = new RegExp(CPP_DECLARATOR_ATTR_RUN_RE.source, 'y');
677
+ let m;
678
+ while ((m = re.exec(code)) !== null) {
679
+ const macroStart = m.index;
680
+ let last = macroStart - 1;
681
+ while (last >= 0 && /\s/.test(code[last]))
682
+ last--;
683
+ if (last === macroStart - 1 || last < 0 || !/[\w\]]/.test(code[last]))
684
+ continue;
685
+ run.lastIndex = macroStart;
686
+ const r = run.exec(code);
687
+ if (!r || !/^[;,)]|^=(?!=)/.test(code.slice(macroStart + r[0].length, macroStart + r[0].length + 2)))
688
+ continue;
689
+ if (code[last] !== ']' && !followsDeclaredName(code, last))
690
+ continue;
691
+ pushCppRunTokens(spans, r[0], macroStart);
692
+ re.lastIndex = macroStart + r[0].length;
693
+ }
694
+ return blankCppSpans(source, spans, code);
695
+ }
696
+ function followsDeclaredName(code, last) {
697
+ let start = last;
698
+ while (start > 0 && /\w/.test(code[start - 1]))
699
+ start--;
700
+ const name = code.slice(start, last + 1);
701
+ if (!/^[A-Za-z_]\w*$/.test(name) || !/[a-z]/.test(name) || CPP_KEYWORDS.has(name))
702
+ return false;
703
+ let i = start - 1;
704
+ while (i >= 0 && /\s/.test(code[i]))
705
+ i--;
706
+ const c = code[i];
707
+ if (c === '*' || c === '&')
708
+ return true;
709
+ if (c === '>')
710
+ return code[i - 1] !== '-';
711
+ if (!c || !/\w/.test(c))
712
+ return false;
713
+ let j = i;
714
+ while (j > 0 && /\w/.test(code[j - 1]))
715
+ j--;
716
+ const before = code.slice(j, i + 1);
717
+ if (before === 'const' || before === 'volatile') {
718
+ let k = j - 1;
719
+ while (k >= 0 && /\s/.test(code[k]))
720
+ k--;
721
+ return code[k] === '*' || code[k] === '&';
722
+ }
723
+ if (CPP_TYPE_KEYWORDS.has(before))
724
+ return true;
725
+ return /^[A-Za-z_]\w*$/.test(before) && !CPP_KEYWORDS.has(before);
726
+ }
727
+ function closesParameterList(code, close) {
728
+ let depth = 0;
729
+ let open = -1;
730
+ for (let i = close; i >= 0 && close - i < 4000; i--) {
731
+ const c = code[i];
732
+ if (c === ')')
733
+ depth++;
734
+ else if (c === '(') {
735
+ if (--depth === 0) {
736
+ open = i;
737
+ break;
738
+ }
739
+ }
740
+ else if (c === ';' || c === '{' || c === '}')
741
+ return false;
742
+ }
743
+ if (open < 0)
744
+ return false;
745
+ const before = code.slice(Math.max(0, open - 200), open);
746
+ if (/\boperator\s*(?:\(\s*\)|\[\s*\]|[^\s\w()[\]]{1,3}|\s+[A-Za-z_][\w\s:<>*&]*)\s*$/.test(before))
747
+ return true;
748
+ const name = /([A-Za-z_]\w*)\s*$/.exec(before)?.[1];
749
+ return !!name && !CPP_PAREN_KEYWORDS.has(name) && !/^[A-Z][A-Z0-9_]*$/.test(name);
750
+ }
751
+ const CPP_TYPE_ARGS = '<(?:[^<>;{}]|<(?:[^<>;{}]|<[^<>;{}]*>)*>)*>';
752
+ const CPP_TYPE_NAME = `(?:::\\s*)?(?!(?:const|volatile|operator|return)\\b)[A-Za-z_]\\w*(?:\\s*${CPP_TYPE_ARGS})?(?:\\s*::\\s*[A-Za-z_]\\w*(?:\\s*${CPP_TYPE_ARGS})?)*`;
753
+ const CPP_DECLARED_NAME = '(?:(?:::\\s*)?~?[A-Za-z_]\\w*(?:\\s*::\\s*~?[A-Za-z_]\\w*)*\\s*[(;=[{]|operator\\b)';
754
+ const CPP_LEADING_ATTR_RE = new RegExp('(^[ \\t]*|\\]\\][ \\t]*)((?:[A-Z][A-Z0-9]*_[A-Z0-9_]*\\s+)+)(?=' +
755
+ '(?:static|inline|virtual|explicit|constexpr|consteval|constinit|friend|extern|thread_local|mutable|' +
756
+ 'typedef|using|template|typename|class|struct|union|enum|void|bool|char|char8_t|char16_t|char32_t|' +
757
+ 'wchar_t|short|int|long|float|double|signed|unsigned|auto|decltype|return)\\b|\\[\\[|' +
758
+ '(?:[A-Za-z_]\\w*\\s*::\\s*)*([A-Za-z_]\\w*)\\s*::\\s*~?\\3\\s*\\(|' +
759
+ `(?:(?:const|volatile)\\s+)*${CPP_TYPE_NAME}(?:\\s*(?:const|volatile)\\b)?(?:\\s*[*&]+\\s*|\\s+)(?:(?:const|volatile)\\s+)?${CPP_DECLARED_NAME})`, 'gm');
760
+ function blankCppLeadingAttributeMacros(source) {
761
+ if (!/(?:^|\]\])[ \t]*[A-Z][A-Z0-9]*_[A-Z0-9_]*\s/m.test(source))
762
+ return source;
763
+ const code = maskCppCode(source);
764
+ const spans = [];
765
+ const re = new RegExp(CPP_LEADING_ATTR_RE.source, 'gm');
766
+ let m;
767
+ while ((m = re.exec(code)) !== null) {
768
+ const start = m.index + m[1].length;
769
+ pushCppRunTokens(spans, m[2], start);
770
+ }
771
+ return blankCppSpans(source, spans, code);
772
+ }
467
773
  const CPP_INLINE_MACROS = [
468
- // Unreal Engine
469
774
  'FORCEINLINE_DEBUGGABLE', 'FORCENOINLINE', 'FORCEINLINE',
470
- // pugixml (ubiquitous vendored XML parser): `#define PUGI__FN inline` before
471
- // the return type, plus `PUGIXML_FUNCTION` (linkage macro) between the return
472
- // type and the name — the blank mechanism handles both positions.
473
775
  'PUGI__FN_NO_INLINE', 'PUGI__FN', 'PUGIXML_FUNCTION',
474
- // Godot
475
776
  '_ALWAYS_INLINE_', '_FORCE_INLINE_',
476
- // Boost
477
777
  'BOOST_FORCEINLINE', 'BOOST_NOINLINE',
478
- // Qt (per-method markers + inline)
479
778
  'Q_INVOKABLE', 'Q_SCRIPTABLE', 'Q_ALWAYS_INLINE', 'Q_SLOT', 'Q_SIGNAL',
480
- // Folly / Abseil / LLVM / V8 / Eigen / rapidjson
481
779
  'FOLLY_ALWAYS_INLINE', 'FOLLY_NOINLINE',
482
780
  'ABSL_ATTRIBUTE_ALWAYS_INLINE', 'ABSL_ATTRIBUTE_NOINLINE',
483
781
  'LLVM_ATTRIBUTE_ALWAYS_INLINE', 'LLVM_ATTRIBUTE_NOINLINE',
484
782
  'V8_INLINE', 'V8_NOINLINE',
485
783
  'EIGEN_STRONG_INLINE', 'EIGEN_ALWAYS_INLINE', 'EIGEN_DEVICE_FUNC',
486
784
  'RAPIDJSON_FORCEINLINE',
487
- // Mozilla / SpiderMonkey
488
785
  'MOZ_ALWAYS_INLINE', 'MOZ_NEVER_INLINE',
489
- // Protocol Buffers
490
786
  'PROTOBUF_ALWAYS_INLINE', 'PROTOBUF_NOINLINE',
491
- // {fmt} / spdlog
492
787
  'FMT_CONSTEXPR20', 'FMT_CONSTEXPR', 'FMT_INLINE',
493
- // Hedley + nlohmann/json (bundles Hedley)
494
788
  'JSON_HEDLEY_ALWAYS_INLINE', 'JSON_HEDLEY_NEVER_INLINE',
495
789
  'HEDLEY_ALWAYS_INLINE', 'HEDLEY_NEVER_INLINE',
496
- // GLM (graphics math — pervasive in games/rendering)
497
790
  'GLM_FUNC_QUALIFIER', 'GLM_FUNC_DECL', 'GLM_CONSTEXPR', 'GLM_INLINE',
498
- // Bullet Physics / Skia / OpenCV / EASTL / Cocos2d-x / Chromium-WebKit
499
791
  'SIMD_FORCE_INLINE',
500
792
  'SK_ALWAYS_INLINE',
501
793
  'CV_ALWAYS_INLINE', 'CV_INLINE',
502
794
  'EA_FORCE_INLINE', 'EA_NOINLINE',
503
795
  'CC_INLINE',
504
796
  'NEVER_INLINE',
505
- // C libraries: GLib, SQLite (internal linkage)
506
797
  'G_INLINE_FUNC', 'SQLITE_PRIVATE', 'SQLITE_API',
507
- // Windows calling conventions (linkage position — recover the return type; the
508
- // name is salvaged regardless). Only the unambiguous, non-word-like ones.
509
798
  'STDMETHODCALLTYPE', 'WINAPIV', 'WINAPI', 'APIENTRY',
510
- // Common cross-ecosystem inline/attribute hints
511
799
  'ALWAYS_INLINE', 'FORCE_INLINE', 'NOINLINE',
512
800
  ];
513
- // One alternation, longest token first so a longer macro wins over a prefix.
514
801
  const CPP_INLINE_MACRO_RE = new RegExp(`\\b(${[...CPP_INLINE_MACROS].sort((a, b) => b.length - a.length).join('|')})\\b(?=\\s+[A-Za-z_])`, 'g');
515
802
  function blankCppInlineMacros(source) {
516
803
  if (!CPP_INLINE_MACROS.some((m) => source.indexOf(m) !== -1))
517
804
  return source;
518
805
  return source.replace(CPP_INLINE_MACRO_RE, (m) => ' '.repeat(m.length));
519
806
  }
520
- // Bare C/C++ type/qualifier tokens that must never be taken as a recovered
521
- // function name (guards `recoverMangledCppName` against the `Ret (name)` idiom,
522
- // where the token before the params is the return type, not the name).
523
807
  const CPP_PRIMITIVE_NAMES = new Set([
524
808
  'bool', 'void', 'int', 'char', 'short', 'long', 'float', 'double', 'unsigned',
525
809
  'signed', 'wchar_t', 'char8_t', 'char16_t', 'char32_t', 'char_t', 'size_t',
526
810
  'auto', 'const', 'struct', 'class', 'enum', 'union', 'typename',
527
811
  ]);
528
- /**
529
- * Universal fallback (any macro, no list) for a C/C++ function name still mangled
530
- * because a macro we don't blank sat in front of the return type: `MACRO Ret
531
- * name(…)` / `Ret MACRO name(…)` misparse so the return type is glued onto the
532
- * name ("Ret name", "char_t* to_str(double v)"). Recover the real identifier —
533
- * the token immediately before the parameter list (or the last token). This runs
534
- * AFTER the curated pre-parse blank, so it only ever sees the residual tail that
535
- * blanking didn't already fix cleanly (which also recovers the return type).
536
- *
537
- * Safe by construction: only touches an ALREADY-mangled name — one with an
538
- * internal space that isn't a legit `operator …`/destructor — so a well-formed
539
- * name is returned unchanged. Guarded against the two ways it could mis-pick:
540
- * the `Ret (name)` parenthesized-name idiom (left as-is, ambiguous), and a token
541
- * that is a bare primitive/keyword rather than a real identifier.
542
- */
543
812
  function recoverMangledCppName(name) {
544
813
  if (!/\s/.test(name) || name.startsWith('operator') || name.startsWith('~'))
545
814
  return name;
546
815
  if (/^\S+\s+\([A-Za-z_]\w*\)/.test(name))
547
- return name; // `Ret (name)` idiom — leave alone
816
+ return name;
548
817
  const beforeParams = name.includes('(') ? name.slice(0, name.indexOf('(')) : name;
549
818
  const tokens = beforeParams.trim().split(/\s+/);
550
819
  const candidate = tokens[tokens.length - 1];
@@ -552,48 +821,16 @@ function recoverMangledCppName(name) {
552
821
  return name;
553
822
  return candidate;
554
823
  }
555
- /**
556
- * Blank Metal Shading Language `[[attribute]]` annotations before parsing.
557
- * MSL (≈ C++14) puts attributes AFTER the declarator — `float4 position
558
- * [[position]];`, `constant Uniforms &u [[buffer(0)]]` — a position
559
- * tree-sitter-cpp can't reconcile: a struct field with a trailing attribute
560
- * misparses into a shape that emits a spurious `extends` reference from the
561
- * struct to the field's *type* (`VertexIn extends float3`), which becomes a
562
- * wrong inheritance edge whenever the repo defines that type itself (simd
563
- * typedefs in a shared ShaderTypes.h are common). Replacing the attribute with
564
- * equal-length spaces preserves every byte offset and lets fields and
565
- * parameters parse as ordinary declarations, mirroring the macro blanks above.
566
- *
567
- * Matched tightly to the attribute shape — `[[ident]]`, `[[ident(args)]]`, and
568
- * comma-separated lists (`[[buffer(0), raster_order_group(0)]]`) — so a
569
- * subscripted lambda call (`arr[[]{ … }()]`, the only other way `[[` appears in
570
- * C++-family source) can never match: after `[[` a lambda continues with `]`,
571
- * never an identifier followed by `]]`. Applied ONLY to `.metal` files — in
572
- * regular C++ the pre-declarator attribute position (`[[nodiscard]] int f()`)
573
- * is legal syntax the grammar parses natively, and blanking it would be pure
574
- * blast radius. (#1121)
575
- */
576
824
  const METAL_ATTRIBUTE_RE = /\[\[\s*[A-Za-z_]\w*(?:\s*\([^()\n]*\))?(?:\s*,\s*[A-Za-z_]\w*(?:\s*\([^()\n]*\))?)*\s*\]\]/g;
577
825
  function blankMetalAttributes(source) {
578
826
  if (source.indexOf('[[') === -1)
579
827
  return source;
580
828
  return source.replace(METAL_ATTRIBUTE_RE, (m) => ' '.repeat(m.length));
581
829
  }
582
- /**
583
- * Hide C++ raw literals from the offset-preserving preParse scans (#1505).
584
- * Neither macro-shaped text in a raw body nor its `)delim"` closer is code.
585
- * Mask the whole literal with non-whitespace, non-paren tokens, keeping line
586
- * endings, so even line-based scanners treat a multiline raw argument as opaque.
587
- * Restore untouched bytes afterward; a real enclosing annotation can still be
588
- * removed in full. The pipeline masks once, and individual paren blankers also
589
- * use this helper so they are safe when called directly.
590
- */
591
830
  function maskCppRawStrings(source) {
592
831
  const unchanged = { source, restore: (blanked) => blanked };
593
832
  if (source.indexOf('R"') === -1)
594
833
  return unchanged;
595
- // Skip comments and ordinary literals before looking for a raw opener. The
596
- // char-literal boundary leaves numeric digit separators (1'000) alone.
597
834
  const re = /\/\/[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$)|\b(?:u8|[LuU])?R"([^ \t\v\f\r\n()\\]{0,16})\(|"(?:\\[\s\S]|[^"\\])*(?:"|$)|(?<!\w)(?:u8|[LuU])?'(?:\\[\s\S]|[^'\\])*(?:'|$)/g;
598
835
  const spans = [];
599
836
  const parts = [];
@@ -604,7 +841,6 @@ function maskCppRawStrings(source) {
604
841
  continue;
605
842
  const closer = `)${m[1]}"`;
606
843
  const close = source.indexOf(closer, re.lastIndex);
607
- // An unterminated raw literal owns the rest of the file too.
608
844
  const end = close < 0 ? source.length : close + closer.length;
609
845
  spans.push({ start: m.index, end });
610
846
  parts.push(source.slice(last, m.index), source.slice(m.index, end).replace(/[^\r\n]/g, '\0'));
@@ -617,7 +853,6 @@ function maskCppRawStrings(source) {
617
853
  return {
618
854
  source: masked,
619
855
  restore(blanked) {
620
- // A length-changing rewrite cannot be restored at the original offsets.
621
856
  if (blanked === masked || blanked.length !== source.length)
622
857
  return source;
623
858
  const chars = blanked.split('');
@@ -631,54 +866,18 @@ function maskCppRawStrings(source) {
631
866
  },
632
867
  };
633
868
  }
634
- /**
635
- * Blank annotation-style macro invocations that decorate a declaration but carry
636
- * NO terminating semicolon — the pervasive Unreal-Engine reflection markup
637
- * (`UPROPERTY(...)`, `UFUNCTION(...)`, `UCLASS(...)`, `GENERATED_BODY()`,
638
- * `UE_DEPRECATED_FORGAME(...)`, `DECLARE_DELEGATE_*(...)`, …) that sits on its
639
- * own line right before a member/type. tree-sitter's C++ grammar doesn't know
640
- * these are macros, so each one drops into error recovery; in a big reflected
641
- * class (`CharacterMovementComponent.h` has ~240 of them) the errors accumulate
642
- * until the enclosing `class_specifier` can't close and collapses into an ERROR
643
- * node — the whole class definition, its members, and its `extends` edges vanish
644
- * from the graph. Neither `blankCppExportMacros` (class-header export macros) nor
645
- * `blankCppInlineMacros` (return-type inline specifiers) touches these in-body
646
- * markup macros. Replacing each with equal-length spaces preserves every byte
647
- * offset (so line/column stay exact) and the class then parses normally.
648
- *
649
- * Deliberately name-list-FREE — UE alone has hundreds of such macros and projects
650
- * add their own — so it keys on structure, not a curated list, matched tightly to
651
- * avoid touching legitimate C++:
652
- * - the macro must be the FIRST non-whitespace token on its line (`^[ \t]*`),
653
- * which is where declaration markup lives — so a macro used inside an
654
- * expression or condition (`if (CHECK(x))`, `x = MACRO(a) + b`) is never
655
- * matched (it isn't line-leading);
656
- * - the name must be ALL-CAPS (`[A-Z][A-Z0-9_]{2,}`), since ordinary
657
- * function/type names called at line start are lower/mixed case;
658
- * - the char after the balanced `(...)` must START A DECLARATION — a letter,
659
- * `_`, `~` (destructor), or `#` (a following directive). Declaration markup is
660
- * always followed by the thing it decorates (`UPROPERTY(...)\n float X;`,
661
- * `UE_DEPRECATED(...) UPROPERTY(...)`), whereas a statement call is followed by
662
- * `;` (`FOO(x);`), an init-list item by `,`/`{`, and an expression fragment by
663
- * an operator (`MAKE(a) + 1`) — all rejected. String/char literals inside the
664
- * args are skipped so an embedded `)` can't mis-close the balance.
665
- *
666
- * C++-only (wired into cppExtractor). A blanked macro inside a block comment is
667
- * harmless (comments don't parse), and the rare line-leading no-semicolon
668
- * ALL-CAPS call that isn't markup only loses that one annotation, never a whole
669
- * class.
670
- */
671
- function blankCppAnnotationMacroCalls(source) {
869
+ function blankCppAnnotationMacroCalls(source, options = {}) {
672
870
  if (!/^[ \t]*[A-Z][A-Z0-9_]{2,}\s*\(/m.test(source))
673
871
  return source;
674
872
  const rawStrings = maskCppRawStrings(source);
675
873
  source = rawStrings.source;
676
- const chars = source.split('');
874
+ let chars = null;
677
875
  const re = /^([ \t]*)([A-Z][A-Z0-9_]{2,})(\s*)\(/gm;
678
876
  let m;
679
877
  while ((m = re.exec(source)) !== null) {
680
- const macroStart = m.index + (m[1] ?? '').length; // skip leading indent
681
- let i = m.index + m[0].length - 1; // index of the opening '('
878
+ const macroStart = m.index + (m[1] ?? '').length;
879
+ const open = m.index + m[0].length - 1;
880
+ let i = open;
682
881
  let depth = 0;
683
882
  let end = -1;
684
883
  for (; i < source.length; i++) {
@@ -709,47 +908,59 @@ function blankCppAnnotationMacroCalls(source) {
709
908
  while (j < source.length && /\s/.test(source[j]))
710
909
  j++;
711
910
  const after = source[j];
712
- // Only markup is followed by the declaration it decorates; a statement call
713
- // (`;`), init-list item (`,`/`{`), or expression fragment (operator) is not.
714
911
  if (!after || !/[A-Za-z_~#]/.test(after))
715
912
  continue;
913
+ if (options.keepCReturnTypes && macroStart === m.index && isCReturnTypeMacro(source, m.index, open, end, j))
914
+ continue;
915
+ chars ??= source.split('');
716
916
  for (let k = macroStart; k < end; k++) {
717
917
  if (chars[k] !== '\n' && chars[k] !== '\r')
718
918
  chars[k] = ' ';
719
919
  }
720
920
  re.lastIndex = end;
721
921
  }
722
- return rawStrings.restore(chars.join(''));
723
- }
724
- /**
725
- * Blank a macro that is the ONLY token on its line — no parens, no semicolon:
726
- * namespace-management macros (`FMT_BEGIN_NAMESPACE`, `FMT_END_EXPORT`,
727
- * `JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS`), Qt's `Q_OBJECT`, and friends. A
728
- * bare identifier is not a statement or declaration in C or C++, so
729
- * tree-sitter drops into error recovery at every one — and since the kernel
730
- * path defers ANY erroring file to wasm, this single idiom deferred 13/73 fmt
731
- * files and a comparable share of jemalloc, forfeiting the native-parse win
732
- * on exactly the header-heavy trees it targets (the wasm path also mis-nests
733
- * scopes around them today). Replacing the token with equal-length spaces
734
- * preserves every byte offset and the surrounding declarations parse clean.
735
- *
736
- * Matched tightly so a real identifier can never be touched — ALL of:
737
- * - the line consists of ONE ALL-CAPS token (≥4 chars, with `_`), optionally
738
- * followed by a same-line comment — a lone lowercase identifier or any
739
- * second token disqualifies;
740
- * - the PREVIOUS non-blank line does not end in a continuation character
741
- * (`=`, an operator, `,`, `(`, `?`, `:`, or a `\` macro-definition
742
- * continuation) — so an ALL-CAPS operand split onto its own line inside a
743
- * multi-line expression (`int x =\n SOME_CONST\n | OTHER;`) is left
744
- * alone; and
745
- * - the NEXT non-blank line starts like a declaration/scope token
746
- * (letter, `_`, `#`, `{`, `}`, or `~`) or the file ends — an operator,
747
- * string literal, or `;` continuation rejects the match.
748
- * Shared by C and C++ (the idiom is identical in both).
749
- */
922
+ return rawStrings.restore(chars ? chars.join('') : source);
923
+ }
924
+ const C_RETURN_TYPE_ARG_RE = /^\s*[A-Za-z_][\w\s*]*$/;
925
+ const C_DECLARATOR_HEAD_RE = /[A-Za-z_]\w*\s*\(/y;
926
+ const C_DECLARATOR_TAIL_RE = /\s*(?:(?:__attribute__\s*\(\((?:[^()]|\([^()]*\))*\)\)|[A-Z][A-Z0-9_]*(?![\w$])(?:\s*\((?:[^()]|\([^()]*\))*\))?)\s*)*[{;]/y;
927
+ function isCReturnTypeMacro(source, lineStart, open, end, next) {
928
+ if (!C_RETURN_TYPE_ARG_RE.test(source.slice(open + 1, end - 1)))
929
+ return false;
930
+ C_DECLARATOR_HEAD_RE.lastIndex = next;
931
+ const head = C_DECLARATOR_HEAD_RE.exec(source);
932
+ if (!head)
933
+ return false;
934
+ let close = -1;
935
+ let depth = 0;
936
+ for (let i = next + head[0].length - 1; i < source.length && close < 0; i++) {
937
+ const c = source[i];
938
+ if (c === '(')
939
+ depth++;
940
+ else if (c === ')') {
941
+ if (--depth === 0)
942
+ close = i;
943
+ }
944
+ else if (c === ';' || c === '{' || c === '}')
945
+ return false;
946
+ }
947
+ if (close < 0)
948
+ return false;
949
+ C_DECLARATOR_TAIL_RE.lastIndex = close + 1;
950
+ return C_DECLARATOR_TAIL_RE.test(source) && !opensCDeclaration(source, lineStart);
951
+ }
952
+ function opensCDeclaration(source, lineStart) {
953
+ if (lineStart === 0)
954
+ return false;
955
+ const from = source.lastIndexOf('\n', lineStart - 2) + 1;
956
+ const line = source.slice(from, lineStart - 1).replace(/\/\/.*$/, '').trim();
957
+ return line !== '' && !line.startsWith('#') && /[\w*]$/.test(line);
958
+ }
750
959
  const LONE_MACRO_LINE_RE = /^[ \t]*([A-Z][A-Z0-9_]{3,})[ \t]*(?:\/\/[^\n\r]*|\/\*[^\n\r]*\*\/[ \t]*)?\r?$/;
751
960
  const LONE_MACRO_CONTINUATION_END_RE = /[=+\-*/%&|^<>?:,(\\]$/;
752
- function blankLoneMacroLines(source) {
961
+ const C_LONE_MACROS = { nextCode: /[A-Za-z_#{}~]/, keepsSoleStatement: false };
962
+ exports.OBJC_LONE_MACROS = { nextCode: /[A-Za-z_#{}~@]/, keepsSoleStatement: true };
963
+ function blankLoneMacroLines(source, rules = C_LONE_MACROS) {
753
964
  if (!/^[ \t]*[A-Z][A-Z0-9_]{3,}[ \t]*\r?$/m.test(source))
754
965
  return source;
755
966
  const lines = source.split('\n');
@@ -760,23 +971,21 @@ function blankLoneMacroLines(source) {
760
971
  const m = LONE_MACRO_LINE_RE.exec(line);
761
972
  if (!m)
762
973
  continue;
763
- // Underscore requirement rides the macro convention (FMT_BEGIN_NAMESPACE,
764
- // Q_OBJECT); a solid all-caps word (`NDEBUG`-style) alone is too risky.
765
974
  if (!m[1].includes('_'))
766
975
  continue;
767
976
  let prev = i - 1;
768
977
  while (prev >= 0 && content(lines[prev]) === '')
769
978
  prev--;
770
- if (prev >= 0 && LONE_MACRO_CONTINUATION_END_RE.test(content(lines[prev])))
979
+ const prevText = prev >= 0 ? content(lines[prev]) : '';
980
+ const prevCode = /^(?:\/\/|\/\*|\*)/.test(prevText) ? '' : prevText.replace(/\/\*.*?\*\/|\/\/.*$/g, '').trim();
981
+ const directiveEnds = prevCode.startsWith('#') && !prevCode.endsWith('\\');
982
+ if (prevCode !== '' && !directiveEnds && !/^template\s*</.test(prevCode) && LONE_MACRO_CONTINUATION_END_RE.test(prevCode))
983
+ continue;
984
+ const first = firstCodeCharAfter(lines, i + 1);
985
+ if (first !== undefined && !rules.nextCode.test(first))
986
+ continue;
987
+ if (rules.keepsSoleStatement && prevCode.endsWith('{') && first === '}')
771
988
  continue;
772
- let next = i + 1;
773
- while (next < lines.length && content(lines[next]) === '')
774
- next++;
775
- if (next < lines.length) {
776
- const first = content(lines[next])[0];
777
- if (!first || !/[A-Za-z_#{}~]/.test(first))
778
- continue;
779
- }
780
989
  const start = line.indexOf(m[1]);
781
990
  lines[i] =
782
991
  line.slice(0, start) + ' '.repeat(m[1].length) + line.slice(start + m[1].length);
@@ -784,68 +993,51 @@ function blankLoneMacroLines(source) {
784
993
  }
785
994
  return changed ? lines.join('\n') : source;
786
995
  }
787
- /**
788
- * Blank an export/visibility macro sitting in front of a *member* or *method*
789
- * declaration inside a class/namespace (`ENGINE_API virtual void Tick(…)`,
790
- * `static ENGINE_API void AddReferencedObjects(…)`, `UE_API FVector GetVel()
791
- * const`), before parsing. `blankCppExportMacros` only recovers the macro in a
792
- * `class MACRO Name` *header*; the very same macro also prefixes almost every
793
- * exported member of a big Unreal-Engine class, and tree-sitter — not knowing
794
- * it's a macro — reads `MACRO <return-type> <name>(` as an extra type token and
795
- * drops each such declaration into error recovery. In a heavily-exported header
796
- * (`Actor.h`, `World.h`, …) hundreds of these accumulate: the return types pile
797
- * up as orphan ERROR tokens and, combined with other markup, can still tip the
798
- * enclosing class into collapse. Replacing the macro with equal-length spaces
799
- * preserves every byte offset (line/column stay exact) and each member parses
800
- * as an ordinary declaration.
801
- *
802
- * Matched tightly so it can't touch the same token used as a value
803
- * (`int x = SOME_API;`, `if (mode == FOO_API)`): the token must be ALL-CAPS AND
804
- * end in the conventional visibility-macro suffix `_API` / `_EXPORT` / `_ABI`
805
- * (Unreal `*_API`, Qt/Boost `*_EXPORT`, LLVM `*_ABI`) — ordinary identifiers
806
- * effectively never carry these suffixes — and must be immediately followed by
807
- * whitespace then a declaration token (`\s+[A-Za-z_]`: a type, `virtual`,
808
- * `static`, or the name). A value use is instead followed by `;`, `)`, `,`,
809
- * `=`, `::`, or an operator, all of which fail the look-ahead. C++-only (wired
810
- * into cppExtractor).
811
- */
996
+ function firstCodeCharAfter(lines, from) {
997
+ let inBlock = false;
998
+ for (let k = from; k < lines.length; k++) {
999
+ let text = lines[k].trim();
1000
+ for (;;) {
1001
+ if (inBlock) {
1002
+ const end = text.indexOf('*/');
1003
+ if (end < 0) {
1004
+ text = '';
1005
+ break;
1006
+ }
1007
+ text = text.slice(end + 2).trim();
1008
+ inBlock = false;
1009
+ }
1010
+ if (text.startsWith('//'))
1011
+ text = '';
1012
+ else if (text.startsWith('/*')) {
1013
+ inBlock = true;
1014
+ text = text.slice(2);
1015
+ continue;
1016
+ }
1017
+ break;
1018
+ }
1019
+ if (text !== '')
1020
+ return text[0];
1021
+ }
1022
+ return undefined;
1023
+ }
812
1024
  const CPP_API_PREFIX_RE = /\b[A-Z][A-Z0-9_]*(?:_API|_EXPORT|_ABI)\b(?=\s+[A-Za-z_])/g;
813
1025
  function blankCppApiPrefixMacros(source) {
814
1026
  if (!/_(?:API|EXPORT|ABI)\b/.test(source))
815
1027
  return source;
816
1028
  return source.replace(CPP_API_PREFIX_RE, (m) => ' '.repeat(m.length));
817
1029
  }
818
- /**
819
- * Blank an Unreal-Engine annotation macro that appears MID-LINE (not
820
- * line-leading, so `blankCppAnnotationMacroCalls` never sees it) inside a
821
- * declaration: an enum value's `UMETA(DisplayName="…")`, a parameter's
822
- * `UPARAM(ref)`, or a deprecation tag wedged into a `using`/member declaration
823
- * (`using FOnNetTick UE_DEPRECATED(5.5, "…") = TMulticastDelegate<void(float)>;`
824
- * in `World.h`, which otherwise collapses `UWorld`). tree-sitter can't reconcile
825
- * these embedded macro calls and drops into error recovery, and a mid-line one
826
- * inside a big enum or a class-scope `using` can cascade into the whole enum /
827
- * class being lost. Replacing the entire `MACRO(...)` (balanced parens, string
828
- * literals skipped so an embedded `)` can't mis-close) with equal-length spaces
829
- * preserves every byte offset and the declaration parses normally.
830
- *
831
- * Keyed on an explicit UE-only name list (`UMETA`, `UPARAM`, and the
832
- * `UE_DEPRECATED*` family) — these identifiers are exclusive to Unreal's
833
- * reflection layer and appear in no standard-C++ or other-library code, so
834
- * blanking them is zero-risk to non-UE sources. (The line-LEADING forms of
835
- * `UE_DEPRECATED(...)` are already handled by `blankCppAnnotationMacroCalls`;
836
- * this covers the mid-line forms it structurally can't.) C++-only.
837
- */
838
1030
  const CPP_INLINE_ANNOTATION_RE = /\b(?:UMETA|UPARAM|UE_DEPRECATED\w*)\s*\(/g;
839
1031
  function blankCppInlineAnnotationMacros(source) {
840
1032
  if (!/\b(?:UMETA|UPARAM|UE_DEPRECATED)/.test(source))
841
1033
  return source;
842
1034
  const rawStrings = maskCppRawStrings(source);
843
1035
  source = rawStrings.source;
844
- const chars = source.split('');
1036
+ let chars = null;
845
1037
  const re = new RegExp(CPP_INLINE_ANNOTATION_RE.source, 'g');
846
1038
  let m;
847
1039
  while ((m = re.exec(source)) !== null) {
848
- let i = m.index + m[0].length - 1; // index of the opening '('
1040
+ let i = m.index + m[0].length - 1;
849
1041
  let depth = 0;
850
1042
  let end = -1;
851
1043
  for (; i < source.length; i++) {
@@ -872,59 +1064,17 @@ function blankCppInlineAnnotationMacros(source) {
872
1064
  }
873
1065
  if (end < 0)
874
1066
  continue;
1067
+ chars ??= source.split('');
875
1068
  for (let k = m.index; k < end; k++) {
876
1069
  if (chars[k] !== '\n' && chars[k] !== '\r')
877
1070
  chars[k] = ' ';
878
1071
  }
879
1072
  re.lastIndex = end;
880
1073
  }
881
- return rawStrings.restore(chars.join(''));
882
- }
883
- /**
884
- * Blank CUDA-specific constructs before parsing `.cu`/`.cuh` files (parsed with
885
- * the C++ grammar). Three shapes tree-sitter-cpp can't reconcile, each replaced
886
- * with equal-length whitespace so every byte offset survives (#387):
887
- *
888
- * 1. Execution-space / storage specifiers: in `__global__ void step(…)` or
889
- * `__shared__ float tile[256]` the specifier parses as the declaration's
890
- * TYPE and shunts the real return/value type into an ERROR node — mangling
891
- * signatures and, for `__shared__` arrays, the declared name itself. Blanked
892
- * unconditionally (no following-token lookahead) so extended lambdas
893
- * (`[=] __device__ (int i) { … }`) recover too. `__restrict__` is deliberately
894
- * absent: the grammar already parses it natively as a type_qualifier.
895
- * 2. `__launch_bounds__(…)` between specifier and declarator — same misparse.
896
- * The parenthesized form is blanked first; a bare leftover token is caught
897
- * by the specifier list.
898
- * 3. Kernel-launch configs `step<<<grid, block, smem, stream>>>(args)`: the
899
- * chevrons lex as shift operators around an empty-named template, so no
900
- * call_expression exists and the host→kernel call edge — the main reason to
901
- * index CUDA at all — is lost. Blanking the `<<<…>>>` span leaves
902
- * `step (args)`, a plain call the grammar
903
- * parses natively (templated launches `k<T, 256><<<…>>>(…)` included).
904
- *
905
- * The launch-config match is deliberately bounded — statement/brace characters
906
- * excluded, span capped, newlines preserved by the replacer — so a stray `<<<`
907
- * (a committed merge-conflict marker, a string literal) can never blank a run
908
- * of real code: an unmatched launch degrades to the status quo for that call
909
- * site (no call edge), never to corruption. Applied to `.cu`/`.cuh` files and —
910
- * because much real CUDA lives in extension-less headers (cutlass launches the
911
- * majority of its kernels from `.h`; flash-attention's launch templates are
912
- * `.h`; llm.c keeps device helpers in C-detected `.h`) — to any C/C++-family
913
- * file whose CONTENT carries a strong CUDA marker (`looksLikeCudaSource`).
914
- * Unlike Metal's `[[attribute]]` (legal C++ syntax elsewhere, hence Metal's
915
- * strict extension gate), no CUDA marker is valid C++ anywhere: `<<<` isn't
916
- * legal syntax and the dunder specifiers are implementation-reserved names no
917
- * real codebase defines — so a content-triggered blank on a non-CUDA file can
918
- * only ever whitespace tokens inside comments or strings, which parse the same.
919
- */
1074
+ return rawStrings.restore(chars ? chars.join('') : source);
1075
+ }
920
1076
  const CUDA_LAUNCH_BOUNDS_RE = /\b__launch_bounds__\s*\([^()\n]*\)/g;
921
1077
  const CUDA_SPECIFIER_RE = /\b__(?:global|device|host|constant|shared|managed|grid_constant|forceinline|noinline|launch_bounds)__\b/g;
922
- // `;` stays excluded (launch configs are expressions; a stray `<<<` spanning
923
- // real statements always crosses one) and the span is capped. Braces are
924
- // allowed through the regex — `k<<<dim3{1,1,1}, dim3{256,1,1}>>>(…)` is a real
925
- // launch shape — but the replacer only blanks a BALANCED match: a merge
926
- // conflict's `<<<<<<< … >>>>>>>` region that dodges every `;` still opens
927
- // braces it never closes, so it fails the balance check and stays untouched.
928
1078
  const CUDA_LAUNCH_CONFIG_RE = /<<<[^;]{0,400}?>>>/g;
929
1079
  function blankCudaConstructs(source) {
930
1080
  let out = source;
@@ -938,9 +1088,9 @@ function blankCudaConstructs(source) {
938
1088
  let depth = 0;
939
1089
  for (let i = 0; i < m.length; i++) {
940
1090
  const ch = m.charCodeAt(i);
941
- if (ch === 0x7b /* { */)
1091
+ if (ch === 0x7b)
942
1092
  depth++;
943
- else if (ch === 0x7d /* } */ && --depth < 0)
1093
+ else if (ch === 0x7d && --depth < 0)
944
1094
  return m;
945
1095
  }
946
1096
  return depth === 0 ? m.replace(/[^\n]/g, ' ') : m;
@@ -948,30 +1098,12 @@ function blankCudaConstructs(source) {
948
1098
  }
949
1099
  return out;
950
1100
  }
951
- /** Strong content markers for CUDA source in files without a CUDA extension
952
- * (headers). The dunders are execution-space specifiers that only nvcc defines;
953
- * `cudaStream_t` is the runtime's stream handle, pervasive in launcher headers
954
- * that themselves declare no kernel. Deliberately excludes weak markers (`dim3`,
955
- * `<<<`) that could plausibly appear in non-CUDA text. */
956
1101
  function looksLikeCudaSource(source) {
957
1102
  return (source.indexOf('__global__') !== -1 ||
958
1103
  source.indexOf('__device__') !== -1 ||
959
1104
  source.indexOf('__constant__') !== -1 ||
960
1105
  source.indexOf('cudaStream_t') !== -1);
961
1106
  }
962
- /**
963
- * Restore preprocessor-directive lines to their original bytes after the
964
- * blanking passes ran. The token-level blanks match on shape, not context, so
965
- * a macro name that happens to sit inside a DIRECTIVE gets blanked too — and
966
- * blanking the name position of `#define FMT_API FMT_VISIBILITY("default")`
967
- * leaves a nameless `# define FMT_VISIBILITY(…)`, which is a parse
968
- * ERROR (fmt's base.h carries several). Inside a directive the blanks were
969
- * never useful anyway: tree-sitter stores `#define` bodies as raw
970
- * preproc_arg text it doesn't parse, so blanking there can only ever break
971
- * the directive itself. Copying the original directive lines back (including
972
- * `\`-continuation lines of multi-line defines) is offset-preserving by
973
- * construction and strictly reduces parse errors on both extraction arms.
974
- */
975
1107
  function restoreDirectiveLines(original, blanked) {
976
1108
  if (blanked === original || original.indexOf('#') === -1)
977
1109
  return blanked;
@@ -990,14 +1122,10 @@ function restoreDirectiveLines(original, blanked) {
990
1122
  }
991
1123
  return changed ? b.join('\n') : blanked;
992
1124
  }
993
- /** Recover MSVC's COM alias only at type-definition sites. Match on a lexical
994
- * mask so comments, literals and directives cannot supply declaration evidence;
995
- * replace just the keyword, preserving source offsets on both parser arms. */
996
1125
  function normalizeCppComInterfaces(source) {
997
1126
  if (!source.includes('interface'))
998
1127
  return source;
999
- // Raw strings have already been masked by preParseCppSource.
1000
- let code = source.replace(/\/\/(?:\\\r?\n|[^\r\n])*|\/\*[\s\S]*?(?:\*\/|$)|"(?:\\[\s\S]|[^"\\])*(?:"|$)|(?<!\w)(?:u8|[LuU])?'(?:\\[\s\S]|[^'\\])*(?:'|$)/g, (m) => m.replace(/[^\r\n]/g, ' '));
1128
+ let code = maskCppCommentsAndLiterals(source);
1001
1129
  const hasAlias = /^[ \t]*#[ \t]*define[ \t]+interface[ \t]+struct\b/m.test(code);
1002
1130
  code = code.replace(/^[ \t]*#(?:\\\r?\n|[^\r\n])*/gm, (m) => m.replace(/[^\r\n]/g, '\0'));
1003
1131
  const declaration = /(^|[;{}])\s*\binterface\s+[A-Za-z_]\w*\s*(:[^;{}]+)?\{/gm;
@@ -1009,27 +1137,131 @@ function normalizeCppComInterfaces(source) {
1009
1137
  if (!hasAlias && !match[2] && !hasVirtual)
1010
1138
  continue;
1011
1139
  offsets.push(match.index + match[0].indexOf('interface'));
1012
- declaration.lastIndex--; // allow the opening brace to start a nested declaration
1140
+ declaration.lastIndex--;
1013
1141
  }
1014
1142
  for (const offset of offsets) {
1015
1143
  source = source.slice(0, offset) + 'struct ' + source.slice(offset + 9);
1016
1144
  }
1017
1145
  return source;
1018
1146
  }
1019
- /** C/C++ source pre-processing before tree-sitter: recover macro-annotated class
1020
- * definitions, macro-prefixed function definitions, macro-prefixed members, and
1021
- * macro-decorated members (Unreal-Engine reflection markup) — plus the non-C++
1022
- * surface of the dialects parsed with the C++ grammar: `.metal` MSL attribute
1023
- * annotations, and CUDA specifiers + launch syntax (by `.cu`/`.cuh` extension
1024
- * or by content, for CUDA living in `.h`/`.hpp` headers). Offset-preserving;
1025
- * directive lines are restored at the end (see restoreDirectiveLines). */
1147
+ const ACCESS_MACRO_LINE = /^([ \t]*)([A-Z][A-Z0-9]*_[A-Z0-9_]*)([ \t]*):(?!:)(?=[ \t]*(?:\/\/[^\n]*)?\r?$)/gm;
1148
+ function rewriteCppAccessMacros(source) {
1149
+ if (!/_[A-Z0-9_]*[ \t]*:(?!:)/.test(source))
1150
+ return source;
1151
+ return source.replace(ACCESS_MACRO_LINE, (m, indent, name, gap) => {
1152
+ const keyword = /PRIVATE/.test(name) ? 'private' : /PROTECTED/.test(name) ? 'protected'
1153
+ : /PUBLIC|^Q_SIGNALS$|^Q_SLOTS$/.test(name) ? 'public' : null;
1154
+ if (!keyword || keyword.length > name.length + gap.length)
1155
+ return m;
1156
+ return `${indent}${keyword}${' '.repeat(name.length + gap.length - keyword.length)}:`;
1157
+ });
1158
+ }
1159
+ function flattenMidStatementConditionals(source) {
1160
+ if (!source.includes('#'))
1161
+ return source;
1162
+ const lines = source.split('\n');
1163
+ const directive = (i) => /^[ \t]*#[ \t]*(\w+)/.exec(lines[i] ?? '')?.[1] ?? null;
1164
+ const code = (i) => (lines[i] ?? '').replace(/\/\/.*$/, '').replace(/\/\*.*?\*\//g, '').trim();
1165
+ let changed = false;
1166
+ const blank = (i) => {
1167
+ lines[i] = (lines[i] ?? '').replace(/[^\r]/g, ' ');
1168
+ changed = true;
1169
+ };
1170
+ let lastCode = '';
1171
+ let inBlockComment = false;
1172
+ let region = 0;
1173
+ let skipFrom = 0;
1174
+ let continued = false;
1175
+ for (let i = 0; i < lines.length; i++) {
1176
+ if (continued) {
1177
+ continued = /\\\s*$/.test(lines[i] ?? '');
1178
+ continue;
1179
+ }
1180
+ const d = directive(i);
1181
+ if (d !== null && !inBlockComment) {
1182
+ if (/\\\s*$/.test(lines[i])) {
1183
+ continued = true;
1184
+ if (region === 0)
1185
+ continue;
1186
+ }
1187
+ const opens = /^if/.test(d);
1188
+ if (region === 0) {
1189
+ const mid = opens && lastCode !== '' && !/[;{}]$|^[\w\s]*:$|\*\/$/.test(lastCode) &&
1190
+ !/^(?:public|private|protected)\s*:$/.test(lastCode) && !/^[A-Z][A-Z0-9_]*(?:\s*\(.*\))?$/.test(lastCode);
1191
+ if (!mid)
1192
+ continue;
1193
+ region = 1;
1194
+ blank(i);
1195
+ continue;
1196
+ }
1197
+ if (opens)
1198
+ region++;
1199
+ else if ((d === 'else' || d === 'elif') && skipFrom === 0)
1200
+ skipFrom = region;
1201
+ else if (d === 'endif') {
1202
+ if (skipFrom === region)
1203
+ skipFrom = 0;
1204
+ region--;
1205
+ }
1206
+ if (/^(?:if|ifdef|ifndef|else|elif|elifdef|elifndef|endif)$/.test(d))
1207
+ blank(i);
1208
+ continue;
1209
+ }
1210
+ const text = lines[i] ?? '';
1211
+ if (region > 0 && skipFrom > 0) {
1212
+ if (text.trim() !== '')
1213
+ blank(i);
1214
+ continue;
1215
+ }
1216
+ const trimmed = code(i);
1217
+ if (inBlockComment) {
1218
+ if (text.includes('*/'))
1219
+ inBlockComment = false;
1220
+ continue;
1221
+ }
1222
+ if (/\/\*(?!.*\*\/)/.test(text.replace(/\/\/.*$/, ''))) {
1223
+ inBlockComment = true;
1224
+ const before = trimmed.split('/*')[0].trim();
1225
+ if (before !== '')
1226
+ lastCode = before;
1227
+ continue;
1228
+ }
1229
+ if (trimmed !== '')
1230
+ lastCode = trimmed;
1231
+ }
1232
+ return changed ? lines.join('\n') : source;
1233
+ }
1234
+ const FOUNDATION_ENUM_MACRO_RE = /\b(?:(typedef)(\s+))?(NS_ENUM|NS_OPTIONS|NS_CLOSED_ENUM|NS_ERROR_ENUM|CF_ENUM|CF_OPTIONS|CF_CLOSED_ENUM)(\s*)\(([^(),]*),(\s*)([A-Za-z_]\w*)(\s*)\)/g;
1235
+ function rewriteFoundationEnumMacros(source) {
1236
+ if (!/\b(?:NS|CF)_[A-Z_]*(?:ENUM|OPTIONS)\s*\(/.test(source))
1237
+ return source;
1238
+ let out = null;
1239
+ for (const m of maskCppCode(source).matchAll(FOUNDATION_ENUM_MACRO_RE)) {
1240
+ out ??= source.split('');
1241
+ const blank = (from, to) => {
1242
+ for (let k = from; k < to; k++)
1243
+ if (out[k] !== '\n' && out[k] !== '\r')
1244
+ out[k] = ' ';
1245
+ };
1246
+ let at = m.index;
1247
+ if (m[1]) {
1248
+ blank(at, at + m[1].length);
1249
+ at += m[1].length + m[2].length;
1250
+ }
1251
+ const macro = m[3];
1252
+ out.splice(at, 4, 'e', 'n', 'u', 'm');
1253
+ blank(at + 4, at + macro.length);
1254
+ at += macro.length + m[4].length;
1255
+ blank(at, at + 1 + m[5].length + 1);
1256
+ at += 1 + m[5].length + 1 + m[6].length + m[7].length + m[8].length;
1257
+ blank(at, at + 1);
1258
+ }
1259
+ return out ? out.join('') : source;
1260
+ }
1026
1261
  function preParseCppSource(source, filePath) {
1027
1262
  const rawStrings = maskCppRawStrings(source);
1028
- source = rawStrings.source;
1029
- // blankCLeadingAttrMacros runs AFTER the api-prefix blank so a stacked
1030
- // `FMT_NORETURN FMT_API void f(…)` reduces to the `MACRO Ret name(` shape
1031
- // it matches (the _API token is already spaces by then).
1032
- let blanked = blankLoneMacroLines(blankCLeadingAttrMacros(blankCppAnnotationMacroCalls(blankCppInlineAnnotationMacros(blankCppApiPrefixMacros(blankCppInlineMacros(blankCppExportMacros(normalizeCppComInterfaces(source))))))));
1263
+ source = flattenMidStatementConditionals(rewriteCppAccessMacros(rewriteFoundationEnumMacros(rawStrings.source)));
1264
+ let blanked = blankLoneMacroLines(blankCppLeadingAttributeMacros(blankCLeadingAttrMacros(blankCppAnnotationMacroCalls(blankCppDeclaratorAttributeMacros(blankCppTrailingAttributeMacros(blankCppPointerAnnotationMacros(blankCppInlineAnnotationMacros(blankCppApiPrefixMacros(blankCppInlineMacros(blankCppExportMacros(normalizeCppComInterfaces(source))))))))))));
1033
1265
  const lower = filePath ? filePath.toLowerCase() : '';
1034
1266
  if (lower.endsWith('.metal')) {
1035
1267
  blanked = blankMetalAttributes(blanked);
@@ -1039,64 +1271,10 @@ function preParseCppSource(source, filePath) {
1039
1271
  }
1040
1272
  return rawStrings.restore(restoreDirectiveLines(source, blanked));
1041
1273
  }
1042
- /**
1043
- * Blank an unknown attribute macro sitting in front of a C function
1044
- * definition's return type: `SEC_ATTR UINT32 LostName(VOID) { … }` (macro
1045
- * wrapping `__attribute__((…))`, common in embedded/kernel C). tree-sitter's
1046
- * C grammar reads the macro as the declaration's type, the real return type
1047
- * as the declarator, and stores the PARAMETER LIST as the function name —
1048
- * `LostName` indexes as `"(VOID)"` and is unfindable (#1211). The C++ grammar
1049
- * recovers this shape differently (glued name, salvaged post-hoc by
1050
- * `recoverMangledCppName`), but in C the real name never reaches the mangled
1051
- * string, so only a pre-parse blank can recover it.
1052
- *
1053
- * Attribute macros are project-specific (`SEC_ATTR`, `INIT_TEXT`, …), so this
1054
- * keys on structure, not a curated list, matched tightly:
1055
- * - line-leading (`^[ \t]*`) — declaration position, never an expression use;
1056
- * - ALL-CAPS token of ≥3 chars (`[A-Z][A-Z0-9_]{2,}`) — ordinary C types in
1057
- * definitions are rarely spelled this way, and when they are (`UINT32 f()`)
1058
- * they're followed by ONE identifier + `(`, which the lookahead rejects;
1059
- * - followed by TWO identifier tokens (return type, then name — `*` allowed
1060
- * for pointer returns) and then `(` — i.e. exactly the
1061
- * `MACRO Ret name(` definition shape. `MACRO name(` calls, `#define`
1062
- * lines (start with `#`), and multi-word builtin returns
1063
- * (`MACRO unsigned int f(` — where the C grammar already keeps the name)
1064
- * are all left untouched.
1065
- * Equal-length spaces preserve every byte offset, like the C++ blanks above.
1066
- */
1067
1274
  const C_LEADING_ATTR_MACRO_RE = /^([ \t]*)([A-Z][A-Z0-9_]{2,})(?=\s+[A-Za-z_]\w*[\s*]+[A-Za-z_]\w*\s*\()/gm;
1068
1275
  function blankCLeadingAttrMacros(source) {
1069
1276
  return source.replace(C_LEADING_ATTR_MACRO_RE, (_m, ws, macro) => ws + ' '.repeat(macro.length));
1070
1277
  }
1071
- /**
1072
- * Blank the body of `#ifdef __cplusplus … #endif` guard regions in C sources.
1073
- * The ubiquitous C-header compatibility idiom
1074
- *
1075
- * #ifdef __cplusplus
1076
- * extern "C" {
1077
- * #endif
1078
- *
1079
- * is NOT valid C — `extern "C" {` (and any other C++-only line under the
1080
- * guard) drops tree-sitter-c into error recovery, so effectively every public
1081
- * C header carries parse errors. The wasm path shrugs (recovery keeps the
1082
- * rest); the kernel path defers EVERY erroring file to wasm by policy — so
1083
- * this one idiom pushed C-header deferral to ~32% on redis (vs the <10%
1084
- * gate) and forfeited the native-parse win exactly where C repos have the
1085
- * most files. A C compiler never sees the guarded lines (`__cplusplus` is
1086
- * only defined for C++), so blanking the region BODY mirrors the
1087
- * preprocessor's own view of the file.
1088
- *
1089
- * Matched conservatively, line-based and offset-preserving:
1090
- * - the opener must be `#ifdef __cplusplus` / `#if defined(__cplusplus)`;
1091
- * - the body may contain NO other preprocessor directive (a nested `#if`,
1092
- * `#else`, or `#define` bails the whole region — those need real
1093
- * preprocessing, so the file keeps its current behavior);
1094
- * - the region must close with `#endif` within a few lines (guards are
1095
- * tiny; a giant region is something else).
1096
- * The `#ifdef`/`#endif` directive lines themselves are kept — an empty
1097
- * preproc_ifdef parses clean — and every blanked byte becomes a space with
1098
- * `\r` preserved, so offsets, lines, and columns survive on CRLF checkouts.
1099
- */
1100
1278
  const C_CPLUSPLUS_GUARD_OPEN_RE = /^[ \t]*#[ \t]*(?:ifdef[ \t]+__cplusplus\b|if[ \t]+defined[ \t]*\(?[ \t]*__cplusplus[ \t]*\)?)/;
1101
1279
  const C_PREPROC_DIRECTIVE_RE = /^[ \t]*#/;
1102
1280
  const C_PREPROC_ENDIF_RE = /^[ \t]*#[ \t]*endif\b/;
@@ -1118,7 +1296,7 @@ function blankCCplusplusGuardBodies(source) {
1118
1296
  break;
1119
1297
  }
1120
1298
  if (C_PREPROC_DIRECTIVE_RE.test(line))
1121
- break; // nested directive — bail
1299
+ break;
1122
1300
  }
1123
1301
  if (end < 0)
1124
1302
  continue;
@@ -1130,45 +1308,67 @@ function blankCCplusplusGuardBodies(source) {
1130
1308
  }
1131
1309
  return changed ? lines.join('\n') : source;
1132
1310
  }
1133
- /**
1134
- * Blank a C iterator-macro call in STATEMENT position — `ql_foreach(iter,
1135
- * &arena->tcache_ql, link) { … }` (jemalloc), `for_each_string_list_item(item,
1136
- * &list) { … }` (git), `list_for_each_entry(pos, head, member) { … }` (the
1137
- * Linux kernel's core iteration idiom). A call followed by a brace block is
1138
- * not a C statement, so tree-sitter-c drops into error recovery at every use —
1139
- * these macros are the single largest source of parse errors in macro-heavy C
1140
- * trees (git: ~39% of files error; the kernel path defers each one to wasm).
1141
- * Blanking JUST the macro call leaves the brace block as a bare compound
1142
- * statement — valid C — so the body's calls/locals extract normally on both
1143
- * arms instead of riding error recovery.
1144
- *
1145
- * C-ONLY, and matched tightly:
1146
- * - the call must be INDENTED (statement position; file-scope definitions
1147
- * start at column 0, and an unbraced file-scope `name(args) { }` is a
1148
- * valid implicit-int function definition that must not be touched);
1149
- * - lowercase-led identifier (iterator macros are lowercase by convention;
1150
- * this also excludes constructors if the file is really C++) that is not a
1151
- * control keyword;
1152
- * - the parens balance ON the line (string literals skipped), and after
1153
- * them only `{` or end-of-line may follow — a `;` (a real call statement),
1154
- * an operator, or any other token disqualifies;
1155
- * - when the line ends at `)`, the NEXT non-blank line must begin with `{`.
1156
- * C++ deliberately does NOT get this pass: an indented snake_case
1157
- * constructor (`basic_string_view(const Char* s) : … {`) is exactly this
1158
- * shape, and blanking it would corrupt every STL-style class.
1159
- */
1160
1311
  const C_STMT_MACRO_KEYWORDS = new Set([
1161
1312
  'if', 'while', 'for', 'switch', 'return', 'do', 'else', 'sizeof',
1162
1313
  ]);
1314
+ const C_BLOCK = -1;
1315
+ const C_OTHER_BRACES = -2;
1316
+ const cStatementFollows = (ch) => ch === ';' || ch === '{' || ch === '}' || ch === ':' || ch === ')';
1317
+ function cStatementLines(code) {
1318
+ const statements = [];
1319
+ const open = [];
1320
+ let line = 0;
1321
+ let atLineStart = true;
1322
+ let prev = -1;
1323
+ let afterControlHead = false;
1324
+ for (let i = 0; i < code.length; i++) {
1325
+ const ch = code[i];
1326
+ if (ch === '\n') {
1327
+ line++;
1328
+ atLineStart = true;
1329
+ continue;
1330
+ }
1331
+ if (ch === ' ' || ch === '\t' || ch === '\r')
1332
+ continue;
1333
+ const top = open[open.length - 1];
1334
+ if (atLineStart) {
1335
+ atLineStart = false;
1336
+ statements[line] = top === C_BLOCK && !afterControlHead && cStatementFollows(code[prev]);
1337
+ }
1338
+ afterControlHead = false;
1339
+ if (ch === '(' || ch === '[') {
1340
+ open.push(i);
1341
+ }
1342
+ else if (ch === ')' || ch === ']') {
1343
+ if (top !== undefined && top >= 0) {
1344
+ open.pop();
1345
+ afterControlHead = /\b(?:if|for|while|switch)\s*$/.test(code.slice(Math.max(0, top - 10), top));
1346
+ }
1347
+ }
1348
+ else if (ch === '{') {
1349
+ const opensBlock = code[prev] === '(' ||
1350
+ (code[prev] === ')' && top === undefined) ||
1351
+ (top === C_BLOCK && (cStatementFollows(code[prev]) || /(?:^|\W)(?:else|do)$/.test(code.slice(Math.max(0, prev - 4), prev + 1))));
1352
+ open.push(opensBlock ? C_BLOCK : C_OTHER_BRACES);
1353
+ }
1354
+ else if (ch === '}') {
1355
+ while (open.length > 0 && open.pop() >= 0)
1356
+ ;
1357
+ }
1358
+ prev = i;
1359
+ }
1360
+ return statements;
1361
+ }
1163
1362
  function blankCStatementMacroCalls(source) {
1164
1363
  const rawStrings = maskCppRawStrings(source);
1165
1364
  source = rawStrings.source;
1166
1365
  const lines = source.split('\n');
1167
1366
  let changed = false;
1367
+ let statementLines = null;
1168
1368
  const content = (l) => l.replace(/\r$/, '').trim();
1169
1369
  for (let i = 0; i < lines.length; i++) {
1170
1370
  const line = lines[i];
1171
- const m = /^[ \t]+([a-z_][a-z0-9_]*)[ \t]*\(/.exec(line);
1371
+ const m = /^[ \t]+([a-z_][a-z0-9_]*|[A-Z_][A-Z0-9_]*)[ \t]*\(/.exec(line);
1172
1372
  if (!m || C_STMT_MACRO_KEYWORDS.has(m[1]))
1173
1373
  continue;
1174
1374
  const open = line.indexOf('(', m[0].length - 1);
@@ -1198,12 +1398,6 @@ function blankCStatementMacroCalls(source) {
1198
1398
  }
1199
1399
  let endLine = i;
1200
1400
  if (close < 0) {
1201
- // Parens don't balance on the head line — the kernel wraps iterator
1202
- // macros (`hlist_for_each_entry_rcu(p, head, hlist,\n\t\t
1203
- // lockdep_is_held(&kprobe_mutex)) {`). Continue the same
1204
- // string-skipping paren scan over a few continuation lines. A `;` or
1205
- // a brace anywhere in the span means a real statement or compound
1206
- // literal — bail (missing a blank is safe; corrupting one is not).
1207
1401
  if (line.indexOf(';') !== -1)
1208
1402
  continue;
1209
1403
  for (let j = i + 1; j <= i + 5 && j < lines.length && close < 0; j++) {
@@ -1245,10 +1439,6 @@ function blankCStatementMacroCalls(source) {
1245
1439
  const endLineStr = lines[endLine];
1246
1440
  const after = endLineStr.slice(close + 1).replace(/\r$/, '').trim();
1247
1441
  if (after === '') {
1248
- // Brace on the next line (`ql_foreach(…)\n{`) or a brace-less
1249
- // single-statement body (`for_each_subsys(ss, i)\n\tstmt;` — blanking
1250
- // leaves the bare statement, valid C). A next line starting with an
1251
- // operator/string/`;` is an expression continuation — bail.
1252
1442
  let next = endLine + 1;
1253
1443
  while (next < lines.length && content(lines[next]) === '')
1254
1444
  next++;
@@ -1262,36 +1452,27 @@ function blankCStatementMacroCalls(source) {
1262
1452
  continue;
1263
1453
  }
1264
1454
  const identStart = line.indexOf(m[1]);
1455
+ statementLines ??= cStatementLines(maskCppCode(source));
1456
+ const kept = statementLines[i] ? `${m[1]};` : '';
1265
1457
  if (endLine === i) {
1266
1458
  lines[i] =
1267
1459
  line.slice(0, identStart) +
1268
- ' '.repeat(close + 1 - identStart) +
1460
+ kept.padEnd(close + 1 - identStart) +
1269
1461
  line.slice(close + 1);
1270
1462
  }
1271
1463
  else {
1272
- lines[i] = line.slice(0, identStart) + line.slice(identStart).replace(/[^\r]/g, ' ');
1464
+ lines[i] = line.slice(0, identStart) + kept + line.slice(identStart + kept.length).replace(/[^\r]/g, ' ');
1273
1465
  for (let j = i + 1; j < endLine; j++) {
1274
1466
  lines[j] = lines[j].replace(/[^\r]/g, ' ');
1275
1467
  }
1276
1468
  lines[endLine] =
1277
1469
  endLineStr.slice(0, close + 1).replace(/[^\r]/g, ' ') + endLineStr.slice(close + 1);
1278
- i = endLine; // the blanked span can't host another head
1470
+ i = endLine;
1279
1471
  }
1280
1472
  changed = true;
1281
1473
  }
1282
1474
  return rawStrings.restore(changed ? lines.join('\n') : source);
1283
1475
  }
1284
- /**
1285
- * Blank a lowercase compiler-annotation word SANDWICHED between a storage
1286
- * class and the rest of a declaration — `static notrace void tick(…)`,
1287
- * `static nokprobe_inline void arm(…)` (kernel compiler.h markers). The
1288
- * dunder word-list can't carry these bare-word forms: `notrace` is a
1289
- * plausible identifier. The sandwich IS the guard — the token counts only
1290
- * when directly preceded by `static`/`extern`/`inline` AND followed by
1291
- * another word, a position where it cannot be a variable name (an archaic
1292
- * implicit-int `static notrace = 1;` fails the following-word requirement).
1293
- * C-only.
1294
- */
1295
1476
  const C_SANDWICHED_ANNOTATIONS = [
1296
1477
  'noinline_for_stack', 'nokprobe_inline', 'noinline', 'notrace', 'noinstr',
1297
1478
  ];
@@ -1303,14 +1484,6 @@ function blankCSandwichedAnnotations(source) {
1303
1484
  C_SANDWICH_RE.lastIndex = 0;
1304
1485
  return source.replace(C_SANDWICH_RE, (_m, storage, ws, ann) => storage + ws + ' '.repeat(ann.length));
1305
1486
  }
1306
- /**
1307
- * Blank a C23 `auto` type-inference keyword — `auto hb = hbr.hb;` (the
1308
- * futex code; tree-sitter-c predates C23 auto and errors the enclosing
1309
- * function). The old storage-class reading (`auto int x = 1;`) has a TYPE
1310
- * between `auto` and the `=` and is untouched — the match requires
1311
- * `auto IDENT =` directly, which only the C23 form exhibits. Blanking
1312
- * leaves a plain assignment statement. C-only.
1313
- */
1314
1487
  const C_AUTO_INFER_RE = /\bauto(?=[ \t]+[A-Za-z_]\w*[ \t]*=)/g;
1315
1488
  function blankCAutoInference(source) {
1316
1489
  C_AUTO_INFER_RE.lastIndex = 0;
@@ -1319,22 +1492,6 @@ function blankCAutoInference(source) {
1319
1492
  C_AUTO_INFER_RE.lastIndex = 0;
1320
1493
  return source.replace(C_AUTO_INFER_RE, () => ' ');
1321
1494
  }
1322
- /**
1323
- * Blank a trailing parameter-attribute macro — `int argc UNUSED,` /
1324
- * `struct repository *repo UNUSED)` — git's house style for
1325
- * `__attribute__((unused))` on nearly every callback parameter (and the same
1326
- * shape as `MAYBE_UNUSED`/`G_GNUC_UNUSED` elsewhere). tree-sitter-c can't
1327
- * parse a second identifier after the parameter name, so every such
1328
- * SIGNATURE drops into error recovery — the single largest deferral bucket
1329
- * on git (~150 files). Blanking the macro leaves an ordinary parameter.
1330
- *
1331
- * Matched tightly: an identifier, whitespace, then an ALL-CAPS ≥3-char token
1332
- * immediately before `,` or `)`. Two juxtaposed identifiers in that position
1333
- * have no other valid-C reading — in a CALL the would-be macro is preceded
1334
- * by `,`/`(`, an operator, or a literal, never by a bare identifier. C-only:
1335
- * C++ grammars accept more juxtapositions (user-defined suffixes, macro'd
1336
- * `final`/`override`), so cpp keeps its existing recovery there.
1337
- */
1338
1495
  const C_TRAILING_PARAM_ATTR_RE = /\b([A-Za-z_]\w*)([ \t]+)([A-Z][A-Z0-9_]{2,})(?=[ \t]*[,)])/g;
1339
1496
  function blankCTrailingParamAttrMacros(source) {
1340
1497
  if (!C_TRAILING_PARAM_ATTR_RE.test(source)) {
@@ -1344,23 +1501,6 @@ function blankCTrailingParamAttrMacros(source) {
1344
1501
  C_TRAILING_PARAM_ATTR_RE.lastIndex = 0;
1345
1502
  return source.replace(C_TRAILING_PARAM_ATTR_RE, (_m, name, ws, macro) => name + ws + ' '.repeat(macro.length));
1346
1503
  }
1347
- /**
1348
- * Blank the Linux-kernel/sparse declaration-annotation macros — `static int
1349
- * __init audit_init(void)`, `void __user *buf`, `__bpf_kfunc void f(…)`,
1350
- * `int x __ro_after_init;`. These lowercase double-underscore annotations sit
1351
- * between storage/type tokens and the declarator, a position tree-sitter-c
1352
- * can't reconcile, and they blanket the Linux tree: measured on the kernel's
1353
- * own `kernel/` + `mm/` subtrees, they are the largest single deferral cause
1354
- * (the `__init` family alone heads ~37% of erroring files).
1355
- *
1356
- * A structural match is IMPOSSIBLE here: `__u32 count` (a real typedef) and
1357
- * `__init foo` (an annotation) are byte-shape identical — so unlike the
1358
- * shape-keyed blanks above, this is a CURATED list (the CPP_INLINE_MACROS
1359
- * precedent) of well-known sparse/section/compiler annotations that are
1360
- * reserved-namespace macros in every codebase that spells them. Whole-word,
1361
- * equal-length spaces, C-only (the C++ grammar's kernel exposure is
1362
- * negligible and cpp keeps its narrower blank set).
1363
- */
1364
1504
  const C_KERNEL_ANNOTATIONS = [
1365
1505
  '__init', '__exit', '__initdata', '__initconst', '__exitdata',
1366
1506
  '__devinit', '__devexit', '__cpuinit', '__meminit', '__meminitdata',
@@ -1371,10 +1511,6 @@ const C_KERNEL_ANNOTATIONS = [
1371
1511
  '__deprecated', '__ro_after_init', '__read_mostly', '__refdata',
1372
1512
  '__latent_entropy', '__randomize_layout', '__no_randomize_layout',
1373
1513
  '__bpf_kfunc', '__function_aligned', '__always_inline', '__noreturn',
1374
- // Round-2 additions, each measured heading first-error lines on the
1375
- // v7.2-rc2 kernel/+mm/ census (2026-07-17): cacheline placement, sparse
1376
- // lock/section markers, and bpf/typecheck annotations. Real dunder TYPES
1377
- // (`__u32`, `__s64`) and operators (`__alignof__`) are deliberately absent.
1378
1514
  '__cacheline_aligned_in_smp', '__cacheline_aligned',
1379
1515
  '__cacheline_internodealigned_in_smp', '____cacheline_aligned_in_smp',
1380
1516
  '____cacheline_aligned', '____cacheline_internodealigned_in_smp',
@@ -1382,9 +1518,6 @@ const C_KERNEL_ANNOTATIONS = [
1382
1518
  '__nosavedata', '__no_kcsan', '__cpuidle', '__ksym',
1383
1519
  '__initdata_memblock', '__initdata_or_meminfo',
1384
1520
  ];
1385
- // `(?!\s*\()` keeps the parameterized annotations (`__printf(1, 2)`,
1386
- // `__aligned(8)`, `__section("x")`) intact — blanking just their name would
1387
- // strand the argument list as a floating parenthesis and CREATE an error.
1388
1521
  const C_KERNEL_ANNOTATION_RE = new RegExp(`\\b(${[...C_KERNEL_ANNOTATIONS].sort((a, b) => b.length - a.length).join('|')})\\b(?!\\s*\\()`, 'g');
1389
1522
  function blankCKernelAnnotations(source) {
1390
1523
  if (source.indexOf('__') === -1)
@@ -1393,35 +1526,11 @@ function blankCKernelAnnotations(source) {
1393
1526
  if (!C_KERNEL_ANNOTATION_RE.test(source))
1394
1527
  return source;
1395
1528
  let out = source.replace(C_KERNEL_ANNOTATION_RE, (m) => ' '.repeat(m.length));
1396
- // `container_of(ptr, struct T, member)` — the type-keyword argument is the
1397
- // one call shape tree-sitter-c cannot read (a macro taking a TYPE), and it
1398
- // is pervasive across the Linux tree. Blanking just the `struct`/`union`
1399
- // keyword leaves `container_of(ptr, T, member)` — a plain
1400
- // identifier argument the grammar parses natively. Keyed to the macro name
1401
- // so no other `struct` keyword anywhere is ever touched.
1402
1529
  if (out.indexOf('container_of') !== -1) {
1403
1530
  out = out.replace(/(\bcontainer_of\s*\([^;()]*?,\s*)(struct|union)(\s+)/g, (_m, head, kw, ws) => head + ' '.repeat(kw.length) + ws);
1404
1531
  }
1405
1532
  return out;
1406
1533
  }
1407
- /**
1408
- * Blank the PARAMETERIZED sparse/compiler annotations whole — name AND
1409
- * argument list — `struct file *f __free(fput) = NULL;`, `static void
1410
- * __printf(4, 0) log_it(…)`, `} owners[] __counted_by(count);`,
1411
- * `__bpf_md_ptr(struct bpf_iter_meta *, meta);`. The word-list blank above
1412
- * deliberately skips these via `(?!\s*\()` because blanking just the NAME
1413
- * strands `(args)` as a floating parenthesis — so every such file kept
1414
- * deferring (the v7.2-rc2 kernel/+mm/ census puts `__free`/`__printf`/
1415
- * `__counted_by`/`__aligned` at the head of 39 first-error lines). Blanking
1416
- * the whole `__name(args)` span leaves an ordinary declaration.
1417
- *
1418
- * CURATED for the same reason as the word list: `__aligned(8)` (annotation)
1419
- * and `__hash(key)` (a real static helper call) are byte-shape identical, so
1420
- * only reserved-namespace names that are annotations in every codebase that
1421
- * spells them are listed. One nesting level of parens is allowed
1422
- * (`__aligned(sizeof(struct x))`); newlines inside the span survive so byte
1423
- * offsets are preserved. C-only.
1424
- */
1425
1534
  const C_PARAMETERIZED_ANNOTATIONS = [
1426
1535
  '__free', '__printf', '__scanf', '__counted_by', '__counted_by_le',
1427
1536
  '__counted_by_be', '__guarded_by', '__pt_guarded_by', '__acquires',
@@ -1441,10 +1550,6 @@ function blankCParameterizedAnnotationMacros(source) {
1441
1550
  while ((m = C_PARAM_ANNOTATION_RE.exec(source)) !== null) {
1442
1551
  const start = m.index;
1443
1552
  let end = start + m[0].length;
1444
- // Field-position form — `__bpf_md_ptr(struct bpf_iter_meta *, meta);` as
1445
- // the whole line: a lone `;` field is ITSELF a parse error (measured;
1446
- // an empty struct body is fine), so the semicolon blanks with it. A
1447
- // mid-line match (`… __free(fput) = NULL;`) keeps its statement tail.
1448
1553
  const lineStart = source.lastIndexOf('\n', start - 1) + 1;
1449
1554
  if (/^[ \t]*$/.test(source.slice(lineStart, start))) {
1450
1555
  const after = /^[ \t]*;/.exec(source.slice(end));
@@ -1456,37 +1561,6 @@ function blankCParameterizedAnnotationMacros(source) {
1456
1561
  }
1457
1562
  return rawStrings.restore(result + source.slice(last));
1458
1563
  }
1459
- /**
1460
- * Blank a bare `struct`/`union`/`enum` TYPE-keyword argument inside a macro
1461
- * call — `kzalloc_obj(struct bpf_mount_opts)`, `alloc_percpu(struct irqstat)`,
1462
- * `list_first_entry(&pending,\n\t\tstruct async_entry, domain_list)` — the
1463
- * `container_of` disease generalized (that blank stays as the keyed
1464
- * precedent). A bare type is never a valid C expression argument, so
1465
- * tree-sitter drops into error recovery at every such call; removing just the
1466
- * keyword leaves a plain identifier argument the grammar parses natively.
1467
- * This single shape heads ~35 first-error lines on the kernel/+mm/ census
1468
- * (kzalloc_obj/list_entry/alloc_percpu + multi-line continuations).
1469
- *
1470
- * Guarded three ways, because `f(struct T)` has VALID look-alikes:
1471
- * - head exclusions: `sizeof(struct T)` / `offsetof(struct T, m)` /
1472
- * `_Generic(x, struct T *: …)` all parse natively (probed) and must keep
1473
- * their keyword; `va_arg` gets its own dedicated blank below.
1474
- * - call-vs-declaration: in `int wf(struct a, struct b);` (a wrapped
1475
- * prototype — valid C) the head is preceded by a TYPE, so any identifier
1476
- * or `*` before the head rejects the match — except the word `return`,
1477
- * which precedes real calls. Newline/`=`/`,`/`(`/`;`/`{`/`>` etc. accept.
1478
- * - the keyword must OPEN a top-level argument and the argument must be
1479
- * exactly `struct T` (optionally `struct T *`, whose stars blank too —
1480
- * `DEFINE_PER_CPU(struct task_struct *, ksoftirqd)` leaves two plain
1481
- * identifier arguments): a cast (`f((struct T *)p)`) opens a nested
1482
- * group, and a declaration argument (`TP_PROTO(struct foo *bar)`) trails
1483
- * an extra identifier — neither matches.
1484
- * A hand-rolled bounded scanner rather than a nested-alternation regex:
1485
- * preceding args may themselves contain calls
1486
- * (`hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(&d->h)),\n
1487
- * struct bpf_dtab_netdev, index_hlist)`), and lazy nested regex groups over
1488
- * untrusted repo text invite catastrophic backtracking. C-only.
1489
- */
1490
1564
  const C_TYPE_ARG_HEAD_EXCLUSIONS = new Set([
1491
1565
  'sizeof', 'alignof', '_Alignof', 'typeof', '__typeof__', '__typeof',
1492
1566
  'offsetof', '_Generic', 'va_arg', 'if', 'while', 'for', 'switch', 'case',
@@ -1506,8 +1580,6 @@ function blankCTypeKeywordArgs(source) {
1506
1580
  const head = m[1];
1507
1581
  if (C_TYPE_ARG_HEAD_EXCLUSIONS.has(head))
1508
1582
  continue;
1509
- // Reject declaration shapes: an identifier or `*` (a return/field type)
1510
- // immediately before the head — unless that word is `return`.
1511
1583
  let j = m.index - 1;
1512
1584
  while (j >= 0 && (source[j] === ' ' || source[j] === '\t'))
1513
1585
  j--;
@@ -1550,7 +1622,7 @@ function blankCTypeKeywordArgs(source) {
1550
1622
  continue;
1551
1623
  }
1552
1624
  if (ch === ';' || ch === '{' || ch === '}')
1553
- break; // not an argument list
1625
+ break;
1554
1626
  if (ch === ',') {
1555
1627
  if (depth === 1)
1556
1628
  atArgStart = true;
@@ -1578,28 +1650,6 @@ function blankCTypeKeywordArgs(source) {
1578
1650
  }
1579
1651
  return rawStrings.restore(chars ? chars.join('') : source);
1580
1652
  }
1581
- /**
1582
- * Blank a file-scope `static`/`extern`-prefixed ALL-CAPS declaration macro —
1583
- * `static DEFINE_PER_CPU(struct llist_head, rstat_backlog_list);`,
1584
- * `static DECLARE_WORK(init_free_wq, do_free_init);`,
1585
- * `static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);` — the single
1586
- * largest deferral family on the kernel/+mm/ census (~45 first-error lines
1587
- * across the DEFINE_/DECLARE_ variants). A storage-class specifier followed
1588
- * by a call expression is never valid C, so every one errors; the whole line
1589
- * blanks to spaces (the macro-declared variable was invisible to extraction
1590
- * anyway, and the file's remaining symbols recover).
1591
- *
1592
- * The UNPREFIXED form (`EXPORT_SYMBOL(x);`, `DEFINE_MUTEX(lock);` at column
1593
- * 0) parses natively as a K&R implicit-int declaration (probed) — extraction
1594
- * ignores declarations, so those lines are left alone; the type-keyword-arg
1595
- * blank above already recovers the `DEFINE_PER_CPU(struct T, x);` bare form.
1596
- * Matched tightly: `static`/`extern` first on the line (indentation allowed —
1597
- * `static DEFINE_RATELIMIT_STATE(…)` appears at BLOCK scope too, and the
1598
- * storage-class-plus-call shape is invalid at every scope), CAPS macro name,
1599
- * parens balancing ON the line (string literals skipped), then exactly `;`
1600
- * to end of line. Initializer forms (`… ) = { …`) are deliberately not
1601
- * matched — blanking the head would strand the brace block. C-only.
1602
- */
1603
1653
  const C_PREFIXED_DECL_MACRO_RE = /^[ \t]*(?:static|extern)[ \t]+[A-Z][A-Z0-9_]{2,}[ \t]*\(/;
1604
1654
  function blankCFileScopePrefixedDeclMacros(source) {
1605
1655
  if (!/^[ \t]*(?:static|extern)[ \t]+[A-Z]/m.test(source))
@@ -1639,7 +1689,7 @@ function blankCFileScopePrefixedDeclMacros(source) {
1639
1689
  }
1640
1690
  }
1641
1691
  if (close < 0)
1642
- continue; // spans lines — leave for a future round
1692
+ continue;
1643
1693
  if (line.slice(close + 1).replace(/\r$/, '').trim() !== ';')
1644
1694
  continue;
1645
1695
  lines[i] = line.replace(/[^\n\r]/g, ' ');
@@ -1647,23 +1697,6 @@ function blankCFileScopePrefixedDeclMacros(source) {
1647
1697
  }
1648
1698
  return rawStrings.restore(changed ? lines.join('\n') : source);
1649
1699
  }
1650
- /**
1651
- * REWRITE (the one non-blank pass in this family — it moves a token) a
1652
- * 2-argument `static CAPS_MACRO(type, name) = {`-style initialized
1653
- * declaration macro into the declaration it expands to — `static
1654
- * DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state) = {` becomes `static
1655
- * struct cpuhp_cpu_state cpuhp_state) …` → `static struct
1656
- * cpuhp_cpu_state` + padding + `cpuhp_state` + padding + `= {`. The blank
1657
- * family can't help here: blanking the head strands the brace block, and
1658
- * dropping the whole span would discard the initializer's function
1659
- * references (`.startup.single = bringup_cpu` — real cFnPtr wiring). The
1660
- * NAME keeps its exact original column and the `= {` tail keeps its exact
1661
- * offsets (`d`-flag group indices); only the TYPE token sits left of where
1662
- * the macro name was, and type tokens contribute strings, not positions.
1663
- * Only the two-argument `(<type-ish>, <ident>)` form with an `=` tail
1664
- * matches; three-argument macros and `;`-terminated forms (the blank above)
1665
- * never do. C-only.
1666
- */
1667
1700
  const C_PREFIXED_DECL_MACRO_INIT_RE = /^([ \t]*)static[ \t]+[A-Z][A-Z0-9_]{2,}[ \t]*\(([^();'"]*?),[ \t]*([A-Za-z_]\w*)[ \t]*\)([ \t]*=[ \t]*\{?[ \t]*\r?)$/d;
1668
1701
  function rewriteCPrefixedDeclMacroInitializers(source) {
1669
1702
  if (!/^[ \t]*static[ \t]+[A-Z]/m.test(source))
@@ -1678,13 +1711,13 @@ function rewriteCPrefixedDeclMacroInitializers(source) {
1678
1711
  const indices = m.indices;
1679
1712
  const arg1 = m[2].trim().replace(/[ \t]+/g, ' ');
1680
1713
  if (!/^[A-Za-z_][\w \t*]*$/.test(arg1))
1681
- continue; // a type-token run only
1714
+ continue;
1682
1715
  const name = m[3];
1683
1716
  const nameStart = indices[3][0];
1684
1717
  const tailStart = indices[4][0];
1685
1718
  const prefix = m[1] + 'static ' + arg1;
1686
1719
  if (prefix.length + 1 > nameStart)
1687
- continue; // rewrite must fit left of the name
1720
+ continue;
1688
1721
  lines[i] =
1689
1722
  prefix +
1690
1723
  ' '.repeat(nameStart - prefix.length) +
@@ -1695,16 +1728,6 @@ function rewriteCPrefixedDeclMacroInitializers(source) {
1695
1728
  }
1696
1729
  return changed ? lines.join('\n') : source;
1697
1730
  }
1698
- /**
1699
- * Blank a QUALIFIED/POINTER type argument of `va_arg` — `va_arg(ap, const
1700
- * char *)`, `va_arg(args, unsigned long)`. tree-sitter-c parses the
1701
- * single-token forms (`va_arg(ap, int)`, `va_arg(ap, foo_t)`) natively
1702
- * (probed), but multi-token type descriptors error the whole enclosing
1703
- * function. Blanking the comma and the entire second argument leaves
1704
- * `va_arg(ap )` — a one-argument call the grammar accepts.
1705
- * Function-pointer types (`va_arg(ap, void (*)(int))`) contain parens and
1706
- * are deliberately unmatched. C-only.
1707
- */
1708
1731
  const C_VA_ARG_RE = /\bva_arg[ \t]*\(([^(),]+)(,[^()]*)\)/g;
1709
1732
  function blankCVaArgQualifiedTypeArgs(source) {
1710
1733
  if (source.indexOf('va_arg') === -1)
@@ -1712,24 +1735,10 @@ function blankCVaArgQualifiedTypeArgs(source) {
1712
1735
  C_VA_ARG_RE.lastIndex = 0;
1713
1736
  return source.replace(C_VA_ARG_RE, (m, arg1, rest) => {
1714
1737
  if (/^,[ \t]*[A-Za-z_]\w*[ \t]*$/.test(rest))
1715
- return m; // single token — parses natively
1738
+ return m;
1716
1739
  return `va_arg(${arg1}${rest.replace(/[^\n\r]/g, ' ')})`;
1717
1740
  });
1718
1741
  }
1719
- /**
1720
- * Blank the DOTS of a GNU NAMED-variadic function-like `#define` parameter —
1721
- * `#define verbose(env, fmt, args...) …` → `#define verbose(env, fmt,
1722
- * args ) …`. The `ident...` parameter form (unlike standard `...`) errors
1723
- * the DIRECTIVE itself (measured — and so does trailing whitespace after a
1724
- * bare `#define NAME`, which is why the tail is NOT blanked wholesale); with
1725
- * just the dots blanked the params parse as ordinary identifiers and the
1726
- * body (`##args` included — the preproc body is opaque to the grammar) is
1727
- * untouched. `restoreDirectiveLines` exists to keep directives out of the
1728
- * other blanks' blast radius, so this pass runs AFTER the restore and edits
1729
- * the directive deliberately. Multi-line bodies are fine — the params always
1730
- * sit on the `#define` line. C-only (the census hits are the kernel's bpf
1731
- * verifier headers).
1732
- */
1733
1742
  const C_NAMED_VARIADIC_DEFINE_RE = /^([ \t]*#[ \t]*define[ \t]+[A-Za-z_]\w*\([^()\n]*?\b\w+)\.\.\./;
1734
1743
  function blankCNamedVariadicDefineDots(source) {
1735
1744
  if (source.indexOf('...') === -1)
@@ -1747,43 +1756,12 @@ function blankCNamedVariadicDefineDots(source) {
1747
1756
  }
1748
1757
  return changed ? lines.join('\n') : source;
1749
1758
  }
1750
- /** C source pre-processing: neutralize `#ifdef __cplusplus` compat-guard
1751
- * bodies (invisible to a C compiler; `extern "C" {` otherwise errors every
1752
- * public header), blank declaration-markup macro calls and lone macro lines
1753
- * (`REDIS_NO_SANITIZE("bounds")` before a definition, jemalloc's diagnostic
1754
- * toggles — the same structural shapes the C++ side already blanks), recover
1755
- * functions hidden behind a leading attribute macro (#1211), then — for
1756
- * C-detected headers in CUDA projects (llm.c keeps `__device__` helpers and
1757
- * kernel prototypes in plain `.h`) — the same content-gated CUDA blank as
1758
- * C++. Offset-preserving. */
1759
- /**
1760
- * Blank the argument list of a statement-level `MACRO( … );` call whose
1761
- * arguments are designated initializers — betaflight's
1762
- *
1763
- * RESET_CONFIG(pidProfile_t, pidProfile,
1764
- * .pid = { [PID_ROLL] = PID_ROLL_DEFAULT, … },
1765
- * .pidSumLimit = PIDSUM_LIMIT,
1766
- * …
1767
- * );
1768
- *
1769
- * tree-sitter-c has no rule for `.field = value` as a call argument. Even a
1770
- * small statement-level `M(a, b, .x = 1, .y = { 1, 2 },);` with a trailing
1771
- * comma recovers by extending the enclosing `function_definition` to EOF —
1772
- * the next function vanishes and later ones nest under the first (#1729 —
1773
- * 310 functions in 73 files on a betaflight tree, which name matching then
1774
- * treated as unreachable closures). Emptying the argument list to spaces,
1775
- * newlines kept, leaves `RESET_CONFIG(\n\n…\n);` — a call the grammar parses
1776
- * cleanly — at the cost of the references inside the initializer, which the
1777
- * broken parse was not yielding either. Statement-level only (`);` follows),
1778
- * macro-cased name only, offsets preserved. Runs before the kernel route
1779
- * point, so both the wasm and kernel C arms see the same bytes.
1780
- */
1781
1759
  function blankCDesignatedMacroArgs(source) {
1782
1760
  if (source.indexOf('=') === -1)
1783
1761
  return source;
1784
1762
  const rawStrings = maskCppRawStrings(source);
1785
1763
  source = rawStrings.source;
1786
- const out = source.split('');
1764
+ let out = null;
1787
1765
  const re = /^[ \t]*([A-Z_][A-Z0-9_]*)\s*\(/gm;
1788
1766
  let m;
1789
1767
  while ((m = re.exec(source))) {
@@ -1801,30 +1779,135 @@ function blankCDesignatedMacroArgs(source) {
1801
1779
  continue;
1802
1780
  const close = i - 1;
1803
1781
  const args = source.slice(open + 1, close);
1804
- // A designator at argument depth: `.name =` or `[index] =`.
1805
1782
  if (!/(^|[,{(\s])(\.[A-Za-z_]\w*|\[[^\]]+\])\s*=[^=]/.test(args))
1806
1783
  continue;
1807
1784
  if (!/^\s*;/.test(source.slice(close + 1)))
1808
1785
  continue;
1786
+ out ??= source.split('');
1809
1787
  for (let k = open + 1; k < close; k++)
1810
1788
  if (out[k] !== '\n')
1811
1789
  out[k] = ' ';
1812
1790
  re.lastIndex = close;
1813
1791
  }
1814
- return rawStrings.restore(out.join(''));
1792
+ return rawStrings.restore(out ? out.join('') : source);
1793
+ }
1794
+ const C_COND_OPEN_RE = /^[ \t]*#[ \t]*(if|ifdef|ifndef)\b[ \t]*(.*)$/;
1795
+ const C_COND_NEXT_RE = /^[ \t]*#[ \t]*(elif|else)\b/;
1796
+ const C_COND_ENDIF_RE = /^[ \t]*#[ \t]*endif\b/;
1797
+ function blankCUnbalancedConditionalBranches(source) {
1798
+ if (source.indexOf('#') === -1)
1799
+ return source;
1800
+ const lines = source.split('\n');
1801
+ const masked = maskCppCommentsAndLiterals(source).split('\n');
1802
+ const stripCr = (l) => (l.endsWith('\r') ? l.slice(0, -1) : l);
1803
+ const code = (k) => stripCr(masked[k]).trim();
1804
+ const blank = (l) => l.replace(/[^\r]/g, ' ');
1805
+ const blankLine = (k) => {
1806
+ lines[k] = blank(lines[k]);
1807
+ masked[k] = blank(masked[k]);
1808
+ };
1809
+ const stack = [];
1810
+ const directive = [];
1811
+ const continued = [];
1812
+ let changed = false;
1813
+ let continuation = false;
1814
+ for (let i = 0; i < lines.length; i++) {
1815
+ const line = stripCr(masked[i]);
1816
+ const isDirective = continuation || /^[ \t]*#/.test(line);
1817
+ directive[i] = isDirective;
1818
+ continued[i] = continuation;
1819
+ const wasContinuation = continuation;
1820
+ continuation = isDirective && /\\\s*$/.test(stripCr(lines[i]));
1821
+ if (!isDirective || wasContinuation)
1822
+ continue;
1823
+ let m;
1824
+ if ((m = C_COND_OPEN_RE.exec(line))) {
1825
+ const cond = m[2].trim();
1826
+ const dead = m[1] === 'if' && /^0\b/.test(cond);
1827
+ const live = m[1] === 'if' && /^1\b/.test(cond);
1828
+ const positive = m[1] === 'ifdef' || (m[1] === 'if' && !dead && !live && !/^!/.test(cond));
1829
+ stack.push({ marks: [i], dead, literal: dead || live, positive, elseAt: -1 });
1830
+ continue;
1831
+ }
1832
+ const top = stack[stack.length - 1];
1833
+ if (!top)
1834
+ continue;
1835
+ if (C_COND_NEXT_RE.test(line)) {
1836
+ if (/^[ \t]*#[ \t]*else\b/.test(line))
1837
+ top.elseAt = top.marks.length;
1838
+ top.marks.push(i);
1839
+ continue;
1840
+ }
1841
+ if (!C_COND_ENDIF_RE.test(line))
1842
+ continue;
1843
+ stack.pop();
1844
+ top.marks.push(i);
1845
+ const keep = top.dead ? 1 : top.positive && top.elseAt > 0 ? top.elseAt : 0;
1846
+ if (keep >= top.marks.length - 1)
1847
+ continue;
1848
+ let damaged = false;
1849
+ let balanced = true;
1850
+ for (let b = 0; b < top.marks.length - 1; b++) {
1851
+ const body = [];
1852
+ for (let k = top.marks[b] + 1; k < top.marks[b + 1]; k++) {
1853
+ if (directive[k])
1854
+ continue;
1855
+ const c = code(k);
1856
+ if (c)
1857
+ body.push(c);
1858
+ }
1859
+ if (body.length === 0)
1860
+ continue;
1861
+ const first = body[0];
1862
+ const last = body[body.length - 1];
1863
+ let depth = 0;
1864
+ let parens = 0;
1865
+ let dips = false;
1866
+ for (const l of body) {
1867
+ for (const ch of l) {
1868
+ depth += ch === '{' ? 1 : ch === '}' ? -1 : 0;
1869
+ parens += ch === '(' ? 1 : ch === ')' ? -1 : 0;
1870
+ if (depth < 0)
1871
+ dips = true;
1872
+ }
1873
+ }
1874
+ if (depth !== 0 || parens !== 0)
1875
+ balanced = false;
1876
+ damaged ||=
1877
+ depth !== 0 ||
1878
+ dips ||
1879
+ /^else\b/.test(first) ||
1880
+ /^(\|\||&&|,|\)|:|\?)/.test(first) ||
1881
+ /(\|\||&&|,|\(|\?|:)$/.test(last) ||
1882
+ (/^(else[ \t]+)?if[ \t]*\(/.test(last) && /\)$/.test(last));
1883
+ }
1884
+ if (!damaged)
1885
+ continue;
1886
+ const keepAll = balanced && !top.literal;
1887
+ for (let b = 0; b < top.marks.length - 1; b++) {
1888
+ const from = top.marks[b];
1889
+ const to = top.marks[b + 1];
1890
+ for (let k = from; k < to && (k === from || continued[k]); k++)
1891
+ blankLine(k);
1892
+ if (b === keep || keepAll)
1893
+ continue;
1894
+ for (let k = from + 1; k < to; k++)
1895
+ blankLine(k);
1896
+ }
1897
+ blankLine(i);
1898
+ changed = true;
1899
+ }
1900
+ return changed ? lines.join('\n') : source;
1815
1901
  }
1816
1902
  function preParseCSource(source) {
1817
1903
  const rawStrings = maskCppRawStrings(source);
1818
- source = rawStrings.source;
1904
+ source = rewriteFoundationEnumMacros(rawStrings.source);
1819
1905
  const inner = blankCDesignatedMacroArgs(blankCKernelAnnotations(blankCCplusplusGuardBodies(source)));
1820
- let blanked = blankCLeadingAttrMacros(blankLoneMacroLines(blankCStatementMacroCalls(blankCTrailingParamAttrMacros(blankCppAnnotationMacroCalls(rewriteCPrefixedDeclMacroInitializers(blankCFileScopePrefixedDeclMacros(blankCVaArgQualifiedTypeArgs(blankCTypeKeywordArgs(blankCParameterizedAnnotationMacros(blankCAutoInference(blankCSandwichedAnnotations(inner))))))))))));
1906
+ let blanked = blankCLeadingAttrMacros(blankLoneMacroLines(blankCStatementMacroCalls(blankCTrailingParamAttrMacros(blankCppAnnotationMacroCalls(rewriteCPrefixedDeclMacroInitializers(blankCFileScopePrefixedDeclMacros(blankCVaArgQualifiedTypeArgs(blankCTypeKeywordArgs(blankCParameterizedAnnotationMacros(blankCAutoInference(blankCSandwichedAnnotations(inner))))))), { keepCReturnTypes: true })))));
1821
1907
  if (looksLikeCudaSource(blanked))
1822
1908
  blanked = blankCudaConstructs(blanked);
1823
- // The named-variadic `#define` pass runs AFTER the directive restore — it
1824
- // deliberately edits directive lines (see its doc comment).
1825
- return rawStrings.restore(blankCNamedVariadicDefineDots(restoreDirectiveLines(source, blanked)));
1909
+ return rawStrings.restore(blankCUnbalancedConditionalBranches(blankCNamedVariadicDefineDots(restoreDirectiveLines(source, blanked))));
1826
1910
  }
1827
- /** A constructor prototype carries defaults even when its body is in another file. */
1828
1911
  function isCppConstructorDeclaration(node) {
1829
1912
  if (node.type !== 'declaration' || (0, tree_sitter_helpers_1.getChildByField)(node, 'type'))
1830
1913
  return false;
@@ -1836,25 +1919,11 @@ function isCppConstructorDeclaration(node) {
1836
1919
  && (0, tree_sitter_helpers_1.getChildByField)(declarator, 'declarator')?.text === (0, tree_sitter_helpers_1.getChildByField)(owner, 'name')?.text;
1837
1920
  }
1838
1921
  exports.cppExtractor = {
1839
- // Recover macro-annotated class/struct definitions (`class MYMODULE_API Foo : Base`,
1840
- // #1061/#946) and macro-prefixed functions (`FORCEINLINE FString Foo()`, #1093
1841
- // follow-up) that tree-sitter otherwise misparses.
1842
1922
  preParse: preParseCppSource,
1843
- // Universal net for any macro the curated blank list misses.
1844
1923
  recoverMangledName: recoverMangledCppName,
1845
1924
  functionTypes: ['function_definition'],
1846
1925
  classTypes: ['class_specifier'],
1847
- // A bodiless `class_specifier` is a forward declaration (`class Foo;`) or an
1848
- // elaborated type reference, not a definition. Skip it so dozens of forward
1849
- // decls across headers don't mint phantom `class` nodes that crowd out — and
1850
- // get picked as the blast-radius representative over — the single real
1851
- // definition, exactly as bodiless struct/enum specifiers are already skipped. (#1093)
1852
1926
  skipBodilessClass: true,
1853
- // `function_definition` covers inline / out-of-line bodies; `field_declaration`
1854
- // covers pure-virtual methods (`virtual int read(int key) = 0;`), which have no
1855
- // body and would otherwise mint no node — so calls through the abstract base and
1856
- // cpp-override synthesis had nothing to attach to (#1727). classifyMethodNode
1857
- // keeps ordinary data members / prototypes on the children-walk path.
1858
1927
  methodTypes: ['function_definition', 'field_declaration'],
1859
1928
  classifyMethodNode: (node) => {
1860
1929
  if (node.type !== 'field_declaration')
@@ -1864,26 +1933,22 @@ exports.cppExtractor = {
1864
1933
  isAbstract: (node) => (isCppPureVirtualMethodDecl(node) ? true : undefined),
1865
1934
  interfaceTypes: [],
1866
1935
  structTypes: ['struct_specifier'],
1867
- // C++ unions additionally carry member functions, which extract through the
1868
- // same aggregate-body walk as structs while preserving their distinct kind.
1869
1936
  unionTypes: ['union_specifier'],
1870
1937
  enumTypes: ['enum_specifier'],
1871
1938
  enumMemberTypes: ['enumerator'],
1872
- typeAliasTypes: ['type_definition', 'alias_declaration'], // typedef and using
1939
+ typeAliasTypes: ['type_definition', 'alias_declaration'],
1873
1940
  importTypes: ['preproc_include'],
1874
1941
  callTypes: ['call_expression'],
1875
1942
  variableTypes: ['declaration'],
1876
1943
  nameField: 'declarator',
1877
1944
  bodyField: 'body',
1878
1945
  paramsField: 'parameters',
1879
- resolveName: extractCppQualifiedMethodName,
1946
+ resolveName: (node, source) => extractCppQualifiedMethodName(node, source) ?? unnamedTypeVariableName(node, source) ?? cppWrittenClassParts(node, source)?.at(-1) ??
1947
+ cppSpecializedFunctionName(node, source),
1948
+ getDeclarationWrapper: (node) => definingDeclaration(node) ?? undefined,
1880
1949
  getReceiverType: extractCppReceiverType,
1950
+ getClassScope: (node, source) => cppWrittenClassParts(node, source)?.slice(0, -1).join('::') || undefined,
1881
1951
  getReturnType: extractCppReturnType,
1882
- // Constructors (definitions and class-body declarations) carry their
1883
- // parameter list as the signature; a trailing semicolon marks a prototype, so a local `T obj(args)` can be matched
1884
- // to the one overload with a compatible arity (#1839). Macro-shaped
1885
- // definitions whose real name was recovered from an argument are excluded:
1886
- // their "parameters" are macro arguments. Mirrored in the kernel.
1887
1952
  getSignature: (node, source) => {
1888
1953
  if ((node.type !== 'function_definition' && !isCppConstructorDeclaration(node)) || (0, tree_sitter_helpers_1.getChildByField)(node, 'type'))
1889
1954
  return undefined;
@@ -1894,7 +1959,6 @@ exports.cppExtractor = {
1894
1959
  return parameters ? (0, tree_sitter_helpers_1.getNodeText)(parameters, source) + (node.type === 'declaration' ? ';' : '') : undefined;
1895
1960
  },
1896
1961
  getVisibility: (node) => {
1897
- // Check for access specifier in parent
1898
1962
  const parent = node.parent;
1899
1963
  if (parent) {
1900
1964
  for (let i = 0; i < parent.childCount; i++) {
@@ -1913,8 +1977,6 @@ exports.cppExtractor = {
1913
1977
  return undefined;
1914
1978
  },
1915
1979
  resolveTypeAliasKind: (node, _source) => {
1916
- // C++ typedef: `typedef enum { ... } name;`, `typedef struct { ... } name;`,
1917
- // or `typedef union { ... } name;` — see the C extractor.
1918
1980
  for (let i = 0; i < node.namedChildCount; i++) {
1919
1981
  const child = node.namedChild(i);
1920
1982
  if (!child)
@@ -1930,24 +1992,15 @@ exports.cppExtractor = {
1930
1992
  return undefined;
1931
1993
  },
1932
1994
  isMisparsedFunction: (name, node) => {
1933
- // C++ macros like NLOHMANN_JSON_NAMESPACE_BEGIN cause tree-sitter to misparse
1934
- // namespace blocks as function_definitions (e.g. name = "namespace detail").
1935
- // Also filter C++ keywords that tree-sitter occasionally misinterprets as
1936
- // function/method names (e.g. switch statements inside macro-confused scopes).
1937
1995
  if (name.startsWith('namespace'))
1938
1996
  return true;
1939
1997
  const cppKeywords = ['switch', 'if', 'for', 'while', 'do', 'case', 'return'];
1940
1998
  if (cppKeywords.includes(name))
1941
1999
  return true;
1942
- // `class MACRO Name : public Base { … }` misparses to a function_definition
1943
- // named after the class. `blankCppExportMacros` (preParse) recovers the
1944
- // common ALL-CAPS export-macro shape; this drop is the fallback for any
1945
- // residual misparse it doesn't blank — still no phantom function (#1061/#946).
1946
2000
  return isMacroMisparsedTypeDecl(node);
1947
2001
  },
1948
2002
  extractImport: (node, source) => {
1949
2003
  const importText = source.substring(node.startIndex, node.endIndex).trim();
1950
- // C++ includes: #include <iostream>, #include "myheader.h"
1951
2004
  const systemLib = node.namedChildren.find((c) => c.type === 'system_lib_string');
1952
2005
  if (systemLib) {
1953
2006
  return { moduleName: (0, tree_sitter_helpers_1.getNodeText)(systemLib, source).replace(/^<|>$/g, ''), signature: importText };