@abaplint/core 2.90.2 → 2.90.3
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.
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +27 -0
- package/package.json +1 -1
package/build/src/registry.js
CHANGED
|
@@ -49,6 +49,7 @@ Current rules:
|
|
|
49
49
|
* REDUCE is outlined
|
|
50
50
|
* SWITCH is outlined
|
|
51
51
|
* APPEND expression is outlined
|
|
52
|
+
* INSERT expression is outlined
|
|
52
53
|
* EMPTY KEY is changed to DEFAULT KEY, opposite of DEFAULT KEY in https://rules.abaplint.org/avoid_use/
|
|
53
54
|
* CAST changed to ?=
|
|
54
55
|
* LOOP AT method_call( ) is outlined
|
|
@@ -286,6 +287,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
286
287
|
if (found) {
|
|
287
288
|
return found;
|
|
288
289
|
}
|
|
290
|
+
found = this.replaceInsertExpression(high, lowFile, highSyntax);
|
|
291
|
+
if (found) {
|
|
292
|
+
return found;
|
|
293
|
+
}
|
|
289
294
|
found = this.downportMessage(high, lowFile, highSyntax);
|
|
290
295
|
if (found) {
|
|
291
296
|
return found;
|
|
@@ -507,6 +512,28 @@ ${indentation}${uniqueName} = ${source.concatTokens()}.\n${indentation}`);
|
|
|
507
512
|
}
|
|
508
513
|
return undefined;
|
|
509
514
|
}
|
|
515
|
+
replaceInsertExpression(high, lowFile, highSyntax) {
|
|
516
|
+
if (!(high.get() instanceof Statements.InsertInternal)) {
|
|
517
|
+
return undefined;
|
|
518
|
+
}
|
|
519
|
+
const children = high.getChildren();
|
|
520
|
+
if (children[1].get() instanceof Expressions.Source) {
|
|
521
|
+
const source = children[1];
|
|
522
|
+
const target = high.findDirectExpression(Expressions.Target);
|
|
523
|
+
if (target === undefined) {
|
|
524
|
+
return undefined;
|
|
525
|
+
}
|
|
526
|
+
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
527
|
+
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
528
|
+
const firstToken = high.getFirstToken();
|
|
529
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, firstToken.getStart(), `DATA ${uniqueName} LIKE LINE OF ${target === null || target === void 0 ? void 0 : target.concatTokens()}.
|
|
530
|
+
${indentation}${uniqueName} = ${source.concatTokens()}.\n${indentation}`);
|
|
531
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, source.getFirstToken().getStart(), source.getLastToken().getEnd(), uniqueName);
|
|
532
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
533
|
+
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Outline INSERT source expression", this.getMetadata().key, this.conf.severity, fix);
|
|
534
|
+
}
|
|
535
|
+
return undefined;
|
|
536
|
+
}
|
|
510
537
|
replaceTableExpression(node, lowFile, highSyntax) {
|
|
511
538
|
for (const fieldChain of node.findAllExpressionsRecursive(Expressions.FieldChain)) {
|
|
512
539
|
const tableExpression = fieldChain.findDirectExpression(Expressions.TableExpression);
|