@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
|
@@ -14,40 +14,23 @@ import type {
|
|
|
14
14
|
Identifier,
|
|
15
15
|
AssignmentPattern,
|
|
16
16
|
RestElement,
|
|
17
|
-
VariableDeclarator
|
|
17
|
+
VariableDeclarator,
|
|
18
|
+
Comment
|
|
18
19
|
} from '@babel/types';
|
|
19
20
|
import type { NodePath } from '@babel/traverse';
|
|
20
21
|
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers, type CounterRef } from './ASTVisitor.js';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
siblingCounters: Map<string, number>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Parameter node info
|
|
32
|
-
*/
|
|
33
|
-
interface ParameterInfo {
|
|
34
|
-
id: string;
|
|
35
|
-
type: 'PARAMETER';
|
|
36
|
-
name: string;
|
|
37
|
-
file: string;
|
|
38
|
-
line: number;
|
|
39
|
-
index: number;
|
|
40
|
-
hasDefault?: boolean;
|
|
41
|
-
isRest?: boolean;
|
|
42
|
-
parentFunctionId: string;
|
|
43
|
-
}
|
|
22
|
+
import { typeNodeToString } from './TypeScriptVisitor.js';
|
|
23
|
+
import { ScopeTracker } from '../../../../core/ScopeTracker.js';
|
|
24
|
+
import { IdGenerator } from '../IdGenerator.js';
|
|
25
|
+
import { createParameterNodes } from '../utils/createParameterNodes.js';
|
|
26
|
+
import { getLine, getColumn } from '../utils/location.js';
|
|
27
|
+
import type { ParameterInfo } from '../types.js';
|
|
44
28
|
|
|
45
29
|
/**
|
|
46
30
|
* Function node info
|
|
47
31
|
*/
|
|
48
32
|
interface FunctionInfo {
|
|
49
33
|
id: string;
|
|
50
|
-
stableId: string;
|
|
51
34
|
type: 'FUNCTION';
|
|
52
35
|
name: string;
|
|
53
36
|
file: string;
|
|
@@ -56,6 +39,11 @@ interface FunctionInfo {
|
|
|
56
39
|
async: boolean;
|
|
57
40
|
generator?: boolean;
|
|
58
41
|
arrowFunction?: boolean;
|
|
42
|
+
params?: string[];
|
|
43
|
+
paramTypes?: string[];
|
|
44
|
+
returnType?: string;
|
|
45
|
+
signature?: string;
|
|
46
|
+
jsdocSummary?: string;
|
|
59
47
|
}
|
|
60
48
|
|
|
61
49
|
/**
|
|
@@ -84,19 +72,23 @@ export type AnalyzeFunctionBodyCallback = (
|
|
|
84
72
|
|
|
85
73
|
export class FunctionVisitor extends ASTVisitor {
|
|
86
74
|
private analyzeFunctionBody: AnalyzeFunctionBodyCallback;
|
|
75
|
+
private scopeTracker: ScopeTracker;
|
|
87
76
|
|
|
88
77
|
/**
|
|
89
78
|
* @param module - Current module being analyzed
|
|
90
79
|
* @param collections - Must contain arrays and counter refs
|
|
91
80
|
* @param analyzeFunctionBody - Callback to analyze function internals
|
|
81
|
+
* @param scopeTracker - REQUIRED for semantic ID generation
|
|
92
82
|
*/
|
|
93
83
|
constructor(
|
|
94
84
|
module: VisitorModule,
|
|
95
85
|
collections: VisitorCollections,
|
|
96
|
-
analyzeFunctionBody: AnalyzeFunctionBodyCallback
|
|
86
|
+
analyzeFunctionBody: AnalyzeFunctionBodyCallback,
|
|
87
|
+
scopeTracker: ScopeTracker
|
|
97
88
|
) {
|
|
98
89
|
super(module, collections);
|
|
99
90
|
this.analyzeFunctionBody = analyzeFunctionBody;
|
|
91
|
+
this.scopeTracker = scopeTracker;
|
|
100
92
|
}
|
|
101
93
|
|
|
102
94
|
getHandlers(): VisitorHandlers {
|
|
@@ -105,76 +97,109 @@ export class FunctionVisitor extends ASTVisitor {
|
|
|
105
97
|
const parameters = this.collections.parameters ?? [];
|
|
106
98
|
const scopes = this.collections.scopes ?? [];
|
|
107
99
|
const functionCounterRef = (this.collections.functionCounterRef ?? { value: 0 }) as CounterRef;
|
|
108
|
-
const
|
|
100
|
+
const scopeTracker = this.scopeTracker;
|
|
109
101
|
|
|
110
102
|
const analyzeFunctionBody = this.analyzeFunctionBody;
|
|
111
103
|
const collections = this.collections;
|
|
112
104
|
|
|
113
105
|
// Helper function to generate stable anonymous function name
|
|
114
106
|
const generateAnonymousName = (): string => {
|
|
115
|
-
|
|
116
|
-
const index = moduleScopeCtx.siblingCounters.get('anonymous') || 0;
|
|
117
|
-
moduleScopeCtx.siblingCounters.set('anonymous', index + 1);
|
|
107
|
+
const index = scopeTracker.getSiblingIndex('anonymous');
|
|
118
108
|
return `anonymous[${index}]`;
|
|
119
109
|
};
|
|
120
110
|
|
|
121
|
-
// Helper function to
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
): void => {
|
|
128
|
-
if (!parameters) return; // Guard for backward compatibility
|
|
129
|
-
|
|
130
|
-
params.forEach((param, index) => {
|
|
131
|
-
// Handle different parameter types
|
|
111
|
+
// Helper function to extract parameter names and types from function params
|
|
112
|
+
const extractParamInfo = (params: Node[]): { names: string[]; types: string[] } => {
|
|
113
|
+
const names: string[] = [];
|
|
114
|
+
const types: string[] = [];
|
|
115
|
+
|
|
116
|
+
params.forEach((param) => {
|
|
132
117
|
if (param.type === 'Identifier') {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
file: file,
|
|
139
|
-
line: param.loc?.start.line || line,
|
|
140
|
-
index: index,
|
|
141
|
-
parentFunctionId: functionId
|
|
142
|
-
});
|
|
118
|
+
const id = param as Identifier;
|
|
119
|
+
names.push(id.name);
|
|
120
|
+
// Check for type annotation
|
|
121
|
+
const typeAnnotation = (id as any).typeAnnotation?.typeAnnotation;
|
|
122
|
+
types.push(typeAnnotation ? typeNodeToString(typeAnnotation) : 'any');
|
|
143
123
|
} else if (param.type === 'AssignmentPattern') {
|
|
144
|
-
// Default parameter: function(a = 1)
|
|
145
124
|
const assignmentParam = param as AssignmentPattern;
|
|
146
125
|
if (assignmentParam.left.type === 'Identifier') {
|
|
147
|
-
const
|
|
148
|
-
(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
name: assignmentParam.left.name,
|
|
152
|
-
file: file,
|
|
153
|
-
line: assignmentParam.left.loc?.start.line || line,
|
|
154
|
-
index: index,
|
|
155
|
-
hasDefault: true,
|
|
156
|
-
parentFunctionId: functionId
|
|
157
|
-
});
|
|
126
|
+
const id = assignmentParam.left as Identifier;
|
|
127
|
+
names.push(id.name + '?');
|
|
128
|
+
const typeAnnotation = (id as any).typeAnnotation?.typeAnnotation;
|
|
129
|
+
types.push(typeAnnotation ? typeNodeToString(typeAnnotation) : 'any');
|
|
158
130
|
}
|
|
159
|
-
} else if (
|
|
160
|
-
// Rest parameter: function(...args)
|
|
131
|
+
} else if (param.type === 'RestElement') {
|
|
161
132
|
const restParam = param as unknown as RestElement;
|
|
162
133
|
if (restParam.argument.type === 'Identifier') {
|
|
163
|
-
const
|
|
164
|
-
(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
name: restParam.argument.name,
|
|
168
|
-
file: file,
|
|
169
|
-
line: restParam.argument.loc?.start.line || line,
|
|
170
|
-
index: index,
|
|
171
|
-
isRest: true,
|
|
172
|
-
parentFunctionId: functionId
|
|
173
|
-
});
|
|
134
|
+
const id = restParam.argument as Identifier;
|
|
135
|
+
names.push('...' + id.name);
|
|
136
|
+
const typeAnnotation = (id as any).typeAnnotation?.typeAnnotation;
|
|
137
|
+
types.push(typeAnnotation ? typeNodeToString(typeAnnotation) : 'any[]');
|
|
174
138
|
}
|
|
175
139
|
}
|
|
176
|
-
// ObjectPattern and ArrayPattern (destructuring parameters) can be added later
|
|
177
140
|
});
|
|
141
|
+
|
|
142
|
+
return { names, types };
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Helper function to extract return type from function
|
|
146
|
+
const extractReturnType = (node: Function): string => {
|
|
147
|
+
const returnTypeAnnotation = (node as any).returnType?.typeAnnotation;
|
|
148
|
+
if (returnTypeAnnotation) {
|
|
149
|
+
return typeNodeToString(returnTypeAnnotation);
|
|
150
|
+
}
|
|
151
|
+
return 'void';
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Helper function to extract JSDoc summary from leading comments
|
|
155
|
+
const extractJsdocSummary = (node: Node): string | undefined => {
|
|
156
|
+
const comments = node.leadingComments as Comment[] | null | undefined;
|
|
157
|
+
if (!comments || comments.length === 0) return undefined;
|
|
158
|
+
|
|
159
|
+
// Find the last block comment that looks like JSDoc
|
|
160
|
+
for (let i = comments.length - 1; i >= 0; i--) {
|
|
161
|
+
const comment = comments[i];
|
|
162
|
+
if (comment.type === 'CommentBlock' && comment.value.startsWith('*')) {
|
|
163
|
+
// Parse JSDoc - get first non-empty line after the opening
|
|
164
|
+
const lines = comment.value.split('\n');
|
|
165
|
+
for (const line of lines) {
|
|
166
|
+
const trimmed = line.replace(/^\s*\*\s?/, '').trim();
|
|
167
|
+
// Skip empty lines and @tags
|
|
168
|
+
if (trimmed && !trimmed.startsWith('@')) {
|
|
169
|
+
return trimmed.slice(0, 200); // Limit length
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return undefined;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// Helper function to build function signature
|
|
178
|
+
const buildSignature = (
|
|
179
|
+
params: string[],
|
|
180
|
+
paramTypes: string[],
|
|
181
|
+
returnType: string,
|
|
182
|
+
isAsync: boolean
|
|
183
|
+
): string => {
|
|
184
|
+
const paramParts = params.map((name, i) => {
|
|
185
|
+
const type = paramTypes[i] || 'any';
|
|
186
|
+
// Handle rest params
|
|
187
|
+
if (name.startsWith('...')) {
|
|
188
|
+
return `${name}: ${type}`;
|
|
189
|
+
}
|
|
190
|
+
// Handle optional params (with ?)
|
|
191
|
+
if (name.endsWith('?')) {
|
|
192
|
+
return `${name}: ${type}`;
|
|
193
|
+
}
|
|
194
|
+
return `${name}: ${type}`;
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const paramsStr = `(${paramParts.join(', ')})`;
|
|
198
|
+
const retStr = isAsync && !returnType.startsWith('Promise')
|
|
199
|
+
? `Promise<${returnType}>`
|
|
200
|
+
: returnType;
|
|
201
|
+
|
|
202
|
+
return `${paramsStr} => ${retStr}`;
|
|
178
203
|
};
|
|
179
204
|
|
|
180
205
|
return {
|
|
@@ -183,24 +208,43 @@ export class FunctionVisitor extends ASTVisitor {
|
|
|
183
208
|
const node = path.node as FunctionDeclaration;
|
|
184
209
|
if (!node.id) return; // Skip anonymous function declarations
|
|
185
210
|
|
|
186
|
-
const
|
|
211
|
+
const isAsync = node.async || false;
|
|
212
|
+
|
|
213
|
+
const line = getLine(node);
|
|
214
|
+
|
|
215
|
+
// Generate ID using centralized IdGenerator
|
|
216
|
+
const idGenerator = new IdGenerator(scopeTracker);
|
|
217
|
+
const functionId = idGenerator.generateSimple('FUNCTION', node.id.name, module.file, line);
|
|
218
|
+
|
|
219
|
+
// Extract type info
|
|
220
|
+
const { names: paramNames, types: paramTypes } = extractParamInfo(node.params);
|
|
221
|
+
const returnType = extractReturnType(node);
|
|
222
|
+
const jsdocSummary = extractJsdocSummary(node);
|
|
223
|
+
const signature = buildSignature(paramNames, paramTypes, returnType, isAsync);
|
|
187
224
|
|
|
188
225
|
(functions as FunctionInfo[]).push({
|
|
189
226
|
id: functionId,
|
|
190
|
-
stableId: functionId,
|
|
191
227
|
type: 'FUNCTION',
|
|
192
228
|
name: node.id.name,
|
|
193
229
|
file: module.file,
|
|
194
|
-
line
|
|
195
|
-
async:
|
|
196
|
-
generator: node.generator || false
|
|
230
|
+
line,
|
|
231
|
+
async: isAsync,
|
|
232
|
+
generator: node.generator || false,
|
|
233
|
+
params: paramNames,
|
|
234
|
+
paramTypes,
|
|
235
|
+
returnType,
|
|
236
|
+
signature,
|
|
237
|
+
jsdocSummary
|
|
197
238
|
});
|
|
198
239
|
|
|
240
|
+
// Enter function scope BEFORE creating parameters (semantic IDs need function context)
|
|
241
|
+
scopeTracker.enterScope(node.id.name, 'FUNCTION');
|
|
242
|
+
|
|
199
243
|
// Create PARAMETER nodes for function parameters
|
|
200
|
-
createParameterNodes(node.params, functionId, module.file, node
|
|
244
|
+
createParameterNodes(node.params, functionId, module.file, getLine(node), parameters as ParameterInfo[], scopeTracker);
|
|
201
245
|
|
|
202
246
|
// Create SCOPE for function body
|
|
203
|
-
const functionBodyScopeId =
|
|
247
|
+
const functionBodyScopeId = idGenerator.generateScope('body', `${node.id.name}:body`, module.file, line);
|
|
204
248
|
(scopes as ScopeInfo[]).push({
|
|
205
249
|
id: functionBodyScopeId,
|
|
206
250
|
type: 'SCOPE',
|
|
@@ -208,13 +252,16 @@ export class FunctionVisitor extends ASTVisitor {
|
|
|
208
252
|
name: `${node.id.name}:body`,
|
|
209
253
|
conditional: false,
|
|
210
254
|
file: module.file,
|
|
211
|
-
line
|
|
255
|
+
line,
|
|
212
256
|
parentFunctionId: functionId
|
|
213
257
|
});
|
|
214
258
|
|
|
215
259
|
// Analyze function body
|
|
216
260
|
analyzeFunctionBody(path as NodePath<FunctionDeclaration>, functionBodyScopeId, module, collections);
|
|
217
261
|
|
|
262
|
+
// Exit function scope
|
|
263
|
+
scopeTracker.exitScope();
|
|
264
|
+
|
|
218
265
|
// Stop traversal - analyzeFunctionBody already processed contents
|
|
219
266
|
path.skip();
|
|
220
267
|
},
|
|
@@ -222,8 +269,9 @@ export class FunctionVisitor extends ASTVisitor {
|
|
|
222
269
|
// Arrow functions (module-level, assigned to variables or as callbacks)
|
|
223
270
|
ArrowFunctionExpression: (path: NodePath) => {
|
|
224
271
|
const node = path.node as ArrowFunctionExpression;
|
|
225
|
-
const line = node
|
|
226
|
-
const column = node
|
|
272
|
+
const line = getLine(node);
|
|
273
|
+
const column = getColumn(node);
|
|
274
|
+
const isAsync = node.async || false;
|
|
227
275
|
|
|
228
276
|
// Determine arrow function name (use scope-level counter for stable semanticId)
|
|
229
277
|
let functionName = generateAnonymousName();
|
|
@@ -237,25 +285,40 @@ export class FunctionVisitor extends ASTVisitor {
|
|
|
237
285
|
}
|
|
238
286
|
}
|
|
239
287
|
|
|
240
|
-
|
|
288
|
+
// Generate ID using centralized IdGenerator
|
|
289
|
+
const idGenerator = new IdGenerator(scopeTracker);
|
|
290
|
+
const functionId = idGenerator.generate('FUNCTION', functionName, module.file, line, column, functionCounterRef);
|
|
291
|
+
|
|
292
|
+
// Extract type info
|
|
293
|
+
const { names: paramNames, types: paramTypes } = extractParamInfo(node.params);
|
|
294
|
+
const returnType = extractReturnType(node);
|
|
295
|
+
const jsdocSummary = extractJsdocSummary(node);
|
|
296
|
+
const signature = buildSignature(paramNames, paramTypes, returnType, isAsync);
|
|
241
297
|
|
|
242
298
|
(functions as FunctionInfo[]).push({
|
|
243
299
|
id: functionId,
|
|
244
|
-
stableId: functionId,
|
|
245
300
|
type: 'FUNCTION',
|
|
246
301
|
name: functionName,
|
|
247
302
|
file: module.file,
|
|
248
303
|
line,
|
|
249
304
|
column,
|
|
250
|
-
async:
|
|
251
|
-
arrowFunction: true
|
|
305
|
+
async: isAsync,
|
|
306
|
+
arrowFunction: true,
|
|
307
|
+
params: paramNames,
|
|
308
|
+
paramTypes,
|
|
309
|
+
returnType,
|
|
310
|
+
signature,
|
|
311
|
+
jsdocSummary
|
|
252
312
|
});
|
|
253
313
|
|
|
314
|
+
// Enter function scope BEFORE creating parameters (semantic IDs need function context)
|
|
315
|
+
scopeTracker.enterScope(functionName, 'FUNCTION');
|
|
316
|
+
|
|
254
317
|
// Create PARAMETER nodes for arrow function parameters
|
|
255
|
-
createParameterNodes(node.params, functionId, module.file, line);
|
|
318
|
+
createParameterNodes(node.params, functionId, module.file, line, parameters as ParameterInfo[], scopeTracker);
|
|
256
319
|
|
|
257
320
|
// Create SCOPE for arrow function body
|
|
258
|
-
const bodyScope =
|
|
321
|
+
const bodyScope = idGenerator.generateScope('body', `${functionName}:body`, module.file, line, column);
|
|
259
322
|
(scopes as ScopeInfo[]).push({
|
|
260
323
|
id: bodyScope,
|
|
261
324
|
type: 'SCOPE',
|
|
@@ -267,6 +330,9 @@ export class FunctionVisitor extends ASTVisitor {
|
|
|
267
330
|
});
|
|
268
331
|
|
|
269
332
|
analyzeFunctionBody(path as NodePath<ArrowFunctionExpression>, bodyScope, module, collections);
|
|
333
|
+
|
|
334
|
+
// Exit function scope
|
|
335
|
+
scopeTracker.exitScope();
|
|
270
336
|
}
|
|
271
337
|
};
|
|
272
338
|
}
|
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
import type { NodePath } from '@babel/traverse';
|
|
27
27
|
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers } from './ASTVisitor.js';
|
|
28
28
|
import type { VariableInfo } from './VariableVisitor.js';
|
|
29
|
+
import { getLine, getColumn } from '../utils/location.js';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Callback type for extracting variable names from patterns
|
|
@@ -47,6 +48,7 @@ interface ImportInfo {
|
|
|
47
48
|
source: string;
|
|
48
49
|
specifiers: ImportSpecifierInfo[];
|
|
49
50
|
line: number;
|
|
51
|
+
column?: number;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -127,7 +129,8 @@ export class ImportExportVisitor extends ASTVisitor {
|
|
|
127
129
|
(imports as ImportInfo[]).push({
|
|
128
130
|
source,
|
|
129
131
|
specifiers,
|
|
130
|
-
line: node
|
|
132
|
+
line: getLine(node),
|
|
133
|
+
column: getColumn(node)
|
|
131
134
|
});
|
|
132
135
|
}
|
|
133
136
|
};
|
|
@@ -143,13 +146,14 @@ export class ImportExportVisitor extends ASTVisitor {
|
|
|
143
146
|
|
|
144
147
|
(exports as ExportInfo[]).push({
|
|
145
148
|
type: 'default',
|
|
146
|
-
line: node
|
|
149
|
+
line: getLine(node),
|
|
147
150
|
declaration: node.declaration
|
|
148
151
|
});
|
|
149
152
|
},
|
|
150
153
|
|
|
151
154
|
ExportNamedDeclaration: (path: NodePath) => {
|
|
152
155
|
const node = path.node as ExportNamedDeclaration;
|
|
156
|
+
const exportLine = getLine(node);
|
|
153
157
|
|
|
154
158
|
// export { foo, bar } from './module'
|
|
155
159
|
if (node.source) {
|
|
@@ -169,7 +173,7 @@ export class ImportExportVisitor extends ASTVisitor {
|
|
|
169
173
|
|
|
170
174
|
(exports as ExportInfo[]).push({
|
|
171
175
|
type: 'named',
|
|
172
|
-
line:
|
|
176
|
+
line: exportLine,
|
|
173
177
|
specifiers,
|
|
174
178
|
source: node.source.value
|
|
175
179
|
});
|
|
@@ -189,7 +193,7 @@ export class ImportExportVisitor extends ASTVisitor {
|
|
|
189
193
|
|
|
190
194
|
(exports as ExportInfo[]).push({
|
|
191
195
|
type: 'named',
|
|
192
|
-
line:
|
|
196
|
+
line: exportLine,
|
|
193
197
|
specifiers
|
|
194
198
|
});
|
|
195
199
|
}
|
|
@@ -203,7 +207,7 @@ export class ImportExportVisitor extends ASTVisitor {
|
|
|
203
207
|
if (funcDecl.id) {
|
|
204
208
|
(exports as ExportInfo[]).push({
|
|
205
209
|
type: 'named',
|
|
206
|
-
line:
|
|
210
|
+
line: exportLine,
|
|
207
211
|
name: funcDecl.id.name
|
|
208
212
|
});
|
|
209
213
|
}
|
|
@@ -217,7 +221,7 @@ export class ImportExportVisitor extends ASTVisitor {
|
|
|
217
221
|
variables.forEach((varInfo: VariableInfo) => {
|
|
218
222
|
(exports as ExportInfo[]).push({
|
|
219
223
|
type: 'named',
|
|
220
|
-
line:
|
|
224
|
+
line: exportLine,
|
|
221
225
|
name: varInfo.name
|
|
222
226
|
});
|
|
223
227
|
});
|
|
@@ -229,7 +233,7 @@ export class ImportExportVisitor extends ASTVisitor {
|
|
|
229
233
|
if (classDecl.id) {
|
|
230
234
|
(exports as ExportInfo[]).push({
|
|
231
235
|
type: 'named',
|
|
232
|
-
line:
|
|
236
|
+
line: exportLine,
|
|
233
237
|
name: classDecl.id.name
|
|
234
238
|
});
|
|
235
239
|
}
|
|
@@ -243,7 +247,7 @@ export class ImportExportVisitor extends ASTVisitor {
|
|
|
243
247
|
// export * from './module'
|
|
244
248
|
(exports as ExportInfo[]).push({
|
|
245
249
|
type: 'all',
|
|
246
|
-
line: node
|
|
250
|
+
line: getLine(node),
|
|
247
251
|
source: node.source.value
|
|
248
252
|
});
|
|
249
253
|
}
|
|
@@ -26,11 +26,14 @@ import type {
|
|
|
26
26
|
EnumDeclarationInfo,
|
|
27
27
|
EnumMemberInfo
|
|
28
28
|
} from '../types.js';
|
|
29
|
+
import { ScopeTracker } from '../../../../core/ScopeTracker.js';
|
|
30
|
+
import { computeSemanticId } from '../../../../core/SemanticId.js';
|
|
31
|
+
import { getLine, getColumn } from '../utils/location.js';
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* Extracts a string representation of a TypeScript type node
|
|
32
35
|
*/
|
|
33
|
-
function typeNodeToString(node: unknown): string {
|
|
36
|
+
export function typeNodeToString(node: unknown): string {
|
|
34
37
|
if (!node || typeof node !== 'object') return 'unknown';
|
|
35
38
|
|
|
36
39
|
const typeNode = node as { type: string; [key: string]: unknown };
|
|
@@ -97,8 +100,16 @@ function typeNodeToString(node: unknown): string {
|
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
export class TypeScriptVisitor extends ASTVisitor {
|
|
100
|
-
|
|
103
|
+
private scopeTracker?: ScopeTracker;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param module - Current module being analyzed
|
|
107
|
+
* @param collections - Must contain interfaces, typeAliases, enums arrays
|
|
108
|
+
* @param scopeTracker - Optional ScopeTracker for semantic ID generation
|
|
109
|
+
*/
|
|
110
|
+
constructor(module: VisitorModule, collections: VisitorCollections, scopeTracker?: ScopeTracker) {
|
|
101
111
|
super(module, collections);
|
|
112
|
+
this.scopeTracker = scopeTracker;
|
|
102
113
|
}
|
|
103
114
|
|
|
104
115
|
getHandlers(): VisitorHandlers {
|
|
@@ -108,6 +119,7 @@ export class TypeScriptVisitor extends ASTVisitor {
|
|
|
108
119
|
typeAliases,
|
|
109
120
|
enums
|
|
110
121
|
} = this.collections;
|
|
122
|
+
const scopeTracker = this.scopeTracker;
|
|
111
123
|
|
|
112
124
|
return {
|
|
113
125
|
TSInterfaceDeclaration: (path: NodePath) => {
|
|
@@ -115,7 +127,12 @@ export class TypeScriptVisitor extends ASTVisitor {
|
|
|
115
127
|
if (!node.id) return;
|
|
116
128
|
|
|
117
129
|
const interfaceName = node.id.name;
|
|
118
|
-
|
|
130
|
+
|
|
131
|
+
// Generate semantic ID if scopeTracker available
|
|
132
|
+
let interfaceSemanticId: string | undefined;
|
|
133
|
+
if (scopeTracker) {
|
|
134
|
+
interfaceSemanticId = computeSemanticId('INTERFACE', interfaceName, scopeTracker.getContext());
|
|
135
|
+
}
|
|
119
136
|
|
|
120
137
|
// Extract extends
|
|
121
138
|
const extendsNames: string[] = [];
|
|
@@ -156,12 +173,12 @@ export class TypeScriptVisitor extends ASTVisitor {
|
|
|
156
173
|
}
|
|
157
174
|
|
|
158
175
|
(interfaces as InterfaceDeclarationInfo[]).push({
|
|
159
|
-
|
|
176
|
+
semanticId: interfaceSemanticId,
|
|
160
177
|
type: 'INTERFACE',
|
|
161
178
|
name: interfaceName,
|
|
162
179
|
file: module.file,
|
|
163
|
-
line: node
|
|
164
|
-
column: node
|
|
180
|
+
line: getLine(node),
|
|
181
|
+
column: getColumn(node),
|
|
165
182
|
extends: extendsNames.length > 0 ? extendsNames : undefined,
|
|
166
183
|
properties
|
|
167
184
|
});
|
|
@@ -172,18 +189,23 @@ export class TypeScriptVisitor extends ASTVisitor {
|
|
|
172
189
|
if (!node.id) return;
|
|
173
190
|
|
|
174
191
|
const typeName = node.id.name;
|
|
175
|
-
|
|
192
|
+
|
|
193
|
+
// Generate semantic ID if scopeTracker available
|
|
194
|
+
let typeSemanticId: string | undefined;
|
|
195
|
+
if (scopeTracker) {
|
|
196
|
+
typeSemanticId = computeSemanticId('TYPE', typeName, scopeTracker.getContext());
|
|
197
|
+
}
|
|
176
198
|
|
|
177
199
|
// Extract the type being aliased
|
|
178
200
|
const aliasOf = typeNodeToString(node.typeAnnotation);
|
|
179
201
|
|
|
180
202
|
(typeAliases as TypeAliasInfo[]).push({
|
|
181
|
-
|
|
203
|
+
semanticId: typeSemanticId,
|
|
182
204
|
type: 'TYPE',
|
|
183
205
|
name: typeName,
|
|
184
206
|
file: module.file,
|
|
185
|
-
line: node
|
|
186
|
-
column: node
|
|
207
|
+
line: getLine(node),
|
|
208
|
+
column: getColumn(node),
|
|
187
209
|
aliasOf
|
|
188
210
|
});
|
|
189
211
|
},
|
|
@@ -193,7 +215,12 @@ export class TypeScriptVisitor extends ASTVisitor {
|
|
|
193
215
|
if (!node.id) return;
|
|
194
216
|
|
|
195
217
|
const enumName = node.id.name;
|
|
196
|
-
|
|
218
|
+
|
|
219
|
+
// Generate semantic ID if scopeTracker available
|
|
220
|
+
let enumSemanticId: string | undefined;
|
|
221
|
+
if (scopeTracker) {
|
|
222
|
+
enumSemanticId = computeSemanticId('ENUM', enumName, scopeTracker.getContext());
|
|
223
|
+
}
|
|
197
224
|
|
|
198
225
|
// Extract members
|
|
199
226
|
const members: EnumMemberInfo[] = [];
|
|
@@ -220,12 +247,12 @@ export class TypeScriptVisitor extends ASTVisitor {
|
|
|
220
247
|
}
|
|
221
248
|
|
|
222
249
|
(enums as EnumDeclarationInfo[]).push({
|
|
223
|
-
|
|
250
|
+
semanticId: enumSemanticId,
|
|
224
251
|
type: 'ENUM',
|
|
225
252
|
name: enumName,
|
|
226
253
|
file: module.file,
|
|
227
|
-
line: node
|
|
228
|
-
column: node
|
|
254
|
+
line: getLine(node),
|
|
255
|
+
column: getColumn(node),
|
|
229
256
|
isConst: node.const || false,
|
|
230
257
|
members
|
|
231
258
|
});
|