@abaplint/core
Version:
abaplint - Core API
55 lines • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParserBadExceptions = exports.ParserBadExceptionsConf = void 0;
const Statements = require("../abap/2_statements/statements");
const Expressions = require("../abap/2_statements/expressions");
const issue_1 = require("../issue");
const _abap_rule_1 = require("./_abap_rule");
const _basic_rule_config_1 = require("./_basic_rule_config");
const _irule_1 = require("./_irule");
// todo: this rule needs refactoring
class ParserBadExceptionsConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.ParserBadExceptionsConf = ParserBadExceptionsConf;
class ParserBadExceptions extends _abap_rule_1.ABAPRule {
constructor() {
super(...arguments);
this.conf = new ParserBadExceptionsConf();
}
getMetadata() {
return {
key: "parser_bad_exceptions",
title: "Parser Error, bad EXCEPTIONS in CALL FUNCTION",
shortDescription: `Checks for syntax not recognized by abaplint, related to EXCEPTIONS in CALL FUNCTION.`,
tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.SingleFile],
/*
badExample: `IF ( foo = 'bar').`,
goodExample: `IF ( foo = 'bar' ).`,
*/
};
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
runParsed(file) {
var _a;
const issues = [];
for (const statement of file.getStatements()) {
if (!(statement.get() instanceof Statements.CallFunction)) {
continue;
}
const found = (_a = statement.findDirectExpression(Expressions.FunctionParameters)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Field);
if (found === undefined) {
continue;
}
const message = "Bad EXCEPTIONS syntax in CALL FUNCTION";
issues.push(issue_1.Issue.atToken(file, found.getFirstToken(), message, this.getMetadata().key, this.conf.severity));
}
return issues;
}
}
exports.ParserBadExceptions = ParserBadExceptions;
//# sourceMappingURL=parser_bad_exceptions.js.map