@abaplint/core 2.86.8 → 2.87.0
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
CHANGED
|
@@ -2646,6 +2646,7 @@ export declare const enum IdentifierMeta {
|
|
|
2646
2646
|
EventParameter = "event_parameter",
|
|
2647
2647
|
FormParameter = "form_parameter",
|
|
2648
2648
|
ReadOnly = "read_only",
|
|
2649
|
+
PassByValue = "pass_by_value",
|
|
2649
2650
|
InlineDefinition = "inline",
|
|
2650
2651
|
BuiltIn = "built-in",
|
|
2651
2652
|
DDIC = "ddic",
|
|
@@ -163,7 +163,14 @@ class MethodParameters {
|
|
|
163
163
|
if (p === undefined) {
|
|
164
164
|
continue;
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
const extraMeta = [];
|
|
167
|
+
if (opt.concatTokens().toUpperCase().startsWith("VALUE(")) {
|
|
168
|
+
extraMeta.push("pass_by_value" /* PassByValue */);
|
|
169
|
+
}
|
|
170
|
+
else if (meta.includes("importing" /* MethodImporting */)) {
|
|
171
|
+
extraMeta.push("read_only" /* ReadOnly */);
|
|
172
|
+
}
|
|
173
|
+
target.push(new method_param_1.MethodParam().runSyntax(p, scope, this.filename, [...meta, ...extraMeta]));
|
|
167
174
|
if (opt.getLastToken().getStr().toUpperCase() === "OPTIONAL") {
|
|
168
175
|
const name = target[target.length - 1].getName().toUpperCase();
|
|
169
176
|
this.optional.push(name);
|
package/build/src/registry.js
CHANGED
package/build/src/rules/index.js
CHANGED
|
@@ -129,6 +129,7 @@ __exportStar(require("./selection_screen_naming"), exports);
|
|
|
129
129
|
__exportStar(require("./sequential_blank"), exports);
|
|
130
130
|
__exportStar(require("./short_case"), exports);
|
|
131
131
|
__exportStar(require("./sicf_consistency"), exports);
|
|
132
|
+
__exportStar(require("./slow_parameter_passing"), exports);
|
|
132
133
|
__exportStar(require("./space_before_colon"), exports);
|
|
133
134
|
__exportStar(require("./space_before_dot"), exports);
|
|
134
135
|
__exportStar(require("./sql_escape_host_variables"), exports);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlowParameterPassing = exports.SlowParameterPassingConf = void 0;
|
|
4
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
5
|
+
const issue_1 = require("../issue");
|
|
6
|
+
const _irule_1 = require("./_irule");
|
|
7
|
+
const _abap_object_1 = require("../objects/_abap_object");
|
|
8
|
+
const syntax_1 = require("../abap/5_syntax/syntax");
|
|
9
|
+
const _scope_type_1 = require("../abap/5_syntax/_scope_type");
|
|
10
|
+
const _reference_1 = require("../abap/5_syntax/_reference");
|
|
11
|
+
class SlowParameterPassingConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
12
|
+
}
|
|
13
|
+
exports.SlowParameterPassingConf = SlowParameterPassingConf;
|
|
14
|
+
class SlowParameterPassing {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.conf = new SlowParameterPassingConf();
|
|
17
|
+
}
|
|
18
|
+
getMetadata() {
|
|
19
|
+
return {
|
|
20
|
+
key: "slow_parameter_passing",
|
|
21
|
+
title: "Slow Parameter Passing",
|
|
22
|
+
shortDescription: `Detects show pass by value passing for methods where parameter is not changed`,
|
|
23
|
+
tags: [_irule_1.RuleTag.Performance],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
getConfig() {
|
|
27
|
+
return this.conf;
|
|
28
|
+
}
|
|
29
|
+
setConfig(conf) {
|
|
30
|
+
this.conf = conf;
|
|
31
|
+
}
|
|
32
|
+
initialize(reg) {
|
|
33
|
+
this.reg = reg;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
run(obj) {
|
|
37
|
+
const issues = [];
|
|
38
|
+
if (!(obj instanceof _abap_object_1.ABAPObject)) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const top = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti.getTop();
|
|
42
|
+
const methods = this.listMethodNodes(top);
|
|
43
|
+
for (const m of methods) {
|
|
44
|
+
const vars = m.getData().vars;
|
|
45
|
+
for (const v in vars) {
|
|
46
|
+
const id = vars[v];
|
|
47
|
+
if (id.getMeta().includes("pass_by_value" /* PassByValue */) === false) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const writes = this.listWritePositions(m, id);
|
|
51
|
+
if (writes.length === 0) {
|
|
52
|
+
const message = "Parameter passed by VALUE but not changed";
|
|
53
|
+
issues.push(issue_1.Issue.atIdentifier(id, message, this.getMetadata().key, this.getConfig().severity));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return issues;
|
|
58
|
+
}
|
|
59
|
+
listWritePositions(node, id) {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const ret = [];
|
|
62
|
+
for (const v of node.getData().references) {
|
|
63
|
+
if (v.referenceType === _reference_1.ReferenceType.DataWriteReference
|
|
64
|
+
&& ((_a = v.resolved) === null || _a === void 0 ? void 0 : _a.getFilename()) === id.getFilename()
|
|
65
|
+
&& ((_b = v.resolved) === null || _b === void 0 ? void 0 : _b.getStart().equals(id.getStart()))) {
|
|
66
|
+
ret.push(v.position.getStart());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return ret;
|
|
70
|
+
}
|
|
71
|
+
listMethodNodes(node) {
|
|
72
|
+
const ret = [];
|
|
73
|
+
if (node.getIdentifier().stype === _scope_type_1.ScopeType.Method) {
|
|
74
|
+
ret.push(node);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
for (const c of node.getChildren()) {
|
|
78
|
+
ret.push(...this.listMethodNodes(c));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return ret;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.SlowParameterPassing = SlowParameterPassing;
|
|
85
|
+
//# sourceMappingURL=slow_parameter_passing.js.map
|