@grafema/core 0.1.0-alpha.5 → 0.1.1-alpha

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 (391) hide show
  1. package/README.md +0 -1
  2. package/dist/Orchestrator.d.ts +24 -2
  3. package/dist/Orchestrator.d.ts.map +1 -1
  4. package/dist/Orchestrator.js +197 -24
  5. package/dist/config/ConfigLoader.d.ts +72 -0
  6. package/dist/config/ConfigLoader.d.ts.map +1 -0
  7. package/dist/config/ConfigLoader.js +187 -0
  8. package/dist/config/index.d.ts +6 -0
  9. package/dist/config/index.d.ts.map +1 -0
  10. package/dist/config/index.js +4 -0
  11. package/dist/core/ASTWorker.d.ts +11 -36
  12. package/dist/core/ASTWorker.d.ts.map +1 -1
  13. package/dist/core/ASTWorker.js +93 -99
  14. package/dist/core/CoverageAnalyzer.d.ts +65 -0
  15. package/dist/core/CoverageAnalyzer.d.ts.map +1 -0
  16. package/dist/core/CoverageAnalyzer.js +198 -0
  17. package/dist/core/FileNodeManager.d.ts +40 -0
  18. package/dist/core/FileNodeManager.d.ts.map +1 -0
  19. package/dist/core/FileNodeManager.js +84 -0
  20. package/dist/core/GraphFreshnessChecker.d.ts +33 -0
  21. package/dist/core/GraphFreshnessChecker.d.ts.map +1 -0
  22. package/dist/core/GraphFreshnessChecker.js +101 -0
  23. package/dist/core/HashUtils.d.ts +24 -0
  24. package/dist/core/HashUtils.d.ts.map +1 -0
  25. package/dist/core/HashUtils.js +45 -0
  26. package/dist/core/IncrementalReanalyzer.d.ts +36 -0
  27. package/dist/core/IncrementalReanalyzer.d.ts.map +1 -0
  28. package/dist/core/IncrementalReanalyzer.js +132 -0
  29. package/dist/core/NodeFactory.d.ts +225 -17
  30. package/dist/core/NodeFactory.d.ts.map +1 -1
  31. package/dist/core/NodeFactory.js +208 -18
  32. package/dist/core/ScopeTracker.d.ts +84 -0
  33. package/dist/core/ScopeTracker.d.ts.map +1 -0
  34. package/dist/core/ScopeTracker.js +116 -0
  35. package/dist/core/SemanticId.d.ts +90 -0
  36. package/dist/core/SemanticId.d.ts.map +1 -0
  37. package/dist/core/SemanticId.js +115 -0
  38. package/dist/core/VersionManager.d.ts.map +1 -1
  39. package/dist/core/VersionManager.js +3 -2
  40. package/dist/core/nodes/ArgumentExpressionNode.d.ts +43 -0
  41. package/dist/core/nodes/ArgumentExpressionNode.d.ts.map +1 -0
  42. package/dist/core/nodes/ArgumentExpressionNode.js +60 -0
  43. package/dist/core/nodes/ArrayLiteralNode.d.ts +27 -0
  44. package/dist/core/nodes/ArrayLiteralNode.d.ts.map +1 -0
  45. package/dist/core/nodes/ArrayLiteralNode.js +41 -0
  46. package/dist/core/nodes/CallSiteNode.d.ts +28 -0
  47. package/dist/core/nodes/CallSiteNode.d.ts.map +1 -1
  48. package/dist/core/nodes/CallSiteNode.js +46 -0
  49. package/dist/core/nodes/ClassNode.d.ts +33 -1
  50. package/dist/core/nodes/ClassNode.d.ts.map +1 -1
  51. package/dist/core/nodes/ClassNode.js +46 -2
  52. package/dist/core/nodes/DecoratorNode.d.ts +42 -0
  53. package/dist/core/nodes/DecoratorNode.d.ts.map +1 -0
  54. package/dist/core/nodes/DecoratorNode.js +62 -0
  55. package/dist/core/nodes/EnumNode.d.ts +42 -0
  56. package/dist/core/nodes/EnumNode.d.ts.map +1 -0
  57. package/dist/core/nodes/EnumNode.js +54 -0
  58. package/dist/core/nodes/ExportNode.d.ts +37 -1
  59. package/dist/core/nodes/ExportNode.d.ts.map +1 -1
  60. package/dist/core/nodes/ExportNode.js +48 -2
  61. package/dist/core/nodes/ExpressionNode.d.ts +97 -0
  62. package/dist/core/nodes/ExpressionNode.d.ts.map +1 -0
  63. package/dist/core/nodes/ExpressionNode.js +178 -0
  64. package/dist/core/nodes/ExternalModuleNode.d.ts +28 -0
  65. package/dist/core/nodes/ExternalModuleNode.d.ts.map +1 -0
  66. package/dist/core/nodes/ExternalModuleNode.js +41 -0
  67. package/dist/core/nodes/ExternalStdioNode.d.ts +13 -6
  68. package/dist/core/nodes/ExternalStdioNode.d.ts.map +1 -1
  69. package/dist/core/nodes/ExternalStdioNode.js +15 -8
  70. package/dist/core/nodes/FunctionNode.d.ts +36 -0
  71. package/dist/core/nodes/FunctionNode.d.ts.map +1 -1
  72. package/dist/core/nodes/FunctionNode.js +80 -1
  73. package/dist/core/nodes/ImportNode.d.ts +19 -5
  74. package/dist/core/nodes/ImportNode.d.ts.map +1 -1
  75. package/dist/core/nodes/ImportNode.js +23 -5
  76. package/dist/core/nodes/InterfaceNode.d.ts +46 -0
  77. package/dist/core/nodes/InterfaceNode.d.ts.map +1 -0
  78. package/dist/core/nodes/InterfaceNode.js +55 -0
  79. package/dist/core/nodes/IssueNode.d.ts +73 -0
  80. package/dist/core/nodes/IssueNode.d.ts.map +1 -0
  81. package/dist/core/nodes/IssueNode.js +129 -0
  82. package/dist/core/nodes/MethodCallNode.d.ts +30 -0
  83. package/dist/core/nodes/MethodCallNode.d.ts.map +1 -1
  84. package/dist/core/nodes/MethodCallNode.js +49 -0
  85. package/dist/core/nodes/MethodNode.d.ts +32 -0
  86. package/dist/core/nodes/MethodNode.d.ts.map +1 -1
  87. package/dist/core/nodes/MethodNode.js +48 -0
  88. package/dist/core/nodes/ModuleNode.d.ts +31 -0
  89. package/dist/core/nodes/ModuleNode.d.ts.map +1 -1
  90. package/dist/core/nodes/ModuleNode.js +37 -0
  91. package/dist/core/nodes/NetworkRequestNode.d.ts +54 -0
  92. package/dist/core/nodes/NetworkRequestNode.d.ts.map +1 -0
  93. package/dist/core/nodes/NetworkRequestNode.js +65 -0
  94. package/dist/core/nodes/ObjectLiteralNode.d.ts +27 -0
  95. package/dist/core/nodes/ObjectLiteralNode.d.ts.map +1 -0
  96. package/dist/core/nodes/ObjectLiteralNode.js +41 -0
  97. package/dist/core/nodes/ScopeNode.d.ts +31 -0
  98. package/dist/core/nodes/ScopeNode.d.ts.map +1 -1
  99. package/dist/core/nodes/ScopeNode.js +49 -0
  100. package/dist/core/nodes/TypeNode.d.ts +36 -0
  101. package/dist/core/nodes/TypeNode.d.ts.map +1 -0
  102. package/dist/core/nodes/TypeNode.js +53 -0
  103. package/dist/core/nodes/VariableDeclarationNode.d.ts +27 -0
  104. package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -1
  105. package/dist/core/nodes/VariableDeclarationNode.js +40 -0
  106. package/dist/core/nodes/index.d.ts +12 -1
  107. package/dist/core/nodes/index.d.ts.map +1 -1
  108. package/dist/core/nodes/index.js +14 -0
  109. package/dist/diagnostics/DiagnosticCollector.d.ts +98 -0
  110. package/dist/diagnostics/DiagnosticCollector.d.ts.map +1 -0
  111. package/dist/diagnostics/DiagnosticCollector.js +129 -0
  112. package/dist/diagnostics/DiagnosticReporter.d.ts +77 -0
  113. package/dist/diagnostics/DiagnosticReporter.d.ts.map +1 -0
  114. package/dist/diagnostics/DiagnosticReporter.js +159 -0
  115. package/dist/diagnostics/DiagnosticWriter.d.ts +31 -0
  116. package/dist/diagnostics/DiagnosticWriter.d.ts.map +1 -0
  117. package/dist/diagnostics/DiagnosticWriter.js +43 -0
  118. package/dist/diagnostics/index.d.ts +14 -0
  119. package/dist/diagnostics/index.d.ts.map +1 -0
  120. package/dist/diagnostics/index.js +11 -0
  121. package/dist/errors/GrafemaError.d.ts +118 -0
  122. package/dist/errors/GrafemaError.d.ts.map +1 -0
  123. package/dist/errors/GrafemaError.js +131 -0
  124. package/dist/index.d.ts +57 -1
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +54 -1
  127. package/dist/logging/Logger.d.ts +48 -0
  128. package/dist/logging/Logger.d.ts.map +1 -0
  129. package/dist/logging/Logger.js +134 -0
  130. package/dist/plugins/Plugin.d.ts +5 -1
  131. package/dist/plugins/Plugin.d.ts.map +1 -1
  132. package/dist/plugins/Plugin.js +33 -0
  133. package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -1
  134. package/dist/plugins/analysis/DatabaseAnalyzer.js +13 -6
  135. package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -1
  136. package/dist/plugins/analysis/ExpressAnalyzer.js +27 -19
  137. package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -1
  138. package/dist/plugins/analysis/ExpressRouteAnalyzer.js +21 -14
  139. package/dist/plugins/analysis/FetchAnalyzer.d.ts +1 -0
  140. package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -1
  141. package/dist/plugins/analysis/FetchAnalyzer.js +34 -14
  142. package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts +6 -3
  143. package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts.map +1 -1
  144. package/dist/plugins/analysis/IncrementalAnalysisPlugin.js +76 -80
  145. package/dist/plugins/analysis/JSASTAnalyzer.d.ts +180 -17
  146. package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -1
  147. package/dist/plugins/analysis/JSASTAnalyzer.js +1171 -471
  148. package/dist/plugins/analysis/ReactAnalyzer.d.ts.map +1 -1
  149. package/dist/plugins/analysis/ReactAnalyzer.js +56 -57
  150. package/dist/plugins/analysis/RustAnalyzer.d.ts.map +1 -1
  151. package/dist/plugins/analysis/RustAnalyzer.js +15 -10
  152. package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -1
  153. package/dist/plugins/analysis/SQLiteAnalyzer.js +9 -7
  154. package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts.map +1 -1
  155. package/dist/plugins/analysis/ServiceLayerAnalyzer.js +21 -9
  156. package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -1
  157. package/dist/plugins/analysis/SocketIOAnalyzer.js +27 -15
  158. package/dist/plugins/analysis/SystemDbAnalyzer.d.ts.map +1 -1
  159. package/dist/plugins/analysis/SystemDbAnalyzer.js +15 -5
  160. package/dist/plugins/analysis/ast/GraphBuilder.d.ts +34 -4
  161. package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -1
  162. package/dist/plugins/analysis/ast/GraphBuilder.js +318 -298
  163. package/dist/plugins/analysis/ast/IdGenerator.d.ts +105 -0
  164. package/dist/plugins/analysis/ast/IdGenerator.d.ts.map +1 -0
  165. package/dist/plugins/analysis/ast/IdGenerator.js +116 -0
  166. package/dist/plugins/analysis/ast/types.d.ts +176 -5
  167. package/dist/plugins/analysis/ast/types.d.ts.map +1 -1
  168. package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts +33 -0
  169. package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts.map +1 -0
  170. package/dist/plugins/analysis/ast/utils/createParameterNodes.js +89 -0
  171. package/dist/plugins/analysis/ast/utils/index.d.ts +6 -0
  172. package/dist/plugins/analysis/ast/utils/index.d.ts.map +1 -0
  173. package/dist/plugins/analysis/ast/utils/index.js +5 -0
  174. package/dist/plugins/analysis/ast/utils/location.d.ts +87 -0
  175. package/dist/plugins/analysis/ast/utils/location.d.ts.map +1 -0
  176. package/dist/plugins/analysis/ast/utils/location.js +78 -0
  177. package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +9 -4
  178. package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -1
  179. package/dist/plugins/analysis/ast/visitors/ASTVisitor.js +6 -5
  180. package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +99 -9
  181. package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -1
  182. package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +663 -125
  183. package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts +4 -1
  184. package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts.map +1 -1
  185. package/dist/plugins/analysis/ast/visitors/ClassVisitor.js +72 -32
  186. package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +4 -1
  187. package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -1
  188. package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +128 -63
  189. package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -1
  190. package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +11 -8
  191. package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts +12 -1
  192. package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts.map +1 -1
  193. package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.js +36 -14
  194. package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +4 -1
  195. package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -1
  196. package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +17 -13
  197. package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts.map +1 -1
  198. package/dist/plugins/discovery/MonorepoServiceDiscovery.js +3 -2
  199. package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts.map +1 -1
  200. package/dist/plugins/discovery/SimpleProjectDiscovery.js +5 -1
  201. package/dist/plugins/discovery/WorkspaceDiscovery.d.ts +22 -0
  202. package/dist/plugins/discovery/WorkspaceDiscovery.d.ts.map +1 -0
  203. package/dist/plugins/discovery/WorkspaceDiscovery.js +136 -0
  204. package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts +46 -0
  205. package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts.map +1 -0
  206. package/dist/plugins/discovery/resolveSourceEntrypoint.js +86 -0
  207. package/dist/plugins/discovery/workspaces/detector.d.ts +21 -0
  208. package/dist/plugins/discovery/workspaces/detector.d.ts.map +1 -0
  209. package/dist/plugins/discovery/workspaces/detector.js +49 -0
  210. package/dist/plugins/discovery/workspaces/globResolver.d.ts +35 -0
  211. package/dist/plugins/discovery/workspaces/globResolver.d.ts.map +1 -0
  212. package/dist/plugins/discovery/workspaces/globResolver.js +184 -0
  213. package/dist/plugins/discovery/workspaces/index.d.ts +9 -0
  214. package/dist/plugins/discovery/workspaces/index.d.ts.map +1 -0
  215. package/dist/plugins/discovery/workspaces/index.js +8 -0
  216. package/dist/plugins/discovery/workspaces/parsers.d.ts +38 -0
  217. package/dist/plugins/discovery/workspaces/parsers.d.ts.map +1 -0
  218. package/dist/plugins/discovery/workspaces/parsers.js +80 -0
  219. package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -1
  220. package/dist/plugins/enrichment/AliasTracker.js +14 -8
  221. package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -1
  222. package/dist/plugins/enrichment/HTTPConnectionEnricher.js +14 -7
  223. package/dist/plugins/enrichment/ImportExportLinker.d.ts.map +1 -1
  224. package/dist/plugins/enrichment/ImportExportLinker.js +23 -6
  225. package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -1
  226. package/dist/plugins/enrichment/MethodCallResolver.js +18 -12
  227. package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -1
  228. package/dist/plugins/enrichment/MountPointResolver.js +8 -3
  229. package/dist/plugins/enrichment/PrefixEvaluator.d.ts.map +1 -1
  230. package/dist/plugins/enrichment/PrefixEvaluator.js +16 -7
  231. package/dist/plugins/enrichment/RustFFIEnricher.d.ts.map +1 -1
  232. package/dist/plugins/enrichment/RustFFIEnricher.js +6 -5
  233. package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +17 -0
  234. package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -1
  235. package/dist/plugins/enrichment/ValueDomainAnalyzer.js +129 -10
  236. package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts.map +1 -1
  237. package/dist/plugins/indexing/IncrementalModuleIndexer.js +23 -14
  238. package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -1
  239. package/dist/plugins/indexing/JSModuleIndexer.js +63 -31
  240. package/dist/plugins/indexing/RustModuleIndexer.d.ts.map +1 -1
  241. package/dist/plugins/indexing/RustModuleIndexer.js +5 -4
  242. package/dist/plugins/indexing/ServiceDetector.d.ts +10 -0
  243. package/dist/plugins/indexing/ServiceDetector.d.ts.map +1 -1
  244. package/dist/plugins/indexing/ServiceDetector.js +28 -15
  245. package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -1
  246. package/dist/plugins/validation/CallResolverValidator.js +8 -7
  247. package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -1
  248. package/dist/plugins/validation/DataFlowValidator.js +17 -12
  249. package/dist/plugins/validation/EvalBanValidator.d.ts.map +1 -1
  250. package/dist/plugins/validation/EvalBanValidator.js +17 -16
  251. package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -1
  252. package/dist/plugins/validation/GraphConnectivityValidator.js +19 -23
  253. package/dist/plugins/validation/NodeCreationValidator.d.ts +85 -0
  254. package/dist/plugins/validation/NodeCreationValidator.d.ts.map +1 -0
  255. package/dist/plugins/validation/NodeCreationValidator.js +415 -0
  256. package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -1
  257. package/dist/plugins/validation/SQLInjectionValidator.js +59 -16
  258. package/dist/plugins/validation/ShadowingDetector.d.ts.map +1 -1
  259. package/dist/plugins/validation/ShadowingDetector.js +6 -5
  260. package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts.map +1 -1
  261. package/dist/plugins/validation/TypeScriptDeadCodeValidator.js +12 -11
  262. package/dist/plugins/vcs/GitPlugin.d.ts.map +1 -1
  263. package/dist/plugins/vcs/GitPlugin.js +10 -12
  264. package/dist/plugins/vcs/VCSPlugin.d.ts +3 -2
  265. package/dist/plugins/vcs/VCSPlugin.d.ts.map +1 -1
  266. package/dist/plugins/vcs/VCSPlugin.js +5 -5
  267. package/dist/storage/backends/RFDBServerBackend.d.ts +10 -17
  268. package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -1
  269. package/dist/storage/backends/RFDBServerBackend.js +31 -10
  270. package/dist/validation/PathValidator.d.ts +1 -2
  271. package/dist/validation/PathValidator.d.ts.map +1 -1
  272. package/package.json +3 -3
  273. package/src/Orchestrator.ts +237 -24
  274. package/src/config/ConfigLoader.ts +263 -0
  275. package/src/config/index.ts +5 -0
  276. package/src/core/ASTWorker.ts +143 -139
  277. package/src/core/CoverageAnalyzer.ts +243 -0
  278. package/src/core/FileNodeManager.ts +100 -0
  279. package/src/core/GraphFreshnessChecker.ts +143 -0
  280. package/src/core/HashUtils.ts +48 -0
  281. package/src/core/IncrementalReanalyzer.ts +192 -0
  282. package/src/core/NodeFactory.ts +401 -18
  283. package/src/core/ScopeTracker.ts +154 -0
  284. package/src/core/SemanticId.ts +192 -0
  285. package/src/core/VersionManager.ts +3 -2
  286. package/src/core/nodes/ArgumentExpressionNode.ts +89 -0
  287. package/src/core/nodes/ArrayLiteralNode.ts +65 -0
  288. package/src/core/nodes/CallSiteNode.ts +58 -0
  289. package/src/core/nodes/ClassNode.ts +63 -2
  290. package/src/core/nodes/DecoratorNode.ts +91 -0
  291. package/src/core/nodes/EnumNode.ts +86 -0
  292. package/src/core/nodes/ExportNode.ts +70 -2
  293. package/src/core/nodes/ExpressionNode.ts +231 -0
  294. package/src/core/nodes/ExternalModuleNode.ts +56 -0
  295. package/src/core/nodes/ExternalStdioNode.ts +17 -9
  296. package/src/core/nodes/FunctionNode.ts +101 -1
  297. package/src/core/nodes/ImportNode.ts +32 -10
  298. package/src/core/nodes/InterfaceNode.ts +91 -0
  299. package/src/core/nodes/IssueNode.ts +177 -0
  300. package/src/core/nodes/MethodCallNode.ts +64 -0
  301. package/src/core/nodes/MethodNode.ts +63 -0
  302. package/src/core/nodes/ModuleNode.ts +50 -0
  303. package/src/core/nodes/NetworkRequestNode.ts +77 -0
  304. package/src/core/nodes/ObjectLiteralNode.ts +65 -0
  305. package/src/core/nodes/ScopeNode.ts +65 -0
  306. package/src/core/nodes/TypeNode.ts +78 -0
  307. package/src/core/nodes/VariableDeclarationNode.ts +52 -0
  308. package/src/core/nodes/index.ts +18 -1
  309. package/src/diagnostics/DiagnosticCollector.ts +163 -0
  310. package/src/diagnostics/DiagnosticReporter.ts +204 -0
  311. package/src/diagnostics/DiagnosticWriter.ts +50 -0
  312. package/src/diagnostics/index.ts +16 -0
  313. package/src/errors/GrafemaError.ts +174 -0
  314. package/src/index.ts +148 -1
  315. package/src/logging/Logger.ts +152 -0
  316. package/src/plugins/Plugin.ts +42 -0
  317. package/src/plugins/analysis/DatabaseAnalyzer.ts +14 -8
  318. package/src/plugins/analysis/ExpressAnalyzer.ts +29 -19
  319. package/src/plugins/analysis/ExpressRouteAnalyzer.ts +22 -21
  320. package/src/plugins/analysis/FetchAnalyzer.ts +39 -16
  321. package/src/plugins/analysis/IncrementalAnalysisPlugin.ts +84 -101
  322. package/src/plugins/analysis/JSASTAnalyzer.ts +1483 -503
  323. package/src/plugins/analysis/ReactAnalyzer.ts +57 -57
  324. package/src/plugins/analysis/RustAnalyzer.ts +15 -10
  325. package/src/plugins/analysis/SQLiteAnalyzer.ts +10 -7
  326. package/src/plugins/analysis/ServiceLayerAnalyzer.ts +22 -16
  327. package/src/plugins/analysis/SocketIOAnalyzer.ts +31 -22
  328. package/src/plugins/analysis/SystemDbAnalyzer.ts +16 -11
  329. package/src/plugins/analysis/ast/GraphBuilder.ts +439 -327
  330. package/src/plugins/analysis/ast/IdGenerator.ts +177 -0
  331. package/src/plugins/analysis/ast/types.ts +209 -6
  332. package/src/plugins/analysis/ast/utils/createParameterNodes.ts +104 -0
  333. package/src/plugins/analysis/ast/utils/index.ts +12 -0
  334. package/src/plugins/analysis/ast/utils/location.ts +103 -0
  335. package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +11 -8
  336. package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +909 -83
  337. package/src/plugins/analysis/ast/visitors/ClassVisitor.ts +97 -44
  338. package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +159 -93
  339. package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +12 -8
  340. package/src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts +41 -14
  341. package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +37 -17
  342. package/src/plugins/discovery/MonorepoServiceDiscovery.ts +3 -2
  343. package/src/plugins/discovery/SimpleProjectDiscovery.ts +6 -1
  344. package/src/plugins/discovery/WorkspaceDiscovery.ts +177 -0
  345. package/src/plugins/discovery/resolveSourceEntrypoint.ts +103 -0
  346. package/src/plugins/discovery/workspaces/detector.ts +63 -0
  347. package/src/plugins/discovery/workspaces/globResolver.ts +229 -0
  348. package/src/plugins/discovery/workspaces/index.ts +23 -0
  349. package/src/plugins/discovery/workspaces/parsers.ts +99 -0
  350. package/src/plugins/enrichment/AliasTracker.ts +14 -8
  351. package/src/plugins/enrichment/HTTPConnectionEnricher.ts +14 -7
  352. package/src/plugins/enrichment/ImportExportLinker.ts +24 -6
  353. package/src/plugins/enrichment/MethodCallResolver.ts +18 -12
  354. package/src/plugins/enrichment/MountPointResolver.ts +8 -3
  355. package/src/plugins/enrichment/PrefixEvaluator.ts +16 -7
  356. package/src/plugins/enrichment/RustFFIEnricher.ts +6 -5
  357. package/src/plugins/enrichment/ValueDomainAnalyzer.ts +149 -12
  358. package/src/plugins/indexing/IncrementalModuleIndexer.ts +23 -14
  359. package/src/plugins/indexing/JSModuleIndexer.ts +74 -34
  360. package/src/plugins/indexing/RustModuleIndexer.ts +5 -4
  361. package/src/plugins/validation/CallResolverValidator.ts +8 -7
  362. package/src/plugins/validation/DataFlowValidator.ts +16 -12
  363. package/src/plugins/validation/EvalBanValidator.ts +17 -16
  364. package/src/plugins/validation/GraphConnectivityValidator.ts +19 -23
  365. package/src/plugins/validation/NodeCreationValidator.ts +554 -0
  366. package/src/plugins/validation/SQLInjectionValidator.ts +61 -15
  367. package/src/plugins/validation/ShadowingDetector.ts +6 -5
  368. package/src/plugins/validation/TypeScriptDeadCodeValidator.ts +12 -11
  369. package/src/plugins/vcs/GitPlugin.ts +40 -12
  370. package/src/plugins/vcs/VCSPlugin.ts +7 -5
  371. package/src/storage/backends/RFDBServerBackend.ts +43 -29
  372. package/src/validation/PathValidator.ts +1 -1
  373. package/dist/core/AnalysisWorker.d.ts +0 -14
  374. package/dist/core/AnalysisWorker.d.ts.map +0 -1
  375. package/dist/core/AnalysisWorker.js +0 -307
  376. package/dist/core/ParallelAnalyzer.d.ts +0 -120
  377. package/dist/core/ParallelAnalyzer.d.ts.map +0 -1
  378. package/dist/core/ParallelAnalyzer.js +0 -331
  379. package/dist/core/QueueWorker.d.ts +0 -12
  380. package/dist/core/QueueWorker.d.ts.map +0 -1
  381. package/dist/core/QueueWorker.js +0 -567
  382. package/dist/core/RFDBClient.d.ts +0 -179
  383. package/dist/core/RFDBClient.d.ts.map +0 -1
  384. package/dist/core/RFDBClient.js +0 -429
  385. package/dist/plugins/discovery/ZonServiceDiscovery.d.ts +0 -19
  386. package/dist/plugins/discovery/ZonServiceDiscovery.d.ts.map +0 -1
  387. package/dist/plugins/discovery/ZonServiceDiscovery.js +0 -204
  388. package/src/core/AnalysisWorker.ts +0 -410
  389. package/src/core/ParallelAnalyzer.ts +0 -476
  390. package/src/core/QueueWorker.ts +0 -780
  391. package/src/plugins/indexing/ServiceDetector.ts +0 -230
