@abaplint/core
Version:
abaplint - Core API
63 lines • 2.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SMIMConsistency = exports.SMIMConsistencyConf = void 0;
const issue_1 = require("../issue");
const _basic_rule_config_1 = require("./_basic_rule_config");
const objects_1 = require("../objects");
const position_1 = require("../position");
class SMIMConsistencyConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.SMIMConsistencyConf = SMIMConsistencyConf;
class SMIMConsistency {
constructor() {
this.conf = new SMIMConsistencyConf();
}
getMetadata() {
return {
key: "smim_consistency",
title: "SMIM consistency check",
shortDescription: `SMIM consistency check`,
extendedInformation: "Check folders exists",
};
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
initialize(reg) {
this.reg = reg;
return this;
}
run(obj) {
const issues = [];
if (!(obj instanceof objects_1.MIMEObject)) {
return [];
}
const base = this.base(obj.getURL() || "");
if (base !== "" && this.findFolder(base) === false) {
const message = `Parent folder "${base}" not found`;
const position = new position_1.Position(1, 1);
const issue = issue_1.Issue.atPosition(obj.getFiles()[0], position, message, this.getMetadata().key, this.conf.severity);
issues.push(issue);
}
return issues;
}
base(full) {
const components = full.split("/");
components.pop();
return components.join("/");
}
findFolder(base) {
for (const smim of this.reg.getObjectsByType("SMIM")) {
const mime = smim;
if (base === mime.getURL() && mime.isFolder() === true) {
return true;
}
}
return false;
}
}
exports.SMIMConsistency = SMIMConsistency;
//# sourceMappingURL=smim_consistency.js.map