@abaplint/core
Version:
abaplint - Core API
52 lines • 2.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NoExclamationEscape = exports.NoExclamationEscapeConf = void 0;
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 edit_helper_1 = require("../edit_helper");
const tokens_1 = require("../abap/1_lexer/tokens");
class NoExclamationEscapeConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.NoExclamationEscapeConf = NoExclamationEscapeConf;
class NoExclamationEscape extends _abap_rule_1.ABAPRule {
constructor() {
super(...arguments);
this.conf = new NoExclamationEscapeConf();
}
getMetadata() {
return {
key: "no_exclamation_escape",
title: "No exclamation escape",
shortDescription: `Detects and removes exclamation marks (!) used to escape identifiers`,
// eslint-disable-next-line max-len
extendedInformation: `Exclamation marks are not needed when the identifier is not a reserved keyword, or could be avoided by renaming.`,
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
badExample: "methods CONVERT changing !CO_sdf type ref to ZCL_sdf optional.",
goodExample: "methods CONVERT changing CO_sdf type ref to ZCL_sdf optional.",
};
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
runParsed(file) {
const issues = [];
for (const token of file.getTokens()) {
if (token instanceof tokens_1.Identifier) {
const str = token.getStr();
if (str.startsWith("!")) {
const replacement = str.substring(1);
const fix = edit_helper_1.EditHelper.replaceToken(file, token, replacement);
issues.push(issue_1.Issue.atToken(file, token, "Do not use exclamation mark to escape identifiers", this.getMetadata().key, this.conf.severity, fix));
}
}
}
return issues;
}
}
exports.NoExclamationEscape = NoExclamationEscape;
//# sourceMappingURL=no_exclamation_escape.js.map