UNPKG

@abaplint/core

Version:
64 lines 2.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InlineDataOldVersions = exports.InlineDataOldVersionsConf = void 0; const issue_1 = require("../issue"); const _abap_rule_1 = require("./_abap_rule"); const version_1 = require("../version"); const expressions_1 = require("../abap/2_statements/expressions"); const _basic_rule_config_1 = require("./_basic_rule_config"); const _irule_1 = require("./_irule"); class InlineDataOldVersionsConf extends _basic_rule_config_1.BasicRuleConfig { } exports.InlineDataOldVersionsConf = InlineDataOldVersionsConf; class InlineDataOldVersions extends _abap_rule_1.ABAPRule { constructor() { super(...arguments); this.conf = new InlineDataOldVersionsConf(); } getMetadata() { return { key: "inline_data_old_versions", title: "Inline data, old versions", shortDescription: `Checks for inline data declarations in older releases. Only active for versions less than v740sp02`, tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.SingleFile], }; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } runParsed(file) { const issues = []; if (this.reg.getConfig().getVersion() >= version_1.Version.v740sp02 || this.reg.getConfig().getVersion() === version_1.Version.OpenABAP || this.reg.getConfig().getVersion() === version_1.Version.Cloud) { return []; } for (const statement of file.getStatements()) { // when parsed in old versions these expressions are NOT InlineData for (const target of statement.findAllExpressions(expressions_1.Target)) { const tokens = target.getAllTokens(); if (tokens.length !== 4) { continue; } if (!tokens[0].getStr().match(/DATA/i)) { continue; } if (tokens[1].getStr() !== "(") { continue; } if (tokens[3].getStr() !== ")") { continue; } const message = "Inline DATA not possible in " + this.reg.getConfig().getVersion(); const issue = issue_1.Issue.atToken(file, tokens[0], message, this.getMetadata().key, this.conf.severity); issues.push(issue); } } return issues; } } exports.InlineDataOldVersions = InlineDataOldVersions; //# sourceMappingURL=inline_data_old_versions.js.map