@abaplint/core 2.119.60 → 2.119.61

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.
@@ -4405,6 +4405,10 @@ declare interface ISyntaxSettings {
4405
4405
  * @uniqueItems true
4406
4406
  */
4407
4407
  globalConstants?: string[];
4408
+ /** List of names to void in ambigious statements (regex not possible)
4409
+ * @uniqueItems true
4410
+ */
4411
+ ambigiousVoids?: string[];
4408
4412
  /** List of full named global macros (regex not possible)
4409
4413
  * @uniqueItems true
4410
4414
  */
@@ -6403,10 +6407,13 @@ declare class Result {
6403
6407
  private readonly tokens;
6404
6408
  private readonly tokenIndex;
6405
6409
  private nodes;
6410
+ private nodeCount;
6406
6411
  constructor(tokens: readonly Token[], tokenIndex: number, nodes?: (ExpressionNode | TokenNode)[]);
6412
+ private static fromChain;
6407
6413
  peek(): Token;
6408
6414
  peekAt(offset: number): Token | undefined;
6409
6415
  shift(node: ExpressionNode | TokenNode): Result;
6416
+ wrapConsumed(consumedTokens: number, node: ExpressionNode): Result;
6410
6417
  popNode(): ExpressionNode | TokenNode | undefined;
6411
6418
  getNodes(): (ExpressionNode | TokenNode)[];
6412
6419
  setNodes(n: (ExpressionNode | TokenNode)[]): void;
@@ -599,24 +599,14 @@ class Expression {
599
599
  for (const input of r) {
600
600
  const temp = this.runnable.run([input]);
601
601
  for (const t of temp) {
602
- let consumed = input.remainingLength() - t.remainingLength();
602
+ const consumed = input.remainingLength() - t.remainingLength();
603
603
  if (consumed > 0) {
604
- const originalLength = t.getNodes().length;
605
- const children = [];
606
- while (consumed > 0) {
607
- const sub = t.popNode();
608
- if (sub) {
609
- children.push(sub);
610
- consumed = consumed - sub.countTokens();
611
- }
612
- }
613
604
  const re = new nodes_1.ExpressionNode(this);
614
- re.setChildren(children.reverse());
615
- const n = t.getNodes().slice(0, originalLength - consumed);
616
- n.push(re);
617
- t.setNodes(n);
605
+ results.push(t.wrapConsumed(consumed, re));
606
+ }
607
+ else {
608
+ results.push(t);
618
609
  }
619
- results.push(t);
620
610
  }
621
611
  }
622
612
  // console.dir(results);
@@ -7,11 +7,17 @@ class Result {
7
7
  // nodes: matched tokens
8
8
  this.tokens = tokens;
9
9
  this.tokenIndex = tokenIndex;
10
- this.nodes = nodes;
11
- if (this.nodes === undefined) {
12
- this.nodes = [];
10
+ this.nodeCount = 0;
11
+ if (nodes !== undefined) {
12
+ this.setNodes(nodes);
13
13
  }
14
14
  }
15
+ static fromChain(tokens, tokenIndex, nodes, nodeCount) {
16
+ const ret = new Result(tokens, tokenIndex);
17
+ ret.nodes = nodes;
18
+ ret.nodeCount = nodeCount;
19
+ return ret;
20
+ }
15
21
  peek() {
16
22
  return this.tokens[this.tokenIndex];
17
23
  }
@@ -19,18 +25,54 @@ class Result {
19
25
  return this.tokens[this.tokenIndex + offset];
20
26
  }
21
27
  shift(node) {
22
- const cp = this.nodes.slice();
23
- cp.push(node);
24
- return new Result(this.tokens, this.tokenIndex + 1, cp);
28
+ return Result.fromChain(this.tokens, this.tokenIndex + 1, { node, previous: this.nodes }, this.nodeCount + 1);
29
+ }
30
+ wrapConsumed(consumedTokens, node) {
31
+ let current = this.nodes;
32
+ let currentCount = this.nodeCount;
33
+ const children = [];
34
+ while (consumedTokens > 0) {
35
+ if (current === undefined) {
36
+ break;
37
+ }
38
+ children.push(current.node);
39
+ consumedTokens = consumedTokens - current.node.countTokens();
40
+ current = current.previous;
41
+ currentCount--;
42
+ }
43
+ node.setChildren(children.reverse());
44
+ this.nodes = { node, previous: current };
45
+ this.nodeCount = currentCount + 1;
46
+ return this;
25
47
  }
26
48
  popNode() {
27
- return this.nodes.pop();
49
+ if (this.nodes === undefined) {
50
+ return undefined;
51
+ }
52
+ const ret = this.nodes.node;
53
+ this.nodes = this.nodes.previous;
54
+ this.nodeCount--;
55
+ return ret;
28
56
  }
29
57
  getNodes() {
30
- return this.nodes;
58
+ const ret = new Array(this.nodeCount);
59
+ let current = this.nodes;
60
+ for (let index = this.nodeCount - 1; index >= 0; index--) {
61
+ if (current === undefined) {
62
+ break;
63
+ }
64
+ ret[index] = current.node;
65
+ current = current.previous;
66
+ }
67
+ return ret;
31
68
  }
32
69
  setNodes(n) {
33
- this.nodes = n;
70
+ this.nodes = undefined;
71
+ this.nodeCount = 0;
72
+ for (const node of n) {
73
+ this.nodes = { node, previous: this.nodes };
74
+ this.nodeCount++;
75
+ }
34
76
  }
35
77
  getTokens() {
36
78
  return this.tokens;
@@ -50,18 +50,25 @@ class DeleteInternal {
50
50
  let targetType = undefined;
51
51
  const target = node.findDirectExpression(Expressions.Target);
52
52
  if (target) {
53
+ const targetName = target.concatTokens();
53
54
  let tabl = undefined;
54
- const localVariable = input.scope.findVariable(target.concatTokens());
55
+ const localVariable = input.scope.findVariable(targetName);
55
56
  if (localVariable === undefined && node.getChildren().length === 5 && node.getChildren()[2].concatTokens().toUpperCase() === "FROM") {
56
57
  // it might be a database table
57
- const found = (_a = input.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.lookupTableOrView(target.concatTokens());
58
+ const found = (_a = input.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.lookupTableOrView(targetName);
58
59
  if ((found === null || found === void 0 ? void 0 : found.object) !== undefined) {
59
60
  tabl = found;
60
61
  input.scope.getDDICReferences().addUsing(input.scope.getParentObj(), { object: tabl.object });
61
62
  }
62
63
  }
63
64
  if (tabl === undefined) {
64
- targetType = target_1.Target.runSyntax(target, input);
65
+ const ambigiousVoids = input.scope.getRegistry().getConfig().getSyntaxSetttings().ambigiousVoids || [];
66
+ if (ambigiousVoids.some(name => name.toUpperCase() === targetName.toUpperCase())) {
67
+ targetType = basic_1.VoidType.get(targetName);
68
+ }
69
+ else {
70
+ targetType = target_1.Target.runSyntax(target, input);
71
+ }
65
72
  if (node.findDirectTokenByText("TABLE") === undefined
66
73
  && node.findDirectTokenByText("ADJACENT") === undefined
67
74
  && (node.findDirectTokenByText("FROM") || node.findDirectTokenByText("INDEX"))
@@ -78,6 +78,7 @@ class Config {
78
78
  languageVersion: langVer,
79
79
  errorNamespace: "^(Z|Y|LCL\_|TY\_|LIF\_)",
80
80
  globalConstants: [],
81
+ ambigiousVoids: [],
81
82
  globalMacros: [],
82
83
  },
83
84
  rules: rules,
@@ -128,6 +129,12 @@ class Config {
128
129
  // remove duplicates,
129
130
  this.config.syntax.globalConstants = [...new Set(this.config.syntax.globalConstants)];
130
131
  }
132
+ if (this.config.syntax.ambigiousVoids === undefined) {
133
+ this.config.syntax.ambigiousVoids = [];
134
+ }
135
+ else {
136
+ this.config.syntax.ambigiousVoids = [...new Set(this.config.syntax.ambigiousVoids)];
137
+ }
131
138
  if (this.config.global.skipIncludesWithoutMain === undefined) {
132
139
  this.config.global.skipIncludesWithoutMain = false;
133
140
  }
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.119.60";
78
+ return "2.119.61";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -342,6 +342,7 @@ Make sure to test the downported code, it might not always be completely correct
342
342
  const lowConfig = this.lowReg.getConfig().get();
343
343
  highConfig.syntax.errorNamespace = lowConfig.syntax.errorNamespace;
344
344
  highConfig.syntax.globalConstants = lowConfig.syntax.globalConstants;
345
+ highConfig.syntax.ambigiousVoids = lowConfig.syntax.ambigiousVoids;
345
346
  highConfig.syntax.globalMacros = lowConfig.syntax.globalMacros;
346
347
  this.highReg = new registry_1.Registry();
347
348
  for (const o of this.lowReg.getObjects()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.119.60",
3
+ "version": "2.119.61",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",