UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

17 lines (16 loc) 923 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var nodeHandlers_1 = require("./nodeHandlers"); function replaceTreeUnwrappingNode(opts) { var changingParent = opts.parent, childIndex = opts.childIndex, replacementSourceFile = opts.replacementSourceFile; var sourceFile = changingParent.getSourceFile(); var compilerFactory = sourceFile.global.compilerFactory; var unwrapParentHandler = new nodeHandlers_1.UnwrapParentHandler(compilerFactory, childIndex); if (changingParent === sourceFile) unwrapParentHandler.handleNode(sourceFile, replacementSourceFile); else { var parentFinderReplacement = new nodeHandlers_1.ParentFinderReplacementNodeHandler(compilerFactory, unwrapParentHandler, changingParent); parentFinderReplacement.handleNode(sourceFile, replacementSourceFile); } } exports.replaceTreeUnwrappingNode = replaceTreeUnwrappingNode;