@abaplint/core 2.120.66 → 2.120.67
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/statements/modify_line.js +3 -1
- package/build/src/abap/5_syntax/_current_scope.js +1 -0
- package/build/src/abap/5_syntax/_object_oriented.js +55 -0
- package/build/src/abap/5_syntax/expressions/attribute_name.js +11 -0
- package/build/src/abap/5_syntax/expressions/method_call_chain.js +3 -44
- package/build/src/abap/5_syntax/expressions/target.js +7 -0
- package/build/src/pretty_printer/indent.js +2 -0
- package/build/src/registry.js +1 -1
- package/package.json +1 -1
|
@@ -18,7 +18,9 @@ class ModifyLine {
|
|
|
18
18
|
const ocp = (0, combi_1.str)("OF CURRENT PAGE");
|
|
19
19
|
const intensified = (0, combi_1.seq)("INTENSIFIED", onOff);
|
|
20
20
|
const intensifiedOpt = (0, combi_1.seq)("INTENSIFIED", (0, combi_1.opt)(onOff));
|
|
21
|
-
const
|
|
21
|
+
const inputOpt = (0, combi_1.seq)("INPUT", (0, combi_1.opt)((0, combi_1.alt)(eq, onOff)));
|
|
22
|
+
const inverseOpt = (0, combi_1.seq)("INVERSE", (0, combi_1.opt)((0, combi_1.alt)(eq, onOff)));
|
|
23
|
+
const lineFormat = (0, combi_1.seq)("LINE FORMAT", (0, combi_1.per)(inputOpt, inverseOpt, "RESET", intensifiedOpt, expressions_1.Color));
|
|
22
24
|
const options = (0, combi_1.per)(index, value, format, page, lineFormat, lineValue, ocp, intensified, expressions_1.Color);
|
|
23
25
|
const ret = (0, combi_1.seq)("MODIFY", (0, combi_1.altPrio)("CURRENT LINE", (0, combi_1.seq)("LINE", expressions_1.Source)), (0, combi_1.opt)(options));
|
|
24
26
|
return (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, ret);
|
|
@@ -173,6 +173,61 @@ class ObjectOriented {
|
|
|
173
173
|
}
|
|
174
174
|
// does the supplied class have friendship with "friendName"?
|
|
175
175
|
// note that interfaces of the friend, and subclasses of the friend also have friendship
|
|
176
|
+
// returns the visibility as text if a member declared in foundDef, reached via def, cannot be accessed from enclosing
|
|
177
|
+
memberNotVisible(visibility, def, foundDef, enclosing) {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
if (visibility === visibility_1.Visibility.Public || foundDef === undefined) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
else if (!(foundDef instanceof types_1.ClassDefinition)) {
|
|
183
|
+
// interface members are always public
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
const name = foundDef.getName().toUpperCase();
|
|
187
|
+
enclosing = enclosing === null || enclosing === void 0 ? void 0 : enclosing.toUpperCase();
|
|
188
|
+
if (enclosing === undefined || enclosing === name) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
// friendship with the class used at the call site also gives access to inherited members
|
|
192
|
+
const visited = [];
|
|
193
|
+
let current = def instanceof types_1.ClassDefinition ? def : foundDef;
|
|
194
|
+
while (current !== undefined && visited.includes(current.getName().toUpperCase()) === false) {
|
|
195
|
+
visited.push(current.getName().toUpperCase());
|
|
196
|
+
if (this.hasFriendship(current, enclosing)) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
const sup = current.getSuperClass();
|
|
200
|
+
current = sup === undefined ? undefined : this.scope.findClassDefinition(sup);
|
|
201
|
+
}
|
|
202
|
+
if (visibility === visibility_1.Visibility.Protected) {
|
|
203
|
+
// subclasses can access protected members
|
|
204
|
+
let sup = (_a = this.scope.findClassDefinition(enclosing)) === null || _a === void 0 ? void 0 : _a.getSuperClass();
|
|
205
|
+
while (sup !== undefined) {
|
|
206
|
+
if (sup.toUpperCase() === name) {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
sup = (_b = this.scope.findClassDefinition(sup)) === null || _b === void 0 ? void 0 : _b.getSuperClass();
|
|
210
|
+
}
|
|
211
|
+
return "protected";
|
|
212
|
+
}
|
|
213
|
+
return "private";
|
|
214
|
+
}
|
|
215
|
+
// the class declaring the attribute or constant, searched from def up through the super classes
|
|
216
|
+
findAttributeOwner(def, found) {
|
|
217
|
+
const visited = [];
|
|
218
|
+
let current = def;
|
|
219
|
+
while (current instanceof types_1.ClassDefinition && visited.includes(current.getName().toUpperCase()) === false) {
|
|
220
|
+
visited.push(current.getName().toUpperCase());
|
|
221
|
+
const attributes = current.getAttributes();
|
|
222
|
+
if (attributes.getAll().includes(found)
|
|
223
|
+
|| attributes.getConstants().includes(found)) {
|
|
224
|
+
return current;
|
|
225
|
+
}
|
|
226
|
+
const sup = current.getSuperClass();
|
|
227
|
+
current = sup === undefined ? undefined : this.findSuperDefinition(sup);
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
176
231
|
hasFriendship(cd, friendName) {
|
|
177
232
|
var _a;
|
|
178
233
|
const friends = cd.getFriends().map(f => f.toUpperCase());
|
|
@@ -8,6 +8,8 @@ const _object_oriented_1 = require("../_object_oriented");
|
|
|
8
8
|
const data_reference_type_1 = require("../../types/basic/data_reference_type");
|
|
9
9
|
const _reference_1 = require("../_reference");
|
|
10
10
|
const basic_1 = require("../../types/basic");
|
|
11
|
+
const class_attribute_1 = require("../../types/class_attribute");
|
|
12
|
+
const class_constant_1 = require("../../types/class_constant");
|
|
11
13
|
const _syntax_input_1 = require("../_syntax_input");
|
|
12
14
|
class AttributeName {
|
|
13
15
|
static runSyntax(context, node, input, type, error = true) {
|
|
@@ -36,6 +38,15 @@ class AttributeName {
|
|
|
36
38
|
}
|
|
37
39
|
return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
38
40
|
}
|
|
41
|
+
if (found instanceof class_attribute_1.ClassAttribute || found instanceof class_constant_1.ClassConstant) {
|
|
42
|
+
const owner = helper.findAttributeOwner(def, found);
|
|
43
|
+
const notVisible = helper.memberNotVisible(found.getVisibility(), def, owner, input.scope.getEnclosingClassName());
|
|
44
|
+
if (notVisible !== undefined) {
|
|
45
|
+
const message = `Attribute "${name}" is ${notVisible} and cannot be accessed`;
|
|
46
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
|
|
47
|
+
return void_type_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
39
50
|
if (type) {
|
|
40
51
|
input.scope.addReference(token, found, type, input.filename);
|
|
41
52
|
}
|
|
@@ -47,8 +47,6 @@ const _reference_1 = require("../_reference");
|
|
|
47
47
|
const component_name_1 = require("./component_name");
|
|
48
48
|
const attribute_name_1 = require("./attribute_name");
|
|
49
49
|
const _syntax_input_1 = require("../_syntax_input");
|
|
50
|
-
const visibility_1 = require("../../4_file_information/visibility");
|
|
51
|
-
const class_definition_1 = require("../../types/class_definition");
|
|
52
50
|
class MethodCallChain {
|
|
53
51
|
static runSyntax(node, input, targetType) {
|
|
54
52
|
var _a, _b;
|
|
@@ -97,7 +95,9 @@ class MethodCallChain {
|
|
|
97
95
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
|
|
98
96
|
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
99
97
|
}
|
|
100
|
-
const notVisible = method
|
|
98
|
+
const notVisible = method
|
|
99
|
+
? helper.memberNotVisible(method.getVisibility(), def, foundDef, input.scope.getEnclosingClassName())
|
|
100
|
+
: undefined;
|
|
101
101
|
if (notVisible !== undefined) {
|
|
102
102
|
const message = `Method "${methodName}" is ${notVisible} and cannot be accessed`;
|
|
103
103
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, methodToken, message));
|
|
@@ -145,47 +145,6 @@ class MethodCallChain {
|
|
|
145
145
|
return context;
|
|
146
146
|
}
|
|
147
147
|
//////////////////////////////////////
|
|
148
|
-
// returns the visibility as text if the method cannot be accessed from the current scope
|
|
149
|
-
static checkVisibility(method, def, foundDef, input) {
|
|
150
|
-
var _a, _b, _c;
|
|
151
|
-
const visibility = method.getVisibility();
|
|
152
|
-
if (visibility === visibility_1.Visibility.Public || foundDef === undefined) {
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
else if (!(foundDef instanceof class_definition_1.ClassDefinition)) {
|
|
156
|
-
// interface members are always public
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
|
-
const name = foundDef.getName().toUpperCase();
|
|
160
|
-
const enclosing = (_a = input.scope.getEnclosingClassName()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
161
|
-
if (enclosing === undefined || enclosing === name) {
|
|
162
|
-
return undefined;
|
|
163
|
-
}
|
|
164
|
-
// friendship with the class used at the call site also gives access to inherited members
|
|
165
|
-
const helper = new _object_oriented_1.ObjectOriented(input.scope);
|
|
166
|
-
const visited = [];
|
|
167
|
-
let current = def instanceof class_definition_1.ClassDefinition ? def : foundDef;
|
|
168
|
-
while (current !== undefined && visited.includes(current.getName().toUpperCase()) === false) {
|
|
169
|
-
visited.push(current.getName().toUpperCase());
|
|
170
|
-
if (helper.hasFriendship(current, enclosing)) {
|
|
171
|
-
return undefined;
|
|
172
|
-
}
|
|
173
|
-
const sup = current.getSuperClass();
|
|
174
|
-
current = sup === undefined ? undefined : input.scope.findClassDefinition(sup);
|
|
175
|
-
}
|
|
176
|
-
if (visibility === visibility_1.Visibility.Protected) {
|
|
177
|
-
// subclasses can access protected members
|
|
178
|
-
let sup = (_b = input.scope.findClassDefinition(enclosing)) === null || _b === void 0 ? void 0 : _b.getSuperClass();
|
|
179
|
-
while (sup !== undefined) {
|
|
180
|
-
if (sup.toUpperCase() === name) {
|
|
181
|
-
return undefined;
|
|
182
|
-
}
|
|
183
|
-
sup = (_c = input.scope.findClassDefinition(sup)) === null || _c === void 0 ? void 0 : _c.getSuperClass();
|
|
184
|
-
}
|
|
185
|
-
return "protected";
|
|
186
|
-
}
|
|
187
|
-
return "private";
|
|
188
|
-
}
|
|
189
148
|
static findTop(first, input, targetType) {
|
|
190
149
|
var _a;
|
|
191
150
|
if (first.get() instanceof Expressions.ClassName) {
|
|
@@ -48,6 +48,7 @@ const expressions_1 = require("../../2_statements/expressions");
|
|
|
48
48
|
const field_length_1 = require("./field_length");
|
|
49
49
|
const cast_1 = require("./cast");
|
|
50
50
|
const _syntax_input_1 = require("../_syntax_input");
|
|
51
|
+
const version_1 = require("../../../version");
|
|
51
52
|
class Target {
|
|
52
53
|
static runSyntax(node, input) {
|
|
53
54
|
const concat = node.concatTokens();
|
|
@@ -113,6 +114,12 @@ class Target {
|
|
|
113
114
|
if (!(context instanceof basic_1.VoidType)) {
|
|
114
115
|
context = context.getType();
|
|
115
116
|
}
|
|
117
|
+
if ((context === null || context === void 0 ? void 0 : context.isGeneric()) === true
|
|
118
|
+
&& !(0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v756)
|
|
119
|
+
&& input.scope.getLanguageVersion() !== version_1.LanguageVersion.Cloud
|
|
120
|
+
&& !input.scope.getOpenABAP()) {
|
|
121
|
+
throw new Error("A generic reference cannot be dereferenced");
|
|
122
|
+
}
|
|
116
123
|
}
|
|
117
124
|
else if (current.get() instanceof Expressions.ComponentName) {
|
|
118
125
|
context = component_name_1.ComponentName.runSyntax(context, current, input);
|
|
@@ -116,6 +116,7 @@ class Indent {
|
|
|
116
116
|
|| type instanceof Statements.ProcessBeforeOutput
|
|
117
117
|
|| type instanceof Statements.ProcessOnValueRequest
|
|
118
118
|
|| type instanceof Statements.TopOfPage
|
|
119
|
+
|| type instanceof Statements.EndOfPage
|
|
119
120
|
|| type instanceof Statements.Get
|
|
120
121
|
|| type instanceof Statements.EndOfSelection
|
|
121
122
|
|| type instanceof Statements.LoadOfProgram) {
|
|
@@ -211,6 +212,7 @@ class Indent {
|
|
|
211
212
|
|| type instanceof Statements.Initialization
|
|
212
213
|
|| type instanceof Statements.AtUserCommand
|
|
213
214
|
|| type instanceof Statements.TopOfPage
|
|
215
|
+
|| type instanceof Statements.EndOfPage
|
|
214
216
|
|| type instanceof Statements.EndOfSelection
|
|
215
217
|
|| type instanceof Statements.Public
|
|
216
218
|
|| type instanceof Statements.Protected
|
package/build/src/registry.js
CHANGED