@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
package/src/core/NodeFactory.ts
CHANGED
|
@@ -23,15 +23,35 @@ import {
|
|
|
23
23
|
VariableDeclarationNode,
|
|
24
24
|
ConstantNode,
|
|
25
25
|
LiteralNode,
|
|
26
|
+
ObjectLiteralNode,
|
|
27
|
+
ArrayLiteralNode,
|
|
26
28
|
ExternalStdioNode,
|
|
29
|
+
NetworkRequestNode,
|
|
27
30
|
EventListenerNode,
|
|
28
31
|
HttpRequestNode,
|
|
29
32
|
DatabaseQueryNode,
|
|
33
|
+
ImportNode,
|
|
34
|
+
ClassNode,
|
|
35
|
+
ExportNode,
|
|
36
|
+
ExternalModuleNode,
|
|
37
|
+
InterfaceNode,
|
|
38
|
+
TypeNode,
|
|
39
|
+
EnumNode,
|
|
40
|
+
DecoratorNode,
|
|
41
|
+
ExpressionNode,
|
|
42
|
+
ArgumentExpressionNode,
|
|
43
|
+
IssueNode,
|
|
30
44
|
type EntrypointType,
|
|
31
45
|
type EntrypointTrigger,
|
|
46
|
+
type DecoratorTargetType,
|
|
47
|
+
type InterfacePropertyRecord,
|
|
48
|
+
type EnumMemberRecord,
|
|
49
|
+
type IssueSeverity,
|
|
32
50
|
} from './nodes/index.js';
|
|
33
51
|
|
|
34
|
-
import type { BaseNodeRecord } from '@grafema/types';
|
|
52
|
+
import type { BaseNodeRecord, BrandedNode } from '@grafema/types';
|
|
53
|
+
import { brandNode } from '@grafema/types';
|
|
54
|
+
import type { ScopeContext } from './SemanticId.js';
|
|
35
55
|
|
|
36
56
|
interface ServiceOptions {
|
|
37
57
|
version?: string;
|
|
@@ -60,6 +80,11 @@ interface ModuleOptions {
|
|
|
60
80
|
isTest?: boolean;
|
|
61
81
|
}
|
|
62
82
|
|
|
83
|
+
interface ModuleContextOptions {
|
|
84
|
+
contentHash?: string;
|
|
85
|
+
isTest?: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
63
88
|
interface FunctionOptions {
|
|
64
89
|
async?: boolean;
|
|
65
90
|
generator?: boolean;
|
|
@@ -109,6 +134,18 @@ interface LiteralOptions {
|
|
|
109
134
|
counter?: number;
|
|
110
135
|
}
|
|
111
136
|
|
|
137
|
+
interface ObjectLiteralOptions {
|
|
138
|
+
parentCallId?: string;
|
|
139
|
+
argIndex?: number;
|
|
140
|
+
counter?: number;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
interface ArrayLiteralOptions {
|
|
144
|
+
parentCallId?: string;
|
|
145
|
+
argIndex?: number;
|
|
146
|
+
counter?: number;
|
|
147
|
+
}
|
|
148
|
+
|
|
112
149
|
interface EventListenerOptions {
|
|
113
150
|
column?: number;
|
|
114
151
|
parentScopeId?: string;
|
|
@@ -126,6 +163,68 @@ interface DatabaseQueryOptions {
|
|
|
126
163
|
parentScopeId?: string;
|
|
127
164
|
}
|
|
128
165
|
|
|
166
|
+
interface ImportOptions {
|
|
167
|
+
importType?: 'default' | 'named' | 'namespace';
|
|
168
|
+
importBinding?: 'value' | 'type' | 'typeof';
|
|
169
|
+
imported?: string;
|
|
170
|
+
local?: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface ClassOptions {
|
|
174
|
+
exported?: boolean;
|
|
175
|
+
superClass?: string;
|
|
176
|
+
methods?: string[];
|
|
177
|
+
isInstantiationRef?: boolean;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
interface ExportOptions {
|
|
181
|
+
exportKind?: 'value' | 'type';
|
|
182
|
+
local?: string;
|
|
183
|
+
default?: boolean;
|
|
184
|
+
source?: string;
|
|
185
|
+
exportType?: 'default' | 'named' | 'all';
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface InterfaceOptions {
|
|
189
|
+
extends?: string[];
|
|
190
|
+
properties?: InterfacePropertyRecord[];
|
|
191
|
+
isExternal?: boolean;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
interface TypeOptions {
|
|
195
|
+
aliasOf?: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface EnumOptions {
|
|
199
|
+
isConst?: boolean;
|
|
200
|
+
members?: EnumMemberRecord[];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
interface DecoratorOptions {
|
|
204
|
+
arguments?: unknown[];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
interface ExpressionOptions {
|
|
208
|
+
// MemberExpression
|
|
209
|
+
object?: string;
|
|
210
|
+
property?: string;
|
|
211
|
+
computed?: boolean;
|
|
212
|
+
computedPropertyVar?: string;
|
|
213
|
+
// Binary/Logical
|
|
214
|
+
operator?: string;
|
|
215
|
+
// Tracking
|
|
216
|
+
path?: string;
|
|
217
|
+
baseName?: string;
|
|
218
|
+
propertyPath?: string[];
|
|
219
|
+
arrayIndex?: number;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
interface ArgumentExpressionOptions extends ExpressionOptions {
|
|
223
|
+
parentCallId: string;
|
|
224
|
+
argIndex: number;
|
|
225
|
+
counter?: number;
|
|
226
|
+
}
|
|
227
|
+
|
|
129
228
|
// Validator type for node classes
|
|
130
229
|
interface NodeValidator {
|
|
131
230
|
validate(node: BaseNodeRecord): string[];
|
|
@@ -136,18 +235,18 @@ export class NodeFactory {
|
|
|
136
235
|
* Create SERVICE node
|
|
137
236
|
*/
|
|
138
237
|
static createService(name: string, projectPath: string, options: ServiceOptions = {}) {
|
|
139
|
-
return ServiceNode.create(name, projectPath, options);
|
|
238
|
+
return brandNode(ServiceNode.create(name, projectPath, options));
|
|
140
239
|
}
|
|
141
240
|
|
|
142
241
|
/**
|
|
143
242
|
* Create ENTRYPOINT node
|
|
144
243
|
*/
|
|
145
244
|
static createEntrypoint(file: string, entrypointType: EntrypointType, options: EntrypointOptions = {}) {
|
|
146
|
-
return EntrypointNode.create(file, entrypointType, options);
|
|
245
|
+
return brandNode(EntrypointNode.create(file, entrypointType, options));
|
|
147
246
|
}
|
|
148
247
|
|
|
149
248
|
/**
|
|
150
|
-
* Create MODULE node
|
|
249
|
+
* Create MODULE node (LEGACY)
|
|
151
250
|
*/
|
|
152
251
|
static createModule(filePath: string, projectPath: string, options: ModuleOptions = {}) {
|
|
153
252
|
if (!filePath) throw new Error('NodeFactory.createModule: filePath is required');
|
|
@@ -156,84 +255,351 @@ export class NodeFactory {
|
|
|
156
255
|
const contentHash = options.contentHash || this._hashFile(filePath);
|
|
157
256
|
const relativePath = relative(projectPath, filePath) || basename(filePath);
|
|
158
257
|
|
|
159
|
-
return ModuleNode.create(filePath, relativePath, contentHash, options);
|
|
258
|
+
return brandNode(ModuleNode.create(filePath, relativePath, contentHash, options));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Create MODULE node with semantic ID (NEW API)
|
|
263
|
+
*
|
|
264
|
+
* Uses ScopeContext for stable identifiers.
|
|
265
|
+
*
|
|
266
|
+
* @param context - Scope context with file path (relative to project root)
|
|
267
|
+
* @param options - Optional contentHash and isTest flag
|
|
268
|
+
* @returns ModuleNodeRecord with semantic ID
|
|
269
|
+
*/
|
|
270
|
+
static createModuleWithContext(context: ScopeContext, options: ModuleContextOptions = {}) {
|
|
271
|
+
return brandNode(ModuleNode.createWithContext(context, options));
|
|
160
272
|
}
|
|
161
273
|
|
|
162
274
|
/**
|
|
163
275
|
* Create FUNCTION node
|
|
164
276
|
*/
|
|
165
277
|
static createFunction(name: string, file: string, line: number, column: number, options: FunctionOptions = {}) {
|
|
166
|
-
return FunctionNode.create(name, file, line, column, options);
|
|
278
|
+
return brandNode(FunctionNode.create(name, file, line, column, options));
|
|
167
279
|
}
|
|
168
280
|
|
|
169
281
|
/**
|
|
170
282
|
* Create SCOPE node
|
|
171
283
|
*/
|
|
172
284
|
static createScope(scopeType: string, file: string, line: number, options: ScopeOptions = {}) {
|
|
173
|
-
return ScopeNode.create(scopeType, file, line, options);
|
|
285
|
+
return brandNode(ScopeNode.create(scopeType, file, line, options));
|
|
174
286
|
}
|
|
175
287
|
|
|
176
288
|
/**
|
|
177
289
|
* Create CALL_SITE node
|
|
178
290
|
*/
|
|
179
291
|
static createCallSite(targetName: string, file: string, line: number, column: number, options: CallSiteOptions = {}) {
|
|
180
|
-
return CallSiteNode.create(targetName, file, line, column, options);
|
|
292
|
+
return brandNode(CallSiteNode.create(targetName, file, line, column, options));
|
|
181
293
|
}
|
|
182
294
|
|
|
183
295
|
/**
|
|
184
296
|
* Create METHOD_CALL node
|
|
185
297
|
*/
|
|
186
298
|
static createMethodCall(objectName: string | undefined, methodName: string, file: string, line: number, column: number, options: MethodCallOptions = {}) {
|
|
187
|
-
return MethodCallNode.create(objectName, methodName, file, line, column, options);
|
|
299
|
+
return brandNode(MethodCallNode.create(objectName, methodName, file, line, column, options));
|
|
188
300
|
}
|
|
189
301
|
|
|
190
302
|
/**
|
|
191
303
|
* Create VARIABLE_DECLARATION node
|
|
192
304
|
*/
|
|
193
305
|
static createVariableDeclaration(name: string, file: string, line: number, column: number, options: VariableOptions = {}) {
|
|
194
|
-
return VariableDeclarationNode.create(name, file, line, column, options);
|
|
306
|
+
return brandNode(VariableDeclarationNode.create(name, file, line, column, options));
|
|
195
307
|
}
|
|
196
308
|
|
|
197
309
|
/**
|
|
198
310
|
* Create CONSTANT node
|
|
199
311
|
*/
|
|
200
312
|
static createConstant(name: string, file: string, line: number, column: number, options: ConstantOptions = {}) {
|
|
201
|
-
return ConstantNode.create(name, file, line, column, options);
|
|
313
|
+
return brandNode(ConstantNode.create(name, file, line, column, options));
|
|
202
314
|
}
|
|
203
315
|
|
|
204
316
|
/**
|
|
205
317
|
* Create LITERAL node
|
|
206
318
|
*/
|
|
207
319
|
static createLiteral(value: unknown, file: string, line: number, column: number, options: LiteralOptions = {}) {
|
|
208
|
-
return LiteralNode.create(value, file, line, column, options);
|
|
320
|
+
return brandNode(LiteralNode.create(value, file, line, column, options));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Create OBJECT_LITERAL node
|
|
325
|
+
*/
|
|
326
|
+
static createObjectLiteral(file: string, line: number, column: number, options: ObjectLiteralOptions = {}) {
|
|
327
|
+
return brandNode(ObjectLiteralNode.create(file, line, column, options));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Create ARRAY_LITERAL node
|
|
332
|
+
*/
|
|
333
|
+
static createArrayLiteral(file: string, line: number, column: number, options: ArrayLiteralOptions = {}) {
|
|
334
|
+
return brandNode(ArrayLiteralNode.create(file, line, column, options));
|
|
209
335
|
}
|
|
210
336
|
|
|
211
337
|
/**
|
|
212
338
|
* Create EXTERNAL_STDIO node (singleton)
|
|
213
339
|
*/
|
|
214
340
|
static createExternalStdio() {
|
|
215
|
-
return ExternalStdioNode.create();
|
|
341
|
+
return brandNode(ExternalStdioNode.create());
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Create net:request singleton node
|
|
346
|
+
*
|
|
347
|
+
* This node represents the external network as a system resource.
|
|
348
|
+
* Should be created once per graph.
|
|
349
|
+
*
|
|
350
|
+
* All HTTP_REQUEST nodes connect to this singleton via CALLS edges.
|
|
351
|
+
*
|
|
352
|
+
* @returns NetworkRequestNodeRecord - singleton node
|
|
353
|
+
*/
|
|
354
|
+
static createNetworkRequest() {
|
|
355
|
+
return brandNode(NetworkRequestNode.create());
|
|
216
356
|
}
|
|
217
357
|
|
|
218
358
|
/**
|
|
219
359
|
* Create EVENT_LISTENER node
|
|
220
360
|
*/
|
|
221
361
|
static createEventListener(eventName: string, objectName: string | undefined, file: string, line: number, options: EventListenerOptions = {}) {
|
|
222
|
-
return EventListenerNode.create(eventName, objectName, file, line, options);
|
|
362
|
+
return brandNode(EventListenerNode.create(eventName, objectName, file, line, options));
|
|
223
363
|
}
|
|
224
364
|
|
|
225
365
|
/**
|
|
226
366
|
* Create HTTP_REQUEST node
|
|
227
367
|
*/
|
|
228
368
|
static createHttpRequest(url: string | undefined, method: string | undefined, file: string, line: number, options: HttpRequestOptions = {}) {
|
|
229
|
-
return HttpRequestNode.create(url, method, file, line, options);
|
|
369
|
+
return brandNode(HttpRequestNode.create(url, method, file, line, options));
|
|
230
370
|
}
|
|
231
371
|
|
|
232
372
|
/**
|
|
233
373
|
* Create DATABASE_QUERY node
|
|
234
374
|
*/
|
|
235
375
|
static createDatabaseQuery(query: string | undefined, operation: string | undefined, file: string, line: number, options: DatabaseQueryOptions = {}) {
|
|
236
|
-
return DatabaseQueryNode.create(query, operation, file, line, options);
|
|
376
|
+
return brandNode(DatabaseQueryNode.create(query, operation, file, line, options));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Create IMPORT node
|
|
381
|
+
*
|
|
382
|
+
* ImportNode automatically detects importType from imported field:
|
|
383
|
+
* - imported === 'default' → importType: 'default'
|
|
384
|
+
* - imported === '*' → importType: 'namespace'
|
|
385
|
+
* - anything else → importType: 'named'
|
|
386
|
+
*
|
|
387
|
+
* @param name - Local binding name (how it's used in this file)
|
|
388
|
+
* @param file - Absolute file path
|
|
389
|
+
* @param line - Line number (for debugging, not part of ID)
|
|
390
|
+
* @param column - Column position (0 if unavailable)
|
|
391
|
+
* @param source - Source module (e.g., 'react', './utils')
|
|
392
|
+
* @param options - Optional fields
|
|
393
|
+
* @returns ImportNodeRecord
|
|
394
|
+
*/
|
|
395
|
+
static createImport(
|
|
396
|
+
name: string,
|
|
397
|
+
file: string,
|
|
398
|
+
line: number,
|
|
399
|
+
column: number,
|
|
400
|
+
source: string,
|
|
401
|
+
options: ImportOptions = {}
|
|
402
|
+
) {
|
|
403
|
+
return brandNode(ImportNode.create(name, file, line, column, source, options));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Create CLASS node
|
|
408
|
+
*/
|
|
409
|
+
static createClass(
|
|
410
|
+
name: string,
|
|
411
|
+
file: string,
|
|
412
|
+
line: number,
|
|
413
|
+
column: number,
|
|
414
|
+
options: ClassOptions = {}
|
|
415
|
+
) {
|
|
416
|
+
return brandNode(ClassNode.create(name, file, line, column, options));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Create EXPORT node
|
|
421
|
+
*/
|
|
422
|
+
static createExport(
|
|
423
|
+
name: string,
|
|
424
|
+
file: string,
|
|
425
|
+
line: number,
|
|
426
|
+
column: number,
|
|
427
|
+
options: ExportOptions = {}
|
|
428
|
+
) {
|
|
429
|
+
return brandNode(ExportNode.create(name, file, line, column, options));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Create EXTERNAL_MODULE node
|
|
434
|
+
*
|
|
435
|
+
* Represents external npm packages or Node.js built-in modules.
|
|
436
|
+
* Uses singleton pattern - same source always produces same ID.
|
|
437
|
+
*
|
|
438
|
+
* @param source - Module name (e.g., 'lodash', '@tanstack/react-query', 'node:fs')
|
|
439
|
+
*/
|
|
440
|
+
static createExternalModule(source: string) {
|
|
441
|
+
return brandNode(ExternalModuleNode.create(source));
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Create INTERFACE node
|
|
446
|
+
*/
|
|
447
|
+
static createInterface(
|
|
448
|
+
name: string,
|
|
449
|
+
file: string,
|
|
450
|
+
line: number,
|
|
451
|
+
column: number,
|
|
452
|
+
options: InterfaceOptions = {}
|
|
453
|
+
) {
|
|
454
|
+
return brandNode(InterfaceNode.create(name, file, line, column, options));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Create TYPE node
|
|
459
|
+
*/
|
|
460
|
+
static createType(
|
|
461
|
+
name: string,
|
|
462
|
+
file: string,
|
|
463
|
+
line: number,
|
|
464
|
+
column: number,
|
|
465
|
+
options: TypeOptions = {}
|
|
466
|
+
) {
|
|
467
|
+
return brandNode(TypeNode.create(name, file, line, column, options));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Create ENUM node
|
|
472
|
+
*/
|
|
473
|
+
static createEnum(
|
|
474
|
+
name: string,
|
|
475
|
+
file: string,
|
|
476
|
+
line: number,
|
|
477
|
+
column: number,
|
|
478
|
+
options: EnumOptions = {}
|
|
479
|
+
) {
|
|
480
|
+
return brandNode(EnumNode.create(name, file, line, column, options));
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Create DECORATOR node
|
|
485
|
+
*/
|
|
486
|
+
static createDecorator(
|
|
487
|
+
name: string,
|
|
488
|
+
file: string,
|
|
489
|
+
line: number,
|
|
490
|
+
column: number,
|
|
491
|
+
targetId: string,
|
|
492
|
+
targetType: DecoratorTargetType,
|
|
493
|
+
options: DecoratorOptions = {}
|
|
494
|
+
) {
|
|
495
|
+
return brandNode(DecoratorNode.create(name, file, line, column, targetId, targetType, options));
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Create EXPRESSION node
|
|
500
|
+
*/
|
|
501
|
+
static createExpression(
|
|
502
|
+
expressionType: string,
|
|
503
|
+
file: string,
|
|
504
|
+
line: number,
|
|
505
|
+
column: number,
|
|
506
|
+
options: ExpressionOptions = {}
|
|
507
|
+
) {
|
|
508
|
+
return brandNode(ExpressionNode.create(expressionType, file, line, column, options));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Generate EXPRESSION node ID without creating the full node
|
|
513
|
+
*
|
|
514
|
+
* Used by JSASTAnalyzer when creating assignment metadata.
|
|
515
|
+
* The full node is created later by GraphBuilder.
|
|
516
|
+
*
|
|
517
|
+
* @param expressionType - Type of expression (MemberExpression, BinaryExpression, etc.)
|
|
518
|
+
* @param file - File path
|
|
519
|
+
* @param line - Line number
|
|
520
|
+
* @param column - Column position
|
|
521
|
+
* @returns Generated ID string in colon format
|
|
522
|
+
*/
|
|
523
|
+
static generateExpressionId(
|
|
524
|
+
expressionType: string,
|
|
525
|
+
file: string,
|
|
526
|
+
line: number,
|
|
527
|
+
column: number
|
|
528
|
+
): string {
|
|
529
|
+
return ExpressionNode.generateId(expressionType, file, line, column);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Create EXPRESSION node from assignment metadata
|
|
534
|
+
*
|
|
535
|
+
* Used by GraphBuilder when processing variableAssignments.
|
|
536
|
+
* The ID is provided from upstream (generated by JSASTAnalyzer).
|
|
537
|
+
*
|
|
538
|
+
* @param expressionType - Type of expression
|
|
539
|
+
* @param file - File path
|
|
540
|
+
* @param line - Line number
|
|
541
|
+
* @param column - Column position
|
|
542
|
+
* @param options - Must include id; optional: expression properties
|
|
543
|
+
*/
|
|
544
|
+
static createExpressionFromMetadata(
|
|
545
|
+
expressionType: string,
|
|
546
|
+
file: string,
|
|
547
|
+
line: number,
|
|
548
|
+
column: number,
|
|
549
|
+
options: ExpressionOptions & { id: string }
|
|
550
|
+
) {
|
|
551
|
+
return brandNode(ExpressionNode.createFromMetadata(expressionType, file, line, column, options));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Create EXPRESSION node with argument context
|
|
556
|
+
*
|
|
557
|
+
* Used when EXPRESSION appears as a call argument and we need to track
|
|
558
|
+
* which call and argument position for data flow analysis.
|
|
559
|
+
*
|
|
560
|
+
* @param expressionType - Type of expression (BinaryExpression, LogicalExpression, etc.)
|
|
561
|
+
* @param file - File path
|
|
562
|
+
* @param line - Line number
|
|
563
|
+
* @param column - Column position
|
|
564
|
+
* @param options - Required: parentCallId, argIndex; Optional: expression properties, counter
|
|
565
|
+
* @returns ArgumentExpressionNodeRecord
|
|
566
|
+
*/
|
|
567
|
+
static createArgumentExpression(
|
|
568
|
+
expressionType: string,
|
|
569
|
+
file: string,
|
|
570
|
+
line: number,
|
|
571
|
+
column: number,
|
|
572
|
+
options: ArgumentExpressionOptions
|
|
573
|
+
) {
|
|
574
|
+
return brandNode(ArgumentExpressionNode.create(expressionType, file, line, column, options));
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Create ISSUE node
|
|
579
|
+
*
|
|
580
|
+
* Issues represent detected problems in the codebase.
|
|
581
|
+
* Used by validation plugins to persist findings in the graph.
|
|
582
|
+
*
|
|
583
|
+
* @param category - Issue category (security, performance, style, smell)
|
|
584
|
+
* @param severity - error | warning | info
|
|
585
|
+
* @param message - Human-readable description
|
|
586
|
+
* @param plugin - Name of the plugin that detected this issue
|
|
587
|
+
* @param file - File path where issue was detected
|
|
588
|
+
* @param line - Line number
|
|
589
|
+
* @param column - Column number (optional)
|
|
590
|
+
* @param options - Optional context data
|
|
591
|
+
*/
|
|
592
|
+
static createIssue(
|
|
593
|
+
category: string,
|
|
594
|
+
severity: IssueSeverity,
|
|
595
|
+
message: string,
|
|
596
|
+
plugin: string,
|
|
597
|
+
file: string,
|
|
598
|
+
line: number,
|
|
599
|
+
column: number = 0,
|
|
600
|
+
options: { context?: Record<string, unknown> } = {}
|
|
601
|
+
) {
|
|
602
|
+
return brandNode(IssueNode.create(category, severity, message, plugin, file, line, column, options));
|
|
237
603
|
}
|
|
238
604
|
|
|
239
605
|
/**
|
|
@@ -251,12 +617,29 @@ export class NodeFactory {
|
|
|
251
617
|
'VARIABLE_DECLARATION': VariableDeclarationNode,
|
|
252
618
|
'CONSTANT': ConstantNode,
|
|
253
619
|
'LITERAL': LiteralNode,
|
|
254
|
-
'
|
|
620
|
+
'OBJECT_LITERAL': ObjectLiteralNode,
|
|
621
|
+
'ARRAY_LITERAL': ArrayLiteralNode,
|
|
622
|
+
'net:stdio': ExternalStdioNode,
|
|
623
|
+
'net:request': NetworkRequestNode,
|
|
255
624
|
'EVENT_LISTENER': EventListenerNode,
|
|
256
625
|
'HTTP_REQUEST': HttpRequestNode,
|
|
257
|
-
'DATABASE_QUERY': DatabaseQueryNode
|
|
626
|
+
'DATABASE_QUERY': DatabaseQueryNode,
|
|
627
|
+
'IMPORT': ImportNode,
|
|
628
|
+
'CLASS': ClassNode,
|
|
629
|
+
'EXPORT': ExportNode,
|
|
630
|
+
'EXTERNAL_MODULE': ExternalModuleNode,
|
|
631
|
+
'INTERFACE': InterfaceNode,
|
|
632
|
+
'TYPE': TypeNode,
|
|
633
|
+
'ENUM': EnumNode,
|
|
634
|
+
'DECORATOR': DecoratorNode,
|
|
635
|
+
'EXPRESSION': ExpressionNode
|
|
258
636
|
};
|
|
259
637
|
|
|
638
|
+
// Handle issue:* types dynamically
|
|
639
|
+
if (IssueNode.isIssueType(node.type)) {
|
|
640
|
+
return IssueNode.validate(node as Parameters<typeof IssueNode.validate>[0]);
|
|
641
|
+
}
|
|
642
|
+
|
|
260
643
|
const validator = validators[node.type];
|
|
261
644
|
if (!validator) {
|
|
262
645
|
return [`Unknown node type: ${node.type}`];
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScopeTracker - Track scope hierarchy during AST traversal
|
|
3
|
+
*
|
|
4
|
+
* Maintains the current scope path and provides counters for:
|
|
5
|
+
* - Counted scopes (if#0, try#1, etc.)
|
|
6
|
+
* - Item counters (CALL, LITERAL, etc.)
|
|
7
|
+
* - Sibling tracking (anonymous[0], anonymous[1], etc.)
|
|
8
|
+
*
|
|
9
|
+
* Used with SemanticId to generate stable identifiers.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ScopeContext } from './SemanticId.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Entry in the scope stack
|
|
16
|
+
*/
|
|
17
|
+
export interface ScopeEntry {
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
counter?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Result of entering a counted scope
|
|
25
|
+
*/
|
|
26
|
+
export interface CountedScopeResult {
|
|
27
|
+
name: string;
|
|
28
|
+
discriminator: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ScopeTracker - Manages scope hierarchy and counters during AST traversal
|
|
33
|
+
*/
|
|
34
|
+
export class ScopeTracker {
|
|
35
|
+
/** Source file path */
|
|
36
|
+
readonly file: string;
|
|
37
|
+
|
|
38
|
+
/** Current scope stack */
|
|
39
|
+
private scopeStack: ScopeEntry[] = [];
|
|
40
|
+
|
|
41
|
+
/** Counters for various purposes (scoped by scope path) */
|
|
42
|
+
private counters: Map<string, number> = new Map();
|
|
43
|
+
|
|
44
|
+
constructor(file: string) {
|
|
45
|
+
this.file = file;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// === Scope Management ===
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Enter a named scope (function, class, etc.)
|
|
52
|
+
*/
|
|
53
|
+
enterScope(name: string, type: string): void {
|
|
54
|
+
this.scopeStack.push({ name, type });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Enter a counted scope (if, try, for, etc.)
|
|
59
|
+
* Automatically assigns a discriminator.
|
|
60
|
+
*/
|
|
61
|
+
enterCountedScope(type: string): CountedScopeResult {
|
|
62
|
+
const key = this.counterKey(type);
|
|
63
|
+
const n = this.counters.get(key) || 0;
|
|
64
|
+
this.counters.set(key, n + 1);
|
|
65
|
+
|
|
66
|
+
const name = `${type}#${n}`;
|
|
67
|
+
this.scopeStack.push({ name, type, counter: n });
|
|
68
|
+
return { name, discriminator: n };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Exit the current scope
|
|
73
|
+
*/
|
|
74
|
+
exitScope(): void {
|
|
75
|
+
this.scopeStack.pop();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// === ID Generation ===
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get current scope context for semantic ID generation
|
|
82
|
+
*/
|
|
83
|
+
getContext(): ScopeContext {
|
|
84
|
+
return {
|
|
85
|
+
file: this.file,
|
|
86
|
+
scopePath: this.scopeStack.map(s => s.name)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get scope path as string (for display/debugging)
|
|
92
|
+
*/
|
|
93
|
+
getScopePath(): string {
|
|
94
|
+
if (this.scopeStack.length === 0) return 'global';
|
|
95
|
+
return this.scopeStack.map(s => s.name).join('->');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get the innermost enclosing scope of a specific type.
|
|
100
|
+
* Searches from innermost to outermost.
|
|
101
|
+
*
|
|
102
|
+
* @param scopeType - Type to search for ('CLASS', 'FUNCTION', etc.)
|
|
103
|
+
* @returns The scope entry name if found, undefined otherwise
|
|
104
|
+
*/
|
|
105
|
+
getEnclosingScope(scopeType: string): string | undefined {
|
|
106
|
+
// Search from end (innermost) to start (outermost)
|
|
107
|
+
for (let i = this.scopeStack.length - 1; i >= 0; i--) {
|
|
108
|
+
if (this.scopeStack[i].type === scopeType) {
|
|
109
|
+
return this.scopeStack[i].name;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// === Counter Management ===
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get next counter for item type within current scope.
|
|
119
|
+
* Used for CALL, LITERAL, etc. that need #N discriminators.
|
|
120
|
+
*/
|
|
121
|
+
getItemCounter(itemType: string): number {
|
|
122
|
+
const key = this.counterKey(itemType);
|
|
123
|
+
const n = this.counters.get(key) || 0;
|
|
124
|
+
this.counters.set(key, n + 1);
|
|
125
|
+
return n;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get current count without incrementing.
|
|
130
|
+
* Used to check for collisions.
|
|
131
|
+
*/
|
|
132
|
+
peekItemCounter(itemType: string): number {
|
|
133
|
+
return this.counters.get(this.counterKey(itemType)) || 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// === Sibling Tracking ===
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Track siblings by name within current scope.
|
|
140
|
+
* Used for anonymous functions: anonymous[0], anonymous[1]
|
|
141
|
+
*/
|
|
142
|
+
getSiblingIndex(name: string): number {
|
|
143
|
+
const key = `${this.getScopePath()}:sibling:${name}`;
|
|
144
|
+
const n = this.counters.get(key) || 0;
|
|
145
|
+
this.counters.set(key, n + 1);
|
|
146
|
+
return n;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// === Private ===
|
|
150
|
+
|
|
151
|
+
private counterKey(itemType: string): string {
|
|
152
|
+
return `${this.getScopePath()}:${itemType}`;
|
|
153
|
+
}
|
|
154
|
+
}
|