@abaplint/core
Version:
abaplint - Core API
65 lines • 2.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SQLValueConversion = exports.SQLValueConversionConf = void 0;
const issue_1 = require("../issue");
const _basic_rule_config_1 = require("./_basic_rule_config");
const objects_1 = require("../objects");
const syntax_1 = require("../abap/5_syntax/syntax");
const _abap_object_1 = require("../objects/_abap_object");
class SQLValueConversionConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.SQLValueConversionConf = SQLValueConversionConf;
class SQLValueConversion {
constructor() {
this.conf = new SQLValueConversionConf();
}
getMetadata() {
return {
key: "sql_value_conversion",
title: "Implicit SQL Value Conversion",
shortDescription: `Ensure types match when selecting from database`,
extendedInformation: `
* Integer to CHAR conversion
* Integer to NUMC conversion
* NUMC to Integer conversion
* CHAR to Integer conversion
* Source field longer than database field, CHAR -> CHAR
* Source field longer than database field, NUMC -> NUMC`,
tags: [],
};
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
initialize(reg) {
this.reg = reg;
return this;
}
run(obj) {
if (!(obj instanceof _abap_object_1.ABAPObject) || obj instanceof objects_1.Interface) {
return [];
}
// messages defined in sql_compare.ts
const issues = this.traverse(new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti.getTop());
return issues;
}
traverse(node) {
const ret = [];
for (const r of node.getData().sqlConversion) {
const file = this.reg.getFileByName(node.getIdentifier().filename);
if (file === undefined) {
continue;
}
ret.push(issue_1.Issue.atToken(file, r.token, r.message, this.getMetadata().key, this.getConfig().severity));
}
for (const c of node.getChildren()) {
ret.push(...this.traverse(c));
}
return ret;
}
}
exports.SQLValueConversion = SQLValueConversion;
//# sourceMappingURL=sql_value_conversion.js.map