@backbencher/brain 0.0.0-stage → 0.1.1

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 (319) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/EMBEDDINGS.md +355 -0
  3. package/LICENSE +21 -0
  4. package/README.md +415 -2
  5. package/bin/bb +13 -0
  6. package/dist/analysis-exclusions-7ZJDXOVZ.js +35 -0
  7. package/dist/brain-index-health-Q5APTJQL.js +17 -0
  8. package/dist/brain-relationship-enrichment-MYR2AM4F.js +558 -0
  9. package/dist/brain.sql-EIM4WS4D.js +29 -0
  10. package/dist/chunk-22V37YTK.js +1758 -0
  11. package/dist/chunk-2BSKD7O3.js +40 -0
  12. package/dist/chunk-2DE27DVC.js +1314 -0
  13. package/dist/chunk-2RRBMNBQ.js +322 -0
  14. package/dist/chunk-2WXYNLBA.js +29 -0
  15. package/dist/chunk-3CTFIJJB.js +17 -0
  16. package/dist/chunk-3ZTOHHSW.js +2104 -0
  17. package/dist/chunk-4H22TLOT.js +543 -0
  18. package/dist/chunk-5BVAH26D.js +340 -0
  19. package/dist/chunk-62DHLYW6.js +3427 -0
  20. package/dist/chunk-7AN7U5IZ.js +371 -0
  21. package/dist/chunk-7DRPNVIN.js +782 -0
  22. package/dist/chunk-7MBYT777.js +174 -0
  23. package/dist/chunk-AHDWGM7Q.js +236 -0
  24. package/dist/chunk-B5GEAAYF.js +818 -0
  25. package/dist/chunk-BEIZZ73B.js +1479 -0
  26. package/dist/chunk-BQ3OVQ3P.js +125 -0
  27. package/dist/chunk-D2Q4Y47A.js +53 -0
  28. package/dist/chunk-DIYAGQJL.js +34 -0
  29. package/dist/chunk-DWKXZ6IF.js +336 -0
  30. package/dist/chunk-DYM4FQEE.js +90 -0
  31. package/dist/chunk-ENW4BTBA.js +930 -0
  32. package/dist/chunk-EWMWK7WN.js +75 -0
  33. package/dist/chunk-EY5ZZUUA.js +626 -0
  34. package/dist/chunk-GBI7V7KY.js +69 -0
  35. package/dist/chunk-GEFFO6O2.js +152 -0
  36. package/dist/chunk-HJEWO5EV.js +247 -0
  37. package/dist/chunk-HQSPJDHI.js +613 -0
  38. package/dist/chunk-KAET47ZL.js +125 -0
  39. package/dist/chunk-KCDECRJY.js +440 -0
  40. package/dist/chunk-L5TDYKYK.js +76 -0
  41. package/dist/chunk-MLKGABMK.js +9 -0
  42. package/dist/chunk-NO3U3FJQ.js +201 -0
  43. package/dist/chunk-OWISBAOF.js +61 -0
  44. package/dist/chunk-QKTRECYS.js +1119 -0
  45. package/dist/chunk-QLK6ED4Q.js +235 -0
  46. package/dist/chunk-R2GW4F6R.js +19 -0
  47. package/dist/chunk-RCMTFSEF.js +87 -0
  48. package/dist/chunk-RM3PY6TG.js +376 -0
  49. package/dist/chunk-ROMM6KMC.js +433 -0
  50. package/dist/chunk-SGGCSHAX.js +12050 -0
  51. package/dist/chunk-SK6YVHFZ.js +211 -0
  52. package/dist/chunk-SM7RFQRO.js +214 -0
  53. package/dist/chunk-UGR4QIGS.js +67 -0
  54. package/dist/chunk-UQNQZXHY.js +711 -0
  55. package/dist/chunk-UUNHHX4M.js +13 -0
  56. package/dist/chunk-VL52PL2T.js +71 -0
  57. package/dist/chunk-WIG36E67.js +196 -0
  58. package/dist/chunk-XHK3WWGB.js +7436 -0
  59. package/dist/chunk-XTQM2IP3.js +2863 -0
  60. package/dist/chunk-ZE2LG76D.js +1296 -0
  61. package/dist/chunk-ZETTGPAW.js +6950 -0
  62. package/dist/cli/index.js +37 -0
  63. package/dist/config-HZAAYDP3.js +10 -0
  64. package/dist/content-search-7XIP555Q.js +593 -0
  65. package/dist/database-76RP44JG.js +9 -0
  66. package/dist/doctor-ANGETYMN.js +395 -0
  67. package/dist/edit-engine-CG72LDZD.js +51 -0
  68. package/dist/engine-BKEOGN7N.js +11 -0
  69. package/dist/engine-VIW6NSKO.js +18 -0
  70. package/dist/fingerprint-OBLIMZLP.js +33 -0
  71. package/dist/framework-intelligence-3LORTPOX.js +860 -0
  72. package/dist/freshness-3K6VU5OT.js +174 -0
  73. package/dist/graph-engine-HBSQNPTB.js +21 -0
  74. package/dist/graph_request-Q6NKB6N2.js +350 -0
  75. package/dist/impact_request-LYP672WE.js +68 -0
  76. package/dist/index-space-IUUN5WYV.js +15 -0
  77. package/dist/index-status-7OVGYSGW.js +34 -0
  78. package/dist/index.js +159 -0
  79. package/dist/instance-FO6QZRLH.js +19 -0
  80. package/dist/language-detection-DFCAU5DZ.js +11 -0
  81. package/dist/lsp/server.js +4301 -0
  82. package/dist/mcp/server.js +132 -0
  83. package/dist/onboard-DIQZV2NW.js +161 -0
  84. package/dist/override-companion-pass-XR7MHTP7.js +117 -0
  85. package/dist/parallel-indexer-FK2XKZXY.js +88 -0
  86. package/dist/pool-worker.js +1153 -0
  87. package/dist/project-health-6XPENVAA.js +94 -0
  88. package/dist/project-index-5SDPHITE.js +57 -0
  89. package/dist/project-registry-ZJ3DVUGO.js +355 -0
  90. package/dist/real-bash-analyzer-EJAU5LW5.js +2201 -0
  91. package/dist/real-c-analyzer-HBD3FNNH.js +5942 -0
  92. package/dist/real-clean-analyzer-4EEZLPV5.js +3470 -0
  93. package/dist/real-clojure-analyzer-Q55EBOO2.js +2818 -0
  94. package/dist/real-cpp-analyzer-IVVOD25R.js +4101 -0
  95. package/dist/real-csharp-analyzer-ZBNLNJZJ.js +3298 -0
  96. package/dist/real-css-analyzer-6XRQLUN7.js +15 -0
  97. package/dist/real-dart-analyzer-OLR72EFW.js +3944 -0
  98. package/dist/real-elixir-analyzer-MQWGAH2I.js +2192 -0
  99. package/dist/real-erlang-analyzer-7BVPQEHO.js +1731 -0
  100. package/dist/real-fsharp-analyzer-C2UPFNOA.js +2390 -0
  101. package/dist/real-go-analyzer-UKGI43YS.js +4126 -0
  102. package/dist/real-graphql-analyzer-VE2EEFII.js +1442 -0
  103. package/dist/real-groovy-analyzer-W26VACFW.js +2285 -0
  104. package/dist/real-haskell-analyzer-5CVVAJRX.js +2533 -0
  105. package/dist/real-hcl-analyzer-5ZT4U43N.js +725 -0
  106. package/dist/real-html-analyzer-JWNX3C6I.js +1759 -0
  107. package/dist/real-java-analyzer-GU42VBGQ.js +4677 -0
  108. package/dist/real-javascript-analyzer-QA4QOJ6W.js +14 -0
  109. package/dist/real-json-analyzer-MPA6PRXL.js +1640 -0
  110. package/dist/real-julia-analyzer-22CWYQMN.js +2085 -0
  111. package/dist/real-kotlin-analyzer-QDZJLXXU.js +3956 -0
  112. package/dist/real-lua-analyzer-G7NHLYKS.js +1957 -0
  113. package/dist/real-makefile-analyzer-OCY3GT5N.js +920 -0
  114. package/dist/real-markdown-analyzer-TEJK2JXJ.js +1215 -0
  115. package/dist/real-matlab-analyzer-Q5SWLN7Z.js +480 -0
  116. package/dist/real-nim-analyzer-YLXSK563.js +3603 -0
  117. package/dist/real-objective-c-analyzer-D23ACC2R.js +1518 -0
  118. package/dist/real-perl-analyzer-WWTRHYDT.js +1865 -0
  119. package/dist/real-php-analyzer-JNKJHTCL.js +9368 -0
  120. package/dist/real-powershell-analyzer-XRSNQERV.js +2915 -0
  121. package/dist/real-protobuf-analyzer-3OKUCZ7T.js +867 -0
  122. package/dist/real-python-analyzer-VXAFWI72.js +4880 -0
  123. package/dist/real-r-analyzer-ZGAIDVI4.js +2596 -0
  124. package/dist/real-ruby-analyzer-X2KTLVBH.js +2429 -0
  125. package/dist/real-rust-analyzer-OFFHPL2A.js +3359 -0
  126. package/dist/real-scala-analyzer-TSTW27J6.js +3293 -0
  127. package/dist/real-scss-analyzer-AVWYPSOQ.js +1515 -0
  128. package/dist/real-solidity-analyzer-UCI2KWUB.js +2608 -0
  129. package/dist/real-sql-analyzer-F77ZMQXR.js +3840 -0
  130. package/dist/real-svelte-analyzer-SF7NRUO5.js +2532 -0
  131. package/dist/real-swift-analyzer-MN5QT3QN.js +2311 -0
  132. package/dist/real-toml-analyzer-66L7BDCQ.js +929 -0
  133. package/dist/real-typescript-analyzer-6KEMVDWQ.js +14 -0
  134. package/dist/real-vb-analyzer-VICVPOP7.js +3145 -0
  135. package/dist/real-vba-analyzer-HXLTTHKM.js +466 -0
  136. package/dist/real-vue-analyzer-QXR56CFV.js +2680 -0
  137. package/dist/real-xml-analyzer-YL465ZJW.js +2405 -0
  138. package/dist/real-yaml-analyzer-SUBCBNSI.js +3528 -0
  139. package/dist/real-zig-analyzer-HIQLZMGY.js +2430 -0
  140. package/dist/regex-search-NJKHMZNO.js +239 -0
  141. package/dist/rules-ACHPB7QU.js +152 -0
  142. package/dist/scoped-path-MJYWJZQX.js +11 -0
  143. package/dist/setup-show-NT5ZHYNE.js +15 -0
  144. package/dist/setup-wizard-G5YYR5T6.js +24 -0
  145. package/dist/symbol-search-GZJIM2J2.js +16 -0
  146. package/dist/taint-KXUHHPIE.js +202 -0
  147. package/dist/taint-analyzer-N7YLZU3N.js +163 -0
  148. package/dist/tool-handlers-OJDC35DI.js +72 -0
  149. package/dist/tool-registry-BPEJNSZG.js +17 -0
  150. package/dist/tool-validation-Q57YMMBX.js +32 -0
  151. package/dist/type-inference-QMT2RMLV.js +13 -0
  152. package/dist/vector-binary-LMY4QGAN.js +19 -0
  153. package/dist/version-ABP2TUL2.js +9 -0
  154. package/dist/wasm-NMWO3WXY.js +16 -0
  155. package/docs/EMBEDDINGS.md +132 -0
  156. package/docs/README.md +178 -0
  157. package/docs/data/m10-baseline.json +602 -0
  158. package/docs/data/m10-benchmark-baseline.json +57 -0
  159. package/docs/data/m10-benchmark-last-run.json +127 -0
  160. package/docs/data/m10-final-audit.json +215 -0
  161. package/docs/data/m12-final-audit.json +138 -0
  162. package/docs/data/m12-surface-matrix.json +50 -0
  163. package/docs/data/public-tools.json +1902 -0
  164. package/docs/indexing/DEAD-ASSETS.md +88 -0
  165. package/docs/indexing/INDEXER-REVIEW.md +634 -0
  166. package/docs/indexing/PERFORMANCE-FINDINGS.md +106 -0
  167. package/docs/indexing/README.md +427 -0
  168. package/docs/indexing/discovery-matrix.md +41 -0
  169. package/docs/indexing/embeddings.md +325 -0
  170. package/docs/indexing/environment-variables.md +77 -0
  171. package/docs/indexing/performance.md +323 -0
  172. package/docs/indexing/resume.md +345 -0
  173. package/docs/indexing/troubleshooting.md +391 -0
  174. package/docs/man/bb.1 +190 -0
  175. package/docs/tools/bb_analyze.md +147 -0
  176. package/docs/tools/bb_annotate.md +110 -0
  177. package/docs/tools/bb_annotations.md +106 -0
  178. package/docs/tools/bb_ask.md +101 -0
  179. package/docs/tools/bb_cross_language.md +103 -0
  180. package/docs/tools/bb_doc.md +169 -0
  181. package/docs/tools/bb_edit.md +185 -0
  182. package/docs/tools/bb_graph.md +169 -0
  183. package/docs/tools/bb_health.md +156 -0
  184. package/docs/tools/bb_impact.md +117 -0
  185. package/docs/tools/bb_index.md +108 -0
  186. package/docs/tools/bb_migrate.md +135 -0
  187. package/docs/tools/bb_patterns.md +140 -0
  188. package/docs/tools/bb_search.md +150 -0
  189. package/docs/tools/bb_security.md +100 -0
  190. package/docs/tools/bb_visualize.md +184 -0
  191. package/grammars/README.md +57 -0
  192. package/grammars/THIRD-PARTY-NOTICES.md +50 -0
  193. package/grammars/tree-sitter-c/LICENSE +21 -0
  194. package/grammars/tree-sitter-clojure/LICENSE.md +21 -0
  195. package/grammars/tree-sitter-cpp/LICENSE +21 -0
  196. package/grammars/tree-sitter-csharp/LICENSE +21 -0
  197. package/grammars/tree-sitter-css/LICENSE +21 -0
  198. package/grammars/tree-sitter-css/README.md +21 -0
  199. package/grammars/tree-sitter-dart/LICENSE +20 -0
  200. package/grammars/tree-sitter-dart-upstream/LICENSE +20 -0
  201. package/grammars/tree-sitter-dart-upstream/README.md +18 -0
  202. package/grammars/tree-sitter-elixir/LICENSE +176 -0
  203. package/grammars/tree-sitter-elixir/README.md +11 -0
  204. package/grammars/tree-sitter-fsharp/LICENSE +21 -0
  205. package/grammars/tree-sitter-fsharp/README.md +45 -0
  206. package/grammars/tree-sitter-graphql/LICENSE +21 -0
  207. package/grammars/tree-sitter-graphql/README.md +106 -0
  208. package/grammars/tree-sitter-groovy/LICENSE +21 -0
  209. package/grammars/tree-sitter-groovy/README.md +4 -0
  210. package/grammars/tree-sitter-haskell/LICENSE +21 -0
  211. package/grammars/tree-sitter-haskell/README.md +394 -0
  212. package/grammars/tree-sitter-hcl/CHANGELOG.md +102 -0
  213. package/grammars/tree-sitter-hcl/LICENSE +201 -0
  214. package/grammars/tree-sitter-hcl/README.md +39 -0
  215. package/grammars/tree-sitter-html/LICENSE +21 -0
  216. package/grammars/tree-sitter-html/README.md +21 -0
  217. package/grammars/tree-sitter-julia/LICENSE +21 -0
  218. package/grammars/tree-sitter-julia/README.md +24 -0
  219. package/grammars/tree-sitter-kotlin/LICENSE +9 -0
  220. package/grammars/tree-sitter-lua/LICENSE.md +21 -0
  221. package/grammars/tree-sitter-lua/README.md +29 -0
  222. package/grammars/tree-sitter-make/LICENSE +21 -0
  223. package/grammars/tree-sitter-matlab/LICENSE +19 -0
  224. package/grammars/tree-sitter-matlab/README.md +99 -0
  225. package/grammars/tree-sitter-nim/LICENSE +373 -0
  226. package/grammars/tree-sitter-nim/README.md +46 -0
  227. package/grammars/tree-sitter-objc/LICENSE +21 -0
  228. package/grammars/tree-sitter-objc/README.md +20 -0
  229. package/grammars/tree-sitter-perl/LICENSE +7 -0
  230. package/grammars/tree-sitter-perl/README.md +100 -0
  231. package/grammars/tree-sitter-powershell/LICENSE +21 -0
  232. package/grammars/tree-sitter-powershell/README.md +7 -0
  233. package/grammars/tree-sitter-proto/LICENSE +21 -0
  234. package/grammars/tree-sitter-proto/README.md +105 -0
  235. package/grammars/tree-sitter-r/LICENSE +9 -0
  236. package/grammars/tree-sitter-r/README.md +66 -0
  237. package/grammars/tree-sitter-ruby/LICENSE +22 -0
  238. package/grammars/tree-sitter-scss/LICENSE +21 -0
  239. package/grammars/tree-sitter-scss/README.md +17 -0
  240. package/grammars/tree-sitter-solidity/LICENSE +7 -0
  241. package/grammars/tree-sitter-sql/LICENSE +21 -0
  242. package/grammars/tree-sitter-typescript/LICENSE +21 -0
  243. package/grammars/tree-sitter-vba/LICENSE +21 -0
  244. package/grammars/tree-sitter-vba/README.md +738 -0
  245. package/grammars/tree-sitter-vbnet/LICENSE +21 -0
  246. package/grammars/tree-sitter-vbnet/README.md +322 -0
  247. package/grammars/tree-sitter-xml/LICENSE +19 -0
  248. package/grammars/tree-sitter-yaml/LICENSE +20 -0
  249. package/grammars/tree-sitter-yaml/README.md +21 -0
  250. package/package.json +184 -4
  251. package/wasm/dart.wasm +0 -0
  252. package/wasm/tree-sitter-bash.wasm +0 -0
  253. package/wasm/tree-sitter-c.wasm +0 -0
  254. package/wasm/tree-sitter-c_sharp.wasm +0 -0
  255. package/wasm/tree-sitter-clean.wasm +0 -0
  256. package/wasm/tree-sitter-clojure.wasm +0 -0
  257. package/wasm/tree-sitter-core_schema.wasm +0 -0
  258. package/wasm/tree-sitter-cpp.wasm +0 -0
  259. package/wasm/tree-sitter-css.wasm +0 -0
  260. package/wasm/tree-sitter-dart.wasm +0 -0
  261. package/wasm/tree-sitter-elisp.wasm +0 -0
  262. package/wasm/tree-sitter-elixir.wasm +0 -0
  263. package/wasm/tree-sitter-elm.wasm +0 -0
  264. package/wasm/tree-sitter-embedded_template.wasm +0 -0
  265. package/wasm/tree-sitter-erlang.wasm +0 -0
  266. package/wasm/tree-sitter-fsharp.wasm +0 -0
  267. package/wasm/tree-sitter-fsharp_signature.wasm +0 -0
  268. package/wasm/tree-sitter-go.wasm +0 -0
  269. package/wasm/tree-sitter-graphql.wasm +0 -0
  270. package/wasm/tree-sitter-groovy.wasm +0 -0
  271. package/wasm/tree-sitter-haskell.wasm +0 -0
  272. package/wasm/tree-sitter-hcl.wasm +0 -0
  273. package/wasm/tree-sitter-html.wasm +0 -0
  274. package/wasm/tree-sitter-java.wasm +0 -0
  275. package/wasm/tree-sitter-javascript.wasm +0 -0
  276. package/wasm/tree-sitter-json.wasm +0 -0
  277. package/wasm/tree-sitter-json_schema.wasm +0 -0
  278. package/wasm/tree-sitter-julia.wasm +0 -0
  279. package/wasm/tree-sitter-kotlin.wasm +0 -0
  280. package/wasm/tree-sitter-lua.wasm +0 -0
  281. package/wasm/tree-sitter-make.wasm +0 -0
  282. package/wasm/tree-sitter-markdown.wasm +0 -0
  283. package/wasm/tree-sitter-markdown_inline.wasm +0 -0
  284. package/wasm/tree-sitter-matlab.wasm +0 -0
  285. package/wasm/tree-sitter-nim.wasm +0 -0
  286. package/wasm/tree-sitter-objc.wasm +0 -0
  287. package/wasm/tree-sitter-ocaml.wasm +0 -0
  288. package/wasm/tree-sitter-perl.wasm +0 -0
  289. package/wasm/tree-sitter-php.wasm +0 -0
  290. package/wasm/tree-sitter-php_only.wasm +0 -0
  291. package/wasm/tree-sitter-powershell.wasm +0 -0
  292. package/wasm/tree-sitter-protobuf.wasm +0 -0
  293. package/wasm/tree-sitter-python.wasm +0 -0
  294. package/wasm/tree-sitter-ql.wasm +0 -0
  295. package/wasm/tree-sitter-r.wasm +0 -0
  296. package/wasm/tree-sitter-rescript.wasm +0 -0
  297. package/wasm/tree-sitter-ruby.wasm +0 -0
  298. package/wasm/tree-sitter-rust.wasm +0 -0
  299. package/wasm/tree-sitter-scala.wasm +0 -0
  300. package/wasm/tree-sitter-scss.wasm +0 -0
  301. package/wasm/tree-sitter-solidity.wasm +0 -0
  302. package/wasm/tree-sitter-sql.wasm +0 -0
  303. package/wasm/tree-sitter-svelte.wasm +0 -0
  304. package/wasm/tree-sitter-swift.wasm +0 -0
  305. package/wasm/tree-sitter-systemrdl.wasm +0 -0
  306. package/wasm/tree-sitter-terraform.wasm +0 -0
  307. package/wasm/tree-sitter-tlaplus.wasm +0 -0
  308. package/wasm/tree-sitter-toml.wasm +0 -0
  309. package/wasm/tree-sitter-tsx.wasm +0 -0
  310. package/wasm/tree-sitter-typescript.wasm +0 -0
  311. package/wasm/tree-sitter-vba.wasm +0 -0
  312. package/wasm/tree-sitter-vbnet.wasm +0 -0
  313. package/wasm/tree-sitter-vue.wasm +0 -0
  314. package/wasm/tree-sitter-xml.wasm +0 -0
  315. package/wasm/tree-sitter-yaml.wasm +0 -0
  316. package/wasm/tree-sitter-zig.wasm +0 -0
  317. package/wasm/tree-sitter.wasm +0 -0
  318. package/wasm/tsx.wasm +0 -0
  319. package/wasm/typescript.wasm +0 -0
