UNPKG

@abaplint/core

Version:
111 lines 3.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Class = exports.ClassCategory = void 0; const _abap_object_1 = require("./_abap_object"); var ClassCategory; (function (ClassCategory) { ClassCategory["Test"] = "05"; ClassCategory["Persistent"] = "10"; ClassCategory["PersistentFactory"] = "11"; ClassCategory["Exception"] = "40"; ClassCategory["SharedObject"] = "45"; })(ClassCategory || (exports.ClassCategory = ClassCategory = {})); class Class extends _abap_object_1.ABAPObject { constructor() { super(...arguments); this.def = undefined; this.parsedXML = undefined; } getType() { return "CLAS"; } getSequencedFiles() { const sequence = [".clas.locals_def.abap", ".clas.locals_imp.abap", ".clas.abap", ".clas.testclasses.abap"]; const copy = this.getABAPFiles().slice().sort((a, b) => { const aValue = sequence.findIndex((s) => a.getFilename().endsWith(s)); const bValue = sequence.findIndex((s) => b.getFilename().endsWith(s)); return aValue - bValue; }); return copy; } setDefinition(def) { this.def = def; } getDefinition() { return this.def; } getAllowedNaming() { return { maxLength: 30, allowNamespace: true, }; } setDirty() { this.def = undefined; this.parsedXML = undefined; super.setDirty(); } getClassDefinition() { var _a; return (_a = this.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getInfo().getClassDefinitionByName(this.getName()); } getIdentifier() { var _a; return (_a = this.getClassDefinition()) === null || _a === void 0 ? void 0 : _a.identifier; } // ------------------- getDescription() { var _a; this.parseXML(); return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.description; } getNameFromXML() { var _a; this.parseXML(); return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.name; } getCategory() { var _a; this.parseXML(); // https://blog.mariusschulz.com/2017/10/27/typescript-2-4-string-enums#no-reverse-mapping-for-string-valued-enum-members return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.category; } getLocalsImpFile() { for (const file of this.getABAPFiles()) { if (file.getFilename().endsWith(".clas.locals_imp.abap")) { return file; } } return undefined; } getTestclassFile() { for (const file of this.getABAPFiles()) { if (file.getFilename().endsWith(".clas.testclasses.abap")) { return file; } } return undefined; } ///////////////////////// parseXML() { if (this.parsedXML !== undefined) { return; } this.parsedXML = {}; const parsed = super.parseRaw2(); if (parsed === undefined || parsed.abapGit["asx:abap"] === undefined || parsed.abapGit["asx:abap"]["asx:values"] === undefined) { return; } const vseo = parsed.abapGit["asx:abap"]["asx:values"].VSEOCLASS; if (vseo === undefined) { return; } this.parsedXML.category = vseo.CATEGORY; this.parsedXML.description = vseo.DESCRIPT ? vseo.DESCRIPT : ""; this.parsedXML.name = vseo.CLSNAME ? vseo.CLSNAME : ""; } } exports.Class = Class; //# sourceMappingURL=class.js.map