@abaplint/core 2.83.2 → 2.83.6

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.
Files changed (38) hide show
  1. package/build/abaplint.d.ts +10 -1
  2. package/build/src/abap/types/method_parameters.js +4 -1
  3. package/build/src/cds/cds_lexer.js +25 -3
  4. package/build/src/cds/cds_parser.js +4 -1
  5. package/build/src/cds/expressions/cds_aggregate.js +13 -0
  6. package/build/src/cds/expressions/cds_annotation.js +3 -4
  7. package/build/src/cds/expressions/cds_annotation_array.js +15 -0
  8. package/build/src/cds/expressions/cds_annotation_object.js +16 -0
  9. package/build/src/cds/expressions/cds_annotation_simple.js +13 -0
  10. package/build/src/cds/expressions/cds_arithmetics.js +15 -0
  11. package/build/src/cds/expressions/cds_as.js +12 -0
  12. package/build/src/cds/expressions/cds_association.js +2 -2
  13. package/build/src/cds/expressions/cds_cardinality.js +12 -0
  14. package/build/src/cds/expressions/cds_case.js +16 -0
  15. package/build/src/cds/expressions/cds_cast.js +13 -0
  16. package/build/src/cds/expressions/cds_composition.js +13 -0
  17. package/build/src/cds/expressions/cds_condition.js +20 -0
  18. package/build/src/cds/expressions/cds_define_abstract.js +14 -0
  19. package/build/src/cds/expressions/cds_define_view.js +3 -1
  20. package/build/src/cds/expressions/cds_element.js +3 -1
  21. package/build/src/cds/expressions/cds_function.js +32 -0
  22. package/build/src/cds/expressions/cds_group_by.js +13 -0
  23. package/build/src/cds/expressions/cds_join.js +2 -1
  24. package/build/src/cds/expressions/cds_name.js +1 -1
  25. package/build/src/cds/expressions/cds_parameters.js +14 -0
  26. package/build/src/cds/expressions/cds_select.js +1 -1
  27. package/build/src/cds/expressions/cds_source.js +12 -0
  28. package/build/src/cds/expressions/cds_string.js +11 -0
  29. package/build/src/cds/expressions/cds_type.js +12 -0
  30. package/build/src/cds/expressions/cds_where.js +1 -1
  31. package/build/src/cds/expressions/cds_with_parameters.js +13 -0
  32. package/build/src/cds/expressions/index.js +20 -0
  33. package/build/src/ddl/ddl_lexer.js +1 -1
  34. package/build/src/objects/data_definition.js +62 -5
  35. package/build/src/registry.js +1 -1
  36. package/build/src/rules/7bit_ascii.js +5 -2
  37. package/build/src/rules/cds_parser_error.js +2 -2
  38. package/package.json +1 -1