@@ -0,0 +1,466 @@
1
+ import {
2
+ ASTEngine
3
+ } from "./chunk-3ZTOHHSW.js";
4
+ import "./chunk-BQ3OVQ3P.js";
5
+ import "./chunk-SK6YVHFZ.js";
6
+ import "./chunk-2BSKD7O3.js";
7
+ import "./chunk-KAET47ZL.js";
8
+ import "./chunk-KCDECRJY.js";
9
+ import "./chunk-MLKGABMK.js";
10
+
11
+ // src/ast/real-vba-analyzer.ts
12
+ var { SymbolKind, RelationshipType } = ASTEngine;
13
+ var DECLARATIONS = /* @__PURE__ */ new Map([
14
+ ["sub_declaration", SymbolKind.Method],
15
+ ["conditional_sub_declaration", SymbolKind.Method],
16
+ ["function_declaration", SymbolKind.Function],
17
+ ["conditional_function_declaration", SymbolKind.Function],
18
+ ["property_get_declaration", SymbolKind.Property],
19
+ ["property_let_declaration", SymbolKind.Property],
20
+ ["property_set_declaration", SymbolKind.Property],
21
+ ["conditional_property_declaration", SymbolKind.Property],
22
+ ["type_declaration", SymbolKind.Type],
23
+ ["enum_declaration", SymbolKind.Enum],
24
+ ["enum_member", SymbolKind.EnumMember],
25
+ ["type_member", SymbolKind.Variable],
26
+ ["event_declaration", SymbolKind.Event],
27
+ // There is no `declare_statement` in this grammar: the name is absent from all 418
28
+ // node-type ids, and the live declare productions are the Function and Sub forms
29
+ // below. The dead literal was removed after the pinned inventory was measured — a
30
+ // node type the grammar does not have makes a branch that can never match, and the
31
+ // grammar-conformance audit cannot see it because the name exists nowhere at all.
32
+ ["declare_function_statement", SymbolKind.Function],
33
+ ["declare_sub_statement", SymbolKind.Method],
34
+ ["const_declaration", SymbolKind.Constant],
35
+ ["variable_declaration", SymbolKind.Variable]
36
+ ]);
37
+ var BODY_NODES = /* @__PURE__ */ new Set([
38
+ "sub_declaration",
39
+ "function_declaration",
40
+ "property_get_declaration",
41
+ "property_let_declaration",
42
+ "property_set_declaration",
43
+ "declare_function_statement",
44
+ "declare_sub_statement",
45
+ "conditional_sub_declaration",
46
+ "conditional_function_declaration",
47
+ "conditional_property_declaration"
48
+ ]);
49
+ var TYPE_NODES = /* @__PURE__ */ new Set(["type_declaration", "enum_declaration"]);
50
+ var RealVbaAnalyzer = class {
51
+ symbols = [];
52
+ relationships = [];
53
+ imports = [];
54
+ declarations = /* @__PURE__ */ new Map();
55
+ owner = [];
56
+ callableNames = /* @__PURE__ */ new Set();
57
+ variableNames = /* @__PURE__ */ new Set();
58
+ emitted = /* @__PURE__ */ new Set();
59
+ nodeSymbols = /* @__PURE__ */ new Map();
60
+ source = "";
61
+ analyze(rootNode, content, _filePath, _context) {
62
+ this.reset(content);
63
+ const declarations = [];
64
+ this.collectDeclarations(rootNode, declarations);
65
+ for (const declaration of declarations) this.publishDeclaration(declaration);
66
+ this.walk(rootNode);
67
+ this.dedupe();
68
+ this.stampEvidence();
69
+ return {
70
+ symbols: this.symbols,
71
+ relationships: this.relationships,
72
+ imports: this.imports,
73
+ metadata: {
74
+ analysisVersion: "m1-vba-1",
75
+ hasTypeInference: false,
76
+ hasFrameworkIntelligence: false,
77
+ vbaGaps: {
78
+ extends: "VBA has no class inheritance syntax",
79
+ overrides: "VBA has no override modifier",
80
+ renders: "VBA grammar has no component-rendering construct",
81
+ mixes_in: "VBA grammar has no mixin construct",
82
+ part_of: "VBA grammar has no partial declaration construct"
83
+ },
84
+ linesOfCode: this.lineCount(content)
85
+ }
86
+ };
87
+ }
88
+ reset(content) {
89
+ this.symbols = [];
90
+ this.relationships = [];
91
+ this.imports = [];
92
+ this.declarations.clear();
93
+ this.owner = [];
94
+ this.callableNames.clear();
95
+ this.variableNames.clear();
96
+ this.emitted.clear();
97
+ this.nodeSymbols.clear();
98
+ this.source = content;
99
+ }
100
+ collectDeclarations(node, out) {
101
+ const kind = DECLARATIONS.get(node.type);
102
+ if (kind) {
103
+ const name = node.childForFieldName("name") ?? this.firstIdentifier(node);
104
+ if (name) out.push({ node, name, kind });
105
+ }
106
+ for (const child of this.children(node)) this.collectDeclarations(child, out);
107
+ }
108
+ publishDeclaration(declaration) {
109
+ const name = declaration.name.text.trim();
110
+ if (!name) return;
111
+ const symbol = {
112
+ name,
113
+ qualifiedName: name,
114
+ kind: declaration.kind,
115
+ range: this.range(declaration.node),
116
+ visibility: this.visibility(declaration.node),
117
+ isStatic: this.hasText(declaration.node, "static"),
118
+ parameters: this.parameters(declaration.node),
119
+ returnType: this.typeName(declaration.node),
120
+ metadata: {
121
+ grammarNode: declaration.node.type,
122
+ language: "vba",
123
+ ...this.hasNodeType(declaration.node, "with_events_modifier") ? { withEvents: true } : {}
124
+ }
125
+ };
126
+ this.symbols.push(symbol);
127
+ this.nodeSymbols.set(declaration.node.startIndex, symbol);
128
+ const key = this.fold(name);
129
+ if (!this.declarations.has(key)) this.declarations.set(key, symbol);
130
+ if (BODY_NODES.has(declaration.node.type)) this.callableNames.add(key);
131
+ if (declaration.kind === SymbolKind.Variable || declaration.kind === SymbolKind.Constant) {
132
+ this.variableNames.add(key);
133
+ }
134
+ }
135
+ walk(node, current) {
136
+ const declaration = this.symbolForNode(node);
137
+ const ownsChildren = declaration !== void 0 && (BODY_NODES.has(node.type) || TYPE_NODES.has(node.type));
138
+ const active = ownsChildren ? declaration : current;
139
+ if (declaration && current && declaration !== current) {
140
+ const nameNode = node.childForFieldName("name") ?? this.firstIdentifier(node) ?? node;
141
+ this.emit(RelationshipType.Contains, current.name, declaration.name, nameNode, 1);
142
+ const ownerName = current.qualifiedName ?? current.name;
143
+ const symbol = this.nodeSymbols.get(node.startIndex);
144
+ if (symbol) {
145
+ symbol.ownerName = ownerName;
146
+ symbol.ownerKind = current.kind;
147
+ symbol.qualifiedName = `${ownerName}.${symbol.name}`;
148
+ }
149
+ }
150
+ if (declaration && declaration.visibility === "public" && !current) {
151
+ this.emit(RelationshipType.Exports, "root", declaration.name, node, 1);
152
+ }
153
+ if (ownsChildren) this.owner.push(declaration);
154
+ if (node.type === "attribute_statement") this.emitAttribute(node, active);
155
+ else if (node.type === "call_statement" || node.type === "call_expression") {
156
+ this.emitCall(node, active);
157
+ } else if (node.type === "raise_event_statement") {
158
+ this.emitEventRaise(node, active);
159
+ } else if (node.type === "new_expression") {
160
+ this.emitInstantiation(node, active);
161
+ } else if (node.type === "with_statement") {
162
+ this.emitWithReceiver(node, active);
163
+ } else if (node.type === "on_error_statement") {
164
+ this.emitControlFlowRead(node.childForFieldName("target"), active, "on_error");
165
+ } else if (node.type === "redim_statement") {
166
+ this.emitControlFlowRead(node.childForFieldName("name") ?? this.firstIdentifier(node), active, "redim");
167
+ } else if (node.type === "for_statement" || node.type === "for_each_statement") {
168
+ this.emitLoopFields(node, active);
169
+ } else if (node.type === "select_statement") {
170
+ this.emitControlFlowRead(node.childForFieldName("value"), active, "select_value");
171
+ } else if (node.type === "case_clause") {
172
+ this.emitControlFlowRead(this.firstIdentifier(node), active, "case_value");
173
+ } else if (node.type === "qualified_member_expression") {
174
+ this.emitMemberReceiver(node, active);
175
+ } else if (node.type === "implements_statement") {
176
+ this.emitNamed(RelationshipType.Implements, active, node.childForFieldName("name") ?? this.firstIdentifier(node), 0.9);
177
+ } else if (node.type === "declare_function_statement" || node.type === "declare_sub_statement") {
178
+ this.emitDeclareImport(node);
179
+ } else if (node.type === "assignment_statement" || node.type === "set_statement") {
180
+ this.emitReads(node.childForFieldName("right"), active);
181
+ } else if (node.type === "as_type_clause" || node.type === "type_expression") {
182
+ if (node.parent?.type === "implements_statement") {
183
+ for (const child of this.children(node)) this.walk(child, active);
184
+ return;
185
+ }
186
+ const type = this.firstIdentifier(node);
187
+ if (type) this.emitNamed(RelationshipType.References, active, type, 0.6);
188
+ } else if (node.type === "identifier") {
189
+ this.emitIdentifierRead(node, active);
190
+ }
191
+ for (const child of this.children(node)) this.walk(child, active);
192
+ if (ownsChildren) this.owner.pop();
193
+ }
194
+ emitAttribute(node, source) {
195
+ const target = node.childForFieldName("name") ?? this.firstIdentifier(node);
196
+ if (!target) return;
197
+ this.emit(RelationshipType.Decorates, source?.name ?? "root", target.text, target, 0.8, {
198
+ attributeName: target.text,
199
+ attributeForm: "attribute_statement"
200
+ });
201
+ }
202
+ /**
203
+ * `Declare Function ... Lib "<library>"` / `Declare Sub ... Lib "<library>"` is how VBA
204
+ * binds a procedure that lives outside the project (a system DLL or a COM export). The
205
+ * fleet's `imports` names a unit's dependency on an external unit, so the row is
206
+ * root -> LIBRARY rather than root -> procedure: the procedure is declared HERE — it is
207
+ * a symbol of this module — while the LIBRARY is the external unit this module depends
208
+ * on. The target is the library text with its string delimiters removed, because a
209
+ * quoted target is not symbol-shaped; the written spelling rides in metadata, together
210
+ * with the exported alias and PtrSafe when present. Confidence is 1: the dependency is
211
+ * written in a live node and needs no resolution to be a fact about this file.
212
+ */
213
+ emitDeclareImport(node) {
214
+ const library = node.childForFieldName("library");
215
+ const target = library ? this.unquote(library.text) : "";
216
+ if (!library || !target) return;
217
+ const name = node.childForFieldName("name") ?? this.firstIdentifier(node);
218
+ const alias = node.childForFieldName("alias");
219
+ this.emit(RelationshipType.Imports, "root", target, library, 1, {
220
+ importForm: "declare-lib",
221
+ libraryName: target,
222
+ declaration: node.type,
223
+ ...name ? { procedure: name.text } : {},
224
+ ...alias ? { alias: this.unquote(alias.text) } : {},
225
+ ...this.children(node).some((child) => child.type === "ptrsafe_modifier") ? { ptrSafe: true } : {}
226
+ });
227
+ }
228
+ /**
229
+ * The grammar carries the library and alias as string literals; a dependency target is
230
+ * a NAME, so the delimiters are removed. Done without a regex deliberately: this
231
+ * analyzer stays regex-free, and a two-character trim needs none.
232
+ */
233
+ unquote(text) {
234
+ let value = text.trim();
235
+ if (value.startsWith('"')) value = value.slice(1);
236
+ if (value.endsWith('"')) value = value.slice(0, -1);
237
+ return value.trim();
238
+ }
239
+ emitCall(node, source) {
240
+ const callee = node.childForFieldName("callee") ?? node.childForFieldName("function");
241
+ const target = callee ? this.lastIdentifier(callee) : this.firstIdentifier(node);
242
+ if (!target || this.fold(target.text) === "new") return;
243
+ const receiver = callee?.childForFieldName("receiver");
244
+ const withReceiver = this.withReceiverFor(node);
245
+ this.emit(RelationshipType.Calls, source?.name ?? "root", target.text, target, this.confidence(target.text), {
246
+ qualified: callee?.text,
247
+ ...receiver ? { receiver: receiver.text } : {},
248
+ ...callee?.type === "implicit_member_expression" ? { implicitMember: true } : {},
249
+ ...withReceiver ? { withReceiver: withReceiver.text } : {}
250
+ });
251
+ }
252
+ emitWithReceiver(node, source) {
253
+ const receiver = node.childForFieldName("value");
254
+ if (!receiver) return;
255
+ this.emit(RelationshipType.Uses, source?.name ?? "root", receiver.text, receiver, this.confidence(receiver.text), {
256
+ construct: "with_receiver"
257
+ });
258
+ }
259
+ emitControlFlowRead(node, source, construct) {
260
+ if (!node) return;
261
+ const target = node.type === "identifier" ? node : this.firstIdentifier(node);
262
+ if (!target) return;
263
+ this.emit(RelationshipType.Uses, source?.name ?? "root", target.text, target, this.confidence(target.text), { construct });
264
+ }
265
+ emitLoopFields(node, source) {
266
+ const variable = node.childForFieldName("variable");
267
+ const collection = node.childForFieldName("collection");
268
+ const start = node.childForFieldName("start");
269
+ const end = node.childForFieldName("end");
270
+ if (variable) this.emitControlFlowRead(variable, source, node.type === "for_each_statement" ? "foreach_binder" : "for_binder");
271
+ if (collection) this.emitControlFlowRead(collection, source, "foreach_collection");
272
+ if (start) this.emitControlFlowRead(start, source, "for_start");
273
+ if (end) this.emitControlFlowRead(end, source, "for_end");
274
+ }
275
+ emitMemberReceiver(node, source) {
276
+ if (!source || this.hasCallAncestor(node)) return;
277
+ const receiver = node.childForFieldName("receiver");
278
+ if (!receiver || receiver.type !== "identifier") return;
279
+ this.emit(RelationshipType.Uses, source.name, receiver.text, receiver, this.confidence(receiver.text), {
280
+ construct: "member_receiver",
281
+ member: node.childForFieldName("member")?.text
282
+ });
283
+ }
284
+ withReceiverFor(node) {
285
+ let parent = node.parent;
286
+ while (parent) {
287
+ if (parent.type === "with_statement") {
288
+ return parent.childForFieldName("value");
289
+ }
290
+ if (BODY_NODES.has(parent.type)) return null;
291
+ parent = parent.parent;
292
+ }
293
+ return null;
294
+ }
295
+ emitInstantiation(node, source) {
296
+ const target = node.childForFieldName("type") ?? this.firstIdentifier(node);
297
+ if (!target) return;
298
+ this.emit(RelationshipType.Instantiates, source?.name ?? "root", target.text, target, this.confidence(target.text));
299
+ }
300
+ emitEventRaise(node, source) {
301
+ const event = node.childForFieldName("event") ?? this.firstIdentifier(node);
302
+ if (!event) return;
303
+ this.emit(RelationshipType.Calls, source?.name ?? "root", event.text, event, this.confidence(event.text), {
304
+ eventRaise: true
305
+ });
306
+ }
307
+ emitReads(node, source) {
308
+ if (!node) return;
309
+ for (const child of this.children(node)) {
310
+ if (child.type === "qualified_member_expression") {
311
+ this.emitMemberReceiver(child, source);
312
+ this.emitReads(child, source);
313
+ } else if (child.type === "identifier") {
314
+ this.emit(RelationshipType.Uses, source?.name ?? "root", child.text, child, this.confidence(child.text));
315
+ } else {
316
+ this.emitReads(child, source);
317
+ }
318
+ }
319
+ }
320
+ emitIdentifierRead(node, source) {
321
+ const parent = node.parent;
322
+ if (!parent || !source) return;
323
+ if (parent.childForFieldName("name")?.id === node.id) return;
324
+ if (parent.type === "type_expression" || parent.type === "as_type_clause") return;
325
+ if (this.hasCallAncestor(node)) return;
326
+ if (parent.type === "new_expression") return;
327
+ if (parent.type === "variable_declarator" || parent.type === "const_declarator") return;
328
+ if (parent.type === "parameter") return;
329
+ const left = parent.childForFieldName("left");
330
+ if (left?.id === node.id) return;
331
+ if (parent.type === "qualified_member_expression" && parent.childForFieldName("member")?.id !== node.id) return;
332
+ this.emit(RelationshipType.Uses, source.name, node.text, node, this.confidence(node.text));
333
+ }
334
+ emitNamed(type, source, target, confidence) {
335
+ if (target) this.emit(type, source?.name ?? "root", target.text, target, confidence);
336
+ }
337
+ emit(type, source, target, node, confidence, metadata = {}) {
338
+ const key = `${source}\0${type}\0${target}\0${node.startPosition.row + 1}`;
339
+ if (this.emitted.has(key)) return;
340
+ this.emitted.add(key);
341
+ this.relationships.push({
342
+ source,
343
+ target,
344
+ type,
345
+ confidence,
346
+ line_number: node.startPosition.row + 1,
347
+ metadata
348
+ });
349
+ }
350
+ confidence(target) {
351
+ return this.declarations.has(this.fold(target)) ? 1 : 0.6;
352
+ }
353
+ symbolForNode(node) {
354
+ return this.nodeSymbols.get(node.startIndex);
355
+ }
356
+ hasCallAncestor(node) {
357
+ let parent = node.parent;
358
+ while (parent) {
359
+ if (parent.type === "call_statement" || parent.type === "call_expression") {
360
+ const callee = parent.childForFieldName("callee") ?? parent.childForFieldName("function");
361
+ return !!callee && callee.startIndex <= node.startIndex && callee.endIndex >= node.endIndex;
362
+ }
363
+ if (parent.type === "block" || BODY_NODES.has(parent.type)) return false;
364
+ parent = parent.parent;
365
+ }
366
+ return false;
367
+ }
368
+ firstIdentifier(node) {
369
+ for (const child of this.children(node)) {
370
+ if (child.type === "identifier") return child;
371
+ const nested = this.firstIdentifier(child);
372
+ if (nested) return nested;
373
+ }
374
+ return null;
375
+ }
376
+ lastIdentifier(node) {
377
+ if (node.type === "identifier") return node;
378
+ const children = this.children(node);
379
+ for (let i = children.length - 1; i >= 0; i--) {
380
+ const child = children[i];
381
+ if (child.type === "identifier") return child;
382
+ const nested = this.lastIdentifier(child);
383
+ if (nested) return nested;
384
+ }
385
+ return null;
386
+ }
387
+ typeName(node) {
388
+ const type = node.childForFieldName("type");
389
+ return this.typeText(type);
390
+ }
391
+ typeText(node) {
392
+ if (!node) return void 0;
393
+ if (node.type === "as_type_clause") {
394
+ return this.typeText(node.childForFieldName("type"));
395
+ }
396
+ const text = node.text.trim();
397
+ return text.length > 0 ? text : void 0;
398
+ }
399
+ parameters(node) {
400
+ const list = node.childForFieldName("parameters");
401
+ if (!list) return void 0;
402
+ return this.children(list).filter((p) => p.type === "parameter").map((p) => ({
403
+ name: (p.childForFieldName("name") ?? this.firstIdentifier(p))?.text ?? "",
404
+ type: this.typeText(p.childForFieldName("type")),
405
+ isOptional: this.children(p).some((c) => c.type === "optional_modifier"),
406
+ passingMode: this.children(p).find((c) => c.type === "byref_modifier" || c.type === "byval_modifier")?.type.replace("_modifier", ""),
407
+ isParamArray: this.children(p).some((c) => c.type === "paramarray_modifier"),
408
+ defaultValue: p.childForFieldName("default_value")?.childForFieldName("value")?.text
409
+ })).filter((p) => p.name.length > 0);
410
+ }
411
+ visibility(node) {
412
+ const value = node.childForFieldName("visibility")?.text.toLowerCase();
413
+ return value === "public" || value === "private" || value === "friend" ? value : "private";
414
+ }
415
+ hasText(node, text) {
416
+ return this.children(node).some((child) => child.text.toLowerCase() === text);
417
+ }
418
+ hasNodeType(node, type) {
419
+ if (node.type === type) return true;
420
+ return this.children(node).some((child) => this.hasNodeType(child, type));
421
+ }
422
+ fold(value) {
423
+ return value.toLowerCase();
424
+ }
425
+ lineCount(value) {
426
+ let lines = 1;
427
+ for (let index = 0; index < value.length; index += 1) {
428
+ if (value[index] === "\n") lines += 1;
429
+ }
430
+ return lines;
431
+ }
432
+ children(node) {
433
+ return node.namedChildren.filter((child) => child !== null);
434
+ }
435
+ range(node) {
436
+ return {
437
+ startLine: node.startPosition.row + 1,
438
+ startColumn: node.startPosition.column,
439
+ endLine: node.endPosition.row + 1,
440
+ endColumn: node.endPosition.column,
441
+ startIndex: node.startIndex,
442
+ endIndex: node.endIndex
443
+ };
444
+ }
445
+ dedupe() {
446
+ const seen = /* @__PURE__ */ new Set();
447
+ this.relationships = this.relationships.filter((relationship) => {
448
+ const key = `${relationship.source}\0${relationship.type}\0${relationship.target}\0${relationship.line_number}`;
449
+ if (seen.has(key)) return false;
450
+ seen.add(key);
451
+ return true;
452
+ });
453
+ }
454
+ stampEvidence() {
455
+ for (const relationship of this.relationships) {
456
+ const confidence = relationship.confidence ?? 1;
457
+ relationship.metadata = {
458
+ evidenceClass: confidence < 0.7 ? "inferred" : relationship.type === RelationshipType.Imports ? "import_based" : relationship.type === RelationshipType.References || relationship.type === RelationshipType.Uses ? "usage_contextual" : "structural",
459
+ ...relationship.metadata
460
+ };
461
+ }
462
+ }
463
+ };
464
+ export {
465
+ RealVbaAnalyzer
466
+ };