UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

26 lines (25 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var code_block_writer_1 = require("code-block-writer"); var compiler_1 = require("./../compiler"); var ManipulationSettings_1 = require("./../ManipulationSettings"); // todo: remove this function function getTextFromStringOrWriter(manipulationSettings, textOrWriterFunction) { if (typeof textOrWriterFunction === "string") return textOrWriterFunction; var writer = getCodeBlockWriter(manipulationSettings); textOrWriterFunction(writer); return writer.toString(); } exports.getTextFromStringOrWriter = getTextFromStringOrWriter; // todo: remove this function function getCodeBlockWriter(manipulationSettings) { var indentationText = manipulationSettings.getIndentationText(); return new code_block_writer_1.default({ newLine: manipulationSettings.getNewLineKind(), indentNumberOfSpaces: indentationText === ManipulationSettings_1.IndentationText.Tab ? undefined : indentationText.length, useTabs: indentationText === ManipulationSettings_1.IndentationText.Tab, useSingleQuote: manipulationSettings.getQuoteType() === compiler_1.QuoteType.Single }); } exports.getCodeBlockWriter = getCodeBlockWriter;