@abaplint/core
Version:
abaplint - Core API
54 lines • 1.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TryWithoutCatch = exports.TryWithoutCatchConf = void 0;
const issue_1 = require("../issue");
const _abap_rule_1 = require("./_abap_rule");
const structures_1 = require("../abap/3_structures/structures");
const _basic_rule_config_1 = require("./_basic_rule_config");
const _irule_1 = require("./_irule");
class TryWithoutCatchConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.TryWithoutCatchConf = TryWithoutCatchConf;
class TryWithoutCatch extends _abap_rule_1.ABAPRule {
constructor() {
super(...arguments);
this.conf = new TryWithoutCatchConf();
}
getMetadata() {
return {
key: "try_without_catch",
title: "TRY without CATCH",
shortDescription: `Checks for TRY blocks without a CATCH and CLEANUP block`,
badExample: `TRY.\n WRITE 'hello world'.\nENDTRY.`,
tags: [_irule_1.RuleTag.SingleFile],
};
}
getMessage() {
return "A TRY block must have a corresponding CATCH or CLEANUP block.";
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
runParsed(file) {
const issues = [];
const stru = file.getStructure();
if (stru === undefined) {
return [];
}
const tries = stru.findAllStructures(structures_1.Try);
for (const t of tries) {
const clean = t.findDirectStructures(structures_1.Cleanup);
const c = t.findDirectStructures(structures_1.Catch);
if (c.length === 0 && clean.length === 0) {
const issue = issue_1.Issue.atToken(file, t.getFirstToken(), this.getMessage(), this.getMetadata().key, this.conf.severity);
issues.push(issue);
}
}
return issues;
}
}
exports.TryWithoutCatch = TryWithoutCatch;
//# sourceMappingURL=try_without_catch.js.map