@abaplint/core 2.95.33 → 2.95.35

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.
@@ -10,13 +10,14 @@ class TypeTable extends combi_1.Expression {
10
10
  getRunnable() {
11
11
  const header = "WITH HEADER LINE";
12
12
  const initial = (0, combi_1.seq)("INITIAL SIZE", _1.Constant);
13
- const normal1 = (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.alt)("STANDARD", "HASHED", "INDEX", "SORTED", "ANY")), "TABLE", (0, combi_1.opt)("OF"), (0, combi_1.opt)("REF TO"), (0, combi_1.opt)(_1.TypeName));
13
+ const generic = (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.alt)("STANDARD", "HASHED", "INDEX", "SORTED", "ANY")), "TABLE");
14
+ const normal1 = (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.alt)("STANDARD", "HASHED", "INDEX", "SORTED", "ANY")), "TABLE OF", (0, combi_1.opt)("REF TO"), (0, combi_1.opt)(_1.TypeName));
14
15
  const likeType = (0, combi_1.seq)((0, combi_1.opt)((0, combi_1.alt)("STANDARD", "HASHED", "INDEX", "SORTED", "ANY")), "TABLE OF", (0, combi_1.optPrio)("REF TO"), (0, combi_1.opt)(field_chain_1.FieldChain), (0, combi_1.opt)((0, combi_1.per)(header, initial, (0, combi_1.plusPrio)(type_table_key_1.TypeTableKey))));
15
16
  const rangeType = (0, combi_1.seq)("RANGE OF", _1.TypeName, (0, combi_1.opt)(header), (0, combi_1.opt)(initial));
16
17
  const rangeLike = (0, combi_1.seq)("RANGE OF", _1.SimpleFieldChain, (0, combi_1.opt)(header), (0, combi_1.opt)(initial));
17
18
  // a maximum of 15 secondary table keys can be defined
18
19
  // "WITH" is not allowed as a field name in keys
19
- const typetable = (0, combi_1.seq)(normal1, (0, combi_1.alt)((0, combi_1.opt)((0, combi_1.per)(header, initial, (0, combi_1.plusPrio)(type_table_key_1.TypeTableKey))), (0, combi_1.seq)((0, combi_1.plus)(type_table_key_1.TypeTableKey), (0, combi_1.optPrio)(initial))));
20
+ const typetable = (0, combi_1.alt)(generic, (0, combi_1.seq)(normal1, (0, combi_1.alt)((0, combi_1.opt)((0, combi_1.per)(header, initial, (0, combi_1.plusPrio)(type_table_key_1.TypeTableKey))), (0, combi_1.seq)((0, combi_1.plus)(type_table_key_1.TypeTableKey), (0, combi_1.optPrio)(initial)))));
20
21
  const occurs = (0, combi_1.seq)("OCCURS", _1.Integer);
21
22
  const derived = (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.seq)("TABLE FOR", (0, combi_1.altPrio)("ACTION IMPORT", "ACTION RESULT", "CREATE", "FAILED", "LOCK", "READ RESULT", "UPDATE"), _1.TypeName));
22
23
  const oldType = (0, combi_1.seq)((0, combi_1.opt)("REF TO"), _1.TypeName, (0, combi_1.alt)((0, combi_1.seq)(occurs, (0, combi_1.opt)(header)), header));
@@ -287,17 +287,24 @@ class BasicTypes {
287
287
  }
288
288
  const typeTableKeys = node.findAllExpressions(expressions_1.TypeTableKey);
289
289
  const firstKey = typeTableKeys[0];
290
+ const isNamed = (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpression(expressions_1.Field)) !== undefined;
290
291
  const primaryKey = {
291
292
  name: "primary_key",
292
293
  type: type,
293
- isUnique: (firstKey === null || firstKey === void 0 ? void 0 : firstKey.concatTokens().toUpperCase().includes("WITH UNIQUE ")) === true,
294
+ isUnique: isNamed ? false : (firstKey === null || firstKey === void 0 ? void 0 : firstKey.concatTokens().toUpperCase().includes("WITH UNIQUE ")) === true,
294
295
  keyFields: [],
295
296
  };
