UNPKG

@abaplint/core

Version:
79 lines 3.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SelectionScreenTextsMissing = exports.SelectionScreenTextsMissingConf = void 0; const issue_1 = require("../issue"); const _basic_rule_config_1 = require("./_basic_rule_config"); const statements_1 = require("../abap/2_statements/statements"); const expressions_1 = require("../abap/2_statements/expressions"); const objects_1 = require("../objects"); class SelectionScreenTextsMissingConf extends _basic_rule_config_1.BasicRuleConfig { } exports.SelectionScreenTextsMissingConf = SelectionScreenTextsMissingConf; class SelectionScreenTextsMissing { constructor() { this.conf = new SelectionScreenTextsMissingConf(); } getMetadata() { return { key: "selection_screen_texts_missing", title: "Selection screen texts missing", shortDescription: `Checks that selection screen parameters and select-options have selection texts`, }; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } initialize(reg) { this.reg = reg; return this; } run(obj) { if (!(obj instanceof objects_1.Program)) { return []; } if (obj.isInclude()) { return []; } const selTexts = obj.getSelectionTexts(); const output = []; const checked = new Set(); this.checkFile(obj.getMainABAPFile(), selTexts, output, checked); return output; } checkFile(file, selTexts, output, checked) { if (file === undefined) { return; } if (checked.has(file.getFilename())) { return; } checked.add(file.getFilename()); for (const stat of file.getStatements()) { const s = stat.get(); if (s instanceof statements_1.Parameter || s instanceof statements_1.SelectOption) { const fieldNode = stat.findFirstExpression(expressions_1.FieldSub); if (fieldNode) { const fieldName = fieldNode.getFirstToken().getStr().toUpperCase(); if (selTexts[fieldName] === undefined) { output.push(issue_1.Issue.atToken(file, fieldNode.getFirstToken(), `Selection text missing for "${fieldName}"`, this.getMetadata().key, this.conf.severity)); } } } else if (s instanceof statements_1.Include) { const nameNode = stat.findFirstExpression(expressions_1.IncludeName); if (nameNode) { const inclName = nameNode.getFirstToken().getStr().toUpperCase(); const inclObj = this.reg.getObject("PROG", inclName); if (inclObj) { this.checkFile(inclObj.getMainABAPFile(), selTexts, output, checked); } } } } } } exports.SelectionScreenTextsMissing = SelectionScreenTextsMissing; //# sourceMappingURL=selection_screen_texts_missing.js.map