@colbymchenry/codegraph-win32-arm64 1.6.2 → 1.6.4

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