@abaplint/core 2.120.109 → 2.120.111
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 +24 -0
- package/build/src/abap/2_statements/statements/authority_check.js +1 -1
- package/build/src/abap/2_statements/statements/commit.js +1 -1
- package/build/src/abap/2_statements/statements/convert.js +2 -2
- package/build/src/abap/2_statements/statements/do.js +2 -1
- package/build/src/abap/2_statements/statements/exit.js +2 -1
- package/build/src/abap/2_statements/statements/get_time.js +3 -2
- package/build/src/abap/2_statements/statements/perform.js +1 -1
- package/build/src/abap/2_statements/statements/rollback.js +1 -1
- package/build/src/abap/2_statements/statements/wait.js +1 -1
- package/build/src/abap/5_syntax/_current_scope.js +64 -0
- package/build/src/abap/5_syntax/expressions/for.js +38 -4
- package/build/src/abap/5_syntax/expressions/inline_field_definition.js +2 -2
- package/build/src/abap/5_syntax/expressions/inline_loop_definition.js +18 -3
- package/build/src/abap/5_syntax/expressions/loop_group_by.js +123 -13
- package/build/src/abap/5_syntax/expressions/select.js +34 -2
- package/build/src/abap/5_syntax/statements/loop.js +12 -1
- package/build/src/abap/5_syntax/statements/move.js +8 -0
- package/build/src/abap/5_syntax/syntax.js +7 -0
- package/build/src/abap/types/event_definition.js +12 -0
- package/build/src/abap/types/function_module_definition.js +16 -0
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +5 -0
- package/build/src/rules/function_module_parameter_names.js +139 -0
- package/build/src/rules/index.js +4 -0
- package/build/src/rules/sort_required.js +487 -0
- package/build/src/rules/suspicious_loop.js +333 -0
- package/build/src/rules/unhandled_classic_exception.js +278 -0
- package/package.json +2 -2
|
@@ -45,6 +45,7 @@ const basic_1 = require("../../types/basic");
|
|
|
45
45
|
const nodes_1 = require("../../nodes");
|
|
46
46
|
class Move {
|
|
47
47
|
runSyntax(node, input) {
|
|
48
|
+
var _a;
|
|
48
49
|
const targets = node.findDirectExpressions(Expressions.Target);
|
|
49
50
|
const firstTarget = targets[0];
|
|
50
51
|
const inline = firstTarget === null || firstTarget === void 0 ? void 0 : firstTarget.findDirectExpression(Expressions.InlineData);
|
|
@@ -85,6 +86,13 @@ class Move {
|
|
|
85
86
|
sourceType = dereference_1.Dereference.runSyntax(node, sourceType, input);
|
|
86
87
|
}
|
|
87
88
|
if (inline) {
|
|
89
|
+
// the length of a text symbol depends on the text pool, "DATA(x) = TEXT-abc." does not compile
|
|
90
|
+
const sourceChildren = (_a = source === null || source === void 0 ? void 0 : source.getChildren()) !== null && _a !== void 0 ? _a : [];
|
|
91
|
+
if (sourceChildren.length === 1 && sourceChildren[0].get() instanceof Expressions.TextElement) {
|
|
92
|
+
const message = `"${source.concatTokens().toUpperCase()}" has a generic type that cannot be used for declarations`;
|
|
93
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, source.getFirstToken(), message));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
88
96
|
if (sourceType instanceof basic_1.PackedType && (source === null || source === void 0 ? void 0 : source.findDirectExpression(Expressions.ArithOperator))) {
|
|
89
97
|
sourceType = new basic_1.PackedType(8, 0);
|
|
90
98
|
}
|
|
@@ -52,6 +52,7 @@ const statics_1 = require("./structures/statics");
|
|
|
52
52
|
const constants_1 = require("./structures/constants");
|
|
53
53
|
const cleanup_1 = require("./structures/cleanup");
|
|
54
54
|
const try_1 = require("./structures/try");
|
|
55
|
+
const loop_group_by_1 = require("./expressions/loop_group_by");
|
|
55
56
|
const class_definition_1 = require("../types/class_definition");
|
|
56
57
|
const interface_definition_1 = require("../types/interface_definition");
|
|
57
58
|
const delete_memory_1 = require("./statements/delete_memory");
|
|
@@ -477,6 +478,12 @@ class SyntaxLogic {
|
|
|
477
478
|
if (loop === true) {
|
|
478
479
|
this.loopTables.pop();
|
|
479
480
|
}
|
|
481
|
+
if (node instanceof nodes_1.StructureNode && node.get() instanceof Structures.Loop) {
|
|
482
|
+
const loopStatement = node.findDirectStatement(Statements.Loop);
|
|
483
|
+
if (loopStatement) {
|
|
484
|
+
loop_group_by_1.LoopGroupBy.unbind(loopStatement, this.scope);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
480
487
|
if (node instanceof nodes_1.StructureNode) {
|
|
481
488
|
this.sortedLines.leave(node);
|
|
482
489
|
}
|
|
@@ -39,6 +39,7 @@ const Expressions = __importStar(require("../2_statements/expressions"));
|
|
|
39
39
|
const events_1 = require("../2_statements/statements/events");
|
|
40
40
|
const expressions_1 = require("../2_statements/expressions");
|
|
41
41
|
const method_param_1 = require("../5_syntax/expressions/method_param");
|
|
42
|
+
const _syntax_input_1 = require("../5_syntax/_syntax_input");
|
|
42
43
|
class EventDefinition extends _identifier_1.Identifier {
|
|
43
44
|
constructor(node, _visibility, input) {
|
|
44
45
|
if (!(node.get() instanceof events_1.Events)) {
|
|
@@ -61,10 +62,21 @@ class EventDefinition extends _identifier_1.Identifier {
|
|
|
61
62
|
}
|
|
62
63
|
///////////////
|
|
63
64
|
parse(node, input) {
|
|
65
|
+
var _a;
|
|
66
|
+
var _b;
|
|
64
67
|
for (const e of node.findAllExpressions(expressions_1.MethodParam)) {
|
|
68
|
+
if (this.isPassByValue(e) === false) {
|
|
69
|
+
const name = (_b = (_a = e.findDirectExpression(Expressions.MethodParamName)) === null || _a === void 0 ? void 0 : _a.concatTokens()) !== null && _b !== void 0 ? _b : "";
|
|
70
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, e.getFirstToken(), "Event parameter " + name + " must be passed by VALUE"));
|
|
71
|
+
}
|
|
65
72
|
this.parameters.push(method_param_1.MethodParam.runSyntax(e, input, []));
|
|
66
73
|
}
|
|
67
74
|
}
|
|
75
|
+
// event parameters can only be passed by value
|
|
76
|
+
isPassByValue(param) {
|
|
77
|
+
const first = param.getFirstToken().getStr().toUpperCase();
|
|
78
|
+
return first === "VALUE" || first === "!VALUE";
|
|
79
|
+
}
|
|
68
80
|
}
|
|
69
81
|
exports.EventDefinition = EventDefinition;
|
|
70
82
|
//# sourceMappingURL=event_definition.js.map
|
|
@@ -34,6 +34,13 @@ class FunctionModuleDefinition {
|
|
|
34
34
|
isGlobalParameters() {
|
|
35
35
|
return this.globalParameters;
|
|
36
36
|
}
|
|
37
|
+
/** the classic exceptions, or the exception classes if isClassBasedExceptions() */
|
|
38
|
+
getExceptions() {
|
|
39
|
+
return this.exceptions;
|
|
40
|
+
}
|
|
41
|
+
isClassBasedExceptions() {
|
|
42
|
+
return this.classBasedExceptions;
|
|
43
|
+
}
|
|
37
44
|
///////////////
|
|
38
45
|
parse(data) {
|
|
39
46
|
if (data.FUNCNAME === undefined) {
|
|
@@ -43,6 +50,8 @@ class FunctionModuleDefinition {
|
|
|
43
50
|
this.description = data.SHORT_TEXT;
|
|
44
51
|
this.parameters = [];
|
|
45
52
|
this.globalParameters = data.GLOBAL_FLAG === "X";
|
|
53
|
+
this.exceptions = [];
|
|
54
|
+
this.classBasedExceptions = data.EXCEPTION_CLASSES === "X";
|
|
46
55
|
this.moduleType = FunctionModuleType.regular;
|
|
47
56
|
if (data.REMOTE_CALL === "R") {
|
|
48
57
|
this.moduleType = FunctionModuleType.remote;
|
|
@@ -111,6 +120,13 @@ class FunctionModuleDefinition {
|
|
|
111
120
|
});
|
|
112
121
|
}
|
|
113
122
|
}
|
|
123
|
+
if (data.EXCEPTION) {
|
|
124
|
+
for (const exception of (0, xml_utils_1.xmlToArray)(data.EXCEPTION.RSEXC)) {
|
|
125
|
+
if (typeof exception.EXCEPTION === "string") {
|
|
126
|
+
this.exceptions.push(exception.EXCEPTION);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
114
130
|
}
|
|
115
131
|
}
|
|
116
132
|
exports.FunctionModuleDefinition = FunctionModuleDefinition;
|
package/build/src/registry.js
CHANGED
|
@@ -3196,6 +3196,11 @@ ${indentation} output = ${uniqueName}.\n`;
|
|
|
3196
3196
|
if (this.lowReg.getConfig().isOpenABAP()) {
|
|
3197
3197
|
return undefined;
|
|
3198
3198
|
}
|
|
3199
|
+
else if (node.get() instanceof Statements.Loop
|
|
3200
|
+
&& node.concatTokens().toUpperCase().startsWith("LOOP AT GROUP ")) {
|
|
3201
|
+
// rewritten by the LOOP GROUP downport, the inline target is outlined afterwards
|
|
3202
|
+
return undefined;
|
|
3203
|
+
}
|
|
3199
3204
|
for (const i of node.findAllExpressionsRecursive(Expressions.InlineData)) {
|
|
3200
3205
|
const nameToken = (_a = i.findDirectExpression(Expressions.TargetField)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
3201
3206
|
if (nameToken === undefined) {
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FunctionModuleParameterNames = exports.FunctionModuleParameterNamesConf = void 0;
|
|
4
|
+
const issue_1 = require("../issue");
|
|
5
|
+
const _irule_1 = require("./_irule");
|
|
6
|
+
const function_group_1 = require("../objects/function_group");
|
|
7
|
+
const _naming_rule_config_1 = require("./_naming_rule_config");
|
|
8
|
+
const name_validator_1 = require("../utils/name_validator");
|
|
9
|
+
const function_module_definition_1 = require("../abap/types/function_module_definition");
|
|
10
|
+
const position_1 = require("../position");
|
|
11
|
+
class FunctionModuleParameterNamesConf extends _naming_rule_config_1.NamingRuleConfig {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
/** The pattern for importing parameters */
|
|
15
|
+
this.importing = "^I._.+$";
|
|
16
|
+
/** The pattern for exporting parameters */
|
|
17
|
+
this.exporting = "^E._.+$";
|
|
18
|
+
/** The pattern for changing parameters */
|
|
19
|
+
this.changing = "^C._.+$";
|
|
20
|
+
/** The pattern for tables parameters */
|
|
21
|
+
this.tables = "^T._.+$";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.FunctionModuleParameterNamesConf = FunctionModuleParameterNamesConf;
|
|
25
|
+
class FunctionModuleParameterNames {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.conf = new FunctionModuleParameterNamesConf();
|
|
28
|
+
this.regex = this.compile();
|
|
29
|
+
}
|
|
30
|
+
getMetadata() {
|
|
31
|
+
return {
|
|
32
|
+
key: "function_module_parameter_names",
|
|
33
|
+
title: "Function module parameter naming conventions",
|
|
34
|
+
shortDescription: `Allows you to enforce a pattern, such as a prefix, for function module parameter names`,
|
|
35
|
+
extendedInformation: `Checks the parameters of function modules in function groups,
|
|
36
|
+
with a separate pattern for importing, exporting, changing and tables parameters.`,
|
|
37
|
+
tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
|
|
38
|
+
badExample: `FUNCTION z_get_name.
|
|
39
|
+
*" IMPORTING
|
|
40
|
+
*" VALUE(CUSTOMER) TYPE STRING
|
|
41
|
+
*" EXPORTING
|
|
42
|
+
*" VALUE(NAME) TYPE STRING
|
|
43
|
+
ENDFUNCTION.`,
|
|
44
|
+
goodExample: `FUNCTION z_get_name.
|
|
45
|
+
*" IMPORTING
|
|
46
|
+
*" VALUE(IV_CUSTOMER) TYPE STRING
|
|
47
|
+
*" EXPORTING
|
|
48
|
+
*" VALUE(EV_NAME) TYPE STRING
|
|
49
|
+
ENDFUNCTION.`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
getDescription(expected, actual) {
|
|
53
|
+
return this.conf.patternKind === "required" ?
|
|
54
|
+
"Function module parameter name does not match pattern " + expected + ": " + actual :
|
|
55
|
+
"Function module parameter name must not match pattern " + expected + ": " + actual;
|
|
56
|
+
}
|
|
57
|
+
getConfig() {
|
|
58
|
+
return this.conf;
|
|
59
|
+
}
|
|
60
|
+
setConfig(conf) {
|
|
61
|
+
this.conf = conf;
|
|
62
|
+
this.regex = this.compile();
|
|
63
|
+
}
|
|
64
|
+
compile() {
|
|
65
|
+
return {
|
|
66
|
+
importing: new RegExp(this.conf.importing, "i"),
|
|
67
|
+
exporting: new RegExp(this.conf.exporting, "i"),
|
|
68
|
+
changing: new RegExp(this.conf.changing, "i"),
|
|
69
|
+
tables: new RegExp(this.conf.tables, "i"),
|
|
70
|
+
ignorePatterns: name_validator_1.NameValidator.compileIgnorePatterns(this.conf),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
initialize(_reg) {
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
run(obj) {
|
|
77
|
+
if (this.conf.patternKind === undefined) {
|
|
78
|
+
this.conf.patternKind = "required";
|
|
79
|
+
}
|
|
80
|
+
if (!(obj instanceof function_group_1.FunctionGroup)) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
let ret = [];
|
|
84
|
+
for (const module of obj.getModules()) {
|
|
85
|
+
ret = ret.concat(this.checkModule(obj, module));
|
|
86
|
+
}
|
|
87
|
+
return ret;
|
|
88
|
+
}
|
|
89
|
+
checkModule(obj, module) {
|
|
90
|
+
const ret = [];
|
|
91
|
+
for (const p of module.getParameters()) {
|
|
92
|
+
let expected;
|
|
93
|
+
let regex;
|
|
94
|
+
switch (p.direction) {
|
|
95
|
+
case function_module_definition_1.FunctionModuleParameterDirection.importing:
|
|
96
|
+
expected = this.conf.importing;
|
|
97
|
+
regex = this.regex.importing;
|
|
98
|
+
break;
|
|
99
|
+
case function_module_definition_1.FunctionModuleParameterDirection.exporting:
|
|
100
|
+
expected = this.conf.exporting;
|
|
101
|
+
regex = this.regex.exporting;
|
|
102
|
+
break;
|
|
103
|
+
case function_module_definition_1.FunctionModuleParameterDirection.changing:
|
|
104
|
+
expected = this.conf.changing;
|
|
105
|
+
regex = this.regex.changing;
|
|
106
|
+
break;
|
|
107
|
+
case function_module_definition_1.FunctionModuleParameterDirection.tables:
|
|
108
|
+
expected = this.conf.tables;
|
|
109
|
+
regex = this.regex.tables;
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const issue = this.checkParameter(obj, module, p, expected, regex);
|
|
115
|
+
if (issue) {
|
|
116
|
+
ret.push(issue);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return ret;
|
|
120
|
+
}
|
|
121
|
+
checkParameter(obj, module, param, expected, regex) {
|
|
122
|
+
if (!name_validator_1.NameValidator.violatesRule(param.name, regex, this.conf, this.regex.ignorePatterns)) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
// the parameter is only defined in the XML, so report at the start of the module file, if it exists
|
|
126
|
+
const file = this.findModuleFile(obj, module) || obj.getMainABAPFile();
|
|
127
|
+
if (file === undefined) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
const message = this.getDescription(expected, param.name);
|
|
131
|
+
return issue_1.Issue.atPosition(file, new position_1.Position(1, 1), message, this.getMetadata().key, this.conf.severity);
|
|
132
|
+
}
|
|
133
|
+
findModuleFile(obj, module) {
|
|
134
|
+
const search = "." + module.getName().toLowerCase().replace(/\//g, "#") + ".abap";
|
|
135
|
+
return obj.getABAPFiles().find(f => f.getFilename().toLowerCase().endsWith(search));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.FunctionModuleParameterNames = FunctionModuleParameterNames;
|
|
139
|
+
//# sourceMappingURL=function_module_parameter_names.js.map
|
package/build/src/rules/index.js
CHANGED
|
@@ -102,6 +102,7 @@ __exportStar(require("./forbidden_void_type"), exports);
|
|
|
102
102
|
__exportStar(require("./form_tables_obsolete"), exports);
|
|
103
103
|
__exportStar(require("./fully_type_constants"), exports);
|
|
104
104
|
__exportStar(require("./fully_type_itabs"), exports);
|
|
105
|
+
__exportStar(require("./function_module_parameter_names"), exports);
|
|
105
106
|
__exportStar(require("./function_module_recommendations"), exports);
|
|
106
107
|
__exportStar(require("./functional_writing"), exports);
|
|
107
108
|
__exportStar(require("./generic_regex"), exports);
|
|
@@ -208,6 +209,7 @@ __exportStar(require("./single_use_expression_temp"), exports);
|
|
|
208
209
|
__exportStar(require("./slow_parameter_passing"), exports);
|
|
209
210
|
__exportStar(require("./smim_consistency"), exports);
|
|
210
211
|
__exportStar(require("./sort_empty_key"), exports);
|
|
212
|
+
__exportStar(require("./sort_required"), exports);
|
|
211
213
|
__exportStar(require("./space_before_colon"), exports);
|
|
212
214
|
__exportStar(require("./space_before_dot"), exports);
|
|
213
215
|
__exportStar(require("./sql_escape_host_variables"), exports);
|
|
@@ -219,6 +221,7 @@ __exportStar(require("./strict_sql"), exports);
|
|
|
219
221
|
__exportStar(require("./subrc_after_assign"), exports);
|
|
220
222
|
__exportStar(require("./superclass_final"), exports);
|
|
221
223
|
__exportStar(require("./superfluous_value"), exports);
|
|
224
|
+
__exportStar(require("./suspicious_loop"), exports);
|
|
222
225
|
__exportStar(require("./sy_modification"), exports);
|
|
223
226
|
__exportStar(require("./sy_read_restriction"), exports);
|
|
224
227
|
__exportStar(require("./tabl_enhancement_category"), exports);
|
|
@@ -228,6 +231,7 @@ __exportStar(require("./try_without_catch"), exports);
|
|
|
228
231
|
__exportStar(require("./type_form_parameters"), exports);
|
|
229
232
|
__exportStar(require("./types_naming"), exports);
|
|
230
233
|
__exportStar(require("./uncaught_exception"), exports);
|
|
234
|
+
__exportStar(require("./unhandled_classic_exception"), exports);
|
|
231
235
|
__exportStar(require("./unit_test_assertions"), exports);
|
|
232
236
|
__exportStar(require("./unknown_types"), exports);
|
|
233
237
|
__exportStar(require("./unnecessary_chaining"), exports);
|