@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.
- package/README.md +0 -1
- package/dist/Orchestrator.d.ts +24 -2
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +197 -24
- package/dist/config/ConfigLoader.d.ts +72 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +187 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/core/ASTWorker.d.ts +11 -36
- package/dist/core/ASTWorker.d.ts.map +1 -1
- package/dist/core/ASTWorker.js +93 -99
- package/dist/core/CoverageAnalyzer.d.ts +65 -0
- package/dist/core/CoverageAnalyzer.d.ts.map +1 -0
- package/dist/core/CoverageAnalyzer.js +198 -0
- package/dist/core/FileNodeManager.d.ts +40 -0
- package/dist/core/FileNodeManager.d.ts.map +1 -0
- package/dist/core/FileNodeManager.js +84 -0
- package/dist/core/GraphFreshnessChecker.d.ts +33 -0
- package/dist/core/GraphFreshnessChecker.d.ts.map +1 -0
- package/dist/core/GraphFreshnessChecker.js +101 -0
- package/dist/core/HashUtils.d.ts +24 -0
- package/dist/core/HashUtils.d.ts.map +1 -0
- package/dist/core/HashUtils.js +45 -0
- package/dist/core/IncrementalReanalyzer.d.ts +36 -0
- package/dist/core/IncrementalReanalyzer.d.ts.map +1 -0
- package/dist/core/IncrementalReanalyzer.js +132 -0
- package/dist/core/NodeFactory.d.ts +225 -17
- package/dist/core/NodeFactory.d.ts.map +1 -1
- package/dist/core/NodeFactory.js +208 -18
- package/dist/core/ScopeTracker.d.ts +84 -0
- package/dist/core/ScopeTracker.d.ts.map +1 -0
- package/dist/core/ScopeTracker.js +116 -0
- package/dist/core/SemanticId.d.ts +90 -0
- package/dist/core/SemanticId.d.ts.map +1 -0
- package/dist/core/SemanticId.js +115 -0
- package/dist/core/VersionManager.d.ts.map +1 -1
- package/dist/core/VersionManager.js +3 -2
- package/dist/core/nodes/ArgumentExpressionNode.d.ts +43 -0
- package/dist/core/nodes/ArgumentExpressionNode.d.ts.map +1 -0
- package/dist/core/nodes/ArgumentExpressionNode.js +60 -0
- package/dist/core/nodes/ArrayLiteralNode.d.ts +27 -0
- package/dist/core/nodes/ArrayLiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/ArrayLiteralNode.js +41 -0
- package/dist/core/nodes/CallSiteNode.d.ts +28 -0
- package/dist/core/nodes/CallSiteNode.d.ts.map +1 -1
- package/dist/core/nodes/CallSiteNode.js +46 -0
- package/dist/core/nodes/ClassNode.d.ts +33 -1
- package/dist/core/nodes/ClassNode.d.ts.map +1 -1
- package/dist/core/nodes/ClassNode.js +46 -2
- package/dist/core/nodes/DecoratorNode.d.ts +42 -0
- package/dist/core/nodes/DecoratorNode.d.ts.map +1 -0
- package/dist/core/nodes/DecoratorNode.js +62 -0
- package/dist/core/nodes/EnumNode.d.ts +42 -0
- package/dist/core/nodes/EnumNode.d.ts.map +1 -0
- package/dist/core/nodes/EnumNode.js +54 -0
- package/dist/core/nodes/ExportNode.d.ts +37 -1
- package/dist/core/nodes/ExportNode.d.ts.map +1 -1
- package/dist/core/nodes/ExportNode.js +48 -2
- package/dist/core/nodes/ExpressionNode.d.ts +97 -0
- package/dist/core/nodes/ExpressionNode.d.ts.map +1 -0
- package/dist/core/nodes/ExpressionNode.js +178 -0
- package/dist/core/nodes/ExternalModuleNode.d.ts +28 -0
- package/dist/core/nodes/ExternalModuleNode.d.ts.map +1 -0
- package/dist/core/nodes/ExternalModuleNode.js +41 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts +13 -6
- package/dist/core/nodes/ExternalStdioNode.d.ts.map +1 -1
- package/dist/core/nodes/ExternalStdioNode.js +15 -8
- package/dist/core/nodes/FunctionNode.d.ts +36 -0
- package/dist/core/nodes/FunctionNode.d.ts.map +1 -1
- package/dist/core/nodes/FunctionNode.js +80 -1
- package/dist/core/nodes/ImportNode.d.ts +19 -5
- package/dist/core/nodes/ImportNode.d.ts.map +1 -1
- package/dist/core/nodes/ImportNode.js +23 -5
- package/dist/core/nodes/InterfaceNode.d.ts +46 -0
- package/dist/core/nodes/InterfaceNode.d.ts.map +1 -0
- package/dist/core/nodes/InterfaceNode.js +55 -0
- package/dist/core/nodes/IssueNode.d.ts +73 -0
- package/dist/core/nodes/IssueNode.d.ts.map +1 -0
- package/dist/core/nodes/IssueNode.js +129 -0
- package/dist/core/nodes/MethodCallNode.d.ts +30 -0
- package/dist/core/nodes/MethodCallNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodCallNode.js +49 -0
- package/dist/core/nodes/MethodNode.d.ts +32 -0
- package/dist/core/nodes/MethodNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodNode.js +48 -0
- package/dist/core/nodes/ModuleNode.d.ts +31 -0
- package/dist/core/nodes/ModuleNode.d.ts.map +1 -1
- package/dist/core/nodes/ModuleNode.js +37 -0
- package/dist/core/nodes/NetworkRequestNode.d.ts +54 -0
- package/dist/core/nodes/NetworkRequestNode.d.ts.map +1 -0
- package/dist/core/nodes/NetworkRequestNode.js +65 -0
- package/dist/core/nodes/ObjectLiteralNode.d.ts +27 -0
- package/dist/core/nodes/ObjectLiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/ObjectLiteralNode.js +41 -0
- package/dist/core/nodes/ScopeNode.d.ts +31 -0
- package/dist/core/nodes/ScopeNode.d.ts.map +1 -1
- package/dist/core/nodes/ScopeNode.js +49 -0
- package/dist/core/nodes/TypeNode.d.ts +36 -0
- package/dist/core/nodes/TypeNode.d.ts.map +1 -0
- package/dist/core/nodes/TypeNode.js +53 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts +27 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -1
- package/dist/core/nodes/VariableDeclarationNode.js +40 -0
- package/dist/core/nodes/index.d.ts +12 -1
- package/dist/core/nodes/index.d.ts.map +1 -1
- package/dist/core/nodes/index.js +14 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts +98 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticCollector.js +129 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts +77 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticReporter.js +159 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts +31 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticWriter.js +43 -0
- package/dist/diagnostics/index.d.ts +14 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +11 -0
- package/dist/errors/GrafemaError.d.ts +118 -0
- package/dist/errors/GrafemaError.d.ts.map +1 -0
- package/dist/errors/GrafemaError.js +131 -0
- package/dist/index.d.ts +57 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -1
- package/dist/logging/Logger.d.ts +48 -0
- package/dist/logging/Logger.d.ts.map +1 -0
- package/dist/logging/Logger.js +134 -0
- package/dist/plugins/Plugin.d.ts +5 -1
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/Plugin.js +33 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/DatabaseAnalyzer.js +13 -6
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressAnalyzer.js +27 -19
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressRouteAnalyzer.js +21 -14
- package/dist/plugins/analysis/FetchAnalyzer.d.ts +1 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/FetchAnalyzer.js +34 -14
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts +6 -3
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts.map +1 -1
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.js +76 -80
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts +180 -17
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/JSASTAnalyzer.js +1171 -471
- package/dist/plugins/analysis/ReactAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ReactAnalyzer.js +56 -57
- package/dist/plugins/analysis/RustAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/RustAnalyzer.js +15 -10
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SQLiteAnalyzer.js +9 -7
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ServiceLayerAnalyzer.js +21 -9
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SocketIOAnalyzer.js +27 -15
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SystemDbAnalyzer.js +15 -5
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts +34 -4
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/GraphBuilder.js +318 -298
- package/dist/plugins/analysis/ast/IdGenerator.d.ts +105 -0
- package/dist/plugins/analysis/ast/IdGenerator.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/IdGenerator.js +116 -0
- package/dist/plugins/analysis/ast/types.d.ts +176 -5
- package/dist/plugins/analysis/ast/types.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts +33 -0
- package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/createParameterNodes.js +89 -0
- package/dist/plugins/analysis/ast/utils/index.d.ts +6 -0
- package/dist/plugins/analysis/ast/utils/index.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/index.js +5 -0
- package/dist/plugins/analysis/ast/utils/location.d.ts +87 -0
- package/dist/plugins/analysis/ast/utils/location.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/location.js +78 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +9 -4
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.js +6 -5
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +99 -9
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +663 -125
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.js +72 -32
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +128 -63
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +11 -8
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts +12 -1
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.js +36 -14
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +17 -13
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts.map +1 -1
- package/dist/plugins/discovery/MonorepoServiceDiscovery.js +3 -2
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts.map +1 -1
- package/dist/plugins/discovery/SimpleProjectDiscovery.js +5 -1
- package/dist/plugins/discovery/WorkspaceDiscovery.d.ts +22 -0
- package/dist/plugins/discovery/WorkspaceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/WorkspaceDiscovery.js +136 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts +46 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts.map +1 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.js +86 -0
- package/dist/plugins/discovery/workspaces/detector.d.ts +21 -0
- package/dist/plugins/discovery/workspaces/detector.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/detector.js +49 -0
- package/dist/plugins/discovery/workspaces/globResolver.d.ts +35 -0
- package/dist/plugins/discovery/workspaces/globResolver.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/globResolver.js +184 -0
- package/dist/plugins/discovery/workspaces/index.d.ts +9 -0
- package/dist/plugins/discovery/workspaces/index.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/index.js +8 -0
- package/dist/plugins/discovery/workspaces/parsers.d.ts +38 -0
- package/dist/plugins/discovery/workspaces/parsers.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/parsers.js +80 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -1
- package/dist/plugins/enrichment/AliasTracker.js +14 -8
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -1
- package/dist/plugins/enrichment/HTTPConnectionEnricher.js +14 -7
- package/dist/plugins/enrichment/ImportExportLinker.d.ts.map +1 -1
- package/dist/plugins/enrichment/ImportExportLinker.js +23 -6
- package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MethodCallResolver.js +18 -12
- package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MountPointResolver.js +8 -3
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts.map +1 -1
- package/dist/plugins/enrichment/PrefixEvaluator.js +16 -7
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts.map +1 -1
- package/dist/plugins/enrichment/RustFFIEnricher.js +6 -5
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +17 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -1
- package/dist/plugins/enrichment/ValueDomainAnalyzer.js +129 -10
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/IncrementalModuleIndexer.js +23 -14
- package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/JSModuleIndexer.js +63 -31
- package/dist/plugins/indexing/RustModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/RustModuleIndexer.js +5 -4
- package/dist/plugins/indexing/ServiceDetector.d.ts +10 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts.map +1 -1
- package/dist/plugins/indexing/ServiceDetector.js +28 -15
- package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -1
- package/dist/plugins/validation/CallResolverValidator.js +8 -7
- package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -1
- package/dist/plugins/validation/DataFlowValidator.js +17 -12
- package/dist/plugins/validation/EvalBanValidator.d.ts.map +1 -1
- package/dist/plugins/validation/EvalBanValidator.js +17 -16
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -1
- package/dist/plugins/validation/GraphConnectivityValidator.js +19 -23
- package/dist/plugins/validation/NodeCreationValidator.d.ts +85 -0
- package/dist/plugins/validation/NodeCreationValidator.d.ts.map +1 -0
- package/dist/plugins/validation/NodeCreationValidator.js +415 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -1
- package/dist/plugins/validation/SQLInjectionValidator.js +59 -16
- package/dist/plugins/validation/ShadowingDetector.d.ts.map +1 -1
- package/dist/plugins/validation/ShadowingDetector.js +6 -5
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts.map +1 -1
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.js +12 -11
- package/dist/plugins/vcs/GitPlugin.d.ts.map +1 -1
- package/dist/plugins/vcs/GitPlugin.js +10 -12
- package/dist/plugins/vcs/VCSPlugin.d.ts +3 -2
- package/dist/plugins/vcs/VCSPlugin.d.ts.map +1 -1
- package/dist/plugins/vcs/VCSPlugin.js +5 -5
- package/dist/storage/backends/RFDBServerBackend.d.ts +10 -17
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -1
- package/dist/storage/backends/RFDBServerBackend.js +31 -10
- package/dist/validation/PathValidator.d.ts +1 -2
- package/dist/validation/PathValidator.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/Orchestrator.ts +237 -24
- package/src/config/ConfigLoader.ts +263 -0
- package/src/config/index.ts +5 -0
- package/src/core/ASTWorker.ts +143 -139
- package/src/core/CoverageAnalyzer.ts +243 -0
- package/src/core/FileNodeManager.ts +100 -0
- package/src/core/GraphFreshnessChecker.ts +143 -0
- package/src/core/HashUtils.ts +48 -0
- package/src/core/IncrementalReanalyzer.ts +192 -0
- package/src/core/NodeFactory.ts +401 -18
- package/src/core/ScopeTracker.ts +154 -0
- package/src/core/SemanticId.ts +192 -0
- package/src/core/VersionManager.ts +3 -2
- package/src/core/nodes/ArgumentExpressionNode.ts +89 -0
- package/src/core/nodes/ArrayLiteralNode.ts +65 -0
- package/src/core/nodes/CallSiteNode.ts +58 -0
- package/src/core/nodes/ClassNode.ts +63 -2
- package/src/core/nodes/DecoratorNode.ts +91 -0
- package/src/core/nodes/EnumNode.ts +86 -0
- package/src/core/nodes/ExportNode.ts +70 -2
- package/src/core/nodes/ExpressionNode.ts +231 -0
- package/src/core/nodes/ExternalModuleNode.ts +56 -0
- package/src/core/nodes/ExternalStdioNode.ts +17 -9
- package/src/core/nodes/FunctionNode.ts +101 -1
- package/src/core/nodes/ImportNode.ts +32 -10
- package/src/core/nodes/InterfaceNode.ts +91 -0
- package/src/core/nodes/IssueNode.ts +177 -0
- package/src/core/nodes/MethodCallNode.ts +64 -0
- package/src/core/nodes/MethodNode.ts +63 -0
- package/src/core/nodes/ModuleNode.ts +50 -0
- package/src/core/nodes/NetworkRequestNode.ts +77 -0
- package/src/core/nodes/ObjectLiteralNode.ts +65 -0
- package/src/core/nodes/ScopeNode.ts +65 -0
- package/src/core/nodes/TypeNode.ts +78 -0
- package/src/core/nodes/VariableDeclarationNode.ts +52 -0
- package/src/core/nodes/index.ts +18 -1
- package/src/diagnostics/DiagnosticCollector.ts +163 -0
- package/src/diagnostics/DiagnosticReporter.ts +204 -0
- package/src/diagnostics/DiagnosticWriter.ts +50 -0
- package/src/diagnostics/index.ts +16 -0
- package/src/errors/GrafemaError.ts +174 -0
- package/src/index.ts +148 -1
- package/src/logging/Logger.ts +152 -0
- package/src/plugins/Plugin.ts +42 -0
- package/src/plugins/analysis/DatabaseAnalyzer.ts +14 -8
- package/src/plugins/analysis/ExpressAnalyzer.ts +29 -19
- package/src/plugins/analysis/ExpressRouteAnalyzer.ts +22 -21
- package/src/plugins/analysis/FetchAnalyzer.ts +39 -16
- package/src/plugins/analysis/IncrementalAnalysisPlugin.ts +84 -101
- package/src/plugins/analysis/JSASTAnalyzer.ts +1483 -503
- package/src/plugins/analysis/ReactAnalyzer.ts +57 -57
- package/src/plugins/analysis/RustAnalyzer.ts +15 -10
- package/src/plugins/analysis/SQLiteAnalyzer.ts +10 -7
- package/src/plugins/analysis/ServiceLayerAnalyzer.ts +22 -16
- package/src/plugins/analysis/SocketIOAnalyzer.ts +31 -22
- package/src/plugins/analysis/SystemDbAnalyzer.ts +16 -11
- package/src/plugins/analysis/ast/GraphBuilder.ts +439 -327
- package/src/plugins/analysis/ast/IdGenerator.ts +177 -0
- package/src/plugins/analysis/ast/types.ts +209 -6
- package/src/plugins/analysis/ast/utils/createParameterNodes.ts +104 -0
- package/src/plugins/analysis/ast/utils/index.ts +12 -0
- package/src/plugins/analysis/ast/utils/location.ts +103 -0
- package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +11 -8
- package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +909 -83
- package/src/plugins/analysis/ast/visitors/ClassVisitor.ts +97 -44
- package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +159 -93
- package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +12 -8
- package/src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts +41 -14
- package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +37 -17
- package/src/plugins/discovery/MonorepoServiceDiscovery.ts +3 -2
- package/src/plugins/discovery/SimpleProjectDiscovery.ts +6 -1
- package/src/plugins/discovery/WorkspaceDiscovery.ts +177 -0
- package/src/plugins/discovery/resolveSourceEntrypoint.ts +103 -0
- package/src/plugins/discovery/workspaces/detector.ts +63 -0
- package/src/plugins/discovery/workspaces/globResolver.ts +229 -0
- package/src/plugins/discovery/workspaces/index.ts +23 -0
- package/src/plugins/discovery/workspaces/parsers.ts +99 -0
- package/src/plugins/enrichment/AliasTracker.ts +14 -8
- package/src/plugins/enrichment/HTTPConnectionEnricher.ts +14 -7
- package/src/plugins/enrichment/ImportExportLinker.ts +24 -6
- package/src/plugins/enrichment/MethodCallResolver.ts +18 -12
- package/src/plugins/enrichment/MountPointResolver.ts +8 -3
- package/src/plugins/enrichment/PrefixEvaluator.ts +16 -7
- package/src/plugins/enrichment/RustFFIEnricher.ts +6 -5
- package/src/plugins/enrichment/ValueDomainAnalyzer.ts +149 -12
- package/src/plugins/indexing/IncrementalModuleIndexer.ts +23 -14
- package/src/plugins/indexing/JSModuleIndexer.ts +74 -34
- package/src/plugins/indexing/RustModuleIndexer.ts +5 -4
- package/src/plugins/validation/CallResolverValidator.ts +8 -7
- package/src/plugins/validation/DataFlowValidator.ts +16 -12
- package/src/plugins/validation/EvalBanValidator.ts +17 -16
- package/src/plugins/validation/GraphConnectivityValidator.ts +19 -23
- package/src/plugins/validation/NodeCreationValidator.ts +554 -0
- package/src/plugins/validation/SQLInjectionValidator.ts +61 -15
- package/src/plugins/validation/ShadowingDetector.ts +6 -5
- package/src/plugins/validation/TypeScriptDeadCodeValidator.ts +12 -11
- package/src/plugins/vcs/GitPlugin.ts +40 -12
- package/src/plugins/vcs/VCSPlugin.ts +7 -5
- package/src/storage/backends/RFDBServerBackend.ts +43 -29
- package/src/validation/PathValidator.ts +1 -1
- package/dist/core/AnalysisWorker.d.ts +0 -14
- package/dist/core/AnalysisWorker.d.ts.map +0 -1
- package/dist/core/AnalysisWorker.js +0 -307
- package/dist/core/ParallelAnalyzer.d.ts +0 -120
- package/dist/core/ParallelAnalyzer.d.ts.map +0 -1
- package/dist/core/ParallelAnalyzer.js +0 -331
- package/dist/core/QueueWorker.d.ts +0 -12
- package/dist/core/QueueWorker.d.ts.map +0 -1
- package/dist/core/QueueWorker.js +0 -567
- package/dist/core/RFDBClient.d.ts +0 -179
- package/dist/core/RFDBClient.d.ts.map +0 -1
- package/dist/core/RFDBClient.js +0 -429
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts +0 -19
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts.map +0 -1
- package/dist/plugins/discovery/ZonServiceDiscovery.js +0 -204
- package/src/core/AnalysisWorker.ts +0 -410
- package/src/core/ParallelAnalyzer.ts +0 -476
- package/src/core/QueueWorker.ts +0 -780
- 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;
|
|
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
|
|
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:
|
|
60
|
-
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
|
-
//
|
|
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
|
-
|
|
94
|
-
|
|
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,
|
|
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}#${
|
|
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
|
-
|
|
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:
|
|
154
|
-
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}#${
|
|
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:
|
|
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
|
|
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:
|
|
196
|
-
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}#${
|
|
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:
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
params.forEach((param
|
|
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
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
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
|
|
106
|
-
async:
|
|
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
|
|
157
|
+
createParameterNodes(node.params, functionId, module.file, getLine(node), parameters, scopeTracker);
|
|
111
158
|
// Create SCOPE for function body
|
|
112
|
-
const functionBodyScopeId =
|
|
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
|
|
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
|
|
132
|
-
const column = node
|
|
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
|
-
|
|
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:
|
|
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 =
|
|
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;
|
|
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"}
|