UNPKG

@abaplint/core

Version:
105 lines 3.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SICFConsistency = exports.SICFConsistencyConf = void 0; const issue_1 = require("../issue"); const _basic_rule_config_1 = require("./_basic_rule_config"); const objects_1 = require("../objects"); const position_1 = require("../position"); class SICFConsistencyConf extends _basic_rule_config_1.BasicRuleConfig { constructor() { super(...arguments); /** skip specific names, case insensitive * @uniqueItems true */ this.skipNames = []; } } exports.SICFConsistencyConf = SICFConsistencyConf; class SICFConsistency { constructor() { this.conf = new SICFConsistencyConf(); } getMetadata() { return { key: "sicf_consistency", title: "SICF consistency", shortDescription: `Checks the validity of ICF services`, extendedInformation: `* Class defined in handler must exist * Class must not have any syntax errors * Class must implement interface IF_HTTP_EXTENSION`, }; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; if (this.conf.skipNames === undefined) { this.conf.skipNames = []; } } initialize(reg) { this.reg = reg; return this; } run(obj) { const issues = []; if (!(obj instanceof objects_1.ICFService)) { return []; } const handlers = obj.getHandlerList(); if (handlers === undefined) { return []; } for (const h of handlers) { const clas = this.reg.getObject("CLAS", h); if (clas === undefined) { if (this.conf.skipNames && this.conf.skipNames.some((a) => a.toUpperCase() === h.toUpperCase())) { continue; } const pattern = new RegExp(this.reg.getConfig().getSyntaxSetttings().errorNamespace, "i"); if (pattern.test(h) === true) { const message = "Handler class " + h + " not found"; const issue = issue_1.Issue.atPosition(obj.getFiles()[0], new position_1.Position(1, 1), message, this.getMetadata().key, this.conf.severity); issues.push(issue); } continue; } const def = clas.getClassDefinition(); if (def === undefined) { const message = "Syntax error in class " + h; const issue = issue_1.Issue.atPosition(obj.getFiles()[0], new position_1.Position(1, 1), message, this.getMetadata().key, this.conf.severity); issues.push(issue); continue; } const implementing = this.findImplementing(def); if (implementing.findIndex((i) => { return i.name.toUpperCase() === "IF_HTTP_EXTENSION"; }) < 0) { const message = "Handler class " + h + " must implement IF_HTTP_EXTENSION"; const issue = issue_1.Issue.atPosition(obj.getFiles()[0], new position_1.Position(1, 1), message, this.getMetadata().key, this.conf.severity); issues.push(issue); continue; } } return issues; } /////////////////////////// findImplementing(def) { let ret = def.interfaces; let superName = def.superClassName; while (superName !== undefined) { const clas = this.reg.getObject("CLAS", superName); if (clas === undefined) { break; } const superDef = clas.getClassDefinition(); if (superDef === undefined) { break; } ret = ret.concat(superDef.interfaces); superName = superDef.superClassName; } return ret; } } exports.SICFConsistency = SICFConsistency; //# sourceMappingURL=sicf_consistency.js.map