@abaplint/core 2.89.9 → 2.89.12

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.
@@ -34,7 +34,7 @@ class Cast {
34
34
  throw new Error("Type \"" + typeName + "\" not found in scope, Cast");
35
35
  }
36
36
  else {
37
- tt = new basic_1.ObjectReferenceType(found);
37
+ tt = new basic_1.ObjectReferenceType(found, typeName);
38
38
  }
39
39
  }
40
40
  new source_1.Source().addIfInferred(node, scope, filename, tt);
@@ -4,11 +4,15 @@ exports.Compare = void 0;
4
4
  const Expressions = require("../../2_statements/expressions");
5
5
  const source_1 = require("./source");
6
6
  const method_call_chain_1 = require("./method_call_chain");
7
+ const source_field_symbol_1 = require("./source_field_symbol");
7
8
  class Compare {
8
9
  runSyntax(node, scope, filename) {
9
10
  for (const t of node.findDirectExpressions(Expressions.Source)) {
10
11
  new source_1.Source().runSyntax(t, scope, filename);
11
12
  }
13
+ for (const t of node.findDirectExpressions(Expressions.SourceFieldSymbol)) {
14
+ new source_field_symbol_1.SourceFieldSymbol().runSyntax(t, scope, filename);
15
+ }
12
16
  for (const t of node.findDirectExpressions(Expressions.MethodCallChain)) {
13
17
  new method_call_chain_1.MethodCallChain().runSyntax(t, scope, filename);
14
18
  }
@@ -13,6 +13,7 @@ const field_length_1 = require("./field_length");
13
13
  const table_expression_1 = require("./table_expression");
14
14
  const expressions_1 = require("../../2_statements/expressions");
15
15
  const dereference_1 = require("./dereference");
16
+ const source_field_symbol_1 = require("./source_field_symbol");
16
17
  class FieldChain {
17
18
  runSyntax(node, scope, filename, refType) {
18
19
  const concat = node.concatTokens();
@@ -102,8 +103,11 @@ class FieldChain {
102
103
  if (node === undefined) {
103
104
  return undefined;
104
105
  }
105
- if (node.get() instanceof Expressions.SourceField
106
- || node.get() instanceof Expressions.SourceFieldSymbol) {
106
+ if (node instanceof nodes_1.ExpressionNode
107
+ && node.get() instanceof Expressions.SourceFieldSymbol) {
108
+ return new source_field_symbol_1.SourceFieldSymbol().runSyntax(node, scope, filename);
109
+ }
110
+ else if (node.get() instanceof Expressions.SourceField) {
107
111
  const token = node.getFirstToken();
108
112
  const name = token.getStr();
109
113
  const found = scope.findVariable(name);
@@ -121,7 +125,7 @@ class FieldChain {
121
125
  }
122
126
  return found.getType();
123
127
  }
124
- if (node.get() instanceof Expressions.ClassName) {
128
+ else if (node.get() instanceof Expressions.ClassName) {
125
129
  const classTok = node.getFirstToken();
126
130
  const classNam = classTok.getStr();
127
131
  if (classNam.toUpperCase() === "OBJECT") {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FieldLength = void 0;
4
4
  const Expressions = require("../../2_statements/expressions");
5
5
  const _reference_1 = require("../_reference");
6
+ const source_field_symbol_1 = require("./source_field_symbol");
6
7
  class FieldLength {
7
8
  runSyntax(node, scope, filename) {
8
9
  const field = node.findDirectExpression(Expressions.SourceField);
@@ -16,12 +17,7 @@ class FieldLength {
16
17
  }
17
18
  const symbol = node.findDirectExpression(Expressions.SourceFieldSymbol);
18
19
  if (symbol) {
19
- const token = symbol.getFirstToken();
20
- const found = scope.findVariable(token.getStr());
21
- if (found === undefined) {
22
- throw new Error("\"" + symbol.getFirstToken().getStr() + "\" not found, FieldLength");
23
- }
24
- scope.addReference(token, found, _reference_1.ReferenceType.DataReadReference, filename);
20
+ new source_field_symbol_1.SourceFieldSymbol().runSyntax(symbol, scope, filename);
25
21
  }
26
22
  }
27
23
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FieldOffset = void 0;
4
4
  const Expressions = require("../../2_statements/expressions");
5
5
  const _reference_1 = require("../_reference");
6
+ const source_field_symbol_1 = require("./source_field_symbol");
6
7
  class FieldOffset {
7
8
  runSyntax(node, scope, filename) {
8
9
  const field = node.findDirectExpression(Expressions.SourceField);
@@ -16,12 +17,7 @@ class FieldOffset {
16
17
  }
17
18
  const symbol = node.findDirectExpression(Expressions.SourceFieldSymbol);
18
19
  if (symbol) {
19
- const token = symbol.getFirstToken();
20
- const found = scope.findVariable(token.getStr());
21
- if (found === undefined) {
22
- throw new Error("\"" + symbol.getFirstToken().getStr() + "\" not found, FieldOffset");
23
- }
24
- scope.addReference(token, found, _reference_1.ReferenceType.DataReadReference, filename);
20
+ new source_field_symbol_1.SourceFieldSymbol().runSyntax(symbol, scope, filename);
25
21
  }
26
22
  }
27
23
  }
@@ -124,6 +124,9 @@ class Source {
124
124
  if (foundType === undefined || foundType.isGeneric()) {
125
125
  this.addIfInferred(node, scope, filename, bodyType);
126
126
  }
127
+ else {
128
+ this.addIfInferred(node, scope, filename, foundType);
129
+ }
127
130
  return foundType ? foundType : bodyType;
128
131
  }
129
132
  default:
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SourceFieldSymbol = void 0;
4
+ const _reference_1 = require("../_reference");
5
+ class SourceFieldSymbol {
6
+ runSyntax(node, scope, filename) {
7
+ const token = node.getFirstToken();
8
+ const found = scope.findVariable(token.getStr());
9
+ if (found === undefined) {
10
+ throw new Error("\"" + node.getFirstToken().getStr() + "\" not found, SourceFieldSymbol");
11
+ }
12
+ scope.addReference(token, found, _reference_1.ReferenceType.DataReadReference, filename);
13
+ return found.getType();
14
+ }
15
+ }
16
+ exports.SourceFieldSymbol = SourceFieldSymbol;
17
+ //# sourceMappingURL=source_field_symbol.js.map
@@ -8,6 +8,7 @@ const basic_1 = require("../../types/basic");
8
8
  const _typed_identifier_1 = require("../../types/_typed_identifier");
9
9
  const _reference_1 = require("../_reference");
10
10
  const enum_type_1 = require("../../types/basic/enum_type");
11
+ const _scope_type_1 = require("../_scope_type");
11
12
  class TypeEnum {
12
13
  runSyntax(node, scope, filename) {
13
14
  var _a;
@@ -48,7 +49,12 @@ class TypeEnum {
48
49
  }
49
50
  const name = begin.findFirstExpression(Expressions.NamespaceSimpleName);
50
51
  if (name) {
51
- const id = new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), filename, new enum_type_1.EnumType(), ["enum" /* Enum */]);
52
+ let qualifiedName = name.concatTokens();
53
+ if (scope.getType() === _scope_type_1.ScopeType.ClassDefinition
54
+ || scope.getType() === _scope_type_1.ScopeType.Interface) {
55
+ qualifiedName = scope.getName() + "=>" + qualifiedName;
56
+ }
57
+ const id = new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), filename, new enum_type_1.EnumType(qualifiedName), ["enum" /* Enum */]);
52
58
  scope.addType(id);
53
59
  types.push(id);
54
60
  }
@@ -10,7 +10,7 @@ class EnumType extends _abstract_type_1.AbstractType {
10
10
  return false;
11
11
  }
12
12
  toABAP() {
13
- return "enum";
13
+ return this.getQualifiedName() || "enum";
14
14
  }
15
15
  containsVoid() {
16
16
  return false;
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.89.9";
71
+ return "2.89.12";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -1305,7 +1305,7 @@ ${indentation} output = ${topTarget}.`;
1305
1305
  }
1306
1306
  return ret;
1307
1307
  }
1308
- findType(i, lowFile, highSyntax) {
1308
+ findType(i, lowFile, highSyntax, ref = false) {
1309
1309
  var _a;
1310
1310
  const expr = i.findDirectExpression(Expressions.TypeNameOrInfer);
1311
1311
  if (expr === undefined) {
@@ -1314,7 +1314,7 @@ ${indentation} output = ${topTarget}.`;
1314
1314
  const firstToken = expr.getFirstToken();
1315
1315
  const concat = expr.concatTokens().toLowerCase();
1316
1316
  if (concat !== "#") {
1317
- return concat;
1317
+ return ref ? "REF TO " + concat : concat;
1318
1318
  }
1319
1319
  const spag = highSyntax.spaghetti.lookupPosition(firstToken.getStart(), lowFile.getFilename());
1320
1320
  if (spag === undefined) {
@@ -1333,7 +1333,12 @@ ${indentation} output = ${topTarget}.`;
1333
1333
  if (inferred === undefined) {
1334
1334
  return undefined;
1335
1335
  }
1336
- return (_a = inferred.getType().getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
1336
+ if (inferred.getType() instanceof basic_1.ObjectReferenceType) {
1337
+ return inferred.getType().toABAP();
1338
+ }
1339
+ else {
1340
+ return (_a = inferred.getType().getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
1341
+ }
1337
1342
  }
1338
1343
  outlineFS(node, lowFile, highSyntax) {
1339
1344
  var _a, _b;
@@ -1519,9 +1524,9 @@ ${indentation} output = ${topTarget}.`;
1519
1524
  var _a;
1520
1525
  for (const i of node.findAllExpressionsRecursive(Expressions.Cast)) {
1521
1526
  const uniqueName = this.uniqueName(i.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1522
- const type = this.findType(i, lowFile, highSyntax);
1527
+ const type = this.findType(i, lowFile, highSyntax, true);
1523
1528
  const body = (_a = i.findDirectExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
1524
- const abap = `DATA ${uniqueName} TYPE REF TO ${type}.\n` +
1529
+ const abap = `DATA ${uniqueName} TYPE ${type}.\n` +
1525
1530
  " ".repeat(node.getFirstToken().getStart().getCol() - 1) +
1526
1531
  `${uniqueName} ?= ${body}.\n` +
1527
1532
  " ".repeat(node.getFirstToken().getStart().getCol() - 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.89.9",
3
+ "version": "2.89.12",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -48,7 +48,7 @@
48
48
  "@microsoft/api-extractor": "^7.23.0",
49
49
  "@types/chai": "^4.3.1",
50
50
  "@types/mocha": "^9.1.1",
51
- "@types/node": "^17.0.26",
51
+ "@types/node": "^17.0.27",
52
52
  "chai": "^4.3.6",
53
53
  "eslint": "^8.14.0",
54
54
  "mocha": "^9.2.2",