@abaplint/core 2.93.24 → 2.93.26

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.
@@ -3272,6 +3272,12 @@ declare interface IRenameParams {
3272
3272
  newName: string;
3273
3273
  }
3274
3274
 
3275
+ declare interface IRenameResult {
3276
+ deletedFiles: Set<string>;
3277
+ addedFiles: Set<string>;
3278
+ updatedFiles: Set<string>;
3279
+ }
3280
+
3275
3281
  export declare interface IRenameSettings {
3276
3282
  /** output folder, if value is empty or undefined the changes are written inline in the input folders */
3277
3283
  output?: string;
@@ -4536,7 +4542,7 @@ export declare class Rename {
4536
4542
  constructor(reg: IRegistry);
4537
4543
  /** Applies the renaming to the objects and files in the registry,
4538
4544
  * after renaming the registry is not parsed */
4539
- rename(type: string, oldName: string, newName: string): void;
4545
+ rename(type: string, oldName: string, newName: string): IRenameResult;
4540
4546
  /** Builds edits, but does not apply to registry, used by LSP */
4541
4547
  buildEdits(type: string, oldName: string, newName: string): WorkspaceEdit | undefined;
4542
4548
  private factory;
@@ -15,7 +15,8 @@ class For extends combi_1.Expression {
15
15
  const whil = (0, combi_1.seq)((0, combi_1.altPrio)("UNTIL", "WHILE"), _1.Cond);
16
16
  const itera = (0, combi_1.seq)(_1.InlineFieldDefinition, (0, combi_1.opt)(then), whil);
17
17
  const groupBy = (0, combi_1.seq)("GROUP BY", (0, combi_1.alt)(field_chain_1.FieldChain, (0, combi_1.seq)("(", (0, combi_1.plus)(_1.LoopGroupByComponent), ")")), (0, combi_1.opt)((0, combi_1.seq)((0, combi_1.alt)("ASCENDING", "DESCENDING"), (0, combi_1.opt)("AS TEXT"))), (0, combi_1.opt)("WITHOUT MEMBERS"));
18
- const groups = (0, combi_1.ver)(version_1.Version.v740sp08, (0, combi_1.seq)("GROUPS", field_chain_1.FieldChain, "OF", _1.Target, "IN", _1.Source, (0, combi_1.optPrio)(groupBy)));
18
+ const t = (0, combi_1.alt)(_1.TargetField, _1.TargetFieldSymbol);
19
+ const groups = (0, combi_1.ver)(version_1.Version.v740sp08, (0, combi_1.seq)("GROUPS", t, "OF", t, "IN", _1.Source, (0, combi_1.optPrio)(groupBy)));
19
20
  const f = (0, combi_1.seq)("FOR", (0, combi_1.alt)(itera, inn, groups), (0, combi_1.optPrio)(_1.Let));
20
21
  return (0, combi_1.ver)(version_1.Version.v740sp05, f);
21
22
  }
@@ -8,12 +8,17 @@ const inline_loop_definition_1 = require("./inline_loop_definition");
8
8
  const _scope_type_1 = require("../_scope_type");
9
9
  const component_cond_1 = require("./component_cond");
10
10
  const cond_1 = require("./cond");
11
+ const basic_1 = require("../../types/basic");
12
+ const _typed_identifier_1 = require("../../types/_typed_identifier");
13
+ const _reference_1 = require("../_reference");
11
14
  class For {
12
15
  runSyntax(node, scope, filename) {
16
+ var _a;
13
17
  let scoped = false;
14
18
  const inlineLoop = node.findDirectExpressions(Expressions.InlineLoopDefinition);
15
19
  const inlineField = node.findAllExpressions(Expressions.InlineFieldDefinition);
16
- const addScope = inlineLoop.length > 0 || inlineField.length > 0;
20
+ const groupsToken = (_a = node.findExpressionAfterToken("GROUPS")) === null || _a === void 0 ? void 0 : _a.getFirstToken();
21
+ const addScope = inlineLoop.length > 0 || inlineField.length > 0 || groupsToken !== undefined;
17
22
  if (addScope) {
18
23
  // this scope is popped in parent expressions
19
24
  scope.push(_scope_type_1.ScopeType.For, "FOR", node.getFirstToken().getStart(), filename);
@@ -25,6 +30,12 @@ class For {
25
30
  for (const f of inlineField) {
26
31
  new inline_field_definition_1.InlineFieldDefinition().runSyntax(f, scope, filename);
27
32
  }
33
+ if (groupsToken !== undefined) {
34
+ const type = new basic_1.VoidType("todoGroupBy");
35
+ const identifier = new _typed_identifier_1.TypedIdentifier(groupsToken, filename, type, ["inline" /* IdentifierMeta.InlineDefinition */]);
36
+ scope.addIdentifier(identifier);
37
+ scope.addReference(groupsToken, identifier, _reference_1.ReferenceType.DataWriteReference, filename);
38
+ }
28
39
  for (const s of node.findDirectExpressions(Expressions.Source)) {
29
40
  new source_1.Source().runSyntax(s, scope, filename);
30
41
  }
@@ -6,7 +6,6 @@ const for_1 = require("./for");
6
6
  const source_1 = require("./source");
7
7
  const inline_field_definition_1 = require("./inline_field_definition");
8
8
  const unknown_type_1 = require("../../types/basic/unknown_type");
9
- const _scope_type_1 = require("../_scope_type");
10
9
  const reduce_next_1 = require("./reduce_next");
11
10
  const let_1 = require("./let");
12
11
  class ReduceBody {
@@ -26,8 +25,12 @@ class ReduceBody {
26
25
  first = found;
27
26
  }
28
27
  }
28
+ let forScopes = 0;
29
29
  for (const forNode of node.findDirectExpressions(Expressions.For) || []) {
30
- new for_1.For().runSyntax(forNode, scope, filename);
30
+ const scoped = new for_1.For().runSyntax(forNode, scope, filename);
31
+ if (scoped === true) {
32
+ forScopes++;
33
+ }
31
34
  }
32
35
  for (const s of node.findDirectExpressions(Expressions.Source)) {
33
36
  new source_1.Source().runSyntax(s, scope, filename);
@@ -38,7 +41,7 @@ class ReduceBody {
38
41
  if (scoped === true) {
39
42
  scope.pop(node.getLastToken().getEnd());
40
43
  }
41
- while (scope.getType() === _scope_type_1.ScopeType.For) {
44
+ for (let i = 0; i < forScopes; i++) {
42
45
  scope.pop(node.getLastToken().getEnd());
43
46
  }
44
47
  if (first) {
@@ -23,8 +23,9 @@ class Renamer {
23
23
  else if (edits.changes) {
24
24
  throw new Error("only documentChanges expected");
25
25
  }
26
- this.apply(edits);
26
+ const result = this.apply(edits);
27
27
  this.reg.findIssues(); // hmm, this builds the ddic references
28
+ return result;
28
29
  }
29
30
  /** Builds edits, but does not apply to registry, used by LSP */
30
31
  buildEdits(type, oldName, newName) {
@@ -61,10 +62,16 @@ class Renamer {
61
62
  }
62
63
  apply(edits) {
63
64
  const renames = [];
65
+ const result = {
66
+ addedFiles: new Set(),
67
+ deletedFiles: new Set(),
68
+ updatedFiles: new Set(),
69
+ };
64
70
  // assumption: only renames or text changes, no deletes or creates
65
71
  for (const dc of edits.documentChanges || []) {
66
72
  if (vscode_languageserver_types_1.TextDocumentEdit.is(dc)) {
67
73
  this.applyEdit(dc);
74
+ result.updatedFiles.add(dc.textDocument.uri);
68
75
  }
69
76
  else if (vscode_languageserver_types_1.RenameFile.is(dc)) {
70
77
  renames.push(dc);
@@ -73,7 +80,13 @@ class Renamer {
73
80
  throw new Error("unexpected documentChange type");
74
81
  }
75
82
  }
83
+ for (const rename of renames) {
84
+ result.updatedFiles.delete(rename.oldUri);
85
+ result.deletedFiles.add(rename.oldUri);
86
+ result.addedFiles.add(rename.newUri);
87
+ }
76
88
  this.applyRenames(renames);
89
+ return result;
77
90
  }
78
91
  applyEdit(dc) {
79
92
  const file = this.reg.getFileByName(dc.textDocument.uri);
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.93.24";
66
+ return "2.93.26";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
@@ -218,7 +218,7 @@ Only one transformation is applied to a statement at a time, so multiple steps m
218
218
  if (found) {
219
219
  return found;
220
220
  }
221
- found = this.downportRefSimple(high, lowFile);
221
+ found = this.downportRefSimple(high, lowFile, highSyntax);
222
222
  if (found) {
223
223
  return found;
224
224
  }
@@ -899,7 +899,7 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
899
899
  const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
900
900
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple CORRESPONDING move", this.getMetadata().key, this.conf.severity, fix);
901
901
  }
902
- downportRefSimple(high, lowFile) {
902
+ downportRefSimple(high, lowFile, highSyntax) {
903
903
  var _a;
904
904
  if (!(high.get() instanceof Statements.Move)
905
905
  || high.getChildren().length !== 4
@@ -911,10 +911,19 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
911
911
  return undefined;
912
912
  }
913
913
  const sourceRef = (_a = high.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source);
914
- if (sourceRef === undefined || sourceRef.getChildren().length !== 1) {
915
- return;
914
+ if (sourceRef === undefined
915
+ || sourceRef.getChildren().length !== 1) {
916
+ return undefined;
917
+ }
918
+ let code = "";
919
+ if (sourceRef.findFirstExpression(Expressions.TableExpression)) {
920
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
921
+ code = `DATA(${uniqueName}) = ${sourceRef.concatTokens()}.
922
+ GET REFERENCE OF ${uniqueName} INTO ${target.concatTokens()}`;
923
+ }
924
+ else {
925
+ code = `GET REFERENCE OF ${sourceRef.concatTokens()} INTO ${target.concatTokens()}`;
916
926
  }
917
- const code = `GET REFERENCE OF ${sourceRef.concatTokens()} INTO ${target.concatTokens()}`;
918
927
  const start = high.getFirstToken().getStart();
919
928
  const end = high.getLastToken().getStart();
920
929
  const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
@@ -1388,24 +1397,28 @@ ${indentation} output = ${topTarget}.`;
1388
1397
  return undefined;
1389
1398
  }
1390
1399
  outlineFor(forLoop, indentation, lowFile, highSyntax) {
1391
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1400
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1392
1401
  let body = "";
1393
1402
  let end = "";
1394
1403
  const loopSource = (_a = forLoop.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
1395
1404
  let loopTargetField = (_b = forLoop.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
1396
- if (((_d = (_c = forLoop.findDirectExpression(Expressions.InlineLoopDefinition)) === null || _c === void 0 ? void 0 : _c.getFirstChild()) === null || _d === void 0 ? void 0 : _d.get()) instanceof Expressions.TargetFieldSymbol) {
1405
+ const of = (_c = forLoop.findExpressionAfterToken("OF")) === null || _c === void 0 ? void 0 : _c.concatTokens();
1406
+ if (of !== undefined) {
1407
+ loopTargetField = of;
1408
+ }
1409
+ if (((_e = (_d = forLoop.findDirectExpression(Expressions.InlineLoopDefinition)) === null || _d === void 0 ? void 0 : _d.getFirstChild()) === null || _e === void 0 ? void 0 : _e.get()) instanceof Expressions.TargetFieldSymbol) {
1397
1410
  loopTargetField = undefined;
1398
1411
  }
1399
- let cond = ((_e = forLoop.findDirectExpression(Expressions.ComponentCond)) === null || _e === void 0 ? void 0 : _e.concatTokens()) || "";
1412
+ let cond = ((_f = forLoop.findDirectExpression(Expressions.ComponentCond)) === null || _f === void 0 ? void 0 : _f.concatTokens()) || "";
1400
1413
  if (cond !== "") {
1401
1414
  cond = " WHERE " + cond;
1402
1415
  }
1403
1416
  const loop = forLoop.findDirectExpression(Expressions.InlineLoopDefinition);
1404
- const indexInto = (_f = loop === null || loop === void 0 ? void 0 : loop.findExpressionAfterToken("INTO")) === null || _f === void 0 ? void 0 : _f.concatTokens();
1417
+ const indexInto = (_g = loop === null || loop === void 0 ? void 0 : loop.findExpressionAfterToken("INTO")) === null || _g === void 0 ? void 0 : _g.concatTokens();
1405
1418
  if (forLoop.findDirectTokenByText("UNTIL")
1406
1419
  || forLoop.findDirectTokenByText("WHILE")) {
1407
1420
  const fieldDef = forLoop.findDirectExpression(Expressions.InlineFieldDefinition);
1408
- const field = (_g = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.findFirstExpression(Expressions.Field)) === null || _g === void 0 ? void 0 : _g.concatTokens();
1421
+ const field = (_h = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.findFirstExpression(Expressions.Field)) === null || _h === void 0 ? void 0 : _h.concatTokens();
1409
1422
  const indexBackup = this.uniqueName(forLoop.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1410
1423
  body += indentation + "DATA " + field + " TYPE i.\n";
1411
1424
  const second = fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.getChildren()[2];
@@ -1428,9 +1441,9 @@ ${indentation} output = ${topTarget}.`;
1428
1441
  end += indentation + "ENDWHILE";
1429
1442
  }
1430
1443
  else if (loopTargetField !== undefined) {
1431
- let from = (_h = forLoop.findExpressionAfterToken("FROM")) === null || _h === void 0 ? void 0 : _h.concatTokens();
1444
+ let from = (_j = forLoop.findExpressionAfterToken("FROM")) === null || _j === void 0 ? void 0 : _j.concatTokens();
1432
1445
  from = from ? " FROM " + from : "";
1433
- let to = (_j = forLoop.findExpressionAfterToken("TO")) === null || _j === void 0 ? void 0 : _j.concatTokens();
1446
+ let to = (_k = forLoop.findExpressionAfterToken("TO")) === null || _k === void 0 ? void 0 : _k.concatTokens();
1434
1447
  to = to ? " TO " + to : "";
1435
1448
  let gby = "";
1436
1449
  for (const lg of forLoop.findDirectExpressions(Expressions.LoopGroupByComponent)) {
@@ -1459,7 +1472,7 @@ ${indentation} output = ${topTarget}.`;
1459
1472
  }
1460
1473
  else if (loopTargetField === undefined) {
1461
1474
  // todo, also backup sy-index / sy-tabix here?
1462
- const loopTargetFieldSymbol = (_k = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _k === void 0 ? void 0 : _k.concatTokens();
1475
+ const loopTargetFieldSymbol = (_l = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _l === void 0 ? void 0 : _l.concatTokens();
1463
1476
  body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol})${cond}.\n`;
1464
1477
  if (indexInto) {
1465
1478
  body += indentation + " DATA(" + indexInto + ") = sy-tabix.\n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.93.24",
3
+ "version": "2.93.26",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -55,7 +55,7 @@
55
55
  "mocha": "^10.0.0",
56
56
  "c8": "^7.12.0",
57
57
  "source-map-support": "^0.5.21",
58
- "ts-json-schema-generator": "^1.0.0",
58
+ "ts-json-schema-generator": "^1.1.0",
59
59
  "typescript": "^4.8.3"
60
60
  },
61
61
  "dependencies": {