@abaplint/core 2.95.35 → 2.95.37

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.
@@ -1,29 +1,80 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentChain = void 0;
4
+ const Expressions = require("../../2_statements/expressions");
4
5
  const void_type_1 = require("../../types/basic/void_type");
5
6
  const structure_type_1 = require("../../types/basic/structure_type");
7
+ const basic_1 = require("../../types/basic");
8
+ const types_1 = require("../../types");
9
+ const _reference_1 = require("../_reference");
6
10
  class ComponentChain {
7
- runSyntax(context, node) {
8
- if (context instanceof void_type_1.VoidType) {
9
- return context;
10
- }
11
- const name = node.getFirstToken().getStr();
12
- if (!(context instanceof structure_type_1.StructureType)) {
13
- if (name.toUpperCase() === "TABLE_LINE") {
11
+ runSyntax(context, node, scope, filename) {
12
+ const children = node.getChildren();
13
+ for (let i = 0; i < children.length; i++) {
14
+ if (context instanceof void_type_1.VoidType || context instanceof basic_1.UnknownType) {
14
15
  return context;
15
16
  }
16
- throw new Error("ComponentChain, not a structure");
17
- }
18
- if (name.toUpperCase() === "TABLE_LINE") {
19
- return context;
20
- }
21
- const ret = context.getComponentByName(name);
22
- if (ret === undefined) {
23
- throw new Error("Component \"" + name + "\" not found in structure");
17
+ const child = children[i];
18
+ if (i === 0 && child.concatTokens().toUpperCase() === "TABLE_LINE") {
19
+ continue;
20
+ }
21
+ else if (child.get() instanceof Expressions.ArrowOrDash) {
22
+ const concat = child.concatTokens();
23
+ if (concat === "-") {
24
+ if (!(context instanceof structure_type_1.StructureType)) {
25
+ throw new Error("ComponentChain, not a structure");
26
+ }
27
+ }
28
+ else if (concat === "=>") {
29
+ if (!(context instanceof basic_1.ObjectReferenceType)) {
30
+ throw new Error("ComponentChain, not a reference");
31
+ }
32
+ }
33
+ else if (concat === "->") {
34
+ if (!(context instanceof basic_1.ObjectReferenceType) && !(context instanceof basic_1.DataReference)) {
35
+ throw new Error("ComponentChain, not a reference");
36
+ }
37
+ }
38
+ }
39
+ else if (child.get() instanceof Expressions.ComponentName) {
40
+ const name = child.concatTokens();
41
+ if (context instanceof basic_1.DataReference) {
42
+ context = context.getType();
43
+ if (name === "*") {
44
+ continue;
45
+ }
46
+ }
47
+ if (context instanceof structure_type_1.StructureType) {
48
+ context = context.getComponentByName(name);
49
+ if (context === undefined) {
50
+ throw new Error("Component \"" + name + "\" not found in structure");
51
+ }
52
+ }
53
+ else if (context instanceof basic_1.ObjectReferenceType) {
54
+ const id = context.getIdentifier();
55
+ const def = scope.findObjectDefinition(id.getName());
56
+ if (def === undefined) {
57
+ throw new Error(id.getName() + " not found in scope");
58
+ }
59
+ const found = def.getAttributes().findByName(name);
60
+ context = found === null || found === void 0 ? void 0 : found.getType();
61
+ if (context === undefined) {
62
+ throw new Error("Attribute \"" + name + "\" not found");
63
+ }
64
+ else {
65
+ const extra = {
66
+ ooName: id.getName(),
67
+ ooType: id instanceof types_1.ClassDefinition ? "CLAS" : "INTF"
68
+ };
69
+ scope.addReference(child.getFirstToken(), found, _reference_1.ReferenceType.DataWriteReference, filename, extra);
70
+ }
71
+ }
72
+ else {
73
+ throw new Error("ComponentChain, not a structure");
74
+ }
75
+ }
24
76
  }
25
- // todo, add more here
26
- return ret;
77
+ return context;
27
78
  }
28
79
  }
29
80
  exports.ComponentChain = ComponentChain;
@@ -11,7 +11,7 @@ class ComponentCompareSimple {
11
11
  for (const c of node.getChildren()) {
12
12
  if (c instanceof nodes_1.ExpressionNode) {
13
13
  if (c.get() instanceof Expressions.ComponentChainSimple) {
14
- targetType = new component_chain_1.ComponentChain().runSyntax(rowType, c);
14
+ targetType = new component_chain_1.ComponentChain().runSyntax(rowType, c, scope, filename);
15
15
  }
16
16
  else if (c.get() instanceof Expressions.Dynamic) {
17
17
  targetType = undefined;
@@ -172,7 +172,7 @@ class Source {
172
172
  // console.dir("dash");
173
173
  }
174
174
  else if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.ComponentChain) {
175
- context = new component_chain_1.ComponentChain().runSyntax(context, first);
175
+ context = new component_chain_1.ComponentChain().runSyntax(context, first, scope, filename);
176
176
  }
177
177
  else if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.AttributeChain) {
178
178
  context = new attribute_chain_1.AttributeChain().runSyntax(context, first, scope, filename, _reference_1.ReferenceType.DataReadReference);
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.95.35";
66
+ return "2.95.37";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.95.35",
3
+ "version": "2.95.37",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -50,7 +50,7 @@
50
50
  "@microsoft/api-extractor": "^7.34.4",
51
51
  "@types/chai": "^4.3.4",
52
52
  "@types/mocha": "^10.0.1",
53
- "@types/node": "^18.14.6",
53
+ "@types/node": "^18.15.0",
54
54
  "chai": "^4.3.7",
55
55
  "eslint": "^8.35.0",
56
56
  "mocha": "^10.2.0",