@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
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IdGenerator - Centralized ID generation for AST nodes
|
|
3
|
+
*
|
|
4
|
+
* Encapsulates the dual ID system:
|
|
5
|
+
* - Semantic IDs (stable, based on scope path) when ScopeTracker is available
|
|
6
|
+
* - Legacy IDs (hash-separated, location-based) as fallback
|
|
7
|
+
*
|
|
8
|
+
* This removes 18+ duplicate instances of the same pattern across visitor files.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { ScopeTracker } from '../../../core/ScopeTracker.js';
|
|
12
|
+
import { computeSemanticId } from '../../../core/SemanticId.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Counter reference for legacy ID generation
|
|
16
|
+
*/
|
|
17
|
+
export interface CounterRef {
|
|
18
|
+
value: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Options for ID generation
|
|
23
|
+
*/
|
|
24
|
+
export interface IdGeneratorOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Whether to use discriminator for same-named items in same scope.
|
|
27
|
+
* When true, calls scopeTracker.getItemCounter() to get a unique discriminator.
|
|
28
|
+
*/
|
|
29
|
+
useDiscriminator?: boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Custom key for discriminator counter.
|
|
33
|
+
* Defaults to `${type}:${name}` if not specified.
|
|
34
|
+
*/
|
|
35
|
+
discriminatorKey?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* IdGenerator - Centralized ID generation for AST nodes
|
|
40
|
+
*
|
|
41
|
+
* Usage:
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const idGen = new IdGenerator(scopeTracker);
|
|
44
|
+
*
|
|
45
|
+
* // For nodes with counter (VARIABLE, CALL, etc.)
|
|
46
|
+
* const varId = idGen.generate('VARIABLE', 'myVar', file, line, col, counterRef);
|
|
47
|
+
*
|
|
48
|
+
* // For nodes with discriminator (CALL - same function called multiple times)
|
|
49
|
+
* const callId = idGen.generate('CALL', 'console.log', file, line, col, counterRef, {
|
|
50
|
+
* useDiscriminator: true
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // For nodes without counter (FUNCTION)
|
|
54
|
+
* const funcId = idGen.generateSimple('FUNCTION', 'myFunc', file, line);
|
|
55
|
+
*
|
|
56
|
+
* // For scope bodies
|
|
57
|
+
* const scopeId = idGen.generateScope('body', 'myFunc:body', file, line);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export class IdGenerator {
|
|
61
|
+
constructor(private scopeTracker?: ScopeTracker) {}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Generate ID for nodes that use a counter in legacy format.
|
|
65
|
+
*
|
|
66
|
+
* Legacy format: `TYPE#name#file#line:column:counter`
|
|
67
|
+
* Semantic format: `file->scope->TYPE->name[#discriminator]`
|
|
68
|
+
*
|
|
69
|
+
* Used for: VARIABLE, CONSTANT, CALL, METHOD_CALL, LITERAL
|
|
70
|
+
*/
|
|
71
|
+
generate(
|
|
72
|
+
type: string,
|
|
73
|
+
name: string,
|
|
74
|
+
file: string,
|
|
75
|
+
line: number,
|
|
76
|
+
column: number,
|
|
77
|
+
counterRef: CounterRef,
|
|
78
|
+
options?: IdGeneratorOptions
|
|
79
|
+
): string {
|
|
80
|
+
const legacyId = `${type}#${name}#${file}#${line}:${column}:${counterRef.value++}`;
|
|
81
|
+
|
|
82
|
+
if (!this.scopeTracker) return legacyId;
|
|
83
|
+
|
|
84
|
+
const discriminator = options?.useDiscriminator
|
|
85
|
+
? this.scopeTracker.getItemCounter(options.discriminatorKey ?? `${type}:${name}`)
|
|
86
|
+
: undefined;
|
|
87
|
+
|
|
88
|
+
return computeSemanticId(type, name, this.scopeTracker.getContext(), { discriminator });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Generate ID for nodes without counter in legacy format.
|
|
93
|
+
*
|
|
94
|
+
* Legacy format: `TYPE#name#file#line` or `TYPE#name#file#line:column`
|
|
95
|
+
* Semantic format: `file->scope->TYPE->name`
|
|
96
|
+
*
|
|
97
|
+
* Used for: FUNCTION (named), CLASS
|
|
98
|
+
*/
|
|
99
|
+
generateSimple(
|
|
100
|
+
type: string,
|
|
101
|
+
name: string,
|
|
102
|
+
file: string,
|
|
103
|
+
line: number,
|
|
104
|
+
column?: number
|
|
105
|
+
): string {
|
|
106
|
+
const legacyId = column !== undefined
|
|
107
|
+
? `${type}#${name}#${file}#${line}:${column}`
|
|
108
|
+
: `${type}#${name}#${file}#${line}`;
|
|
109
|
+
|
|
110
|
+
if (!this.scopeTracker) return legacyId;
|
|
111
|
+
|
|
112
|
+
return computeSemanticId(type, name, this.scopeTracker.getContext());
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Generate ID for scope nodes.
|
|
117
|
+
*
|
|
118
|
+
* Legacy format: `SCOPE#funcName:body#file#line` or with column
|
|
119
|
+
* Semantic format: `file->scope->SCOPE->body`
|
|
120
|
+
*
|
|
121
|
+
* @param semanticName - Name for semantic ID (usually 'body')
|
|
122
|
+
* @param legacyName - Name for legacy ID (usually 'funcName:body')
|
|
123
|
+
*/
|
|
124
|
+
generateScope(
|
|
125
|
+
semanticName: string,
|
|
126
|
+
legacyName: string,
|
|
127
|
+
file: string,
|
|
128
|
+
line: number,
|
|
129
|
+
column?: number
|
|
130
|
+
): string {
|
|
131
|
+
const legacyId = column !== undefined
|
|
132
|
+
? `SCOPE#${legacyName}#${file}#${line}:${column}`
|
|
133
|
+
: `SCOPE#${legacyName}#${file}#${line}`;
|
|
134
|
+
|
|
135
|
+
if (!this.scopeTracker) return legacyId;
|
|
136
|
+
|
|
137
|
+
return computeSemanticId('SCOPE', semanticName, this.scopeTracker.getContext());
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Generate legacy-only ID (no semantic version).
|
|
142
|
+
*
|
|
143
|
+
* Used for: LITERAL (arguments), DECORATOR, PROPERTY
|
|
144
|
+
*
|
|
145
|
+
* NOTE: PARAMETER nodes use computeSemanticId() for stable, semantic identifiers.
|
|
146
|
+
* See createParameterNodes.ts for the implementation.
|
|
147
|
+
*
|
|
148
|
+
* @param includeSuffix - Additional suffix after line:column (counter or index)
|
|
149
|
+
*/
|
|
150
|
+
generateLegacy(
|
|
151
|
+
type: string,
|
|
152
|
+
name: string,
|
|
153
|
+
file: string,
|
|
154
|
+
line: number,
|
|
155
|
+
column: number,
|
|
156
|
+
suffix?: string | number
|
|
157
|
+
): string {
|
|
158
|
+
if (suffix !== undefined) {
|
|
159
|
+
return `${type}#${name}#${file}#${line}:${column}:${suffix}`;
|
|
160
|
+
}
|
|
161
|
+
return `${type}#${name}#${file}#${line}:${column}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Check if semantic IDs are available (scopeTracker is present)
|
|
166
|
+
*/
|
|
167
|
+
hasSemanticIds(): boolean {
|
|
168
|
+
return this.scopeTracker !== undefined;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get the underlying ScopeTracker (for advanced usage)
|
|
173
|
+
*/
|
|
174
|
+
getScopeTracker(): ScopeTracker | undefined {
|
|
175
|
+
return this.scopeTracker;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -19,7 +19,6 @@ export interface ModuleNode {
|
|
|
19
19
|
// === FUNCTION INFO ===
|
|
20
20
|
export interface FunctionInfo {
|
|
21
21
|
id: string;
|
|
22
|
-
stableId: string;
|
|
23
22
|
type: 'FUNCTION';
|
|
24
23
|
name: string;
|
|
25
24
|
file: string;
|
|
@@ -36,12 +35,15 @@ export interface FunctionInfo {
|
|
|
36
35
|
// === PARAMETER INFO ===
|
|
37
36
|
export interface ParameterInfo {
|
|
38
37
|
id: string;
|
|
38
|
+
semanticId?: string; // Stable ID: file->scope->PARAMETER->name
|
|
39
39
|
type: 'PARAMETER';
|
|
40
40
|
name: string;
|
|
41
41
|
file: string;
|
|
42
42
|
line: number;
|
|
43
43
|
index?: number;
|
|
44
|
-
|
|
44
|
+
hasDefault?: boolean; // Has default value (e.g., function(a = 1))
|
|
45
|
+
isRest?: boolean; // Rest parameter (e.g., function(...args))
|
|
46
|
+
functionId?: string; // Legacy field - prefer parentFunctionId
|
|
45
47
|
parentFunctionId?: string;
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -51,7 +53,7 @@ export interface ScopeInfo {
|
|
|
51
53
|
type: 'SCOPE';
|
|
52
54
|
scopeType: string;
|
|
53
55
|
name?: string;
|
|
54
|
-
semanticId?: string; // Stable ID for diff comparison (e.g., "MyClass
|
|
56
|
+
semanticId?: string; // Stable ID for diff comparison (e.g., "MyClass->myMethod:if_statement[0]")
|
|
55
57
|
conditional?: boolean;
|
|
56
58
|
condition?: string;
|
|
57
59
|
constraints?: unknown[];
|
|
@@ -66,6 +68,7 @@ export interface ScopeInfo {
|
|
|
66
68
|
// === VARIABLE DECLARATION INFO ===
|
|
67
69
|
export interface VariableDeclarationInfo {
|
|
68
70
|
id: string;
|
|
71
|
+
semanticId?: string; // Stable ID: file->scope->VARIABLE->name
|
|
69
72
|
type: 'VARIABLE' | 'CONSTANT';
|
|
70
73
|
name: string;
|
|
71
74
|
file: string;
|
|
@@ -78,6 +81,7 @@ export interface VariableDeclarationInfo {
|
|
|
78
81
|
// === CALL SITE INFO ===
|
|
79
82
|
export interface CallSiteInfo {
|
|
80
83
|
id: string;
|
|
84
|
+
semanticId?: string; // Stable ID: file->scope->CALL->name#N
|
|
81
85
|
type: 'CALL';
|
|
82
86
|
name: string;
|
|
83
87
|
file: string;
|
|
@@ -91,10 +95,13 @@ export interface CallSiteInfo {
|
|
|
91
95
|
// === METHOD CALL INFO ===
|
|
92
96
|
export interface MethodCallInfo {
|
|
93
97
|
id: string;
|
|
98
|
+
semanticId?: string; // Stable ID: file->scope->CALL->object.method#N
|
|
94
99
|
type: 'CALL';
|
|
95
100
|
name: string;
|
|
96
101
|
object: string;
|
|
97
102
|
method: string;
|
|
103
|
+
computed?: boolean; // Whether method was accessed via computed property [x]
|
|
104
|
+
computedPropertyVar?: string | null; // Variable name used in obj[x]() calls
|
|
98
105
|
file: string;
|
|
99
106
|
line: number;
|
|
100
107
|
column?: number;
|
|
@@ -106,6 +113,7 @@ export interface MethodCallInfo {
|
|
|
106
113
|
// === EVENT LISTENER INFO ===
|
|
107
114
|
export interface EventListenerInfo {
|
|
108
115
|
id: string;
|
|
116
|
+
semanticId?: string; // Stable ID: file->scope->EVENT_LISTENER->name#N
|
|
109
117
|
type: 'event:listener';
|
|
110
118
|
name: string;
|
|
111
119
|
object: string;
|
|
@@ -127,6 +135,7 @@ export interface ClassInstantiationInfo {
|
|
|
127
135
|
// === CLASS DECLARATION INFO ===
|
|
128
136
|
export interface ClassDeclarationInfo {
|
|
129
137
|
id: string;
|
|
138
|
+
semanticId?: string; // Stable ID: file->scope->CLASS->name
|
|
130
139
|
type: 'CLASS';
|
|
131
140
|
name: string;
|
|
132
141
|
file: string;
|
|
@@ -139,7 +148,12 @@ export interface ClassDeclarationInfo {
|
|
|
139
148
|
|
|
140
149
|
// === INTERFACE DECLARATION INFO ===
|
|
141
150
|
export interface InterfaceDeclarationInfo {
|
|
142
|
-
|
|
151
|
+
/**
|
|
152
|
+
* @deprecated ID is now generated by InterfaceNode.create() in GraphBuilder.
|
|
153
|
+
* This field will be removed in a future version.
|
|
154
|
+
*/
|
|
155
|
+
id?: string;
|
|
156
|
+
semanticId?: string; // Stable ID: file->scope->INTERFACE->name
|
|
143
157
|
type: 'INTERFACE';
|
|
144
158
|
name: string;
|
|
145
159
|
file: string;
|
|
@@ -158,7 +172,12 @@ export interface InterfacePropertyInfo {
|
|
|
158
172
|
|
|
159
173
|
// === TYPE ALIAS INFO ===
|
|
160
174
|
export interface TypeAliasInfo {
|
|
161
|
-
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated ID is now generated by NodeFactory.createType() in GraphBuilder.
|
|
177
|
+
* This field will be removed in a future version.
|
|
178
|
+
*/
|
|
179
|
+
id?: string;
|
|
180
|
+
semanticId?: string; // Stable ID: file->scope->TYPE->name
|
|
162
181
|
type: 'TYPE';
|
|
163
182
|
name: string;
|
|
164
183
|
file: string;
|
|
@@ -169,7 +188,12 @@ export interface TypeAliasInfo {
|
|
|
169
188
|
|
|
170
189
|
// === ENUM DECLARATION INFO ===
|
|
171
190
|
export interface EnumDeclarationInfo {
|
|
172
|
-
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated ID is now generated by EnumNode.create() in GraphBuilder.
|
|
193
|
+
* This field will be removed in a future version.
|
|
194
|
+
*/
|
|
195
|
+
id?: string;
|
|
196
|
+
semanticId?: string; // Stable ID: file->scope->ENUM->name
|
|
173
197
|
type: 'ENUM';
|
|
174
198
|
name: string;
|
|
175
199
|
file: string;
|
|
@@ -187,6 +211,7 @@ export interface EnumMemberInfo {
|
|
|
187
211
|
// === DECORATOR INFO ===
|
|
188
212
|
export interface DecoratorInfo {
|
|
189
213
|
id: string;
|
|
214
|
+
semanticId?: string; // Stable ID: file->target->DECORATOR->name#N
|
|
190
215
|
type: 'DECORATOR';
|
|
191
216
|
name: string;
|
|
192
217
|
file: string;
|
|
@@ -229,6 +254,7 @@ export interface ImportInfo {
|
|
|
229
254
|
source: string;
|
|
230
255
|
file: string;
|
|
231
256
|
line: number;
|
|
257
|
+
column?: number; // Column position for ImportNode
|
|
232
258
|
specifiers: ImportSpecifier[];
|
|
233
259
|
}
|
|
234
260
|
|
|
@@ -267,6 +293,7 @@ export interface HttpRequestInfo {
|
|
|
267
293
|
// === LITERAL INFO ===
|
|
268
294
|
export interface LiteralInfo {
|
|
269
295
|
id: string;
|
|
296
|
+
semanticId?: string; // Stable ID: file->scope->LITERAL->type#N
|
|
270
297
|
type: 'LITERAL' | 'CALL';
|
|
271
298
|
value?: unknown;
|
|
272
299
|
valueType?: string;
|
|
@@ -281,6 +308,150 @@ export interface LiteralInfo {
|
|
|
281
308
|
argIndex?: number;
|
|
282
309
|
}
|
|
283
310
|
|
|
311
|
+
// === OBJECT LITERAL INFO ===
|
|
312
|
+
export interface ObjectLiteralInfo {
|
|
313
|
+
id: string;
|
|
314
|
+
semanticId?: string; // Stable ID: file->scope->OBJECT_LITERAL->literal#N
|
|
315
|
+
type: 'OBJECT_LITERAL';
|
|
316
|
+
file: string;
|
|
317
|
+
line: number;
|
|
318
|
+
column: number;
|
|
319
|
+
parentCallId?: string;
|
|
320
|
+
argIndex?: number;
|
|
321
|
+
isSpread?: boolean;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// === OBJECT PROPERTY INFO ===
|
|
325
|
+
export interface ObjectPropertyInfo {
|
|
326
|
+
objectId: string;
|
|
327
|
+
propertyName: string;
|
|
328
|
+
valueNodeId?: string;
|
|
329
|
+
valueType: 'LITERAL' | 'VARIABLE' | 'CALL' | 'EXPRESSION' | 'OBJECT_LITERAL' | 'ARRAY_LITERAL' | 'SPREAD';
|
|
330
|
+
valueName?: string; // For VARIABLE
|
|
331
|
+
literalValue?: unknown; // For LITERAL
|
|
332
|
+
file: string;
|
|
333
|
+
line: number;
|
|
334
|
+
column: number;
|
|
335
|
+
// For CALL values
|
|
336
|
+
callLine?: number;
|
|
337
|
+
callColumn?: number;
|
|
338
|
+
// For nested object/array
|
|
339
|
+
nestedObjectId?: string;
|
|
340
|
+
nestedArrayId?: string;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// === ARRAY LITERAL INFO ===
|
|
344
|
+
export interface ArrayLiteralInfo {
|
|
345
|
+
id: string;
|
|
346
|
+
semanticId?: string; // Stable ID: file->scope->ARRAY_LITERAL->literal#N
|
|
347
|
+
type: 'ARRAY_LITERAL';
|
|
348
|
+
file: string;
|
|
349
|
+
line: number;
|
|
350
|
+
column: number;
|
|
351
|
+
parentCallId?: string;
|
|
352
|
+
argIndex?: number;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// === ARRAY ELEMENT INFO ===
|
|
356
|
+
export interface ArrayElementInfo {
|
|
357
|
+
arrayId: string;
|
|
358
|
+
index: number;
|
|
359
|
+
valueNodeId?: string;
|
|
360
|
+
valueType: 'LITERAL' | 'VARIABLE' | 'CALL' | 'EXPRESSION' | 'OBJECT_LITERAL' | 'ARRAY_LITERAL' | 'SPREAD';
|
|
361
|
+
valueName?: string; // For VARIABLE
|
|
362
|
+
literalValue?: unknown; // For LITERAL
|
|
363
|
+
file: string;
|
|
364
|
+
line: number;
|
|
365
|
+
column: number;
|
|
366
|
+
// For CALL values
|
|
367
|
+
callLine?: number;
|
|
368
|
+
callColumn?: number;
|
|
369
|
+
// For nested object/array
|
|
370
|
+
nestedObjectId?: string;
|
|
371
|
+
nestedArrayId?: string;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// === ARRAY MUTATION INFO ===
|
|
375
|
+
/**
|
|
376
|
+
* Tracks array mutation calls (push, unshift, splice) and indexed assignments
|
|
377
|
+
* Used to create FLOWS_INTO edges in GraphBuilder
|
|
378
|
+
*
|
|
379
|
+
* IMPORTANT: This type is defined ONLY here. Import from this file everywhere.
|
|
380
|
+
*/
|
|
381
|
+
export interface ArrayMutationInfo {
|
|
382
|
+
id?: string; // Semantic ID for the mutation (optional for backward compatibility)
|
|
383
|
+
arrayName: string; // Name of the array variable being mutated
|
|
384
|
+
arrayLine?: number; // Line where array is referenced (for scope resolution)
|
|
385
|
+
mutationMethod: 'push' | 'unshift' | 'splice' | 'indexed';
|
|
386
|
+
file: string;
|
|
387
|
+
line: number;
|
|
388
|
+
column: number;
|
|
389
|
+
insertedValues: ArrayMutationArgument[]; // What's being added to the array
|
|
390
|
+
isNested?: boolean; // REG-117: true if receiver is MemberExpression
|
|
391
|
+
baseObjectName?: string; // REG-117: "obj" from obj.arr.push()
|
|
392
|
+
propertyName?: string; // REG-117: "arr" - the array property name
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export interface ArrayMutationArgument {
|
|
396
|
+
argIndex: number;
|
|
397
|
+
isSpread?: boolean;
|
|
398
|
+
valueType: 'LITERAL' | 'VARIABLE' | 'CALL' | 'EXPRESSION' | 'OBJECT_LITERAL' | 'ARRAY_LITERAL';
|
|
399
|
+
valueName?: string; // For VARIABLE type - name of the variable
|
|
400
|
+
valueNodeId?: string; // For LITERAL, OBJECT_LITERAL, ARRAY_LITERAL - node ID
|
|
401
|
+
literalValue?: unknown; // For LITERAL type
|
|
402
|
+
callLine?: number; // For CALL type
|
|
403
|
+
callColumn?: number;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// === OBJECT MUTATION INFO ===
|
|
407
|
+
/**
|
|
408
|
+
* Tracks object property mutations for FLOWS_INTO edge creation in GraphBuilder.
|
|
409
|
+
* Handles: obj.prop = value, obj['prop'] = value, Object.assign(), spread in object literals.
|
|
410
|
+
*
|
|
411
|
+
* IMPORTANT: This type is defined ONLY here. Import from this file everywhere.
|
|
412
|
+
*/
|
|
413
|
+
export interface ObjectMutationInfo {
|
|
414
|
+
id?: string; // Semantic ID for the mutation (optional for backward compatibility)
|
|
415
|
+
objectName: string; // Name of the object being mutated ('config', 'this', etc.)
|
|
416
|
+
objectLine?: number; // Line where object is referenced (for scope resolution)
|
|
417
|
+
enclosingClassName?: string; // Class name when objectName === 'this' (REG-152)
|
|
418
|
+
propertyName: string; // Property name or '<computed>' for obj[x] or '<assign>' for Object.assign
|
|
419
|
+
mutationType: 'property' | 'computed' | 'assign' | 'spread';
|
|
420
|
+
computedPropertyVar?: string; // Variable name in obj[key] = value (for computed mutation type)
|
|
421
|
+
file: string;
|
|
422
|
+
line: number;
|
|
423
|
+
column: number;
|
|
424
|
+
value: ObjectMutationValue;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export interface ObjectMutationValue {
|
|
428
|
+
valueType: 'LITERAL' | 'VARIABLE' | 'CALL' | 'EXPRESSION' | 'OBJECT_LITERAL' | 'ARRAY_LITERAL';
|
|
429
|
+
valueName?: string; // For VARIABLE type - name of the variable
|
|
430
|
+
valueNodeId?: string; // For LITERAL, OBJECT_LITERAL, ARRAY_LITERAL - node ID
|
|
431
|
+
literalValue?: unknown; // For LITERAL type
|
|
432
|
+
callLine?: number; // For CALL type
|
|
433
|
+
callColumn?: number;
|
|
434
|
+
isSpread?: boolean; // For Object.assign with spread: Object.assign(target, ...sources)
|
|
435
|
+
argIndex?: number; // For Object.assign - which source argument (0, 1, 2, ...)
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Resolution status for computed property names.
|
|
440
|
+
* Used in FLOWS_INTO edge metadata to indicate how property name was determined.
|
|
441
|
+
*
|
|
442
|
+
* - RESOLVED: Single deterministic value traced from literals
|
|
443
|
+
* - RESOLVED_CONDITIONAL: Multiple possible values (ternary, logical OR, etc.)
|
|
444
|
+
* - UNKNOWN_PARAMETER: Variable traces to function parameter
|
|
445
|
+
* - UNKNOWN_RUNTIME: Variable traces to function call result
|
|
446
|
+
* - DEFERRED_CROSS_FILE: Variable traces to import (requires cross-file analysis)
|
|
447
|
+
*/
|
|
448
|
+
export type ResolutionStatus =
|
|
449
|
+
| 'RESOLVED'
|
|
450
|
+
| 'RESOLVED_CONDITIONAL'
|
|
451
|
+
| 'UNKNOWN_PARAMETER'
|
|
452
|
+
| 'UNKNOWN_RUNTIME'
|
|
453
|
+
| 'DEFERRED_CROSS_FILE';
|
|
454
|
+
|
|
284
455
|
// === VARIABLE ASSIGNMENT INFO ===
|
|
285
456
|
export interface VariableAssignmentInfo {
|
|
286
457
|
variableId: string;
|
|
@@ -296,6 +467,7 @@ export interface VariableAssignmentInfo {
|
|
|
296
467
|
className?: string;
|
|
297
468
|
functionName?: string;
|
|
298
469
|
line?: number;
|
|
470
|
+
column?: number; // Column position for EXPRESSION nodes
|
|
299
471
|
expressionType?: string;
|
|
300
472
|
object?: string;
|
|
301
473
|
property?: string;
|
|
@@ -348,6 +520,15 @@ export interface ASTCollections {
|
|
|
348
520
|
httpRequests?: HttpRequestInfo[];
|
|
349
521
|
literals?: LiteralInfo[];
|
|
350
522
|
variableAssignments?: VariableAssignmentInfo[];
|
|
523
|
+
// Object/Array literal tracking for data flow
|
|
524
|
+
objectLiterals?: ObjectLiteralInfo[];
|
|
525
|
+
objectProperties?: ObjectPropertyInfo[];
|
|
526
|
+
arrayLiterals?: ArrayLiteralInfo[];
|
|
527
|
+
arrayElements?: ArrayElementInfo[];
|
|
528
|
+
// Array mutation tracking for FLOWS_INTO edges
|
|
529
|
+
arrayMutations?: ArrayMutationInfo[];
|
|
530
|
+
// Object mutation tracking for FLOWS_INTO edges
|
|
531
|
+
objectMutations?: ObjectMutationInfo[];
|
|
351
532
|
// TypeScript-specific collections
|
|
352
533
|
interfaces?: InterfaceDeclarationInfo[];
|
|
353
534
|
typeAliases?: TypeAliasInfo[];
|
|
@@ -361,7 +542,11 @@ export interface ASTCollections {
|
|
|
361
542
|
functionCounterRef?: CounterRef;
|
|
362
543
|
httpRequestCounterRef?: CounterRef;
|
|
363
544
|
literalCounterRef?: CounterRef;
|
|
545
|
+
objectLiteralCounterRef?: CounterRef;
|
|
546
|
+
arrayLiteralCounterRef?: CounterRef;
|
|
364
547
|
processedNodes?: ProcessedNodes;
|
|
548
|
+
// ScopeTracker for semantic ID generation
|
|
549
|
+
scopeTracker?: import('../../../core/ScopeTracker.js').ScopeTracker;
|
|
365
550
|
}
|
|
366
551
|
|
|
367
552
|
// === EXTRACTED VARIABLE ===
|
|
@@ -381,6 +566,12 @@ export interface GraphNode {
|
|
|
381
566
|
file?: string;
|
|
382
567
|
line?: number;
|
|
383
568
|
column?: number;
|
|
569
|
+
// IMPORT node fields
|
|
570
|
+
source?: string;
|
|
571
|
+
importType?: 'default' | 'named' | 'namespace';
|
|
572
|
+
importBinding?: 'value' | 'type' | 'typeof';
|
|
573
|
+
imported?: string;
|
|
574
|
+
local?: string;
|
|
384
575
|
[key: string]: unknown;
|
|
385
576
|
}
|
|
386
577
|
|
|
@@ -390,6 +581,18 @@ export interface GraphEdge {
|
|
|
390
581
|
src: string;
|
|
391
582
|
dst: string;
|
|
392
583
|
index?: number;
|
|
584
|
+
// For FLOWS_INTO edges (array mutations)
|
|
585
|
+
mutationMethod?: string;
|
|
586
|
+
argIndex?: number;
|
|
587
|
+
isSpread?: boolean;
|
|
588
|
+
nestedProperty?: string; // REG-117: Property name for nested mutations (obj.arr.push -> "arr")
|
|
589
|
+
// For FLOWS_INTO edges (object mutations)
|
|
590
|
+
mutationType?: 'property' | 'computed' | 'assign' | 'spread' | 'this_property';
|
|
591
|
+
propertyName?: string;
|
|
592
|
+
// For computed property resolution (enrichment phase)
|
|
593
|
+
computedPropertyVar?: string; // Variable name for obj[key] patterns
|
|
594
|
+
resolvedPropertyNames?: string[]; // Resolved names after enrichment
|
|
595
|
+
resolutionStatus?: ResolutionStatus; // How resolution was determined
|
|
393
596
|
metadata?: Record<string, unknown>;
|
|
394
597
|
}
|
|
395
598
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createParameterNodes - Shared utility for creating PARAMETER nodes
|
|
3
|
+
*
|
|
4
|
+
* Used by FunctionVisitor and ClassVisitor to create PARAMETER nodes
|
|
5
|
+
* for function/method parameters with consistent behavior.
|
|
6
|
+
*
|
|
7
|
+
* Uses semantic IDs for stable, scope-based identification that doesn't
|
|
8
|
+
* change when lines are added/removed above the function.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
Node,
|
|
13
|
+
Identifier,
|
|
14
|
+
AssignmentPattern,
|
|
15
|
+
RestElement
|
|
16
|
+
} from '@babel/types';
|
|
17
|
+
import type { ParameterInfo } from '../types.js';
|
|
18
|
+
import { ScopeTracker } from '../../../../core/ScopeTracker.js';
|
|
19
|
+
import { computeSemanticId } from '../../../../core/SemanticId.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Create PARAMETER nodes for function parameters
|
|
23
|
+
*
|
|
24
|
+
* Handles:
|
|
25
|
+
* - Simple Identifier parameters: function(a, b)
|
|
26
|
+
* - AssignmentPattern (default parameters): function(a = 1)
|
|
27
|
+
* - RestElement (rest parameters): function(...args)
|
|
28
|
+
*
|
|
29
|
+
* Does NOT handle (can be added later):
|
|
30
|
+
* - ObjectPattern (destructuring): function({ x, y })
|
|
31
|
+
* - ArrayPattern (destructuring): function([a, b])
|
|
32
|
+
*
|
|
33
|
+
* @param params - AST nodes for function parameters
|
|
34
|
+
* @param functionId - ID of the parent function (for parentFunctionId field)
|
|
35
|
+
* @param file - File path
|
|
36
|
+
* @param line - Line number of the function (for ParameterInfo.line fallback)
|
|
37
|
+
* @param parameters - Array to push ParameterInfo objects into
|
|
38
|
+
* @param scopeTracker - REQUIRED for semantic ID generation
|
|
39
|
+
*/
|
|
40
|
+
export function createParameterNodes(
|
|
41
|
+
params: Node[],
|
|
42
|
+
functionId: string,
|
|
43
|
+
file: string,
|
|
44
|
+
line: number,
|
|
45
|
+
parameters: ParameterInfo[],
|
|
46
|
+
scopeTracker: ScopeTracker
|
|
47
|
+
): void {
|
|
48
|
+
if (!parameters) return; // Guard for backward compatibility
|
|
49
|
+
|
|
50
|
+
params.forEach((param, index) => {
|
|
51
|
+
// Handle different parameter types
|
|
52
|
+
if (param.type === 'Identifier') {
|
|
53
|
+
const name = (param as Identifier).name;
|
|
54
|
+
const paramId = computeSemanticId('PARAMETER', name, scopeTracker.getContext(), { discriminator: index });
|
|
55
|
+
parameters.push({
|
|
56
|
+
id: paramId,
|
|
57
|
+
semanticId: paramId,
|
|
58
|
+
type: 'PARAMETER',
|
|
59
|
+
name,
|
|
60
|
+
file: file,
|
|
61
|
+
line: param.loc?.start.line || line,
|
|
62
|
+
index: index,
|
|
63
|
+
parentFunctionId: functionId
|
|
64
|
+
});
|
|
65
|
+
} else if (param.type === 'AssignmentPattern') {
|
|
66
|
+
// Default parameter: function(a = 1)
|
|
67
|
+
const assignmentParam = param as AssignmentPattern;
|
|
68
|
+
if (assignmentParam.left.type === 'Identifier') {
|
|
69
|
+
const name = assignmentParam.left.name;
|
|
70
|
+
const paramId = computeSemanticId('PARAMETER', name, scopeTracker.getContext(), { discriminator: index });
|
|
71
|
+
parameters.push({
|
|
72
|
+
id: paramId,
|
|
73
|
+
semanticId: paramId,
|
|
74
|
+
type: 'PARAMETER',
|
|
75
|
+
name,
|
|
76
|
+
file: file,
|
|
77
|
+
line: assignmentParam.left.loc?.start.line || line,
|
|
78
|
+
index: index,
|
|
79
|
+
hasDefault: true,
|
|
80
|
+
parentFunctionId: functionId
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
} else if ((param as Node).type === 'RestElement') {
|
|
84
|
+
// Rest parameter: function(...args)
|
|
85
|
+
const restParam = param as unknown as RestElement;
|
|
86
|
+
if (restParam.argument.type === 'Identifier') {
|
|
87
|
+
const name = restParam.argument.name;
|
|
88
|
+
const paramId = computeSemanticId('PARAMETER', name, scopeTracker.getContext(), { discriminator: index });
|
|
89
|
+
parameters.push({
|
|
90
|
+
id: paramId,
|
|
91
|
+
semanticId: paramId,
|
|
92
|
+
type: 'PARAMETER',
|
|
93
|
+
name,
|
|
94
|
+
file: file,
|
|
95
|
+
line: restParam.argument.loc?.start.line || line,
|
|
96
|
+
index: index,
|
|
97
|
+
isRest: true,
|
|
98
|
+
parentFunctionId: functionId
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// ObjectPattern and ArrayPattern (destructuring parameters) can be added later
|
|
103
|
+
});
|
|
104
|
+
}
|