UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

85 lines (84 loc) 2.88 kB
"use strict"; var __assign = (this && this.__assign)/* istanbul ignore next */ || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); var objectAssign = require("object-assign"); var typescript_1 = require("./typescript"); var compiler_1 = require("./compiler"); var utils_1 = require("./utils"); /** Kinds of indentation */ var IndentationText; (function (IndentationText) { /** Two spaces */ IndentationText["TwoSpaces"] = " "; /** Four spaces */ IndentationText["FourSpaces"] = " "; /** Eight spaces */ IndentationText["EightSpaces"] = " "; /** Tab */ IndentationText["Tab"] = "\t"; })(/* istanbul ignore next */IndentationText = exports.IndentationText || (exports.IndentationText = {})); /** * Holds the manipulation settings. */ var ManipulationSettingsContainer = /** @class */ (function () { function ManipulationSettingsContainer() { this.settings = { indentationText: IndentationText.FourSpaces, newLineKind: typescript_1.NewLineKind.LineFeed, scriptTarget: typescript_1.ScriptTarget.Latest, quoteType: compiler_1.QuoteType.Double }; } /** * Gets the quote type used for string literals. */ ManipulationSettingsContainer.prototype.getQuoteType = function () { return this.settings.quoteType; }; /** * Gets the new line kind. */ ManipulationSettingsContainer.prototype.getNewLineKind = function () { return this.settings.newLineKind; }; /** * Gets the new line kind as a string. */ ManipulationSettingsContainer.prototype.getNewLineKindAsString = function () { return utils_1.newLineKindToString(this.getNewLineKind()); }; /** * Gets the indentation text; */ ManipulationSettingsContainer.prototype.getIndentationText = function () { return this.settings.indentationText; }; /** * Gets the script target. */ ManipulationSettingsContainer.prototype.getScriptTarget = function () { return this.settings.scriptTarget; }; /** * Gets a copy of the manipulations settings as an object. */ ManipulationSettingsContainer.prototype.get = function () { return __assign({}, this.settings); }; /** * Sets one or all of the settings. * @param settings - Settings to set. */ ManipulationSettingsContainer.prototype.set = function (settings) { objectAssign(this.settings, settings); }; return ManipulationSettingsContainer; }()); exports.ManipulationSettingsContainer = ManipulationSettingsContainer;