@abaplint/core 2.120.104 → 2.120.106
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
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SuperConstructorCall = void 0;
|
|
37
|
+
const Expressions = __importStar(require("../2_statements/expressions"));
|
|
38
|
+
const Statements = __importStar(require("../2_statements/statements"));
|
|
39
|
+
const _statement_1 = require("../2_statements/statements/_statement");
|
|
40
|
+
const dash_1 = require("../1_lexer/tokens/dash");
|
|
41
|
+
const identifier_1 = require("../1_lexer/tokens/identifier");
|
|
42
|
+
const virtual_position_1 = require("../../virtual_position");
|
|
43
|
+
const _syntax_input_1 = require("./_syntax_input");
|
|
44
|
+
/** The constructor of a subclass must call SUPER->CONSTRUCTOR, and before the call instance
|
|
45
|
+
* attributes, instance methods and ME cannot be used. Runs when the method has been traversed,
|
|
46
|
+
* scopeNode is the outermost scope of the method, holding the references of its body. */
|
|
47
|
+
class SuperConstructorCall {
|
|
48
|
+
static check(method, scopeNode, input) {
|
|
49
|
+
var _a;
|
|
50
|
+
const methodStatement = method.findDirectStatement(Statements.MethodImplementation);
|
|
51
|
+
const methodName = (_a = methodStatement === null || methodStatement === void 0 ? void 0 : methodStatement.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
52
|
+
if (methodStatement === undefined || (methodName === null || methodName === void 0 ? void 0 : methodName.toUpperCase()) !== "CONSTRUCTOR") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const classDefinition = input.scope.findClassDefinition(input.scope.getName());
|
|
56
|
+
const superName = classDefinition === null || classDefinition === void 0 ? void 0 : classDefinition.getSuperClass();
|
|
57
|
+
if (classDefinition === undefined || superName === undefined || superName.toUpperCase() === "OBJECT") {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const statements = method.findAllStatementNodes();
|
|
61
|
+
for (const s of statements) {
|
|
62
|
+
const type = s.get();
|
|
63
|
+
if (type instanceof _statement_1.Unknown || type instanceof _statement_1.MacroCall
|
|
64
|
+
|| s.getFirstToken().getStart() instanceof virtual_position_1.VirtualPosition) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const callIndex = statements.findIndex(s => SuperConstructorCall.isSuperConstructorCall(s));
|
|
69
|
+
// at most one issue is reported per constructor
|
|
70
|
+
if (callIndex < 0) {
|
|
71
|
+
const message = "The constructor of a subclass must call SUPER->CONSTRUCTOR";
|
|
72
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodStatement.getFirstToken(), message));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// the statements before the call, the call itself can pass instance attributes, eg. previous = previous,
|
|
76
|
+
// declarations can refer to instance attributes for typing, eg. DATA ls_row LIKE LINE OF mt_table
|
|
77
|
+
const before = statements.slice(1, callIndex)
|
|
78
|
+
.filter(s => !(s.get() instanceof _statement_1.NativeSQL) && !SuperConstructorCall.isDeclaration(s));
|
|
79
|
+
const offending = SuperConstructorCall.findInstanceAccess(before, classDefinition, scopeNode, input);
|
|
80
|
+
if (offending !== undefined) {
|
|
81
|
+
const message = "Instance attributes, instance methods and ME can only be accessed after SUPER->CONSTRUCTOR is called";
|
|
82
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, offending, message));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
static isDeclaration(statement) {
|
|
86
|
+
const type = statement.get();
|
|
87
|
+
return type instanceof Statements.Data
|
|
88
|
+
|| type instanceof Statements.DataBegin
|
|
89
|
+
|| type instanceof Statements.DataEnd
|
|
90
|
+
|| type instanceof Statements.Constant
|
|
91
|
+
|| type instanceof Statements.ConstantBegin
|
|
92
|
+
|| type instanceof Statements.ConstantEnd
|
|
93
|
+
|| type instanceof Statements.Type
|
|
94
|
+
|| type instanceof Statements.TypeBegin
|
|
95
|
+
|| type instanceof Statements.TypeEnd
|
|
96
|
+
|| type instanceof Statements.Static
|
|
97
|
+
|| type instanceof Statements.StaticBegin
|
|
98
|
+
|| type instanceof Statements.StaticEnd
|
|
99
|
+
|| type instanceof Statements.IncludeType
|
|
100
|
+
|| type instanceof Statements.FieldSymbol;
|
|
101
|
+
}
|
|
102
|
+
static isSuperConstructorCall(statement) {
|
|
103
|
+
const tokens = statement.getTokens();
|
|
104
|
+
for (let i = 0; i < tokens.length - 2; i++) {
|
|
105
|
+
if (tokens[i].getStr().toUpperCase() === "SUPER"
|
|
106
|
+
&& tokens[i + 1].getStr() === "->"
|
|
107
|
+
&& tokens[i + 2].getStr().toUpperCase() === "CONSTRUCTOR") {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
/** returns the first offending token */
|
|
114
|
+
static findInstanceAccess(statements, classDefinition, scopeNode, input) {
|
|
115
|
+
const instance = SuperConstructorCall.listInstanceMembers(classDefinition, input);
|
|
116
|
+
const references = SuperConstructorCall.listReferences(scopeNode, input.filename);
|
|
117
|
+
for (const statement of statements) {
|
|
118
|
+
const tokens = statement.getTokens();
|
|
119
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
120
|
+
const token = tokens[i];
|
|
121
|
+
if (SuperConstructorCall.isMe(tokens, i)) {
|
|
122
|
+
return token;
|
|
123
|
+
}
|
|
124
|
+
const resolved = references.get(SuperConstructorCall.key(token));
|
|
125
|
+
if (resolved !== undefined
|
|
126
|
+
&& resolved.some(r => instance.has(r))
|
|
127
|
+
&& SuperConstructorCall.isOwnAccess(tokens, i)) {
|
|
128
|
+
return token;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
/** ME used as a value, me->component is allowed for constants and static components,
|
|
135
|
+
* instance components are found via the references */
|
|
136
|
+
static isMe(tokens, index) {
|
|
137
|
+
var _a;
|
|
138
|
+
const token = tokens[index];
|
|
139
|
+
if (!(token instanceof identifier_1.Identifier) || token.getStr().toUpperCase() !== "ME") {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
const prev = tokens[index - 1];
|
|
143
|
+
if (prev !== undefined && (prev instanceof dash_1.Dash || ["->", "=>", "~"].includes(prev.getStr()))) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return ((_a = tokens[index + 1]) === null || _a === void 0 ? void 0 : _a.getStr()) !== "->";
|
|
147
|
+
}
|
|
148
|
+
/** the member is accessed via the implicit or explicit self reference, not via another object or class */
|
|
149
|
+
static isOwnAccess(tokens, index) {
|
|
150
|
+
var _a;
|
|
151
|
+
const prev = tokens[index - 1];
|
|
152
|
+
if (prev === undefined) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
else if (prev.getStr() === "->") {
|
|
156
|
+
return ((_a = tokens[index - 2]) === null || _a === void 0 ? void 0 : _a.getStr().toUpperCase()) === "ME";
|
|
157
|
+
}
|
|
158
|
+
return !(prev instanceof dash_1.Dash || ["=>", "~"].includes(prev.getStr()));
|
|
159
|
+
}
|
|
160
|
+
/** instance attributes and methods of the class, its super classes and implemented interfaces */
|
|
161
|
+
static listInstanceMembers(classDefinition, input) {
|
|
162
|
+
const ret = new Set();
|
|
163
|
+
const visited = new Set();
|
|
164
|
+
const stack = [classDefinition];
|
|
165
|
+
while (stack.length > 0) {
|
|
166
|
+
const current = stack.pop();
|
|
167
|
+
const name = current.getName().toUpperCase();
|
|
168
|
+
if (visited.has(name)) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
visited.add(name);
|
|
172
|
+
for (const a of current.getAttributes().getInstance()) {
|
|
173
|
+
ret.add(a);
|
|
174
|
+
}
|
|
175
|
+
for (const m of current.getMethodDefinitions().getAll()) {
|
|
176
|
+
if (m.isStatic() === false) {
|
|
177
|
+
ret.add(m);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
for (const i of current.getImplementing()) {
|
|
181
|
+
const intf = input.scope.findInterfaceDefinition(i.name);
|
|
182
|
+
if (intf !== undefined) {
|
|
183
|
+
stack.push(intf);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if ("getSuperClass" in current) {
|
|
187
|
+
const sup = input.scope.findClassDefinition(current.getSuperClass());
|
|
188
|
+
if (sup !== undefined) {
|
|
189
|
+
stack.push(sup);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return ret;
|
|
194
|
+
}
|
|
195
|
+
/** resolved references of the method body by token position */
|
|
196
|
+
static listReferences(node, filename) {
|
|
197
|
+
var _a;
|
|
198
|
+
const ret = new Map();
|
|
199
|
+
const stack = node ? [node] : [];
|
|
200
|
+
while (stack.length > 0) {
|
|
201
|
+
const current = stack.pop();
|
|
202
|
+
stack.push(...current.getChildren());
|
|
203
|
+
for (const r of current.getData().references) {
|
|
204
|
+
if (r.resolved === undefined || r.position.getFilename() !== filename) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const key = SuperConstructorCall.key(r.position.getToken());
|
|
208
|
+
const list = (_a = ret.get(key)) !== null && _a !== void 0 ? _a : [];
|
|
209
|
+
list.push(r.resolved);
|
|
210
|
+
ret.set(key, list);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return ret;
|
|
214
|
+
}
|
|
215
|
+
static key(token) {
|
|
216
|
+
return token.getRow() + ":" + token.getCol();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.SuperConstructorCall = SuperConstructorCall;
|
|
220
|
+
//# sourceMappingURL=_super_constructor_call.js.map
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ModifyInternal = void 0;
|
|
37
37
|
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
38
|
+
const nodes_1 = require("../../nodes");
|
|
38
39
|
const source_1 = require("../expressions/source");
|
|
39
40
|
const target_1 = require("../expressions/target");
|
|
40
41
|
const fstarget_1 = require("../expressions/fstarget");
|
|
@@ -43,15 +44,22 @@ const basic_1 = require("../../types/basic");
|
|
|
43
44
|
const _syntax_input_1 = require("../_syntax_input");
|
|
44
45
|
class ModifyInternal {
|
|
45
46
|
runSyntax(node, input) {
|
|
46
|
-
|
|
47
|
-
source_1.Source.runSyntax(s, input);
|
|
48
|
-
}
|
|
47
|
+
var _a;
|
|
49
48
|
// there is only one
|
|
50
49
|
const target = node.findFirstExpression(Expressions.Target);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
// it might be a dynamic target
|
|
51
|
+
const targetType = target ? target_1.Target.runSyntax(target, input) : undefined;
|
|
52
|
+
// the FROM work area has the row type of the table, used for inferring "#"
|
|
53
|
+
const rowType = targetType instanceof basic_1.TableType ? targetType.getRowType() : undefined;
|
|
54
|
+
const children = node.getChildren();
|
|
55
|
+
for (let i = 0; i < children.length; i++) {
|
|
56
|
+
const s = children[i];
|
|
57
|
+
if (s instanceof nodes_1.ExpressionNode && s.get() instanceof Expressions.Source) {
|
|
58
|
+
const isFrom = ((_a = children[i - 1]) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase()) === "FROM";
|
|
59
|
+
source_1.Source.runSyntax(s, input, isFrom ? rowType : undefined);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (target) {
|
|
55
63
|
if (targetType instanceof basic_1.VoidType
|
|
56
64
|
|| targetType instanceof basic_1.AnyType
|
|
57
65
|
|| targetType instanceof basic_1.UnknownType) {
|
|
@@ -195,6 +195,7 @@ const field_group_1 = require("./statements/field_group");
|
|
|
195
195
|
const stuff_1 = require("../../stuff");
|
|
196
196
|
const _loop_table_change_1 = require("./_loop_table_change");
|
|
197
197
|
const _sorted_key_write_1 = require("./_sorted_key_write");
|
|
198
|
+
const _super_constructor_call_1 = require("./_super_constructor_call");
|
|
198
199
|
// -----------------------------------
|
|
199
200
|
const map = {};
|
|
200
201
|
function addToMap(handler) {
|
|
@@ -541,6 +542,9 @@ class SyntaxLogic {
|
|
|
541
542
|
else if (stru instanceof Structures.Try) {
|
|
542
543
|
try_1.Try.runSyntax(node, input);
|
|
543
544
|
}
|
|
545
|
+
else if (stru instanceof Structures.Method) {
|
|
546
|
+
this.currentMethod = node;
|
|
547
|
+
}
|
|
544
548
|
return false;
|
|
545
549
|
}
|
|
546
550
|
updateScopeStatement(node) {
|
|
@@ -588,12 +592,17 @@ class SyntaxLogic {
|
|
|
588
592
|
this.scope.pop(node.getLastToken().getEnd());
|
|
589
593
|
}
|
|
590
594
|
else if (s instanceof Statements.EndMethod) {
|
|
595
|
+
let popped = undefined;
|
|
591
596
|
if (this.scope.getType() === _scope_type_1.ScopeType.Method) {
|
|
592
|
-
this.scope.pop(node.getLastToken().getEnd());
|
|
597
|
+
popped = this.scope.pop(node.getLastToken().getEnd());
|
|
593
598
|
}
|
|
594
599
|
if (this.scope.getType() === _scope_type_1.ScopeType.MethodInstance) {
|
|
595
|
-
this.scope.pop(node.getLastToken().getEnd());
|
|
600
|
+
popped = this.scope.pop(node.getLastToken().getEnd());
|
|
601
|
+
}
|
|
602
|
+
if (this.currentMethod !== undefined && popped !== undefined) {
|
|
603
|
+
_super_constructor_call_1.SuperConstructorCall.check(this.currentMethod, popped.getTop(), input);
|
|
596
604
|
}
|
|
605
|
+
this.currentMethod = undefined;
|
|
597
606
|
}
|
|
598
607
|
}
|
|
599
608
|
updateSelectionEventScope(node) {
|
package/build/src/registry.js
CHANGED