refakts
Version:
TypeScript refactoring tool built for AI coding agents to perform precise refactoring operations via command line instead of requiring complete code regeneration.
37 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SelectionService = void 0;
class SelectionService {
constructor(astService, contextAnalyzer, rangeAnalyzer, boundaryAnalyzer, structuralAnalyzer, regexMatcher) {
this.astService = astService;
this.contextAnalyzer = contextAnalyzer;
this.rangeAnalyzer = rangeAnalyzer;
this.boundaryAnalyzer = boundaryAnalyzer;
this.structuralAnalyzer = structuralAnalyzer;
this.regexMatcher = regexMatcher;
}
async findSelections(sourceFile, options) {
const selectionType = this.determineSelectionType(options);
return this.executeSelection(sourceFile, options, selectionType);
}
determineSelectionType(options) {
if (options.range)
return 'range';
if (options.structural)
return 'structural';
if (options.boundaries)
return 'boundaries';
return 'regex';
}
executeSelection(sourceFile, options, type) {
const handlers = {
range: () => this.rangeAnalyzer.findRangeMatches(sourceFile, options),
structural: () => this.structuralAnalyzer.findStructuralMatches(sourceFile, options),
boundaries: () => this.boundaryAnalyzer.findBoundaryMatches(sourceFile, options),
regex: () => this.regexMatcher.findRegexMatches(sourceFile, options)
};
return Promise.resolve(handlers[type]());
}
}
exports.SelectionService = SelectionService;
//# sourceMappingURL=selection-service.js.map