@abaplint/core 2.85.17 → 2.85.18

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.
@@ -3824,11 +3824,19 @@ declare class Normal implements IStructure {
3824
3824
  }
3825
3825
 
3826
3826
  declare class NumberRange extends AbstractObject {
3827
+ private parsedXML;
3827
3828
  getType(): string;
3828
3829
  getAllowedNaming(): {
3829
3830
  maxLength: number;
3830
3831
  allowNamespace: boolean;
3831
3832
  };
3833
+ getDomain(): string | undefined;
3834
+ getPercentage(): number | undefined;
3835
+ setDirty(): void;
3836
+ parse(): {
3837
+ updated: boolean;
3838
+ runtime: number;
3839
+ };
3832
3840
  getDescription(): string | undefined;
3833
3841
  }
3834
3842
 
@@ -12,9 +12,43 @@ class NumberRange extends _abstract_object_1.AbstractObject {
12
12
  allowNamespace: true,
13
13
  };
14
14
  }
15
+ getDomain() {
16
+ var _a;
17
+ this.parse();
18
+ return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.domain;
19
+ }
20
+ getPercentage() {
21
+ var _a;
22
+ this.parse();
23
+ return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.percentage;
24
+ }
25
+ setDirty() {
26
+ this.parsedXML = undefined;
27
+ super.setDirty();
28
+ }
29
+ parse() {
30
+ var _a, _b, _c, _d, _e, _f;
31
+ if (this.parsedXML) {
32
+ return { updated: false, runtime: 0 };
33
+ }
34
+ const start = Date.now();
35
+ this.parsedXML = {};
36
+ const parsed = super.parseRaw2();
37
+ if (parsed === undefined) {
38
+ return { updated: false, runtime: 0 };
39
+ }
40
+ const text = (_c = (_b = (_a = parsed.abapGit) === null || _a === void 0 ? void 0 : _a["asx:abap"]) === null || _b === void 0 ? void 0 : _b["asx:values"]) === null || _c === void 0 ? void 0 : _c.TEXT;
41
+ this.parsedXML.description = text === null || text === void 0 ? void 0 : text.TXT;
42
+ const attributes = (_f = (_e = (_d = parsed.abapGit) === null || _d === void 0 ? void 0 : _d["asx:abap"]) === null || _e === void 0 ? void 0 : _e["asx:values"]) === null || _f === void 0 ? void 0 : _f.ATTRIBUTES;
43
+ this.parsedXML.domain = attributes === null || attributes === void 0 ? void 0 : attributes.DOMLEN;
44
+ this.parsedXML.percentage = parseFloat((attributes === null || attributes === void 0 ? void 0 : attributes.PERCENTAGE) || "");
45
+ const end = Date.now();
46
+ return { updated: true, runtime: end - start };
47
+ }
15
48
  getDescription() {
16
- // todo
17
- return undefined;
49
+ var _a;
50
+ this.parse();
51
+ return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.description;
18
52
  }
19
53
  }
