@abaplint/core 2.101.12 → 2.101.14
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 +10 -1
- package/build/src/abap/5_syntax/expressions/source.js +19 -6
- package/build/src/abap/5_syntax/expressions/value_body.js +2 -1
- package/build/src/abap/5_syntax/statements/insert_internal.js +3 -3
- package/build/src/lsp/_lsp_utils.js +3 -0
- package/build/src/lsp/code_lens.js +16 -8
- package/build/src/lsp/inlay_hints.js +65 -0
- package/build/src/lsp/language_server.js +7 -2
- package/build/src/registry.js +1 -1
- package/package.json +2 -2
package/build/abaplint.d.ts
CHANGED
|
@@ -1063,6 +1063,10 @@ declare class CloseDataset implements IStatement {
|
|
|
1063
1063
|
getMatcher(): IStatementRunnable;
|
|
1064
1064
|
}
|
|
1065
1065
|
|
|
1066
|
+
declare type CodeLensSettings = {
|
|
1067
|
+
messageText: boolean;
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1066
1070
|
declare class Collect implements IStatement {
|
|
1067
1071
|
getMatcher(): IStatementRunnable;
|
|
1068
1072
|
}
|
|
@@ -3272,6 +3276,10 @@ declare class Initialization implements IStatement {
|
|
|
3272
3276
|
getMatcher(): IStatementRunnable;
|
|
3273
3277
|
}
|
|
3274
3278
|
|
|
3279
|
+
declare type InlayHintsSettings = {
|
|
3280
|
+
inferredTypes: boolean;
|
|
3281
|
+
};
|
|
3282
|
+
|
|
3275
3283
|
declare class InlineData extends Expression {
|
|
3276
3284
|
getRunnable(): IStatementRunnable;
|
|
3277
3285
|
}
|
|
@@ -3787,7 +3795,8 @@ export declare class LanguageServer {
|
|
|
3787
3795
|
references(params: ITextDocumentPositionParams): LServer.Location[];
|
|
3788
3796
|
static semanticTokensLegend(): LServer.SemanticTokensLegend;
|
|
3789
3797
|
semanticTokensRange(range: ITextDocumentRange): LServer.SemanticTokens;
|
|
3790
|
-
codeLens(textDocument: LServer.TextDocumentIdentifier): LServer.CodeLens[];
|
|
3798
|
+
codeLens(textDocument: LServer.TextDocumentIdentifier, settings?: CodeLensSettings): LServer.CodeLens[];
|
|
3799
|
+
inlayHints(textDocument: LServer.TextDocumentIdentifier, settings?: InlayHintsSettings): LServer.InlayHint[];
|
|
3791
3800
|
help(textDocument: LServer.TextDocumentIdentifier, position: LServer.Position): string;
|
|
3792
3801
|
listDefinitionPositions(textDocument: LServer.TextDocumentIdentifier): LServer.Range[];
|
|
3793
3802
|
listReadPositions(textDocument: LServer.TextDocumentIdentifier): LServer.Range[];
|
|
@@ -65,27 +65,36 @@ class Source {
|
|
|
65
65
|
{
|
|
66
66
|
const foundType = this.determineType(node, scope, filename, targetType);
|
|
67
67
|
const bodyType = new reduce_body_1.ReduceBody().runSyntax(node.findDirectExpression(Expressions.ReduceBody), scope, filename, foundType);
|
|
68
|
-
if (foundType === undefined || foundType.isGeneric()
|
|
68
|
+
if (foundType === undefined || foundType.isGeneric()) {
|
|
69
69
|
this.addIfInferred(node, scope, filename, bodyType);
|
|
70
70
|
}
|
|
71
|
+
else {
|
|
72
|
+
this.addIfInferred(node, scope, filename, foundType);
|
|
73
|
+
}
|
|
71
74
|
return foundType ? foundType : bodyType;
|
|
72
75
|
}
|
|
73
76
|
case "SWITCH":
|
|
74
77
|
{
|
|
75
78
|
const foundType = this.determineType(node, scope, filename, targetType);
|
|
76
79
|
const bodyType = new switch_body_1.SwitchBody().runSyntax(node.findDirectExpression(Expressions.SwitchBody), scope, filename);
|
|
77
|
-
if (foundType === undefined || foundType.isGeneric()
|
|
80
|
+
if (foundType === undefined || foundType.isGeneric()) {
|
|
78
81
|
this.addIfInferred(node, scope, filename, bodyType);
|
|
79
82
|
}
|
|
83
|
+
else {
|
|
84
|
+
this.addIfInferred(node, scope, filename, foundType);
|
|
85
|
+
}
|
|
80
86
|
return foundType ? foundType : bodyType;
|
|
81
87
|
}
|
|
82
88
|
case "COND":
|
|
83
89
|
{
|
|
84
90
|
const foundType = this.determineType(node, scope, filename, targetType);
|
|
85
91
|
const bodyType = new cond_body_1.CondBody().runSyntax(node.findDirectExpression(Expressions.CondBody), scope, filename);
|
|
86
|
-
if (foundType === undefined || foundType.isGeneric()
|
|
92
|
+
if (foundType === undefined || foundType.isGeneric()) {
|
|
87
93
|
this.addIfInferred(node, scope, filename, bodyType);
|
|
88
94
|
}
|
|
95
|
+
else {
|
|
96
|
+
this.addIfInferred(node, scope, filename, foundType);
|
|
97
|
+
}
|
|
89
98
|
return foundType ? foundType : bodyType;
|
|
90
99
|
}
|
|
91
100
|
case "CONV":
|
|
@@ -126,7 +135,9 @@ class Source {
|
|
|
126
135
|
case "CORRESPONDING":
|
|
127
136
|
{
|
|
128
137
|
const foundType = this.determineType(node, scope, filename, targetType);
|
|
129
|
-
|
|
138
|
+
new corresponding_body_1.CorrespondingBody().runSyntax(node.findDirectExpression(Expressions.CorrespondingBody), scope, filename, foundType);
|
|
139
|
+
this.addIfInferred(node, scope, filename, foundType);
|
|
140
|
+
return foundType;
|
|
130
141
|
}
|
|
131
142
|
case "EXACT":
|
|
132
143
|
return this.determineType(node, scope, filename, targetType);
|
|
@@ -222,10 +233,12 @@ class Source {
|
|
|
222
233
|
throw new Error("determineType, child TypeNameOrInfer not found");
|
|
223
234
|
}
|
|
224
235
|
else if (typeName === "#" && targetType) {
|
|
225
|
-
const found = basic.lookupQualifiedName(targetType.getQualifiedName());
|
|
236
|
+
// const found = basic.lookupQualifiedName(targetType.getQualifiedName());
|
|
237
|
+
/*
|
|
226
238
|
if (found) {
|
|
227
|
-
|
|
239
|
+
scope.addReference(typeToken, found, ReferenceType.InferredType, filename);
|
|
228
240
|
}
|
|
241
|
+
*/
|
|
229
242
|
return targetType;
|
|
230
243
|
}
|
|
231
244
|
if (typeName !== "#" && typeToken) {
|
|
@@ -45,6 +45,7 @@ class ValueBody {
|
|
|
45
45
|
}
|
|
46
46
|
for (const l of foo.findDirectExpressions(Expressions.ValueBodyLines)) {
|
|
47
47
|
for (const s of l.findDirectExpressions(Expressions.Source)) {
|
|
48
|
+
// LINES OF ?? todo, pass type,
|
|
48
49
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -52,7 +53,7 @@ class ValueBody {
|
|
|
52
53
|
new field_assignment_1.FieldAssignment().runSyntax(s, scope, filename, rowType);
|
|
53
54
|
}
|
|
54
55
|
for (const s of foo.findDirectExpressions(Expressions.Source)) {
|
|
55
|
-
new source_1.Source().runSyntax(s, scope, filename);
|
|
56
|
+
new source_1.Source().runSyntax(s, scope, filename, rowType);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
if (letScoped === true) {
|
|
@@ -44,9 +44,9 @@ class InsertInternal {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
if (s === source) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
50
|
new source_1.Source().runSyntax(s, scope, filename, targetType);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -26,6 +26,9 @@ class LSPUtils {
|
|
|
26
26
|
static tokenToRange(token) {
|
|
27
27
|
return LServer.Range.create(token.getStart().getRow() - 1, token.getStart().getCol() - 1, token.getEnd().getRow() - 1, token.getEnd().getCol() - 1);
|
|
28
28
|
}
|
|
29
|
+
static positionToLS(pos) {
|
|
30
|
+
return LServer.Position.create(pos.getRow() - 1, pos.getCol() - 1);
|
|
31
|
+
}
|
|
29
32
|
static identiferToLocation(identifier) {
|
|
30
33
|
return {
|
|
31
34
|
uri: identifier.getFilename(),
|
|
@@ -9,7 +9,7 @@ class CodeLens {
|
|
|
9
9
|
constructor(reg) {
|
|
10
10
|
this.reg = reg;
|
|
11
11
|
}
|
|
12
|
-
list(textDocument) {
|
|
12
|
+
list(textDocument, settings = { messageText: true }) {
|
|
13
13
|
var _a;
|
|
14
14
|
const file = _lsp_utils_1.LSPUtils.getABAPFile(this.reg, textDocument.uri);
|
|
15
15
|
if (file === undefined) {
|
|
@@ -21,14 +21,22 @@ class CodeLens {
|
|
|
21
21
|
}
|
|
22
22
|
new syntax_1.SyntaxLogic(this.reg, obj).run();
|
|
23
23
|
const ret = [];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
if (settings.messageText === true) {
|
|
25
|
+
const list = this.reg.getMSAGReferences().listByFilename(file.getFilename());
|
|
26
|
+
for (const l of list) {
|
|
27
|
+
const msag = this.reg.getObject("MSAG", l.messageClass);
|
|
28
|
+
if (msag === undefined) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const text = (_a = msag.getByNumber(l.number)) === null || _a === void 0 ? void 0 : _a.getMessage();
|
|
32
|
+
if (text === undefined) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
ret.push({
|
|
36
|
+
range: _lsp_utils_1.LSPUtils.tokenToRange(l.token),
|
|
37
|
+
command: LServer.Command.create(text, ""),
|
|
38
|
+
});
|
|
29
39
|
}
|
|
30
|
-
const text = (_a = msag.getByNumber(l.number)) === null || _a === void 0 ? void 0 : _a.getMessage();
|
|
31
|
-
ret.push(LServer.CodeLens.create(_lsp_utils_1.LSPUtils.tokenToRange(l.token), text));
|
|
32
40
|
}
|
|
33
41
|
return ret;
|
|
34
42
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InlayHints = void 0;
|
|
4
|
+
const LServer = require("vscode-languageserver-types");
|
|
5
|
+
const _lsp_utils_1 = require("./_lsp_utils");
|
|
6
|
+
const syntax_1 = require("../abap/5_syntax/syntax");
|
|
7
|
+
const _abap_object_1 = require("../objects/_abap_object");
|
|
8
|
+
const _reference_1 = require("../abap/5_syntax/_reference");
|
|
9
|
+
const _typed_identifier_1 = require("../abap/types/_typed_identifier");
|
|
10
|
+
const types_1 = require("../abap/types");
|
|
11
|
+
class InlayHints {
|
|
12
|
+
constructor(reg) {
|
|
13
|
+
this.reg = reg;
|
|
14
|
+
}
|
|
15
|
+
list(textDocument, settings = { inferredTypes: true }) {
|
|
16
|
+
const file = _lsp_utils_1.LSPUtils.getABAPFile(this.reg, textDocument.uri);
|
|
17
|
+
if (file === undefined) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
const obj = this.reg.findObjectForFile(file);
|
|
21
|
+
if (obj === undefined || !(obj instanceof _abap_object_1.ABAPObject)) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const top = new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti.getTop();
|
|
25
|
+
const ret = [];
|
|
26
|
+
if (settings.inferredTypes === true) {
|
|
27
|
+
const implicit = this.findImplicitReferences(top);
|
|
28
|
+
for (const i of implicit) {
|
|
29
|
+
let label = undefined;
|
|
30
|
+
if (i.resolved instanceof _typed_identifier_1.TypedIdentifier) {
|
|
31
|
+
label = "TYPE " + i.resolved.getType().toABAP();
|
|
32
|
+
}
|
|
33
|
+
else if (i.resolved instanceof types_1.ClassDefinition) {
|
|
34
|
+
label = "TYPE REF TO " + i.resolved.getName();
|
|
35
|
+
}
|
|
36
|
+
if (label === undefined) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
ret.push({
|
|
40
|
+
label: label,
|
|
41
|
+
tooltip: "Inferred type",
|
|
42
|
+
kind: LServer.InlayHintKind.Type,
|
|
43
|
+
paddingLeft: true,
|
|
44
|
+
paddingRight: true,
|
|
45
|
+
position: _lsp_utils_1.LSPUtils.positionToLS(i.position.getEnd()),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return ret;
|
|
50
|
+
}
|
|
51
|
+
findImplicitReferences(node) {
|
|
52
|
+
const ret = [];
|
|
53
|
+
for (const r of node.getData().references) {
|
|
54
|
+
if (r.referenceType === _reference_1.ReferenceType.InferredType) {
|
|
55
|
+
ret.push(r);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const c of node.getChildren()) {
|
|
59
|
+
ret.push(...this.findImplicitReferences(c));
|
|
60
|
+
}
|
|
61
|
+
return ret;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.InlayHints = InlayHints;
|
|
65
|
+
//# sourceMappingURL=inlay_hints.js.map
|
|
@@ -17,6 +17,7 @@ const implementation_1 = require("./implementation");
|
|
|
17
17
|
const semantic_1 = require("./semantic");
|
|
18
18
|
const statement_flow_1 = require("../abap/flow/statement_flow");
|
|
19
19
|
const code_lens_1 = require("./code_lens");
|
|
20
|
+
const inlay_hints_1 = require("./inlay_hints");
|
|
20
21
|
// note Ranges are zero based in LSP,
|
|
21
22
|
// https://github.com/microsoft/language-server-protocol/blob/main/versions/protocol-2-x.md#range
|
|
22
23
|
// but 1 based in abaplint
|
|
@@ -98,8 +99,12 @@ class LanguageServer {
|
|
|
98
99
|
return new semantic_1.SemanticHighlighting(this.reg).semanticTokensRange(range);
|
|
99
100
|
}
|
|
100
101
|
// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeLens
|
|
101
|
-
codeLens(textDocument) {
|
|
102
|
-
return new code_lens_1.CodeLens(this.reg).list(textDocument);
|
|
102
|
+
codeLens(textDocument, settings) {
|
|
103
|
+
return new code_lens_1.CodeLens(this.reg).list(textDocument, settings);
|
|
104
|
+
}
|
|
105
|
+
// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint
|
|
106
|
+
inlayHints(textDocument, settings) {
|
|
107
|
+
return new inlay_hints_1.InlayHints(this.reg).list(textDocument, settings);
|
|
103
108
|
}
|
|
104
109
|
////////////////////////////////////////
|
|
105
110
|
// ______ _
|
package/build/src/registry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.101.
|
|
3
|
+
"version": "2.101.14",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"typescript": "^5.1.3"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"fast-xml-parser": "^4.2.
|
|
64
|
+
"fast-xml-parser": "^4.2.4",
|
|
65
65
|
"json5": "^2.2.3",
|
|
66
66
|
"vscode-languageserver-types": "^3.17.3"
|
|
67
67
|
}
|