driftdetect-core 0.1.0
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/ast-analyzer.d.ts +251 -0
- package/dist/analyzers/ast-analyzer.d.ts.map +1 -0
- package/dist/analyzers/ast-analyzer.js +548 -0
- package/dist/analyzers/ast-analyzer.js.map +1 -0
- package/dist/analyzers/flow-analyzer.d.ts +241 -0
- package/dist/analyzers/flow-analyzer.d.ts.map +1 -0
- package/dist/analyzers/flow-analyzer.js +1219 -0
- package/dist/analyzers/flow-analyzer.js.map +1 -0
- package/dist/analyzers/index.d.ts +18 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +19 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/analyzers/semantic-analyzer.d.ts +252 -0
- package/dist/analyzers/semantic-analyzer.d.ts.map +1 -0
- package/dist/analyzers/semantic-analyzer.js +1182 -0
- package/dist/analyzers/semantic-analyzer.js.map +1 -0
- package/dist/analyzers/type-analyzer.d.ts +289 -0
- package/dist/analyzers/type-analyzer.d.ts.map +1 -0
- package/dist/analyzers/type-analyzer.js +1269 -0
- package/dist/analyzers/type-analyzer.js.map +1 -0
- package/dist/analyzers/types.d.ts +537 -0
- package/dist/analyzers/types.d.ts.map +1 -0
- package/dist/analyzers/types.js +11 -0
- package/dist/analyzers/types.js.map +1 -0
- package/dist/config/config-loader.d.ts +166 -0
- package/dist/config/config-loader.d.ts.map +1 -0
- package/dist/config/config-loader.js +429 -0
- package/dist/config/config-loader.js.map +1 -0
- package/dist/config/config-validator.d.ts +204 -0
- package/dist/config/config-validator.d.ts.map +1 -0
- package/dist/config/config-validator.js +632 -0
- package/dist/config/config-validator.js.map +1 -0
- package/dist/config/defaults.d.ts +8 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +26 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +10 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/types.d.ts +47 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +7 -0
- package/dist/config/types.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest/exporter.d.ts +21 -0
- package/dist/manifest/exporter.d.ts.map +1 -0
- package/dist/manifest/exporter.js +339 -0
- package/dist/manifest/exporter.js.map +1 -0
- package/dist/manifest/index.d.ts +14 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +15 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/manifest-store.d.ts +111 -0
- package/dist/manifest/manifest-store.d.ts.map +1 -0
- package/dist/manifest/manifest-store.js +418 -0
- package/dist/manifest/manifest-store.js.map +1 -0
- package/dist/manifest/types.d.ts +238 -0
- package/dist/manifest/types.d.ts.map +1 -0
- package/dist/manifest/types.js +11 -0
- package/dist/manifest/types.js.map +1 -0
- package/dist/matcher/confidence-scorer.d.ts +188 -0
- package/dist/matcher/confidence-scorer.d.ts.map +1 -0
- package/dist/matcher/confidence-scorer.js +302 -0
- package/dist/matcher/confidence-scorer.js.map +1 -0
- package/dist/matcher/index.d.ts +24 -0
- package/dist/matcher/index.d.ts.map +1 -0
- package/dist/matcher/index.js +26 -0
- package/dist/matcher/index.js.map +1 -0
- package/dist/matcher/outlier-detector.d.ts +252 -0
- package/dist/matcher/outlier-detector.d.ts.map +1 -0
- package/dist/matcher/outlier-detector.js +544 -0
- package/dist/matcher/outlier-detector.js.map +1 -0
- package/dist/matcher/pattern-matcher.d.ts +169 -0
- package/dist/matcher/pattern-matcher.d.ts.map +1 -0
- package/dist/matcher/pattern-matcher.js +692 -0
- package/dist/matcher/pattern-matcher.js.map +1 -0
- package/dist/matcher/types.d.ts +476 -0
- package/dist/matcher/types.d.ts.map +1 -0
- package/dist/matcher/types.js +36 -0
- package/dist/matcher/types.js.map +1 -0
- package/dist/parsers/base-parser.d.ts +282 -0
- package/dist/parsers/base-parser.d.ts.map +1 -0
- package/dist/parsers/base-parser.js +421 -0
- package/dist/parsers/base-parser.js.map +1 -0
- package/dist/parsers/css-parser.d.ts +225 -0
- package/dist/parsers/css-parser.d.ts.map +1 -0
- package/dist/parsers/css-parser.js +477 -0
- package/dist/parsers/css-parser.js.map +1 -0
- package/dist/parsers/index.d.ts +15 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +15 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/json-parser.d.ts +219 -0
- package/dist/parsers/json-parser.d.ts.map +1 -0
- package/dist/parsers/json-parser.js +602 -0
- package/dist/parsers/json-parser.js.map +1 -0
- package/dist/parsers/markdown-parser.d.ts +276 -0
- package/dist/parsers/markdown-parser.d.ts.map +1 -0
- package/dist/parsers/markdown-parser.js +731 -0
- package/dist/parsers/markdown-parser.js.map +1 -0
- package/dist/parsers/parser-manager.d.ts +294 -0
- package/dist/parsers/parser-manager.d.ts.map +1 -0
- package/dist/parsers/parser-manager.js +738 -0
- package/dist/parsers/parser-manager.js.map +1 -0
- package/dist/parsers/python-parser.d.ts +204 -0
- package/dist/parsers/python-parser.d.ts.map +1 -0
- package/dist/parsers/python-parser.js +517 -0
- package/dist/parsers/python-parser.js.map +1 -0
- package/dist/parsers/types.d.ts +43 -0
- package/dist/parsers/types.d.ts.map +1 -0
- package/dist/parsers/types.js +7 -0
- package/dist/parsers/types.js.map +1 -0
- package/dist/parsers/typescript-parser.d.ts +264 -0
- package/dist/parsers/typescript-parser.d.ts.map +1 -0
- package/dist/parsers/typescript-parser.js +658 -0
- package/dist/parsers/typescript-parser.js.map +1 -0
- package/dist/rules/evaluator.d.ts +305 -0
- package/dist/rules/evaluator.d.ts.map +1 -0
- package/dist/rules/evaluator.js +579 -0
- package/dist/rules/evaluator.js.map +1 -0
- package/dist/rules/index.d.ts +13 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +13 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/quick-fix-generator.d.ts +334 -0
- package/dist/rules/quick-fix-generator.d.ts.map +1 -0
- package/dist/rules/quick-fix-generator.js +1075 -0
- package/dist/rules/quick-fix-generator.js.map +1 -0
- package/dist/rules/rule-engine.d.ts +241 -0
- package/dist/rules/rule-engine.d.ts.map +1 -0
- package/dist/rules/rule-engine.js +585 -0
- package/dist/rules/rule-engine.js.map +1 -0
- package/dist/rules/severity-manager.d.ts +394 -0
- package/dist/rules/severity-manager.d.ts.map +1 -0
- package/dist/rules/severity-manager.js +619 -0
- package/dist/rules/severity-manager.js.map +1 -0
- package/dist/rules/types.d.ts +370 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +133 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/rules/variant-manager.d.ts +388 -0
- package/dist/rules/variant-manager.d.ts.map +1 -0
- package/dist/rules/variant-manager.js +777 -0
- package/dist/rules/variant-manager.js.map +1 -0
- package/dist/scanner/change-detector.d.ts +164 -0
- package/dist/scanner/change-detector.d.ts.map +1 -0
- package/dist/scanner/change-detector.js +263 -0
- package/dist/scanner/change-detector.js.map +1 -0
- package/dist/scanner/dependency-graph.d.ts +270 -0
- package/dist/scanner/dependency-graph.d.ts.map +1 -0
- package/dist/scanner/dependency-graph.js +436 -0
- package/dist/scanner/dependency-graph.js.map +1 -0
- package/dist/scanner/file-walker.d.ts +127 -0
- package/dist/scanner/file-walker.d.ts.map +1 -0
- package/dist/scanner/file-walker.js +526 -0
- package/dist/scanner/file-walker.js.map +1 -0
- package/dist/scanner/index.d.ts +12 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +12 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/types.d.ts +218 -0
- package/dist/scanner/types.d.ts.map +1 -0
- package/dist/scanner/types.js +10 -0
- package/dist/scanner/types.js.map +1 -0
- package/dist/scanner/worker-pool.d.ts +317 -0
- package/dist/scanner/worker-pool.d.ts.map +1 -0
- package/dist/scanner/worker-pool.js +571 -0
- package/dist/scanner/worker-pool.js.map +1 -0
- package/dist/store/cache-manager.d.ts +179 -0
- package/dist/store/cache-manager.d.ts.map +1 -0
- package/dist/store/cache-manager.js +391 -0
- package/dist/store/cache-manager.js.map +1 -0
- package/dist/store/history-store.d.ts +314 -0
- package/dist/store/history-store.d.ts.map +1 -0
- package/dist/store/history-store.js +707 -0
- package/dist/store/history-store.js.map +1 -0
- package/dist/store/index.d.ts +20 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +26 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/lock-file-manager.d.ts +202 -0
- package/dist/store/lock-file-manager.d.ts.map +1 -0
- package/dist/store/lock-file-manager.js +475 -0
- package/dist/store/lock-file-manager.js.map +1 -0
- package/dist/store/pattern-store.d.ts +289 -0
- package/dist/store/pattern-store.d.ts.map +1 -0
- package/dist/store/pattern-store.js +936 -0
- package/dist/store/pattern-store.js.map +1 -0
- package/dist/store/schema-validator.d.ts +159 -0
- package/dist/store/schema-validator.d.ts.map +1 -0
- package/dist/store/schema-validator.js +1096 -0
- package/dist/store/schema-validator.js.map +1 -0
- package/dist/store/types.d.ts +585 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +82 -0
- package/dist/store/types.js.map +1 -0
- package/dist/types/analysis.d.ts +19 -0
- package/dist/types/analysis.d.ts.map +1 -0
- package/dist/types/analysis.js +5 -0
- package/dist/types/analysis.js.map +1 -0
- package/dist/types/common.d.ts +7 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +5 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/patterns.d.ts +40 -0
- package/dist/types/patterns.d.ts.map +1 -0
- package/dist/types/patterns.js +7 -0
- package/dist/types/patterns.js.map +1 -0
- package/dist/types/violations.d.ts +7 -0
- package/dist/types/violations.d.ts.map +1 -0
- package/dist/types/violations.js +7 -0
- package/dist/types/violations.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quick Fix Generator - Code transformation generation for violations
|
|
3
|
+
*
|
|
4
|
+
* Generates code transformations (quick fixes) for pattern violations.
|
|
5
|
+
* Supports multiple fix types: replace, wrap, extract, import, rename, move, delete.
|
|
6
|
+
* Provides preview of changes before applying.
|
|
7
|
+
*
|
|
8
|
+
* @requirements 25.1 - THE Quick_Fix_System SHALL generate code transformations for fixable violations
|
|
9
|
+
* @requirements 25.2 - THE Quick_Fix SHALL include a preview of the change before applying
|
|
10
|
+
* @requirements 25.3 - THE Quick_Fix SHALL support fix types: replace, wrap, extract, import, rename, move, delete
|
|
11
|
+
* @requirements 25.4 - WHEN multiple fixes are available, THE Quick_Fix_System SHALL rank by confidence
|
|
12
|
+
* @requirements 25.5 - THE Quick_Fix_System SHALL mark the preferred fix for one-click application
|
|
13
|
+
*/
|
|
14
|
+
import type { Violation, QuickFix, QuickFixWithMetadata, FixType, FixImpact } from './types.js';
|
|
15
|
+
/**
|
|
16
|
+
* Configuration options for the QuickFixGenerator
|
|
17
|
+
*/
|
|
18
|
+
export interface QuickFixGeneratorConfig {
|
|
19
|
+
/** Minimum confidence threshold for generating fixes */
|
|
20
|
+
minConfidence?: number;
|
|
21
|
+
/** Maximum number of fixes to generate per violation */
|
|
22
|
+
maxFixesPerViolation?: number;
|
|
23
|
+
/** Whether to generate previews for fixes */
|
|
24
|
+
generatePreviews?: boolean;
|
|
25
|
+
/** Whether to validate fixes before returning */
|
|
26
|
+
validateFixes?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Default QuickFixGenerator configuration
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_QUICK_FIX_GENERATOR_CONFIG: Required<QuickFixGeneratorConfig>;
|
|
32
|
+
/**
|
|
33
|
+
* Strategy for generating a specific type of fix
|
|
34
|
+
*/
|
|
35
|
+
export interface FixStrategy {
|
|
36
|
+
/** Type of fix this strategy generates */
|
|
37
|
+
type: FixType;
|
|
38
|
+
/** Generate a fix for a violation */
|
|
39
|
+
generate(context: FixContext): QuickFix | null;
|
|
40
|
+
/** Check if this strategy can handle the violation */
|
|
41
|
+
canHandle(violation: Violation): boolean;
|
|
42
|
+
/** Get the confidence score for this fix */
|
|
43
|
+
getConfidence(context: FixContext): number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Context for generating a fix
|
|
47
|
+
*/
|
|
48
|
+
export interface FixContext {
|
|
49
|
+
/** The violation to fix */
|
|
50
|
+
violation: Violation;
|
|
51
|
+
/** File content */
|
|
52
|
+
content: string;
|
|
53
|
+
/** Expected code/pattern */
|
|
54
|
+
expected: string;
|
|
55
|
+
/** Actual code found */
|
|
56
|
+
actual: string;
|
|
57
|
+
/** Additional context for the fix */
|
|
58
|
+
metadata?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Result of generating fixes for a violation
|
|
62
|
+
*/
|
|
63
|
+
export interface FixGenerationResult {
|
|
64
|
+
/** Violation ID */
|
|
65
|
+
violationId: string;
|
|
66
|
+
/** Generated fixes (sorted by confidence) */
|
|
67
|
+
fixes: QuickFixWithMetadata[];
|
|
68
|
+
/** Whether any fixes were generated */
|
|
69
|
+
hasFixs: boolean;
|
|
70
|
+
/** The preferred fix (highest confidence) */
|
|
71
|
+
preferredFix?: QuickFixWithMetadata;
|
|
72
|
+
/** Errors encountered during generation */
|
|
73
|
+
errors: string[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Strategy for generating replace fixes
|
|
77
|
+
* Replaces text at a specific range with new text
|
|
78
|
+
*/
|
|
79
|
+
export declare class ReplaceFixStrategy implements FixStrategy {
|
|
80
|
+
readonly type: FixType;
|
|
81
|
+
canHandle(violation: Violation): boolean;
|
|
82
|
+
getConfidence(context: FixContext): number;
|
|
83
|
+
generate(context: FixContext): QuickFix | null;
|
|
84
|
+
private truncateText;
|
|
85
|
+
private generatePreview;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Strategy for generating wrap fixes
|
|
89
|
+
* Wraps code with additional structure (e.g., try/catch, function wrapper)
|
|
90
|
+
*/
|
|
91
|
+
export declare class WrapFixStrategy implements FixStrategy {
|
|
92
|
+
readonly type: FixType;
|
|
93
|
+
canHandle(violation: Violation): boolean;
|
|
94
|
+
getConfidence(_context: FixContext): number;
|
|
95
|
+
generate(context: FixContext): QuickFix | null;
|
|
96
|
+
private extractCode;
|
|
97
|
+
private determineWrapType;
|
|
98
|
+
private wrapCode;
|
|
99
|
+
private detectIndent;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Strategy for generating extract fixes
|
|
103
|
+
* Extracts code into a new location (e.g., extract function, extract variable)
|
|
104
|
+
*/
|
|
105
|
+
export declare class ExtractFixStrategy implements FixStrategy {
|
|
106
|
+
readonly type: FixType;
|
|
107
|
+
canHandle(violation: Violation): boolean;
|
|
108
|
+
getConfidence(_context: FixContext): number;
|
|
109
|
+
generate(context: FixContext): QuickFix | null;
|
|
110
|
+
private extractCode;
|
|
111
|
+
private generateExtractedName;
|
|
112
|
+
private createExtraction;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Strategy for generating import fixes
|
|
116
|
+
* Adds import statements for missing dependencies
|
|
117
|
+
*/
|
|
118
|
+
export declare class ImportFixStrategy implements FixStrategy {
|
|
119
|
+
readonly type: FixType;
|
|
120
|
+
canHandle(violation: Violation): boolean;
|
|
121
|
+
getConfidence(_context: FixContext): number;
|
|
122
|
+
generate(context: FixContext): QuickFix | null;
|
|
123
|
+
private generateImportStatement;
|
|
124
|
+
private truncateText;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Strategy for generating rename fixes
|
|
128
|
+
* Renames symbols to match naming conventions
|
|
129
|
+
*/
|
|
130
|
+
export declare class RenameFixStrategy implements FixStrategy {
|
|
131
|
+
readonly type: FixType;
|
|
132
|
+
canHandle(violation: Violation): boolean;
|
|
133
|
+
getConfidence(_context: FixContext): number;
|
|
134
|
+
generate(context: FixContext): QuickFix | null;
|
|
135
|
+
private generateNewName;
|
|
136
|
+
private toCamelCase;
|
|
137
|
+
private toPascalCase;
|
|
138
|
+
private toSnakeCase;
|
|
139
|
+
private toKebabCase;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Strategy for generating move fixes
|
|
143
|
+
* Moves code to a different location (e.g., different file, different position)
|
|
144
|
+
*/
|
|
145
|
+
export declare class MoveFixStrategy implements FixStrategy {
|
|
146
|
+
readonly type: FixType;
|
|
147
|
+
canHandle(violation: Violation): boolean;
|
|
148
|
+
getConfidence(_context: FixContext): number;
|
|
149
|
+
generate(context: FixContext): QuickFix | null;
|
|
150
|
+
private extractCode;
|
|
151
|
+
private determineTargetLocation;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Strategy for generating delete fixes
|
|
155
|
+
* Deletes code that should be removed
|
|
156
|
+
*/
|
|
157
|
+
export declare class DeleteFixStrategy implements FixStrategy {
|
|
158
|
+
readonly type: FixType;
|
|
159
|
+
canHandle(violation: Violation): boolean;
|
|
160
|
+
getConfidence(_context: FixContext): number;
|
|
161
|
+
generate(context: FixContext): QuickFix | null;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* QuickFixGenerator class for generating code transformations for violations.
|
|
165
|
+
*
|
|
166
|
+
* The generator:
|
|
167
|
+
* - Takes violations and generates appropriate quick fixes
|
|
168
|
+
* - Supports multiple fix types: replace, wrap, extract, import, rename, move, delete
|
|
169
|
+
* - Ranks fixes by confidence and marks preferred fix
|
|
170
|
+
* - Provides preview of changes before applying
|
|
171
|
+
*
|
|
172
|
+
* @requirements 25.1 - Generate code transformations for fixable violations
|
|
173
|
+
* @requirements 25.3 - Support fix types: replace, wrap, extract, import, rename, move, delete
|
|
174
|
+
* @requirements 25.4 - Rank fixes by confidence
|
|
175
|
+
* @requirements 25.5 - Mark preferred fix for one-click application
|
|
176
|
+
*/
|
|
177
|
+
export declare class QuickFixGenerator {
|
|
178
|
+
private config;
|
|
179
|
+
private strategies;
|
|
180
|
+
private fixIdCounter;
|
|
181
|
+
/**
|
|
182
|
+
* Create a new QuickFixGenerator instance.
|
|
183
|
+
*
|
|
184
|
+
* @param config - Optional configuration options
|
|
185
|
+
*/
|
|
186
|
+
constructor(config?: QuickFixGeneratorConfig);
|
|
187
|
+
/**
|
|
188
|
+
* Generate quick fixes for a violation.
|
|
189
|
+
*
|
|
190
|
+
* @param violation - The violation to generate fixes for
|
|
191
|
+
* @param content - The file content
|
|
192
|
+
* @returns Fix generation result with ranked fixes
|
|
193
|
+
*
|
|
194
|
+
* @requirements 25.1 - Generate code transformations
|
|
195
|
+
* @requirements 25.4 - Rank by confidence
|
|
196
|
+
*/
|
|
197
|
+
generateFixes(violation: Violation, content: string): FixGenerationResult;
|
|
198
|
+
/**
|
|
199
|
+
* Generate quick fixes for multiple violations.
|
|
200
|
+
*
|
|
201
|
+
* @param violations - Array of violations
|
|
202
|
+
* @param content - The file content
|
|
203
|
+
* @returns Array of fix generation results
|
|
204
|
+
*/
|
|
205
|
+
generateFixesForAll(violations: Violation[], content: string): FixGenerationResult[];
|
|
206
|
+
/**
|
|
207
|
+
* Generate a specific type of fix for a violation.
|
|
208
|
+
*
|
|
209
|
+
* @param violation - The violation to fix
|
|
210
|
+
* @param content - The file content
|
|
211
|
+
* @param fixType - The type of fix to generate
|
|
212
|
+
* @returns The generated fix or null if not applicable
|
|
213
|
+
*/
|
|
214
|
+
generateFixOfType(violation: Violation, content: string, fixType: FixType): QuickFix | null;
|
|
215
|
+
/**
|
|
216
|
+
* Generate a preview of a fix before applying.
|
|
217
|
+
*
|
|
218
|
+
* @param fix - The quick fix to preview
|
|
219
|
+
* @param content - The original file content
|
|
220
|
+
* @returns Preview string showing the change
|
|
221
|
+
*
|
|
222
|
+
* @requirements 25.2 - Include preview of change before applying
|
|
223
|
+
*/
|
|
224
|
+
generatePreview(fix: QuickFix, content: string): string;
|
|
225
|
+
/**
|
|
226
|
+
* Apply a fix to content and return the result.
|
|
227
|
+
*
|
|
228
|
+
* This method is idempotent: applying the same fix twice will result in
|
|
229
|
+
* no additional changes after the first application.
|
|
230
|
+
*
|
|
231
|
+
* @param fix - The quick fix to apply
|
|
232
|
+
* @param content - The original file content
|
|
233
|
+
* @returns The modified content after applying the fix
|
|
234
|
+
*
|
|
235
|
+
* @requirements 25.1 - Generate code transformations for fixable violations
|
|
236
|
+
*/
|
|
237
|
+
applyFix(fix: QuickFix, content: string): string;
|
|
238
|
+
/**
|
|
239
|
+
* Extract text from a position for a given length.
|
|
240
|
+
* Used for idempotence checking.
|
|
241
|
+
*/
|
|
242
|
+
private extractTextFromPosition;
|
|
243
|
+
/**
|
|
244
|
+
* Check if a fix is idempotent (applying twice has no additional effect).
|
|
245
|
+
*
|
|
246
|
+
* A fix is idempotent if after applying it once, the content at the
|
|
247
|
+
* fix's range already matches the newText, so applying again has no effect.
|
|
248
|
+
*
|
|
249
|
+
* @param fix - The quick fix to check
|
|
250
|
+
* @param content - The original file content
|
|
251
|
+
* @returns True if the fix is idempotent
|
|
252
|
+
*/
|
|
253
|
+
isIdempotent(fix: QuickFix, content: string): boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Validate a fix before applying.
|
|
256
|
+
*
|
|
257
|
+
* @param fix - The quick fix to validate
|
|
258
|
+
* @param content - The file content
|
|
259
|
+
* @returns Validation result with any errors
|
|
260
|
+
*/
|
|
261
|
+
validateFix(fix: QuickFix, content: string): {
|
|
262
|
+
valid: boolean;
|
|
263
|
+
errors: string[];
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Get available fix types for a violation.
|
|
267
|
+
*
|
|
268
|
+
* @param violation - The violation to check
|
|
269
|
+
* @returns Array of fix types that can handle this violation
|
|
270
|
+
*/
|
|
271
|
+
getAvailableFixTypes(violation: Violation): FixType[];
|
|
272
|
+
/**
|
|
273
|
+
* Register a custom fix strategy.
|
|
274
|
+
*
|
|
275
|
+
* @param strategy - The fix strategy to register
|
|
276
|
+
*/
|
|
277
|
+
registerStrategy(strategy: FixStrategy): void;
|
|
278
|
+
/**
|
|
279
|
+
* Get all registered fix strategies.
|
|
280
|
+
*
|
|
281
|
+
* @returns Array of registered strategies
|
|
282
|
+
*/
|
|
283
|
+
getStrategies(): FixStrategy[];
|
|
284
|
+
/**
|
|
285
|
+
* Calculate the impact of a fix.
|
|
286
|
+
*
|
|
287
|
+
* @param fix - The quick fix to assess
|
|
288
|
+
* @param content - The file content
|
|
289
|
+
* @returns Impact assessment
|
|
290
|
+
*/
|
|
291
|
+
calculateImpact(fix: QuickFix, content: string): FixImpact;
|
|
292
|
+
/**
|
|
293
|
+
* Add metadata to a quick fix.
|
|
294
|
+
*/
|
|
295
|
+
private addMetadata;
|
|
296
|
+
/**
|
|
297
|
+
* Extract text from a range in content.
|
|
298
|
+
*/
|
|
299
|
+
private extractTextFromRange;
|
|
300
|
+
/**
|
|
301
|
+
* Apply a text edit to content.
|
|
302
|
+
*/
|
|
303
|
+
private applyTextEdit;
|
|
304
|
+
/**
|
|
305
|
+
* Check if a fix might be breaking.
|
|
306
|
+
*/
|
|
307
|
+
private mightBeBreaking;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Create a QuickFixGenerator with default configuration.
|
|
311
|
+
*
|
|
312
|
+
* @returns New QuickFixGenerator instance
|
|
313
|
+
*/
|
|
314
|
+
export declare function createQuickFixGenerator(): QuickFixGenerator;
|
|
315
|
+
/**
|
|
316
|
+
* Create a QuickFixGenerator with custom configuration.
|
|
317
|
+
*
|
|
318
|
+
* @param config - Configuration options
|
|
319
|
+
* @returns New QuickFixGenerator instance
|
|
320
|
+
*/
|
|
321
|
+
export declare function createQuickFixGeneratorWithConfig(config: QuickFixGeneratorConfig): QuickFixGenerator;
|
|
322
|
+
/**
|
|
323
|
+
* Create a QuickFixGenerator with high confidence threshold.
|
|
324
|
+
*
|
|
325
|
+
* @returns New QuickFixGenerator instance with high confidence threshold
|
|
326
|
+
*/
|
|
327
|
+
export declare function createHighConfidenceQuickFixGenerator(): QuickFixGenerator;
|
|
328
|
+
/**
|
|
329
|
+
* Create a QuickFixGenerator with all fixes enabled.
|
|
330
|
+
*
|
|
331
|
+
* @returns New QuickFixGenerator instance with all fixes
|
|
332
|
+
*/
|
|
333
|
+
export declare function createFullQuickFixGenerator(): QuickFixGenerator;
|
|
334
|
+
//# sourceMappingURL=quick-fix-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-fix-generator.d.ts","sourceRoot":"","sources":["../../src/rules/quick-fix-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,oBAAoB,EACpB,OAAO,EACP,SAAS,EAKV,MAAM,YAAY,CAAC;AAapB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,wDAAwD;IACxD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,iDAAiD;IACjD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,uBAAuB,CAKhF,CAAC;AAMF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,IAAI,EAAE,OAAO,CAAC;IAEd,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC;IAE/C,sDAAsD;IACtD,SAAS,CAAC,SAAS,EAAE,SAAS,GAA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