UNPKG

@abaplint/core

Version:
75 lines 3.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MethodImplementedTwice = exports.MethodImplementedTwiceConf = void 0; const _abap_rule_1 = require("./_abap_rule"); const _basic_rule_config_1 = require("./_basic_rule_config"); const issue_1 = require("../issue"); const _irule_1 = require("./_irule"); class MethodImplementedTwiceConf extends _basic_rule_config_1.BasicRuleConfig { } exports.MethodImplementedTwiceConf = MethodImplementedTwiceConf; class MethodImplementedTwice extends _abap_rule_1.ABAPRule { constructor() { super(...arguments); this.conf = new MethodImplementedTwiceConf(); } getMetadata() { return { key: "method_implemented_twice", title: "Method implemented twice", shortDescription: `Reports an error if a method is implemented or defined twice`, tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Syntax], }; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } runParsed(file) { const issues = []; for (const classDef of file.getInfo().listClassImplementations()) { const names = {}; for (const m of classDef.methods) { const name = m.getName().toUpperCase(); if (names[name] === undefined) { names[name] = true; } else { const message = `Method ${name} implemented twice`; issues.push(issue_1.Issue.atToken(file, m.getToken(), message, this.getMetadata().key, this.getConfig().severity)); } } } for (const classDef of file.getInfo().listClassDefinitions()) { const names = {}; for (const m of classDef.methods) { const name = m.name.toUpperCase(); if (names[name] === undefined) { names[name] = true; } else { const message = `Method ${name} defined twice`; issues.push(issue_1.Issue.atToken(file, m.identifier.getToken(), message, this.getMetadata().key, this.getConfig().severity)); } } } for (const iDef of file.getInfo().listInterfaceDefinitions()) { const names = {}; for (const m of iDef.methods) { const name = m.name.toUpperCase(); if (names[name] === undefined) { names[name] = true; } else { const message = `Method ${name} implemented twice`; issues.push(issue_1.Issue.atIdentifier(m.identifier, message, this.getMetadata().key, this.getConfig().severity)); } } } return issues; } } exports.MethodImplementedTwice = MethodImplementedTwice; //# sourceMappingURL=method_implemented_twice.js.map