@abaplint/core
Version:
abaplint - Core API
74 lines (73 loc) • 3.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParserError = exports.ParserErrorConf = void 0;
const issue_1 = require("../issue");
const _statement_1 = require("../abap/2_statements/statements/_statement");
const _basic_rule_config_1 = require("./_basic_rule_config");
const statement_parser_1 = require("../abap/2_statements/statement_parser");
const _irule_1 = require("./_irule");
const version_1 = require("../version");
const _abap_object_1 = require("../objects/_abap_object");
class ParserErrorConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.ParserErrorConf = ParserErrorConf;
class ParserError {
constructor() {
this.conf = new ParserErrorConf();
}
getMetadata() {
return {
key: "parser_error",
title: "Parser error",
shortDescription: `Checks for syntax not recognized by abaplint.
See recognized syntax at https://syntax.abaplint.org`,
tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.SingleFile],
};
}
initialize(reg) {
this.reg = reg;
return this;
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
run(obj) {
const issues = [];
issues.push(...obj.getParsingIssues());
if (obj instanceof _abap_object_1.ABAPObject) {
for (const file of obj.getABAPFiles()) {
for (const statement of file.getStatements()) {
if (!(statement.get() instanceof _statement_1.Unknown)) {
continue;
}
if (statement.getTokens().length > statement_parser_1.STATEMENT_MAX_TOKENS) {
const message = "Statement too long, refactor statement";
const issue = issue_1.Issue.atToken(file, statement.getTokens()[0], message, this.getMetadata().key, this.conf.severity);
issues.push(issue);
}
else {
const tok = statement.getFirstToken();
const message = "Statement does not exist in ABAP" + this.reg.getConfig().getVersion() + "(or a parser error), \"" + tok.getStr() + "\"";
const issue = issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity);
issues.push(issue);
}
}
if (this.reg.getConfig().getVersion() === version_1.Version.v700) {
for (const statement of file.getStatements()) {
if (statement.getPragmas().length > 0) {
const message = "Pragmas not allowed in v700";
const issue = issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity);
issues.push(issue);
}
}
}
}
}
return issues;
}
}
exports.ParserError = ParserError;
//# sourceMappingURL=parser_error.js.map