@abaplint/core 2.89.6 → 2.89.7

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.
@@ -12,7 +12,7 @@ class Message {
12
12
  const raising = (0, combi_1.seq)("RAISING", expressions_1.ExceptionName);
13
13
  const options = (0, combi_1.per)(like, into, raising);
14
14
  const type = (0, combi_1.seq)("TYPE", expressions_1.Source);
15
- const sou = (0, combi_1.altPrio)(options, expressions_1.Source);
15
+ const sou = (0, combi_1.altPrio)(options, s);
16
16
  const sourc = (0, combi_1.alt)(sou, (0, combi_1.seq)(s, sou), (0, combi_1.seq)(s, s, sou), (0, combi_1.seq)(s, s, s, options));
17
17
  const mwith = (0, combi_1.seq)("WITH", s, (0, combi_1.opt)(sourc));
18
18
  const foo = (0, combi_1.seq)(expressions_1.MessageSource, (0, combi_1.opt)(options), (0, combi_1.opt)(mwith));
@@ -2,15 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentCompareSimple = void 0;
4
4
  const Expressions = require("../../2_statements/expressions");
5
+ const nodes_1 = require("../../nodes");
5
6
  const component_chain_1 = require("./component_chain");
6
7
  const source_1 = require("./source");
7
8
  class ComponentCompareSimple {
8
9
  runSyntax(node, scope, filename, rowType) {
9
- for (const s of node.findDirectExpressions(Expressions.Source)) {
10
- new source_1.Source().runSyntax(s, scope, filename);
11
- }
12
- for (const s of node.findDirectExpressions(Expressions.ComponentChainSimple)) {
13
- new component_chain_1.ComponentChain().runSyntax(rowType, s);
10
+ let targetType = undefined;
11
+ for (const c of node.getChildren()) {
12
+ if (c instanceof nodes_1.ExpressionNode) {
13
+ if (c.get() instanceof Expressions.ComponentChainSimple) {
14
+ targetType = new component_chain_1.ComponentChain().runSyntax(rowType, c);
15
+ }
16
+ else if (c.get() instanceof Expressions.Dynamic) {
17
+ targetType = undefined;
18
+ }
19
+ else if (c.get() instanceof Expressions.Source) {
20
+ new source_1.Source().runSyntax(c, scope, filename, targetType);
21
+ }
22
+ else {
23
+ throw "ComponentCompareSimple, unexpected node";
24
+ }
25
+ }
14
26
  }
15
27
  }
16
28
  }
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.89.6";
71
+ return "2.89.7";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -63,6 +63,7 @@ Current rules:
63
63
  * Moving with +=, -=, /=, *=, &&= is expanded
64
64
  * line_exists and line_index is downported to READ TABLE
65
65
  * ENUMs, but does not nessesarily give the correct type and value
66
+ * MESSAGE with non simple source
66
67
 
67
68
  Only one transformation is applied to a statement at a time, so multiple steps might be required to do the full downport.`,
68
69
  tags: [_irule_1.RuleTag.Experimental, _irule_1.RuleTag.Downport, _irule_1.RuleTag.Quickfix],
@@ -285,6 +286,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
285
286
  if (found) {
286
287
  return found;
287
288
  }
289
+ found = this.downportMessage(high, lowFile, highSyntax);
290
+ if (found) {
291
+ return found;
292
+ }
288
293
  return undefined;
289
294
  }
290
295
  //////////////////////////////////////////
@@ -456,6 +461,30 @@ ${indentation}`);
456
461
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
457
462
  return issue_1.Issue.atToken(lowFile, inlineData.getFirstToken(), "Outline SELECT @DATA", this.getMetadata().key, this.conf.severity, fix);
458
463
  }
464
+ downportMessage(high, lowFile, highSyntax) {
465
+ if (!(high.get() instanceof Statements.Message)) {
466
+ return undefined;
467
+ }
468
+ const foundWith = high.findExpressionAfterToken("WITH");
469
+ if (foundWith === undefined) {
470
+ return undefined;
471
+ }
472
+ const likeSource = high.findExpressionAfterToken("LIKE");
473
+ for (const s of high.findAllExpressions(Expressions.Source)) {
474
+ if (s === likeSource) {
475
+ continue;
476
+ }
477
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
478
+ const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
479
+ const firstToken = high.getFirstToken();
480
+ const code = `DATA(${uniqueName}) = ${s.concatTokens()}.\n${indentation}`;
481
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, firstToken.getStart(), code);
482
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, s.getFirstToken().getStart(), s.getLastToken().getEnd(), uniqueName);
483
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
484
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Refactor MESSAGE WITH source", this.getMetadata().key, this.conf.severity, fix);
485
+ }
486
+ return undefined;
487
+ }
459
488
  replaceAppendExpression(high, lowFile, highSyntax) {
460
489
  if (!(high.get() instanceof Statements.Append)) {
461
490
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.89.6",
3
+ "version": "2.89.7",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -47,7 +47,7 @@
47
47
  "devDependencies": {
48
48
  "@microsoft/api-extractor": "^7.22.2",
49
49
  "@types/chai": "^4.3.1",
50
- "@types/mocha": "^9.1.0",
50
+ "@types/mocha": "^9.1.1",
51
51
  "@types/node": "^17.0.25",
52
52
  "chai": "^4.3.6",
53
53
  "eslint": "^8.13.0",