@abaplint/core 2.83.13 → 2.83.17

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.
@@ -1857,6 +1857,7 @@ declare namespace Expressions {
1857
1857
  MethodDefImporting,
1858
1858
  MethodDefRaising,
1859
1859
  MethodDefReturning,
1860
+ MethodDefExceptions,
1860
1861
  MethodName,
1861
1862
  MethodParamName,
1862
1863
  MethodParamOptional,
@@ -1880,6 +1881,7 @@ declare namespace Expressions {
1880
1881
  PerformTables,
1881
1882
  PerformUsing,
1882
1883
  RadioGroupName,
1884
+ RaiseWith,
1883
1885
  ReadTableTarget,
1884
1886
  ReceiveParameters,
1885
1887
  Redefinition,
@@ -2776,6 +2778,7 @@ export declare interface IMethodDefinition extends Identifier {
2776
2778
  isEventHandler(): boolean;
2777
2779
  getParameters(): IMethodParameters;
2778
2780
  getRaising(): readonly string[];
2781
+ getExceptions(): readonly string[];
2779
2782
  }
2780
2783
 
2781
2784
  declare interface IMethodDefinitions {
@@ -3586,6 +3589,10 @@ declare class MethodDefChanging extends Expression {
3586
3589
  getRunnable(): IStatementRunnable;
3587
3590
  }
3588
3591
 
3592
+ declare class MethodDefExceptions extends Expression {
3593
+ getRunnable(): IStatementRunnable;
3594
+ }
3595
+
3589
3596
  declare class MethodDefExporting extends Expression {
3590
3597
  getRunnable(): IStatementRunnable;
3591
3598
  }
@@ -3602,6 +3609,7 @@ declare class MethodDefinition extends Identifier implements IMethodDefinition {
3602
3609
  private readonly abstract;
3603
3610
  private readonly static;
3604
3611
  private readonly raising;
3612
+ private readonly exceptions;
3605
3613
  constructor(node: StatementNode, visibility: Visibility, filename: string, scope: CurrentScope);
3606
3614
  getVisibility(): Visibility;
3607
3615
  isRedefinition(): boolean;
@@ -3610,6 +3618,7 @@ declare class MethodDefinition extends Identifier implements IMethodDefinition {
3610
3618
  isEventHandler(): boolean;
3611
3619
  getParameters(): MethodParameters_2;
3612
3620
  getRaising(): readonly string[];
3621
+ getExceptions(): readonly string[];
3613
3622
  }
3614
3623
 
3615
3624
  declare class MethodDefinitions implements IMethodDefinitions {
@@ -4256,6 +4265,10 @@ declare class RaiseEvent implements IStatement {
4256
4265
  getMatcher(): IStatementRunnable;
4257
4266
  }
4258
4267
 
4268
+ declare class RaiseWith extends Expression {
4269
+ getRunnable(): IStatementRunnable;
4270
+ }
4271
+
4259
4272
  declare class Ranges implements IStatement {
4260
4273
  getMatcher(): IStatementRunnable;
4261
4274
  }
@@ -105,6 +105,7 @@ __exportStar(require("./method_def_exporting"), exports);
105
105
  __exportStar(require("./method_def_importing"), exports);
106
106
  __exportStar(require("./method_def_raising"), exports);
107
107
  __exportStar(require("./method_def_returning"), exports);
108
+ __exportStar(require("./method_def_exceptions"), exports);
108
109
  __exportStar(require("./method_name"), exports);
109
110
  __exportStar(require("./method_param_name"), exports);
110
111
  __exportStar(require("./method_param_optional"), exports);
@@ -128,6 +129,7 @@ __exportStar(require("./perform_changing"), exports);
128
129
  __exportStar(require("./perform_tables"), exports);
129
130
  __exportStar(require("./perform_using"), exports);
130
131
  __exportStar(require("./radio_group_name"), exports);
132
+ __exportStar(require("./raise_with"), exports);
131
133
  __exportStar(require("./read_table_target"), exports);
132
134
  __exportStar(require("./receive_parameters"), exports);
133
135
  __exportStar(require("./redefinition"), exports);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MethodDefExceptions = void 0;
4
+ const combi_1 = require("../combi");
5
+ const _1 = require(".");
6
+ class MethodDefExceptions extends combi_1.Expression {
7
+ getRunnable() {
8
+ const exceptions = (0, combi_1.seq)("EXCEPTIONS", (0, combi_1.plusPrio)(_1.NamespaceSimpleName));
9
+ return exceptions;
10
+ }
11
+ }
12
+ exports.MethodDefExceptions = MethodDefExceptions;
13
+ //# sourceMappingURL=method_def_exceptions.js.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RaiseWith = void 0;
4
+ const combi_1 = require("../combi");
5
+ const _1 = require(".");
6
+ class RaiseWith extends combi_1.Expression {
7
+ getRunnable() {
8
+ const wit = (0, combi_1.seq)("WITH", _1.Source, (0, combi_1.opt)(_1.Source), (0, combi_1.opt)(_1.Source), (0, combi_1.opt)(_1.Source));
9
+ return wit;
10
+ }
11
+ }
12
+ exports.RaiseWith = RaiseWith;
13
+ //# sourceMappingURL=raise_with.js.map
@@ -6,10 +6,9 @@ const combi_1 = require("../combi");
6
6
  const expressions_1 = require("../expressions");
7
7
  class MethodDef {
8
8
  getMatcher() {
9
- const exceptions = (0, combi_1.seq)("EXCEPTIONS", (0, combi_1.plusPrio)(expressions_1.NamespaceSimpleName));
10
9
  const def = (0, combi_1.ver)(version_1.Version.v740sp08, (0, combi_1.seq)("DEFAULT", (0, combi_1.altPrio)("FAIL", "IGNORE")));
11
- const parameters = (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.altPrio)("FINAL", def, expressions_1.Abstract)), (0, combi_1.optPrio)(expressions_1.MethodDefImporting), (0, combi_1.optPrio)(expressions_1.MethodDefExporting), (0, combi_1.optPrio)(expressions_1.MethodDefChanging), (0, combi_1.optPrio)(expressions_1.MethodDefReturning), (0, combi_1.optPrio)((0, combi_1.altPrio)(expressions_1.MethodDefRaising, exceptions)));
12
- const testing = (0, combi_1.seq)((0, combi_1.optPrio)(expressions_1.Abstract), "FOR TESTING", (0, combi_1.optPrio)((0, combi_1.altPrio)(expressions_1.MethodDefRaising, exceptions)));
10
+ const parameters = (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.altPrio)("FINAL", def, expressions_1.Abstract)), (0, combi_1.optPrio)(expressions_1.MethodDefImporting), (0, combi_1.optPrio)(expressions_1.MethodDefExporting), (0, combi_1.optPrio)(expressions_1.MethodDefChanging), (0, combi_1.optPrio)(expressions_1.MethodDefReturning), (0, combi_1.optPrio)((0, combi_1.altPrio)(expressions_1.MethodDefRaising, expressions_1.MethodDefExceptions)));
11
+ const testing = (0, combi_1.seq)((0, combi_1.optPrio)(expressions_1.Abstract), "FOR TESTING", (0, combi_1.optPrio)((0, combi_1.altPrio)(expressions_1.MethodDefRaising, expressions_1.MethodDefExceptions)));
13
12
  // todo, this is only from version something
14
13
  const tableFunction = (0, combi_1.seq)("FOR TABLE FUNCTION", (0, combi_1.regex)(/^\w+?$/));
15
14
  // todo, this is only from version something
@@ -6,9 +6,8 @@ const version_1 = require("../../../version");
6
6
  const expressions_1 = require("../expressions");
7
7
  class Raise {
8
8
  getMatcher() {
9
- const wit = (0, combi_1.seq)("WITH", expressions_1.Source, (0, combi_1.opt)(expressions_1.Source), (0, combi_1.opt)(expressions_1.Source), (0, combi_1.opt)(expressions_1.Source));
10
- const mess = (0, combi_1.seq)("MESSAGE", expressions_1.MessageSource, (0, combi_1.opt)(wit));
11
- const messid = (0, combi_1.seq)("MESSAGE ID", expressions_1.Source, "NUMBER", expressions_1.Source, (0, combi_1.optPrio)(wit));
9
+ const mess = (0, combi_1.seq)("MESSAGE", expressions_1.MessageSource, (0, combi_1.opt)(expressions_1.RaiseWith));
10
+ const messid = (0, combi_1.seq)("MESSAGE ID", expressions_1.Source, "NUMBER", expressions_1.Source, (0, combi_1.optPrio)(expressions_1.RaiseWith));
12
11
  const exporting = (0, combi_1.seq)("EXPORTING", expressions_1.ParameterListS);
13
12
  const from = (0, combi_1.seq)("TYPE", expressions_1.ClassName, (0, combi_1.opt)((0, combi_1.alt)((0, combi_1.ver)(version_1.Version.v750, (0, combi_1.alt)(mess, messid)), (0, combi_1.ver)(version_1.Version.v752, "USING MESSAGE"))), (0, combi_1.optPrio)(exporting));
14
13
  const clas = (0, combi_1.seq)((0, combi_1.optPrio)("RESUMABLE"), "EXCEPTION", (0, combi_1.altPrio)(from, (0, combi_1.ver)(version_1.Version.v752, expressions_1.Source), expressions_1.SimpleSource2));
@@ -9,7 +9,7 @@ class SelectOption {
9
9
  const sourc = (0, combi_1.alt)(expressions_1.Constant, expressions_1.FieldChain);
10
10
  const to = (0, combi_1.seq)("TO", sourc);
11
11
  const def = (0, combi_1.seq)("DEFAULT", sourc, (0, combi_1.opt)(to));
12
- const option = (0, combi_1.seq)("OPTION", expressions_1.Field);
12
+ const option = (0, combi_1.seq)("OPTION", (0, combi_1.alt)("CP", expressions_1.Field));
13
13
  const sign = (0, combi_1.seq)("SIGN", expressions_1.Field);
14
14
  const memory = (0, combi_1.seq)("MEMORY ID", expressions_1.SimpleSource1);
15
15
  const match = (0, combi_1.seq)("MATCHCODE OBJECT", expressions_1.Field);
@@ -9,7 +9,7 @@ const _reference_1 = require("../5_syntax/_reference");
9
9
  class MethodDefinition extends _identifier_1.Identifier {
10
10
  // todo: final flag
11
11
  constructor(node, visibility, filename, scope) {
12
- var _a;
12
+ var _a, _b;
13
13
  if (!(node.get() instanceof statements_1.MethodDef)) {
14
14
  throw new Error("MethodDefinition, expected MethodDef as part of input node");
15
15
  }
@@ -58,6 +58,12 @@ class MethodDefinition extends _identifier_1.Identifier {
58
58
  scope.addReference(token, clas, _reference_1.ReferenceType.ObjectOrientedUnknownReference, filename, { ooName: name.toUpperCase(), ooType: "CLAS" });
59
59
  }
60
60
  }
61
+ this.exceptions = [];
62
+ for (const r of ((_b = node.findDirectExpression(Expressions.MethodDefExceptions)) === null || _b === void 0 ? void 0 : _b.findAllExpressions(Expressions.NamespaceSimpleName)) || []) {
63
+ const token = r.getFirstToken();
64
+ const name = token.getStr();
65
+ this.exceptions.push(name);
66
+ }
61
67
  this.visibility = visibility;
62
68
  this.parameters = new method_parameters_1.MethodParameters(node, this.filename, scope);
63
69
  }
@@ -82,6 +88,9 @@ class MethodDefinition extends _identifier_1.Identifier {
82
88
  getRaising() {
83
89
  return this.raising;
84
90
  }
91
+ getExceptions() {
92
+ return this.exceptions;
93
+ }
85
94
  }
86
95
  exports.MethodDefinition = MethodDefinition;
87
96
  //# sourceMappingURL=method_definition.js.map
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.83.13";
71
+ return "2.83.17";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -19,7 +19,8 @@ const _typed_identifier_1 = require("../abap/types/_typed_identifier");
19
19
  const basic_1 = require("../abap/types/basic");
20
20
  const config_1 = require("../config");
21
21
  const tokens_1 = require("../abap/1_lexer/tokens");
22
- // todo: refactor each sub-rule to new classes
22
+ // todo: refactor each sub-rule to new classes?
23
+ // todo: add configuration
23
24
  class DownportConf extends _basic_rule_config_1.BasicRuleConfig {
24
25
  }
25
26
  exports.DownportConf = DownportConf;
@@ -52,6 +53,8 @@ Current rules:
52
53
  * SELECT INTO @DATA definitions are outlined
53
54
  * Some occurrences of string template formatting option ALPHA changed to function module call
54
55
  * SELECT/INSERT/MODIFY/DELETE/UPDATE "," in field list removed, "@" in source/targets removed
56
+ * PARTIALLY IMPLEMENTED removed, it can be quick fixed via rule implement_methods
57
+ * RAISE EXCEPTION ... MESSAGE
55
58
 
56
59
  Only one transformation is applied to a statement at a time, so multiple steps might be required to do the full downport.`,
57
60
  tags: [_irule_1.RuleTag.Experimental, _irule_1.RuleTag.Downport, _irule_1.RuleTag.Quickfix],
@@ -143,7 +146,15 @@ Only one transformation is applied to a statement at a time, so multiple steps m
143
146
  if (low.getFirstToken().getStart() instanceof position_1.VirtualPosition) {
144
147
  return undefined;
145
148
  }
146
- let found = this.emptyKey(high, lowFile);
149
+ let found = this.partiallyImplemented(high, lowFile);
150
+ if (found) {
151
+ return found;
152
+ }
153
+ found = this.raiseException(high, lowFile, highSyntax);
154
+ if (found) {
155
+ return found;
156
+ }
157
+ found = this.emptyKey(high, lowFile);
147
158
  if (found) {
148
159
  return found;
149
160
  }
@@ -428,6 +439,65 @@ ${indentation}`);
428
439
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
429
440
  return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Outline DATA", this.getMetadata().key, this.conf.severity, fix);
430
441
  }
442
+ partiallyImplemented(node, lowFile) {
443
+ if (node.get() instanceof Statements.InterfaceDef) {
444
+ const partially = node.findDirectTokenByText("PARTIALLY");
445
+ if (partially === undefined) {
446
+ return undefined;
447
+ }
448
+ const implemented = node.findDirectTokenByText("IMPLEMENTED");
449
+ if (implemented === undefined) {
450
+ return undefined;
451
+ }
452
+ const fix = edit_helper_1.EditHelper.deleteRange(lowFile, partially.getStart(), implemented.getEnd());
453
+ return issue_1.Issue.atToken(lowFile, partially, "Downport PARTIALLY IMPLEMENTED", this.getMetadata().key, this.conf.severity, fix);
454
+ }
455
+ return undefined;
456
+ }
457
+ raiseException(node, lowFile, highSyntax) {
458
+ /*
459
+ Note: IF_T100_DYN_MSG does not exist in 702, so this rule is mostly relevant for the transpiler
460
+
461
+ DATA foo LIKE if_t100_message=>t100key.
462
+ foo-msgid = 'ZHVAM'.
463
+ foo-msgno = '001'.
464
+ foo-attr1 = 'IF_T100_DYN_MSG~MSGV1'.
465
+ foo-attr2 = 'IF_T100_DYN_MSG~MSGV2'.
466
+ foo-attr3 = 'IF_T100_DYN_MSG~MSGV3'.
467
+ foo-attr4 = 'IF_T100_DYN_MSG~MSGV4'.
468
+ DATA bar TYPE REF TO zcl_hvam_exception.
469
+ CREATE OBJECT bar EXPORTING textid = foo.
470
+ bar->if_t100_dyn_msg~msgty = 'E'.
471
+ bar->if_t100_dyn_msg~msgv1 = 'abc'.
472
+ bar->if_t100_dyn_msg~msgv2 = 'abc'.
473
+ bar->if_t100_dyn_msg~msgv3 = 'abc'.
474
+ bar->if_t100_dyn_msg~msgv4 = 'abc'.
475
+ RAISE EXCEPTION bar.
476
+ */
477
+ var _a;
478
+ if (node.get() instanceof Statements.Raise) {
479
+ const startToken = node.findDirectTokenByText("ID");
480
+ if (startToken === undefined) {
481
+ return undefined;
482
+ }
483
+ const sources = node.findDirectExpressions(Expressions.Source);
484
+ const id = sources[0].concatTokens();
485
+ const number = sources[1].concatTokens();
486
+ const className = ((_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.concatTokens()) || "ERROR";
487
+ const uniqueName1 = this.uniqueName(node.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
488
+ const uniqueName2 = this.uniqueName(node.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
489
+ const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
490
+ const abap = `DATA ${uniqueName1} LIKE if_t100_message=>t100key.
491
+ ${indentation}${uniqueName1}-msgid = ${id}.
492
+ ${indentation}${uniqueName1}-msgno = ${number}.
493
+ ${indentation}DATA ${uniqueName2} TYPE REF TO ${className}.
494
+ ${indentation}CREATE OBJECT ${uniqueName2} EXPORTING textid = ${uniqueName1}.
495
+ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
496
+ const fix = edit_helper_1.EditHelper.replaceRange(lowFile, node.getStart(), node.getEnd(), abap);
497
+ return issue_1.Issue.atToken(lowFile, startToken, "Downport RAISE MESSAGE", this.getMetadata().key, this.conf.severity, fix);
498
+ }
499
+ return undefined;
500
+ }
431
501
  emptyKey(node, lowFile) {
432
502
  for (let i of node.findAllExpressions(Expressions.TypeTable)) {
433
503
  const key = i.findDirectExpression(Expressions.TypeTableKey);
@@ -58,7 +58,7 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
58
58
  }
59
59
  const fix = edit_helper_1.EditHelper.deleteRange(file, colon.getStart(), colon.getEnd());
60
60
  const message = "Unnecessary chaining";
61
- const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key, this.conf.severity, fix);
61
+ const issue = issue_1.Issue.atToken(file, colon, message, this.getMetadata().key, this.conf.severity, fix);
62
62
  issues.push(issue);
63
63
  }
64
64
  return issues;
@@ -5,6 +5,7 @@ const _basic_rule_config_1 = require("./_basic_rule_config");
5
5
  const _abap_rule_1 = require("./_abap_rule");
6
6
  const _irule_1 = require("./_irule");
7
7
  const Statements = require("../abap/2_statements/statements");
8
+ const Expressions = require("../abap/2_statements/expressions");
8
9
  const issue_1 = require("../issue");
9
10
  class UseClassBasedExceptionsConf extends _basic_rule_config_1.BasicRuleConfig {
10
11
  }
@@ -36,7 +37,7 @@ class UseClassBasedExceptions extends _abap_rule_1.ABAPRule {
36
37
  var _a;
37
38
  const issues = [];
38
39
  for (const s of ((_a = file.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllStatements(Statements.MethodDef)) || []) {
39
- if (s.findDirectTokenByText("EXCEPTIONS")) {
40
+ if (s.findDirectExpression(Expressions.MethodDefExceptions)) {
40
41
  issues.push(issue_1.Issue.atStatement(file, s, this.getMessage(), this.getMetadata().key));
41
42
  }
42
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.83.13",
3
+ "version": "2.83.17",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -50,9 +50,9 @@
50
50
  "@types/mocha": "^9.0.0",
51
51
  "@types/node": "^17.0.5",
52
52
  "chai": "^4.3.4",
53
- "eslint": "^8.5.0",
53
+ "eslint": "^8.6.0",
54
54
  "mocha": "^9.1.3",
55
- "c8": "^7.10.0",
55
+ "c8": "^7.11.0",
56
56
  "source-map-support": "^0.5.21",
57
57
  "ts-json-schema-generator": "^0.97.0",
58
58
  "typescript": "^4.5.4"