@abaplint/core 2.120.65 → 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.
@@ -16,7 +16,9 @@ class Source extends combi_1.Expression {
16
16
  const comp = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.Dash), _1.ComponentChain);
17
17
  const attr = (0, combi_1.seq)(_1.Arrow, attribute_chain_1.AttributeChain);
18
18
  const deref = (0, combi_1.optPrio)((0, combi_1.ver)(version_1.Release.v756, dereference_1.Dereference));
19
- const dynChain = (0, combi_1.star)((0, combi_1.altPrio)((0, _dynamic_access_1.dynAttr)(), (0, _dynamic_access_1.dynComp)(), dereference_1.Dereference));
19
+ // below v756 "->*" directly after a functional method call is a syntax error, CAST can be dereferenced
20
+ const dynChain = (0, combi_1.star)((0, combi_1.seq)((0, combi_1.altPrio)((0, _dynamic_access_1.dynAttr)(), (0, _dynamic_access_1.dynComp)()), (0, combi_1.optPrio)(dereference_1.Dereference)));
21
+ const castDeref = (0, combi_1.seq)(_1.Cast, dereference_1.Dereference);
20
22
  const method = (0, combi_1.seq)(_1.MethodCallChain, (0, combi_1.optPrio)((0, combi_1.altPrio)(attr, comp)), deref, dynChain);
21
23
  const rparen = (0, combi_1.tok)(tokens_1.WParenRightW);
22
24
  const rparenNoSpace = (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenRightW), (0, combi_1.tok)(tokens_1.WParenRightW));
@@ -26,7 +28,7 @@ class Source extends combi_1.Expression {
26
28
  const after = (0, combi_1.seq)((0, combi_1.altPrio)("&", "&&", _1.ArithOperator), Source);
27
29
  const bool = (0, combi_1.seq)((0, combi_1.altPrio)((0, combi_1.ver)(version_1.Release.v702, (0, combi_1.regex)(/^BOOLC$/i), { also: combi_1.AlsoIn.OpenABAP }), (0, combi_1.ver)(version_1.Release.v740sp08, (0, combi_1.regex)(/^XSDBOOL$/i), { also: combi_1.AlsoIn.OpenABAP })), (0, combi_1.tok)(tokens_1.ParenLeftW), _1.Cond, ")");
28
30
  const prefix = (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WPlus), "BIT-NOT");
29
- const old = (0, combi_1.seq)((0, combi_1.optPrio)(prefix), (0, combi_1.altPrio)(_1.Constant, _1.StringTemplate, text_element_1.TextElement, bool, method, (0, combi_1.seq)(_1.FieldChain, deref), paren), (0, combi_1.optPrio)(after));
31
+ const old = (0, combi_1.seq)((0, combi_1.optPrio)(prefix), (0, combi_1.altPrio)(_1.Constant, _1.StringTemplate, text_element_1.TextElement, bool, castDeref, method, (0, combi_1.seq)(_1.FieldChain, deref), paren), (0, combi_1.optPrio)(after));
30
32
  const corr = (0, combi_1.ver)(version_1.Release.v740sp05, (0, combi_1.seq)("CORRESPONDING", _1.TypeNameOrInfer, (0, combi_1.tok)(tokens_1.ParenLeftW), _1.CorrespondingBody, rparen, (0, combi_1.optPrio)(after)), { also: combi_1.AlsoIn.OpenABAP });
31
33
  const conv = (0, combi_1.ver)(version_1.Release.v740sp02, (0, combi_1.seq)("CONV", _1.TypeNameOrInfer, lparenNoSpace, _1.ConvBody, rparenNoSpace, (0, combi_1.optPrio)(after)), { also: combi_1.AlsoIn.OpenABAP });
32
34
  const swit = (0, combi_1.ver)(version_1.Release.v740sp02, (0, combi_1.seq)("SWITCH", _1.TypeNameOrInfer, (0, combi_1.tok)(tokens_1.ParenLeftW), _1.SwitchBody, rparenNoSpace, (0, combi_1.optPrio)(after)), { also: combi_1.AlsoIn.OpenABAP });
