refakts
Version:
TypeScript refactoring tool built for AI coding agents to perform precise refactoring operations via command line instead of requiring complete code regeneration.
38 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextAnalyzer = void 0;
const ts_morph_1 = require("ts-morph");
class ContextAnalyzer {
isInDestructuringPattern(node) {
let parent = node.getParent();
while (parent) {
if (this.isDestructuringContext(parent)) {
return true;
}
parent = parent.getParent();
}
return false;
}
isInTypeContext(node) {
let parent = node.getParent();
while (parent) {
if (this.isTypeContext(parent)) {
return true;
}
parent = parent.getParent();
}
return false;
}
isDestructuringContext(node) {
return node.getKind() === ts_morph_1.SyntaxKind.ObjectBindingPattern ||
node.getKind() === ts_morph_1.SyntaxKind.ArrayBindingPattern ||
node.getKind() === ts_morph_1.SyntaxKind.BindingElement;
}
isTypeContext(node) {
return node.getKind() === ts_morph_1.SyntaxKind.TypeLiteral ||
node.getKind() === ts_morph_1.SyntaxKind.PropertySignature ||
node.getKind() === ts_morph_1.SyntaxKind.TypeReference;
}
}
exports.ContextAnalyzer = ContextAnalyzer;
//# sourceMappingURL=context-analyzer.js.map