@@ -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
- temporaryParse(): ExpressionNode | undefined;
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 {
@@ -105,10 +105,13 @@ class MethodParameters {
105
105
  const nameToken = (_a = node.findFirstExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
106
106
  const ooName = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr();
107
107
  const def = scope.findObjectDefinition(ooName);
108
+ const doVoid = def ? false : !scope.getDDIC().inErrorNamespace(ooName);
108
109
  if (def) {
109
110
  scope.addReference(nameToken, def, _reference_1.ReferenceType.ObjectOrientedReference, filename);
110
111
  }
111
- const doVoid = def ? false : !scope.getDDIC().inErrorNamespace(ooName);
112
+ else if (doVoid && ooName) {
113
+ scope.addReference(nameToken, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: ooName.toUpperCase() });
114
+ }
112
115
  const eventName = (_b = node.findFirstExpression(Expressions.Field)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
113
116
  const event = new _object_oriented_1.ObjectOriented(scope).searchEvent(def, eventName);
114
117
  for (const p of handler.findAllExpressions(Expressions.MethodParamName)) {
@@ -50,11 +50,14 @@ class CDSLexer {
50
50
  let row = 1;
51
51
  let col = 1;
52
52
  let build = "";
53
- const stream = new Stream(file.getRaw());
53
+ const stream = new Stream(file.getRaw().replace(/\r/g, "").replace(/\u00a0/g, " "));
54
+ let next = "";
54
55
  while (stream.length() > 0) {
55
- const next = stream.takeNext();
56
+ const prev = next;
57
+ next = stream.takeNext();
56
58
  const nextNext = stream.peekNext();
57
59
  col++;
60
+ // string handling
58
61
  if (mode === Mode.String) {
59
62
  build += next;
60
63
  if (next === "'") {
@@ -63,6 +66,7 @@ class CDSLexer {
63
66
  }
64
67
  continue;
65
68
  }
69
+ // single line comment handling
66
70
  if (mode === Mode.SingleLineComment) {
67
71
  if (next === "\n") {
68
72
  mode = Mode.Default;
@@ -74,6 +78,18 @@ class CDSLexer {
74
78
  build = result.add(build, row, col);
75
79
  continue;
76
80
  }
81
+ // multi line comment handling
82
+ if (mode === Mode.MultiLineComment) {
83
+ if (prev === "*" && next === "/") {
84
+ mode = Mode.Default;
85
+ }
86
+ continue;
87
+ }
88
+ else if (mode === Mode.Default && next === "/" && nextNext === "*") {
89
+ mode = Mode.MultiLineComment;
90
+ build = result.add(build, row, col);
91
+ continue;
92
+ }
77
93
  switch (next) {
78
94
  case "'":
79
95
  mode = Mode.String;
@@ -88,13 +104,19 @@ class CDSLexer {
88
104
  col = 0;
89
105
  break;
90
106
  case ";":
107
+ case ":":
91
108
  case ",":
92
109
  case ".":
93
110
  case "{":
94
- case ":":
95
111
  case "}":
112
+ case "(":
113
+ case ")":
96
114
  case "[":
97
115
  case "]":
116
+ case "+":
117
+ case "-":
118
+ case "*":
119
+ case "/":
98
120
  build = result.add(build, row, col);
99
121
  result.add(next, row, col);
100
122
  break;
@@ -14,7 +14,10 @@ class CDSParser {
14
14
  }
15
15
  const tokens = cds_lexer_1.CDSLexer.run(file);
16
16
  // console.dir(tokens);
17
- const res = combi_1.Combi.run(new Expressions.CDSDefineView(), tokens, version_1.defaultVersion);
17
+ let res = combi_1.Combi.run(new Expressions.CDSDefineView(), tokens, version_1.defaultVersion);
18
+ if (res === undefined || !(res[0] instanceof nodes_1.ExpressionNode)) {
19
+ res = combi_1.Combi.run(new Expressions.CDSDefineAbstract(), tokens, version_1.defaultVersion);
20
+ }
18
21
  if (res === undefined || !(res[0] instanceof nodes_1.ExpressionNode)) {
19
22
  return undefined;
20
23
  }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSAggregate = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ class CDSAggregate extends combi_1.Expression {
7
+ getRunnable() {
8
+ const value = (0, combi_1.alt)(_1.CDSName, _1.CDSCast, _1.CDSCase);
9
+ return (0, combi_1.seq)((0, combi_1.alt)("MAX", "MIN", "SUM", "AVG", "COUNT"), "(", (0, combi_1.opt)("DISTINCT"), value, ")");
10
+ }
11
+ }
12
+ exports.CDSAggregate = CDSAggregate;
13
+ //# sourceMappingURL=cds_aggregate.js.map
@@ -1,13 +1,12 @@
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");
6
+ const cds_annotation_array_1 = require("./cds_annotation_array");
5
7
  class CDSAnnotation extends combi_1.Expression {
6
8
  getRunnable() {
7
- // 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 valueList = (0, combi_1.seq)("[", value, (0, combi_1.star)((0, combi_1.seq)(",", value)), "]");
10
- return (0, combi_1.seq)((0, combi_1.regex)(/^@\w+$/), (0, combi_1.plus)((0, combi_1.seq)(".", (0, combi_1.regex)(/^\w+$/))), (0, combi_1.opt)(":"), (0, combi_1.opt)((0, combi_1.alt)(valueList, value)));
9
+ 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)(cds_annotation_array_1.CDSAnnotationArray, _1.CDSAnnotationObject, _1.CDSAnnotationSimple)));
11
10
  }
12
11
  }
13
12
  exports.CDSAnnotation = CDSAnnotation;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSAnnotationArray = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ const cds_annotation_simple_1 = require("./cds_annotation_simple");
7
+ class CDSAnnotationArray extends combi_1.Expression {
8
+ getRunnable() {
9
+ const value = (0, combi_1.alt)(cds_annotation_simple_1.CDSAnnotationSimple, _1.CDSAnnotationObject, CDSAnnotationArray);
10
+ const valueList = (0, combi_1.seq)("[", value, (0, combi_1.star)((0, combi_1.seq)(",", value)), "]");
11
+ return valueList;
12
+ }
13
+ }
14
+ exports.CDSAnnotationArray = CDSAnnotationArray;
15
+ //# sourceMappingURL=cds_annotation_array.js.map
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSAnnotationObject = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ const cds_annotation_simple_1 = require("./cds_annotation_simple");
7
+ class CDSAnnotationObject extends combi_1.Expression {
8
+ getRunnable() {
9
+ const value = (0, combi_1.alt)(CDSAnnotationObject, _1.CDSAnnotationArray, cds_annotation_simple_1.CDSAnnotationSimple);
10
+ const namedot = (0, combi_1.seq)(_1.CDSName, (0, combi_1.star)((0, combi_1.seq)(".", _1.CDSName)));
11
+ const valueNested = (0, combi_1.seq)("{", namedot, ":", value, (0, combi_1.star)((0, combi_1.seq)(",", namedot, ":", value)), "}");
12
+ return valueNested;
13
+ }
14
+ }
15
+ exports.CDSAnnotationObject = CDSAnnotationObject;
16
+ //# sourceMappingURL=cds_annotation_object.js.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSAnnotationSimple = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ class CDSAnnotationSimple extends combi_1.Expression {
7
+ getRunnable() {
8
+ const value = (0, combi_1.alt)(_1.CDSString, "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
+ return value;
10
+ }
11
+ }
12
+ exports.CDSAnnotationSimple = CDSAnnotationSimple;
13
+ //# sourceMappingURL=cds_annotation_simple.js.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSArithmetics = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ class CDSArithmetics 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
+ const val = (0, combi_1.alt)((0, combi_1.regex)(/\d+/), name, _1.CDSFunction, _1.CDSCase, _1.CDSCast, _1.CDSString);
10
+ const operator = (0, combi_1.alt)("+", "-", "*", "/");
11
+ return (0, combi_1.seq)(val, operator, val);
12
+ }
13
+ }
14
+ exports.CDSArithmetics = CDSArithmetics;
15
+ //# sourceMappingURL=cds_arithmetics.js.map
@@ -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
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CDSAssociation = void 0;
4
4
  const _1 = require(".");
5
5
  const combi_1 = require("../../abap/2_statements/combi");
6
+ const cds_cardinality_1 = require("./cds_cardinality");
6
7
  class CDSAssociation extends combi_1.Expression {
7
8
  getRunnable() {
8
- const cardinality = (0, combi_1.alt)("[0..1]", "[0..*]");
9
- return (0, combi_1.seq)("ASSOCIATION", cardinality, "TO", _1.CDSName);
9
+ return (0, combi_1.seq)("ASSOCIATION", (0, combi_1.opt)(cds_cardinality_1.CDSCardinality), "TO", (0, combi_1.opt)("PARENT"), _1.CDSName, (0, combi_1.opt)(_1.CDSAs), "ON", _1.CDSCondition);
10
10
  }
11
11
  }
12
12
  exports.CDSAssociation = CDSAssociation;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSCardinality = void 0;
4
+ const combi_1 = require("../../abap/2_statements/combi");
5
+ class CDSCardinality extends combi_1.Expression {
6
+ getRunnable() {
7
+ const cardinality = (0, combi_1.seq)("[", (0, combi_1.alt)("0", "1"), (0, combi_1.opt)((0, combi_1.seq)(".", ".", (0, combi_1.alt)("0", "1", "*"))), "]");
8
+ return cardinality;
9
+ }
10
+ }
11
+ exports.CDSCardinality = CDSCardinality;
12
+ //# sourceMappingURL=cds_cardinality.js.map
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSCase = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ class CDSCase 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
+ const value = (0, combi_1.alt)(name, _1.CDSString, _1.CDSFunction, CDSCase, _1.CDSCast, _1.CDSArithmetics);
10
+ const simple = (0, combi_1.seq)("CASE", name, (0, combi_1.plus)((0, combi_1.seq)("WHEN", value, "THEN", value)), "ELSE", value, "END");
11
+ const complex = (0, combi_1.seq)("CASE", (0, combi_1.plus)((0, combi_1.seq)("WHEN", _1.CDSCondition, "THEN", value)), (0, combi_1.opt)((0, combi_1.seq)("ELSE", value)), "END");
12
+ return (0, combi_1.alt)(simple, complex);
13
+ }
14
+ }
15
+ exports.CDSCase = CDSCase;
16
+ //# sourceMappingURL=cds_case.js.map
@@ -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, _1.CDSCase, CDSCast, _1.CDSString, _1.CDSArithmetics), "AS", _1.CDSType, (0, combi_1.opt)((0, combi_1.seq)("PRESERVING", "TYPE")), ")");
10
+ }
11
+ }
12
+ exports.CDSCast = CDSCast;
13
+ //# sourceMappingURL=cds_cast.js.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSComposition = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ const cds_cardinality_1 = require("./cds_cardinality");
7
+ class CDSComposition extends combi_1.Expression {
8
+ getRunnable() {
9
+ return (0, combi_1.seq)("COMPOSITION", (0, combi_1.opt)(cds_cardinality_1.CDSCardinality), "OF", _1.CDSName, (0, combi_1.opt)(_1.CDSAs));
10
+ }
11
+ }
12
+ exports.CDSComposition = CDSComposition;
13
+ //# sourceMappingURL=cds_composition.js.map
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSCondition = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ class CDSCondition extends combi_1.Expression {
7
+ getRunnable() {
8
+ const name = (0, combi_1.seq)(_1.CDSName, (0, combi_1.opt)((0, combi_1.seq)(".", (0, combi_1.alt)(_1.CDSName, _1.CDSString))));
9
+ const eq = (0, combi_1.seq)(name, (0, combi_1.alt)("=", "<>", "<", ">", ">=", "<="), (0, combi_1.alt)(name, _1.CDSFunction, _1.CDSString));
10
+ const isInitial = (0, combi_1.seq)(name, "IS INITIAL");
11
+ const isNotInitial = (0, combi_1.seq)(name, "IS NOT INITIAL");
12
+ const isNull = (0, combi_1.seq)(name, "IS NULL");
13
+ const isNotNull = (0, combi_1.seq)(name, "IS NOT NULL");
14
+ const condition = (0, combi_1.alt)(eq, isNull, isNotNull, isInitial, isNotInitial);
15
+ const paren = (0, combi_1.seq)("(", CDSCondition, ")");
16
+ return (0, combi_1.seq)((0, combi_1.alt)(condition, paren), (0, combi_1.star)((0, combi_1.seq)((0, combi_1.alt)("AND", "OR"), (0, combi_1.alt)(condition, paren))));
17
+ }
18
+ }
19
+ exports.CDSCondition = CDSCondition;
20
+ //# sourceMappingURL=cds_condition.js.map
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSDefineAbstract = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ const cds_name_1 = require("./cds_name");
7
+ class CDSDefineAbstract extends combi_1.Expression {
8
+ getRunnable() {
9
+ const field = (0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.str)("KEY"), cds_name_1.CDSName, ":", cds_name_1.CDSName, ";");
10
+ return (0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.str)("DEFINE ABSTRACT ENTITY"), cds_name_1.CDSName, (0, combi_1.str)("{"), (0, combi_1.plus)(field), (0, combi_1.str)("}"), (0, combi_1.opt)(";"));
11
+ }
12
+ }
13
+ exports.CDSDefineAbstract = CDSDefineAbstract;
14
+ //# sourceMappingURL=cds_define_abstract.js.map
@@ -2,12 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CDSDefineView = void 0;
4
4
  const _1 = require(".");
