@abaplint/core 2.81.2 → 2.81.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 +29 -16
- package/build/src/abap/5_syntax/_builtin.js +817 -80
- package/build/src/abap/5_syntax/_object_oriented.js +13 -9
- package/build/src/abap/5_syntax/_reference.js +16 -16
- package/build/src/abap/5_syntax/statements/class_implementation.js +2 -3
- package/build/src/abap/5_syntax/statements/method_implementation.js +0 -2
- package/build/src/abap/nodes/expression_node.js +2 -2
- package/build/src/abap/nodes/statement_node.js +1 -1
- package/build/src/abap/types/class_definition.js +1 -2
- package/build/src/edit_helper.js +6 -2
- package/build/src/lsp/_lookup.js +46 -25
- package/build/src/registry.js +1 -1
- package/build/src/rules/parser_missing_space.js +2 -1
- package/package.json +2 -2
|
@@ -9,14 +9,6 @@ class ObjectOriented {
|
|
|
9
9
|
constructor(scope) {
|
|
10
10
|
this.scope = scope;
|
|
11
11
|
}
|
|
12
|
-
// returns list of interfaces implemented
|
|
13
|
-
fromInterfaces(classDefinition, skip) {
|
|
14
|
-
const ignore = [];
|
|
15
|
-
for (const i of classDefinition.getImplementing()) {
|
|
16
|
-
ignore.push(...this.fromInterfaceByName(i.name, ignore.concat(skip || [])));
|
|
17
|
-
}
|
|
18
|
-
return ignore;
|
|
19
|
-
}
|
|
20
12
|
fromInterfaceByName(name, ignore) {
|
|
21
13
|
const idef = this.scope.findInterfaceDefinition(name);
|
|
22
14
|
if (idef === undefined || ignore.includes(name.toUpperCase())) {
|
|
@@ -279,8 +271,12 @@ class ObjectOriented {
|
|
|
279
271
|
}
|
|
280
272
|
return csup;
|
|
281
273
|
}
|
|
274
|
+
fromSuperClassesAndInterfaces(child) {
|
|
275
|
+
const implemented = this.fromSuperClasses(child);
|
|
276
|
+
this.fromInterfaces(child, implemented);
|
|
277
|
+
}
|
|
282
278
|
// returns list of interfaces implemented
|
|
283
|
-
|
|
279
|
+
fromSuperClasses(child) {
|
|
284
280
|
let sup = child.getSuperClass();
|
|
285
281
|
const ignore = [];
|
|
286
282
|
while (sup !== undefined) {
|
|
@@ -306,6 +302,14 @@ class ObjectOriented {
|
|
|
306
302
|
}
|
|
307
303
|
return ignore;
|
|
308
304
|
}
|
|
305
|
+
// returns list of interfaces implemented
|
|
306
|
+
fromInterfaces(classDefinition, skip) {
|
|
307
|
+
const ignore = [];
|
|
308
|
+
for (const i of classDefinition.getImplementing()) {
|
|
309
|
+
ignore.push(...this.fromInterfaceByName(i.name, ignore.concat(skip || [])));
|
|
310
|
+
}
|
|
311
|
+
return ignore;
|
|
312
|
+
}
|
|
309
313
|
}
|
|
310
314
|
exports.ObjectOriented = ObjectOriented;
|
|
311
315
|
//# sourceMappingURL=_object_oriented.js.map
|
|
@@ -4,21 +4,21 @@ exports.ReferenceType = void 0;
|
|
|
4
4
|
var ReferenceType;
|
|
5
5
|
(function (ReferenceType) {
|
|
6
6
|
/** for classes and interface references */
|
|
7
|
-
ReferenceType["ObjectOrientedReference"] = "
|
|
8
|
-
ReferenceType["ObjectOrientedVoidReference"] = "
|
|
9
|
-
ReferenceType["ObjectOrientedUnknownReference"] = "
|
|
10
|
-
ReferenceType["TableReference"] = "
|
|
11
|
-
ReferenceType["TableVoidReference"] = "
|
|
12
|
-
ReferenceType["MethodReference"] = "
|
|
13
|
-
ReferenceType["BuiltinMethodReference"] = "
|
|
14
|
-
ReferenceType["MethodImplementationReference"] = "
|
|
15
|
-
ReferenceType["TypeReference"] = "
|
|
16
|
-
ReferenceType["BuiltinTypeReference"] = "
|
|
17
|
-
ReferenceType["VoidType"] = "
|
|
18
|
-
ReferenceType["InferredType"] = "
|
|
19
|
-
ReferenceType["FormReference"] = "
|
|
20
|
-
// FormVoidReference = "
|
|
21
|
-
ReferenceType["DataReadReference"] = "
|
|
22
|
-
ReferenceType["DataWriteReference"] = "
|
|
7
|
+
ReferenceType["ObjectOrientedReference"] = "Object";
|
|
8
|
+
ReferenceType["ObjectOrientedVoidReference"] = "Object (Void)";
|
|
9
|
+
ReferenceType["ObjectOrientedUnknownReference"] = "Object (Unknown)";
|
|
10
|
+
ReferenceType["TableReference"] = "Table";
|
|
11
|
+
ReferenceType["TableVoidReference"] = "Table (Void)";
|
|
12
|
+
ReferenceType["MethodReference"] = "Method";
|
|
13
|
+
ReferenceType["BuiltinMethodReference"] = "Builtin Method";
|
|
14
|
+
ReferenceType["MethodImplementationReference"] = "Method Implementation";
|
|
15
|
+
ReferenceType["TypeReference"] = "Type";
|
|
16
|
+
ReferenceType["BuiltinTypeReference"] = "Builtin Type";
|
|
17
|
+
ReferenceType["VoidType"] = "Type (Void)";
|
|
18
|
+
ReferenceType["InferredType"] = "Inferred Type";
|
|
19
|
+
ReferenceType["FormReference"] = "Form";
|
|
20
|
+
// FormVoidReference = "Form (void)",
|
|
21
|
+
ReferenceType["DataReadReference"] = "Read From";
|
|
22
|
+
ReferenceType["DataWriteReference"] = "Write To";
|
|
23
23
|
})(ReferenceType = exports.ReferenceType || (exports.ReferenceType = {}));
|
|
24
24
|
//# sourceMappingURL=_reference.js.map
|
|
@@ -17,7 +17,6 @@ class ClassImplementation {
|
|
|
17
17
|
if (classDefinition === undefined) {
|
|
18
18
|
throw new Error("Class definition for \"" + className + "\" not found");
|
|
19
19
|
}
|
|
20
|
-
const classAttributes = classDefinition.getAttributes();
|
|
21
20
|
for (const t of classDefinition.getTypeDefinitions().getAll()) {
|
|
22
21
|
scope.addType(t.type);
|
|
23
22
|
}
|
|
@@ -27,13 +26,13 @@ class ClassImplementation {
|
|
|
27
26
|
}
|
|
28
27
|
scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(new tokens_1.Identifier(new position_1.Position(1, 1), "me"), _builtin_1.BuiltIn.filename, new basic_1.ObjectReferenceType(classDefinition)));
|
|
29
28
|
helper.addAliasedAttributes(classDefinition); // todo, this is not correct, take care of instance vs static
|
|
29
|
+
const classAttributes = classDefinition.getAttributes();
|
|
30
30
|
scope.addList(classAttributes.getConstants());
|
|
31
31
|
scope.addList(classAttributes.getStatic());
|
|
32
32
|
for (const i of classAttributes.getInstance()) {
|
|
33
33
|
scope.addExtraLikeType(i);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
helper.fromInterfaces(classDefinition, implemented);
|
|
35
|
+
helper.fromSuperClassesAndInterfaces(classDefinition);
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
exports.ClassImplementation = ClassImplementation;
|
|
@@ -13,12 +13,10 @@ class MethodImplementation {
|
|
|
13
13
|
const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr();
|
|
14
14
|
const classDefinition = scope.findClassDefinition(className);
|
|
15
15
|
if (classDefinition === undefined) {
|
|
16
|
-
// scope.pop(node.getLastToken().getEnd());
|
|
17
16
|
throw new Error("Class definition for \"" + className + "\" not found");
|
|
18
17
|
}
|
|
19
18
|
const { method: methodDefinition } = helper.searchMethodName(classDefinition, methodName);
|
|
20
19
|
if (methodDefinition === undefined) {
|
|
21
|
-
// scope.pop(node.getLastToken().getEnd());
|
|
22
20
|
throw new Error("Method definition \"" + methodName + "\" not found");
|
|
23
21
|
}
|
|
24
22
|
if (methodDefinition.isStatic() === false) {
|
|
@@ -189,7 +189,7 @@ class ExpressionNode extends _abstract_node_1.AbstractNode {
|
|
|
189
189
|
}
|
|
190
190
|
return ret;
|
|
191
191
|
}
|
|
192
|
-
findAllExpressionsMulti(type) {
|
|
192
|
+
findAllExpressionsMulti(type, recursive = false) {
|
|
193
193
|
const ret = [];
|
|
194
194
|
for (const child of this.getChildren()) {
|
|
195
195
|
if (child instanceof token_node_1.TokenNode) {
|
|
@@ -201,7 +201,7 @@ class ExpressionNode extends _abstract_node_1.AbstractNode {
|
|
|
201
201
|
ret.push(child);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
if (before === ret.length) {
|
|
204
|
+
if (before === ret.length || recursive === true) {
|
|
205
205
|
ret.push(...child.findAllExpressionsMulti(type));
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -211,7 +211,7 @@ class StatementNode extends _abstract_node_1.AbstractNode {
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
if (before === ret.length || recursive === true) {
|
|
214
|
-
ret.push(...child.findAllExpressionsMulti(type));
|
|
214
|
+
ret.push(...child.findAllExpressionsMulti(type, recursive));
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
return ret;
|
|
@@ -31,8 +31,7 @@ class ClassDefinition extends _identifier_1.Identifier {
|
|
|
31
31
|
this.friends = this.findFriends(def, filename, scope);
|
|
32
32
|
this.parse(filename, scope);
|
|
33
33
|
const helper = new _object_oriented_1.ObjectOriented(scope);
|
|
34
|
-
|
|
35
|
-
helper.fromInterfaces(this, implemented);
|
|
34
|
+
helper.fromSuperClassesAndInterfaces(this);
|
|
36
35
|
this.attributes = new class_attributes_1.Attributes(this.node, this.filename, scope);
|
|
37
36
|
this.types = this.attributes.getTypes();
|
|
38
37
|
this.methodDefs = new method_definitions_1.MethodDefinitions(this.node, this.filename, scope);
|
package/build/src/edit_helper.js
CHANGED
|
@@ -114,10 +114,14 @@ class EditHelper {
|
|
|
114
114
|
continue;
|
|
115
115
|
}
|
|
116
116
|
else if (setPrevious === true) {
|
|
117
|
-
|
|
117
|
+
if (scolon.getStart().equals(colon.getStart())) {
|
|
118
|
+
previousStatement = s;
|
|
119
|
+
}
|
|
118
120
|
}
|
|
119
121
|
else if (setNext === true) {
|
|
120
|
-
|
|
122
|
+
if (scolon.getStart().equals(colon.getStart())) {
|
|
123
|
+
nextStatement = s;
|
|
124
|
+
}
|
|
121
125
|
break;
|
|
122
126
|
}
|
|
123
127
|
}
|
package/build/src/lsp/_lookup.js
CHANGED
|
@@ -28,36 +28,40 @@ class LSPLookup {
|
|
|
28
28
|
const clas = bottomScope.findClassDefinition(cursor.token.getStr());
|
|
29
29
|
if (clas && clas.getStart().equals(cursor.token.getStart())) {
|
|
30
30
|
const found = _lsp_utils_1.LSPUtils.identiferToLocation(clas);
|
|
31
|
-
return {
|
|
31
|
+
return {
|
|
32
|
+
hover: "Class Definition, " + cursor.token.getStr(),
|
|
32
33
|
definition: found,
|
|
33
34
|
definitionId: clas,
|
|
34
35
|
implementation: undefined,
|
|
35
|
-
scope: bottomScope
|
|
36
|
+
scope: bottomScope,
|
|
37
|
+
};
|
|
36
38
|
}
|
|
37
39
|
const intf = bottomScope.findInterfaceDefinition(cursor.token.getStr());
|
|
38
40
|
if (intf && intf.getStart().equals(cursor.token.getStart())) {
|
|
39
41
|
const found = _lsp_utils_1.LSPUtils.identiferToLocation(intf);
|
|
40
|
-
return {
|
|
42
|
+
return {
|
|
43
|
+
hover: "Interface Definition, " + cursor.token.getStr(),
|
|
41
44
|
definition: found,
|
|
42
45
|
definitionId: intf,
|
|
43
46
|
implementation: undefined,
|
|
44
|
-
scope: bottomScope
|
|
47
|
+
scope: bottomScope,
|
|
48
|
+
};
|
|
45
49
|
}
|
|
46
50
|
const type = bottomScope.findType(cursor.token.getStr());
|
|
47
51
|
if (type !== undefined && type.getStart().equals(cursor.token.getStart())) {
|
|
48
52
|
const found = _lsp_utils_1.LSPUtils.identiferToLocation(type);
|
|
49
|
-
const hover = "Type
|
|
53
|
+
const hover = "Type Definition, " + cursor.token.getStr() + "\n\n" + this.dumpType(type);
|
|
50
54
|
return { hover, definition: found, definitionId: type, scope: bottomScope };
|
|
51
55
|
}
|
|
52
56
|
const method = this.findMethodDefinition(cursor, bottomScope);
|
|
53
57
|
if (method !== undefined && method.getStart().equals(cursor.token.getStart())) {
|
|
54
58
|
const found = _lsp_utils_1.LSPUtils.identiferToLocation(method);
|
|
55
|
-
const hover = "Method
|
|
59
|
+
const hover = "Method Definition \"" + method.getName() + "\"";
|
|
56
60
|
return { hover, definition: found, definitionId: method, scope: bottomScope };
|
|
57
61
|
}
|
|
58
62
|
const variable = bottomScope.findVariable(cursor.token.getStr());
|
|
59
63
|
if (variable !== undefined && variable.getStart().equals(cursor.token.getStart())) {
|
|
60
|
-
const hover = "Variable
|
|
64
|
+
const hover = "Variable Definition\n\n" + this.dumpType(variable);
|
|
61
65
|
let location = undefined;
|
|
62
66
|
if (variable.getMeta().includes("built-in" /* BuiltIn */) === false) {
|
|
63
67
|
location = _lsp_utils_1.LSPUtils.identiferToLocation(variable);
|
|
@@ -103,23 +107,23 @@ class LSPLookup {
|
|
|
103
107
|
value = value + "\n\nMeta: " + variable.getMeta().join(", ");
|
|
104
108
|
}
|
|
105
109
|
if (variable.getType().containsVoid() === true) {
|
|
106
|
-
value = value + "\n\nContains
|
|
110
|
+
value = value + "\n\nContains Void types";
|
|
107
111
|
}
|
|
108
112
|
if (variable.getType().getQualifiedName()) {
|
|
109
|
-
value = value + "\n\nQualified
|
|
113
|
+
value = value + "\n\nQualified Type Name: ```" + variable.getType().getQualifiedName() + "```";
|
|
110
114
|
}
|
|
111
115
|
if (variable.getType().isGeneric() === true) {
|
|
112
|
-
value = value + "\n\nIs
|
|
116
|
+
value = value + "\n\nIs Generic Type";
|
|
113
117
|
}
|
|
114
118
|
return value;
|
|
115
119
|
}
|
|
116
120
|
static referenceHover(ref, scope, reg) {
|
|
117
|
-
var _a, _b, _c;
|
|
121
|
+
var _a, _b, _c, _d, _e;
|
|
118
122
|
let name = "";
|
|
119
123
|
if (ref.resolved) {
|
|
120
124
|
name = "```" + ref.resolved.getName() + "```";
|
|
121
125
|
}
|
|
122
|
-
let ret =
|
|
126
|
+
let ret = `${ref.referenceType} ${name}`;
|
|
123
127
|
if (ref.referenceType === _reference_1.ReferenceType.MethodReference && ((_a = ref.extra) === null || _a === void 0 ? void 0 : _a.ooName)) {
|
|
124
128
|
let cdef = scope.findClassDefinition(ref.extra.ooName);
|
|
125
129
|
if (cdef === undefined) {
|
|
@@ -136,45 +140,62 @@ class LSPLookup {
|
|
|
136
140
|
else if (ref.resolved instanceof _typed_identifier_1.TypedIdentifier) {
|
|
137
141
|
ret += "\n\n" + this.dumpType(ref.resolved);
|
|
138
142
|
}
|
|
143
|
+
else if (ref.referenceType === _reference_1.ReferenceType.BuiltinMethodReference) {
|
|
144
|
+
const builtinDef = new _builtin_1.BuiltIn().searchBuiltin((_e = (_d = ref.resolved) === null || _d === void 0 ? void 0 : _d.getName()) === null || _e === void 0 ? void 0 : _e.toUpperCase());
|
|
145
|
+
if (builtinDef === undefined) {
|
|
146
|
+
return "Error: builtin method signature not found";
|
|
147
|
+
}
|
|
148
|
+
ret += "\n\n" + this.methodParameters(builtinDef);
|
|
149
|
+
}
|
|
150
|
+
if (ref.resolved) {
|
|
151
|
+
ret += "\n\n(Resolved)";
|
|
152
|
+
}
|
|
139
153
|
if (ref.extra !== undefined && Object.keys(ref.extra).length > 0) {
|
|
140
154
|
ret += "\n\nExtra: " + JSON.stringify(ref.extra);
|
|
141
155
|
}
|
|
142
156
|
return ret;
|
|
143
157
|
}
|
|
144
|
-
static hoverMethod(method,
|
|
145
|
-
if (
|
|
158
|
+
static hoverMethod(method, classDef) {
|
|
159
|
+
if (classDef === undefined) {
|
|
146
160
|
return "class not found";
|
|
147
161
|
}
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
162
|
+
const methodDef = classDef.getMethodDefinitions().getByName(method);
|
|
163
|
+
if (methodDef === undefined) {
|
|
150
164
|
return "method not found in definition";
|
|
151
165
|
}
|
|
166
|
+
return this.methodParameters(methodDef);
|
|
167
|
+
}
|
|
168
|
+
static methodParameters(methodDef) {
|
|
152
169
|
let ret = "";
|
|
153
|
-
|
|
170
|
+
const parameters = methodDef.getParameters();
|
|
171
|
+
const importing = parameters.getImporting();
|
|
172
|
+
if (importing.length > 0) {
|
|
154
173
|
ret += "IMPORTING\n";
|
|
155
|
-
for (const p of
|
|
174
|
+
for (const p of importing) {
|
|
156
175
|
ret += this.singleParameter(p);
|
|
157
176
|
}
|
|
158
177
|
}
|
|
159
|
-
|
|
178
|
+
const exporting = parameters.getExporting();
|
|
179
|
+
if (exporting.length > 0) {
|
|
160
180
|
ret += "EXPORTING\n";
|
|
161
|
-
for (const p of
|
|
181
|
+
for (const p of exporting) {
|
|
162
182
|
ret += this.singleParameter(p);
|
|
163
183
|
}
|
|
164
184
|
}
|
|
165
|
-
|
|
185
|
+
const changing = parameters.getChanging();
|
|
186
|
+
if (changing.length > 0) {
|
|
166
187
|
ret += "CHANGING\n";
|
|
167
|
-
for (const p of
|
|
188
|
+
for (const p of changing) {
|
|
168
189
|
ret += this.singleParameter(p);
|
|
169
190
|
}
|
|
170
191
|
}
|
|
171
|
-
const r =
|
|
192
|
+
const r = parameters.getReturning();
|
|
172
193
|
if (r) {
|
|
173
194
|
ret += "RETURNING\n" + this.singleParameter(r);
|
|
174
195
|
}
|
|
175
|
-
if (
|
|
196
|
+
if (methodDef.getRaising().length > 0) {
|
|
176
197
|
ret += "RAISING\n";
|
|
177
|
-
for (const p of
|
|
198
|
+
for (const p of methodDef.getRaising()) {
|
|
178
199
|
ret += "* " + p + "\n";
|
|
179
200
|
}
|
|
180
201
|
}
|
package/build/src/registry.js
CHANGED
|
@@ -50,7 +50,8 @@ This rule makes sure the spaces are consistently required across the language.`,
|
|
|
50
50
|
}
|
|
51
51
|
missingSpace(statement) {
|
|
52
52
|
const found = statement.findAllExpressionsMulti([Expressions.CondSub, Expressions.SQLCond,
|
|
53
|
-
Expressions.ValueBody, Expressions.NewObject, Expressions.Cond,
|
|
53
|
+
Expressions.ValueBody, Expressions.NewObject, Expressions.Cond,
|
|
54
|
+
Expressions.ComponentCond, Expressions.MethodCallParam], true);
|
|
54
55
|
let pos = undefined;
|
|
55
56
|
for (const f of found) {
|
|
56
57
|
const type = f.get();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.81.
|
|
3
|
+
"version": "2.81.3",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@types/mocha": "^9.0.0",
|
|
51
51
|
"@types/node": "^16.11.9",
|
|
52
52
|
"chai": "^4.3.4",
|
|
53
|
-
"eslint": "^8.
|
|
53
|
+
"eslint": "^8.3.0",
|
|
54
54
|
"mocha": "^9.1.3",
|
|
55
55
|
"c8": "^7.10.0",
|
|
56
56
|
"source-map-support": "^0.5.21",
|