@abaplint/core 2.90.1 → 2.90.4

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.
@@ -6,7 +6,7 @@ const version_1 = require("../../../version");
6
6
  const expressions_1 = require("../expressions");
7
7
  class InsertInternal {
8
8
  getMatcher() {
9
- const target = (0, combi_1.alt)(expressions_1.Source, expressions_1.Dynamic);
9
+ const target = (0, combi_1.altPrio)(expressions_1.Source, expressions_1.Dynamic);
10
10
  const assigning = (0, combi_1.seq)("ASSIGNING", expressions_1.FSTarget);
11
11
  const ref = (0, combi_1.seq)("REFERENCE INTO", expressions_1.Target);
12
12
  const index = (0, combi_1.seq)("INDEX", expressions_1.Source);
@@ -14,10 +14,10 @@ class InsertInternal {
14
14
  const into = (0, combi_1.seq)("INTO", (0, combi_1.opt)("TABLE"), expressions_1.Target);
15
15
  const to = (0, combi_1.seq)("TO", expressions_1.Source);
16
16
  const from = (0, combi_1.seq)("FROM", expressions_1.Source);
17
- const fromTo = (0, combi_1.seq)((0, combi_1.opt)(from), (0, combi_1.opt)(to));
17
+ const fromTo = (0, combi_1.seq)((0, combi_1.optPrio)(from), (0, combi_1.optPrio)(to));
18
18
  const foo = (0, combi_1.per)(into, ref, index, assigning);
19
19
  const lines = (0, combi_1.seq)("LINES OF", target, (0, combi_1.opt)(fromTo));
20
- const src = (0, combi_1.alt)((0, combi_1.ver)(version_1.Version.v740sp02, expressions_1.Source), expressions_1.SimpleSource4);
20
+ const src = (0, combi_1.alt)(expressions_1.SimpleSource4, (0, combi_1.ver)(version_1.Version.v740sp02, expressions_1.Source));
21
21
  const tab = (0, combi_1.seq)("TABLE", expressions_1.Source);
22
22
  const ret = (0, combi_1.seq)("INSERT", (0, combi_1.altPrio)(tab, (0, combi_1.seq)((0, combi_1.altPrio)(initial, lines, src), foo)));
23
23
  return ret;
@@ -18,7 +18,7 @@ class InsertInternal {
18
18
  }
19
19
  const afterAssigning = node.findExpressionAfterToken("ASSIGNING");
20
20
  if ((afterAssigning === null || afterAssigning === void 0 ? void 0 : afterAssigning.get()) instanceof Expressions.FSTarget) {
21
- let source = node.findDirectExpression(Expressions.SimpleSource2);
21
+ let source = node.findDirectExpression(Expressions.SimpleSource4);
22
22
  if (source === undefined) {
23
23
  source = node.findDirectExpression(Expressions.Source);
24
24
  }
@@ -34,7 +34,7 @@ class InsertInternal {
34
34
  for (const s of node.findDirectExpressions(Expressions.Source)) {
35
35
  new source_1.Source().runSyntax(s, scope, filename, targetType);
36
36
  }
37
- for (const s of node.findDirectExpressions(Expressions.SimpleSource1)) {
37
+ for (const s of node.findDirectExpressions(Expressions.SimpleSource4)) {
38
38
  new source_1.Source().runSyntax(s, scope, filename, targetType);
39
39
  }
40
40
  }
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.90.1";
71
+ return "2.90.4";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -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);
@@ -1224,12 +1251,14 @@ ${indentation} output = ${topTarget}.`;
1224
1251
  body += indentation + uniqueName + " = " + base.concatTokens() + ".\n";
1225
1252
  }
1226
1253
  let end = "";
1227
- for (const forLoop of (valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpressions(Expressions.For)) || []) {
1228
- const outlineFor = this.outlineFor(forLoop, indentation, lowFile, highSyntax);
1229
- body += outlineFor.body;
1230
- end = outlineFor.end + `.\n` + end;
1231
- indentation += " ";
1232
- }
1254
+ /*
1255
+ for (const forLoop of valueBody?.findDirectExpressions(Expressions.For) || []) {
1256
+ const outlineFor = this.outlineFor(forLoop, indentation, lowFile, highSyntax);
1257
+ body += outlineFor.body;
1258
+ end = outlineFor.end + `.\n` + end;
1259
+ indentation += " ";
1260
+ }
1261
+ */
1233
1262
  let structureName = uniqueName;
1234
1263
  let added = false;
1235
1264
  let skip = false;
@@ -1247,6 +1276,12 @@ ${indentation} output = ${topTarget}.`;
1247
1276
  }
1248
1277
  body += indentation + structureName + "-" + b.concatTokens() + ".\n";
1249
1278
  }
1279
+ else if (b instanceof nodes_1.ExpressionNode && b.get() instanceof Expressions.For) {
1280
+ const outlineFor = this.outlineFor(b, indentation, lowFile, highSyntax);
1281
+ body += outlineFor.body;
1282
+ end = outlineFor.end + `.\n` + end;
1283
+ indentation += " ";
1284
+ }
1250
1285
  else if (b.get() instanceof Expressions.Source) {
1251
1286
  structureName = b.concatTokens();
1252
1287
  if (base && (valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectTokenByText("(")) === undefined) {
@@ -1302,6 +1337,10 @@ ${indentation} output = ${topTarget}.`;
1302
1337
  }
1303
1338
  const found = spag.findVariable(name);
1304
1339
  if (found === undefined) {
1340
+ const source = f.findFirstExpression(Expressions.Source);
1341
+ if (source) {
1342
+ ret += indentation + "DATA(" + name + `) = ${source.concatTokens()}.\n`;
1343
+ }
1305
1344
  continue;
1306
1345
  }
1307
1346
  const type = found.getType().getQualifiedName() ? (_a = found.getType().getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toLowerCase() : found.getType().toABAP();
@@ -12,28 +12,29 @@ class FunctionModuleRecommendationsConf extends _basic_rule_config_1.BasicRuleCo
12
12
  /** Tuple of Function Module Name to be replaced, the recommended alternative and
13
13
  * the version from which the recommendation is valid.*/
14
14
  this.recommendations = [
15
- { name: "SUBST_GET_FILE_LIST", replace: "see note 1686357" },
16
- { name: "ROUND", replace: "use built in function: round()" },
17
- { name: "SO_NEW_DOCUMENT_ATT_SEND_API1", replace: "use CL_BCS" },
15
+ { name: "CALCULATE_HASH_FOR_RAW", replace: "use CL_ABAP_HMAC" },
18
16
  { name: "ECATT_CONV_XSTRING_TO_STRING", replace: "use CL_BINARY_CONVERT" },
19
- { name: "SCMS_STRING_TO_XSTRING", replace: "use CL_BINARY_CONVERT" },
20
- { name: "JOB_CREATE", replace: "use CL_BP_ABAP_JOB" },
21
- { name: "JOB_SUBMIT", replace: "use CL_BP_ABAP_JOB" },
17
+ { name: "F4_FILENAME", replace: "use CL_GUI_FRONTEND_SERVICES" },
18
+ { name: "FUNCTION_EXISTS", replace: "surround with try-catch CX_SY_DYN_CALL_ILLEGAL_METHOD instead" },
22
19
  { name: "GUI_DOWNLOAD", replace: "use CL_GUI_FRONTEND_SERVICES" },
23
20
  { name: "GUI_UPLOAD", replace: "use CL_GUI_FRONTEND_SERVICES" },
24
- { name: "WS_FILENAME_GET", replace: "use CL_GUI_FRONTEND_SERVICES" },
25
- { name: "F4_FILENAME", replace: "use CL_GUI_FRONTEND_SERVICES" },
26
- { name: "SAPGUI_PROGRESS_INDICATOR", replace: "use CL_PROGRESS_INDICATOR" },
27
21
  { name: "GUID_CREATE", replace: "use CL_SYSTEM_UUID" },
28
- { name: "SSFC_BASE64_DECODE", replace: "use class CL_HTTP_UTILITY methods" },
29
- { name: "SSFC_BASE64_ENCODE", replace: "use class CL_HTTP_UTILITY methods" },
30
- { name: "SCMS_BASE64_DECODE_STR", replace: "use class CL_HTTP_UTILITY methods" },
31
- { name: "POPUP_TO_DECIDE", replace: "use POPUP_TO_CONFIRM" },
32
- { name: "REUSE_ALV_GRID_DISPLAY", replace: "use CL_SALV_TABLE=>FACTORY or CL_GUI_ALV_GRID" },
33
- { name: "CALCULATE_HASH_FOR_RAW", replace: "use CL_ABAP_HMAC" },
34
- { name: "FUNCTION_EXISTS", replace: "surround with try-catch CX_SY_DYN_CALL_ILLEGAL_METHOD instead" },
35
22
  { name: "IGN_TIMESTAMP_DIFFERENCE", replace: "use CL_ABAP_TSTMP" },
36
23
  { name: "IGN_TIMESTAMP_PLUSMINUS", replace: "use CL_ABAP_TSTMP" },
24
+ { name: "JOB_CREATE", replace: "use CL_BP_ABAP_JOB" },
25
+ { name: "JOB_SUBMIT", replace: "use CL_BP_ABAP_JOB" },
26
+ { name: "POPUP_TO_DECIDE", replace: "use POPUP_TO_CONFIRM" },
27
+ { name: "POPUP_TO_GET_VALUE", replace: "use POPUP_GET_VALUES" },
28
+ { name: "REUSE_ALV_GRID_DISPLAY", replace: "use CL_SALV_TABLE=>FACTORY or CL_GUI_ALV_GRID" },
29
+ { name: "ROUND", replace: "use built in function: round()" },
30
+ { name: "SAPGUI_PROGRESS_INDICATOR", replace: "use CL_PROGRESS_INDICATOR" },
31
+ { name: "SCMS_BASE64_DECODE_STR", replace: "use class CL_HTTP_UTILITY methods" },
32
+ { name: "SCMS_STRING_TO_XSTRING", replace: "use CL_BINARY_CONVERT" },
33
+ { name: "SO_NEW_DOCUMENT_ATT_SEND_API1", replace: "use CL_BCS" },
34
+ { name: "SSFC_BASE64_DECODE", replace: "use class CL_HTTP_UTILITY methods" },
35
+ { name: "SSFC_BASE64_ENCODE", replace: "use class CL_HTTP_UTILITY methods" },
36
+ { name: "SUBST_GET_FILE_LIST", replace: "see note 1686357" },
37
+ { name: "WS_FILENAME_GET", replace: "use CL_GUI_FRONTEND_SERVICES" },
37
38
  ];
38
39
  }
39
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.90.1",
3
+ "version": "2.90.4",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -45,10 +45,10 @@
45
45
  },
46
46
  "homepage": "https://abaplint.org",
47
47
  "devDependencies": {
48
- "@microsoft/api-extractor": "^7.23.1",
48
+ "@microsoft/api-extractor": "^7.23.2",
49
49
  "@types/chai": "^4.3.1",
50
50
  "@types/mocha": "^9.1.1",
51
- "@types/node": "^17.0.31",
51
+ "@types/node": "^17.0.32",
52
52
  "chai": "^4.3.6",
53
53
  "eslint": "^8.15.0",
54
54
  "mocha": "^10.0.0",
@@ -60,7 +60,7 @@
60
60
  "dependencies": {
61
61
  "fast-xml-parser": "^4.0.7",
62
62
  "json5": "^2.2.1",
63
- "vscode-languageserver-protocol": "^3.16.0",
64
- "vscode-languageserver-types": "^3.16.0"
63
+ "vscode-languageserver-protocol": "=3.16.0",
64
+ "vscode-languageserver-types": "=3.16.0"
65
65
  }
66
66
  }