@abaplint/core 2.83.15 → 2.83.19
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.
- package/build/abaplint.d.ts +8 -0
- package/build/src/abap/2_statements/expressions/index.js +1 -0
- package/build/src/abap/2_statements/expressions/method_def_exceptions.js +13 -0
- package/build/src/abap/2_statements/statements/method_def.js +2 -3
- package/build/src/abap/2_statements/statements/selectoption.js +1 -1
- package/build/src/abap/types/method_definition.js +10 -1
- package/build/src/registry.js +1 -1
- package/build/src/rules/align_parameters.js +12 -0
- package/build/src/rules/downport.js +27 -0
- package/build/src/rules/use_class_based_exceptions.js +2 -1
- package/package.json +3 -3
package/build/abaplint.d.ts
CHANGED
|
@@ -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,
|
|
@@ -2777,6 +2778,7 @@ export declare interface IMethodDefinition extends Identifier {
|
|
|
2777
2778
|
isEventHandler(): boolean;
|
|
2778
2779
|
getParameters(): IMethodParameters;
|
|
2779
2780
|
getRaising(): readonly string[];
|
|
2781
|
+
getExceptions(): readonly string[];
|
|
2780
2782
|
}
|
|
2781
2783
|
|
|
2782
2784
|
declare interface IMethodDefinitions {
|
|
@@ -3587,6 +3589,10 @@ declare class MethodDefChanging extends Expression {
|
|
|
3587
3589
|
getRunnable(): IStatementRunnable;
|
|
3588
3590
|
}
|
|
3589
3591
|
|
|
3592
|
+
declare class MethodDefExceptions extends Expression {
|
|
3593
|
+
getRunnable(): IStatementRunnable;
|
|
3594
|
+
}
|
|
3595
|
+
|
|
3590
3596
|
declare class MethodDefExporting extends Expression {
|
|
3591
3597
|
getRunnable(): IStatementRunnable;
|
|
3592
3598
|
}
|
|
@@ -3603,6 +3609,7 @@ declare class MethodDefinition extends Identifier implements IMethodDefinition {
|
|
|
3603
3609
|
private readonly abstract;
|
|
3604
3610
|
private readonly static;
|
|
3605
3611
|
private readonly raising;
|
|
3612
|
+
private readonly exceptions;
|
|
3606
3613
|
constructor(node: StatementNode, visibility: Visibility, filename: string, scope: CurrentScope);
|
|
3607
3614
|
getVisibility(): Visibility;
|
|
3608
3615
|
isRedefinition(): boolean;
|
|
@@ -3611,6 +3618,7 @@ declare class MethodDefinition extends Identifier implements IMethodDefinition {
|
|
|
3611
3618
|
isEventHandler(): boolean;
|
|
3612
3619
|
getParameters(): MethodParameters_2;
|
|
3613
3620
|
getRaising(): readonly string[];
|
|
3621
|
+
getExceptions(): readonly string[];
|
|
3614
3622
|
}
|
|
3615
3623
|
|
|
3616
3624
|
declare class MethodDefinitions implements IMethodDefinitions {
|
|
@@ -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);
|
|
@@ -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
|
|
@@ -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,
|
|
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,
|
|
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
|
|
@@ -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
|
package/build/src/registry.js
CHANGED
|
@@ -190,6 +190,18 @@ foo = VALUE #(
|
|
|
190
190
|
right: children[2],
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
|
+
const ex = raise.findDirectExpression(Expressions.ParameterListExceptions);
|
|
194
|
+
for (const e of (ex === null || ex === void 0 ? void 0 : ex.getChildren()) || []) {
|
|
195
|
+
const children = e.getChildren();
|
|
196
|
+
if (children.length < 3) {
|
|
197
|
+
continue; // unexpected
|
|
198
|
+
}
|
|
199
|
+
parameters.push({
|
|
200
|
+
left: children[0],
|
|
201
|
+
eq: children[1].getFirstToken().getStart(),
|
|
202
|
+
right: children[2],
|
|
203
|
+
});
|
|
204
|
+
}
|
|
193
205
|
if (parameters.length > 0) {
|
|
194
206
|
candidates.push({ parameters });
|
|
195
207
|
}
|
|
@@ -55,6 +55,7 @@ Current rules:
|
|
|
55
55
|
* SELECT/INSERT/MODIFY/DELETE/UPDATE "," in field list removed, "@" in source/targets removed
|
|
56
56
|
* PARTIALLY IMPLEMENTED removed, it can be quick fixed via rule implement_methods
|
|
57
57
|
* RAISE EXCEPTION ... MESSAGE
|
|
58
|
+
* APPEND expression is outlined
|
|
58
59
|
|
|
59
60
|
Only one transformation is applied to a statement at a time, so multiple steps might be required to do the full downport.`,
|
|
60
61
|
tags: [_irule_1.RuleTag.Experimental, _irule_1.RuleTag.Downport, _irule_1.RuleTag.Quickfix],
|
|
@@ -223,6 +224,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
223
224
|
if (found) {
|
|
224
225
|
return found;
|
|
225
226
|
}
|
|
227
|
+
found = this.replaceAppendExpression(high, lowFile, highSyntax);
|
|
228
|
+
if (found) {
|
|
229
|
+
return found;
|
|
230
|
+
}
|
|
226
231
|
// todo, add more rules here
|
|
227
232
|
return undefined;
|
|
228
233
|
}
|
|
@@ -364,6 +369,28 @@ ${indentation}`);
|
|
|
364
369
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
365
370
|
return issue_1.Issue.atToken(lowFile, inlineData.getFirstToken(), "Outline SELECT @DATA", this.getMetadata().key, this.conf.severity, fix);
|
|
366
371
|
}
|
|
372
|
+
replaceAppendExpression(high, lowFile, highSyntax) {
|
|
373
|
+
if (!(high.get() instanceof Statements.Append)) {
|
|
374
|
+
return undefined;
|
|
375
|
+
}
|
|
376
|
+
const children = high.getChildren();
|
|
377
|
+
if (children[1].get() instanceof Expressions.Source) {
|
|
378
|
+
const source = children[1];
|
|
379
|
+
const target = high.findDirectExpression(Expressions.Target);
|
|
380
|
+
if (target === undefined) {
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
384
|
+
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
385
|
+
const firstToken = high.getFirstToken();
|
|
386
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, firstToken.getStart(), `DATA ${uniqueName} LIKE LINE OF ${target === null || target === void 0 ? void 0 : target.concatTokens()}.
|
|
387
|
+
${indentation}${uniqueName} = ${source.concatTokens()}.\n${indentation}`);
|
|
388
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, source.getFirstToken().getStart(), source.getLastToken().getEnd(), uniqueName);
|
|
389
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
390
|
+
return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Outline APPEND source expression", this.getMetadata().key, this.conf.severity, fix);
|
|
391
|
+
}
|
|
392
|
+
return undefined;
|
|
393
|
+
}
|
|
367
394
|
replaceTableExpression(node, lowFile, highSyntax) {
|
|
368
395
|
var _a;
|
|
369
396
|
for (const fieldChain of node.findAllExpressionsRecursive(Expressions.FieldChain)) {
|
|
@@ -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.
|
|
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.
|
|
3
|
+
"version": "2.83.19",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@microsoft/api-extractor": "^7.19.3",
|
|
49
49
|
"@types/chai": "^4.3.0",
|
|
50
50
|
"@types/mocha": "^9.0.0",
|
|
51
|
-
"@types/node": "^17.0.
|
|
51
|
+
"@types/node": "^17.0.8",
|
|
52
52
|
"chai": "^4.3.4",
|
|
53
|
-
"eslint": "^8.
|
|
53
|
+
"eslint": "^8.6.0",
|
|
54
54
|
"mocha": "^9.1.3",
|
|
55
55
|
"c8": "^7.11.0",
|
|
56
56
|
"source-map-support": "^0.5.21",
|