@abaplint/core 2.83.18 → 2.83.22
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/abap/5_syntax/expressions/constant.js +2 -2
- package/build/src/abap/5_syntax/expressions/source.js +21 -2
- package/build/src/objects/_abstract_object.js +2 -2
- package/build/src/objects/function_group.js +2 -2
- package/build/src/registry.js +1 -1
- package/build/src/rules/definitions_top.js +3 -3
- package/build/src/rules/downport.js +27 -0
- package/build/src/rules/remove_descriptions.js +2 -2
- package/build/src/rules/xml_consistency.js +2 -2
- package/package.json +4 -4
|
@@ -6,10 +6,10 @@ const expressions_1 = require("../../2_statements/expressions");
|
|
|
6
6
|
class Constant {
|
|
7
7
|
runSyntax(node) {
|
|
8
8
|
if (node.findDirectExpression(expressions_1.Integer)) {
|
|
9
|
-
return new basic_1.IntegerType();
|
|
9
|
+
return new basic_1.IntegerType("I");
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
12
|
-
return new basic_1.StringType();
|
|
12
|
+
return new basic_1.StringType("STRING");
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -58,12 +58,15 @@ class Source {
|
|
|
58
58
|
const method = new _builtin_1.BuiltIn().searchBuiltin(tok);
|
|
59
59
|
scope.addReference(token, method, _reference_1.ReferenceType.BuiltinMethodReference, filename);
|
|
60
60
|
new cond_1.Cond().runSyntax(node.findDirectExpression(Expressions.Cond), scope, filename);
|
|
61
|
-
return new basic_1.CharacterType(1);
|
|
61
|
+
return new basic_1.CharacterType(1, "ABAP_BOOL");
|
|
62
62
|
}
|
|
63
63
|
case "REDUCE":
|
|
64
64
|
{
|
|
65
65
|
const foundType = this.determineType(node, scope, filename, targetType);
|
|
66
66
|
const bodyType = new reduce_body_1.ReduceBody().runSyntax(node.findDirectExpression(Expressions.ReduceBody), scope, filename);
|
|
67
|
+
if (foundType === undefined) {
|
|
68
|
+
this.addIfInferred(node, scope, filename, bodyType);
|
|
69
|
+
}
|
|
67
70
|
return foundType ? foundType : bodyType;
|
|
68
71
|
}
|
|
69
72
|
case "SWITCH":
|
|
@@ -75,7 +78,11 @@ class Source {
|
|
|
75
78
|
case "COND":
|
|
76
79
|
{
|
|
77
80
|
const foundType = this.determineType(node, scope, filename, targetType);
|
|
78
|
-
|
|
81
|
+
const bodyType = new cond_body_1.CondBody().runSyntax(node.findDirectExpression(Expressions.CondBody), scope, filename, foundType);
|
|
82
|
+
if (foundType === undefined) {
|
|
83
|
+
this.addIfInferred(node, scope, filename, bodyType);
|
|
84
|
+
}
|
|
85
|
+
return foundType ? foundType : bodyType;
|
|
79
86
|
}
|
|
80
87
|
case "CONV":
|
|
81
88
|
{
|
|
@@ -155,6 +162,18 @@ class Source {
|
|
|
155
162
|
return context;
|
|
156
163
|
}
|
|
157
164
|
////////////////////////////////
|
|
165
|
+
addIfInferred(node, scope, filename, inferredType) {
|
|
166
|
+
const basic = new basic_types_1.BasicTypes(filename, scope);
|
|
167
|
+
const typeExpression = node.findFirstExpression(Expressions.TypeNameOrInfer);
|
|
168
|
+
const typeToken = typeExpression === null || typeExpression === void 0 ? void 0 : typeExpression.getFirstToken();
|
|
169
|
+
const typeName = typeToken === null || typeToken === void 0 ? void 0 : typeToken.getStr();
|
|
170
|
+
if (typeName === "#" && inferredType) {
|
|
171
|
+
const found = basic.lookupQualifiedName(inferredType.getQualifiedName());
|
|
172
|
+
if (found) {
|
|
173
|
+
scope.addReference(typeToken, found, _reference_1.ReferenceType.InferredType, filename);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
158
177
|
determineType(node, scope, filename, targetType) {
|
|
159
178
|
const basic = new basic_types_1.BasicTypes(filename, scope);
|
|
160
179
|
const typeExpression = node.findFirstExpression(Expressions.TypeNameOrInfer);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractObject = void 0;
|
|
4
|
-
const
|
|
4
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
5
5
|
const _identifier_1 = require("../abap/4_file_information/_identifier");
|
|
6
6
|
const identifier_1 = require("../abap/1_lexer/tokens/identifier");
|
|
7
7
|
const position_1 = require("../position");
|
|
@@ -100,7 +100,7 @@ class AbstractObject {
|
|
|
100
100
|
return undefined;
|
|
101
101
|
}
|
|
102
102
|
try {
|
|
103
|
-
return
|
|
103
|
+
return new fast_xml_parser_1.XMLParser({ parseTagValue: false, ignoreAttributes: true, trimValues: false }).parse(xml);
|
|
104
104
|
}
|
|
105
105
|
catch (_a) {
|
|
106
106
|
return undefined;
|
|
@@ -4,7 +4,7 @@ exports.FunctionGroup = void 0;
|
|
|
4
4
|
const _abap_object_1 = require("./_abap_object");
|
|
5
5
|
const types_1 = require("../abap/types");
|
|
6
6
|
const xml_utils_1 = require("../xml_utils");
|
|
7
|
-
const
|
|
7
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
8
8
|
class FunctionGroup extends _abap_object_1.ABAPObject {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
@@ -123,7 +123,7 @@ class FunctionGroup extends _abap_object_1.ABAPObject {
|
|
|
123
123
|
if (found === undefined) {
|
|
124
124
|
return {};
|
|
125
125
|
}
|
|
126
|
-
const parsed =
|
|
126
|
+
const parsed = new fast_xml_parser_1.XMLParser({ parseTagValue: false, ignoreAttributes: true, trimValues: false }).parse(found.getRaw());
|
|
127
127
|
this.findTexts(parsed);
|
|
128
128
|
}
|
|
129
129
|
return this.texts;
|
package/build/src/registry.js
CHANGED
|
@@ -47,10 +47,10 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
|
|
|
47
47
|
if (structure === undefined) {
|
|
48
48
|
return [];
|
|
49
49
|
}
|
|
50
|
-
// one fix per file
|
|
51
|
-
this.fixed = false;
|
|
52
50
|
const routines = structure.findAllStructures(Structures.Form).concat(structure.findAllStructures(Structures.Method));
|
|
53
51
|
for (const r of routines) {
|
|
52
|
+
// one fix per routine
|
|
53
|
+
this.fixed = false;
|
|
54
54
|
this.mode = DEFINITION;
|
|
55
55
|
this.moveTo = r.getFirstStatement();
|
|
56
56
|
const found = this.walk(r, file);
|
|
@@ -89,7 +89,7 @@ class DefinitionsTop extends _abap_rule_1.ABAPRule {
|
|
|
89
89
|
|| c.get() instanceof Statements.Static
|
|
90
90
|
|| c.get() instanceof Statements.FieldSymbol)) {
|
|
91
91
|
if (this.mode === AFTER) {
|
|
92
|
-
// only one fix per
|
|
92
|
+
// only one fix per routine, as it reorders a lot
|
|
93
93
|
let fix = undefined;
|
|
94
94
|
if (this.fixed === false && this.moveTo) {
|
|
95
95
|
fix = this.buildFix(file, c, this.moveTo);
|
|
@@ -55,6 +55,7 @@ Current rules:
|
|
|
55
55
|
* SELECT/INSERT/MODIFY/DELETE/UPDATE "," in field list removed, "@" in source/targets removed
|
|
56
56
|
* PARTIALLY IMPLEMENTED removed, it can be quick fixed via rule implement_methods
|
|
57
57
|
* RAISE EXCEPTION ... MESSAGE
|
|
58
|
+
* APPEND expression is outlined
|
|
58
59
|
|
|
59
60
|
Only one transformation is applied to a statement at a time, so multiple steps might be required to do the full downport.`,
|
|
60
61
|
tags: [_irule_1.RuleTag.Experimental, _irule_1.RuleTag.Downport, _irule_1.RuleTag.Quickfix],
|
|
@@ -223,6 +224,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
223
224
|
if (found) {
|
|
224
225
|
return found;
|
|
225
226
|
}
|
|
227
|
+
found = this.replaceAppendExpression(high, lowFile, highSyntax);
|
|
228
|
+
if (found) {
|
|
229
|
+
return found;
|
|
230
|
+
}
|
|
226
231
|
// todo, add more rules here
|
|
227
232
|
return undefined;
|
|
228
233
|
}
|
|
@@ -364,6 +369,28 @@ ${indentation}`);
|
|
|
364
369
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
365
370
|
return issue_1.Issue.atToken(lowFile, inlineData.getFirstToken(), "Outline SELECT @DATA", this.getMetadata().key, this.conf.severity, fix);
|
|
366
371
|
}
|
|
372
|
+
replaceAppendExpression(high, lowFile, highSyntax) {
|
|
373
|
+
if (!(high.get() instanceof Statements.Append)) {
|
|
374
|
+
return undefined;
|
|
375
|
+
}
|
|
376
|
+
const children = high.getChildren();
|
|
377
|
+
if (children[1].get() instanceof Expressions.Source) {
|
|
378
|
+
const source = children[1];
|
|
379
|
+
const target = high.findDirectExpression(Expressions.Target);
|
|
380
|
+
if (target === undefined) {
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
384
|
+
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
385
|
+
const firstToken = high.getFirstToken();
|
|
386
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, firstToken.getStart(), `DATA ${uniqueName} LIKE LINE OF ${target === null || target === void 0 ? void 0 : target.concatTokens()}.
|
|
387
|
+
${indentation}${uniqueName} = ${source.concatTokens()}.\n${indentation}`);
|
|
388
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, source.getFirstToken().getStart(), source.getLastToken().getEnd(), uniqueName);
|
|
389
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
390
|
+
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Outline APPEND source expression", this.getMetadata().key, this.conf.severity, fix);
|
|
391
|
+
}
|
|
392
|
+
return undefined;
|
|
393
|
+
}
|
|
367
394
|
replaceTableExpression(node, lowFile, highSyntax) {
|
|
368
395
|
var _a;
|
|
369
396
|
for (const fieldChain of node.findAllExpressionsRecursive(Expressions.FieldChain)) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RemoveDescriptions = exports.RemoveDescriptionsConf = void 0;
|
|
4
4
|
const issue_1 = require("../issue");
|
|
5
|
-
const
|
|
5
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
6
6
|
const Objects = require("../objects");
|
|
7
7
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
8
8
|
const position_1 = require("../position");
|
|
@@ -95,7 +95,7 @@ Consider using ABAP Doc for documentation.`,
|
|
|
95
95
|
return this.checkXML(xml, file);
|
|
96
96
|
}
|
|
97
97
|
checkXML(xml, file) {
|
|
98
|
-
const parsed =
|
|
98
|
+
const parsed = new fast_xml_parser_1.XMLParser({ parseTagValue: false, ignoreAttributes: true, trimValues: false }).parse(xml);
|
|
99
99
|
if (parsed === undefined || parsed.abapGit["asx:abap"]["asx:values"] === undefined) {
|
|
100
100
|
return [];
|
|
101
101
|
}
|
|
@@ -5,7 +5,7 @@ const issue_1 = require("../issue");
|
|
|
5
5
|
const _irule_1 = require("./_irule");
|
|
6
6
|
const Objects = require("../objects");
|
|
7
7
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
8
|
-
const
|
|
8
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
9
9
|
class XMLConsistencyConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
10
10
|
}
|
|
11
11
|
exports.XMLConsistencyConf = XMLConsistencyConf;
|
|
@@ -39,7 +39,7 @@ class XMLConsistency {
|
|
|
39
39
|
}
|
|
40
40
|
const xml = obj.getXML();
|
|
41
41
|
if (xml) {
|
|
42
|
-
const res =
|
|
42
|
+
const res = fast_xml_parser_1.XMLValidator.validate(xml);
|
|
43
43
|
if (res !== true) {
|
|
44
44
|
issues.push(issue_1.Issue.atRow(file, 1, "XML parser error: " + res.err.msg, this.getMetadata().key, this.conf.severity));
|
|
45
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.83.
|
|
3
|
+
"version": "2.83.22",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://abaplint.org",
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@microsoft/api-extractor": "^7.19.
|
|
48
|
+
"@microsoft/api-extractor": "^7.19.4",
|
|
49
49
|
"@types/chai": "^4.3.0",
|
|
50
50
|
"@types/mocha": "^9.0.0",
|
|
51
|
-
"@types/node": "^17.0.
|
|
51
|
+
"@types/node": "^17.0.8",
|
|
52
52
|
"chai": "^4.3.4",
|
|
53
53
|
"eslint": "^8.6.0",
|
|
54
54
|
"mocha": "^9.1.3",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"typescript": "^4.5.4"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"fast-xml-parser": "^
|
|
61
|
+
"fast-xml-parser": "^4.0.1",
|
|
62
62
|
"json5": "^2.2.0",
|
|
63
63
|
"vscode-languageserver-protocol": "^3.16.0",
|
|
64
64
|
"vscode-languageserver-types": "^3.16.0"
|