UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

24 lines (22 loc) 909 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tree_1 = require("./../tree"); const getNewReplacementSourceFile_1 = require("./getNewReplacementSourceFile"); function insertIntoParent(opts) { const { insertPos, newText, parent, childIndex, insertItemsCount } = opts; const tempSourceFile = getNewReplacementSourceFile_1.getNewReplacementSourceFile({ sourceFile: parent.getSourceFile(), insertPos, newText, replacingLength: opts.replacing == null ? undefined : opts.replacing.length }); tree_1.replaceTreeWithChildIndex({ parent, childCount: insertItemsCount, childIndex, replacementSourceFile: tempSourceFile, replacingNodes: opts.replacing == null ? undefined : opts.replacing.nodes }); } exports.insertIntoParent = insertIntoParent; //# sourceMappingURL=insertIntoParent.js.map