20
54
  exports.NumberRange = NumberRange;
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.85.17";
71
+ return "2.85.18";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -659,8 +659,34 @@ ${indentation} output = ${topTarget}.`;
659
659
  }
660
660
  return undefined;
661
661
  }
662
+ outlineFor(forLoop, indentation) {
663
+ var _a, _b, _c, _d, _e, _f;
664
+ let body = "";
665
+ let end = "";
666
+ const loopSource = (_a = forLoop.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
667
+ const loopTargetField = (_b = forLoop.findFirstExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
668
+ if (forLoop.findDirectTokenByText("UNTIL")) {
669
+ const name = (_c = forLoop.findFirstExpression(Expressions.Field)) === null || _c === void 0 ? void 0 : _c.concatTokens();
670
+ body += indentation + "DATA " + name + " TYPE i.\n";
671
+ const cond = forLoop.findFirstExpression(Expressions.Cond);
672
+ body += indentation + `WHILE NOT ${cond === null || cond === void 0 ? void 0 : cond.concatTokens()}.\n`;
673
+ const field = (_e = (_d = forLoop.findDirectExpression(Expressions.InlineFieldDefinition)) === null || _d === void 0 ? void 0 : _d.findFirstExpression(Expressions.Field)) === null || _e === void 0 ? void 0 : _e.concatTokens();
674
+ body += indentation + ` ${field} = ${field} + 1.\n`;
675
+ end = "ENDWHILE";
676
+ }
677
+ else if (loopTargetField) {
678
+ body += indentation + `LOOP AT ${loopSource} INTO DATA(${loopTargetField}).\n`;
679
+ end = "ENDLOOP";
680
+ }
681
+ else if (loopTargetField === undefined) {
682
+ const loopTargetFieldSymbol = (_f = forLoop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _f === void 0 ? void 0 : _f.concatTokens();
683
+ body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol}).\n`;
684
+ end = "ENDLOOP";
685
+ }
686
+ return { body, end };
687
+ }
662
688
  outlineReduce(node, lowFile, highSyntax) {
663
- var _a, _b, _c, _d;
689
+ var _a;
664
690
  for (const i of node.findAllExpressionsRecursive(Expressions.Source)) {
665
691
  const firstToken = i.getFirstToken();
666
692
  if (firstToken.getStr().toUpperCase() !== "REDUCE") {
@@ -682,19 +708,12 @@ ${indentation} output = ${topTarget}.`;
682
708
  name = init.getFirstToken().getStr();
683
709
  body += indentation + `DATA(${name}) = ${(_a = reduceBody.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens()}.\n`;
684
710
  }
685
- const loop = reduceBody.findFirstExpression(Expressions.InlineLoopDefinition);
686
- if (loop === undefined) {
711
+ const forLoop = reduceBody.findDirectExpression(Expressions.For);
712
+ if (forLoop === undefined) {
687
713
  continue;
688
714
  }
689
- const loopSource = (_b = loop.findFirstExpression(Expressions.Source)) === null || _b === void 0 ? void 0 : _b.concatTokens();
690
- const loopTargetField = (_c = loop.findFirstExpression(Expressions.TargetField)) === null || _c === void 0 ? void 0 : _c.concatTokens();
691
- if (loopTargetField) {
692
- body += indentation + `LOOP AT ${loopSource} INTO DATA(${loopTargetField}).\n`;
693
- }
694
- if (loopTargetField === undefined) {
695
- const loopTargetFieldSymbol = (_d = loop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _d === void 0 ? void 0 : _d.concatTokens();
696
- body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol}).\n`;
697
- }
715
+ const outlineFor = this.outlineFor(forLoop, indentation);
716
+ body += outlineFor.body;
698
717
  const next = reduceBody.findDirectExpression(Expressions.ReduceNext);
699
718
  if (next === undefined) {
700
719
  continue;
@@ -713,7 +732,7 @@ ${indentation} output = ${topTarget}.`;
713
732
  body += n.concatTokens() + ".\n";
714
733
  }
715
734
  }
716
- body += indentation + `ENDLOOP.\n`;
735
+ body += indentation + outlineFor.end + `.\n`;
717
736
  body += indentation + `${uniqueName} = ${name}.\n`;
718
737
  const abap = `DATA ${uniqueName} TYPE ${type}.\n` +
719
738
  body +
@@ -726,7 +745,6 @@ ${indentation} output = ${topTarget}.`;
726
745
  return undefined;
727
746
  }
728
747
  outlineValue(node, lowFile, highSyntax) {
729
- var _a, _b;
730
748
  const allSources = node.findAllExpressionsRecursive(Expressions.Source);
731
749
  for (const i of allSources) {
732
750
  const firstToken = i.getFirstToken();
@@ -741,11 +759,11 @@ ${indentation} output = ${topTarget}.`;
741
759
  const uniqueName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
742
760
  let indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
743
761
  let body = "";
744
- const loop = valueBody === null || valueBody === void 0 ? void 0 : valueBody.findFirstExpression(Expressions.InlineLoopDefinition);
745
- if (loop) {
746
- const loopSource = (_a = loop.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
747
- const loopTargetFieldSymbol = (_b = loop.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _b === void 0 ? void 0 : _b.concatTokens();
748
- body += indentation + `LOOP AT ${loopSource} ASSIGNING FIELD-SYMBOL(${loopTargetFieldSymbol}).\n`;
762
+ const forLoop = valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpression(Expressions.For);
763
+ let outlineFor = { body: "", end: "" };
764
+ if (forLoop !== undefined) {
765
+ outlineFor = this.outlineFor(forLoop, indentation);
766
+ body += outlineFor.body;
749
767
  indentation += " ";
750
768
  }
751
769
  let structureName = uniqueName;
@@ -773,9 +791,9 @@ ${indentation} output = ${topTarget}.`;
773
791
  body += indentation + `APPEND ${structureName} TO ${uniqueName}.\n`;
774
792
  }
775
793
  }
776
- if (loop) {
777
- indentation = indentation.substr(2);
778
- body += indentation + `ENDLOOP.\n`;
794
+ if (forLoop !== undefined) {
795
+ indentation = indentation.substring(2);
796
+ body += indentation + outlineFor.end + `.\n`;
779
797
  }
780
798
  const abap = `DATA ${uniqueName} TYPE ${type}.\n` +
781
799
  body +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.85.17",
3
+ "version": "2.85.18",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -50,7 +50,7 @@
50
50
  "@types/mocha": "^9.1.0",
51
51
  "@types/node": "^17.0.17",
52
52
  "chai": "^4.3.6",
53
- "eslint": "^8.8.0",
53
+ "eslint": "^8.9.0",
54
54
  "mocha": "^9.2.0",
55
55
  "c8": "^7.11.0",
56
56
  "source-map-support": "^0.5.21",