@abaplint/core 2.120.89 → 2.120.90
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/field_chain.js +5 -0
- package/build/src/abap/5_syntax/expressions/method_call_chain.js +8 -0
- package/build/src/abap/5_syntax/expressions/table_expression.js +14 -0
- package/build/src/abap/5_syntax/expressions/target.js +5 -0
- package/build/src/objects/data_definition.js +28 -5
- package/build/src/registry.js +1 -1
- package/build/src/rules/xml_consistency.js +26 -0
- package/package.json +1 -1
|
@@ -73,6 +73,7 @@ class FieldChain {
|
|
|
73
73
|
const children = node.getChildren();
|
|
74
74
|
context = this.findTop(children[0], input, refType);
|
|
75
75
|
let prev = children[0].concatTokens();
|
|
76
|
+
let afterTableExpression = false;
|
|
76
77
|
for (let i = 1; i < children.length; i++) {
|
|
77
78
|
const current = children[i];
|
|
78
79
|
if (current === undefined) {
|
|
@@ -120,6 +121,9 @@ class FieldChain {
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
else if (current.get() instanceof tokens_1.InstanceArrow) {
|
|
124
|
+
if (afterTableExpression && table_expression_1.TableExpression.checkArrowAfter(input, current.getFirstToken())) {
|
|
125
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
126
|
+
}
|
|
123
127
|
if (!(context instanceof basic_1.ObjectReferenceType)
|
|
124
128
|
&& !(context instanceof basic_1.DataReference)
|
|
125
129
|
&& !(context instanceof basic_1.VoidType)) {
|
|
@@ -152,6 +156,7 @@ class FieldChain {
|
|
|
152
156
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
153
157
|
}
|
|
154
158
|
table_expression_1.TableExpression.runSyntax(current, input, context);
|
|
159
|
+
afterTableExpression = true;
|
|
155
160
|
if (!(context instanceof basic_1.VoidType) && !(context instanceof basic_1.UnknownType)) {
|
|
156
161
|
context = context.getRowType();
|
|
157
162
|
}
|
|
@@ -46,6 +46,7 @@ const method_call_param_1 = require("./method_call_param");
|
|
|
46
46
|
const _reference_1 = require("../_reference");
|
|
47
47
|
const component_name_1 = require("./component_name");
|
|
48
48
|
const attribute_name_1 = require("./attribute_name");
|
|
49
|
+
const table_expression_1 = require("./table_expression");
|
|
49
50
|
const _syntax_input_1 = require("../_syntax_input");
|
|
50
51
|
class MethodCallChain {
|
|
51
52
|
static runSyntax(node, input, targetType) {
|
|
@@ -58,6 +59,13 @@ class MethodCallChain {
|
|
|
58
59
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
59
60
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
60
61
|
}
|
|
62
|
+
// the field chain is followed by "->", eg. "itab[ 1 ]-ref->meth( )"
|
|
63
|
+
if (first instanceof nodes_1.ExpressionNode
|
|
64
|
+
&& first.get() instanceof Expressions.FieldChain
|
|
65
|
+
&& first.findDirectExpression(Expressions.TableExpression) !== undefined
|
|
66
|
+
&& table_expression_1.TableExpression.checkArrowAfter(input, children[1].getFirstToken())) {
|
|
67
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
68
|
+
}
|
|
61
69
|
let currentIndex = 1;
|
|
62
70
|
let context = this.findTop(first, input, targetType);
|
|
63
71
|
if (first.get() instanceof Expressions.MethodCall) {
|
|
@@ -37,9 +37,23 @@ exports.TableExpression = void 0;
|
|
|
37
37
|
const nodes_1 = require("../../nodes");
|
|
38
38
|
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
39
39
|
const source_1 = require("./source");
|
|
40
|
+
const _syntax_input_1 = require("../_syntax_input");
|
|
40
41
|
const basic_1 = require("../../types/basic");
|
|
41
42
|
const component_chain_1 = require("./component_chain");
|
|
43
|
+
const version_1 = require("../../../version");
|
|
42
44
|
class TableExpression {
|
|
45
|
+
/** below v750 the object component selector "->" cannot follow a table expression, eg. "itab[ 1 ]-ref->meth( )",
|
|
46
|
+
* returns true and adds an issue if not allowed */
|
|
47
|
+
static checkArrowAfter(input, arrow) {
|
|
48
|
+
if ((0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v750)
|
|
49
|
+
|| input.scope.getLanguageVersion() === version_1.LanguageVersion.Cloud
|
|
50
|
+
|| input.scope.getOpenABAP()) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const message = "Object component selector \"->\" after table expression not possible below v750";
|
|
54
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, arrow, message));
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
43
57
|
static runSyntax(node, input, rowType) {
|
|
44
58
|
if (node === undefined) {
|
|
45
59
|
return;
|
|
@@ -73,6 +73,7 @@ class Target {
|
|
|
73
73
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
74
74
|
}
|
|
75
75
|
let currentIndex = 1;
|
|
76
|
+
let afterTableExpression = false;
|
|
76
77
|
while (currentIndex <= children.length) {
|
|
77
78
|
const current = children[currentIndex];
|
|
78
79
|
if (current === undefined) {
|
|
@@ -98,6 +99,9 @@ class Target {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
else if (current.get() instanceof tokens_1.InstanceArrow) {
|
|
102
|
+
if (afterTableExpression && table_expression_1.TableExpression.checkArrowAfter(input, current.getFirstToken())) {
|
|
103
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
104
|
+
}
|
|
101
105
|
if (!(context instanceof basic_1.ObjectReferenceType)
|
|
102
106
|
&& !(context instanceof basic_1.DataReference)
|
|
103
107
|
&& !(context instanceof basic_1.VoidType)) {
|
|
@@ -146,6 +150,7 @@ class Target {
|
|
|
146
150
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
147
151
|
}
|
|
148
152
|
table_expression_1.TableExpression.runSyntax(current, input, context);
|
|
153
|
+
afterTableExpression = true;
|
|
149
154
|
if (!(context instanceof basic_1.VoidType) && !(context instanceof unknown_type_1.UnknownType)) {
|
|
150
155
|
context = context.getRowType();
|
|
151
156
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataDefinition = void 0;
|
|
4
|
+
const tokens_1 = require("../abap/1_lexer/tokens");
|
|
5
|
+
const combi_1 = require("../abap/2_statements/combi");
|
|
4
6
|
const nodes_1 = require("../abap/nodes");
|
|
5
7
|
const cds_determine_types_1 = require("../cds/cds_determine_types");
|
|
8
|
+
const cds_lexer_1 = require("../cds/cds_lexer");
|
|
9
|
+
const version_1 = require("../version");
|
|
6
10
|
const cds_parser_1 = require("../cds/cds_parser");
|
|
7
11
|
const expressions_1 = require("../cds/expressions");
|
|
8
12
|
const _abstract_object_1 = require("./_abstract_object");
|
|
@@ -94,8 +98,8 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
94
98
|
associations: [],
|
|
95
99
|
tree: undefined,
|
|
96
100
|
};
|
|
97
|
-
this.findSQLViewName();
|
|
98
101
|
this.parsedData.tree = new cds_parser_1.CDSParser().parse(this.findSourceFile());
|
|
102
|
+
this.findSQLViewName(this.parsedData.tree);
|
|
99
103
|
if (this.parsedData.tree) {
|
|
100
104
|
for (const c of ((_a = this.parsedData.tree) === null || _a === void 0 ? void 0 : _a.getChildren()) || []) {
|
|
101
105
|
if (c.get() instanceof expressions_1.CDSAnnotation) {
|
|
@@ -120,11 +124,30 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
120
124
|
return (_a = this.parsedData) === null || _a === void 0 ? void 0 : _a.tree;
|
|
121
125
|
}
|
|
122
126
|
//////////
|
|
123
|
-
findSQLViewName() {
|
|
127
|
+
findSQLViewName(tree) {
|
|
124
128
|
var _a;
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
129
|
+
let annotations = tree === null || tree === void 0 ? void 0 : tree.findDirectExpressions(expressions_1.CDSAnnotation);
|
|
130
|
+
if (annotations === undefined) {
|
|
131
|
+
const file = this.findSourceFile();
|
|
132
|
+
if (file === undefined) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Keep SQL view lookup available even when the view body cannot be parsed.
|
|
136
|
+
const tokens = cds_lexer_1.CDSLexer.run(file).filter(t => !(t instanceof tokens_1.Comment));
|
|
137
|
+
const leadingAnnotations = (0, combi_1.seq)((0, combi_1.starPrio)(expressions_1.CDSAnnotation), (0, combi_1.starPrio)((0, combi_1.regex)(/.*/)));
|
|
138
|
+
annotations = (_a = combi_1.Combi.run(leadingAnnotations, tokens, version_1.defaultRelease)) === null || _a === void 0 ? void 0 : _a.filter((n) => n instanceof nodes_1.ExpressionNode && n.get() instanceof expressions_1.CDSAnnotation);
|
|
139
|
+
}
|
|
140
|
+
for (const annotation of annotations || []) {
|
|
141
|
+
const tokens = annotation.getTokens().map(t => t.getStr());
|
|
142
|
+
const colon = tokens.indexOf(":");
|
|
143
|
+
if (tokens.slice(0, colon).join("") !== "@AbapCatalog.sqlViewName") {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const match = tokens.slice(colon + 1).join(" ").match(/^'([\w/]+)'$/);
|
|
147
|
+
if (match) {
|
|
148
|
+
this.parsedData.sqlViewName = match[1].toUpperCase();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
128
151
|
}
|
|
129
152
|
}
|
|
130
153
|
findDescription() {
|
package/build/src/registry.js
CHANGED
|
@@ -69,6 +69,7 @@ class XMLConsistency {
|
|
|
69
69
|
extendedInformation: `Checks:
|
|
70
70
|
* XML is well-formed and parseable
|
|
71
71
|
* Naming for CLAS and INTF objects
|
|
72
|
+
* CLAS and INTF objects do not contain fields that abapGit clears, eg. AUTHOR, CREATEDON and VERSION
|
|
72
73
|
* QUAN fields in TABL objects have reference table and field values
|
|
73
74
|
* Transparent TABL objects have delivery class and size category set
|
|
74
75
|
* TABL fields with a built-in type carry the INTTYPE abapGit serializes for it, for the confirmed pairs
|
|
@@ -154,6 +155,22 @@ class XMLConsistency {
|
|
|
154
155
|
else if (((_a = obj.getMainABAPFile()) === null || _a === void 0 ? void 0 : _a.getStructure()) !== undefined && obj.getClassDefinition() === undefined) {
|
|
155
156
|
issues.push(issue_1.Issue.atRow(file, 1, "Class matching XML name not found in ABAP file", this.getMetadata().key, this.conf.severity));
|
|
156
157
|
}
|
|
158
|
+
issues.push(...this.checkClearedFields(obj, file, "VSEOCLASS", XMLConsistency.clearedClassFields));
|
|
159
|
+
return issues;
|
|
160
|
+
}
|
|
161
|
+
checkClearedFields(obj, file, structure, fields) {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
const issues = [];
|
|
164
|
+
const block = (_b = (_a = obj.getXML()) === null || _a === void 0 ? void 0 : _a.match(new RegExp(`<${structure}>([\\s\\S]*?)</${structure}>`))) === null || _b === void 0 ? void 0 : _b[1];
|
|
165
|
+
if (block === undefined) {
|
|
166
|
+
return issues;
|
|
167
|
+
}
|
|
168
|
+
for (const field of fields) {
|
|
169
|
+
if (block.match(new RegExp(`<${field}[\\s/>]`)) !== null) {
|
|
170
|
+
const message = `Field ${field} in ${structure} is cleared by abapGit and should not be in the XML`;
|
|
171
|
+
issues.push(issue_1.Issue.atRow(file, 1, message, this.getMetadata().key, this.conf.severity));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
157
174
|
return issues;
|
|
158
175
|
}
|
|
159
176
|
runTextPool(obj, file) {
|
|
@@ -187,6 +204,7 @@ class XMLConsistency {
|
|
|
187
204
|
else if (obj.getDefinition() !== undefined && ((_a = obj.getDefinition()) === null || _a === void 0 ? void 0 : _a.getName().toUpperCase()) !== name.toUpperCase()) {
|
|
188
205
|
issues.push(issue_1.Issue.atRow(file, 1, "Interface matching XML name not found in ABAP file", this.getMetadata().key, this.conf.severity));
|
|
189
206
|
}
|
|
207
|
+
issues.push(...this.checkClearedFields(obj, file, "VSEOINTERF", XMLConsistency.clearedInterfaceFields));
|
|
190
208
|
return issues;
|
|
191
209
|
}
|
|
192
210
|
checkTextLength(file, fieldName, text, maxLength, lang) {
|
|
@@ -367,6 +385,14 @@ class XMLConsistency {
|
|
|
367
385
|
}
|
|
368
386
|
}
|
|
369
387
|
exports.XMLConsistency = XMLConsistency;
|
|
388
|
+
// fields abapGit clears before serializing, see ZCL_ABAPGIT_OO_CLASS and ZCL_ABAPGIT_OO_INTERFACE;
|
|
389
|
+
// abapGit omits initial fields, so any occurrence shows as a diff on every pull
|
|
390
|
+
XMLConsistency.clearedInterfaceFields = [
|
|
391
|
+
"UUID", "AUTHOR", "CREATEDON", "CHANGEDBY", "CHANGEDON", "CHGDANYBY", "CHGDANYON", "R3RELEASE", "VERSION",
|
|
392
|
+
];
|
|
393
|
+
XMLConsistency.clearedClassFields = [
|
|
394
|
+
...XMLConsistency.clearedInterfaceFields, "CLSFINAL", "CLSABSTRCT", "EXPOSURE",
|
|
395
|
+
];
|
|
370
396
|
// INTTYPE that abapGit serializes for a built-in DATATYPE, confirmed by exported tables;
|
|
371
397
|
// a different value activates, but shows as a diff on every pull
|
|
372
398
|
XMLConsistency.intTypes = {
|