5
+ const __1 = require("../..");
5
6
  const combi_1 = require("../../abap/2_statements/combi");
6
7
  const cds_name_1 = require("./cds_name");
7
8
  const cds_select_1 = require("./cds_select");
9
+ const cds_with_parameters_1 = require("./cds_with_parameters");
8
10
  class CDSDefineView extends combi_1.Expression {
9
11
  getRunnable() {
10
- return (0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.str)("DEFINE VIEW"), cds_name_1.CDSName, "AS", cds_select_1.CDSSelect, (0, combi_1.opt)(";"));
12
+ return (0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), "DEFINE", (0, combi_1.opt)("ROOT"), "VIEW", (0, combi_1.ver)(__1.Version.v755, (0, combi_1.opt)("ENTITY")), cds_name_1.CDSName, (0, combi_1.opt)(cds_with_parameters_1.CDSWithParameters), "AS", cds_select_1.CDSSelect, (0, combi_1.opt)(";"));
11
13
  }
12
14
  }
13
15
  exports.CDSDefineView = CDSDefineView;
@@ -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"), _1.CDSName, (0, combi_1.optPrio)((0, combi_1.seq)("AS", _1.CDSName)));
10
+ return (0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.optPrio)("KEY"), (0, combi_1.alt)((0, combi_1.seq)(_1.CDSName, (0, combi_1.opt)(_1.CDSParameters), (0, combi_1.star)((0, combi_1.seq)(".", _1.CDSName, (0, combi_1.opt)(_1.CDSParameters)))), cds_cast_1.CDSCast, _1.CDSAggregate, _1.CDSString, _1.CDSFunction, (0, combi_1.regex)(/^\d+$/), _1.CDSArithmetics, _1.CDSCase), (0, combi_1.opt)(cds_as_1.CDSAs));
9
11
  }
