@abaplint/core
Version:
abaplint - Core API
84 lines • 3.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmptyEvent = exports.EmptyEventConf = void 0;
const issue_1 = require("../issue");
const _abap_rule_1 = require("./_abap_rule");
const _basic_rule_config_1 = require("./_basic_rule_config");
const Structures = require("../abap/3_structures/structures");
const _irule_1 = require("./_irule");
const objects_1 = require("../objects");
const selection_events_1 = require("../abap/flow/selection_events");
class EmptyEventConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.EmptyEventConf = EmptyEventConf;
class EmptyEvent extends _abap_rule_1.ABAPRule {
constructor() {
super(...arguments);
this.conf = new EmptyEventConf();
}
getMetadata() {
return {
key: "empty_event",
title: "Empty selection screen or list processing event block",
shortDescription: `Empty selection screen or list processing event block`,
extendedInformation: ``,
tags: [_irule_1.RuleTag.SingleFile],
badExample: `
INITIALIZATION.
WRITE 'hello'.
END-OF-SELECTION.`,
goodExample: `
START-OF-SELECTION.
PERFORM sdf.
COMMIT WORK.`,
};
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
runParsed(file, obj) {
const issues = [];
if (!(obj instanceof objects_1.Program) || obj.isInclude()) {
return issues;
}
const stru = file.getStructure();
if (stru === undefined) {
return [];
}
let currentEvent = undefined;
let children = [];
for (const s of stru.getChildren() || []) {
if (selection_events_1.SELECTION_EVENTS.some(f => s.get() instanceof f)) {
if (currentEvent !== undefined && children.length === 0) {
issues.push(issue_1.Issue.atStatement(file, currentEvent, "Empty event", this.getMetadata().key, this.getConfig().severity));
}
children = [];
currentEvent = s;
}
else if (s.get() instanceof Structures.Normal) {
const stru = s;
// ignore declaration stuff
if (selection_events_1.DECLARATION_STUFF.some(d => { var _a; return ((_a = stru.getFirstStatement()) === null || _a === void 0 ? void 0 : _a.get()) instanceof d; })) {
continue;
}
children.push(s);
}
else {
if (currentEvent !== undefined && children.length === 0) {
issues.push(issue_1.Issue.atStatement(file, currentEvent, "Empty event", this.getMetadata().key, this.getConfig().severity));
}
children = [];
currentEvent = undefined;
}
}
if (currentEvent !== undefined && children.length === 0) {
issues.push(issue_1.Issue.atStatement(file, currentEvent, "Empty event", this.getMetadata().key, this.getConfig().severity));
}
return issues;
}
}
exports.EmptyEvent = EmptyEvent;
//# sourceMappingURL=empty_event.js.map