ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
19 lines (18 loc) • 815 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/* barrel:ignore */
var errors = require("./../../errors");
function doManipulation(sourceFile, textManipulator, nodeHandler) {
var newFileText = textManipulator.getNewText(sourceFile.getFullText());
try {
var replacementSourceFile = sourceFile.global.compilerFactory.createTempSourceFileFromText(newFileText, { filePath: sourceFile.getFilePath() });
nodeHandler.handleNode(sourceFile, replacementSourceFile);
}
catch (err) {
throw new errors.InvalidOperationError(err.message + "\n" +
"-- Details --\n" +
("Path: " + sourceFile.getFilePath() + "\n") +
("Text: " + textManipulator.getTextForError(newFileText)));
}
}
exports.doManipulation = doManipulation;