10
12
  }
11
13
  exports.CDSElement = CDSElement;
@@ -0,0 +1,32 @@
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 qualified = (0, combi_1.seq)(_1.CDSName, (0, combi_1.opt)(_1.CDSParameters), (0, combi_1.star)((0, combi_1.seq)(".", _1.CDSName, (0, combi_1.opt)(_1.CDSParameters))));
9
+ const input = (0, combi_1.alt)(qualified, (0, combi_1.regex)(/^\d+$/), _1.CDSCast, CDSFunction, _1.CDSArithmetics, _1.CDSCase, _1.CDSString);
10
+ const coalesce = (0, combi_1.seq)("COALESCE", "(", input, ",", input, ")");
11
+ const concat = (0, combi_1.seq)("CONCAT", "(", input, ",", input, ")");
12
+ const concat_with_space = (0, combi_1.seq)("CONCAT_WITH_SPACE", "(", input, ",", input, ",", input, ")");
13
+ const dats_add_days = (0, combi_1.seq)("DATS_ADD_DAYS", "(", input, ",", input, ",", input, ")");
14
+ const dats_add_months = (0, combi_1.seq)("DATS_ADD_MONTHS", "(", input, ",", input, ",", input, ")");
15
+ const dats_days_between = (0, combi_1.seq)("DATS_DAYS_BETWEEN", "(", input, ",", input, ")");
16
+ const dats_is_valid = (0, combi_1.seq)("DATS_IS_VALID", "(", input, ")");
17
+ const substring = (0, combi_1.seq)("SUBSTRING", "(", input, ",", input, ",", input, ")");
18
+ const tstmp_to_dats = (0, combi_1.seq)("TSTMP_TO_DATS", "(", input, ",", input, ",", input, ",", input, ")");
19
+ const tstmp_to_tims = (0, combi_1.seq)("TSTMP_TO_TIMS", "(", input, ",", input, ",", input, ",", input, ")");
20
+ const tstmp_to_dst = (0, combi_1.seq)("TSTMP_TO_DST", "(", input, ",", input, ",", input, ",", input, ")");
21
+ const dats_tims_to_tstmp = (0, combi_1.seq)("DATS_TIMS_TO_TSTMP", "(", input, ",", input, ",", input, ",", input, ",", input, ")");
22
+ const tstmp_is_valid = (0, combi_1.seq)("TSTMP_IS_VALID", "(", input, ")");
23
+ const tstmp_current_utctimestamp = (0, combi_1.seq)("TSTMP_CURRENT_UTCTIMESTAMP", "(", ")");
24
+ const tstmp_seconds_between = (0, combi_1.seq)("TSTMP_SECONDS_BETWEEN", "(", input, ",", input, ",", input, ")");
25
+ const tstmp_add_seconds = (0, combi_1.seq)("TSTMP_ADD_SECONDS", "(", input, ",", input, ",", input, ")");
26
+ const abap_system_timezone = (0, combi_1.seq)("ABAP_SYSTEM_TIMEZONE", "(", input, ",", input, ")");
27
+ const abap_user_timezone = (0, combi_1.seq)("ABAP_USER_TIMEZONE", "(", input, ",", input, ",", input, ")");
28
+ return (0, combi_1.alt)(substring, coalesce, tstmp_to_dats, concat, tstmp_to_tims, concat_with_space, dats_is_valid, dats_days_between, tstmp_add_seconds, tstmp_seconds_between, tstmp_current_utctimestamp, tstmp_is_valid, abap_system_timezone, abap_user_timezone, dats_add_days, dats_add_months, tstmp_to_dst, dats_tims_to_tstmp);
29
+ }
30
+ }
31
+ exports.CDSFunction = CDSFunction;
32
+ //# sourceMappingURL=cds_function.js.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSGroupBy = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ class CDSGroupBy extends combi_1.Expression {
7
+ getRunnable() {
8
+ const name = (0, combi_1.seq)(_1.CDSName, (0, combi_1.star)((0, combi_1.seq)(".", _1.CDSName)));
9
+ return (0, combi_1.seq)("GROUP BY", name, (0, combi_1.star)((0, combi_1.seq)(",", name)));
10
+ }
11
+ }
12
+ exports.CDSGroupBy = CDSGroupBy;
13
+ //# sourceMappingURL=cds_group_by.js.map
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CDSJoin = void 0;
4
4
  const _1 = require(".");
