@abaplint/core 2.79.5 → 2.79.9

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.
@@ -249,6 +249,7 @@ class BuiltIn {
249
249
  components.push({ name: "index", type: new basic_1.IntegerType() });
250
250
  components.push({ name: "langu", type: new basic_1.CharacterType(1) });
251
251
  components.push({ name: "ldbpg", type: new basic_1.CharacterType(40) });
252
+ components.push({ name: "pdest", type: new basic_1.CharacterType(4) });
252
253
  components.push({ name: "lilli", type: new basic_1.IntegerType() });
253
254
  components.push({ name: "linct", type: new basic_1.IntegerType() });
254
255
  components.push({ name: "linno", type: new basic_1.IntegerType() });
@@ -4,6 +4,7 @@ exports.Domain = void 0;
4
4
  const _abstract_object_1 = require("./_abstract_object");
5
5
  const Types = require("../abap/types/basic");
6
6
  const ddic_1 = require("../ddic");
7
+ const xml_utils_1 = require("../xml_utils");
7
8
  class Domain extends _abstract_object_1.AbstractObject {
8
9
  getType() {
9
10
  return "DOMA";
@@ -46,17 +47,15 @@ class Domain extends _abstract_object_1.AbstractObject {
46
47
  return { updated: false, runtime: 0 };
47
48
  }
48
49
  const dd01v = (_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.DD01V;
49
- const dd07v_tab = (_g = (_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.DD07V_TAB) === null || _g === void 0 ? void 0 : _g.DD07V;
50
+ const dd07v_tab = (0, xml_utils_1.xmlToArray)((_g = (_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.DD07V_TAB) === null || _g === void 0 ? void 0 : _g.DD07V);
50
51
  const values = [];
51
- if (dd07v_tab) {
52
- for (const ddo7v of dd07v_tab) {
53
- const value = {
54
- description: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DDTEXT,
55
- value: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DOMVALUE_L,
56
- language: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DDLANGUAGE,
57
- };
58
- values.push(value);
59
- }
52
+ for (const ddo7v of dd07v_tab) {
53
+ const value = {
54
+ description: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DDTEXT,
55
+ value: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DOMVALUE_L,
56
+ language: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DDLANGUAGE,
57
+ };
58
+ values.push(value);
60
59
  }
61
60
  this.parsedXML = {
62
61
  description: dd01v === null || dd01v === void 0 ? void 0 : dd01v.DDTEXT,
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenameDataElement = void 0;
4
+ const __1 = require("..");
5
+ const renamer_helper_1 = require("./renamer_helper");
6
+ class RenameDataElement {
7
+ constructor(reg) {
8
+ this.reg = reg;
9
+ }
10
+ buildEdits(obj, oldName, newName) {
11
+ if (!(obj instanceof __1.DataElement)) {
12
+ throw new Error("RenameDataElement, not a data element");
13
+ }
14
+ let changes = [];
15
+ const helper = new renamer_helper_1.RenamerHelper(this.reg);
16
+ changes = changes.concat(helper.buildXMLFileEdits(obj, "ROLLNAME", oldName, newName));
17
+ changes = changes.concat(helper.renameFiles(obj, oldName, newName));
18
+ return {
19
+ documentChanges: changes,
20
+ };
21
+ }
22
+ }
23
+ exports.RenameDataElement = RenameDataElement;
24
+ //# sourceMappingURL=rename_data_element.js.map
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenameDomain = void 0;
4
+ const __1 = require("..");
5
+ const renamer_helper_1 = require("./renamer_helper");
6
+ class RenameDomain {
7
+ constructor(reg) {
8
+ this.reg = reg;
9
+ }
10
+ buildEdits(obj, oldName, newName) {
11
+ if (!(obj instanceof __1.Domain)) {
12
+ throw new Error("RenameDomain, not a domain");
13
+ }
14
+ let changes = [];
15
+ const helper = new renamer_helper_1.RenamerHelper(this.reg);
16
+ changes = changes.concat(helper.buildXMLFileEdits(obj, "DOMNAME", oldName, newName));
17
+ changes = changes.concat(helper.renameFiles(obj, oldName, newName));
18
+ return {
19
+ documentChanges: changes,
20
+ };
21
+ }
22
+ }
23
+ exports.RenameDomain = RenameDomain;
24
+ //# sourceMappingURL=rename_domain.js.map
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Renamer = void 0;
4
4
  const vscode_languageserver_types_1 = require("vscode-languageserver-types");
5
5
  const memory_file_1 = require("../../files/memory_file");
6
+ const rename_data_element_1 = require("./rename_data_element");
7
+ const rename_domain_1 = require("./rename_domain");
6
8
  const rename_global_class_1 = require("./rename_global_class");
7
9
  const rename_global_interface_1 = require("./rename_global_interface");
8
10
  class Renamer {
@@ -40,6 +42,10 @@ class Renamer {
40
42
  switch (type) {
41
43
  case "CLAS":
42
44
  return new rename_global_class_1.RenameGlobalClass(this.reg);
45
+ case "DTEL":
46
+ return new rename_data_element_1.RenameDataElement(this.reg);
47
+ case "DOMA":
48
+ return new rename_domain_1.RenameDomain(this.reg);
43
49
  case "INTF":
44
50
  return new rename_global_interface_1.RenameGlobalInterface(this.reg);
45
51
  default:
@@ -35,11 +35,12 @@ class RenamerHelper {
35
35
  }
36
36
  const tag = xmlTag.toUpperCase();
37
37
  const search = "<" + tag + ">" + oldName.toUpperCase() + "</" + tag + ">";
38
+ const length = tag.length + 2;
38
39
  const rows = xml.getRawRows();
39
40
  for (let i = 0; i < rows.length; i++) {
40
41
  const index = rows[i].indexOf(search);
41
42
  if (index >= 0) {
42
- const range = vscode_languageserver_types_1.Range.create(i, index + 9, i, index + oldName.length + 9);
43
+ const range = vscode_languageserver_types_1.Range.create(i, index + length, i, index + oldName.length + length);
43
44
  changes.push(vscode_languageserver_types_1.TextDocumentEdit.create({ uri: xml.getFilename(), version: 1 }, [vscode_languageserver_types_1.TextEdit.replace(range, newName.toUpperCase())]));
44
45
  }
45
46
  }
@@ -5,7 +5,6 @@ const Types = require("../abap/types/basic");
5
5
  const _abstract_object_1 = require("./_abstract_object");
6
6
  const xml_utils_1 = require("../xml_utils");
7
7
  const ddic_1 = require("../ddic");
8
- const _typed_identifier_1 = require("../abap/types/_typed_identifier");
9
8
  class View extends _abstract_object_1.AbstractObject {
10
9
  getType() {
11
10
  return "VIEW";
@@ -31,17 +30,18 @@ class View extends _abstract_object_1.AbstractObject {
31
30
  const references = [];
32
31
  const ddic = new ddic_1.DDIC(reg);
33
32
  for (const field of this.parsedData.fields) {
34
- if (field.VIEWFIELD === "*") {
33
+ if (field.VIEWFIELD === "*" || field.VIEWFIELD === "-") {
35
34
  // ignore, this is a special case of old style .INCLUDE
36
35
  continue;
37
36
  }
38
37
  const lookup = ddic.lookupTableOrView(field.TABNAME);
38
+ let found = lookup.type;
39
39
  if (lookup.object) {
40
40
  references.push(lookup.object);
41
41
  }
42
- let found = lookup.type;
43
- if (found instanceof _typed_identifier_1.TypedIdentifier) {
44
- found = found.getType();
42
+ if (field.VIEWFIELD === ".APPEND") {
43
+ // it is already expanded in the abapGit xml
44
+ continue;
45
45
  }
46
46
  if (found instanceof Types.StructureType) {
47
47
  const s = found.getComponentByName(field.FIELDNAME);
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.79.5";
71
+ return "2.79.9";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -35,11 +35,12 @@ class AvoidUse extends _abap_rule_1.ABAPRule {
35
35
  key: "avoid_use",
36
36
  title: "Avoid use of certain statements",
37
37
  shortDescription: `Detects usage of certain statements.`,
38
- extendedInformation: `
39
- DEFAULT KEY: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-default-key
38
+ extendedInformation: `DEFAULT KEY: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-default-key
40
39
 
41
40
  Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
42
41
 
42
+ STATICS: use CLASS-DATA instead
43
+
43
44
  DESCRIBE TABLE LINES: use lines() instead (quickfix exists)`,
44
45
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
45
46
  };
@@ -7,6 +7,11 @@ const _irule_1 = require("./_irule");
7
7
  const __1 = require("..");
8
8
  /** Checks that constants classes are in sync with domain fixed values */
9
9
  class ConstantClassesConf extends _basic_rule_config_1.BasicRuleConfig {
10
+ constructor() {
11
+ super(...arguments);
12
+ /** Specify a list of domain-class pairs which will be validated */
13
+ this.mapping = [];
14
+ }
10
15
  }
11
16
  exports.ConstantClassesConf = ConstantClassesConf;
12
17
  class ConstantClasses {
@@ -46,6 +46,7 @@ Current rules:
46
46
  * VALUE # with internal table lines
47
47
  * Table Expressions[ index ] are outlined
48
48
  * SELECT INTO @DATA definitions are outlined
49
+ * Some occurrences of string template formatting option ALPHA changed to function module call
49
50
  * SELECT/INSERT/MODIFY/DELETE/UPDATE "," in field list removed, "@" in source/targets removed
50
51
 
51
52
  Only one transformation is applied to a statement at a time, so multiple steps might be required to do the full downport.`,
@@ -142,6 +143,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
142
143
  if (found) {
143
144
  return found;
144
145
  }
146
+ found = this.stringTemplateAlpha(high, lowFile);
147
+ if (found) {
148
+ return found;
149
+ }
145
150
  found = this.downportSelectInline(low, high, lowFile, highSyntax);
146
151
  if (found) {
147
152
  return found;
@@ -429,7 +434,51 @@ ${indentation}`);
429
434
  const fix = edit_helper_1.EditHelper.replaceToken(lowFile, token, "DEFAULT");
430
435
  return issue_1.Issue.atToken(lowFile, i.getFirstToken(), "Downport EMPTY KEY", this.getMetadata().key, this.conf.severity, fix);
431
436
  }
432
- return;
437
+ return undefined;
438
+ }
439
+ // must be very simple string templates, like "|{ ls_line-no ALPHA = IN }|"
440
+ stringTemplateAlpha(node, lowFile) {
441
+ var _a, _b, _c;
442
+ if (!(node.get() instanceof Statements.Move)) {
443
+ return undefined;
444
+ }
445
+ const topSource = node.findDirectExpression(Expressions.Source);
446
+ if (topSource === undefined || topSource.getChildren().length !== 1) {
447
+ return undefined;
448
+ }
449
+ const child = topSource.getFirstChild();
450
+ if (!(child.get() instanceof Expressions.StringTemplate)) {
451
+ return undefined;
452
+ }
453
+ const templateTokens = child.getChildren();
454
+ if (templateTokens.length !== 3
455
+ || templateTokens[0].getFirstToken().getStr() !== "|{"
456
+ || templateTokens[2].getFirstToken().getStr() !== "}|") {
457
+ return undefined;
458
+ }
459
+ const templateSource = child.findDirectExpression(Expressions.StringTemplateSource);
460
+ const formatting = (_a = templateSource === null || templateSource === void 0 ? void 0 : templateSource.findDirectExpression(Expressions.StringTemplateFormatting)) === null || _a === void 0 ? void 0 : _a.concatTokens();
461
+ let functionName = "";
462
+ switch (formatting) {
463
+ case "ALPHA = IN":
464
+ functionName = "CONVERSION_EXIT_ALPHA_INPUT";
465
+ break;
466
+ case "ALPHA = OUT":
467
+ functionName = "CONVERSION_EXIT_ALPHA_OUTPUT";
468
+ break;
469
+ default:
470
+ return undefined;
471
+ }
472
+ const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
473
+ const source = (_b = templateSource === null || templateSource === void 0 ? void 0 : templateSource.findDirectExpression(Expressions.Source)) === null || _b === void 0 ? void 0 : _b.concatTokens();
474
+ const topTarget = (_c = node.findDirectExpression(Expressions.Target)) === null || _c === void 0 ? void 0 : _c.concatTokens();
475
+ const code = `CALL FUNCTION '${functionName}'
476
+ ${indentation} EXPORTING
477
+ ${indentation} input = ${source}
478
+ ${indentation} IMPORTING
479
+ ${indentation} output = ${topTarget}.`;
480
+ const fix = edit_helper_1.EditHelper.replaceRange(lowFile, node.getFirstToken().getStart(), node.getLastToken().getEnd(), code);
481
+ return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Downport ALPHA", this.getMetadata().key, this.conf.severity, fix);
433
482
  }
434
483
  outlineLoopInput(node, lowFile, highSyntax) {
435
484
  if (!(node.get() instanceof Statements.Loop)) {
@@ -26,11 +26,9 @@ class ExitOrCheck extends _abap_rule_1.ABAPRule {
26
26
  title: "Find EXIT or CHECK outside loops",
27
27
  shortDescription: `Detects usages of EXIT or CHECK statements outside of loops.
28
28
  Use RETURN to leave procesing blocks instead.`,
29
- extendedInformation: `
30
- https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenleave_processing_blocks.htm
29
+ extendedInformation: `https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenleave_processing_blocks.htm
31
30
  https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapcheck_processing_blocks.htm
32
- https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#check-vs-return
33
- `,
31
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#check-vs-return`,
34
32
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
35
33
  };
36
34
  }
@@ -44,19 +42,20 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#check-vs-re
44
42
  const issues = [];
45
43
  const stack = [];
46
44
  for (const statement of file.getStatements()) {
47
- if (statement.get() instanceof Statements.Loop
48
- || statement.get() instanceof Statements.While
49
- || statement.get() instanceof Statements.SelectLoop
50
- || statement.get() instanceof Statements.Do) {
45
+ const get = statement.get();
46
+ if (get instanceof Statements.Loop
47
+ || get instanceof Statements.While
48
+ || get instanceof Statements.SelectLoop
49
+ || get instanceof Statements.Do) {
51
50
  stack.push(statement);
52
51
  }
53
- else if (statement.get() instanceof Statements.EndLoop
54
- || statement.get() instanceof Statements.EndWhile
55
- || statement.get() instanceof Statements.EndSelect
56
- || statement.get() instanceof Statements.EndDo) {
52
+ else if (get instanceof Statements.EndLoop
53
+ || get instanceof Statements.EndWhile
54
+ || get instanceof Statements.EndSelect
55
+ || get instanceof Statements.EndDo) {
57
56
  stack.pop();
58
57
  }
59
- else if (this.conf.allowCheck === false && statement.get() instanceof Statements.Check && stack.length === 0) {
58
+ else if (this.conf.allowCheck === false && get instanceof Statements.Check && stack.length === 0) {
60
59
  const message = "CHECK is not allowed outside of loops";
61
60
  let tokensString = statement.concatTokens();
62
61
  tokensString = tokensString.slice(statement.getFirstToken().getEnd().getCol());
@@ -65,7 +64,7 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#check-vs-re
65
64
  const issue = issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity, fix);
66
65
  issues.push(issue);
67
66
  }
68
- else if (this.conf.allowExit === false && statement.get() instanceof Statements.Exit && stack.length === 0) {
67
+ else if (this.conf.allowExit === false && get instanceof Statements.Exit && stack.length === 0) {
69
68
  const message = "EXIT is not allowed outside of loops";
70
69
  const fix = edit_helper_1.EditHelper.replaceToken(file, statement.getFirstToken(), "RETURN");
71
70
  const issue = issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity, fix);
@@ -186,12 +186,10 @@ class UnusedVariables {
186
186
  if (statement === undefined) {
187
187
  return undefined;
188
188
  }
189
- else if (statement.get() instanceof Statements.FunctionModule) {
190
- return undefined; // function module parameters are not part of the code
191
- }
192
- else {
189
+ else if (statement.get() instanceof Statements.Data) {
193
190
  return edit_helper_1.EditHelper.deleteStatement(file, statement);
194
191
  }
192
+ return undefined;
195
193
  }
196
194
  }
197
195
  exports.UnusedVariables = UnusedVariables;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.79.5",
3
+ "version": "2.79.9",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -54,21 +54,21 @@
54
54
  },
55
55
  "homepage": "https://abaplint.org",
56
56
  "devDependencies": {
57
- "@microsoft/api-extractor": "^7.18.9",
57
+ "@microsoft/api-extractor": "^7.18.11",
58
58
  "@types/chai": "^4.2.22",
59
59
  "@types/mocha": "^9.0.0",
60
- "@types/node": "^16.9.6",
60
+ "@types/node": "^16.10.2",
61
61
  "chai": "^4.3.4",
62
62
  "eslint": "^7.32.0",
63
63
  "madge": "^5.0.1",
64
- "mocha": "^9.1.1",
64
+ "mocha": "^9.1.2",
65
65
  "c8": "^7.9.0",
66
66
  "source-map-support": "^0.5.20",
67
67
  "ts-json-schema-generator": "^0.95.0",
68
68
  "typescript": "^4.4.3"
69
69
  },
70
70
  "dependencies": {
71
- "fast-xml-parser": "^3.20.0",
71
+ "fast-xml-parser": "^3.20.3",
72
72
  "json5": "^2.2.0",
73
73
  "vscode-languageserver-protocol": "^3.16.0",
74
74
  "vscode-languageserver-types": "^3.16.0"