@abaplint/core 2.113.11 → 2.113.13
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/src/registry.js
CHANGED
|
@@ -63,6 +63,7 @@ class UnusedMethods {
|
|
|
63
63
|
extendedInformation: `Checks private and protected methods.
|
|
64
64
|
|
|
65
65
|
Unused methods are not reported if the object contains parser or syntax errors.
|
|
66
|
+
Quick fixes only appears for private methods or projected methods where the class doesnt have any subclasses.
|
|
66
67
|
|
|
67
68
|
Skips:
|
|
68
69
|
* methods FOR TESTING
|
|
@@ -154,18 +155,37 @@ Skips:
|
|
|
154
155
|
else if (this.suppressedbyPseudo(statement, file)) {
|
|
155
156
|
continue;
|
|
156
157
|
}
|
|
157
|
-
const implementation = this.findMethodImplementation(i, file);
|
|
158
158
|
let fix = undefined;
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
|
|
159
|
+
if (i.visibility === visibility_1.Visibility.Private
|
|
160
|
+
|| (i.visibility === visibility_1.Visibility.Protected && this.hasSubClass(obj) === false)) {
|
|
161
|
+
const implementation = this.findMethodImplementation(i, file);
|
|
162
|
+
if (implementation !== undefined) {
|
|
163
|
+
const fix1 = edit_helper_1.EditHelper.deleteStatement(file, statement);
|
|
164
|
+
const fix2 = edit_helper_1.EditHelper.deleteRange(file, implementation.getFirstToken().getStart(), implementation.getLastToken().getEnd());
|
|
165
|
+
fix = edit_helper_1.EditHelper.merge(fix1, fix2);
|
|
166
|
+
}
|
|
163
167
|
}
|
|
164
168
|
const message = "Method \"" + i.identifier.getName() + "\" not used";
|
|
165
169
|
issues.push(issue_1.Issue.atIdentifier(i.identifier, message, this.getMetadata().key, this.conf.severity, fix));
|
|
166
170
|
}
|
|
167
171
|
return issues;
|
|
168
172
|
}
|
|
173
|
+
hasSubClass(obj) {
|
|
174
|
+
var _a, _b, _c;
|
|
175
|
+
if (!(obj instanceof objects_1.Class)) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
if (((_a = obj.getDefinition()) === null || _a === void 0 ? void 0 : _a.isFinal()) === true) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
for (const r of this.reg.getObjects()) {
|
|
182
|
+
if (r instanceof objects_1.Class
|
|
183
|
+
&& ((_c = (_b = r.getDefinition()) === null || _b === void 0 ? void 0 : _b.getSuperClass()) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === obj.getName().toUpperCase()) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
169
189
|
findMethodImplementation(method, file) {
|
|
170
190
|
var _a, _b;
|
|
171
191
|
for (const classImplementation of ((_a = file.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllStructures(Structures.ClassImplementation)) || []) {
|