@@ -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 lineFormat = (0, combi_1.seq)("LINE FORMAT", (0, combi_1.per)("INPUT OFF", "INVERSE", "RESET", intensifiedOpt, expressions_1.Color));
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);
@@ -409,6 +409,7 @@ class CurrentScope {
409
409
  if (name === undefined) {
410
410
  return undefined;
411
411
  }
412
+ name = name.replace(/^!/, "");
412
413
  const found = (_a = this.current) === null || _a === void 0 ? void 0 : _a.findVariable(name);
413
414
  if (found) {
414
415
  return found;
@@ -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 ? this.checkVisibility(method, def, foundDef, input) : undefined;
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) {
@@ -47,6 +47,9 @@ const field_chain_1 = require("./field_chain");
47
47
  const _reference_1 = require("../_reference");
48
48
  const _check_offset_length_1 = require("./_check_offset_length");
49
49
  const _check_text_symbol_1 = require("./_check_text_symbol");
50
+ function normalizeParameterName(name) {
51
+ return name.replace(/^!/, "").toUpperCase();
52
+ }
50
53
  class MethodParameters {
51
54
  constructor() {
52
55
  this.requiredParameters = undefined;
@@ -233,7 +236,7 @@ class MethodParameters {
233
236
  throw new assert_error_1.AssertError("parameterListS, unexpected node, child");
234
237
  }
235
238
  const nameNode = c.findDirectExpression(Expressions.ParameterName);
236
- const name = nameNode === null || nameNode === void 0 ? void 0 : nameNode.getFirstToken().getStr().toUpperCase();
239
+ const name = nameNode === undefined ? undefined : normalizeParameterName(nameNode.getFirstToken().getStr());
237
240
  if (name === undefined || nameNode === undefined) {
238
241
  throw new assert_error_1.AssertError("parameterListS, no name determined");
239
242
  }
@@ -288,7 +291,7 @@ class MethodParameters {
288
291
  throw new assert_error_1.AssertError("parameterListT, unexpected node, child");
289
292
  }
290
293
  const nameNode = c.findDirectExpression(Expressions.ParameterName);
291
- const name = nameNode === null || nameNode === void 0 ? void 0 : nameNode.getFirstToken().getStr().toUpperCase();
294
+ const name = nameNode === undefined ? undefined : normalizeParameterName(nameNode.getFirstToken().getStr());
292
295
  if (name === undefined || nameNode === undefined) {
293
296
  throw new assert_error_1.AssertError("parameterListT, no name determined");
294
297
  }
@@ -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);
@@ -76,7 +76,7 @@ class Convert {
76
76
  if ((stampTarget === null || stampTarget === void 0 ? void 0 : stampTarget.get()) instanceof Expressions.Target) {
77
77
  const inline = stampTarget === null || stampTarget === void 0 ? void 0 : stampTarget.findDirectExpression(Expressions.InlineData);
78
78
  if (inline) {
79
- inline_data_1.InlineData.runSyntax(inline, input, new basic_1.PackedType(8, 4));
79
+ inline_data_1.InlineData.runSyntax(inline, input, new basic_1.PackedType(8, 0));
80
80
  }
81
81
  else {
82
82
  target_1.Target.runSyntax(stampTarget, input);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataReference = void 0;
4
4
  const _abstract_type_1 = require("./_abstract_type");
5
5
  const any_type_1 = require("./any_type");
6
+ const table_type_1 = require("./table_type");
6
7
  class DataReference extends _abstract_type_1.AbstractType {
7
8
  constructor(type, qualifiedName) {
8
9
  super({ qualifiedName: qualifiedName });
@@ -25,6 +26,10 @@ class DataReference extends _abstract_type_1.AbstractType {
25
26
  if (this.type instanceof any_type_1.AnyType) {
26
27
  return true;
27
28
  }
29
+ // LIKE REF TO a generic table, eg. a field symbol TYPE STANDARD TABLE
30
+ if (this.type instanceof table_type_1.TableType && this.type.isGeneric()) {
31
+ return true;
32
+ }
28
33
  return false;
29
34
  }
30
35
  containsVoid() {
@@ -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
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.65";
78
+ return "2.120.67";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.65",
3
+ "version": "2.120.67",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",