5
5
  const combi_1 = require("../../abap/2_statements/combi");
6
+ const cds_condition_1 = require("./cds_condition");
6
7
  class CDSJoin extends combi_1.Expression {
7
8
  getRunnable() {
8
- return (0, combi_1.seq)("INNER JOIN", _1.CDSName);
9
+ return (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.alt)("INNER", "LEFT OUTER", "LEFT OUTER TO ONE")), "JOIN", _1.CDSSource, "ON", cds_condition_1.CDSCondition);
9
10
  }
10
11
  }
11
12
  exports.CDSJoin = CDSJoin;
@@ -4,7 +4,7 @@ exports.CDSName = void 0;
4
4
  const combi_1 = require("../../abap/2_statements/combi");
5
5
  class CDSName extends combi_1.Expression {
6
6
  getRunnable() {
7
- return (0, combi_1.regex)(/^\$?[\w_]+$/);
7
+ return (0, combi_1.seq)((0, combi_1.opt)(":"), (0, combi_1.regex)(/^\$?#?[\w_]+$/));
8
8
  }
9
9
  }
10
10
  exports.CDSName = CDSName;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSParameters = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ class CDSParameters 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
+ const value = (0, combi_1.alt)(name, _1.CDSString);
10
+ return (0, combi_1.seq)("[", (0, combi_1.regex)(/\d+/), ":", name, "=", value, (0, combi_1.star)((0, combi_1.seq)("AND", name, "=", value)), "]");
11
+ }
12
+ }
13
+ exports.CDSParameters = CDSParameters;
14
+ //# sourceMappingURL=cds_parameters.js.map
@@ -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.CDSName, (0, combi_1.opt)((0, combi_1.seq)("AS", _1.CDSName)), (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));
11
+ return (0, combi_1.seq)("SELECT", (0, combi_1.opt)("DISTINCT"), "FROM", _1.CDSSource, (0, combi_1.star)(cds_join_1.CDSJoin), (0, combi_1.star)(_1.CDSComposition), (0, combi_1.star)(cds_association_1.CDSAssociation), (0, combi_1.star)(_1.CDSComposition), (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.CDSGroupBy), (0, combi_1.opt)(_1.CDSWhere), (0, combi_1.opt)((0, combi_1.seq)("UNION", (0, combi_1.opt)("ALL"), CDSSelect)));
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
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSString = void 0;
4
+ const combi_1 = require("../../abap/2_statements/combi");
5
+ class CDSString extends combi_1.Expression {
6
+ getRunnable() {
7
+ return (0, combi_1.regex)(/^'[\w: -_]*'$/);
8
+ }
9
+ }
10
+ exports.CDSString = CDSString;
11
+ //# sourceMappingURL=cds_string.js.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSType = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ class CDSType extends combi_1.Expression {
7
+ getRunnable() {
8
+ return (0, combi_1.seq)(_1.CDSName, (0, combi_1.opt)((0, combi_1.seq)(".", _1.CDSName)), (0, combi_1.opt)((0, combi_1.seq)("(", (0, combi_1.regex)(/\d+/), ")")));
9
+ }
10
+ }
11
+ exports.CDSType = CDSType;
12
+ //# sourceMappingURL=cds_type.js.map
@@ -5,7 +5,7 @@ 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
- return (0, combi_1.seq)("WHERE", _1.CDSName, "=", _1.CDSName, (0, combi_1.star)((0, combi_1.seq)(".", _1.CDSName)));
8
+ return (0, combi_1.seq)("WHERE", _1.CDSCondition);
9
9
  }
