@abaplint/core 2.94.23 → 2.94.25
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/abap/2_statements/expressions/method_source.js +11 -6
- package/build/src/abap/5_syntax/basic_types.js +8 -0
- package/build/src/abap/5_syntax/expressions/field_chain.js +4 -17
- package/build/src/abap/5_syntax/expressions/method_source.js +110 -41
- package/build/src/abap/5_syntax/expressions/source_field.js +26 -0
- package/build/src/lsp/_lookup.js +12 -1
- package/build/src/registry.js +1 -1
- package/package.json +2 -2
|
@@ -6,12 +6,17 @@ const tokens_1 = require("../../1_lexer/tokens");
|
|
|
6
6
|
const _1 = require(".");
|
|
7
7
|
class MethodSource extends combi_1.Expression {
|
|
8
8
|
getRunnable() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
9
|
+
// note: AttributeName can be both an attribute and a method name, the syntax check will tell
|
|
10
|
+
// note: its allowed to end with MethodCall, however if this is done it will give a syntax error via syntax check
|
|
11
|
+
const afterArrow = (0, combi_1.alt)(_1.AttributeName, _1.MethodCall, _1.Dynamic);
|
|
12
|
+
const arrow = (0, combi_1.alt)((0, combi_1.tok)(tokens_1.InstanceArrow), (0, combi_1.tok)(tokens_1.StaticArrow));
|
|
13
|
+
const attr = (0, combi_1.seq)(arrow, afterArrow);
|
|
14
|
+
const comp = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.Dash), _1.ComponentName);
|
|
15
|
+
const attrOrComp = (0, combi_1.alt)(attr, comp);
|
|
16
|
+
const staticClass = (0, combi_1.seq)(_1.ClassName, (0, combi_1.tok)(tokens_1.StaticArrow));
|
|
17
|
+
const clas = (0, combi_1.seq)(staticClass, afterArrow);
|
|
18
|
+
const start = (0, combi_1.seq)((0, combi_1.altPrio)(clas, _1.SourceField, _1.SourceFieldSymbol, _1.Dynamic), (0, combi_1.star)(attrOrComp));
|
|
19
|
+
return start;
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
22
|
exports.MethodSource = MethodSource;
|
|
@@ -408,6 +408,11 @@ class BasicTypes {
|
|
|
408
408
|
if (text === undefined) {
|
|
409
409
|
text = (_d = node.findFirstExpression(Expressions.FormParamType)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();
|
|
410
410
|
}
|
|
411
|
+
if (text === undefined
|
|
412
|
+
&& node.get() instanceof Statements.Parameter
|
|
413
|
+
&& node.findDirectTokenByText("LIKE")) {
|
|
414
|
+
text = "LIKE " + (typeName === null || typeName === void 0 ? void 0 : typeName.concatTokens());
|
|
415
|
+
}
|
|
411
416
|
if (text === undefined) {
|
|
412
417
|
text = "TYPE";
|
|
413
418
|
}
|
|
@@ -461,6 +466,9 @@ class BasicTypes {
|
|
|
461
466
|
if (sub === undefined) {
|
|
462
467
|
sub = node.findFirstExpression(Expressions.FieldChain);
|
|
463
468
|
}
|
|
469
|
+
if (sub === undefined) {
|
|
470
|
+
sub = node.findFirstExpression(Expressions.TypeName);
|
|
471
|
+
}
|
|
464
472
|
found = this.resolveLikeName(sub);
|
|
465
473
|
if (found && this.isOccurs(node)) {
|
|
466
474
|
found = new Types.TableType(found, { withHeader: text.includes("WITH HEADER LINE") }, qualifiedName);
|
|
@@ -14,6 +14,7 @@ const table_expression_1 = require("./table_expression");
|
|
|
14
14
|
const expressions_1 = require("../../2_statements/expressions");
|
|
15
15
|
const dereference_1 = require("./dereference");
|
|
16
16
|
const source_field_symbol_1 = require("./source_field_symbol");
|
|
17
|
+
const source_field_1 = require("./source_field");
|
|
17
18
|
class FieldChain {
|
|
18
19
|
runSyntax(node, scope, filename, refType) {
|
|
19
20
|
const concat = node.concatTokens();
|
|
@@ -110,23 +111,9 @@ class FieldChain {
|
|
|
110
111
|
&& node.get() instanceof Expressions.SourceFieldSymbol) {
|
|
111
112
|
return new source_field_symbol_1.SourceFieldSymbol().runSyntax(node, scope, filename);
|
|
112
113
|
}
|
|
113
|
-
else if (node
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const found = scope.findVariable(name);
|
|
117
|
-
if (found === undefined) {
|
|
118
|
-
throw new Error("\"" + name + "\" not found, findTop");
|
|
119
|
-
}
|
|
120
|
-
if (type) {
|
|
121
|
-
scope.addReference(token, found, type, filename);
|
|
122
|
-
}
|
|
123
|
-
if (name.includes("~")) {
|
|
124
|
-
const idef = scope.findInterfaceDefinition(name.split("~")[0]);
|
|
125
|
-
if (idef) {
|
|
126
|
-
scope.addReference(token, idef, _reference_1.ReferenceType.ObjectOrientedReference, filename);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return found.getType();
|
|
114
|
+
else if (node instanceof nodes_1.ExpressionNode
|
|
115
|
+
&& node.get() instanceof Expressions.SourceField) {
|
|
116
|
+
return new source_field_1.SourceField().runSyntax(node, scope, filename, type);
|
|
130
117
|
}
|
|
131
118
|
else if (node.get() instanceof Expressions.ClassName) {
|
|
132
119
|
const classTok = node.getFirstToken();
|
|
@@ -4,68 +4,137 @@ exports.MethodSource = void 0;
|
|
|
4
4
|
const Expressions = require("../../2_statements/expressions");
|
|
5
5
|
const nodes_1 = require("../../nodes");
|
|
6
6
|
const dynamic_1 = require("./dynamic");
|
|
7
|
-
const method_call_chain_1 = require("./method_call_chain");
|
|
8
7
|
const basic_1 = require("../../types/basic");
|
|
9
|
-
const types_1 = require("../../types");
|
|
10
8
|
const _reference_1 = require("../_reference");
|
|
11
9
|
const _object_oriented_1 = require("../_object_oriented");
|
|
10
|
+
const _abstract_type_1 = require("../../types/basic/_abstract_type");
|
|
11
|
+
const source_field_symbol_1 = require("./source_field_symbol");
|
|
12
|
+
const source_field_1 = require("./source_field");
|
|
13
|
+
const tokens_1 = require("../../1_lexer/tokens");
|
|
14
|
+
const attribute_name_1 = require("./attribute_name");
|
|
15
|
+
const component_name_1 = require("./component_name");
|
|
16
|
+
const types_1 = require("../../types");
|
|
12
17
|
class MethodSource {
|
|
13
18
|
runSyntax(node, scope, filename) {
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const first =
|
|
18
|
-
if (first
|
|
19
|
-
new
|
|
19
|
+
var _a;
|
|
20
|
+
const helper = new _object_oriented_1.ObjectOriented(scope);
|
|
21
|
+
const children = node.getChildren().slice();
|
|
22
|
+
const first = children.shift();
|
|
23
|
+
if (first === undefined) {
|
|
24
|
+
throw new Error("MethodSource, first child expected");
|
|
20
25
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
let context = this.findTop(first, scope, filename);
|
|
27
|
+
if (context === undefined) {
|
|
28
|
+
context = (_a = scope.findVariable("me")) === null || _a === void 0 ? void 0 : _a.getType();
|
|
29
|
+
children.unshift(first);
|
|
30
|
+
}
|
|
31
|
+
if (context instanceof basic_1.VoidType) {
|
|
32
|
+
// todo, if there are more dynamic with variables, the references for the variables are not added?
|
|
33
|
+
return context;
|
|
34
|
+
}
|
|
35
|
+
while (children.length > 0) {
|
|
36
|
+
const current = children.shift();
|
|
37
|
+
if (current === undefined) {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
if (current.get() instanceof tokens_1.Dash) {
|
|
41
|
+
if (context instanceof basic_1.UnknownType) {
|
|
42
|
+
throw new Error("Not a structure, type unknown, MethodSource");
|
|
26
43
|
}
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
else if (!(context instanceof basic_1.StructureType)) {
|
|
45
|
+
throw new Error("Not a structure, MethodSource");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (current.get() instanceof tokens_1.InstanceArrow
|
|
49
|
+
|| current.get() instanceof tokens_1.StaticArrow) {
|
|
50
|
+
// todo, handling static vs instance
|
|
51
|
+
}
|
|
52
|
+
else if (current.get() instanceof Expressions.AttributeName
|
|
53
|
+
|| current.get() instanceof Expressions.SourceField) {
|
|
54
|
+
try {
|
|
55
|
+
if (context instanceof _abstract_type_1.AbstractType) {
|
|
56
|
+
const attr = new attribute_name_1.AttributeName().runSyntax(context, current, scope, filename, _reference_1.ReferenceType.DataReadReference);
|
|
57
|
+
context = attr;
|
|
58
|
+
continue;
|
|
37
59
|
}
|
|
60
|
+
}
|
|
61
|
+
catch (_b) {
|
|
62
|
+
// ignore
|
|
63
|
+
}
|
|
64
|
+
// try looking for method name
|
|
65
|
+
const className = context instanceof basic_1.ObjectReferenceType ? context.getIdentifierName() : undefined;
|
|
66
|
+
const methodToken = current.getFirstToken();
|
|
67
|
+
const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr();
|
|
68
|
+
const def = scope.findObjectDefinition(className);
|
|
69
|
+
// eslint-disable-next-line prefer-const
|
|
70
|
+
let { method, def: foundDef } = helper.searchMethodName(def, methodName);
|
|
71
|
+
if (method === undefined && (methodName === null || methodName === void 0 ? void 0 : methodName.toUpperCase()) === "CONSTRUCTOR") {
|
|
72
|
+
context = new basic_1.VoidType("CONSTRUCTOR"); // todo, this is a workaround, constructors always exists
|
|
73
|
+
}
|
|
74
|
+
else if (method === undefined && !(context instanceof basic_1.VoidType)) {
|
|
75
|
+
throw new Error("Method or attribute \"" + methodName + "\" not found, MethodSource");
|
|
76
|
+
}
|
|
77
|
+
else if (method) {
|
|
38
78
|
const extra = {
|
|
39
79
|
ooName: foundDef === null || foundDef === void 0 ? void 0 : foundDef.getName(),
|
|
40
80
|
ooType: foundDef instanceof types_1.ClassDefinition ? "CLAS" : "INTF"
|
|
41
81
|
};
|
|
42
|
-
scope.addReference(
|
|
43
|
-
|
|
82
|
+
scope.addReference(methodToken, method, _reference_1.ReferenceType.MethodReference, filename, extra);
|
|
83
|
+
context = method;
|
|
44
84
|
}
|
|
45
85
|
}
|
|
46
|
-
else if (context instanceof
|
|
47
|
-
|
|
86
|
+
else if (current.get() instanceof Expressions.ComponentName && context instanceof _abstract_type_1.AbstractType) {
|
|
87
|
+
if (context instanceof basic_1.TableType && context.isWithHeader()) {
|
|
88
|
+
context = context.getRowType();
|
|
89
|
+
}
|
|
90
|
+
context = new component_name_1.ComponentName().runSyntax(context, current);
|
|
48
91
|
}
|
|
49
|
-
else {
|
|
50
|
-
|
|
92
|
+
else if (current instanceof nodes_1.ExpressionNode && current.get() instanceof Expressions.Dynamic) {
|
|
93
|
+
new dynamic_1.Dynamic().runSyntax(current, scope, filename);
|
|
94
|
+
context = new basic_1.VoidType("Dynamic");
|
|
51
95
|
}
|
|
52
96
|
}
|
|
53
|
-
|
|
54
|
-
new
|
|
97
|
+
if (context instanceof _abstract_type_1.AbstractType && !(context instanceof basic_1.VoidType)) {
|
|
98
|
+
throw new Error("Not a method, MethodSource");
|
|
55
99
|
}
|
|
56
|
-
else {
|
|
57
|
-
throw new Error("
|
|
100
|
+
else if (context === undefined) {
|
|
101
|
+
throw new Error("Not found, MethodSource");
|
|
58
102
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
103
|
+
return context;
|
|
104
|
+
}
|
|
105
|
+
//////////////////////////////////////
|
|
106
|
+
findTop(first, scope, filename) {
|
|
107
|
+
if (first.get() instanceof Expressions.ClassName) {
|
|
108
|
+
// todo, refactor this part to new expression handler,
|
|
109
|
+
const token = first.getFirstToken();
|
|
110
|
+
const className = token.getStr();
|
|
111
|
+
const classDefinition = scope.findObjectDefinition(className);
|
|
112
|
+
if (classDefinition === undefined && scope.getDDIC().inErrorNamespace(className) === false) {
|
|
113
|
+
const extra = { ooName: className, ooType: "Void" };
|
|
114
|
+
scope.addReference(token, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, filename, extra);
|
|
115
|
+
return new basic_1.VoidType(className);
|
|
116
|
+
}
|
|
117
|
+
else if (classDefinition === undefined) {
|
|
118
|
+
throw new Error("Class " + className + " not found");
|
|
119
|
+
}
|
|
120
|
+
scope.addReference(first.getFirstToken(), classDefinition, _reference_1.ReferenceType.ObjectOrientedReference, filename);
|
|
121
|
+
return new basic_1.ObjectReferenceType(classDefinition);
|
|
63
122
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
123
|
+
else if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.SourceField) {
|
|
124
|
+
try {
|
|
125
|
+
return new source_field_1.SourceField().runSyntax(first, scope, filename, _reference_1.ReferenceType.DataReadReference);
|
|
126
|
+
}
|
|
127
|
+
catch (_a) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.SourceFieldSymbol) {
|
|
132
|
+
return new source_field_symbol_1.SourceFieldSymbol().runSyntax(first, scope, filename);
|
|
133
|
+
}
|
|
134
|
+
else if (first instanceof nodes_1.ExpressionNode && first.get() instanceof Expressions.Dynamic) {
|
|
135
|
+
new dynamic_1.Dynamic().runSyntax(first, scope, filename);
|
|
136
|
+
return new basic_1.VoidType("Dynamic");
|
|
67
137
|
}
|
|
68
|
-
*/
|
|
69
138
|
return undefined;
|
|
70
139
|
}
|
|
71
140
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SourceField = void 0;
|
|
4
|
+
const _reference_1 = require("../_reference");
|
|
5
|
+
class SourceField {
|
|
6
|
+
runSyntax(node, scope, filename, type) {
|
|
7
|
+
const token = node.getFirstToken();
|
|
8
|
+
const name = token.getStr();
|
|
9
|
+
const found = scope.findVariable(name);
|
|
10
|
+
if (found === undefined) {
|
|
11
|
+
throw new Error("\"" + name + "\" not found, findTop");
|
|
12
|
+
}
|
|
13
|
+
if (type) {
|
|
14
|
+
scope.addReference(token, found, type, filename);
|
|
15
|
+
}
|
|
16
|
+
if (name.includes("~")) {
|
|
17
|
+
const idef = scope.findInterfaceDefinition(name.split("~")[0]);
|
|
18
|
+
if (idef) {
|
|
19
|
+
scope.addReference(token, idef, _reference_1.ReferenceType.ObjectOrientedReference, filename);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return found.getType();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.SourceField = SourceField;
|
|
26
|
+
//# sourceMappingURL=source_field.js.map
|
package/build/src/lsp/_lookup.js
CHANGED
|
@@ -10,6 +10,7 @@ const _typed_identifier_1 = require("../abap/types/_typed_identifier");
|
|
|
10
10
|
const _reference_1 = require("../abap/5_syntax/_reference");
|
|
11
11
|
const _builtin_1 = require("../abap/5_syntax/_builtin");
|
|
12
12
|
const _scope_type_1 = require("../abap/5_syntax/_scope_type");
|
|
13
|
+
const types_1 = require("../abap/types");
|
|
13
14
|
class LSPLookup {
|
|
14
15
|
static lookup(cursor, reg, obj) {
|
|
15
16
|
const inc = this.findInclude(cursor, reg);
|
|
@@ -84,13 +85,23 @@ class LSPLookup {
|
|
|
84
85
|
hoverValue += this.referenceHover(ref, bottomScope, reg);
|
|
85
86
|
}
|
|
86
87
|
let definition = undefined;
|
|
88
|
+
let implementation = undefined;
|
|
87
89
|
if (refs[0].resolved) {
|
|
88
90
|
definition = _lsp_utils_1.LSPUtils.identiferToLocation(refs[0].resolved);
|
|
89
91
|
if (definition.uri === _builtin_1.BuiltIn.filename) {
|
|
90
92
|
definition = undefined;
|
|
91
93
|
}
|
|
94
|
+
if (refs[0].resolved instanceof types_1.FormDefinition) {
|
|
95
|
+
implementation = definition;
|
|
96
|
+
}
|
|
92
97
|
}
|
|
93
|
-
return {
|
|
98
|
+
return {
|
|
99
|
+
hover: hoverValue,
|
|
100
|
+
definition: definition,
|
|
101
|
+
implementation: implementation,
|
|
102
|
+
definitionId: refs[0].resolved,
|
|
103
|
+
scope: bottomScope,
|
|
104
|
+
};
|
|
94
105
|
}
|
|
95
106
|
if (hoverValue !== "") {
|
|
96
107
|
return { hover: hoverValue, scope: bottomScope };
|
package/build/src/registry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.94.
|
|
3
|
+
"version": "2.94.25",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/mocha": "^10.0.1",
|
|
53
53
|
"@types/node": "^18.11.18",
|
|
54
54
|
"chai": "^4.3.7",
|
|
55
|
-
"eslint": "^8.
|
|
55
|
+
"eslint": "^8.32.0",
|
|
56
56
|
"mocha": "^10.2.0",
|
|
57
57
|
"c8": "^7.12.0",
|
|
58
58
|
"source-map-support": "^0.5.21",
|