@abaplint/core 2.83.2 → 2.83.3
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/abaplint.d.ts +10 -1
- package/build/src/cds/cds_lexer.js +3 -1
- package/build/src/cds/expressions/cds_annotation.js +4 -2
- package/build/src/cds/expressions/cds_as.js +12 -0
- package/build/src/cds/expressions/cds_association.js +6 -2
- package/build/src/cds/expressions/cds_cast.js +13 -0
- package/build/src/cds/expressions/cds_element.js +3 -1
- package/build/src/cds/expressions/cds_function.js +17 -0
- package/build/src/cds/expressions/cds_join.js +2 -1
- package/build/src/cds/expressions/cds_select.js +1 -1
- package/build/src/cds/expressions/cds_source.js +12 -0
- package/build/src/cds/expressions/cds_where.js +4 -1
- package/build/src/cds/expressions/index.js +4 -0
- package/build/src/objects/data_definition.js +58 -4
- package/build/src/registry.js +1 -1
- package/build/src/rules/cds_parser_error.js +2 -2
- package/package.json +1 -1
package/build/abaplint.d.ts
CHANGED
|
@@ -1114,6 +1114,9 @@ declare class DataControl extends AbstractObject {
|
|
|
1114
1114
|
|
|
1115
1115
|
declare class DataDefinition extends AbstractObject {
|
|
1116
1116
|
private sqlViewName;
|
|
1117
|
+
private parserError;
|
|
1118
|
+
private fieldNames;
|
|
1119
|
+
private sources;
|
|
1117
1120
|
getType(): string;
|
|
1118
1121
|
getAllowedNaming(): {
|
|
1119
1122
|
maxLength: number;
|
|
@@ -1122,10 +1125,16 @@ declare class DataDefinition extends AbstractObject {
|
|
|
1122
1125
|
getSQLViewName(): string | undefined;
|
|
1123
1126
|
getDescription(): string | undefined;
|
|
1124
1127
|
parseType(_reg: IRegistry): AbstractType;
|
|
1128
|
+
listSources(): {
|
|
1129
|
+
name: string;
|
|
1130
|
+
as: string | undefined;
|
|
1131
|
+
}[];
|
|
1125
1132
|
setDirty(): void;
|
|
1126
1133
|
findSourceFile(): IFile | undefined;
|
|
1127
|
-
|
|
1134
|
+
hasParserError(): boolean | undefined;
|
|
1128
1135
|
parse(): IParseResult;
|
|
1136
|
+
private findFieldNames;
|
|
1137
|
+
private findSources;
|
|
1129
1138
|
}
|
|
1130
1139
|
|
|
1131
1140
|
declare class DataDefinition_2 extends Expression {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CDSAnnotation = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
4
5
|
const combi_1 = require("../../abap/2_statements/combi");
|
|
5
6
|
class CDSAnnotation extends combi_1.Expression {
|
|
6
7
|
getRunnable() {
|
|
7
8
|
// todo: add all the known annotations
|
|
8
|
-
const value = (0, combi_1.alt)((0, combi_1.regex)(/^'[\w ]+'$/), "true", "false", (0, combi_1.regex)(/^#\w+$/));
|
|
9
|
+
const value = (0, combi_1.alt)((0, combi_1.regex)(/^'[\w ]+'$/), "true", "false", (0, combi_1.regex)(/^\d+$/), (0, combi_1.seq)((0, combi_1.regex)(/^\d+$/), ".", (0, combi_1.regex)(/^\d+$/)), (0, combi_1.regex)(/^#\w+$/));
|
|
9
10
|
const valueList = (0, combi_1.seq)("[", value, (0, combi_1.star)((0, combi_1.seq)(",", value)), "]");
|
|
10
|
-
|
|
11
|
+
const valueNested = (0, combi_1.seq)("{", _1.CDSName, (0, combi_1.star)((0, combi_1.seq)(".", _1.CDSName)), ":", value, "}");
|
|
12
|
+
return (0, combi_1.seq)((0, combi_1.regex)(/^@\w+$/), (0, combi_1.star)((0, combi_1.seq)(".", (0, combi_1.regex)(/^\w+$/))), (0, combi_1.opt)(":"), (0, combi_1.opt)((0, combi_1.alt)(valueList, valueNested, value)));
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
15
|
exports.CDSAnnotation = CDSAnnotation;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CDSAs = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const combi_1 = require("../../abap/2_statements/combi");
|
|
6
|
+
class CDSAs extends combi_1.Expression {
|
|
7
|
+
getRunnable() {
|
|
8
|
+
return (0, combi_1.seq)("AS", _1.CDSName);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.CDSAs = CDSAs;
|
|
12
|
+
//# sourceMappingURL=cds_as.js.map
|
|
@@ -5,8 +5,12 @@ const _1 = require(".");
|
|
|
5
5
|
const combi_1 = require("../../abap/2_statements/combi");
|
|
6
6
|
class CDSAssociation extends combi_1.Expression {
|
|
7
7
|
getRunnable() {
|
|
8
|
-
const cardinality = (0, combi_1.
|
|
9
|
-
|
|
8
|
+
const cardinality = (0, combi_1.seq)("[", (0, combi_1.alt)("0", "1"), ".", ".", (0, combi_1.alt)("0", "1", "*"), "]");
|
|
9
|
+
const as = (0, combi_1.seq)("AS", _1.CDSName);
|
|
10
|
+
const name = (0, combi_1.seq)(_1.CDSName, (0, combi_1.plus)((0, combi_1.seq)(".", _1.CDSName)));
|
|
11
|
+
const cond = (0, combi_1.seq)(name, "=", name);
|
|
12
|
+
const and = (0, combi_1.seq)("AND", cond);
|
|
13
|
+
return (0, combi_1.seq)("ASSOCIATION", cardinality, "TO", _1.CDSName, (0, combi_1.opt)(as), "ON", cond, (0, combi_1.star)(and));
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
16
|
exports.CDSAssociation = CDSAssociation;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CDSCast = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const combi_1 = require("../../abap/2_statements/combi");
|
|
6
|
+
class CDSCast extends combi_1.Expression {
|
|
7
|
+
getRunnable() {
|
|
8
|
+
const name = (0, combi_1.seq)(_1.CDSName, (0, combi_1.opt)((0, combi_1.seq)(".", _1.CDSName)));
|
|
9
|
+
return (0, combi_1.seq)("CAST", "(", (0, combi_1.alt)(name, _1.CDSFunction), "AS", _1.CDSName, (0, combi_1.opt)((0, combi_1.seq)("PRESERVING", "TYPE")), ")");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.CDSCast = CDSCast;
|
|
13
|
+
//# sourceMappingURL=cds_cast.js.map
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CDSElement = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const combi_1 = require("../../abap/2_statements/combi");
|
|
6
|
+
const cds_as_1 = require("./cds_as");
|
|
7
|
+
const cds_cast_1 = require("./cds_cast");
|
|
6
8
|
class CDSElement extends combi_1.Expression {
|
|
7
9
|
getRunnable() {
|
|
8
|
-
return (0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.optPrio)("KEY"),
|
|
10
|
+
return (0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.optPrio)("KEY"), (0, combi_1.alt)(_1.CDSName, cds_cast_1.CDSCast), (0, combi_1.optPrio)(cds_as_1.CDSAs));
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
exports.CDSElement = CDSElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CDSFunction = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const combi_1 = require("../../abap/2_statements/combi");
|
|
6
|
+
class CDSFunction extends combi_1.Expression {
|
|
7
|
+
getRunnable() {
|
|
8
|
+
const input = (0, combi_1.alt)(_1.CDSName, (0, combi_1.regex)(/^\d+$/));
|
|
9
|
+
const coalesce = (0, combi_1.seq)("COALESCE", "(", input, ",", input, ")");
|
|
10
|
+
const concat = (0, combi_1.seq)("CONCAT", "(", input, ",", input, ")");
|
|
11
|
+
const concat_with_space = (0, combi_1.seq)("CONCAT_WITH_SPACE", "(", input, ",", input, ",", input, ")");
|
|
12
|
+
const substring = (0, combi_1.seq)("SUBSTRING", "(", input, ",", input, ",", input, ")");
|
|
13
|
+
return (0, combi_1.alt)(substring, coalesce, concat, concat_with_space);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.CDSFunction = CDSFunction;
|
|
17
|
+
//# sourceMappingURL=cds_function.js.map
|
|
@@ -5,7 +5,8 @@ const _1 = require(".");
|
|
|
5
5
|
const combi_1 = require("../../abap/2_statements/combi");
|
|
6
6
|
class CDSJoin extends combi_1.Expression {
|
|
7
7
|
getRunnable() {
|
|
8
|
-
|
|
8
|
+
const name = (0, combi_1.seq)(_1.CDSName, ".", _1.CDSName);
|
|
9
|
+
return (0, combi_1.seq)("INNER JOIN", _1.CDSSource, "ON", name, "=", name);
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.CDSJoin = CDSJoin;
|
|
@@ -8,7 +8,7 @@ const cds_element_1 = require("./cds_element");
|
|
|
8
8
|
const cds_join_1 = require("./cds_join");
|
|
9
9
|
class CDSSelect extends combi_1.Expression {
|
|
10
10
|
getRunnable() {
|
|
11
|
-
return (0, combi_1.seq)((0, combi_1.str)("SELECT FROM"), _1.
|
|
11
|
+
return (0, combi_1.seq)((0, combi_1.str)("SELECT FROM"), _1.CDSSource, (0, combi_1.opt)(cds_join_1.CDSJoin), (0, combi_1.star)(cds_association_1.CDSAssociation), (0, combi_1.str)("{"), (0, combi_1.plus)(cds_element_1.CDSElement), (0, combi_1.star)((0, combi_1.seq)(",", cds_element_1.CDSElement)), (0, combi_1.str)("}"), (0, combi_1.opt)(_1.CDSWhere));
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
exports.CDSSelect = CDSSelect;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CDSSource = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const combi_1 = require("../../abap/2_statements/combi");
|
|
6
|
+
class CDSSource extends combi_1.Expression {
|
|
7
|
+
getRunnable() {
|
|
8
|
+
return (0, combi_1.seq)((0, combi_1.regex)(/^[\w_]+$/), (0, combi_1.opt)(_1.CDSAs));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.CDSSource = CDSSource;
|
|
12
|
+
//# sourceMappingURL=cds_source.js.map
|
|
@@ -5,7 +5,10 @@ const _1 = require(".");
|
|
|
5
5
|
const combi_1 = require("../../abap/2_statements/combi");
|
|
6
6
|
class CDSWhere extends combi_1.Expression {
|
|
7
7
|
getRunnable() {
|
|
8
|
-
|
|
8
|
+
const constant = (0, combi_1.regex)(/^'[\w ]+'$/);
|
|
9
|
+
const field = (0, combi_1.seq)(_1.CDSName, (0, combi_1.star)((0, combi_1.seq)(".", _1.CDSName)));
|
|
10
|
+
const condition = (0, combi_1.seq)(field, "=", (0, combi_1.alt)(constant, field));
|
|
11
|
+
return (0, combi_1.seq)("WHERE", condition, (0, combi_1.star)((0, combi_1.seq)("AND", condition)));
|
|
9
12
|
}
|
|
10
13
|
}
|
|
11
14
|
exports.CDSWhere = CDSWhere;
|
|
@@ -11,11 +11,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./cds_annotation"), exports);
|
|
14
|
+
__exportStar(require("./cds_as"), exports);
|
|
14
15
|
__exportStar(require("./cds_association"), exports);
|
|
16
|
+
__exportStar(require("./cds_cast"), exports);
|
|
15
17
|
__exportStar(require("./cds_define_view"), exports);
|
|
16
18
|
__exportStar(require("./cds_element"), exports);
|
|
19
|
+
__exportStar(require("./cds_function"), exports);
|
|
17
20
|
__exportStar(require("./cds_join"), exports);
|
|
18
21
|
__exportStar(require("./cds_name"), exports);
|
|
19
22
|
__exportStar(require("./cds_select"), exports);
|
|
23
|
+
__exportStar(require("./cds_source"), exports);
|
|
20
24
|
__exportStar(require("./cds_where"), exports);
|
|
21
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -3,11 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataDefinition = void 0;
|
|
4
4
|
const basic_1 = require("../abap/types/basic");
|
|
5
5
|
const cds_parser_1 = require("../cds/cds_parser");
|
|
6
|
+
const expressions_1 = require("../cds/expressions");
|
|
6
7
|
const _abstract_object_1 = require("./_abstract_object");
|
|
7
8
|
class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
8
9
|
constructor() {
|
|
9
10
|
super(...arguments);
|
|
10
11
|
this.sqlViewName = undefined;
|
|
12
|
+
this.parserError = undefined;
|
|
13
|
+
this.fieldNames = [];
|
|
14
|
+
this.sources = [];
|
|
11
15
|
}
|
|
12
16
|
getType() {
|
|
13
17
|
return "DDLS";
|
|
@@ -26,18 +30,36 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
26
30
|
return undefined;
|
|
27
31
|
}
|
|
28
32
|
parseType(_reg) {
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
this.parse();
|
|
34
|
+
if (this.fieldNames.length === 0) {
|
|
35
|
+
return new basic_1.VoidType("DDLS:todo");
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const components = [];
|
|
39
|
+
for (const f of this.fieldNames) {
|
|
40
|
+
components.push({
|
|
41
|
+
name: f,
|
|
42
|
+
type: new basic_1.VoidType("DDLS:fieldname"),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return new basic_1.StructureType(components);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
listSources() {
|
|
49
|
+
return this.sources;
|
|
31
50
|
}
|
|
32
51
|
setDirty() {
|
|
33
52
|
this.sqlViewName = undefined;
|
|
53
|
+
this.parserError = undefined;
|
|
54
|
+
this.fieldNames = [];
|
|
55
|
+
this.sources = [];
|
|
34
56
|
super.setDirty();
|
|
35
57
|
}
|
|
36
58
|
findSourceFile() {
|
|
37
59
|
return this.getFiles().find(f => f.getFilename().endsWith(".asddls"));
|
|
38
60
|
}
|
|
39
|
-
|
|
40
|
-
return
|
|
61
|
+
hasParserError() {
|
|
62
|
+
return this.parserError;
|
|
41
63
|
}
|
|
42
64
|
parse() {
|
|
43
65
|
var _a;
|
|
@@ -49,8 +71,40 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
49
71
|
if (match) {
|
|
50
72
|
this.sqlViewName = match[1].toUpperCase();
|
|
51
73
|
}
|
|
74
|
+
const tree = new cds_parser_1.CDSParser().parse(this.findSourceFile());
|
|
75
|
+
if (tree) {
|
|
76
|
+
this.findFieldNames(tree);
|
|
77
|
+
this.findSources(tree);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.parserError = true;
|
|
81
|
+
}
|
|
82
|
+
this.dirty = false;
|
|
52
83
|
return { updated: true, runtime: 0 };
|
|
53
84
|
}
|
|
85
|
+
findFieldNames(tree) {
|
|
86
|
+
var _a;
|
|
87
|
+
this.fieldNames = [];
|
|
88
|
+
for (const e of tree.findAllExpressions(expressions_1.CDSElement)) {
|
|
89
|
+
let found = (_a = e.findDirectExpression(expressions_1.CDSAs)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(expressions_1.CDSName);
|
|
90
|
+
if (found === undefined) {
|
|
91
|
+
found = e.findDirectExpression(expressions_1.CDSName);
|
|
92
|
+
}
|
|
93
|
+
if (found === undefined) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
this.fieldNames.push(found === null || found === void 0 ? void 0 : found.concatTokens());
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
findSources(tree) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
this.sources = [];
|
|
102
|
+
for (const e of tree.findAllExpressions(expressions_1.CDSSource)) {
|
|
103
|
+
const name = e.getFirstToken().getStr();
|
|
104
|
+
const as = (_b = (_a = e.findDirectExpression(expressions_1.CDSAs)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(expressions_1.CDSName)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
|
|
105
|
+
this.sources.push({ name, as });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
54
108
|
}
|
|
55
109
|
exports.DataDefinition = DataDefinition;
|
|
56
110
|
//# sourceMappingURL=data_definition.js.map
|
package/build/src/registry.js
CHANGED
|
@@ -33,9 +33,9 @@ class CDSParserError {
|
|
|
33
33
|
run(o) {
|
|
34
34
|
const issues = [];
|
|
35
35
|
if (o.getType() === "DDLS" && o instanceof objects_1.DataDefinition) {
|
|
36
|
-
const
|
|
36
|
+
const hasError = o.hasParserError();
|
|
37
37
|
const file = o.findSourceFile();
|
|
38
|
-
if (
|
|
38
|
+
if (hasError === true && file) {
|
|
39
39
|
issues.push(issue_1.Issue.atRow(file, 1, "CDS Parser error", this.getMetadata().key));
|
|
40
40
|
}
|
|
41
41
|
}
|