10
10
  }
11
11
  exports.CDSWhere = CDSWhere;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CDSWithParameters = void 0;
4
+ const _1 = require(".");
5
+ const combi_1 = require("../../abap/2_statements/combi");
6
+ class CDSWithParameters extends combi_1.Expression {
7
+ getRunnable() {
8
+ const param = (0, combi_1.seq)(_1.CDSName, ":", _1.CDSType);
9
+ return (0, combi_1.seq)("wITH PARAMETERS", param, (0, combi_1.star)((0, combi_1.seq)(",", param)));
10
+ }
11
+ }
12
+ exports.CDSWithParameters = CDSWithParameters;
13
+ //# sourceMappingURL=cds_with_parameters.js.map
@@ -10,12 +10,32 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./cds_aggregate"), exports);
14
+ __exportStar(require("./cds_aggregate"), exports);
15
+ __exportStar(require("./cds_annotation_array"), exports);
16
+ __exportStar(require("./cds_annotation_object"), exports);
17
+ __exportStar(require("./cds_annotation_simple"), exports);
13
18
  __exportStar(require("./cds_annotation"), exports);
19
+ __exportStar(require("./cds_arithmetics"), exports);
20
+ __exportStar(require("./cds_as"), exports);
14
21
  __exportStar(require("./cds_association"), exports);