296
- for (const k of (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpressions(expressions_1.FieldSub)) || []) {
297
- primaryKey.keyFields.push(k.concatTokens().toUpperCase());
297
+ let start = 1;
298
+ if (isNamed === false) {
299
+ for (const k of (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpressions(expressions_1.FieldSub)) || []) {
300
+ primaryKey.keyFields.push(k.concatTokens().toUpperCase());
301
+ }
302
+ }
303
+ else {
304
+ start = 0;
298
305
  }
299
306
  const secondaryKeys = [];
300
- for (let i = 1; i < typeTableKeys.length; i++) {
307
+ for (let i = start; i < typeTableKeys.length; i++) {
301
308
  const row = typeTableKeys[i];
302
309
  const name = (_b = row.findDirectExpression(expressions_1.Field)) === null || _b === void 0 ? void 0 : _b.concatTokens();
303
310
  if (name === undefined) {
@@ -684,6 +691,9 @@ class BasicTypes {
684
691
  return new Types.UnknownType("Not a structured type");
685
692
  }
686
693
  foundType = foundType.getComponentByName(subs[0]);
694
+ if (foundType === undefined) {
695
+ return new Types.UnknownType(`Field "${subs[0]}" not found in structure`);
696
+ }
687
697
  subs.shift();
688
698
  }
689
699
  return foundType;
@@ -14,6 +14,10 @@ class DataReference extends _abstract_type_1.AbstractType {
14
14
  return this.type;
15
15
  }
16
16
  toABAP() {
17
+ const type = this.type.toABAP();
18
+ if (type.includes(" TABLE OF ")) {
19
+ return ""; // hmm, should this return undefined?
20
+ }
17
21
  return "REF TO " + this.type.toABAP();
18
22
  }
19
23
  isGeneric() {
@@ -12,9 +12,13 @@ var TableAccessType;
12
12
  })(TableAccessType = exports.TableAccessType || (exports.TableAccessType = {}));
13
13
  class TableType extends _abstract_type_1.AbstractType {
14
14
  constructor(rowType, options, qualifiedName) {
15
+ var _a;
15
16
  super({ qualifiedName: qualifiedName });
16
17
  this.rowType = rowType;
17
18
  this.options = options;
19
+ if (((_a = options.primaryKey) === null || _a === void 0 ? void 0 : _a.type) === TableAccessType.standard && options.primaryKey.isUnique === true) {
20
+ throw new Error("STANDARD tables cannot have UNIQUE key");
21
+ }
18
22
  }
19
23
  getOptions() {
20
24
  return this.options;
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.95.33";
66
+ return "2.95.35";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
@@ -1545,7 +1545,7 @@ ${indentation} output = ${topTarget}.`;
1545
1545
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
1546
1546
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Outline LOOP input", this.getMetadata().key, this.conf.severity, fix);
1547
1547
  }
1548
- outlineLoopTarget(node, lowFile, _highSyntax) {
1548
+ outlineLoopTarget(node, lowFile, highSyntax) {
1549
1549
  var _a, _b, _c, _d, _e, _f, _g;
1550
1550
  // also allows outlining of voided types
1551
1551
  if (!(node.get() instanceof Statements.Loop)) {
@@ -1556,16 +1556,19 @@ ${indentation} output = ${topTarget}.`;
1556
1556
  return undefined;
1557
1557
  }
1558
1558
  const concat = node.concatTokens().toUpperCase();
1559
- if (concat.includes(" REFERENCE INTO ")
1560
- || concat.includes(" GROUP BY ")
1561
- || concat.startsWith("LOOP AT GROUP ")) {
1559
+ if (concat.includes(" GROUP BY ") || concat.startsWith("LOOP AT GROUP ")) {
1562
1560
  return undefined;
1563
1561
  }
1562
+ const isReference = concat.includes(" REFERENCE INTO ");
1564
1563
  const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
1565
1564
  const dataTarget = (_c = (_b = node.findDirectExpression(Expressions.LoopTarget)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.Target)) === null || _c === void 0 ? void 0 : _c.findDirectExpression(Expressions.InlineData);
1566
1565
  if (dataTarget) {
1567
1566
  const targetName = ((_d = dataTarget.findDirectExpression(Expressions.TargetField)) === null || _d === void 0 ? void 0 : _d.concatTokens()) || "DOWNPORT_ERROR";
1568
- const code = `DATA ${targetName} LIKE LINE OF ${sourceName}.\n${indentation}`;
1567
+ let code = `DATA ${targetName} LIKE LINE OF ${sourceName}.\n${indentation}`;
1568
+ if (isReference) {
1569
+ const likeName = this.uniqueName(node.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1570
+ code = `DATA ${likeName} LIKE LINE OF ${sourceName}.\n${indentation}DATA ${targetName} LIKE REF TO ${likeName}.\n${indentation}`;
1571
+ }
1569
1572
  const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
1570
1573
  const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, dataTarget.getFirstToken().getStart(), dataTarget.getLastToken().getEnd(), targetName);
1571
1574
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
@@ -2173,10 +2176,15 @@ ${indentation} output = ${topTarget}.`;
2173
2176
  else if (found.getType() instanceof basic_1.VoidType && found.getType().getQualifiedName() === undefined) {
2174
2177
  continue;
2175
2178
  }
2176
- let type = found.getType().getQualifiedName() ? (_b = found.getType().getQualifiedName()) === null || _b === void 0 ? void 0 : _b.toLowerCase() : found.getType().toABAP();
2179
+ let type = found.getType().getQualifiedName()
2180
+ ? (_b = found.getType().getQualifiedName()) === null || _b === void 0 ? void 0 : _b.toLowerCase()
2181
+ : found.getType().toABAP();
2177
2182
  if (found.getType() instanceof basic_1.ObjectReferenceType) {
2178
2183
  type = found.getType().toABAP();
2179
2184
  }
2185
+ if (type === "") {
2186
+ continue;
2187
+ }
2180
2188
  const code = `DATA ${name} TYPE ${type}.\n` +
2181
2189
  " ".repeat(node.getFirstToken().getStart().getCol() - 1);
2182
2190
  const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.95.33",
3
+ "version": "2.95.35",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",