@abaplint/core 2.109.2 → 2.109.3
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
|
@@ -3221,10 +3221,14 @@ declare interface IMacroReferences {
|
|
|
3221
3221
|
addReference(ref: IFilenameAndToken): void;
|
|
3222
3222
|
listDefinitionsByFile(filename: string): Token[];
|
|
3223
3223
|
listUsagesbyMacro(filename: string, token: Token): IFilenameAndToken[];
|
|
3224
|
-
|
|
3224
|
+
getDefinitionRange(filename: string, token: Token): {
|
|
3225
3225
|
start: Position;
|
|
3226
3226
|
end: Position;
|
|
3227
3227
|
} | undefined;
|
|
3228
|
+
findDefinitionByUsage(filename: string, token: Token): {
|
|
3229
|
+
filename: string;
|
|
3230
|
+
token: Token;
|
|
3231
|
+
} | undefined;
|
|
3228
3232
|
clear(filename: string): void;
|
|
3229
3233
|
}
|
|
3230
3234
|
|
package/build/src/lsp/_lookup.js
CHANGED
|
@@ -12,6 +12,7 @@ const _reference_1 = require("../abap/5_syntax/_reference");
|
|
|
12
12
|
const _builtin_1 = require("../abap/5_syntax/_builtin");
|
|
13
13
|
const _scope_type_1 = require("../abap/5_syntax/_scope_type");
|
|
14
14
|
const types_1 = require("../abap/types");
|
|
15
|
+
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
15
16
|
class LSPLookup {
|
|
16
17
|
static lookup(cursor, reg, obj) {
|
|
17
18
|
var _a, _b;
|
|
@@ -128,6 +129,18 @@ class LSPLookup {
|
|
|
128
129
|
scope: bottomScope,
|
|
129
130
|
};
|
|
130
131
|
}
|
|
132
|
+
if (cursor.snode.get() instanceof _statement_1.MacroCall) {
|
|
133
|
+
const macroDefinition = reg.getMacroReferences().findDefinitionByUsage(cursor.identifier.getFilename(), cursor.snode.getFirstToken());
|
|
134
|
+
if (macroDefinition) {
|
|
135
|
+
return {
|
|
136
|
+
hover: "Macro Call",
|
|
137
|
+
definition: {
|
|
138
|
+
uri: macroDefinition === null || macroDefinition === void 0 ? void 0 : macroDefinition.filename,
|
|
139
|
+
range: _lsp_utils_1.LSPUtils.tokenToRange(macroDefinition.token),
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
131
144
|
if (hoverValue !== "") {
|
|
132
145
|
return { hover: hoverValue, scope: bottomScope };
|
|
133
146
|
}
|
|
@@ -30,6 +30,7 @@ class References {
|
|
|
30
30
|
const locs = this.search(lookup.definitionId, lookup.scope);
|
|
31
31
|
return locs.map(_lsp_utils_1.LSPUtils.identiferToLocation);
|
|
32
32
|
}
|
|
33
|
+
////////////////////////////////////////////
|
|
33
34
|
// todo, cleanup this mehtod, some of the method parameters are not used anymore?
|
|
34
35
|
search(identifier, node, exitAfterFound = false, removeDuplicates = true) {
|
|
35
36
|
let ret = [];
|
|
@@ -57,7 +58,6 @@ class References {
|
|
|
57
58
|
return ret;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
////////////////////////////////////////////
|
|
61
61
|
removeDuplicates(arr) {
|
|
62
62
|
const values = {};
|
|
63
63
|
return arr.filter(item => {
|
|
@@ -15,7 +15,7 @@ class MacroReferences {
|
|
|
15
15
|
}
|
|
16
16
|
this.definitions[ref.filename].push({ token: ref.token, start, end });
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
getDefinitionRange(filename, token) {
|
|
19
19
|
for (const d of this.definitions[filename] || []) {
|
|
20
20
|
if (d.token.getStart().equals(token.getStart())) {
|
|
21
21
|
return { start: d.start, end: d.end };
|
|
@@ -50,6 +50,22 @@ class MacroReferences {
|
|
|
50
50
|
delete this.definitions[filename];
|
|
51
51
|
delete this.references[filename];
|
|
52
52
|
}
|
|
53
|
+
findDefinitionByUsage(filename, token) {
|
|
54
|
+
const tokenStr = token.getStr().toUpperCase();
|
|
55
|
+
for (const ref of this.references[filename] || []) {
|
|
56
|
+
if (ref.token.getStart().equals(token.getStart())) {
|
|
57
|
+
for (const d of this.definitions[ref.filename] || []) {
|
|
58
|
+
if (d.token.getStr().toUpperCase() === tokenStr) {
|
|
59
|
+
return {
|
|
60
|
+
filename: ref.filename,
|
|
61
|
+
token: d.token,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
53
69
|
}
|
|
54
70
|
exports.MacroReferences = MacroReferences;
|
|
55
71
|
//# sourceMappingURL=macro_references.js.map
|
package/build/src/registry.js
CHANGED
|
@@ -61,7 +61,7 @@ foobar2.`,
|
|
|
61
61
|
const usages = references.listUsagesbyMacro(file.getFilename(), macroToken);
|
|
62
62
|
if (usages.length === 0 && ((_a = this.conf.skipNames) === null || _a === void 0 ? void 0 : _a.includes(macroToken.getStr().toUpperCase())) === false) {
|
|
63
63
|
const message = "Unused macro definition: " + macroToken.getStr();
|
|
64
|
-
const pos = references.
|
|
64
|
+
const pos = references.getDefinitionRange(file.getFilename(), macroToken);
|
|
65
65
|
const fix = edit_helper_1.EditHelper.deleteRange(file, pos.start, pos.end);
|
|
66
66
|
result.push(issue_1.Issue.atToken(file, macroToken, message, this.getMetadata().key, this.conf.severity, fix));
|
|
67
67
|
}
|