@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,2818 @@
1
+ import {
2
+ clojureExecutionHead,
3
+ clojureSymName
4
+ } from "./chunk-2DE27DVC.js";
5
+ import {
6
+ ASTEngine
7
+ } from "./chunk-3ZTOHHSW.js";
8
+ import "./chunk-BQ3OVQ3P.js";
9
+ import "./chunk-SK6YVHFZ.js";
10
+ import "./chunk-2BSKD7O3.js";
11
+ import "./chunk-KAET47ZL.js";
12
+ import "./chunk-KCDECRJY.js";
13
+ import "./chunk-MLKGABMK.js";
14
+
15
+ // src/ast/real-clojure-analyzer.ts
16
+ var CLOJURE_CORE_BUILTINS = (function() {
17
+ const r = /* @__PURE__ */ Object.create(null);
18
+ const arr = [
19
+ "*",
20
+ "*'",
21
+ "*1",
22
+ "*2",
23
+ "*3",
24
+ "*data-readers*",
25
+ "*default-data-reader-fn*",
26
+ "*e",
27
+ "*print-length*",
28
+ "*print-level*",
29
+ "*print-namespace-maps*",
30
+ "*repl*",
31
+ "*verbose-defrecords*",
32
+ "+",
33
+ "+'",
34
+ "-",
35
+ "-'",
36
+ "->",
37
+ "->>",
38
+ "-cache-protocol-fn",
39
+ "-reset-methods",
40
+ ".",
41
+ "..",
42
+ "/",
43
+ "<",
44
+ "<=",
45
+ "=",
46
+ "==",
47
+ ">",
48
+ ">=",
49
+ "Double/parseDouble",
50
+ "EMPTY-NODE",
51
+ "Integer/parseInt",
52
+ "Long/parseLong",
53
+ "Math/abs",
54
+ "Math/ceil",
55
+ "Math/floor",
56
+ "Math/max",
57
+ "Math/min",
58
+ "Math/pow",
59
+ "Math/random",
60
+ "Math/round",
61
+ "Math/sqrt",
62
+ "NaN?",
63
+ "PrintWriter-on",
64
+ "StackTraceElement->vec",
65
+ "String/format",
66
+ "String/join",
67
+ "String/split",
68
+ "String/valueOf",
69
+ "System/currentTimeMillis",
70
+ "System/exit",
71
+ "System/gc",
72
+ "System/getProperty",
73
+ "System/nanoTime",
74
+ "Thread/currentThread",
75
+ "Thread/sleep",
76
+ "Throwable->map",
77
+ "UUID/randomUUID",
78
+ "abs",
79
+ "accessor",
80
+ "aclone",
81
+ "add-classpath",
82
+ "add-doc-and-meta",
83
+ "add-tap",
84
+ "add-watch",
85
+ "agent",
86
+ "agent-error",
87
+ "agent-errors",
88
+ "agent?",
89
+ "aget",
90
+ "alength",
91
+ "alias",
92
+ "all-ns",
93
+ "alter",
94
+ "alter-meta!",
95
+ "alter-var-root",
96
+ "amap",
97
+ "ancestors",
98
+ "and",
99
+ "any?",
100
+ "append!",
101
+ "apply",
102
+ "areduce",
103
+ "array-map",
104
+ "as->",
105
+ "aset",
106
+ "assert",
107
+ "assoc",
108
+ "assoc!",
109
+ "assoc-in",
110
+ "associative?",
111
+ "atom",
112
+ "atom?",
113
+ "await",
114
+ "await-for",
115
+ "await1",
116
+ "bases",
117
+ "bean",
118
+ "bigdec",
119
+ "bigint",
120
+ "biginteger",
121
+ "binding",
122
+ "binding-conveyor-fn",
123
+ "bit-and",
124
+ "bit-and-not",
125
+ "bit-clear",
126
+ "bit-count",
127
+ "bit-flip",
128
+ "bit-not",
129
+ "bit-or",
130
+ "bit-set",
131
+ "bit-shift-left",
132
+ "bit-shift-right",
133
+ "bit-test",
134
+ "bit-xor",
135
+ "boolean",
136
+ "boolean-array",
137
+ "boolean?",
138
+ "booleans",
139
+ "bound-fn",
140
+ "bound-fn*",
141
+ "bound?",
142
+ "bounded-count",
143
+ "butlast",
144
+ "byte",
145
+ "byte-array",
146
+ "byte?",
147
+ "bytes",
148
+ "bytes?",
149
+ "case",
150
+ "cast",
151
+ "cat",
152
+ "catch",
153
+ "char",
154
+ "char-array",
155
+ "char-escape-string",
156
+ "char-name-string",
157
+ "char?",
158
+ "chars",
159
+ "chunk",
160
+ "chunk-append",
161
+ "chunk-buffer",
162
+ "chunk-cons",
163
+ "chunk-first",
164
+ "chunk-next",
165
+ "chunk-rest",
166
+ "chunked-seq?",
167
+ "class",
168
+ "class?",
169
+ "clear-agent-errors",
170
+ "clojure-version",
171
+ "code-char",
172
+ "coll?",
173
+ "comment",
174
+ "commute",
175
+ "comp",
176
+ "comparator",
177
+ "compare",
178
+ "compare-and-set!",
179
+ "compile",
180
+ "complement",
181
+ "completing",
182
+ "concat",
183
+ "cond",
184
+ "cond->",
185
+ "cond->>",
186
+ "condp",
187
+ "conj",
188
+ "conj!",
189
+ "cons",
190
+ "constantly",
191
+ "construct-proxy",
192
+ "contains?",
193
+ "count",
194
+ "counted?",
195
+ "create-ns",
196
+ "create-struct",
197
+ "cycle",
198
+ "dec",
199
+ "dec'",
200
+ "decimal?",
201
+ "declare",
202
+ "dedupe",
203
+ "def",
204
+ "default-data-readers",
205
+ "definline",
206
+ "definterface",
207
+ "defmacro",
208
+ "defmethod",
209
+ "defmulti",
210
+ "defn",
211
+ "defn-",
212
+ "defonce",
213
+ "defprotocol",
214
+ "defrecord",
215
+ "defstruct",
216
+ "deftest",
217
+ "deftype",
218
+ "delay",
219
+ "delay?",
220
+ "delayed?",
221
+ "deliver",
222
+ "denominator",
223
+ "deref",
224
+ "derive",
225
+ "descendants",
226
+ "destructure",
227
+ "disj",
228
+ "disj!",
229
+ "dissoc",
230
+ "dissoc!",
231
+ "distinct",
232
+ "distinct?",
233
+ "do",
234
+ "doall",
235
+ "dorun",
236
+ "doseq",
237
+ "dosync",
238
+ "dotimes",
239
+ "doto",
240
+ "double",
241
+ "double-array",
242
+ "double?",
243
+ "doubles",
244
+ "drop",
245
+ "drop-last",
246
+ "drop-while",
247
+ "eduction",
248
+ "empty",
249
+ "empty?",
250
+ "ensure",
251
+ "ensure-reduced",
252
+ "enumeration-seq",
253
+ "equiv",
254
+ "error-handler",
255
+ "error-mode",
256
+ "eval",
257
+ "even?",
258
+ "every-pred",
259
+ "every?",
260
+ "ex-cause",
261
+ "ex-data",
262
+ "ex-info",
263
+ "ex-message",
264
+ "extend",
265
+ "extend-protocol",
266
+ "extend-type",
267
+ "extenders",
268
+ "extends?",
269
+ "false?",
270
+ "ffirst",
271
+ "file-seq",
272
+ "filter",
273
+ "filterv",
274
+ "finally",
275
+ "find",
276
+ "find-keyword",
277
+ "find-ns",
278
+ "find-protocol-impl",
279
+ "find-protocol-method",
280
+ "find-var",
281
+ "first",
282
+ "fjtask",
283
+ "flatten",
284
+ "float",
285
+ "float-array",
286
+ "float?",
287
+ "floats",
288
+ "flush",
289
+ "fn",
290
+ "fn?",
291
+ "fnext",
292
+ "fnil",
293
+ "fold",
294
+ "foldcat",
295
+ "folder",
296
+ "for",
297
+ "force",
298
+ "format",
299
+ "frequencies",
300
+ "future",
301
+ "future-call",
302
+ "future-cancel",
303
+ "future-cancelled?",
304
+ "future-done?",
305
+ "future?",
306
+ "gen-class",
307
+ "gen-interface",
308
+ "gensym",
309
+ "get",
310
+ "get-in",
311
+ "get-method",
312
+ "get-proxy-class",
313
+ "get-thread-bindings",
314
+ "get-validator",
315
+ "global-hierarchy",
316
+ "group-by",
317
+ "halt-when",
318
+ "hash",
319
+ "hash-combine",
320
+ "hash-map",
321
+ "hash-ordered-coll",
322
+ "hash-set",
323
+ "hash-unordered-coll",
324
+ "ident?",
325
+ "identical?",
326
+ "identity",
327
+ "if",
328
+ "if-let",
329
+ "if-not",
330
+ "if-some",
331
+ "ifn?",
332
+ "import",
333
+ "in-ns",
334
+ "inc",
335
+ "inc'",
336
+ "indexed?",
337
+ "infinite?",
338
+ "init-proxy",
339
+ "inst-ms",
340
+ "inst?",
341
+ "instance?",
342
+ "int",
343
+ "int-array",
344
+ "int?",
345
+ "integer?",
346
+ "interleave",
347
+ "intern",
348
+ "interpose",
349
+ "into",
350
+ "into-array",
351
+ "ints",
352
+ "io!",
353
+ "is",
354
+ "isa?",
355
+ "iterate",
356
+ "iteration",
357
+ "iterator-reduce!",
358
+ "iterator-seq",
359
+ "java.util.Date",
360
+ "join",
361
+ "juxt",
362
+ "keep",
363
+ "keep-indexed",
364
+ "key",
365
+ "keys",
366
+ "keyword",
367
+ "keyword?",
368
+ "last",
369
+ "lazy-cat",
370
+ "lazy-seq",
371
+ "let",
372
+ "letfn",
373
+ "line-seq",
374
+ "list",
375
+ "list*",
376
+ "list?",
377
+ "load",
378
+ "load-file",
379
+ "load-reader",
380
+ "load-string",
381
+ "loaded-libs",
382
+ "locking",
383
+ "long",
384
+ "long-array",
385
+ "longs",
386
+ "loop",
387
+ "lower-case",
388
+ "macroexpand",
389
+ "macroexpand-1",
390
+ "make-array",
391
+ "make-hierarchy",
392
+ "map",
393
+ "map-entry?",
394
+ "map-indexed",
395
+ "map?",
396
+ "mapcat",
397
+ "mapv",
398
+ "max",
399
+ "max-key",
400
+ "memfn",
401
+ "memoize",
402
+ "merge",
403
+ "merge-with",
404
+ "meta",
405
+ "method-sig",
406
+ "methods",
407
+ "min",
408
+ "min-key",
409
+ "mix-collection-hash",
410
+ "mk-am",
411
+ "mk-bound-fn",
412
+ "mod",
413
+ "monitor-enter",
414
+ "monitor-exit",
415
+ "monoid",
416
+ "munge",
417
+ "name",
418
+ "namespace",
419
+ "namespace-munge",
420
+ "nat-int?",
421
+ "neg-int?",
422
+ "neg?",
423
+ "new",
424
+ "newline",
425
+ "next",
426
+ "nfirst",
427
+ "nil?",
428
+ "nnext",
429
+ "not",
430
+ "not-any?",
431
+ "not-empty",
432
+ "not-every?",
433
+ "not=",
434
+ "ns",
435
+ "ns-aliases",
436
+ "ns-imports",
437
+ "ns-interns",
438
+ "ns-map",
439
+ "ns-name",
440
+ "ns-publics",
441
+ "ns-refers",
442
+ "ns-resolve",
443
+ "ns-unalias",
444
+ "ns-unmap",
445
+ "nth",
446
+ "nthnext",
447
+ "nthrest",
448
+ "num",
449
+ "number?",
450
+ "numerator",
451
+ "object-array",
452
+ "odd?",
453
+ "or",
454
+ "parents",
455
+ "parse-boolean",
456
+ "parse-double",
457
+ "parse-long",
458
+ "parse-uuid",
459
+ "partial",
460
+ "partition",
461
+ "partition-all",
462
+ "partition-by",
463
+ "partitionv",
464
+ "partitionv-all",
465
+ "pcalls",
466
+ "peek",
467
+ "persistent!",
468
+ "pmap",
469
+ "pool",
470
+ "pop",
471
+ "pop!",
472
+ "pop-thread-bindings",
473
+ "pos-int?",
474
+ "pos?",
475
+ "pr",
476
+ "pr-on",
477
+ "pr-str",
478
+ "prefer-method",
479
+ "prefers",
480
+ "primitives-classnames",
481
+ "print",
482
+ "print-ctor",
483
+ "print-simple",
484
+ "print-str",
485
+ "printf",
486
+ "println",
487
+ "println-str",
488
+ "prn",
489
+ "prn-str",
490
+ "process-annotation",
491
+ "promise",
492
+ "promise?",
493
+ "proxy",
494
+ "proxy-call-with-super",
495
+ "proxy-mappings",
496
+ "proxy-name",
497
+ "proxy-super",
498
+ "push-thread-bindings",
499
+ "pvalues",
500
+ "qualified-ident?",
501
+ "qualified-keyword?",
502
+ "qualified-symbol?",
503
+ "quot",
504
+ "quote",
505
+ "rand",
506
+ "rand-int",
507
+ "rand-nth",
508
+ "random-sample",
509
+ "random-uuid",
510
+ "range",
511
+ "ratio?",
512
+ "rational?",
513
+ "rationalize",
514
+ "re-find",
515
+ "re-groups",
516
+ "re-matcher",
517
+ "re-matches",
518
+ "re-pattern",
519
+ "re-seq",
520
+ "read",
521
+ "read+string",
522
+ "read-line",
523
+ "read-string",
524
+ "reader-conditional",
525
+ "reader-conditional?",
526
+ "realized?",
527
+ "record?",
528
+ "recur",
529
+ "reduce",
530
+ "reduce-kv",
531
+ "reduced",
532
+ "reduced?",
533
+ "reducer",
534
+ "reductions",
535
+ "ref",
536
+ "ref-history-count",
537
+ "ref-max-history",
538
+ "ref-min-history",
539
+ "ref-set",
540
+ "ref?",
541
+ "refer",
542
+ "refer-clojure",
543
+ "regexp?",
544
+ "reify",
545
+ "release-pending-sends",
546
+ "rem",
547
+ "remove",
548
+ "remove-all-methods",
549
+ "remove-method",
550
+ "remove-ns",
551
+ "remove-tap",
552
+ "remove-watch",
553
+ "repeat",
554
+ "repeatedly",
555
+ "replace",
556
+ "replicate",
557
+ "req!",
558
+ "require",
559
+ "requiring-resolve",
560
+ "reset!",
561
+ "reset-meta!",
562
+ "reset-vals!",
563
+ "resolve",
564
+ "rest",
565
+ "restart-agent",
566
+ "resultset-seq",
567
+ "reverse",
568
+ "reversible?",
569
+ "rseq",
570
+ "rsubseq",
571
+ "run!",
572
+ "satisfies?",
573
+ "second",
574
+ "select-keys",
575
+ "send",
576
+ "send-off",
577
+ "send-via",
578
+ "seq",
579
+ "seq-to-map-for-destructuring",
580
+ "seq?",
581
+ "seqable?",
582
+ "seque",
583
+ "sequence",
584
+ "sequential?",
585
+ "set",
586
+ "set!",
587
+ "set-agent-send-executor!",
588
+ "set-agent-send-off-executor!",
589
+ "set-error-handler!",
590
+ "set-error-mode!",
591
+ "set-validator!",
592
+ "set?",
593
+ "shift-left",
594
+ "shift-right",
595
+ "short",
596
+ "short-array",
597
+ "short?",
598
+ "shorts",
599
+ "shuffle",
600
+ "shutdown-agents",
601
+ "simple-ident?",
602
+ "simple-keyword?",
603
+ "simple-symbol?",
604
+ "slurp",
605
+ "some",
606
+ "some->",
607
+ "some->>",
608
+ "some-fn",
609
+ "some-vals",
610
+ "some?",
611
+ "sort",
612
+ "sort-by",
613
+ "sorted-map",
614
+ "sorted-map-by",
615
+ "sorted-set",
616
+ "sorted-set-by",
617
+ "sorted?",
618
+ "special-symbol?",
619
+ "spit",
620
+ "split",
621
+ "split-at",
622
+ "split-with",
623
+ "splitv-at",
624
+ "spread",
625
+ "str",
626
+ "stream-into!",
627
+ "stream-reduce!",
628
+ "stream-seq!",
629
+ "stream-transduce!",
630
+ "string?",
631
+ "struct",
632
+ "struct-map",
633
+ "subs",
634
+ "subseq",
635
+ "subvec",
636
+ "supers",
637
+ "swap!",
638
+ "swap-vals!",
639
+ "symbol",
640
+ "symbol?",
641
+ "sync",
642
+ "syntax-quote",
643
+ "tagged-literal",
644
+ "tagged-literal?",
645
+ "take",
646
+ "take-last",
647
+ "take-nth",
648
+ "take-while",
649
+ "tap->",
650
+ "tap>",
651
+ "test",
652
+ "testing",
653
+ "the-ns",
654
+ "thread-bound?",
655
+ "throw",
656
+ "time",
657
+ "to-array",
658
+ "to-array-2d",
659
+ "trampoline",
660
+ "transduce",
661
+ "transient",
662
+ "tree-seq",
663
+ "trim",
664
+ "trim-newline",
665
+ "triml",
666
+ "trimr",
667
+ "true?",
668
+ "try",
669
+ "type",
670
+ "unchecked-add",
671
+ "unchecked-add-int",
672
+ "unchecked-byte",
673
+ "unchecked-char",
674
+ "unchecked-dec",
675
+ "unchecked-dec-int",
676
+ "unchecked-divide",
677
+ "unchecked-divide-int",
678
+ "unchecked-double",
679
+ "unchecked-float",
680
+ "unchecked-inc",
681
+ "unchecked-inc-int",
682
+ "unchecked-int",
683
+ "unchecked-long",
684
+ "unchecked-multiply",
685
+ "unchecked-multiply-int",
686
+ "unchecked-negate",
687
+ "unchecked-negate-int",
688
+ "unchecked-remainder",
689
+ "unchecked-remainder-int",
690
+ "unchecked-short",
691
+ "unchecked-subtract",
692
+ "unchecked-subtract-int",
693
+ "underive",
694
+ "unquote",
695
+ "unquote-splicing",
696
+ "unreduced",
697
+ "unsigned-bit-shift-right",
698
+ "update",
699
+ "update-in",
700
+ "update-keys",
701
+ "update-proxy",
702
+ "update-vals",
703
+ "upper-case",
704
+ "uri?",
705
+ "use",
706
+ "uuid?",
707
+ "val",
708
+ "vals",
709
+ "var",
710
+ "var-get",
711
+ "var-set",
712
+ "var?",
713
+ "vary-meta",
714
+ "vec",
715
+ "vector",
716
+ "vector-of",
717
+ "vector?",
718
+ "volatile!",
719
+ "volatile?",
720
+ "vreset!",
721
+ "vswap!",
722
+ "when",
723
+ "when-first",
724
+ "when-let",
725
+ "when-not",
726
+ "when-some",
727
+ "while",
728
+ "with-bindings",
729
+ "with-bindings*",
730
+ "with-in-str",
731
+ "with-loading-context",
732
+ "with-local-vars",
733
+ "with-meta",
734
+ "with-open",
735
+ "with-out-str",
736
+ "with-precision",
737
+ "with-redefs",
738
+ "with-redefs-fn",
739
+ "xml-seq",
740
+ "zero?",
741
+ "zipmap"
742
+ ];
743
+ for (let i = 0; i < arr.length; i++) r[arr[i]] = true;
744
+ return r;
745
+ })();
746
+ var HOF_BUILTINS = (function() {
747
+ const r = /* @__PURE__ */ Object.create(null);
748
+ const arr = ["apply", "map", "reduce", "filter", "comp", "partial"];
749
+ for (let i = 0; i < arr.length; i++) r[arr[i]] = true;
750
+ return r;
751
+ })();
752
+ var STM_BUILTINS = (function() {
753
+ const r = /* @__PURE__ */ Object.create(null);
754
+ const arr = ["swap!", "reset!", "deref", "alter", "commute", "dosync", "ref", "atom", "agent", "send", "send-off"];
755
+ for (let i = 0; i < arr.length; i++) r[arr[i]] = true;
756
+ return r;
757
+ })();
758
+ var COMPLEXITY_BUILTINS = (function() {
759
+ const r = /* @__PURE__ */ Object.create(null);
760
+ const arr = ["if", "if-not", "if-let", "if-some", "when", "when-not", "when-let", "when-some", "cond", "condp", "case", "for", "while", "loop", "cond->", "cond->>", "some->", "some->>"];
761
+ for (let i = 0; i < arr.length; i++) r[arr[i]] = true;
762
+ return r;
763
+ })();
764
+ var IMPURE_BUILTINS = (function() {
765
+ const r = /* @__PURE__ */ Object.create(null);
766
+ const arr = ["println", "print", "def", "alter-var-root", "with-redefs", "set!", "swap!", "reset!", "alter"];
767
+ for (let i = 0; i < arr.length; i++) r[arr[i]] = true;
768
+ return r;
769
+ })();
770
+ var METHOD_IMPL_PARENT_FORMS = (function() {
771
+ const r = /* @__PURE__ */ Object.create(null);
772
+ const arr = ["defrecord", "deftype", "reify", "extend-type", "extend-protocol", "proxy", "defprotocol", "definterface"];
773
+ for (let i = 0; i < arr.length; i++) r[arr[i]] = true;
774
+ return r;
775
+ })();
776
+ function defNameNodeOf(node) {
777
+ let head = 0;
778
+ while (head < node.namedChildCount && node.namedChild(head)?.type === "meta_lit") head++;
779
+ let i = head + 1;
780
+ while (i < node.namedChildCount) {
781
+ const c = node.namedChild(i);
782
+ if (!c) return null;
783
+ if (c.type === "meta_lit") {
784
+ let inner = null;
785
+ for (let k = 0; k < c.namedChildCount; k++) {
786
+ const cand = c.namedChild(k);
787
+ if (cand && cand.type === "sym_lit") {
788
+ inner = cand;
789
+ break;
790
+ }
791
+ }
792
+ if (inner) return inner;
793
+ i++;
794
+ continue;
795
+ }
796
+ return c.type === "sym_lit" ? c : null;
797
+ }
798
+ return null;
799
+ }
800
+ function isPublishableName(name) {
801
+ if (name.length === 0) return false;
802
+ for (let i = 0; i < name.length; i++) {
803
+ const c = name.charCodeAt(i);
804
+ if (c === 32 || c === 9 || c === 10 || c === 13) return false;
805
+ if (c === 34 || c === 40 || c === 41 || c === 91 || c === 93 || c === 123 || c === 125 || c === 35 || c === 59) return false;
806
+ }
807
+ return true;
808
+ }
809
+ function isDefLikeHead(head) {
810
+ if (head.length < 3) return false;
811
+ if (head.charCodeAt(0) !== 100 || head.charCodeAt(1) !== 101 || head.charCodeAt(2) !== 102) return false;
812
+ if (head.length === 3) return true;
813
+ const c3 = head.charCodeAt(3);
814
+ if (c3 !== 45 && c3 !== 95) {
815
+ if (head.startsWith("default") || head.startsWith("define")) return false;
816
+ return true;
817
+ }
818
+ return true;
819
+ }
820
+ function staticInteropMember(head) {
821
+ const slash = head.lastIndexOf("/");
822
+ if (slash <= 0) return null;
823
+ const member = head.slice(slash + 1);
824
+ if (member.length === 0) return null;
825
+ const afterDot = head.charCodeAt(slash + 1) === 46;
826
+ const beforeDot = head.charCodeAt(slash - 1) === 46;
827
+ if (afterDot) {
828
+ const m = head.slice(slash + 2);
829
+ return m.length > 0 && head.slice(0, slash).length > 0 ? m : null;
830
+ }
831
+ if (beforeDot) {
832
+ const cls = head.slice(0, slash - 1);
833
+ return member.length > 0 && cls.length > 0 ? member : null;
834
+ }
835
+ return null;
836
+ }
837
+ function staticInteropClass(head) {
838
+ const slash = head.lastIndexOf("/");
839
+ if (slash <= 0) return null;
840
+ if (staticInteropMember(head) === null) return null;
841
+ const cls = head.charCodeAt(slash + 1) === 46 ? head.slice(0, slash) : head.slice(0, slash - 1);
842
+ return cls.length > 0 ? cls : null;
843
+ }
844
+ var isAnonArgShorthand = (s) => {
845
+ if (s.length === 0) return false;
846
+ if (s.charCodeAt(0) !== 37) return false;
847
+ if (s.length === 1) return true;
848
+ const c1 = s.charCodeAt(1);
849
+ if (c1 === 38) return s.length === 2;
850
+ if (c1 < 48 || c1 > 57) return false;
851
+ for (let i = 2; i < s.length; i++) {
852
+ const c = s.charCodeAt(i);
853
+ if (c < 48 || c > 57) return false;
854
+ }
855
+ return true;
856
+ };
857
+ var CLOJURE_SPECIAL_FORMS = /* @__PURE__ */ new Set([
858
+ "def",
859
+ "do",
860
+ "fn",
861
+ "fn*",
862
+ "if",
863
+ "if*",
864
+ "let",
865
+ "let*",
866
+ "quote",
867
+ "quote*",
868
+ "var",
869
+ "var*",
870
+ "recur",
871
+ "recur*",
872
+ "throw",
873
+ "throw*",
874
+ "try",
875
+ "try*",
876
+ "catch",
877
+ "catch*",
878
+ "finally",
879
+ "new",
880
+ "new*",
881
+ "set!",
882
+ "monitor-enter",
883
+ "monitor-exit",
884
+ "case*",
885
+ "letfn*",
886
+ "loop*",
887
+ ".",
888
+ "&"
889
+ ]);
890
+ function endsWithIgnoreCase(s, suffix) {
891
+ if (s.length < suffix.length) return false;
892
+ return s.slice(s.length - suffix.length).toLowerCase() === suffix.toLowerCase();
893
+ }
894
+ function whitespaceTokens(s) {
895
+ const out = [];
896
+ let cur = "";
897
+ for (let i = 0; i < s.length; i++) {
898
+ const code = s.charCodeAt(i);
899
+ if (code <= 32 || code === 160) {
900
+ if (cur.length > 0) {
901
+ out.push(cur);
902
+ cur = "";
903
+ }
904
+ } else cur += s[i];
905
+ }
906
+ if (cur.length > 0) out.push(cur);
907
+ return out;
908
+ }
909
+ function carriesPrivateToken(s) {
910
+ for (const tok of whitespaceTokens(s)) {
911
+ let t = tok;
912
+ while (t.startsWith("^")) t = t.slice(1);
913
+ while (t.endsWith("}")) t = t.slice(0, -1);
914
+ if (t === ":private" || t === "private") return true;
915
+ }
916
+ return false;
917
+ }
918
+ function splitOnNamespaceSeparators(s) {
919
+ const out = [];
920
+ let start = 0;
921
+ let i = 0;
922
+ while (i < s.length) {
923
+ const c = s[i];
924
+ let len = 0;
925
+ if (c === "/" || c === ".") len = 1;
926
+ else if (c === ":") len = s[i + 1] === ":" ? 2 : 1;
927
+ if (len > 0) {
928
+ out.push(s.slice(start, i));
929
+ i += len;
930
+ start = i;
931
+ } else i += 1;
932
+ }
933
+ out.push(s.slice(start));
934
+ return out;
935
+ }
936
+ var RealClojureAnalyzer = class {
937
+ analyze(rootNode, content, filePath) {
938
+ if (endsWithIgnoreCase(filePath, ".edn")) return this.dataOnlyResult(content);
939
+ const symbols = [];
940
+ const relationships = [];
941
+ const imports = [];
942
+ const exports = [];
943
+ const exportNamespaces = [];
944
+ const overrideCandidates = [];
945
+ const renderCandidates = [];
946
+ const errors = [];
947
+ const frameworks = {};
948
+ const patterns = {};
949
+ let currentNamespace = "user";
950
+ let sawNamespaceForm = false;
951
+ let namespaceAliases = /* @__PURE__ */ Object.create(null);
952
+ const referSegments = [];
953
+ const openReferSegment = (start) => {
954
+ let seg = referSegments[referSegments.length - 1];
955
+ if (!seg || seg.start !== start || seg.end !== Infinity) {
956
+ seg = { start, end: Infinity, names: /* @__PURE__ */ Object.create(null) };
957
+ referSegments.push(seg);
958
+ }
959
+ return seg.names;
960
+ };
961
+ let referTable = openReferSegment(0);
962
+ const referAt = (name, pos) => {
963
+ for (const seg of referSegments) if (pos >= seg.start && pos < seg.end) return seg.names[name] || "";
964
+ return "";
965
+ };
966
+ let activeFunction = null;
967
+ let totalCyclomaticComplexity = 0;
968
+ const readCondRanges = [];
969
+ const readCondOf = (pos) => {
970
+ for (let i = 0; i < readCondRanges.length; i++) {
971
+ const r = readCondRanges[i];
972
+ if (pos >= r.start && pos <= r.end) return r.start;
973
+ }
974
+ return 0;
975
+ };
976
+ if (rootNode.hasError) {
977
+ errors.push({
978
+ message: "Syntax Error bypassed",
979
+ range: this.nodeToRange(rootNode),
980
+ severity: "warning"
981
+ });
982
+ }
983
+ const symName = (node) => {
984
+ return clojureSymName(node);
985
+ };
986
+ const attrMapHasPrivate = (node, nameNode) => {
987
+ if (!nameNode) return false;
988
+ for (let i = 0; i < node.namedChildCount; i++) {
989
+ const c = node.namedChild(i);
990
+ if (!c || c.startIndex <= nameNode.startIndex) continue;
991
+ if (c.type === "vec_lit" || c.type === "list_lit") break;
992
+ if (c.type === "str_lit") continue;
993
+ if (c.type === "map_lit") {
994
+ const hasKey = (n) => {
995
+ if (n.type === "kwd_lit" && n.text === ":private") return true;
996
+ for (let k = 0; k < n.namedChildCount; k++) {
997
+ const kk = n.namedChild(k);
998
+ if (kk && hasKey(kk)) return true;
999
+ }
1000
+ return false;
1001
+ };
1002
+ if (hasKey(c)) return true;
1003
+ }
1004
+ }
1005
+ return false;
1006
+ };
1007
+ const metaHasPrivate = (nd) => {
1008
+ if (!nd) return false;
1009
+ const scan = (n) => {
1010
+ if (n.type === "kwd_lit" && n.text === ":private") return true;
1011
+ for (let i = 0; i < n.namedChildCount; i++) {
1012
+ const c = n.namedChild(i);
1013
+ if (c && scan(c)) return true;
1014
+ }
1015
+ return false;
1016
+ };
1017
+ if ((nd.type === "sym_lit" || nd.type === "sym_name") && carriesPrivateToken(nd.text ?? "")) return true;
1018
+ for (let i = 0; i < nd.namedChildCount; i++) {
1019
+ const c = nd.namedChild(i);
1020
+ if (c && (c.type === "meta_lit" || c.type === "old_meta_lit") && scan(c)) return true;
1021
+ }
1022
+ if (nd.type === "meta_lit" || nd.type === "old_meta_lit") return scan(nd);
1023
+ return false;
1024
+ };
1025
+ const formNameOf = (listNode) => {
1026
+ const first = executionHead(listNode);
1027
+ if (!first) return "";
1028
+ if (first.type !== "sym_lit") return "";
1029
+ return symName(first);
1030
+ };
1031
+ const clauseNameOf = (listNode) => {
1032
+ const first = executionHead(listNode);
1033
+ if (first && first.type === "kwd_lit") return first.childForFieldName("name")?.text || "";
1034
+ return "";
1035
+ };
1036
+ const extractParams = (fnNode) => {
1037
+ const params = [];
1038
+ if (!fnNode) return params;
1039
+ const seen = /* @__PURE__ */ new Set();
1040
+ const collectBinding = (binding) => {
1041
+ if (binding.type === "sym_lit") {
1042
+ const name = symName(binding);
1043
+ if (!name || name === "&" || seen.has(name)) return;
1044
+ seen.add(name);
1045
+ params.push({ name, type: "Any" });
1046
+ return;
1047
+ }
1048
+ if (binding.type === "vec_lit") {
1049
+ for (let i = 0; i < binding.namedChildCount; i++) {
1050
+ const c = binding.namedChild(i);
1051
+ if (c) collectBinding(c);
1052
+ }
1053
+ return;
1054
+ }
1055
+ if (binding.type === "map_lit") {
1056
+ for (let i = 0; i < binding.namedChildCount; i++) {
1057
+ const k = binding.namedChild(i);
1058
+ if (!k) continue;
1059
+ if (k.type === "kwd_lit") {
1060
+ const kw = k.childForFieldName("name")?.text || "";
1061
+ if (kw === "keys" || kw === "strs" || kw === "syms") {
1062
+ const v = binding.namedChild(i + 1);
1063
+ if (v && (v.type === "vec_lit" || v.type === "sym_lit")) {
1064
+ collectBinding(v);
1065
+ i++;
1066
+ }
1067
+ } else if (kw === "as") {
1068
+ const v = binding.namedChild(i + 1);
1069
+ if (v) {
1070
+ collectBinding(v);
1071
+ i++;
1072
+ }
1073
+ } else if (kw === "or") {
1074
+ i++;
1075
+ }
1076
+ } else if (k.type === "sym_lit") {
1077
+ collectBinding(k);
1078
+ }
1079
+ }
1080
+ return;
1081
+ }
1082
+ };
1083
+ let directVec = null;
1084
+ const arityVecs = [];
1085
+ for (let i = 0; i < fnNode.namedChildCount; i++) {
1086
+ const c = fnNode.namedChild(i);
1087
+ if (!c) continue;
1088
+ if (c.type === "vec_lit") {
1089
+ if (!directVec) directVec = c;
1090
+ } else if (c.type === "list_lit" && c.namedChild(0)?.type === "vec_lit") arityVecs.push(c.namedChild(0));
1091
+ }
1092
+ if (directVec) collectBinding(directVec);
1093
+ else for (const v of arityVecs) collectBinding(v);
1094
+ return params;
1095
+ };
1096
+ const REQUIRED_LIB_PATTERNS = [
1097
+ ["ring.adapter", "Ring"],
1098
+ ["ring.util", "Ring"],
1099
+ ["ring.middleware", "Ring"],
1100
+ ["compojure.core", "Compojure"],
1101
+ ["compojure.route", "Compojure"],
1102
+ ["reagent.core", "Reagent"],
1103
+ ["re-frame.core", "Re-frame"],
1104
+ ["datomic.api", "Datomic"],
1105
+ ["clojure.test", "Clojure.test"],
1106
+ ["clojure.core.async", "Core.async"]
1107
+ ];
1108
+ const seenRelKeys = /* @__PURE__ */ new Set();
1109
+ const relOrigins = /* @__PURE__ */ new Map();
1110
+ const pushRel = (source, target, type, confidence, metadata = {}, line, callArity, origin) => {
1111
+ const key = `${source}|${type}|${target}|${callArity ?? ""}|${line ?? ""}`;
1112
+ if (seenRelKeys.has(key)) return;
1113
+ seenRelKeys.add(key);
1114
+ if (typeof origin === "number") relOrigins.set(relationships.length, origin);
1115
+ const rel = {
1116
+ source,
1117
+ target,
1118
+ type,
1119
+ confidence,
1120
+ metadata: callArity === void 0 ? metadata : { ...metadata, callArity },
1121
+ ...typeof line === "number" && line > 0 ? { line_number: line } : {}
1122
+ };
1123
+ relationships.push(rel);
1124
+ };
1125
+ const resolveQualified = (name) => {
1126
+ const slash = name.indexOf("/");
1127
+ if (slash <= 0) return name;
1128
+ const alias = name.slice(0, slash);
1129
+ const rest = name.slice(slash + 1);
1130
+ const resolved = namespaceAliases[alias];
1131
+ return resolved ? `${resolved}/${rest}` : name;
1132
+ };
1133
+ const resolveCallee = (head, formName) => {
1134
+ if (head && head.type === "sym_lit") {
1135
+ const nsNode = head.childForFieldName("namespace");
1136
+ const nameNode = head.childForFieldName("name");
1137
+ if (nsNode && nameNode) {
1138
+ const alias = nsNode.text;
1139
+ const nm = nameNode.text;
1140
+ const resolved = namespaceAliases[alias];
1141
+ return { alias, name: nm, target: resolved ? `${resolved}/${nm}` : `${alias}/${nm}` };
1142
+ }
1143
+ }
1144
+ return { alias: "", name: formName, target: formName };
1145
+ };
1146
+ const callArityOf = (list) => {
1147
+ const head = executionHead(list);
1148
+ if (!head) return 0;
1149
+ let n = 0;
1150
+ for (let i = 0; i < list.namedChildCount; i++) {
1151
+ const c = list.namedChild(i);
1152
+ if (!c || c.type === "comment" || c.type === "dis_expr") continue;
1153
+ if (c.startIndex > head.startIndex) n++;
1154
+ }
1155
+ return n;
1156
+ };
1157
+ const stripCommentText = (text) => {
1158
+ let i = 0;
1159
+ while (i < text.length && text[i] === ";") i++;
1160
+ return text.slice(i).trim();
1161
+ };
1162
+ const stripDocstringText = (text) => {
1163
+ const t = text.trim();
1164
+ if (t.length >= 2 && t.startsWith('"') && t.endsWith('"')) return t.slice(1, -1);
1165
+ return t;
1166
+ };
1167
+ const leadingCommentTexts = (n) => {
1168
+ const out = [];
1169
+ let prev = n.previousNamedSibling;
1170
+ let anchorRow = n.startPosition.row;
1171
+ while (prev && prev.type === "comment") {
1172
+ if (prev.startPosition.row !== anchorRow - 1) break;
1173
+ if (!prev.text.startsWith(";;")) break;
1174
+ const before = prev.previousNamedSibling;
1175
+ if (before) {
1176
+ const beforeEndRow = before.type === "comment" ? before.endPosition.row - 1 : before.endPosition.row;
1177
+ if (before.startPosition.row === prev.startPosition.row) break;
1178
+ if (beforeEndRow === prev.startPosition.row) break;
1179
+ }
1180
+ const t = stripCommentText(prev.text);
1181
+ if (t.length > 0) out.unshift(t);
1182
+ anchorRow = prev.startPosition.row;
1183
+ prev = prev.previousNamedSibling;
1184
+ }
1185
+ return out;
1186
+ };
1187
+ const docstringOf = (formNode, style) => {
1188
+ if (style === "always") {
1189
+ const c2 = formNode.namedChild(2);
1190
+ return c2 && c2.type === "str_lit" ? stripDocstringText(c2.text) : "";
1191
+ }
1192
+ if (style === "def") {
1193
+ const c2 = formNode.namedChild(2);
1194
+ const c3 = formNode.namedChild(3);
1195
+ return c2 && c2.type === "str_lit" && c3 ? stripDocstringText(c2.text) : "";
1196
+ }
1197
+ for (let i = 2; i < formNode.namedChildCount; i++) {
1198
+ const c = formNode.namedChild(i);
1199
+ if (!c) continue;
1200
+ if (c.type === "str_lit") {
1201
+ const next = formNode.namedChild(i + 1);
1202
+ const beforeParams = next !== null && (next.type === "vec_lit" || next.type === "list_lit" && next.namedChild(0)?.type === "vec_lit");
1203
+ return beforeParams ? stripDocstringText(c.text) : "";
1204
+ }
1205
+ if (c.type === "vec_lit" || c.type === "list_lit") return "";
1206
+ }
1207
+ return "";
1208
+ };
1209
+ const attachDocs = (sym, formNode, style) => {
1210
+ const doc = docstringOf(formNode, style);
1211
+ const comments = leadingCommentTexts(formNode);
1212
+ if (doc) {
1213
+ sym.comments = comments.length > 0 ? [...comments, doc] : [doc];
1214
+ sym.docstring = doc;
1215
+ } else if (comments.length > 0) {
1216
+ sym.comments = comments;
1217
+ sym.docstring = comments.join(" ");
1218
+ }
1219
+ };
1220
+ const pushImport = (fromNs, lib, line, extra) => {
1221
+ if (!fromNs || !lib || fromNs === lib) return;
1222
+ pushRel(
1223
+ fromNs,
1224
+ lib,
1225
+ ASTEngine.RelationshipType.Imports,
1226
+ 1,
1227
+ { clojureSpecific: true, isLibraryDep: true, isImport: true, evidenceClass: "structural", ...extra ?? {} },
1228
+ line
1229
+ );
1230
+ };
1231
+ const isTopLevelDirective = (n) => {
1232
+ for (let p = n.parent; p; p = p.parent) {
1233
+ if (p.type === "source") return true;
1234
+ if (p.type === "list_lit" || p.type === "vec_lit" || p.type === "map_lit" || p.type === "set_lit") return false;
1235
+ }
1236
+ return false;
1237
+ };
1238
+ const handleLibNode = (rawNode) => {
1239
+ const spec = rawNode.type === "quoting_lit" ? rawNode.namedChild(0) ?? rawNode : rawNode;
1240
+ if (spec.type === "read_cond_lit" || spec.type === "splicing_read_cond_lit") {
1241
+ for (let i = 0; i < spec.namedChildCount; i++) {
1242
+ const c = spec.namedChild(i);
1243
+ if (!c) continue;
1244
+ if (c.type === "vec_lit" || c.type === "list_lit" || c.type === "sym_lit" || c.type === "quoting_lit" || c.type === "read_cond_lit" || c.type === "splicing_read_cond_lit") handleLibNode(c);
1245
+ }
1246
+ return;
1247
+ }
1248
+ if (spec.type === "vec_lit") {
1249
+ let libNameNode = spec.namedChild(0);
1250
+ while (libNameNode && libNameNode.type === "meta_lit") {
1251
+ let inner = null;
1252
+ for (let k = 0; k < libNameNode.namedChildCount; k++) {
1253
+ const cand = libNameNode.namedChild(k);
1254
+ if (cand && cand.type === "sym_lit") {
1255
+ inner = cand;
1256
+ break;
1257
+ }
1258
+ }
1259
+ libNameNode = inner;
1260
+ }
1261
+ const libName = libNameNode && libNameNode.type === "str_lit" ? stripDocstringText(libNameNode.text) : symName(libNameNode);
1262
+ if (!libName) return;
1263
+ let alias = "";
1264
+ let referNames = [];
1265
+ const subNames = [];
1266
+ let sawKwd = false;
1267
+ let hasAsAlias = false;
1268
+ for (let k = 1; k < spec.namedChildCount; k++) {
1269
+ const part = spec.namedChild(k);
1270
+ if (!part) continue;
1271
+ if (part.type === "kwd_lit") {
1272
+ sawKwd = true;
1273
+ const kw = part.childForFieldName("name")?.text || "";
1274
+ if ((kw === "as" || kw === "as-alias") && k + 1 < spec.namedChildCount) {
1275
+ alias = symName(spec.namedChild(k + 1));
1276
+ if (kw === "as-alias") hasAsAlias = true;
1277
+ } else if ((kw === "refer" || kw === "only") && k + 1 < spec.namedChildCount) {
1278
+ const refVec = spec.namedChild(k + 1);
1279
+ if (refVec && (refVec.type === "vec_lit" || refVec.type === "list_lit")) {
1280
+ for (let r = 0; r < refVec.namedChildCount; r++) {
1281
+ const rn = refVec.namedChild(r);
1282
+ if (rn && rn.type === "sym_lit") referNames.push(symName(rn));
1283
+ }
1284
+ }
1285
+ } else if (kw === "rename" && k + 1 < spec.namedChildCount) {
1286
+ const renameMap = spec.namedChild(k + 1);
1287
+ if (renameMap && renameMap.type === "map_lit") {
1288
+ for (let r = 1; r < renameMap.namedChildCount; r += 2) {
1289
+ const v = renameMap.namedChild(r);
1290
+ if (v && v.type === "sym_lit") referNames.push(symName(v));
1291
+ }
1292
+ }
1293
+ }
1294
+ } else if (part.type === "sym_lit") {
1295
+ subNames.push(symName(part));
1296
+ } else if (part.type === "vec_lit") {
1297
+ const prev = spec.namedChild(k - 1);
1298
+ if (prev && prev.type === "kwd_lit") continue;
1299
+ const sub = symName(part.namedChild(0));
1300
+ if (!sub) continue;
1301
+ const full = `${libName}.${sub}`;
1302
+ let subAlias = "";
1303
+ for (let q = 1; q < part.namedChildCount; q++) {
1304
+ const pp = part.namedChild(q);
1305
+ if (pp && pp.type === "kwd_lit" && (pp.childForFieldName("name")?.text || "") === "as") {
1306
+ const av = part.namedChild(q + 1);
1307
+ if (av) subAlias = symName(av);
1308
+ }
1309
+ }
1310
+ if (subAlias) namespaceAliases[subAlias] = full;
1311
+ if (full !== currentNamespace) pushRel(currentNamespace, full, ASTEngine.RelationshipType.References, 0.9, { clojureSpecific: true, isLibraryDep: true }, part.startPosition.row + 1);
1312
+ pushImport(currentNamespace, full, part.startPosition.row + 1);
1313
+ }
1314
+ }
1315
+ if (alias) namespaceAliases[alias] = libName;
1316
+ if (referNames.length > 0 && libName) for (const rn of referNames) referTable[rn] = libName;
1317
+ const items = referNames.length > 0 ? referNames : subNames.length > 0 && !sawKwd ? subNames : alias ? [alias] : ["*"];
1318
+ if (!hasAsAlias) {
1319
+ imports.push({ module: libName, items: [...items], type: "named", isExternal: true, line: (libNameNode ?? spec).startPosition.row + 1 });
1320
+ if (libName !== currentNamespace) pushRel(currentNamespace, libName, ASTEngine.RelationshipType.References, 0.9, { clojureSpecific: true, isLibraryDep: true }, (libNameNode ?? spec).startPosition.row + 1);
1321
+ pushImport(currentNamespace, libName, (libNameNode ?? spec).startPosition.row + 1);
1322
+ for (const [needle, fw] of REQUIRED_LIB_PATTERNS) {
1323
+ if (libName.startsWith(needle)) frameworks[fw] = true;
1324
+ }
1325
+ }
1326
+ if (subNames.length > 0 && !sawKwd) patterns["Java Interoperability"] = true;
1327
+ } else if (spec.type === "list_lit") {
1328
+ const pkgNode = spec.namedChild(0);
1329
+ const pkg = symName(pkgNode);
1330
+ if (!pkg) return;
1331
+ if (pkg !== currentNamespace) pushRel(currentNamespace, pkg, ASTEngine.RelationshipType.References, 0.9, { clojureSpecific: true, isLibraryDep: true, isImport: true }, (pkgNode ?? spec).startPosition.row + 1);
1332
+ pushImport(currentNamespace, pkg, (pkgNode ?? spec).startPosition.row + 1);
1333
+ for (let k = 1; k < spec.namedChildCount; k++) {
1334
+ const cls = spec.namedChild(k);
1335
+ if (!cls) continue;
1336
+ if (cls.type === "list_lit") {
1337
+ const subName = symName(cls.namedChild(0));
1338
+ if (!subName) continue;
1339
+ const full = `${pkg}.${subName}`;
1340
+ for (let q = 1; q < cls.namedChildCount; q++) {
1341
+ const pp = cls.namedChild(q);
1342
+ if (pp && pp.type === "kwd_lit" && (pp.childForFieldName("name")?.text || "") === "as") {
1343
+ const av = cls.namedChild(q + 1);
1344
+ const subAlias = av ? symName(av) : "";
1345
+ if (subAlias) namespaceAliases[subAlias] = full;
1346
+ }
1347
+ }
1348
+ if (full !== currentNamespace) pushRel(currentNamespace, full, ASTEngine.RelationshipType.References, 0.9, { clojureSpecific: true, isLibraryDep: true }, cls.startPosition.row + 1);
1349
+ pushImport(currentNamespace, full, cls.startPosition.row + 1);
1350
+ } else if (cls.type === "sym_lit") {
1351
+ imports.push({ module: pkg, items: [symName(cls)], type: "named", isExternal: true, line: cls.startPosition.row + 1 });
1352
+ patterns["Java Interoperability"] = true;
1353
+ }
1354
+ }
1355
+ } else if (spec.type === "sym_lit") {
1356
+ const libName = symName(spec);
1357
+ if (libName) {
1358
+ imports.push({ module: libName, items: ["*"], type: "named", isExternal: true, line: spec.startPosition.row + 1 });
1359
+ if (libName !== currentNamespace) pushRel(currentNamespace, libName, ASTEngine.RelationshipType.References, 0.9, { clojureSpecific: true, isLibraryDep: true }, spec.startPosition.row + 1);
1360
+ pushImport(currentNamespace, libName, spec.startPosition.row + 1);
1361
+ for (const [needle, fw] of REQUIRED_LIB_PATTERNS) {
1362
+ if (libName.startsWith(needle)) frameworks[fw] = true;
1363
+ }
1364
+ }
1365
+ }
1366
+ };
1367
+ const protocolsOfExtendingForm = (parent, parentForm) => {
1368
+ if (!parent) return [];
1369
+ const out = [];
1370
+ if (parentForm === "extend-protocol") {
1371
+ const p = symName(parent.namedChild(1));
1372
+ return p ? [p] : [];
1373
+ }
1374
+ if (parentForm === "defrecord" || parentForm === "deftype") {
1375
+ let sawFields = false;
1376
+ for (let i = 2; i < parent.namedChildCount; i++) {
1377
+ const c = parent.namedChild(i);
1378
+ if (!c) continue;
1379
+ if (!sawFields) {
1380
+ if (c.type === "vec_lit") sawFields = true;
1381
+ continue;
1382
+ }
1383
+ if (c.type === "sym_lit") {
1384
+ const n = symName(c);
1385
+ if (n) out.push(n);
1386
+ }
1387
+ }
1388
+ return out;
1389
+ }
1390
+ if (parentForm === "extend-type") {
1391
+ for (let i = 2; i < parent.namedChildCount; i++) {
1392
+ const c = parent.namedChild(i);
1393
+ if (c && c.type === "sym_lit") {
1394
+ const n = symName(c);
1395
+ if (n) out.push(n);
1396
+ }
1397
+ }
1398
+ return out;
1399
+ }
1400
+ return [];
1401
+ };
1402
+ const typeNameOf = (n) => {
1403
+ if (!n) return "";
1404
+ if (n.type === "nil_lit") return "nil";
1405
+ if (n.type === "meta_lit") {
1406
+ for (let i = 0; i < n.namedChildCount; i++) {
1407
+ const inner = typeNameOf(n.namedChild(i));
1408
+ if (inner) return inner;
1409
+ }
1410
+ return "";
1411
+ }
1412
+ if (n.type !== "sym_lit") return "";
1413
+ return symName(n);
1414
+ };
1415
+ const methodImplOwner = (implNode, parentForm) => {
1416
+ const parent = implNode.parent;
1417
+ if ((parentForm === "defrecord" || parentForm === "deftype" || parentForm === "extend-type") && parent) {
1418
+ return typeNameOf(parent.namedChild(1));
1419
+ }
1420
+ if (parentForm === "extend-protocol") {
1421
+ let prev = implNode.previousNamedSibling;
1422
+ while (prev && prev.type !== "sym_lit" && prev.type !== "nil_lit") prev = prev.previousNamedSibling;
1423
+ return prev ? typeNameOf(prev) : "";
1424
+ }
1425
+ return activeFunction ? activeFunction.name : currentNamespace;
1426
+ };
1427
+ const executionHead = (list) => {
1428
+ return clojureExecutionHead(list);
1429
+ };
1430
+ const headStartIndex = (list) => {
1431
+ const h = executionHead(list);
1432
+ return h ? h.startIndex : list.startIndex;
1433
+ };
1434
+ const shadowRanges = [];
1435
+ const shadowIndex = /* @__PURE__ */ new Map();
1436
+ const indexShadowRange = (name, start, end) => {
1437
+ const list = shadowIndex.get(name);
1438
+ if (list) list.push({ start, end });
1439
+ else shadowIndex.set(name, [{ start, end }]);
1440
+ };
1441
+ const DEF_NAME_HEADS = /* @__PURE__ */ Object.create(null);
1442
+ for (const h of ["def", "defn", "defn-", "defmacro", "defonce", "defmulti", "defmethod", "deftest", "declare"]) DEF_NAME_HEADS[h] = true;
1443
+ const PROTO_SIG_PARENTS = /* @__PURE__ */ Object.create(null);
1444
+ for (const h of ["defprotocol", "definterface"]) PROTO_SIG_PARENTS[h] = true;
1445
+ const BINDING_VEC_HEADS = /* @__PURE__ */ Object.create(null);
1446
+ for (const h of ["let", "let*", "loop", "loop*", "when-let", "if-let", "when-some", "if-some", "when-first", "binding", "for", "doseq", "dotimes", "with-open", "with-local-vars", "with-bindings", "letfn"]) BINDING_VEC_HEADS[h] = true;
1447
+ const FN_PARAM_HEADS = /* @__PURE__ */ Object.create(null);
1448
+ for (const h of ["fn", "defn", "defn-", "defmacro", "defmethod", "deftest"]) FN_PARAM_HEADS[h] = true;
1449
+ const shadowRangeOf = (candidate) => {
1450
+ const nm = symName(candidate);
1451
+ const parent = candidate.parent;
1452
+ if (!parent) return null;
1453
+ if (parent.type === "list_lit") {
1454
+ const head = formNameOf(parent);
1455
+ if (DEF_NAME_HEADS[head] && parent.namedChild(1)?.startIndex === candidate.startIndex) {
1456
+ return { name: nm, start: parent.endIndex, end: Infinity };
1457
+ }
1458
+ if (parent.namedChild(0)?.startIndex === candidate.startIndex) {
1459
+ const specVec = parent.parent;
1460
+ if (specVec && specVec.type === "vec_lit") {
1461
+ const letfnForm = specVec.parent;
1462
+ if (letfnForm && letfnForm.type === "list_lit" && formNameOf(letfnForm) === "letfn" && letfnForm.namedChild(1)?.startIndex === specVec.startIndex) {
1463
+ return { name: nm, start: letfnForm.startIndex, end: letfnForm.endIndex };
1464
+ }
1465
+ }
1466
+ const declForm = parent.parent;
1467
+ if (declForm && declForm.type === "list_lit" && PROTO_SIG_PARENTS[formNameOf(declForm)] && declForm.namedChild(0)?.startIndex !== parent.startIndex) {
1468
+ return { name: nm, start: declForm.endIndex, end: Infinity };
1469
+ }
1470
+ }
1471
+ return null;
1472
+ }
1473
+ if (parent.type === "vec_lit") {
1474
+ const gp = parent.parent;
1475
+ if (!gp || gp.type !== "list_lit") return null;
1476
+ const head = formNameOf(gp);
1477
+ if (FN_PARAM_HEADS[head]) {
1478
+ for (let i = 0; i < gp.namedChildCount; i++) {
1479
+ const c = gp.namedChild(i);
1480
+ if (c?.type === "vec_lit") return c.startIndex === parent.startIndex ? { name: nm, start: gp.startIndex, end: gp.endIndex } : null;
1481
+ }
1482
+ return null;
1483
+ }
1484
+ if (BINDING_VEC_HEADS[head] && gp.namedChild(1)?.startIndex === parent.startIndex) {
1485
+ return { name: nm, start: gp.startIndex, end: gp.endIndex };
1486
+ }
1487
+ if (gp.namedChild(0)?.startIndex === parent.startIndex) {
1488
+ const ggp = gp.parent;
1489
+ if (ggp && ggp.type === "list_lit" && FN_PARAM_HEADS[formNameOf(ggp)]) {
1490
+ return { name: nm, start: gp.startIndex, end: gp.endIndex };
1491
+ }
1492
+ }
1493
+ {
1494
+ const specVec = gp.parent;
1495
+ if (specVec && specVec.type === "vec_lit") {
1496
+ const letfnForm = specVec.parent;
1497
+ if (letfnForm && letfnForm.type === "list_lit" && formNameOf(letfnForm) === "letfn" && letfnForm.namedChild(1)?.startIndex === specVec.startIndex) {
1498
+ return { name: nm, start: gp.startIndex, end: gp.endIndex };
1499
+ }
1500
+ }
1501
+ }
1502
+ return null;
1503
+ }
1504
+ return null;
1505
+ };
1506
+ const bindingStack = [rootNode];
1507
+ while (bindingStack.length > 0) {
1508
+ const candidate = bindingStack.pop();
1509
+ if (candidate.type === "dis_expr" || candidate.type === "quoting_lit") continue;
1510
+ if (candidate.type === "sym_lit" && CLOJURE_CORE_BUILTINS[symName(candidate)]) {
1511
+ const range = shadowRangeOf(candidate);
1512
+ if (range) {
1513
+ shadowRanges.push(range);
1514
+ indexShadowRange(range.name, range.start, range.end);
1515
+ }
1516
+ }
1517
+ for (let i = 0; i < candidate.namedChildCount; i++) {
1518
+ const child = candidate.namedChild(i);
1519
+ if (child) bindingStack.push(child);
1520
+ }
1521
+ }
1522
+ const isShadowedAt = (name, pos) => {
1523
+ const list = shadowIndex.get(name);
1524
+ if (list === void 0) return false;
1525
+ for (let i = 0; i < list.length; i++) {
1526
+ const r = list[i];
1527
+ if (pos >= r.start && pos < r.end) return true;
1528
+ }
1529
+ return false;
1530
+ };
1531
+ const isCoreCallSuppressed = (name, pos) => {
1532
+ if (!name || !CLOJURE_CORE_BUILTINS[name]) return false;
1533
+ if (referAt(name, pos)) return false;
1534
+ return !isShadowedAt(name, pos);
1535
+ };
1536
+ const threadedSteps = /* @__PURE__ */ new Set();
1537
+ const walkStack = [{ node: rootNode, isExit: false, previousActiveFunction: activeFunction, quoteDepth: 0 }];
1538
+ while (walkStack.length > 0) {
1539
+ const { node, isExit, previousActiveFunction: savedActiveFunction, quoteDepth } = walkStack.pop();
1540
+ if (!node) continue;
1541
+ if (isExit) {
1542
+ activeFunction = savedActiveFunction;
1543
+ continue;
1544
+ }
1545
+ if (node.type === "dis_expr") continue;
1546
+ if (node.type === "read_cond_lit" || node.type === "splicing_read_cond_lit") {
1547
+ readCondRanges.push({ start: node.startIndex, end: node.endIndex });
1548
+ }
1549
+ if (node.type === "meta_lit") continue;
1550
+ if (node.type === "syn_quoting_lit" || quoteDepth > 0) {
1551
+ let childDepth = quoteDepth;
1552
+ if (node.type === "syn_quoting_lit") childDepth++;
1553
+ else if (node.type === "unquoting_lit" || node.type === "unquote_splicing_lit") childDepth--;
1554
+ for (let i = node.namedChildCount - 1; i >= 0; i--) {
1555
+ const child = node.namedChild(i);
1556
+ if (child) walkStack.push({ node: child, isExit: false, previousActiveFunction: null, quoteDepth: childDepth });
1557
+ }
1558
+ continue;
1559
+ }
1560
+ if (node.type === "quoting_lit") continue;
1561
+ if (node.type === "tagged_or_ctor_lit") {
1562
+ const tagNode = node.namedChild(0);
1563
+ const payload = node.namedChild(1);
1564
+ const tag = symName(tagNode);
1565
+ const bareTag = tag.includes("/") ? tag.slice(tag.indexOf("/") + 1) : tag;
1566
+ if ((bareTag === "js" || bareTag === "JS") && payload) {
1567
+ const walkJsValues = (nd) => {
1568
+ if (nd.type === "kwd_lit") return;
1569
+ if (nd.type === "map_lit") {
1570
+ for (let i = 0; i < nd.namedChildCount; i++) {
1571
+ const c = nd.namedChild(i);
1572
+ if (!c) continue;
1573
+ const isKey = i % 2 === 0;
1574
+ if (!isKey) walkStack.push({ node: c, isExit: false, previousActiveFunction: null, quoteDepth });
1575
+ }
1576
+ return;
1577
+ }
1578
+ if (nd.type === "vec_lit" || nd.type === "set_lit") {
1579
+ for (let i = 0; i < nd.namedChildCount; i++) {
1580
+ const c = nd.namedChild(i);
1581
+ if (c) walkStack.push({ node: c, isExit: false, previousActiveFunction: null, quoteDepth });
1582
+ }
1583
+ return;
1584
+ }
1585
+ };
1586
+ walkJsValues(payload);
1587
+ continue;
1588
+ }
1589
+ if (tag && payload && (payload.type === "vec_lit" || payload.type === "map_lit")) {
1590
+ const namePart = tag.includes("/") ? tag.slice(tag.indexOf("/") + 1) : tag;
1591
+ const lastSeg = namePart.includes(".") ? namePart.slice(namePart.lastIndexOf(".") + 1) : namePart;
1592
+ const c0 = lastSeg.charCodeAt(0);
1593
+ if (c0 >= 65 && c0 <= 90) {
1594
+ const src = activeFunction ? activeFunction.name : currentNamespace;
1595
+ pushRel(src, resolveQualified(tag), ASTEngine.RelationshipType.Instantiates, 0.8, { clojureSpecific: true, isCtorLiteral: true, ...activeFunction ? {} : { isTopLevel: true } }, tagNode ? tagNode.startPosition.row + 1 : void 0, payload.type === "vec_lit" ? payload.namedChildCount : void 0);
1596
+ }
1597
+ }
1598
+ continue;
1599
+ }
1600
+ if (node.type === "list_lit") {
1601
+ let site = null;
1602
+ for (let anc = node.parent; anc; anc = anc.parent) {
1603
+ if (anc.type !== "list_lit") continue;
1604
+ const pf = clauseNameOf(anc) || formNameOf(anc);
1605
+ if (pf === "require" || pf === "use" || pf === "import" || pf === "refer" || pf === "refer-macros" || pf === "use-macros" || pf === "refer-clojure") {
1606
+ site = anc;
1607
+ break;
1608
+ }
1609
+ }
1610
+ if (site) continue;
1611
+ }
1612
+ if (node.type === "list_lit") {
1613
+ const form = formNameOf(node);
1614
+ const canon = resolveQualified(form);
1615
+ if (canon === "quote" || canon === "clojure.core/quote" || canon === "clojure.core/comment" || canon === "comment" && !isShadowedAt("comment", node.startIndex)) continue;
1616
+ }
1617
+ if (node.type === "vec_lit") {
1618
+ const tag = node.namedChild(0);
1619
+ if (tag && tag.type === "kwd_lit") {
1620
+ for (let i = 1; i < node.namedChildCount; i++) {
1621
+ const c = node.namedChild(i);
1622
+ if (!c) continue;
1623
+ let component = null;
1624
+ if (c.type === "sym_lit") component = c;
1625
+ else if (c.type === "vec_lit") {
1626
+ const inner = c.namedChild(0);
1627
+ if (inner && inner.type === "sym_lit") component = inner;
1628
+ }
1629
+ if (!component) continue;
1630
+ const target = resolveQualified(symName(component));
1631
+ if (!target) continue;
1632
+ renderCandidates.push({
1633
+ source: activeFunction ? activeFunction.name : currentNamespace,
1634
+ target,
1635
+ line: component.startPosition.row + 1,
1636
+ topLevel: !activeFunction
1637
+ });
1638
+ }
1639
+ }
1640
+ }
1641
+ const previousActiveFunction = activeFunction;
1642
+ walkStack.push({ node, isExit: true, previousActiveFunction, quoteDepth });
1643
+ if (node.type === "anon_fn_lit") {
1644
+ const name = `lambda_${node.startPosition.row}_${node.startPosition.column}`;
1645
+ const lambdaSymbol = {
1646
+ name,
1647
+ kind: ASTEngine.SymbolKind.Function,
1648
+ range: this.nodeToRange(node),
1649
+ scope: currentNamespace,
1650
+ ownerName: "",
1651
+ visibility: "local",
1652
+ parameters: [],
1653
+ metadata: { isAnonymous: true, isPure: true, complexity: 1, clojureSpecific: true }
1654
+ };
1655
+ symbols.push(lambdaSymbol);
1656
+ activeFunction = lambdaSymbol;
1657
+ const anonHead = node.namedChild(0);
1658
+ if (anonHead && anonHead.type === "sym_lit") {
1659
+ const hName = symName(anonHead);
1660
+ const anonMember = hName && hName.startsWith(".") && hName !== ".." ? hName.startsWith(".-") ? hName.slice(2) : hName.slice(1) : null;
1661
+ const anonStatic = hName ? staticInteropMember(hName) : null;
1662
+ if (anonMember) {
1663
+ const mLine = anonHead.startPosition.row + 1;
1664
+ pushRel(
1665
+ name,
1666
+ anonMember,
1667
+ ASTEngine.RelationshipType.Uses,
1668
+ 0.7,
1669
+ { clojureSpecific: true, isFieldAccess: true, isAnonShorthand: true },
1670
+ mLine,
1671
+ Math.max(0, node.namedChildCount - 1),
1672
+ anonHead.startIndex
1673
+ );
1674
+ patterns["Java Interoperability"] = true;
1675
+ } else if (anonStatic !== null) {
1676
+ const mLine = anonHead.startPosition.row + 1;
1677
+ const mArity = Math.max(0, node.namedChildCount - 1);
1678
+ pushRel(
1679
+ name,
1680
+ anonStatic,
1681
+ ASTEngine.RelationshipType.Uses,
1682
+ 0.7,
1683
+ { clojureSpecific: true, isFieldAccess: true, isAnonShorthand: true },
1684
+ mLine,
1685
+ mArity,
1686
+ anonHead.startIndex
1687
+ );
1688
+ const anonCls = staticInteropClass(hName);
1689
+ if (anonCls) {
1690
+ pushRel(
1691
+ name,
1692
+ resolveQualified(anonCls),
1693
+ ASTEngine.RelationshipType.Uses,
1694
+ 0.8,
1695
+ { clojureSpecific: true, isClassReference: true, isAnonShorthand: true },
1696
+ mLine,
1697
+ 0,
1698
+ anonHead.startIndex
1699
+ );
1700
+ }
1701
+ patterns["Java Interoperability"] = true;
1702
+ } else if (hName && !isAnonArgShorthand(hName) && !isCoreCallSuppressed(hName, anonHead.startIndex)) {
1703
+ const line = anonHead.startPosition.row + 1;
1704
+ const arity = Math.max(0, node.namedChildCount - 1);
1705
+ const q = resolveCallee(anonHead, hName);
1706
+ if (q.alias) {
1707
+ const resolvedNs = namespaceAliases[q.alias] || q.alias;
1708
+ pushRel(name, q.target, ASTEngine.RelationshipType.Calls, 0.9, { clojureSpecific: true, isGeneralCall: true, isAnonShorthand: true }, line, arity, anonHead.startIndex);
1709
+ if (resolvedNs !== currentNamespace) pushRel(currentNamespace, resolvedNs, ASTEngine.RelationshipType.References, 0.8, { clojureSpecific: true, isLibraryDep: true }, line);
1710
+ } else {
1711
+ pushRel(name, hName, ASTEngine.RelationshipType.Calls, 0.9, { clojureSpecific: true, isGeneralCall: true, isAnonShorthand: true }, line, arity, anonHead.startIndex);
1712
+ }
1713
+ }
1714
+ }
1715
+ } else if (node.type === "list_lit") {
1716
+ const formName = formNameOf(node);
1717
+ const bareForm = formName.includes("/") ? formName.slice(formName.lastIndexOf("/") + 1) : formName;
1718
+ if (formName === "fn") {
1719
+ const name = `lambda_${node.startPosition.row}_${node.startPosition.column}`;
1720
+ const lambdaSymbol = {
1721
+ name,
1722
+ kind: ASTEngine.SymbolKind.Function,
1723
+ range: this.nodeToRange(node),
1724
+ scope: currentNamespace,
1725
+ ownerName: "",
1726
+ visibility: "local",
1727
+ parameters: extractParams(node),
1728
+ metadata: { isAnonymous: true, isPure: true, complexity: 1, clojureSpecific: true }
1729
+ };
1730
+ symbols.push(lambdaSymbol);
1731
+ activeFunction = lambdaSymbol;
1732
+ } else if (formName === "ns" || formName === "in-ns") {
1733
+ sawNamespaceForm = true;
1734
+ const argNode = node.namedChild(1);
1735
+ let nsName = "";
1736
+ if (argNode) {
1737
+ if (argNode.type === "sym_lit") nsName = symName(argNode);
1738
+ else if (argNode.type === "quoting_lit" || argNode.type === "syn_quoting_lit") {
1739
+ const inner = executionHead(argNode);
1740
+ const innerName = inner && inner.type === "sym_lit" ? symName(inner) : "";
1741
+ nsName = innerName;
1742
+ }
1743
+ }
1744
+ if (nsName) currentNamespace = nsName;
1745
+ if (formName === "ns") {
1746
+ namespaceAliases = /* @__PURE__ */ Object.create(null);
1747
+ if (referSegments.length > 0) referSegments[referSegments.length - 1].end = node.startIndex;
1748
+ referTable = openReferSegment(node.startIndex);
1749
+ }
1750
+ const modSym = {
1751
+ name: currentNamespace,
1752
+ kind: ASTEngine.SymbolKind.Module,
1753
+ range: this.nodeToRange(node),
1754
+ scope: "",
1755
+ visibility: "public",
1756
+ metadata: { clojureSpecific: true }
1757
+ };
1758
+ symbols.push(modSym);
1759
+ attachDocs(modSym, node, "always");
1760
+ exports.push({ name: currentNamespace, kind: ASTEngine.SymbolKind.Module, range: this.nodeToRange(node), visibility: "public" });
1761
+ exportNamespaces.push(currentNamespace);
1762
+ const clauses = [];
1763
+ for (let i = 1; i < node.namedChildCount; i++) {
1764
+ const clause = node.namedChild(i);
1765
+ if (!clause) continue;
1766
+ if (clause.type === "list_lit") clauses.push(clause);
1767
+ else if (clause.type === "read_cond_lit" || clause.type === "splicing_read_cond_lit") {
1768
+ for (let c = 0; c < clause.namedChildCount; c++) {
1769
+ const inner = clause.namedChild(c);
1770
+ if (inner && inner.type === "list_lit") clauses.push(inner);
1771
+ }
1772
+ }
1773
+ }
1774
+ for (const clause of clauses) {
1775
+ const clauseType = clauseNameOf(clause);
1776
+ if (clauseType !== "require" && clauseType !== "use" && clauseType !== "import" && clauseType !== "require-macros") continue;
1777
+ for (let j = 1; j < clause.namedChildCount; j++) {
1778
+ const libNode = clause.namedChild(j);
1779
+ if (libNode) handleLibNode(libNode);
1780
+ }
1781
+ }
1782
+ } else if ((formName === "require" || formName === "use" || formName === "import" || formName === "refer" || formName === "require-macros") && executionHead(node)?.type === "sym_lit" && isTopLevelDirective(node)) {
1783
+ for (let j = 1; j < node.namedChildCount; j++) {
1784
+ const libNode = node.namedChild(j);
1785
+ if (!libNode) continue;
1786
+ if (libNode.type === "sym_lit" && !libNode.text.includes(".") && !libNode.text.includes("/")) continue;
1787
+ handleLibNode(libNode);
1788
+ }
1789
+ } else if (bareForm === "defn" || bareForm === "defn-" || bareForm === "defmacro" || bareForm === "s/defn" || formName === "mu/defn") {
1790
+ const isMacro = bareForm === "defmacro";
1791
+ const nameNode2 = defNameNodeOf(node);
1792
+ const rawName = nameNode2 ? symName(nameNode2) : "";
1793
+ const name = isPublishableName(rawName) ? rawName : "";
1794
+ const isPrivate = formName === "defn-" || metaHasPrivate(node.namedChild(1)) || metaHasPrivate(nameNode2) || attrMapHasPrivate(node, nameNode2);
1795
+ if (name) {
1796
+ const funcSymbol = {
1797
+ name,
1798
+ kind: ASTEngine.SymbolKind.Function,
1799
+ range: this.nodeToRange(node),
1800
+ scope: currentNamespace,
1801
+ ownerName: currentNamespace,
1802
+ visibility: isPrivate ? "private" : "public",
1803
+ parameters: extractParams(node),
1804
+ metadata: { clojureSpecific: true, isPure: true, complexity: 1, isMacro: isMacro || void 0 }
1805
+ };
1806
+ symbols.push(funcSymbol);
1807
+ activeFunction = funcSymbol;
1808
+ attachDocs(funcSymbol, node, "fn");
1809
+ }
1810
+ if (isMacro) patterns["Metaprogramming"] = true;
1811
+ if (name) {
1812
+ exports.push({ name, kind: ASTEngine.SymbolKind.Function, range: this.nodeToRange(node), visibility: isPrivate ? "private" : "public" });
1813
+ exportNamespaces.push(currentNamespace);
1814
+ }
1815
+ } else if (formName === "deftest") {
1816
+ const testNameNode = defNameNodeOf(node);
1817
+ const name = (testNameNode ? symName(testNameNode) : "") || `test_${node.startPosition.row}`;
1818
+ const testSym = {
1819
+ name,
1820
+ kind: ASTEngine.SymbolKind.Function,
1821
+ range: this.nodeToRange(node),
1822
+ scope: currentNamespace,
1823
+ ownerName: currentNamespace,
1824
+ visibility: "public",
1825
+ parameters: [],
1826
+ metadata: { clojureSpecific: true, isTest: true, isPure: true, complexity: 1 }
1827
+ };
1828
+ symbols.push(testSym);
1829
+ activeFunction = testSym;
1830
+ attachDocs(testSym, node, "fn");
1831
+ } else if (formName === "defprotocol") {
1832
+ const name = symName(node.namedChild(1)) || "unknown";
1833
+ const typeVisibility = metaHasPrivate(node.namedChild(1)) ? "private" : "public";
1834
+ const protoSym = {
1835
+ name,
1836
+ kind: ASTEngine.SymbolKind.Interface,
1837
+ range: this.nodeToRange(node),
1838
+ scope: currentNamespace,
1839
+ ownerName: currentNamespace,
1840
+ visibility: typeVisibility,
1841
+ metadata: { clojureSpecific: true, isProtocol: true }
1842
+ };
1843
+ symbols.push(protoSym);
1844
+ attachDocs(protoSym, node, "always");
1845
+ patterns["Protocol-based Polymorphism"] = true;
1846
+ exports.push({ name, kind: ASTEngine.SymbolKind.Interface, range: this.nodeToRange(node), visibility: typeVisibility });
1847
+ exportNamespaces.push(currentNamespace);
1848
+ for (let i = 2; i < node.namedChildCount; i++) {
1849
+ const m = node.namedChild(i);
1850
+ if (!m || m.type !== "list_lit") continue;
1851
+ const mName = symName(m.namedChild(0));
1852
+ if (!mName) continue;
1853
+ symbols.push({
1854
+ name: mName,
1855
+ kind: ASTEngine.SymbolKind.Function,
1856
+ range: this.nodeToRange(m),
1857
+ scope: `${currentNamespace}.${name}`,
1858
+ ownerName: name,
1859
+ visibility: "public",
1860
+ parameters: extractParams(m),
1861
+ metadata: { clojureSpecific: true, isProtocolMethod: true }
1862
+ });
1863
+ }
1864
+ } else if (formName === "definterface") {
1865
+ const name = symName(node.namedChild(1)) || "unknown";
1866
+ const typeVisibility = metaHasPrivate(node.namedChild(1)) ? "private" : "public";
1867
+ const ifaceSym = {
1868
+ name,
1869
+ kind: ASTEngine.SymbolKind.Interface,
1870
+ range: this.nodeToRange(node),
1871
+ scope: currentNamespace,
1872
+ ownerName: currentNamespace,
1873
+ visibility: typeVisibility,
1874
+ metadata: { clojureSpecific: true, isInterface: true }
1875
+ };
1876
+ symbols.push(ifaceSym);
1877
+ attachDocs(ifaceSym, node, "always");
1878
+ exports.push({ name, kind: ASTEngine.SymbolKind.Interface, range: this.nodeToRange(node), visibility: typeVisibility });
1879
+ exportNamespaces.push(currentNamespace);
1880
+ for (let i = 2; i < node.namedChildCount; i++) {
1881
+ const m = node.namedChild(i);
1882
+ if (!m || m.type !== "list_lit") continue;
1883
+ const mName = symName(m.namedChild(0));
1884
+ if (!mName) continue;
1885
+ symbols.push({
1886
+ name: mName,
1887
+ kind: ASTEngine.SymbolKind.Function,
1888
+ range: this.nodeToRange(m),
1889
+ scope: `${currentNamespace}.${name}`,
1890
+ ownerName: name,
1891
+ visibility: "public",
1892
+ parameters: extractParams(m),
1893
+ metadata: { clojureSpecific: true, isInterfaceMethod: true }
1894
+ });
1895
+ }
1896
+ } else if (formName === "defrecord" || formName === "deftype") {
1897
+ const name = symName(node.namedChild(1)) || "unknown";
1898
+ const typeVisibility = metaHasPrivate(node.namedChild(1)) ? "private" : "public";
1899
+ const classSym = {
1900
+ name,
1901
+ kind: ASTEngine.SymbolKind.Class,
1902
+ range: this.nodeToRange(node),
1903
+ scope: currentNamespace,
1904
+ ownerName: currentNamespace,
1905
+ visibility: typeVisibility,
1906
+ metadata: { clojureSpecific: true, isRecord: formName === "defrecord", isType: formName === "deftype" }
1907
+ };
1908
+ symbols.push(classSym);
1909
+ attachDocs(classSym, node, "always");
1910
+ exports.push({ name, kind: ASTEngine.SymbolKind.Class, range: this.nodeToRange(node), visibility: typeVisibility });
1911
+ exportNamespaces.push(currentNamespace);
1912
+ let fieldsVec = null;
1913
+ for (let i = 2; i < node.namedChildCount; i++) {
1914
+ const c = node.namedChild(i);
1915
+ if (c && c.type === "vec_lit") {
1916
+ fieldsVec = c;
1917
+ break;
1918
+ }
1919
+ }
1920
+ if (fieldsVec) {
1921
+ for (let i = 0; i < fieldsVec.namedChildCount; i++) {
1922
+ const field = fieldsVec.namedChild(i);
1923
+ if (field && field.type === "sym_lit") {
1924
+ symbols.push({
1925
+ name: symName(field),
1926
+ kind: ASTEngine.SymbolKind.Property,
1927
+ range: this.nodeToRange(field),
1928
+ scope: `${currentNamespace}.${name}`,
1929
+ ownerName: name,
1930
+ visibility: "public",
1931
+ metadata: { clojureSpecific: true }
1932
+ });
1933
+ }
1934
+ }
1935
+ }
1936
+ for (let pi = 3; pi < node.namedChildCount; pi++) {
1937
+ const protoNode = node.namedChild(pi);
1938
+ if (!protoNode || protoNode.type !== "sym_lit") continue;
1939
+ const protoName = resolveQualified(symName(protoNode));
1940
+ if (protoName) {
1941
+ pushRel(name, protoName, ASTEngine.RelationshipType.Implements, 0.85, { clojureSpecific: true, isRecord: formName === "defrecord" }, protoNode.startPosition.row + 1);
1942
+ }
1943
+ }
1944
+ } else if (formName === "reify" || formName === "extend-type" || formName === "extend-protocol" || formName === "proxy") {
1945
+ const ctxName = activeFunction ? activeFunction.name : currentNamespace;
1946
+ const topMeta = activeFunction ? {} : { isTopLevel: true };
1947
+ if (formName === "reify") {
1948
+ for (let i = 1; i < node.namedChildCount; i++) {
1949
+ const c = node.namedChild(i);
1950
+ if (c && c.type === "sym_lit") {
1951
+ const proto = resolveQualified(symName(c));
1952
+ if (proto) pushRel(ctxName, proto, ASTEngine.RelationshipType.Implements, 0.85, { clojureSpecific: true, isReify: true, ...topMeta }, c.startPosition.row + 1);
1953
+ }
1954
+ }
1955
+ patterns["Protocol-based Polymorphism"] = true;
1956
+ } else if (formName === "extend-protocol") {
1957
+ const proto = resolveQualified(symName(node.namedChild(1)));
1958
+ for (let i = 2; i < node.namedChildCount; i++) {
1959
+ const c = node.namedChild(i);
1960
+ const type = typeNameOf(c);
1961
+ if (type && proto) {
1962
+ pushRel(type, proto, ASTEngine.RelationshipType.Implements, 0.85, { clojureSpecific: true, isExtendProtocol: true }, c.startPosition.row + 1);
1963
+ }
1964
+ }
1965
+ patterns["Protocol-based Polymorphism"] = true;
1966
+ } else if (formName === "extend-type") {
1967
+ const typeName = typeNameOf(node.namedChild(1));
1968
+ for (let i = 2; i < node.namedChildCount; i++) {
1969
+ const c = node.namedChild(i);
1970
+ if (c && c.type === "sym_lit") {
1971
+ const proto = resolveQualified(symName(c));
1972
+ if (proto && typeName) pushRel(typeName, proto, ASTEngine.RelationshipType.Implements, 0.85, { clojureSpecific: true, isExtendType: true }, c.startPosition.row + 1);
1973
+ }
1974
+ }
1975
+ patterns["Protocol-based Polymorphism"] = true;
1976
+ } else {
1977
+ const ifaces = node.namedChild(1);
1978
+ if (ifaces && ifaces.type === "vec_lit") {
1979
+ for (let i = 0; i < ifaces.namedChildCount; i++) {
1980
+ const c = ifaces.namedChild(i);
1981
+ if (c && c.type === "sym_lit") {
1982
+ const iface = resolveQualified(symName(c));
1983
+ if (iface) pushRel(ctxName, iface, i === 0 ? ASTEngine.RelationshipType.Extends : ASTEngine.RelationshipType.Implements, 0.8, { clojureSpecific: true, isProxy: true, ...topMeta }, c.startPosition.row + 1);
1984
+ }
1985
+ }
1986
+ }
1987
+ patterns["Java Interoperability"] = true;
1988
+ }
1989
+ } else if (formName === "gen-class" || formName === "gen-interface") {
1990
+ const ctxName = activeFunction ? activeFunction.name : currentNamespace;
1991
+ const topMeta = activeFunction ? {} : { isTopLevel: true };
1992
+ let genName = "";
1993
+ let extendsNode = null;
1994
+ let implementsNode = null;
1995
+ for (let i = 1; i < node.namedChildCount; i++) {
1996
+ const k = node.namedChild(i);
1997
+ if (!k || k.type !== "kwd_lit") continue;
1998
+ const kw = k.childForFieldName("name")?.text || "";
1999
+ const val = node.namedChild(i + 1);
2000
+ if (!val) continue;
2001
+ if (kw === "name" && val.type === "sym_lit") genName = symName(val);
2002
+ else if (kw === "extends") extendsNode = val;
2003
+ else if (kw === "implements") implementsNode = val;
2004
+ }
2005
+ const genMeta = { clojureSpecific: true, isGenClass: true, ...genName ? { genClassName: genName } : {}, ...topMeta };
2006
+ if (extendsNode) {
2007
+ const targets = extendsNode.type === "vec_lit" ? Array.from({ length: extendsNode.namedChildCount }, (_, k2) => extendsNode.namedChild(k2)).filter((x) => !!x && x.type === "sym_lit") : extendsNode.type === "sym_lit" ? [extendsNode] : [];
2008
+ for (const c of targets) {
2009
+ const superName = resolveQualified(symName(c));
2010
+ if (superName) pushRel(ctxName, superName, ASTEngine.RelationshipType.Extends, 0.8, genMeta, c.startPosition.row + 1);
2011
+ }
2012
+ patterns["Java Interoperability"] = true;
2013
+ }
2014
+ if (implementsNode && implementsNode.type === "vec_lit") {
2015
+ for (let k2 = 0; k2 < implementsNode.namedChildCount; k2++) {
2016
+ const c = implementsNode.namedChild(k2);
2017
+ if (!c || c.type !== "sym_lit") continue;
2018
+ const iface = resolveQualified(symName(c));
2019
+ if (iface) pushRel(ctxName, iface, ASTEngine.RelationshipType.Implements, 0.85, genMeta, c.startPosition.row + 1);
2020
+ }
2021
+ }
2022
+ if (genName) patterns["AOT Compilation"] = true;
2023
+ } else if (formName === "defmulti") {
2024
+ const multiNameNode = defNameNodeOf(node);
2025
+ const name = multiNameNode ? symName(multiNameNode) : "unknown";
2026
+ const multiVisibility = metaHasPrivate(node.namedChild(1)) || metaHasPrivate(multiNameNode) ? "private" : "public";
2027
+ const multiSym = {
2028
+ name,
2029
+ kind: ASTEngine.SymbolKind.Function,
2030
+ range: this.nodeToRange(node),
2031
+ scope: currentNamespace,
2032
+ ownerName: currentNamespace,
2033
+ visibility: multiVisibility,
2034
+ metadata: { clojureSpecific: true, isMultimethod: true }
2035
+ };
2036
+ symbols.push(multiSym);
2037
+ attachDocs(multiSym, node, "always");
2038
+ patterns["Multimethods"] = true;
2039
+ exports.push({ name, kind: ASTEngine.SymbolKind.Function, range: this.nodeToRange(node), visibility: multiVisibility });
2040
+ exportNamespaces.push(currentNamespace);
2041
+ } else if (formName === "defmethod") {
2042
+ const multiName = symName(node.namedChild(1)) || "unknown";
2043
+ const methodSym = {
2044
+ name: multiName,
2045
+ kind: ASTEngine.SymbolKind.Function,
2046
+ range: this.nodeToRange(node),
2047
+ scope: currentNamespace,
2048
+ ownerName: currentNamespace,
2049
+ visibility: "public",
2050
+ parameters: extractParams(node),
2051
+ metadata: { clojureSpecific: true, isMethodImpl: true }
2052
+ };
2053
+ symbols.push(methodSym);
2054
+ activeFunction = methodSym;
2055
+ patterns["Multimethods"] = true;
2056
+ } else if (formName === "def" || formName === "defonce") {
2057
+ const nameNode = node.namedChild(1);
2058
+ if (nameNode && nameNode.type === "sym_lit") {
2059
+ const name = symName(nameNode);
2060
+ const varVisibility = metaHasPrivate(nameNode) ? "private" : "public";
2061
+ const varSym = {
2062
+ name,
2063
+ kind: ASTEngine.SymbolKind.Variable,
2064
+ range: this.nodeToRange(node),
2065
+ scope: currentNamespace,
2066
+ ownerName: currentNamespace,
2067
+ visibility: varVisibility,
2068
+ metadata: { clojureSpecific: true }
2069
+ };
2070
+ symbols.push(varSym);
2071
+ attachDocs(varSym, node, "def");
2072
+ exports.push({ name, kind: ASTEngine.SymbolKind.Variable, range: this.nodeToRange(node), visibility: varVisibility });
2073
+ exportNamespaces.push(currentNamespace);
2074
+ }
2075
+ } else if (formName === "declare") {
2076
+ for (let i = 1; i < node.namedChildCount; i++) {
2077
+ const nameNode = node.namedChild(i);
2078
+ if (!nameNode) continue;
2079
+ if (nameNode.type === "sym_lit") {
2080
+ const name = symName(nameNode);
2081
+ if (!name || CLOJURE_CORE_BUILTINS[name]) continue;
2082
+ symbols.push({
2083
+ name,
2084
+ kind: ASTEngine.SymbolKind.Variable,
2085
+ range: this.nodeToRange(node),
2086
+ scope: currentNamespace,
2087
+ ownerName: currentNamespace,
2088
+ visibility: metaHasPrivate(nameNode) ? "private" : "public",
2089
+ metadata: { clojureSpecific: true, isForwardDeclaration: true }
2090
+ });
2091
+ } else if (nameNode.type === "vec_lit") {
2092
+ continue;
2093
+ }
2094
+ }
2095
+ } else if (isDefLikeHead(formName)) {
2096
+ const nameNode = defNameNodeOf(node);
2097
+ const name = nameNode ? symName(nameNode) : "";
2098
+ if (name) {
2099
+ let hasArglist = false;
2100
+ for (let i = 2; i < node.namedChildCount; i++) {
2101
+ const c = node.namedChild(i);
2102
+ if (c && c.type === "vec_lit") {
2103
+ hasArglist = true;
2104
+ break;
2105
+ }
2106
+ if (c && c.type === "str_lit") continue;
2107
+ if (c && c.type === "map_lit") continue;
2108
+ if (c && c.type === "meta_lit") continue;
2109
+ break;
2110
+ }
2111
+ const inferredKind = hasArglist ? ASTEngine.SymbolKind.Function : ASTEngine.SymbolKind.Variable;
2112
+ const visibility = metaHasPrivate(nameNode) ? "private" : "public";
2113
+ const sym = {
2114
+ name,
2115
+ kind: inferredKind,
2116
+ range: this.nodeToRange(node),
2117
+ scope: currentNamespace,
2118
+ ownerName: currentNamespace,
2119
+ visibility,
2120
+ ...hasArglist ? { parameters: extractParams(node) } : {},
2121
+ metadata: { clojureSpecific: true, isPure: true, complexity: 1, isUnknownDefMacro: true, definedBy: formName }
2122
+ };
2123
+ symbols.push(sym);
2124
+ activeFunction = sym;
2125
+ attachDocs(sym, node, "fn");
2126
+ exports.push({ name, kind: inferredKind, range: this.nodeToRange(node), visibility });
2127
+ exportNamespaces.push(currentNamespace);
2128
+ }
2129
+ } else if ((formName === "s/def" || formName === "s/fdef" || formName === "clojure.spec.alpha/def" || formName === "clojure.spec.alpha/fdef") && node.namedChild(1)) {
2130
+ const child = node.namedChild(1);
2131
+ const raw = symName(child);
2132
+ const specName = child.type === "kwd_lit" && raw.startsWith("::") ? `:${currentNamespace}/${raw.slice(2)}` : raw;
2133
+ if (!specName || child.type === "num_lit" || child.type === "str_lit" || child.type === "bool_lit" || child.type === "char_lit") {
2134
+ } else {
2135
+ symbols.push({
2136
+ name: specName,
2137
+ kind: ASTEngine.SymbolKind.Interface,
2138
+ range: this.nodeToRange(node),
2139
+ scope: currentNamespace,
2140
+ ownerName: currentNamespace,
2141
+ visibility: "public",
2142
+ metadata: { isSpec: true, clojureSpecific: true }
2143
+ });
2144
+ }
2145
+ } else if (node.parent?.type === "list_lit" && METHOD_IMPL_PARENT_FORMS[formNameOf(node.parent)] && executionHead(node.parent)?.startIndex !== node.startIndex) {
2146
+ const parentForm = formNameOf(node.parent);
2147
+ if (parentForm !== "defprotocol" && parentForm !== "definterface") {
2148
+ const mName = symName(node.namedChild(0));
2149
+ if (mName) {
2150
+ const owner = methodImplOwner(node, parentForm);
2151
+ const isRecord = parentForm === "defrecord" || parentForm === "deftype";
2152
+ const methodSym = {
2153
+ name: mName,
2154
+ kind: ASTEngine.SymbolKind.Function,
2155
+ range: this.nodeToRange(node),
2156
+ scope: owner ? `${currentNamespace}.${owner}` : currentNamespace,
2157
+ ownerName: owner || currentNamespace,
2158
+ visibility: "public",
2159
+ parameters: extractParams(node),
2160
+ metadata: { clojureSpecific: true, isProtocolMethodImpl: true, ...isRecord ? { isRecordMethod: true } : {} }
2161
+ };
2162
+ symbols.push(methodSym);
2163
+ activeFunction = methodSym;
2164
+ const implProtos = protocolsOfExtendingForm(node.parent, parentForm);
2165
+ if (implProtos.length > 0 && owner) {
2166
+ overrideCandidates.push({ type: owner, protos: implProtos, method: mName, line: node.startPosition.row + 1, form: parentForm });
2167
+ }
2168
+ }
2169
+ }
2170
+ } else if (node.parent?.type === "vec_lit" && node.parent.parent?.type === "list_lit" && formNameOf(node.parent.parent) === "letfn") {
2171
+ const fName = symName(node.namedChild(0));
2172
+ if (fName) {
2173
+ const fnSym = {
2174
+ name: fName,
2175
+ kind: ASTEngine.SymbolKind.Function,
2176
+ range: this.nodeToRange(node),
2177
+ scope: currentNamespace,
2178
+ ownerName: "",
2179
+ visibility: "local",
2180
+ parameters: extractParams(node),
2181
+ metadata: { clojureSpecific: true, isLocalFn: true, isPure: true, complexity: 1 }
2182
+ };
2183
+ symbols.push(fnSym);
2184
+ activeFunction = fnSym;
2185
+ }
2186
+ } else if (formName.startsWith("->") && formName.length > 2 && formName !== "->>") {
2187
+ const cls = formName.slice(2);
2188
+ const namePart = cls.includes("/") ? cls.slice(cls.indexOf("/") + 1) : cls;
2189
+ const lastSeg = namePart.includes(".") ? namePart.slice(namePart.lastIndexOf(".") + 1) : namePart;
2190
+ const c0 = lastSeg.charCodeAt(0);
2191
+ if (c0 >= 65 && c0 <= 90) {
2192
+ const src = activeFunction ? activeFunction.name : currentNamespace;
2193
+ const headNode = executionHead(node);
2194
+ pushRel(src, resolveQualified(cls), ASTEngine.RelationshipType.Instantiates, 0.8, { clojureSpecific: true, isConstructor: true, ...activeFunction ? {} : { isTopLevel: true } }, headNode ? headNode.startPosition.row + 1 : void 0, callArityOf(node));
2195
+ }
2196
+ } else if (formName === "new") {
2197
+ const clsNode = node.namedChild(1);
2198
+ const clsName = symName(clsNode);
2199
+ if (clsName) {
2200
+ const src = activeFunction ? activeFunction.name : currentNamespace;
2201
+ pushRel(src, resolveQualified(clsName), ASTEngine.RelationshipType.Instantiates, 0.8, { clojureSpecific: true, isJavaInterop: true, ...activeFunction ? {} : { isTopLevel: true } }, clsNode ? clsNode.startPosition.row + 1 : void 0, Math.max(0, node.namedChildCount - 2));
2202
+ patterns["Java Interoperability"] = true;
2203
+ if (activeFunction?.metadata) activeFunction.metadata.isPure = false;
2204
+ }
2205
+ } else if (formName.endsWith(".") && formName.length > 1 && !formName.startsWith(".")) {
2206
+ const cls = resolveQualified(formName.slice(0, -1));
2207
+ const src = activeFunction ? activeFunction.name : currentNamespace;
2208
+ const headNode = executionHead(node);
2209
+ pushRel(src, cls, ASTEngine.RelationshipType.Instantiates, 0.8, { clojureSpecific: true, isJavaInterop: true, ...activeFunction ? {} : { isTopLevel: true } }, headNode ? headNode.startPosition.row + 1 : void 0, callArityOf(node));
2210
+ patterns["Java Interoperability"] = true;
2211
+ } else if (formName.startsWith(".") && formName !== "..") {
2212
+ const target = formName.startsWith(".-") ? formName.slice(2) : formName.slice(1);
2213
+ const src = activeFunction ? activeFunction.name : currentNamespace;
2214
+ const headNode = executionHead(node);
2215
+ if (target) pushRel(src, target, ASTEngine.RelationshipType.Uses, 0.7, { clojureSpecific: true, isFieldAccess: true, ...activeFunction ? {} : { isTopLevel: true } }, headNode ? headNode.startPosition.row + 1 : void 0, callArityOf(node));
2216
+ patterns["Java Interoperability"] = true;
2217
+ } else if (staticInteropMember(formName) !== null) {
2218
+ const member = staticInteropMember(formName);
2219
+ const clsName = staticInteropClass(formName);
2220
+ const src = activeFunction ? activeFunction.name : currentNamespace;
2221
+ const headNode = executionHead(node);
2222
+ const line = headNode ? headNode.startPosition.row + 1 : void 0;
2223
+ const topMeta = activeFunction ? {} : { isTopLevel: true };
2224
+ if (member) {
2225
+ pushRel(src, member, ASTEngine.RelationshipType.Uses, 0.7, { clojureSpecific: true, isFieldAccess: true, isStaticInterop: true, ...topMeta }, line, callArityOf(node));
2226
+ }
2227
+ if (clsName) {
2228
+ const clsNode = headNode;
2229
+ pushRel(src, resolveQualified(clsName), ASTEngine.RelationshipType.Uses, 0.8, { clojureSpecific: true, isStaticInteropClass: true, ...topMeta }, clsNode ? clsNode.startPosition.row + 1 : void 0, 0);
2230
+ }
2231
+ patterns["Java Interoperability"] = true;
2232
+ } else if (formName === "->" || formName === "->>" || formName === "some->" || formName === "some->>" || formName === "cond->" || formName === "cond->>" || formName === "doto") {
2233
+ if (activeFunction) patterns["Threading Macros"] = true;
2234
+ if ((formName === "cond->" || formName === "cond->>" || formName === "some->" || formName === "some->>") && activeFunction?.metadata) {
2235
+ activeFunction.metadata.complexity = (activeFunction.metadata.complexity || 1) + 1;
2236
+ totalCyclomaticComplexity++;
2237
+ }
2238
+ const isCond = formName === "cond->" || formName === "cond->>";
2239
+ const tSrc = activeFunction ? activeFunction.name : currentNamespace;
2240
+ const tTop = activeFunction ? {} : { isTopLevel: true };
2241
+ for (let i = 2; i < node.namedChildCount; i++) {
2242
+ if (isCond && i % 2 === 0) continue;
2243
+ const step = node.namedChild(i);
2244
+ if (!step) continue;
2245
+ const emitStep = (hName, line, arity, bare, stepPos, alias = "") => {
2246
+ if (!hName || isCoreCallSuppressed(hName, stepPos) || hName.startsWith(".") || hName.startsWith("->") || hName.endsWith(".")) return;
2247
+ pushRel(tSrc, alias ? hName : resolveQualified(hName), ASTEngine.RelationshipType.Calls, 0.9, { clojureSpecific: true, isGeneralCall: true, isThreadedStep: true, ...bare ? { isBareStep: true } : {}, ...tTop }, line, arity, stepPos);
2248
+ if (alias) {
2249
+ const resolvedNs = namespaceAliases[alias] || alias;
2250
+ if (resolvedNs !== currentNamespace) pushRel(currentNamespace, resolvedNs, ASTEngine.RelationshipType.References, 0.8, { clojureSpecific: true, isLibraryDep: true }, line);
2251
+ }
2252
+ };
2253
+ if (step.type === "list_lit") {
2254
+ const h = executionHead(step);
2255
+ if (!h || h.type !== "sym_lit") continue;
2256
+ const qh = resolveCallee(h, symName(h));
2257
+ emitStep(qh.alias ? qh.target : symName(h), h.startPosition.row + 1, callArityOf(step) + 1, false, h.startIndex, qh.alias);
2258
+ threadedSteps.add(step.startIndex);
2259
+ } else if (step.type === "sym_lit") {
2260
+ const qs = resolveCallee(step, symName(step));
2261
+ emitStep(qs.alias ? qs.target : symName(step), step.startPosition.row + 1, 1, true, step.startIndex, qs.alias);
2262
+ }
2263
+ }
2264
+ } else if (threadedSteps.has(node.startIndex) && formName && !isCoreCallSuppressed(formName, node.startIndex)) {
2265
+ } else if (formName && !CLOJURE_SPECIAL_FORMS.has(formName) && !isCoreCallSuppressed(formName, headStartIndex(node))) {
2266
+ const src = activeFunction ? activeFunction.name : currentNamespace;
2267
+ const topMeta = activeFunction ? {} : { isTopLevel: true };
2268
+ const headNode = executionHead(node);
2269
+ const line = headNode ? headNode.startPosition.row + 1 : void 0;
2270
+ const arity = callArityOf(node);
2271
+ const q = resolveCallee(headNode, formName);
2272
+ if (q.alias) {
2273
+ const resolvedNs = namespaceAliases[q.alias] || q.alias;
2274
+ pushRel(src, q.target, ASTEngine.RelationshipType.Calls, 0.9, { clojureSpecific: true, isGeneralCall: true, ...topMeta }, line, arity, headStartIndex(node));
2275
+ if (resolvedNs !== currentNamespace) pushRel(currentNamespace, resolvedNs, ASTEngine.RelationshipType.References, 0.8, { clojureSpecific: true, isLibraryDep: true }, line);
2276
+ if (q.name.endsWith("!") && activeFunction) activeFunction.metadata.isPure = false;
2277
+ } else {
2278
+ pushRel(src, formName, ASTEngine.RelationshipType.Calls, 0.9, { clojureSpecific: true, isGeneralCall: true, ...topMeta }, line, arity, headStartIndex(node));
2279
+ if (formName.endsWith("!") && activeFunction) activeFunction.metadata.isPure = false;
2280
+ }
2281
+ } else if (formName && activeFunction && activeFunction.metadata) {
2282
+ if (COMPLEXITY_BUILTINS[formName]) {
2283
+ activeFunction.metadata.complexity = (activeFunction.metadata.complexity || 1) + 1;
2284
+ totalCyclomaticComplexity++;
2285
+ }
2286
+ if (HOF_BUILTINS[formName]) {
2287
+ activeFunction.metadata.isHigherOrder = true;
2288
+ patterns["Higher-Order Functions"] = true;
2289
+ }
2290
+ if (STM_BUILTINS[formName]) {
2291
+ activeFunction.metadata.usesSTM = true;
2292
+ patterns["Software Transactional Memory"] = true;
2293
+ }
2294
+ if (IMPURE_BUILTINS[formName] || formName.endsWith("!") || formName.startsWith(".") || formName.endsWith(".")) {
2295
+ activeFunction.metadata.isPure = false;
2296
+ }
2297
+ if (formName === "recur") {
2298
+ activeFunction.metadata.isRecursive = true;
2299
+ } else if (formName === activeFunction.name) {
2300
+ activeFunction.metadata.isRecursive = true;
2301
+ }
2302
+ if (formName === "lazy-seq") patterns["Lazy Evaluation"] = true;
2303
+ }
2304
+ }
2305
+ const isCaseForm = node.type === "list_lit" && formNameOf(node) === "case";
2306
+ let caseSkip = null;
2307
+ if (isCaseForm) {
2308
+ const exec = [];
2309
+ for (let i = 0; i < node.namedChildCount; i++) {
2310
+ const c = node.namedChild(i);
2311
+ if (!c || c.type === "comment" || c.type === "dis_expr") continue;
2312
+ exec.push(i);
2313
+ }
2314
+ const hasDefault = exec.length % 2 === 1;
2315
+ const defaultIdx = hasDefault ? exec[exec.length - 1] : -1;
2316
+ caseSkip = /* @__PURE__ */ new Set();
2317
+ for (let pos = 2; pos < exec.length; pos += 2) {
2318
+ const childIdx = exec[pos];
2319
+ if (childIdx === defaultIdx) continue;
2320
+ const c = node.namedChild(childIdx);
2321
+ if (c && c.type === "list_lit") caseSkip.add(childIdx);
2322
+ }
2323
+ }
2324
+ for (let i = node.namedChildCount - 1; i >= 0; i--) {
2325
+ const child = node.namedChild(i);
2326
+ if (!child) continue;
2327
+ if (caseSkip !== null && caseSkip.has(i)) continue;
2328
+ walkStack.push({ node: child, isExit: false, previousActiveFunction: null, quoteDepth });
2329
+ }
2330
+ }
2331
+ if (!sawNamespaceForm) {
2332
+ const implicitNs = {
2333
+ name: currentNamespace,
2334
+ kind: ASTEngine.SymbolKind.Module,
2335
+ range: { startLine: 1, startColumn: 1, endLine: 1, endColumn: 1, startIndex: 0, endIndex: 0 },
2336
+ scope: "",
2337
+ visibility: "public",
2338
+ metadata: { clojureSpecific: true, isImplicitNamespace: true }
2339
+ };
2340
+ symbols.push(implicitNs);
2341
+ exports.push({ name: currentNamespace, kind: ASTEngine.SymbolKind.Module, range: implicitNs.range, visibility: "public" });
2342
+ exportNamespaces.push(currentNamespace);
2343
+ }
2344
+ const PLACEHOLDER_NAMES = /* @__PURE__ */ new Set(["unknown", "unnamed", "anonymous", "<unknown>"]);
2345
+ {
2346
+ const isPlaceholder = (n) => typeof n !== "string" || n.trim() === "" || PLACEHOLDER_NAMES.has(n.trim().toLowerCase());
2347
+ let droppedSymbols = 0;
2348
+ for (let i = symbols.length - 1; i >= 0; i--) {
2349
+ if (isPlaceholder(symbols[i].name)) {
2350
+ symbols.splice(i, 1);
2351
+ droppedSymbols++;
2352
+ }
2353
+ }
2354
+ for (let i = exports.length - 1; i >= 0; i--) {
2355
+ if (isPlaceholder(exports[i].name)) exports.splice(i, 1);
2356
+ }
2357
+ let droppedEdges = 0;
2358
+ for (let i = relationships.length - 1; i >= 0; i--) {
2359
+ const r = relationships[i];
2360
+ if (isPlaceholder(r.source) || isPlaceholder(r.target)) {
2361
+ if (isPlaceholder(r.source) || isPlaceholder(r.target)) {
2362
+ errors.push({
2363
+ message: `Placeholder relationship endpoint dropped (CLJ-D57): ${r.type} "${r.source}" -> "${r.target}"`,
2364
+ line: (r.line_number ?? 0) > 0 ? r.line_number : void 0,
2365
+ severity: "warning"
2366
+ });
2367
+ }
2368
+ relationships.splice(i, 1);
2369
+ droppedEdges++;
2370
+ }
2371
+ }
2372
+ if (droppedSymbols > 0) {
2373
+ const live = new Set(symbols.map((s) => s));
2374
+ if (activeFunction && !live.has(activeFunction)) activeFunction = null;
2375
+ }
2376
+ }
2377
+ {
2378
+ const callableNames = /* @__PURE__ */ new Set();
2379
+ for (const s of symbols) {
2380
+ const k = s.kind;
2381
+ if (k === "function" || k === "method" || k === "macro") callableNames.add(s.name);
2382
+ }
2383
+ let published = 0;
2384
+ for (const cand of renderCandidates) {
2385
+ const bare = cand.target.includes("/") ? cand.target.slice(cand.target.lastIndexOf("/") + 1) : cand.target;
2386
+ if (!callableNames.has(bare) && !callableNames.has(cand.target)) continue;
2387
+ pushRel(cand.source, cand.target, ASTEngine.RelationshipType.Renders, 0.8, { clojureSpecific: true, isRenderElement: true, ...cand.topLevel ? { isTopLevel: true } : {} }, cand.line);
2388
+ published++;
2389
+ }
2390
+ void published;
2391
+ }
2392
+ const isDefinition = (s) => s.metadata?.isForwardDeclaration !== true && s.metadata?.isSpec !== true;
2393
+ const containsPick = /* @__PURE__ */ new Map();
2394
+ for (const s of symbols) {
2395
+ const _owner = s.ownerName;
2396
+ if (!_owner || s.metadata?.isAnonymous) continue;
2397
+ const key = `${_owner}->${s.name}`;
2398
+ const prev = containsPick.get(key);
2399
+ if (prev === void 0) {
2400
+ containsPick.set(key, s);
2401
+ continue;
2402
+ }
2403
+ if (!isDefinition(prev) && isDefinition(s)) {
2404
+ containsPick.set(key, s);
2405
+ continue;
2406
+ }
2407
+ if (isDefinition(prev) && !isDefinition(s)) continue;
2408
+ if (s.range.startLine < prev.range.startLine) containsPick.set(key, s);
2409
+ }
2410
+ for (const s of containsPick.values()) {
2411
+ if (s.metadata?.isForwardDeclaration === true) continue;
2412
+ if (!isPublishableName(s.name)) continue;
2413
+ pushRel(s.ownerName, s.name, ASTEngine.RelationshipType.Contains, 1, {}, s.range.startLine);
2414
+ }
2415
+ const isNsLevelDefinition = (s) => {
2416
+ if (!s.ownerName) return false;
2417
+ if (s.metadata?.isAnonymous === true) return false;
2418
+ if (s.metadata?.isForwardDeclaration === true || s.metadata?.isSpec === true) return false;
2419
+ if (s.metadata?.isMethodImpl === true) return false;
2420
+ if (s.ownerName !== s.scope) return false;
2421
+ return s.kind === ASTEngine.SymbolKind.Function || s.kind === ASTEngine.SymbolKind.Variable || s.kind === ASTEngine.SymbolKind.Class || s.kind === ASTEngine.SymbolKind.Interface;
2422
+ };
2423
+ const nsDefGroups = /* @__PURE__ */ new Map();
2424
+ for (const s of symbols) {
2425
+ if (!isNsLevelDefinition(s)) continue;
2426
+ const cond = readCondOf(s.range.startIndex ?? 0);
2427
+ const groupId = cond !== 0 ? `c${cond}` : `f${s.range.startIndex ?? 0}`;
2428
+ const key = `${s.ownerName}->${s.name}`;
2429
+ let byCond = nsDefGroups.get(key);
2430
+ if (!byCond) {
2431
+ byCond = [];
2432
+ nsDefGroups.set(key, byCond);
2433
+ }
2434
+ const existing = byCond.find((g) => g.groupId === groupId);
2435
+ if (existing) existing.syms.push(s);
2436
+ else byCond.push({ groupId, syms: [s] });
2437
+ }
2438
+ for (const byCond of nsDefGroups.values()) {
2439
+ if (byCond.length < 2) continue;
2440
+ const ordered = byCond.map((g) => g.syms.reduce((a, b) => a.range.startLine <= b.range.startLine ? a : b)).sort((a, b) => a.range.startLine - b.range.startLine);
2441
+ const first = ordered[0];
2442
+ for (let i = 1; i < ordered.length; i++) {
2443
+ const later = ordered[i];
2444
+ pushRel(later.ownerName, later.name, ASTEngine.RelationshipType.Overrides, 1, {
2445
+ clojureSpecific: true,
2446
+ evidenceClass: "structural",
2447
+ redefinition: true,
2448
+ overridesLine: first.range.startLine,
2449
+ definitionCount: ordered.length
2450
+ }, later.range.startLine);
2451
+ }
2452
+ }
2453
+ const exportedKinds = /* @__PURE__ */ new Set([
2454
+ ASTEngine.SymbolKind.Function,
2455
+ ASTEngine.SymbolKind.Variable,
2456
+ ASTEngine.SymbolKind.Class,
2457
+ ASTEngine.SymbolKind.Interface,
2458
+ ASTEngine.SymbolKind.Module
2459
+ ]);
2460
+ const seenExports = /* @__PURE__ */ new Set();
2461
+ const finalExports = [];
2462
+ const finalExportNs = [];
2463
+ const definedNames = /* @__PURE__ */ new Set();
2464
+ for (const s of symbols) {
2465
+ if (s.metadata?.isForwardDeclaration) continue;
2466
+ if (s.metadata?.isSpec) continue;
2467
+ definedNames.add(s.name);
2468
+ }
2469
+ for (const s of symbols) {
2470
+ if (s.metadata?.isMethodImpl === true || s.metadata?.isProtocolMethodImpl === true || s.metadata?.isRecordMethod === true) continue;
2471
+ if (!isPublishableName(s.name)) continue;
2472
+ const isNSLevel = !s.scope || s.scope === currentNamespace || s.ownerName === currentNamespace;
2473
+ if (s.metadata?.isForwardDeclaration) continue;
2474
+ if (s.metadata?.isSpec && definedNames.has(s.name)) continue;
2475
+ if (isNSLevel && s.visibility === "public" && exportedKinds.has(s.kind)) {
2476
+ const key = `${s.name}|${s.kind}`;
2477
+ if (seenExports.has(key)) continue;
2478
+ seenExports.add(key);
2479
+ finalExports.push({ name: s.name, kind: s.kind, range: s.range, visibility: s.visibility });
2480
+ finalExportNs.push(s.ownerName ? s.ownerName : s.kind === ASTEngine.SymbolKind.Module ? s.name : currentNamespace);
2481
+ }
2482
+ }
2483
+ for (let _i = 0; _i < exports.length; _i++) {
2484
+ const e = exports[_i];
2485
+ if (e.visibility && e.visibility !== "public") continue;
2486
+ if (!isPublishableName(e.name)) continue;
2487
+ const key = `${e.name}|${e.kind}`;
2488
+ if (seenExports.has(key)) continue;
2489
+ seenExports.add(key);
2490
+ finalExports.push(e);
2491
+ finalExportNs.push(exportNamespaces[_i] ?? currentNamespace);
2492
+ }
2493
+ exports.length = 0;
2494
+ exports.push(...finalExports);
2495
+ const exportEdgeSeen = /* @__PURE__ */ new Set();
2496
+ for (let _i = 0; _i < finalExports.length; _i++) {
2497
+ const e = finalExports[_i];
2498
+ const ns = finalExportNs[_i] ?? currentNamespace;
2499
+ if (!ns || !e.name) continue;
2500
+ if (ns === e.name) continue;
2501
+ const key = `${ns}->${e.name}`;
2502
+ if (exportEdgeSeen.has(key)) continue;
2503
+ exportEdgeSeen.add(key);
2504
+ pushRel(
2505
+ ns,
2506
+ e.name,
2507
+ ASTEngine.RelationshipType.Exports,
2508
+ 1,
2509
+ { clojureSpecific: true, isNamespaceExport: true, evidenceClass: "structural" },
2510
+ e.range?.startLine ?? 0
2511
+ );
2512
+ }
2513
+ const protoDeclares = /* @__PURE__ */ new Map();
2514
+ for (const s of symbols) {
2515
+ if (!(s.metadata?.isProtocolMethod || s.metadata?.isInterfaceMethod)) continue;
2516
+ const owner = s.ownerName;
2517
+ if (!owner) continue;
2518
+ let set = protoDeclares.get(owner);
2519
+ if (!set) {
2520
+ set = /* @__PURE__ */ new Set();
2521
+ protoDeclares.set(owner, set);
2522
+ }
2523
+ set.add(s.name);
2524
+ }
2525
+ const protoBySimple = /* @__PURE__ */ new Map();
2526
+ for (const pn of protoDeclares.keys()) {
2527
+ const seg = pn.indexOf(".") >= 0 ? pn.slice(pn.lastIndexOf(".") + 1) : pn;
2528
+ const cur = protoBySimple.get(seg);
2529
+ if (cur) cur.push(pn);
2530
+ else protoBySimple.set(seg, [pn]);
2531
+ }
2532
+ const overrideSeen = /* @__PURE__ */ new Set();
2533
+ for (const cand of overrideCandidates) {
2534
+ let proto = "";
2535
+ for (const p of cand.protos) {
2536
+ if (protoDeclares.has(p)) {
2537
+ proto = p;
2538
+ break;
2539
+ }
2540
+ if (p.indexOf(".") < 0) continue;
2541
+ const cands = protoBySimple.get(p.slice(p.lastIndexOf(".") + 1)) ?? [];
2542
+ if (cands.length === 1) {
2543
+ proto = cands[0];
2544
+ break;
2545
+ }
2546
+ }
2547
+ if (!proto) continue;
2548
+ const declares = protoDeclares.get(proto);
2549
+ if (!declares || !declares.has(cand.method)) continue;
2550
+ const src = `${cand.type}.${cand.method}`;
2551
+ const tgt = `${proto}.${cand.method}`;
2552
+ if (src === tgt) continue;
2553
+ const key = `${src}->${tgt}`;
2554
+ if (overrideSeen.has(key)) continue;
2555
+ overrideSeen.add(key);
2556
+ pushRel(
2557
+ src,
2558
+ tgt,
2559
+ ASTEngine.RelationshipType.Override,
2560
+ 1,
2561
+ {
2562
+ clojureSpecific: true,
2563
+ evidenceClass: "structural",
2564
+ isProtocolMethodOverride: true,
2565
+ isReify: cand.form === "reify",
2566
+ isProxy: cand.form === "proxy",
2567
+ isExtendType: cand.form === "extend-type",
2568
+ isExtendProtocol: cand.form === "extend-protocol",
2569
+ isRecord: cand.form === "defrecord",
2570
+ isType: cand.form === "deftype"
2571
+ },
2572
+ cand.line
2573
+ );
2574
+ }
2575
+ let pureCount = 0;
2576
+ let funcCount = 0;
2577
+ for (let _i = 0; _i < symbols.length; _i++) {
2578
+ const s = symbols[_i];
2579
+ if (s.kind === ASTEngine.SymbolKind.Function && !s.metadata?.isMultimethod) {
2580
+ funcCount++;
2581
+ if (s.metadata?.isPure) pureCount++;
2582
+ }
2583
+ }
2584
+ const immutabilityScore = funcCount > 0 ? Math.round(pureCount / funcCount * 100) : 0;
2585
+ const patternsArray = [];
2586
+ for (const p in patterns) patternsArray.push(p);
2587
+ const frameworksArray = [];
2588
+ for (const f in frameworks) frameworksArray.push(f);
2589
+ let score = 50 + immutabilityScore * 0.3;
2590
+ if (!!patterns["Metaprogramming"]) score += 10;
2591
+ if (!!patterns["Protocol-based Polymorphism"]) score += 10;
2592
+ if (!!patterns["Software Transactional Memory"]) score += 5;
2593
+ if (!!patterns["Immutable Data Structures"]) score += 5;
2594
+ if (totalCyclomaticComplexity === 0) totalCyclomaticComplexity = funcCount;
2595
+ {
2596
+ const localDecls = /* @__PURE__ */ new Set();
2597
+ for (const s of symbols) {
2598
+ if (s.kind === ASTEngine.SymbolKind.Function || s.kind === ASTEngine.SymbolKind.Macro || s.kind === ASTEngine.SymbolKind.Variable) localDecls.add(s.name);
2599
+ }
2600
+ for (let i = 0; i < relationships.length; i++) {
2601
+ const r = relationships[i];
2602
+ if (r.type !== ASTEngine.RelationshipType.Calls) continue;
2603
+ if (typeof r.target !== "string" || r.target.indexOf("/") !== -1 || r.target.indexOf(".") !== -1) continue;
2604
+ if (localDecls.has(r.target)) continue;
2605
+ const lib = referAt(r.target, relOrigins.get(i) ?? 0);
2606
+ if (lib) r.target = `${lib}/${r.target}`;
2607
+ }
2608
+ const seenFinal = /* @__PURE__ */ new Set();
2609
+ for (let i = relationships.length - 1; i >= 0; i--) {
2610
+ const r = relationships[i];
2611
+ const key = `${r.source}|${r.type}|${r.target}|${r.metadata?.callArity ?? ""}|${r.line_number ?? ""}`;
2612
+ if (seenFinal.has(key)) relationships.splice(i, 1);
2613
+ else seenFinal.add(key);
2614
+ }
2615
+ }
2616
+ for (const s of symbols) {
2617
+ const cx = s.metadata?.complexity;
2618
+ if (typeof cx === "number" && s.complexity === void 0) s.complexity = cx;
2619
+ }
2620
+ for (const s of symbols) {
2621
+ const sc = typeof s.scope === "string" ? s.scope : "";
2622
+ if (sc.length === 0 || sc === s.name) continue;
2623
+ s.qualifiedName = `${sc}/${s.name}`;
2624
+ }
2625
+ const LANGUAGE_NAMESPACE_ROOTS = ["clojure", "cljs", "js", "goog", "java", "javax"];
2626
+ {
2627
+ const rootOf = (target) => {
2628
+ if (target.length === 0) return null;
2629
+ const segs = splitOnNamespaceSeparators(target);
2630
+ for (let n = segs.length; n >= 1; n--) {
2631
+ const cand = segs.slice(0, n).join(".");
2632
+ if (LANGUAGE_NAMESPACE_ROOTS.includes(cand)) return cand;
2633
+ }
2634
+ return null;
2635
+ };
2636
+ const declaredHere = /* @__PURE__ */ new Set();
2637
+ for (const s2 of symbols) {
2638
+ if (typeof s2.name === "string" && s2.name.length > 0) declaredHere.add(s2.name);
2639
+ }
2640
+ for (const r of relationships) {
2641
+ const md = r.metadata;
2642
+ if (!md || md.languageNamespace !== void 0) continue;
2643
+ const tgt = typeof r.target === "string" ? r.target : "";
2644
+ if (tgt.length === 0 || declaredHere.has(tgt)) continue;
2645
+ const root = rootOf(tgt);
2646
+ if (root === null) continue;
2647
+ md.languageNamespace = LANGUAGE_NAMESPACE_ROOTS;
2648
+ md.languageNamespacePolicy = "strict-absent";
2649
+ md.languageNamespaceSlash = true;
2650
+ if (md.isExternalTarget !== true) {
2651
+ md.isExternalTarget = true;
2652
+ md.externalReason = "language-platform-namespace";
2653
+ md.externalSpecifier = root;
2654
+ }
2655
+ }
2656
+ }
2657
+ {
2658
+ const libspecs = /* @__PURE__ */ new Set();
2659
+ for (const im of imports) {
2660
+ const m = String(im?.module ?? "");
2661
+ if (m.length > 0) libspecs.add(m);
2662
+ }
2663
+ const libspecList = [...libspecs].sort((a, b) => b.length - a.length);
2664
+ for (const r of relationships) {
2665
+ const md = r.metadata;
2666
+ if (!md || md.packageScope !== void 0) continue;
2667
+ const tgt = typeof r.target === "string" ? r.target : "";
2668
+ if (tgt.length === 0) continue;
2669
+ let member = "";
2670
+ let lib = "";
2671
+ for (const l of libspecList) {
2672
+ if (tgt === l) {
2673
+ member = l;
2674
+ lib = l;
2675
+ break;
2676
+ }
2677
+ if (tgt.startsWith(l + "/")) {
2678
+ member = tgt.slice(l.length + 1);
2679
+ lib = l;
2680
+ break;
2681
+ }
2682
+ }
2683
+ if (member.length === 0 || lib.length === 0) continue;
2684
+ const root = lib.split(".")[0];
2685
+ if (LANGUAGE_NAMESPACE_ROOTS.includes(root)) continue;
2686
+ md.packageScope = { package: lib, name: member };
2687
+ }
2688
+ }
2689
+ this.classifyEvidenceTier(relationships);
2690
+ return {
2691
+ language: "clojure",
2692
+ symbols,
2693
+ relationships,
2694
+ imports,
2695
+ exports,
2696
+ errors,
2697
+ metadata: {
2698
+ complexity: symbols.length + relationships.length || 1,
2699
+ linesOfCode: content.split("\n").length,
2700
+ cyclomaticComplexity: totalCyclomaticComplexity || 1,
2701
+ framework: frameworksArray[0],
2702
+ patterns: patternsArray,
2703
+ detectedFrameworks: frameworksArray,
2704
+ frameworkPatterns: frameworksArray.length > 0 ? [{ framework: frameworksArray[0], patterns: patternsArray }] : [],
2705
+ architecturalInsights: [],
2706
+ architecturalScore: Math.min(100, Math.round(score)),
2707
+ codeQuality: score >= 80 ? "Excellent" : score >= 60 ? "Good" : "Fair",
2708
+ hasTypeInference: false,
2709
+ hasFrameworkIntelligence: true,
2710
+ immutabilityScore,
2711
+ concurrencyComplexity: !!patterns["Software Transactional Memory"] ? 1 : 0,
2712
+ replDrivenScore: !!patterns["REPL-driven Development"] ? 100 : 0,
2713
+ analysisVersion: "6.0-clojure-yogthos-grammar-pure-ast-single-pass"
2714
+ }
2715
+ };
2716
+ }
2717
+ /**
2718
+ * CLJ-EX3: the EMPTY result for a data file. `.edn` is a data format; this lane
2719
+ * publishes no symbols and no relationships for it (Lead ruling 2026-10-20). The
2720
+ * metadata is the honest zero: one line count, no complexity, no framework, no
2721
+ * type inference, no REPL-driven score, and the same analysisVersion the code
2722
+ * path carries so a consumer can tell a data file from a fallback parser.
2723
+ */
2724
+ dataOnlyResult(content) {
2725
+ return {
2726
+ language: "clojure",
2727
+ symbols: [],
2728
+ relationships: [],
2729
+ imports: [],
2730
+ exports: [],
2731
+ errors: [],
2732
+ metadata: {
2733
+ complexity: 1,
2734
+ linesOfCode: content.split("\n").length,
2735
+ cyclomaticComplexity: 1,
2736
+ framework: void 0,
2737
+ patterns: [],
2738
+ detectedFrameworks: [],
2739
+ frameworkPatterns: [],
2740
+ architecturalInsights: [],
2741
+ architecturalScore: 0,
2742
+ codeQuality: "Fair",
2743
+ hasTypeInference: false,
2744
+ hasFrameworkIntelligence: false,
2745
+ immutabilityScore: 0,
2746
+ concurrencyComplexity: 0,
2747
+ replDrivenScore: 0,
2748
+ analysisVersion: "6.0-clojure-yogthos-grammar-pure-ast-single-pass"
2749
+ }
2750
+ };
2751
+ }
2752
+ /**
2753
+ * M14.0.SPEC SECTION D — EVIDENCE TIERS. Before this pass the lane set `evidenceClass` on exactly
2754
+ * three emission sites (exports/imports/overrides, all `structural`), so section D's ">=2 distinct
2755
+ * tiers pinned" could not be satisfied truthfully and every other relationship carried no tier at
2756
+ * all. The mapping below is the FAMILY convention, copied from `real-typescript-analyzer.ts`
2757
+ * (`classifyEvidenceTier`) rather than invented: contains/exports structural, imports import_based,
2758
+ * references reference_qualified, extends/implements structural (or inferred below confidence 1),
2759
+ * overrides structural/usage_contextual/inferred by confidence, instantiates structural/usage_contextual,
2760
+ * everything else usage_contextual. METADATA ONLY: it adds no relationship, removes none, and
2761
+ * changes no endpoint — the graph is identical before and after (measured: 72/72 clojure fixtures
2762
+ * pass on both sides).
2763
+ */
2764
+ classifyEvidenceTier(relationships) {
2765
+ for (const r of relationships) {
2766
+ const md = r.metadata ?? (r.metadata = {});
2767
+ if (md.evidenceClass) continue;
2768
+ const t = String(r.type ?? r.relationshipType ?? "");
2769
+ const conf = typeof r.confidence === "number" ? r.confidence : 1;
2770
+ if (t === "contains" || t === "exports") {
2771
+ md.evidenceClass = "structural";
2772
+ continue;
2773
+ }
2774
+ if (t === "imports") {
2775
+ md.evidenceClass = "import_based";
2776
+ continue;
2777
+ }
2778
+ if (t === "references") {
2779
+ md.evidenceClass = "reference_qualified";
2780
+ continue;
2781
+ }
2782
+ if (t === "extends" || t === "implements") {
2783
+ md.evidenceClass = conf >= 1 ? "structural" : "inferred";
2784
+ continue;
2785
+ }
2786
+ if (t === "overrides") {
2787
+ md.evidenceClass = conf >= 1 ? "structural" : conf >= 0.85 ? "usage_contextual" : "inferred";
2788
+ continue;
2789
+ }
2790
+ if (t === "instantiates") {
2791
+ md.evidenceClass = conf >= 0.9 ? "structural" : "usage_contextual";
2792
+ continue;
2793
+ }
2794
+ md.evidenceClass = "usage_contextual";
2795
+ }
2796
+ }
2797
+ nodeToRange(node) {
2798
+ return {
2799
+ startLine: node.startPosition.row + 1,
2800
+ startColumn: node.startPosition.column + 1,
2801
+ endLine: node.endPosition.row + 1,
2802
+ endColumn: node.endPosition.column + 1,
2803
+ startIndex: node.startIndex,
2804
+ endIndex: node.endIndex
2805
+ };
2806
+ }
2807
+ };
2808
+ export {
2809
+ CLOJURE_CORE_BUILTINS,
2810
+ CLOJURE_SPECIAL_FORMS,
2811
+ RealClojureAnalyzer,
2812
+ carriesPrivateToken,
2813
+ endsWithIgnoreCase,
2814
+ isAnonArgShorthand,
2815
+ isPublishableName,
2816
+ splitOnNamespaceSeparators,
2817
+ whitespaceTokens
2818
+ };