ts-simple-ast
Version:
TypeScript compiler wrapper for static analysis and code manipulation.
33 lines (32 loc) • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var codeBlockWriter_1 = require("../codeBlockWriter");
var StructurePrinter = /** @class */ (function () {
function StructurePrinter() {
}
// todo: this should not be a method on the base
StructurePrinter.prototype.printTextOrWriterFunc = function (writer, textOrWriterFunc) {
if (typeof textOrWriterFunc === "string")
writer.write(textOrWriterFunc);
else if (textOrWriterFunc != null)
textOrWriterFunc(writer);
};
StructurePrinter.prototype.getNewWriter = function (writer) {
return new codeBlockWriter_1.CodeBlockWriter(writer.getOptions());
};
StructurePrinter.prototype.getNewWriterWithQueuedChildIndentation = function (writer) {
var newWriter = new codeBlockWriter_1.CodeBlockWriter(writer.getOptions());
newWriter.queueIndentationLevel(1);
return newWriter;
};
StructurePrinter.prototype.getTextWithQueuedChildIndentation = function (writer, textOrWriterFunc) {
var queuedChildIndentationWriter = this.getNewWriterWithQueuedChildIndentation(writer);
if (typeof textOrWriterFunc === "string")
queuedChildIndentationWriter.write(textOrWriterFunc);
else
textOrWriterFunc(queuedChildIndentationWriter);
return queuedChildIndentationWriter.toString();
};
return StructurePrinter;
}());
exports.StructurePrinter = StructurePrinter;