@abaplint/core
Version:
abaplint - Core API
52 lines • 2.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmptyStatement = exports.EmptyStatementConf = void 0;
const issue_1 = require("../issue");
const _statement_1 = require("../abap/2_statements/statements/_statement");
const _abap_rule_1 = require("./_abap_rule");
const _basic_rule_config_1 = require("./_basic_rule_config");
const edit_helper_1 = require("../edit_helper");
const position_1 = require("../position");
const _irule_1 = require("./_irule");
class EmptyStatementConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.EmptyStatementConf = EmptyStatementConf;
class EmptyStatement extends _abap_rule_1.ABAPRule {
constructor() {
super(...arguments);
this.conf = new EmptyStatementConf();
}
getMetadata() {
return {
key: "empty_statement",
title: "Remove empty statement",
shortDescription: `Checks for empty statements (an empty statement is a single dot)`,
tags: [_irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
badExample: `WRITE 'hello world'..`,
goodExample: `WRITE 'hello world'.`,
};
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
runParsed(file) {
const issues = [];
const statements = file.getStatements();
let previousEnd = new position_1.Position(1, 1);
for (const sta of statements) {
if (sta.get() instanceof _statement_1.Empty) {
const token = sta.getFirstToken();
const fix = edit_helper_1.EditHelper.deleteRange(file, previousEnd, token.getEnd());
const issue = issue_1.Issue.atStatement(file, sta, "Remove empty statement", this.getMetadata().key, this.conf.severity, fix);
issues.push(issue);
}
previousEnd = sta.getLastToken().getEnd();
}
return issues;
}
}
exports.EmptyStatement = EmptyStatement;
//# sourceMappingURL=empty_statement.js.map