@nahisaho/musubix-dfg 1.8.5
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/dist/analyzers/index.d.ts +92 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +902 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/graph/index.d.ts +192 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +552 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +312 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +29 -0
- package/dist/types/index.js.map +1 -0
- package/dist/yata/index.d.ts +135 -0
- package/dist/yata/index.d.ts.map +1 -0
- package/dist/yata/index.js +557 -0
- package/dist/yata/index.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DFG/CFG Analyzers
|
|
3
|
+
*
|
|
4
|
+
* TypeScript AST to Data Flow Graph and Control Flow Graph conversion
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module @nahisaho/musubix-dfg/analyzers
|
|
8
|
+
*/
|
|
9
|
+
import type { CFGBlock, DataFlowGraph, ControlFlowGraph, DFGAnalysisOptions, CFGAnalysisOptions } from '../types/index.js';
|
|
10
|
+
import { DFGAnalyzer, CFGAnalyzer } from '../graph/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Data Flow Graph analyzer for TypeScript/JavaScript code
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const analyzer = new DataFlowAnalyzer();
|
|
17
|
+
* const dfg = await analyzer.analyze('src/user-service.ts');
|
|
18
|
+
*
|
|
19
|
+
* // Query dependencies
|
|
20
|
+
* const deps = dfg.getDataDependencies('userId');
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @traces REQ-DFG-001
|
|
24
|
+
*/
|
|
25
|
+
export declare class DataFlowAnalyzer {
|
|
26
|
+
private options;
|
|
27
|
+
constructor(options?: Partial<DFGAnalysisOptions>);
|
|
28
|
+
/**
|
|
29
|
+
* Analyze a TypeScript/JavaScript file
|
|
30
|
+
*/
|
|
31
|
+
analyze(filePath: string): Promise<DataFlowGraph>;
|
|
32
|
+
/**
|
|
33
|
+
* Analyze source code directly
|
|
34
|
+
*/
|
|
35
|
+
analyzeSource(sourceCode: string, filePath: string): DataFlowGraph;
|
|
36
|
+
private handleVariableDeclaration;
|
|
37
|
+
private handleParameter;
|
|
38
|
+
private handleFunction;
|
|
39
|
+
private handleClass;
|
|
40
|
+
private handleCallExpression;
|
|
41
|
+
private handleBinaryExpression;
|
|
42
|
+
private handleIdentifier;
|
|
43
|
+
private handleReturn;
|
|
44
|
+
private createDataFlowEdges;
|
|
45
|
+
private getSourceLocation;
|
|
46
|
+
/**
|
|
47
|
+
* Create analyzer for a built graph
|
|
48
|
+
*/
|
|
49
|
+
createAnalyzer(graph: DataFlowGraph): DFGAnalyzer;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Control Flow Graph analyzer for TypeScript/JavaScript code
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const analyzer = new ControlFlowAnalyzer();
|
|
57
|
+
* const cfg = await analyzer.analyze('src/user-service.ts', 'getUserById');
|
|
58
|
+
*
|
|
59
|
+
* // Get cyclomatic complexity
|
|
60
|
+
* const complexity = cfg.getCyclomaticComplexity();
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @traces REQ-DFG-002
|
|
64
|
+
*/
|
|
65
|
+
export declare class ControlFlowAnalyzer {
|
|
66
|
+
private options;
|
|
67
|
+
constructor(options?: Partial<CFGAnalysisOptions>);
|
|
68
|
+
/**
|
|
69
|
+
* Analyze a specific function in a file
|
|
70
|
+
*/
|
|
71
|
+
analyze(filePath: string, functionName?: string): Promise<ControlFlowGraph[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Analyze source code directly
|
|
74
|
+
*/
|
|
75
|
+
analyzeSource(sourceCode: string, filePath: string, functionName?: string): ControlFlowGraph[];
|
|
76
|
+
private getFunctionName;
|
|
77
|
+
private analyzeFunction;
|
|
78
|
+
private processIfStatement;
|
|
79
|
+
private processLoopStatement;
|
|
80
|
+
private processTryStatement;
|
|
81
|
+
private getSourceLocation;
|
|
82
|
+
/**
|
|
83
|
+
* Create analyzer for a built graph
|
|
84
|
+
*/
|
|
85
|
+
createAnalyzer(graph: ControlFlowGraph): CFGAnalyzer;
|
|
86
|
+
}
|
|
87
|
+
declare module '../graph/index.js' {
|
|
88
|
+
interface CFGBuilder {
|
|
89
|
+
getBlock(blockId: string): CFGBlock | undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analyzers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAGV,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,WAAW,EAEX,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAM3B;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAqB;gBAExB,OAAO,GAAE,OAAO,CAAC,kBAAkB,CAAM;IAWrD;;OAEG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAMvD;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa;IA6GlE,OAAO,CAAC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