UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

23 lines (22 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tree_1 = require("./../tree"); var getNewReplacementSourceFile_1 = require("./../getNewReplacementSourceFile"); function insertIntoParent(opts) { var insertPos = opts.insertPos, newText = opts.newText, parent = opts.parent, childIndex = opts.childIndex, insertItemsCount = opts.insertItemsCount, customMappings = opts.customMappings; var tempSourceFile = getNewReplacementSourceFile_1.getNewReplacementSourceFile({ sourceFile: parent.getSourceFile(), insertPos: insertPos, newText: newText, replacingLength: opts.replacing == null ? undefined : opts.replacing.textLength }); tree_1.replaceTreeWithChildIndex({ parent: parent, childCount: insertItemsCount, childIndex: childIndex, replacementSourceFile: tempSourceFile, replacingNodes: opts.replacing == null ? undefined : opts.replacing.nodes, customMappings: customMappings }); } exports.insertIntoParent = insertIntoParent;