UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

17 lines (15 loc) 786 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /* istanbul ignore next */ function getInsertErrorMessageText(preText, currentNode, newNode) { let text = `${preText} Perhaps a syntax error was inserted (Current: ${currentNode.getKindName()} -- New: ${newNode.getKindName()}).\n\nCode:\n`; const sourceFileText = newNode.getSourceFile().getFullText(); const startPos = sourceFileText.lastIndexOf("\n", newNode.getPos()) + 1; let endPos = sourceFileText.indexOf("\n", newNode.getEnd()); if (endPos === -1) endPos = sourceFileText.length; text += sourceFileText.substring(startPos, endPos); return text; } exports.getInsertErrorMessageText = getInsertErrorMessageText; //# sourceMappingURL=getInsertErrorMessageText.js.map