@abaplint/core
Version:
abaplint - Core API
75 lines • 2.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SuperclassFinal = exports.SuperclassFinalConf = void 0;
const issue_1 = require("../issue");
const _abap_rule_1 = require("./_abap_rule");
const Objects = require("../objects");
const _basic_rule_config_1 = require("./_basic_rule_config");
const _irule_1 = require("./_irule");
class SuperclassFinalConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.SuperclassFinalConf = SuperclassFinalConf;
class SuperclassFinal extends _abap_rule_1.ABAPRule {
constructor() {
super(...arguments);
this.conf = new SuperclassFinalConf();
}
getMetadata() {
return {
key: "superclass_final",
title: "Super class final",
shortDescription: `Checks that classes which are inherited from are not declared as FINAL.`,
tags: [_irule_1.RuleTag.Syntax],
};
}
getMessage() {
return "Superclasses cannot be FINAL";
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
runParsed(file, obj) {
const output = [];
for (const definition of file.getInfo().listClassDefinitions()) {
const sup = definition.superClassName;
if (sup === undefined) {
continue;
}
let localLookup = true;
if (obj instanceof Objects.Class && file.getFilename().match(/\.clas\.abap$/)) {
localLookup = false;
}
let found = undefined;
if (localLookup) {
for (const f of obj.getABAPFiles()) {
found = f.getInfo().getClassDefinitionByName(sup);
if (found !== undefined) {
break;
}
}
}
if (found === undefined) {
const clas = this.reg.getObject("CLAS", sup);
if (clas) {
found = clas.getClassDefinition();
}
}
if (found === undefined) {
const message = "Super class \"" + sup + "\" not found";
const issue = issue_1.Issue.atIdentifier(definition.identifier, message, this.getMetadata().key, this.conf.severity);
output.push(issue);
continue;
}
if (found.isFinal === true) {
const issue = issue_1.Issue.atIdentifier(definition.identifier, this.getMessage(), this.getMetadata().key, this.conf.severity);
output.push(issue);
}
}
return output;
}
}
exports.SuperclassFinal = SuperclassFinal;
//# sourceMappingURL=superclass_final.js.map