@abaplint/core 2.120.81 → 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.
@@ -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) {
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.81";
78
+ return "2.120.82";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -84,10 +84,14 @@ If the statement contains a JOIN it is not checked`,
84
84
  setConfig(conf) {
85
85
  this.conf = conf;
86
86
  }
87
- buildFix(file, statement) {
87
+ buildFix(file, statement, rows) {
88
+ const end = statement.getLastToken().getEnd();
89
+ const suffix = rows[end.getRow() - 1].slice(end.getCol() - 1).trimStart();
90
+ // Keep chained '*' continuations out of the full-line comment column.
91
+ const newline = suffix !== "" && suffix.startsWith('"') === false ? "\n " : "";
88
92
  return {
89
93
  description: `Add "#EC CI_NOORDER`,
90
- edit: edit_helper_1.EditHelper.insertAt(file, statement.getLastToken().getStart(), ` "#EC CI_NOORDER`),
94
+ edit: edit_helper_1.EditHelper.insertAt(file, end, ` "#EC CI_NOORDER${newline}`),
91
95
  };
92
96
  }
93
97
  run(obj) {
@@ -103,6 +107,7 @@ If the statement contains a JOIN it is not checked`,
103
107
  const message = "SELECT SINGLE possibily not unique";
104
108
  for (const file of obj.getABAPFiles()) {
105
109
  const statements = file.getStatements();
110
+ const rows = file.getRawRows();
106
111
  for (let i = 0; i < statements.length; i++) {
107
112
  const s = statements[i];
108
113
  if (!(s.get() instanceof Statements.Select)) {
@@ -149,7 +154,7 @@ If the statement contains a JOIN it is not checked`,
149
154
  }
150
155
  }
151
156
  if (set.size > 0) {
152
- const fix = this.buildFix(file, s);
157
+ const fix = this.buildFix(file, s, rows);
153
158
  issues.push(issue_1.Issue.atStatement(file, s, message, this.getMetadata().key, this.getConfig().severity, undefined, [fix]));
154
159
  }
155
160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.81",
3
+ "version": "2.120.82",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",