@@ -10,14 +10,17 @@
10
10
  */
11
11
  import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers } from './ASTVisitor.js';
12
12
  import type { AnalyzeFunctionBodyCallback } from './FunctionVisitor.js';
13
+ import { ScopeTracker } from '../../../../core/ScopeTracker.js';
13
14
  export declare class ClassVisitor extends ASTVisitor {
14
15
  private analyzeFunctionBody;
16
+ private scopeTracker;
15
17
  /**
16
18
  * @param module - Current module being analyzed
17
19
  * @param collections - Must contain arrays and counter refs
18
20
  * @param analyzeFunctionBody - Callback to analyze method internals
21
+ * @param scopeTracker - REQUIRED for semantic ID generation
19
22
  */
20
- constructor(module: VisitorModule, collections: VisitorCollections, analyzeFunctionBody: AnalyzeFunctionBodyCallback);
23
+ constructor(module: VisitorModule, collections: VisitorCollections, analyzeFunctionBody: AnalyzeFunctionBodyCallback, scopeTracker: ScopeTracker);
21
24
  /**
22
25
  * Extract decorator information from a Decorator node
23
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ClassVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/ClassVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAqDxE,qBAAa,YAAa,SAAQ,UAAU;IAC1C,OAAO,CAAC,mBAAmB,CAA8B;IAEzD;;;;OAIG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,EAAE,2BAA2B;IAMlD;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA6C5B,WAAW,IAAI,eAAe;CAqM/B"}
1
+ {"version":3,"file":"ClassVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/ClassVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAIxE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAgDhE,qBAAa,YAAa,SAAQ,UAAU;IAC1C,OAAO,CAAC,mBAAmB,CAA8B;IACzD,OAAO,CAAC,YAAY,CAAe;IAEnC;;;;;OAKG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,EAAE,2BAA2B,EAChD,YAAY,EAAE,YAAY;IAO5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA+C5B,WAAW,IAAI,eAAe;CAqP/B"}
@@ -10,16 +10,24 @@
10
10
  */
11
11
  import { ASTVisitor } from './ASTVisitor.js';
12
12
  import { ExpressionEvaluator } from '../ExpressionEvaluator.js';
13
+ import { createParameterNodes } from '../utils/createParameterNodes.js';
14
+ import { ClassNode } from '../../../../core/nodes/ClassNode.js';
15
+ import { computeSemanticId } from '../../../../core/SemanticId.js';
16
+ import { getLine, getColumn } from '../utils/location.js';
13
17
  export class ClassVisitor extends ASTVisitor {
14
18
  analyzeFunctionBody;
19
+ scopeTracker;
15
20
  /**
16
21
  * @param module - Current module being analyzed
17
22
  * @param collections - Must contain arrays and counter refs
18
23
  * @param analyzeFunctionBody - Callback to analyze method internals
24
+ * @param scopeTracker - REQUIRED for semantic ID generation
19
25
  */
20
- constructor(module, collections, analyzeFunctionBody) {
26
+ constructor(module, collections, analyzeFunctionBody, scopeTracker // REQUIRED, not optional
27
+ ) {
21
28
  super(module, collections);
22
29
  this.analyzeFunctionBody = analyzeFunctionBody;
30
+ this.scopeTracker = scopeTracker;
23
31
  }
24
32
  /**
25
33
  * Extract decorator information from a Decorator node
@@ -50,14 +58,16 @@ export class ClassVisitor extends ASTVisitor {
50
58
  else {
51
59
  return null; // Unsupported decorator type
52
60
  }
53
- const decoratorId = `DECORATOR#${decoratorName}#${module.file}#${decorator.loc.start.line}:${decorator.loc.start.column}`;
61
+ const decoratorLine = getLine(decorator);
62
+ const decoratorColumn = getColumn(decorator);
63
+ const decoratorId = `DECORATOR#${decoratorName}#${module.file}#${decoratorLine}:${decoratorColumn}`;
54
64
  return {
55
65
  id: decoratorId,
56
66
  type: 'DECORATOR',
57
67
  name: decoratorName,
58
68
  file: module.file,
59
- line: decorator.loc.start.line,
60
- column: decorator.loc.start.column,
69
+ line: decoratorLine,
70
+ column: decoratorColumn,
61
71
  arguments: decoratorArgs,
62
72
  targetId,
63
73
  targetType
@@ -65,20 +75,24 @@ export class ClassVisitor extends ASTVisitor {
65
75
  }
66
76
  getHandlers() {
67
77
  const { module } = this;
68
- const { functions, scopes, classDeclarations, decorators } = this.collections;
78
+ const { functions, scopes, classDeclarations, decorators, parameters } = this.collections;
69
79
  const analyzeFunctionBody = this.analyzeFunctionBody;
70
80
  const collections = this.collections;
81
+ const scopeTracker = this.scopeTracker;
71
82
  return {
72
83
  ClassDeclaration: (classPath) => {
73
84
  const classNode = classPath.node;
74
85
  if (!classNode.id)
75
86
  return; // Skip anonymous classes
76
87
  const className = classNode.id.name;
77
- // Create CLASS node for declaration
78
- const classId = `CLASS#${className}#${module.file}#${classNode.loc.start.line}`;
88
+ // Extract superClass name
79
89
  const superClassName = classNode.superClass?.type === 'Identifier'
80
90
  ? classNode.superClass.name
81
91
  : null;
92
+ const classLine = getLine(classNode);
93
+ const classColumn = getColumn(classNode);
94
+ // Create CLASS node using NodeFactory with semantic ID
95
+ const classRecord = ClassNode.createWithContext(className, scopeTracker.getContext(), { line: classLine, column: classColumn }, { superClass: superClassName || undefined });
82
96
  // Extract implements (TypeScript)
83
97
  const implementsNames = [];
84
98
  const classNodeWithImplements = classNode;
@@ -89,22 +103,18 @@ export class ClassVisitor extends ASTVisitor {
89
103
  }
90
104
  }
91
105
  }
106
+ // Store ClassNodeRecord + TypeScript metadata
92
107
  classDeclarations.push({
93
- id: classId,
94
- type: 'CLASS',
95
- name: className,
96
- file: module.file,
97
- line: classNode.loc.start.line,
98
- column: classNode.loc.start.column,
99
- superClass: superClassName,
100
- implements: implementsNames.length > 0 ? implementsNames : undefined,
101
- methods: []
108
+ ...classRecord,
109
+ implements: implementsNames.length > 0 ? implementsNames : undefined
102
110
  });
111
+ // Enter class scope for tracking methods
112
+ scopeTracker.enterScope(className, 'CLASS');
103
113
  // Extract class decorators
104
114
  const classNodeWithDecorators = classNode;
105
115
  if (classNodeWithDecorators.decorators && classNodeWithDecorators.decorators.length > 0 && decorators) {
106
116
  for (const decorator of classNodeWithDecorators.decorators) {
107
- const decoratorInfo = this.extractDecoratorInfo(decorator, classId, 'CLASS', module);
117
+ const decoratorInfo = this.extractDecoratorInfo(decorator, classRecord.id, 'CLASS', module);
108
118
  if (decoratorInfo) {
109
119
  decorators.push(decoratorInfo);
110
120
  }
@@ -124,11 +134,13 @@ export class ClassVisitor extends ASTVisitor {
124
134
  const propName = propNode.key.type === 'Identifier'
125
135
  ? propNode.key.name
126
136
  : propNode.key.value || 'anonymous';
137
+ const propLine = getLine(propNode);
138
+ const propColumn = getColumn(propNode);
127
139
  // Extract property decorators (even for non-function properties)
128
140
  const propNodeWithDecorators = propNode;
129
141
  if (propNodeWithDecorators.decorators && propNodeWithDecorators.decorators.length > 0 && decorators) {
130
142
  // For function properties, target will be set later; for regular properties, create a target ID
131
- const propertyTargetId = `PROPERTY#${className}.${propName}#${module.file}#${propNode.loc.start.line}`;
143
+ const propertyTargetId = `PROPERTY#${className}.${propName}#${module.file}#${propLine}`;
132
144
  for (const decorator of propNodeWithDecorators.decorators) {
133
145
  const decoratorInfo = this.extractDecoratorInfo(decorator, propertyTargetId, 'PROPERTY', module);
134
146
  if (decoratorInfo) {
@@ -141,37 +153,49 @@ export class ClassVisitor extends ASTVisitor {
141
153
  (propNode.value.type === 'ArrowFunctionExpression' ||
142
154
  propNode.value.type === 'FunctionExpression')) {
143
155
  const funcNode = propNode.value;
144
- const functionId = `FUNCTION#${className}.${propName}#${module.file}#${propNode.loc.start.line}:${propNode.loc.start.column}`;
156
+ // Use semantic ID as primary ID (matching FunctionVisitor pattern)
157
+ const legacyId = `FUNCTION#${className}.${propName}#${module.file}#${propLine}:${propColumn}`;
158
+ const functionId = computeSemanticId('FUNCTION', propName, scopeTracker.getContext());
145
159
  // Add method to class methods list for CONTAINS edges
146
160
  currentClass.methods.push(functionId);
147
161
  functions.push({
148
162
  id: functionId,
149
- stableId: functionId,
150
163
  type: 'FUNCTION',
151
164
  name: propName,
152
165
  file: module.file,
153
- line: propNode.loc.start.line,
154
- column: propNode.loc.start.column,
166
+ line: propLine,
167
+ column: propColumn,
155
168
  async: funcNode.async || false,
156
169
  generator: funcNode.type === 'FunctionExpression' ? funcNode.generator || false : false,
157
170
  arrowFunction: funcNode.type === 'ArrowFunctionExpression',
158
171
  isClassProperty: true,
159
- className: className
172
+ className: className,
173
+ legacyId // Keep for debugging/migration purposes
160
174
  });
175
+ // Enter method scope for tracking
176
+ scopeTracker.enterScope(propName, 'FUNCTION');
177
+ // Create PARAMETER nodes for class property function parameters (REG-134)
178
+ if (parameters) {
179
+ createParameterNodes(funcNode.params, functionId, module.file, propLine, parameters, scopeTracker);
180
+ }
161
181
  // Create SCOPE for property function body
162
- const propBodyScopeId = `SCOPE#${className}.${propName}:body#${module.file}#${propNode.loc.start.line}`;
182
+ const propBodyScopeId = `SCOPE#${className}.${propName}:body#${module.file}#${propLine}`;
183
+ const propBodySemanticId = computeSemanticId('SCOPE', 'body', scopeTracker.getContext());
163
184
  scopes.push({
164
185
  id: propBodyScopeId,
186
+ semanticId: propBodySemanticId,
165
187
  type: 'SCOPE',
166
188
  scopeType: 'property_body',
167
189
  name: `${className}.${propName}:body`,
168
190
  conditional: false,
169
191
  file: module.file,
170
- line: propNode.loc.start.line,
192
+ line: propLine,
171
193
  parentFunctionId: functionId
172
194
  });
173
195
  const funcPath = propPath.get('value');
174
196
  analyzeFunctionBody(funcPath, propBodyScopeId, module, collections);
197
+ // Exit method scope
198
+ scopeTracker.exitScope();
175
199
  }
176
200
  },
177
201
  ClassMethod: (methodPath) => {
@@ -183,22 +207,26 @@ export class ClassVisitor extends ASTVisitor {
183
207
  if (methodPath.parent !== classNode.body) {
184
208
  return;
185
209
  }
186
- const functionId = `FUNCTION#${className}.${methodName}#${module.file}#${methodNode.loc.start.line}:${methodNode.loc.start.column}`;
210
+ const methodLine = getLine(methodNode);
211
+ const methodColumn = getColumn(methodNode);
212
+ // Use semantic ID as primary ID (matching FunctionVisitor pattern)
213
+ const legacyId = `FUNCTION#${className}.${methodName}#${module.file}#${methodLine}:${methodColumn}`;
214
+ const functionId = computeSemanticId('FUNCTION', methodName, scopeTracker.getContext());
187
215
  // Add method to class methods list for CONTAINS edges
188
216
  currentClass.methods.push(functionId);
189
217
  const funcData = {
190
218
  id: functionId,
191
- stableId: functionId,
192
219
  type: 'FUNCTION',
193
220
  name: methodName,
194
221
  file: module.file,
195
- line: methodNode.loc.start.line,
196
- column: methodNode.loc.start.column,
222
+ line: methodLine,
223
+ column: methodColumn,
197
224
  async: methodNode.async || false,
198
225
  generator: methodNode.generator || false,
199
226
  isClassMethod: true,
200
227
  className: className,
201
- methodKind: methodNode.kind
228
+ methodKind: methodNode.kind,
229
+ legacyId // Keep for debugging/migration purposes
202
230
  };
203
231
  functions.push(funcData);
204
232
  // Extract method decorators
@@ -211,21 +239,33 @@ export class ClassVisitor extends ASTVisitor {
211
239
  }
212
240
  }
213
241
  }
242
+ // Enter method scope for tracking
243
+ scopeTracker.enterScope(methodName, 'FUNCTION');
244
+ // Create PARAMETER nodes for class method parameters (REG-134)
245
+ if (parameters) {
246
+ createParameterNodes(methodNode.params, functionId, module.file, methodLine, parameters, scopeTracker);
247
+ }
214
248
  // Create SCOPE for method body
215
- const methodBodyScopeId = `SCOPE#${className}.${methodName}:body#${module.file}#${methodNode.loc.start.line}`;
249
+ const methodBodyScopeId = `SCOPE#${className}.${methodName}:body#${module.file}#${methodLine}`;
250
+ const methodBodySemanticId = computeSemanticId('SCOPE', 'body', scopeTracker.getContext());
216
251
  scopes.push({
217
252
  id: methodBodyScopeId,
253
+ semanticId: methodBodySemanticId,
218
254
  type: 'SCOPE',
219
255
  scopeType: 'method_body',
220
256
  name: `${className}.${methodName}:body`,
221
257
  conditional: false,
222
258
  file: module.file,
223
- line: methodNode.loc.start.line,
259
+ line: methodLine,
224
260
  parentFunctionId: functionId
225
261
  });
226
262
  analyzeFunctionBody(methodPath, methodBodyScopeId, module, collections);
263
+ // Exit method scope
264
+ scopeTracker.exitScope();
227
265
  }
228
266
  });
267
+ // Exit class scope
268
+ scopeTracker.exitScope();
229
269
  }
230
270
  };
231
271
  }
@@ -8,18 +8,21 @@
8
8
  import type { Function } from '@babel/types';
9
9
  import type { NodePath } from '@babel/traverse';
10
10
  import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers } from './ASTVisitor.js';
11
+ import { ScopeTracker } from '../../../../core/ScopeTracker.js';
11
12
  /**
12
13
  * Callback type for analyzing function bodies
13
14
  */
14
15
  export type AnalyzeFunctionBodyCallback = (path: NodePath<Function>, scopeId: string, module: VisitorModule, collections: VisitorCollections) => void;
15
16
  export declare class FunctionVisitor extends ASTVisitor {
16
17
  private analyzeFunctionBody;
18
+ private scopeTracker;
17
19
  /**
18
20
  * @param module - Current module being analyzed
19
21
  * @param collections - Must contain arrays and counter refs
20
22
  * @param analyzeFunctionBody - Callback to analyze function internals
23
+ * @param scopeTracker - REQUIRED for semantic ID generation
21
24
  */
22
- constructor(module: VisitorModule, collections: VisitorCollections, analyzeFunctionBody: AnalyzeFunctionBodyCallback);
25
+ constructor(module: VisitorModule, collections: VisitorCollections, analyzeFunctionBody: AnalyzeFunctionBodyCallback, scopeTracker: ScopeTracker);
23
26
  getHandlers(): VisitorHandlers;
24
27
  }
25
28
  //# sourceMappingURL=FunctionVisitor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/FunctionVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAEV,QAAQ,EAOT,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AAuDjI;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACxC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,KAC5B,IAAI,CAAC;AAEV,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,OAAO,CAAC,mBAAmB,CAA8B;IAEzD;;;;OAIG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,EAAE,2BAA2B;IAMlD,WAAW,IAAI,eAAe;CA2K/B"}
1
+ {"version":3,"file":"FunctionVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/FunctionVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAEV,QAAQ,EAQT,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AAEjI,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAwChE;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACxC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,KAC5B,IAAI,CAAC;AAEV,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,OAAO,CAAC,mBAAmB,CAA8B;IACzD,OAAO,CAAC,YAAY,CAAe;IAEnC;;;;;OAKG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,EAAE,2BAA2B,EAChD,YAAY,EAAE,YAAY;IAO5B,WAAW,IAAI,eAAe;CAqP/B"}
@@ -6,16 +6,23 @@
6
6
  * - ArrowFunctionExpression (module-level)
7
7
  */
8
8
  import { ASTVisitor } from './ASTVisitor.js';
9
+ import { typeNodeToString } from './TypeScriptVisitor.js';
10
+ import { IdGenerator } from '../IdGenerator.js';
11
+ import { createParameterNodes } from '../utils/createParameterNodes.js';
12
+ import { getLine, getColumn } from '../utils/location.js';
9
13
  export class FunctionVisitor extends ASTVisitor {
10
14
  analyzeFunctionBody;
15
+ scopeTracker;
11
16
  /**
12
17
  * @param module - Current module being analyzed
13
18
  * @param collections - Must contain arrays and counter refs
14
19
  * @param analyzeFunctionBody - Callback to analyze function internals
20
+ * @param scopeTracker - REQUIRED for semantic ID generation
15
21
  */
16
- constructor(module, collections, analyzeFunctionBody) {
22
+ constructor(module, collections, analyzeFunctionBody, scopeTracker) {
17
23
  super(module, collections);
18
24
  this.analyzeFunctionBody = analyzeFunctionBody;
25
+ this.scopeTracker = scopeTracker;
19
26
  }
20
27
  getHandlers() {
21
28
  const { module } = this;
@@ -23,71 +30,96 @@ export class FunctionVisitor extends ASTVisitor {
23
30
  const parameters = this.collections.parameters ?? [];
24
31
  const scopes = this.collections.scopes ?? [];
25
32
  const functionCounterRef = (this.collections.functionCounterRef ?? { value: 0 });
26
- const moduleScopeCtx = this.collections.moduleScopeCtx;
33
+ const scopeTracker = this.scopeTracker;
27
34
  const analyzeFunctionBody = this.analyzeFunctionBody;
28
35
  const collections = this.collections;
29
36
  // Helper function to generate stable anonymous function name
30
37
  const generateAnonymousName = () => {
31
- if (!moduleScopeCtx)
32
- return 'anonymous';
33
- const index = moduleScopeCtx.siblingCounters.get('anonymous') || 0;
34
- moduleScopeCtx.siblingCounters.set('anonymous', index + 1);
38
+ const index = scopeTracker.getSiblingIndex('anonymous');
35
39
  return `anonymous[${index}]`;
36
40
  };
37
- // Helper function to create PARAMETER nodes for function params
38
- const createParameterNodes = (params, functionId, file, line) => {
39
- if (!parameters)
40
- return; // Guard for backward compatibility
41
- params.forEach((param, index) => {
42
- // Handle different parameter types
41
+ // Helper function to extract parameter names and types from function params
42
+ const extractParamInfo = (params) => {
43
+ const names = [];
44
+ const types = [];
45
+ params.forEach((param) => {
43
46
  if (param.type === 'Identifier') {
44
- const paramId = `PARAMETER#${param.name}#${file}#${line}:${index}`;
45
- parameters.push({
46
- id: paramId,
47
- type: 'PARAMETER',
48
- name: param.name,
49
- file: file,
50
- line: param.loc?.start.line || line,
51
- index: index,
52
- parentFunctionId: functionId
53
- });
47
+ const id = param;
48
+ names.push(id.name);
49
+ // Check for type annotation
50
+ const typeAnnotation = id.typeAnnotation?.typeAnnotation;
51
+ types.push(typeAnnotation ? typeNodeToString(typeAnnotation) : 'any');
54
52
  }
55
53
  else if (param.type === 'AssignmentPattern') {
56
- // Default parameter: function(a = 1)
57
54
  const assignmentParam = param;
58
55
  if (assignmentParam.left.type === 'Identifier') {
59
- const paramId = `PARAMETER#${assignmentParam.left.name}#${file}#${line}:${index}`;
60
- parameters.push({
61
- id: paramId,
62
- type: 'PARAMETER',
63
- name: assignmentParam.left.name,
64
- file: file,
65
- line: assignmentParam.left.loc?.start.line || line,
66
- index: index,
67
- hasDefault: true,
68
- parentFunctionId: functionId
69
- });
56
+ const id = assignmentParam.left;
57
+ names.push(id.name + '?');
58
+ const typeAnnotation = id.typeAnnotation?.typeAnnotation;
59
+ types.push(typeAnnotation ? typeNodeToString(typeAnnotation) : 'any');
70
60
  }
71
61
  }
72
62
  else if (param.type === 'RestElement') {
73
- // Rest parameter: function(...args)
74
63
  const restParam = param;
75
64
  if (restParam.argument.type === 'Identifier') {
76
- const paramId = `PARAMETER#${restParam.argument.name}#${file}#${line}:${index}`;
77
- parameters.push({
78
- id: paramId,
79
- type: 'PARAMETER',
80
- name: restParam.argument.name,
81
- file: file,
82
- line: restParam.argument.loc?.start.line || line,
83
- index: index,
84
- isRest: true,
85
- parentFunctionId: functionId
86
- });
65
+ const id = restParam.argument;
66
+ names.push('...' + id.name);
67
+ const typeAnnotation = id.typeAnnotation?.typeAnnotation;
68
+ types.push(typeAnnotation ? typeNodeToString(typeAnnotation) : 'any[]');
87
69
  }
88
70
  }
89
- // ObjectPattern and ArrayPattern (destructuring parameters) can be added later
90
71
  });
72
+ return { names, types };
73
+ };
74
+ // Helper function to extract return type from function
75
+ const extractReturnType = (node) => {
76
+ const returnTypeAnnotation = node.returnType?.typeAnnotation;
77
+ if (returnTypeAnnotation) {
78
+ return typeNodeToString(returnTypeAnnotation);
79
+ }
80
+ return 'void';
81
+ };
82
+ // Helper function to extract JSDoc summary from leading comments
83
+ const extractJsdocSummary = (node) => {
84
+ const comments = node.leadingComments;
85
+ if (!comments || comments.length === 0)
86
+ return undefined;
87
+ // Find the last block comment that looks like JSDoc
88
+ for (let i = comments.length - 1; i >= 0; i--) {
89
+ const comment = comments[i];
90
+ if (comment.type === 'CommentBlock' && comment.value.startsWith('*')) {
91
+ // Parse JSDoc - get first non-empty line after the opening
92
+ const lines = comment.value.split('\n');
93
+ for (const line of lines) {
94
+ const trimmed = line.replace(/^\s*\*\s?/, '').trim();
95
+ // Skip empty lines and @tags
96
+ if (trimmed && !trimmed.startsWith('@')) {
97
+ return trimmed.slice(0, 200); // Limit length
98
+ }
99
+ }
100
+ }
101
+ }
102
+ return undefined;
103
+ };
104
+ // Helper function to build function signature
105
+ const buildSignature = (params, paramTypes, returnType, isAsync) => {
106
+ const paramParts = params.map((name, i) => {
107
+ const type = paramTypes[i] || 'any';
108
+ // Handle rest params
109
+ if (name.startsWith('...')) {
110
+ return `${name}: ${type}`;
111
+ }
112
+ // Handle optional params (with ?)
113
+ if (name.endsWith('?')) {
114
+ return `${name}: ${type}`;
115
+ }
116
+ return `${name}: ${type}`;
117
+ });
118
+ const paramsStr = `(${paramParts.join(', ')})`;
119
+ const retStr = isAsync && !returnType.startsWith('Promise')
120
+ ? `Promise<${returnType}>`
121
+ : returnType;
122
+ return `${paramsStr} => ${retStr}`;
91
123
  };
92
124
  return {
93
125
  // Regular function declarations
@@ -95,21 +127,36 @@ export class FunctionVisitor extends ASTVisitor {
95
127
  const node = path.node;
96
128
  if (!node.id)
97
129
  return; // Skip anonymous function declarations
98
- const functionId = `FUNCTION#${node.id.name}#${module.file}#${node.loc.start.line}`;
130
+ const isAsync = node.async || false;
131
+ const line = getLine(node);
132
+ // Generate ID using centralized IdGenerator
133
+ const idGenerator = new IdGenerator(scopeTracker);
134
+ const functionId = idGenerator.generateSimple('FUNCTION', node.id.name, module.file, line);
135
+ // Extract type info
136
+ const { names: paramNames, types: paramTypes } = extractParamInfo(node.params);
137
+ const returnType = extractReturnType(node);
138
+ const jsdocSummary = extractJsdocSummary(node);
139
+ const signature = buildSignature(paramNames, paramTypes, returnType, isAsync);
99
140
  functions.push({
100
141
  id: functionId,
101
- stableId: functionId,
102
142
  type: 'FUNCTION',
103
143
  name: node.id.name,
104
144
  file: module.file,
105
- line: node.loc.start.line,
106
- async: node.async || false,
107
- generator: node.generator || false
145
+ line,
146
+ async: isAsync,
147
+ generator: node.generator || false,
148
+ params: paramNames,
149
+ paramTypes,
150
+ returnType,
151
+ signature,
152
+ jsdocSummary
108
153
  });
154
+ // Enter function scope BEFORE creating parameters (semantic IDs need function context)
155
+ scopeTracker.enterScope(node.id.name, 'FUNCTION');
109
156
  // Create PARAMETER nodes for function parameters
110
- createParameterNodes(node.params, functionId, module.file, node.loc.start.line);
157
+ createParameterNodes(node.params, functionId, module.file, getLine(node), parameters, scopeTracker);
111
158
  // Create SCOPE for function body
112
- const functionBodyScopeId = `SCOPE#${node.id.name}:body#${module.file}#${node.loc.start.line}`;
159
+ const functionBodyScopeId = idGenerator.generateScope('body', `${node.id.name}:body`, module.file, line);
113
160
  scopes.push({
114
161
  id: functionBodyScopeId,
115
162
  type: 'SCOPE',
@@ -117,19 +164,22 @@ export class FunctionVisitor extends ASTVisitor {
117
164
  name: `${node.id.name}:body`,
118
165
  conditional: false,
119
166
  file: module.file,
120
- line: node.loc.start.line,
167
+ line,
121
168
  parentFunctionId: functionId
122
169
  });
123
170
  // Analyze function body
124
171
  analyzeFunctionBody(path, functionBodyScopeId, module, collections);
172
+ // Exit function scope
173
+ scopeTracker.exitScope();
125
174
  // Stop traversal - analyzeFunctionBody already processed contents
126
175
  path.skip();
127
176
  },
128
177
  // Arrow functions (module-level, assigned to variables or as callbacks)
129
178
  ArrowFunctionExpression: (path) => {
130
179
  const node = path.node;
131
- const line = node.loc.start.line;
132
- const column = node.loc.start.column;
180
+ const line = getLine(node);
181
+ const column = getColumn(node);
182
+ const isAsync = node.async || false;
133
183
  // Determine arrow function name (use scope-level counter for stable semanticId)
134
184
  let functionName = generateAnonymousName();
135
185
  // If arrow function is assigned to variable: const add = () => {}
@@ -140,22 +190,35 @@ export class FunctionVisitor extends ASTVisitor {
140
190
  functionName = declarator.id.name;
141
191
  }
142
192
  }
143
- const functionId = `FUNCTION#${functionName}#${module.file}#${line}:${column}:${functionCounterRef.value++}`;
193
+ // Generate ID using centralized IdGenerator
194
+ const idGenerator = new IdGenerator(scopeTracker);
195
+ const functionId = idGenerator.generate('FUNCTION', functionName, module.file, line, column, functionCounterRef);
196
+ // Extract type info
197
+ const { names: paramNames, types: paramTypes } = extractParamInfo(node.params);
198
+ const returnType = extractReturnType(node);
199
+ const jsdocSummary = extractJsdocSummary(node);
200
+ const signature = buildSignature(paramNames, paramTypes, returnType, isAsync);
144
201
  functions.push({
145
202
  id: functionId,
146
- stableId: functionId,
147
203
  type: 'FUNCTION',
148
204
  name: functionName,
149
205
  file: module.file,
150
206
  line,
151
207
  column,
152
- async: node.async || false,
153
- arrowFunction: true
208
+ async: isAsync,
209
+ arrowFunction: true,
210
+ params: paramNames,
211
+ paramTypes,
212
+ returnType,
213
+ signature,
214
+ jsdocSummary
154
215
  });
216
+ // Enter function scope BEFORE creating parameters (semantic IDs need function context)
217
+ scopeTracker.enterScope(functionName, 'FUNCTION');
155
218
  // Create PARAMETER nodes for arrow function parameters
156
- createParameterNodes(node.params, functionId, module.file, line);
219
+ createParameterNodes(node.params, functionId, module.file, line, parameters, scopeTracker);
157
220
  // Create SCOPE for arrow function body
158
- const bodyScope = `SCOPE#${functionName}:body#${module.file}#${line}:${column}`;
221
+ const bodyScope = idGenerator.generateScope('body', `${functionName}:body`, module.file, line, column);
159
222
  scopes.push({
160
223
  id: bodyScope,
161
224
  type: 'SCOPE',
@@ -166,6 +229,8 @@ export class FunctionVisitor extends ASTVisitor {
166
229
  parentFunctionId: functionId
167
230
  });
168
231
  analyzeFunctionBody(path, bodyScope, module, collections);
232
+ // Exit function scope
233
+ scopeTracker.exitScope();
169
234
  }
170
235
  };
171
236
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ImportExportVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/ImportExportVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAaV,IAAI,EACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;AAuC7E,qBAAa,mBAAoB,SAAQ,UAAU;IACjD,OAAO,CAAC,+BAA+B,CAA+B;IAEtE;;;;OAIG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,+BAA+B,EAAE,4BAA4B;IAM/D,iBAAiB,IAAI,eAAe;IA+CpC,iBAAiB,IAAI,eAAe;IAqHpC,WAAW,IAAI,eAAe;CAM/B"}
1
+ {"version":3,"file":"ImportExportVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/ImportExportVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAaV,IAAI,EACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;AAwC7E,qBAAa,mBAAoB,SAAQ,UAAU;IACjD,OAAO,CAAC,+BAA+B,CAA+B;IAEtE;;;;OAIG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,+BAA+B,EAAE,4BAA4B;IAM/D,iBAAiB,IAAI,eAAe;IAgDpC,iBAAiB,IAAI,eAAe;IAsHpC,WAAW,IAAI,eAAe;CAM/B"}