UNPKG

@abaplint/core

Version:
71 lines 2.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Parser702Chaining = exports.Parser702ChainingConf = void 0; 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"); const version_1 = require("../version"); class Parser702ChainingConf extends _basic_rule_config_1.BasicRuleConfig { } exports.Parser702ChainingConf = Parser702ChainingConf; class Parser702Chaining extends _abap_rule_1.ABAPRule { constructor() { super(...arguments); this.conf = new Parser702ChainingConf(); } getMetadata() { return { key: "parser_702_chaining", title: "Parser Error, bad chanining on 702", shortDescription: `ABAP on 702 does not allow for method chaining with IMPORTING/EXPORTING/CHANGING keywords, this rule finds these and reports errors. Only active on target version 702 and below.`, 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.v702 && this.reg.getConfig().getVersion() !== version_1.Version.v700) { return []; } const stru = file.getStructure(); if (stru === undefined) { return []; } for (const chain of stru.findAllExpressions(Expressions.MethodCallChain)) { const calls = chain.findDirectExpressions(Expressions.MethodCall); if (calls.length < 2) { continue; } for (const call of calls) { const callParam = call.findDirectExpression(Expressions.MethodCallParam); if (callParam === undefined) { continue; } const param = callParam.findDirectExpression(Expressions.MethodParameters); if (param === undefined) { continue; } if (param.findDirectTokenByText("IMPORTING") || param.findDirectTokenByText("CHANGING") || param.findDirectTokenByText("EXCEPTIONS")) { const message = "This kind of method chaining not possible in 702"; const issue = issue_1.Issue.atPosition(file, param.getFirstToken().getStart(), message, this.getMetadata().key, this.conf.severity); issues.push(issue); } } } return issues; } } exports.Parser702Chaining = Parser702Chaining; //# sourceMappingURL=parser_702_chaining.js.map