@abaplint/core 2.119.21 → 2.119.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/objects/_abap_object.js +4 -4
- package/build/src/objects/transaction.js +7 -8
- package/build/src/registry.js +1 -1
- package/build/src/rules/check_text_elements.js +3 -2
- package/build/src/rules/uncaught_exception.js +22 -0
- package/build/src/rules/xml_consistency.js +7 -1
- package/package.json +1 -1
|
@@ -119,16 +119,16 @@ class ABAPObject extends _abstract_object_1.AbstractObject {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
findTextsTranslations(parsed) {
|
|
122
|
-
var _a, _b, _c, _d, _e, _f;
|
|
122
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
123
123
|
this.textsTranslations = [];
|
|
124
|
-
const values = (_c = (_b = (_a = parsed === null || parsed === void 0 ? void 0 : parsed.abapGit) === null || _a === void 0 ? void 0 : _a["asx:abap"]) === null || _b === void 0 ? void 0 : _b["asx:values"]
|
|
124
|
+
const values = (_d = (_c = (_b = (_a = parsed === null || parsed === void 0 ? void 0 : parsed.abapGit) === null || _a === void 0 ? void 0 : _a["asx:abap"]) === null || _b === void 0 ? void 0 : _b["asx:values"]) === null || _c === void 0 ? void 0 : _c.I18N_TPOOL) === null || _d === void 0 ? void 0 : _d.item;
|
|
125
125
|
if (values === undefined) {
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
for (const langItem of (0, xml_utils_1.xmlToArray)(values)) {
|
|
129
129
|
const textElements = {};
|
|
130
|
-
for (const item of (0, xml_utils_1.xmlToArray)((
|
|
131
|
-
const key = (
|
|
130
|
+
for (const item of (0, xml_utils_1.xmlToArray)((_e = langItem.TEXTPOOL) === null || _e === void 0 ? void 0 : _e.item)) {
|
|
131
|
+
const key = (_g = ((_f = item.KEY) !== null && _f !== void 0 ? _f : item.ID)) === null || _g === void 0 ? void 0 : _g.toUpperCase();
|
|
132
132
|
if (key !== undefined) {
|
|
133
133
|
textElements[key] = { entry: (0, xml_utils_1.unescape)(item.ENTRY), maxLength: parseInt(item.LENGTH, 10) };
|
|
134
134
|
}
|
|
@@ -38,23 +38,22 @@ class Transaction extends _abstract_object_1.AbstractObject {
|
|
|
38
38
|
return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.textsTranslations;
|
|
39
39
|
}
|
|
40
40
|
parse() {
|
|
41
|
-
var _a, _b, _c, _d;
|
|
41
|
+
var _a, _b, _c, _d, _e, _f;
|
|
42
42
|
if (this.parsedXML) {
|
|
43
43
|
return { updated: false, runtime: 0 };
|
|
44
44
|
}
|
|
45
45
|
const start = Date.now();
|
|
46
46
|
this.parsedXML = {};
|
|
47
47
|
const parsed = super.parseRaw2();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|| parsed.abapGit["asx:abap"]["asx:values"] === undefined) {
|
|
48
|
+
const values = (_b = (_a = parsed === null || parsed === void 0 ? void 0 : parsed.abapGit) === null || _a === void 0 ? void 0 : _a["asx:abap"]) === null || _b === void 0 ? void 0 : _b["asx:values"];
|
|
49
|
+
if (values === undefined) {
|
|
51
50
|
return { updated: false, runtime: 0 };
|
|
52
51
|
}
|
|
53
|
-
this.parsedXML.description = (
|
|
54
|
-
this.parsedXML.programName = (
|
|
55
|
-
this.parsedXML.cinfo = (
|
|
52
|
+
this.parsedXML.description = (_c = values.TSTCT) === null || _c === void 0 ? void 0 : _c.TTEXT;
|
|
53
|
+
this.parsedXML.programName = (_d = values.TSTC) === null || _d === void 0 ? void 0 : _d.PGMNA;
|
|
54
|
+
this.parsedXML.cinfo = (_e = values.TSTC) === null || _e === void 0 ? void 0 : _e.CINFO;
|
|
56
55
|
this.parsedXML.textsTranslations = [];
|
|
57
|
-
for (const item of (0, xml_utils_1.xmlToArray)((
|
|
56
|
+
for (const item of (0, xml_utils_1.xmlToArray)((_f = values.I18N_TPOOL) === null || _f === void 0 ? void 0 : _f.TSTCT)) {
|
|
58
57
|
this.parsedXML.textsTranslations.push({ language: item.SPRSL, description: item.TTEXT });
|
|
59
58
|
}
|
|
60
59
|
const end = Date.now();
|
package/build/src/registry.js
CHANGED
|
@@ -59,11 +59,12 @@ class CheckTextElements {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
for (const e of expressions) {
|
|
62
|
+
const mainNameSuffix = mainName !== undefined && mainName.toLowerCase() !== file.getFilename().toLowerCase() ? ", " + mainName : "";
|
|
62
63
|
if (e.get() instanceof Expressions.TextElement) {
|
|
63
64
|
const token = e.findFirstExpression(Expressions.TextElementKey).getFirstToken();
|
|
64
65
|
const key = token.getStr().toUpperCase();
|
|
65
66
|
if (texts[key] === undefined) {
|
|
66
|
-
const message = `Text element "${key}" not found` +
|
|
67
|
+
const message = `Text element "${key}" not found` + mainNameSuffix;
|
|
67
68
|
output.push(issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity));
|
|
68
69
|
}
|
|
69
70
|
}
|
|
@@ -77,7 +78,7 @@ class CheckTextElements {
|
|
|
77
78
|
found = found.replace(/'/g, "''");
|
|
78
79
|
}
|
|
79
80
|
if (found === undefined) {
|
|
80
|
-
const message = `Text element "${key}" not found` +
|
|
81
|
+
const message = `Text element "${key}" not found` + mainNameSuffix;
|
|
81
82
|
output.push(issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity));
|
|
82
83
|
}
|
|
83
84
|
else if (code !== "'" + found + "'"
|
|
@@ -159,7 +159,29 @@ class UncaughtException extends _abap_rule_1.ABAPRule {
|
|
|
159
159
|
this.check(name, n, file);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
+
else if (r.referenceType === _reference_1.ReferenceType.ConstructorReference
|
|
163
|
+
&& r.position.getStart().isAfter(start)
|
|
164
|
+
&& r.position.getEnd().isBefore(end)
|
|
165
|
+
&& r.resolved instanceof types_1.ClassDefinition) {
|
|
166
|
+
const method = this.findConstructor(r.resolved, scope);
|
|
167
|
+
for (const name of (method === null || method === void 0 ? void 0 : method.getRaising()) || []) {
|
|
168
|
+
this.check(name, n, file);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
findConstructor(def, scope) {
|
|
174
|
+
for (const method of def.getMethodDefinitions().getAll()) {
|
|
175
|
+
if (method instanceof types_1.MethodDefinition && method.getName().toUpperCase() === "CONSTRUCTOR") {
|
|
176
|
+
return method;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const sup = def.getSuperClass();
|
|
180
|
+
if (sup === undefined) {
|
|
181
|
+
return undefined;
|
|
162
182
|
}
|
|
183
|
+
const superDefinition = scope === null || scope === void 0 ? void 0 : scope.findClassDefinition(sup);
|
|
184
|
+
return superDefinition ? this.findConstructor(superDefinition, scope) : undefined;
|
|
163
185
|
}
|
|
164
186
|
addFromTryStructure(s) {
|
|
165
187
|
if (this.sinked === undefined) {
|
|
@@ -7,7 +7,13 @@ const Objects = require("../objects");
|
|
|
7
7
|
const _abap_object_1 = require("../objects/_abap_object");
|
|
8
8
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
9
9
|
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
10
|
+
const severity_1 = require("../severity");
|
|
10
11
|
class XMLConsistencyConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
/** Problem severity for text and translation length checks */
|
|
15
|
+
this.textAndTranslationLengthSeverity = severity_1.Severity.Error;
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
exports.XMLConsistencyConf = XMLConsistencyConf;
|
|
13
19
|
class XMLConsistency {
|
|
@@ -130,7 +136,7 @@ class XMLConsistency {
|
|
|
130
136
|
const max = typeof maxLength === "number" ? maxLength : parseInt(maxLength, 10);
|
|
131
137
|
if (text.length > max) {
|
|
132
138
|
const prefix = lang ? `[${lang}] ` : "";
|
|
133
|
-
return issue_1.Issue.atRow(file, 1, `${prefix}${fieldName} "${text}" exceeds maximum length of ${max} characters (actual: ${text.length})`, this.getMetadata().key, this.conf.
|
|
139
|
+
return issue_1.Issue.atRow(file, 1, `${prefix}${fieldName} "${text}" exceeds maximum length of ${max} characters (actual: ${text.length})`, this.getMetadata().key, this.conf.textAndTranslationLengthSeverity);
|
|
134
140
|
}
|
|
135
141
|
return undefined;
|
|
136
142
|
}
|