UNPKG

@abaplint/core

Version:
63 lines (61 loc) 2.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CDSLegacyView = exports.CDSLegacyViewConf = void 0; const issue_1 = require("../issue"); const _irule_1 = require("./_irule"); const version_1 = require("../version"); const _basic_rule_config_1 = require("./_basic_rule_config"); const objects_1 = require("../objects"); const expressions_1 = require("../cds/expressions"); class CDSLegacyViewConf extends _basic_rule_config_1.BasicRuleConfig { } exports.CDSLegacyViewConf = CDSLegacyViewConf; class CDSLegacyView { constructor() { this.conf = new CDSLegacyViewConf(); } getMetadata() { return { key: "cds_legacy_view", title: "CDS Legacy View", shortDescription: `Identify CDS Legacy Views`, extendedInformation: `Use DEFINE VIEW ENTITY instead of DEFINE VIEW https://blogs.sap.com/2021/10/16/a-new-generation-of-cds-views-how-to-migrate-your-cds-views-to-cds-view-entities/ v755 and up`, tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Upport], }; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } initialize(reg) { this.reg = reg; return this; } run(o) { const issues = []; if (this.reg.getConfig().getVersion() < version_1.Version.v755 && this.reg.getConfig().getVersion() !== version_1.Version.Cloud) { return []; } if (o.getType() !== "DDLS" || !(o instanceof objects_1.DataDefinition)) { return []; } const tree = o.getTree(); if (tree === undefined) { return []; // parser error } if (tree.get() instanceof expressions_1.CDSDefineView && tree.findDirectTokenByText("ENTITY") === undefined) { const file = o.findSourceFile(); if (file) { issues.push(issue_1.Issue.atRow(file, 1, "CDS Legacy View", this.getMetadata().key, this.getConfig().severity)); } } return issues; } } exports.CDSLegacyView = CDSLegacyView; //# sourceMappingURL=cds_legacy_view.js.map