22
+ __exportStar(require("./cds_cardinality"), exports);
23
+ __exportStar(require("./cds_case"), exports);
24
+ __exportStar(require("./cds_cast"), exports);
25
+ __exportStar(require("./cds_composition"), exports);
26
+ __exportStar(require("./cds_condition"), exports);
27
+ __exportStar(require("./cds_define_abstract"), exports);
15
28
  __exportStar(require("./cds_define_view"), exports);
16
29
  __exportStar(require("./cds_element"), exports);
30
+ __exportStar(require("./cds_function"), exports);
31
+ __exportStar(require("./cds_group_by"), exports);
17
32
  __exportStar(require("./cds_join"), exports);
18
33
  __exportStar(require("./cds_name"), exports);
34
+ __exportStar(require("./cds_parameters"), exports);
19
35
  __exportStar(require("./cds_select"), exports);
36
+ __exportStar(require("./cds_source"), exports);
37
+ __exportStar(require("./cds_string"), exports);
38
+ __exportStar(require("./cds_type"), exports);
20
39
  __exportStar(require("./cds_where"), exports);
40
+ __exportStar(require("./cds_with_parameters"), exports);
21
41
  //# sourceMappingURL=index.js.map
@@ -6,7 +6,7 @@ const position_1 = require("../position");
6
6
  class DDLLexer {
7
7
  static run(file) {
8
8
  const step1 = [];
9
- const lines = file.getRaw().replace(/\c/g, "").split("\n");
9
+ const lines = file.getRaw().replace(/\r/g, "").split("\n");
10
10
  for (const l of lines) {
11
11
  if (l.startsWith("@")) {
12
12
  continue; // skip annotations for now
@@ -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,30 +30,83 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
26
30
  return undefined;
27
31
  }
28
32
  parseType(_reg) {
29
- // todo
30
- return new basic_1.VoidType("DDLS:todo");
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
- temporaryParse() {
40
- return new cds_parser_1.CDSParser().parse(this.findSourceFile());
61
+ hasParserError() {
62
+ return this.parserError;
41
63
  }
42
64
  parse() {
43
65
  var _a;
44
66
  if (this.isDirty() === false) {
45
67
  return { updated: false, runtime: 0 };
46
68
  }
69
+ const start = Date.now();
47
70
  this.sqlViewName = undefined;
48
71
  const match = (_a = this.findSourceFile()) === null || _a === void 0 ? void 0 : _a.getRaw().match(/@AbapCatalog\.sqlViewName: '(\w+)'/);
49
72
  if (match) {
50
73
  this.sqlViewName = match[1].toUpperCase();
51
74
  }
52
- return { updated: true, runtime: 0 };
75
+ const tree = new cds_parser_1.CDSParser().parse(this.findSourceFile());
76
+ if (tree) {
77
+ this.findFieldNames(tree);
78
+ this.findSources(tree);
79
+ }
80
+ else {
81
+ this.parserError = true;
82
+ }
83
+ const end = Date.now();
84
+ this.dirty = false;
85
+ return { updated: true, runtime: end - start };
86
+ }
87
+ findFieldNames(tree) {
88
+ var _a;
89
+ this.fieldNames = [];
90
+ for (const e of tree.findAllExpressions(expressions_1.CDSElement)) {
91
+ let found = (_a = e.findDirectExpression(expressions_1.CDSAs)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(expressions_1.CDSName);
92
+ if (found === undefined) {
93
+ const list = e.findDirectExpressions(expressions_1.CDSName);
94
+ found = list[list.length - 1];
95
+ }
96
+ if (found === undefined) {
97
+ continue;
98
+ }
99
+ this.fieldNames.push(found === null || found === void 0 ? void 0 : found.concatTokens());
100
+ }
101
+ }
102
+ findSources(tree) {
103
+ var _a, _b;
104
+ this.sources = [];
105
+ for (const e of tree.findAllExpressions(expressions_1.CDSSource)) {
106
+ const name = e.getFirstToken().getStr();
107
+ 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();
108
+ this.sources.push({ name, as });
109
+ }
53
110
  }
54
111
  }
55
112
  exports.DataDefinition = DataDefinition;
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.83.2";
71
+ return "2.83.6";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -17,7 +17,9 @@ class SevenBitAscii {
17
17
  key: "7bit_ascii",
18
18
  title: "Check for 7bit ascii",
19
19
  shortDescription: `Only allow characters from the 7bit ASCII set.`,
20
- extendedInformation: `https://docs.abapopenchecks.org/checks/05/`,
20
+ extendedInformation: `https://docs.abapopenchecks.org/checks/05/
21
+
22
+ Checkes files with extension ".abap" and ".asddls"`,
21
23
  tags: [_irule_1.RuleTag.SingleFile],
22
24
  };
23
25
  }
@@ -33,7 +35,8 @@ class SevenBitAscii {
33
35
  run(obj) {
34
36
  const output = [];
35
37
  for (const file of obj.getFiles()) {
36
- if (file.getFilename().endsWith(".abap")) {
38
+ const filename = file.getFilename();
39
+ if (filename.endsWith(".abap") || filename.endsWith(".asddls")) {
37
40
  const rows = file.getRawRows();
38
41
  for (let i = 0; i < rows.length; i++) {
39
42
  const found = /[\u007f-\uffff]/.exec(rows[i]);
@@ -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 result = o.temporaryParse();
36
+ const hasError = o.hasParserError();
37
37
  const file = o.findSourceFile();
38
- if (result === undefined && file) {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.83.2",
3
+ "version": "2.83.6",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",