@abaplint/core 2.120.80 → 2.120.82

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.
@@ -99,7 +99,7 @@ declare class AbstractMethods extends Expression {
99
99
  }
100
100
 
101
101
  declare abstract class AbstractNode<T extends INode> implements INode {
102
- protected children: T[];
102
+ private children;
103
103
  constructor();
104
104
  abstract get(): any;
105
105
  abstract getFirstToken(): Token;
@@ -274,6 +274,7 @@ class ABAPFileInformationParser {
274
274
  return results;
275
275
  }
276
276
  parseAttributes(node, visibility) {
277
+ var _a;
277
278
  if (node === undefined) {
278
279
  return [];
279
280
  }
@@ -282,23 +283,34 @@ class ABAPFileInformationParser {
282
283
  return [];
283
284
  }
284
285
  const ret = [];
285
- for (const d of contents.findDirectStatements(Statements.Data)) {
286
+ const data = contents.findDirectStatements(Statements.Data);
287
+ for (const structure of contents.findDirectStructures(Structures.Data)) {
288
+ const begin = structure.findDirectStatement(Statements.DataBegin);
289
+ if (begin.findDirectExpression(Expressions.DefinitionName)) {
290
+ data.push(begin);
291
+ }
292
+ }
293
+ for (const d of data) {
286
294
  const name = d.findFirstExpression(Expressions.DefinitionName).getFirstToken();
287
295
  ret.push({
288
296
  name: name.getStr(),
289
297
  identifier: new _identifier_1.Identifier(name, this.filename),
290
298
  level: _abap_file_information_1.AttributeLevel.Instance,
291
- readOnly: d.concatTokens().toUpperCase().includes(" READ-ONLY"),
299
+ readOnly: this.isReadOnly(d),
292
300
  visibility,
293
301
  });
294
302
  }
295
- for (const d of contents.findDirectStatements(Statements.ClassData)) {
296
- const name = d.findFirstExpression(Expressions.DefinitionName).getFirstToken();
303
+ const classData = contents.findDirectStatements(Statements.ClassData);
304
+ for (const structure of contents.findDirectStructures(Structures.ClassData)) {
305
+ classData.push(structure.findDirectStatement(Statements.ClassDataBegin));
306
+ }
307
+ for (const d of classData) {
308
+ const name = ((_a = d.findFirstExpression(Expressions.DefinitionName)) !== null && _a !== void 0 ? _a : d.findDirectExpression(Expressions.NamespaceSimpleName)).getFirstToken();
297
309
  ret.push({
298
310
  name: name.getStr(),
299
311
  identifier: new _identifier_1.Identifier(name, this.filename),
300
312
  level: _abap_file_information_1.AttributeLevel.Static,
301
- readOnly: d.concatTokens().toUpperCase().includes(" READ-ONLY"),
313
+ readOnly: this.isReadOnly(d),
302
314
  visibility,
303
315
  });
304
316
  }
@@ -314,6 +326,12 @@ class ABAPFileInformationParser {
314
326
  }
315
327
  return ret;
316
328
  }
329
+ isReadOnly(statement) {
330
+ const definition = statement.findDirectExpression(Expressions.DataDefinition);
331
+ const nodes = definition ? [definition, ...definition.findAllExpressions(Expressions.TypeTableKey)] : [statement];
332
+ // In these grammar nodes, a direct READ token only occurs in the READ-ONLY modifier.
333
+ return nodes.some(node => node.findDirectTokenByText("READ") !== undefined);
334
+ }
317
335
  parseMethodDefinition(node, visibility) {
318
336
  var _a;
319
337
  if (node === undefined) {
@@ -168,7 +168,9 @@ class Procedural {
168
168
  }
169
169
  }
170
170
  if (found === undefined) {
171
- found = ddic.lookup(param.type).type;
171
+ const lookup = ddic.lookup(param.type);
172
+ this.addDDICUsing(lookup.object, nameToken, filename);
173
+ found = lookup.type;
172
174
  }
173
175
  if (param.direction === types_1.FunctionModuleParameterDirection.tables) {
174
176
  if (found instanceof basic_1.TableType) {
@@ -180,10 +182,12 @@ class Procedural {
180
182
  }
181
183
  if ((found instanceof basic_1.UnknownType || found instanceof basic_1.VoidType) && ((_a = param.type) === null || _a === void 0 ? void 0 : _a.includes("-"))) {
182
184
  const [name, field] = param.type.split("-");
183
- const f = ddic.lookupTableOrView(name).type;
185
+ const lookup = ddic.lookupTableOrView(name);
186
+ const f = lookup.type;
184
187
  if (f && f instanceof basic_1.StructureType) {
185
188
  const c = f.getComponentByName(field);
186
189
  if (c) {
190
+ this.addDDICUsing(lookup.object, nameToken, filename);
187
191
  found = c;
188
192
  }
189
193
  }
@@ -247,6 +251,12 @@ class Procedural {
247
251
  }
248
252
  }
249
253
  }
254
+ addDDICUsing(object, token, filename) {
255
+ if (object === undefined) {
256
+ return;
257
+ }
258
+ this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object, token, filename });
259
+ }
250
260
  functionModuleParameterMeta(param) {
251
261
  const ret = [];
252
262
  if (param.direction === types_1.FunctionModuleParameterDirection.importing) {
@@ -156,7 +156,7 @@ class MethodCallChain {
156
156
  context = component_name_1.ComponentName.runSyntax(context, current, input);
157
157
  }
158
158
  else if (current instanceof nodes_1.ExpressionNode && current.get() instanceof Expressions.AttributeName) {
159
- context = attribute_name_1.AttributeName.runSyntax(context, current, input);
159
+ context = attribute_name_1.AttributeName.runSyntax(context, current, input, _reference_1.ReferenceType.DataReadReference);
160
160
  }
161
161
  previous = current;
162
162
  }
@@ -9,22 +9,35 @@ class AbstractNode {
9
9
  }
10
10
  addChild(n) {
11
11
  if (this.children === EMPTY) {
12
- this.children = [];
12
+ this.children = n;
13
+ }
14
+ else if (Array.isArray(this.children)) {
15
+ this.children.push(n);
16
+ }
17
+ else {
18
+ this.children = [this.children, n];
13
19
  }
14
- this.children.push(n);
15
20
  }
16
21
  setChildren(children) {
17
- // copy, input arrays are built via push() and carry over-allocated backing stores
18
- this.children = children.slice();
22
+ if (children.length === 1) {
23
+ this.children = children[0];
24
+ }
25
+ else {
26
+ // copy, input arrays are built via push() and carry over-allocated backing stores
27
+ this.children = children.length === 0 ? EMPTY : children.slice();
28
+ }
19
29
  }
20
30
  getChildren() {
21
- return this.children;
31
+ const children = this.children;
32
+ return Array.isArray(children) ? children : [children];
22
33
  }
23
34
  getFirstChild() {
24
- return this.children[0];
35
+ const children = this.children;
36
+ return Array.isArray(children) ? children[0] : children;
25
37
  }
26
38
  getLastChild() {
27
- return this.children[this.children.length - 1];
39
+ const children = this.children;
40
+ return Array.isArray(children) ? children[children.length - 1] : children;
28
41
  }
29
42
  }
30
43
  exports.AbstractNode = AbstractNode;
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.80";
78
+ return "2.120.82";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;