UNPKG

@abaplint/core

Version:
65 lines 2.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NoCommentsBetweenMethods = exports.NoCommentsBetweenMethodsConf = void 0; const Statements = require("../abap/2_statements/statements"); 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 objects_1 = require("../objects"); const _statement_1 = require("../abap/2_statements/statements/_statement"); class NoCommentsBetweenMethodsConf extends _basic_rule_config_1.BasicRuleConfig { } exports.NoCommentsBetweenMethodsConf = NoCommentsBetweenMethodsConf; class NoCommentsBetweenMethods extends _abap_rule_1.ABAPRule { constructor() { super(...arguments); this.conf = new NoCommentsBetweenMethodsConf(); } getMetadata() { return { key: "no_comments_between_methods", title: "No comments between methods in global classes", shortDescription: `Its not possible to have comments between methods in global classes.`, tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Syntax], }; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } runParsed(file, obj) { const issues = []; if (!(obj instanceof objects_1.Class)) { return []; } else if (file !== obj.getMainABAPFile()) { return []; } let inMethod = false; let inClassImpl = false; for (const statement of file.getStatements()) { const statementType = statement.get(); if (statementType instanceof Statements.ClassImplementation) { inClassImpl = true; } else if (statementType instanceof Statements.EndClass) { inClassImpl = false; } else if (statementType instanceof Statements.MethodImplementation) { inMethod = true; } else if (statementType instanceof Statements.EndMethod) { inMethod = false; } else if (inClassImpl === true && inMethod === false && statementType instanceof _statement_1.Comment) { issues.push(issue_1.Issue.atStatement(file, statement, "Comment between methods in global class implementation", this.getMetadata().key, this.conf.severity)); } } return issues; } } exports.NoCommentsBetweenMethods = NoCommentsBetweenMethods; //# sourceMappingURL=no_comments_between_methods.js.map