UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

17 lines (15 loc) 754 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tree_1 = require("./../tree"); /** * Replaces the text in a source file and assumes only the nodes will shift (no tree structure should change). * * This is very useful when making formatting changes that won't change the AST structure. */ function replaceSourceFileTextForFormatting(opts) { const { sourceFile, newText } = opts; const tempSourceFile = sourceFile.global.compilerFactory.createTempSourceFileFromText(newText, sourceFile.getFilePath()); tree_1.replaceTreeStraight(sourceFile, tempSourceFile); } exports.replaceSourceFileTextForFormatting = replaceSourceFileTextForFormatting; //# sourceMappingURL=replaceSourceFileTextForFormatting.js.map