UNPKG

@abaplint/transpiler

Version:
108 lines 5.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Transpiler = exports.UnknownTypesEnum = exports.config = void 0; const abaplint = require("@abaplint/core"); const validation_1 = require("./validation"); Object.defineProperty(exports, "config", { enumerable: true, get: function () { return validation_1.config; } }); const unit_test_1 = require("./unit_test"); const types_1 = require("./types"); Object.defineProperty(exports, "UnknownTypesEnum", { enumerable: true, get: function () { return types_1.UnknownTypesEnum; } }); const db_1 = require("./db"); const handle_table_1 = require("./handlers/handle_table"); const handle_abap_1 = require("./handlers/handle_abap"); const handle_data_element_1 = require("./handlers/handle_data_element"); const handle_table_type_1 = require("./handlers/handle_table_type"); const handle_view_1 = require("./handlers/handle_view"); const handle_enqu_1 = require("./handlers/handle_enqu"); const handle_type_pool_1 = require("./handlers/handle_type_pool"); const handle_w3mi_1 = require("./handlers/handle_w3mi"); const handle_smim_1 = require("./handlers/handle_smim"); const handle_msag_1 = require("./handlers/handle_msag"); const handle_oa2p_1 = require("./handlers/handle_oa2p"); const handle_fugr_1 = require("./handlers/handle_fugr"); const initialization_1 = require("./initialization"); class Transpiler { constructor(options) { this.options = options; if (this.options === undefined) { this.options = {}; } if (this.options.unknownTypes === undefined) { this.options.unknownTypes = types_1.UnknownTypesEnum.compileError; } } // workaround for web/webpack async runRaw(files) { const memory = files.map(f => new abaplint.MemoryFile(f.filename, f.contents)); const reg = new abaplint.Registry().addFiles(memory).parse(); return new Transpiler().run(reg); } async run(reg, progress) { reg.parse(); this.validate(reg); const dbSetup = new db_1.DatabaseSetup(reg).run(this.options); const output = { objects: [], unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, this.options?.skip), unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, this.options?.skip), initializationScript: new initialization_1.Initialization().script(reg, dbSetup, this.options?.extraSetup), initializationScript2: new initialization_1.Initialization().script(reg, dbSetup, this.options?.extraSetup, true), databaseSetup: dbSetup, reg: reg, }; progress?.set(reg.getObjectCount(false), "Building"); for (const obj of reg.getObjects()) { await progress?.tick("Building, " + obj.getName()); if (obj instanceof abaplint.Objects.TypePool) { output.objects.push(...new handle_type_pool_1.HandleTypePool().runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.FunctionGroup) { output.objects.push(...new handle_fugr_1.HandleFUGR(this.options).runObject(obj, reg)); } else if (obj instanceof abaplint.ABAPObject) { output.objects.push(...new handle_abap_1.HandleABAP(this.options).runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.Oauth2Profile) { output.objects.push(...new handle_oa2p_1.HandleOA2P().runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.Table) { output.objects.push(...new handle_table_1.HandleTable().runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.View) { output.objects.push(...new handle_view_1.HandleView().runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.LockObject) { output.objects.push(...new handle_enqu_1.HandleEnqu().runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.DataElement) { output.objects.push(...new handle_data_element_1.HandleDataElement().runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.TableType) { output.objects.push(...new handle_table_type_1.HandleTableType().runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.MIMEObject) { output.objects.push(...new handle_smim_1.HandleSMIM().runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.WebMIME) { output.objects.push(...new handle_w3mi_1.HandleW3MI().runObject(obj, reg)); } else if (obj instanceof abaplint.Objects.MessageClass) { output.objects.push(...new handle_msag_1.HandleMSAG().runObject(obj, reg)); } } return output; } // /////////////////////////////// validate(reg) { const issues = new validation_1.Validation(this.options).run(reg); if (issues.length > 0) { const messages = issues.map(i => i.getKey() + ", " + i.getMessage() + ", " + i.getFilename() + ":" + i.getStart().getRow()); throw new Error(messages.join("\n")); } } } exports.Transpiler = Transpiler; //# sourceMappingURL=index.js.map