UNPKG

@abaplint/core

Version:
40 lines 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PrettyPrinter = void 0; const _statement_1 = require("../abap/2_statements/statements/_statement"); const fix_keyword_case_1 = require("./fix_keyword_case"); const indent_1 = require("./indent"); const virtual_position_1 = require("../virtual_position"); const indentation_1 = require("../rules/indentation"); class PrettyPrinter { constructor(file, config) { this.result = file.getRaw(); this.file = file; this.config = config; const indentationConf = config.readByRule(new indentation_1.Indentation().getMetadata().key); this.options = { alignTryCatch: indentationConf === null || indentationConf === void 0 ? void 0 : indentationConf.alignTryCatch, globalClassSkipFirst: indentationConf === null || indentationConf === void 0 ? void 0 : indentationConf.globalClassSkipFirst, }; } run() { const statements = this.file.getStatements(); for (const statement of statements) { if (statement.get() instanceof _statement_1.Unknown || statement.get() instanceof _statement_1.MacroContent || statement.get() instanceof _statement_1.MacroCall || statement.getFirstToken().getStart() instanceof virtual_position_1.VirtualPosition || statement.get() instanceof _statement_1.Comment) { continue; } // note that no positions are changed when case is changed const fixCase = new fix_keyword_case_1.FixCase(this.result, this.config); this.result = fixCase.execute(statement); } const indentation = new indent_1.Indent(this.options); this.result = indentation.execute(this.file, this.result); return this.result; } } exports.PrettyPrinter = PrettyPrinter; //# sourceMappingURL=pretty_printer.js.map