UNPKG

@abaplint/core

Version:
75 lines 2.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CheckDDIC = exports.CheckDDICConf = void 0; const _irule_1 = require("./_irule"); const issue_1 = require("../issue"); const Objects = require("../objects"); const _basic_rule_config_1 = require("./_basic_rule_config"); const position_1 = require("../position"); const basic_1 = require("../abap/types/basic"); const _typed_identifier_1 = require("../abap/types/_typed_identifier"); class CheckDDICConf extends _basic_rule_config_1.BasicRuleConfig { } exports.CheckDDICConf = CheckDDICConf; class CheckDDIC { constructor() { this.conf = new CheckDDICConf(); } getMetadata() { return { key: "check_ddic", title: "Check DDIC", // eslint-disable-next-line max-len shortDescription: `Checks the types of DDIC objects can be resolved, the namespace of the development/errors can be configured in "errorNamespace" `, tags: [_irule_1.RuleTag.Syntax], }; } initialize(reg) { this.reg = reg; return this; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } run(obj) { let found = undefined; if (obj instanceof Objects.DataElement || obj instanceof Objects.Domain || obj instanceof Objects.Table || obj instanceof Objects.View || obj instanceof Objects.AuthorizationCheckField || obj instanceof Objects.LockObject || obj instanceof Objects.MaintenanceAndTransportObject || obj instanceof Objects.TableType) { found = obj.parseType(this.reg); } else { return []; } return this.check(found, obj); } check(found, obj) { const ret = []; if (found instanceof basic_1.UnknownType) { const position = new position_1.Position(1, 1); const message = "Unknown/un-resolveable type in " + obj.getName() + ": " + found.getError(); ret.push(issue_1.Issue.atPosition(obj.getFiles()[0], position, message, this.getMetadata().key, this.conf.severity)); } else if (found instanceof basic_1.StructureType) { // assumption: no circular types for (const c of found.getComponents()) { ret.push(...this.check(c.type instanceof _typed_identifier_1.TypedIdentifier ? c.type.getType() : c.type, obj)); } } else if (found instanceof basic_1.TableType) { ret.push(...this.check(found.getRowType(), obj)); } // todo, reference types? return ret; } } exports.CheckDDIC = CheckDDIC; //# sourceMappingURL=check_ddic.js.map