@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.
@@ -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 {
@@ -88,11 +88,13 @@ class CDSLexer {
88
88
  col = 0;
89
89
  break;
90
90
  case ";":
91
+ case ":":
91
92
  case ",":
92
93
  case ".":
93
94
  case "{":
94
- case ":":
95
95
  case "}":
96
+ case "(":
97
+ case ")":
96
98
  case "[":
97
99
  case "]":
98
100
  build = result.add(build, row, col);
@@ -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
- 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)));
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.alt)("[0..1]", "[0..*]");
9
- return (0, combi_1.seq)("ASSOCIATION", cardinality, "TO", _1.CDSName);
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"), _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)(_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
- return (0, combi_1.seq)("INNER JOIN", _1.CDSName);
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.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)((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
- return (0, combi_1.seq)("WHERE", _1.CDSName, "=", _1.CDSName, (0, combi_1.star)((0, combi_1.seq)(".", _1.CDSName)));
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
- // 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;
@@ -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
@@ -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.3";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -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.3",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",