@abaplint/core 2.79.18 → 2.79.22

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.
Files changed (77) hide show
  1. package/README.md +6 -6
  2. package/build/abaplint.d.ts +1 -0
  3. package/build/src/abap/5_syntax/_builtin.js +50 -50
  4. package/build/src/abap/5_syntax/basic_types.js +7 -1
  5. package/build/src/abap/5_syntax/expressions/method_source.js +8 -2
  6. package/build/src/abap/5_syntax/statements/tables.js +1 -1
  7. package/build/src/ddic.js +6 -6
  8. package/build/src/ddic_references.js +44 -16
  9. package/build/src/lsp/_lookup.js +14 -5
  10. package/build/src/lsp/help.js +7 -7
  11. package/build/src/objects/assignment_service_to_authorization_group.js +1 -1
  12. package/build/src/registry.js +1 -1
  13. package/build/src/rules/abapdoc.js +1 -1
  14. package/build/src/rules/ambiguous_statement.js +5 -5
  15. package/build/src/rules/avoid_use.js +6 -6
  16. package/build/src/rules/begin_end_names.js +4 -4
  17. package/build/src/rules/begin_single_include.js +12 -12
  18. package/build/src/rules/chain_mainly_declarations.js +4 -4
  19. package/build/src/rules/check_abstract.js +2 -2
  20. package/build/src/rules/check_comments.js +3 -3
  21. package/build/src/rules/check_include.js +3 -3
  22. package/build/src/rules/check_no_handler_pragma.js +8 -8
  23. package/build/src/rules/check_subrc.js +8 -8
  24. package/build/src/rules/commented_code.js +1 -1
  25. package/build/src/rules/constructor_visibility_public.js +4 -4
  26. package/build/src/rules/contains_tab.js +2 -2
  27. package/build/src/rules/downport.js +103 -43
  28. package/build/src/rules/exit_or_check.js +3 -3
  29. package/build/src/rules/exporting.js +1 -1
  30. package/build/src/rules/forbidden_identifier.js +1 -1
  31. package/build/src/rules/forbidden_void_type.js +2 -2
  32. package/build/src/rules/functional_writing.js +17 -17
  33. package/build/src/rules/global_class.js +4 -4
  34. package/build/src/rules/identical_conditions.js +2 -2
  35. package/build/src/rules/identical_contents.js +15 -15
  36. package/build/src/rules/identical_descriptions.js +4 -4
  37. package/build/src/rules/if_in_if.js +7 -7
  38. package/build/src/rules/implement_methods.js +3 -3
  39. package/build/src/rules/in_statement_indentation.js +11 -11
  40. package/build/src/rules/intf_referencing_clas.js +3 -3
  41. package/build/src/rules/line_break_style.js +2 -2
  42. package/build/src/rules/line_length.js +1 -1
  43. package/build/src/rules/line_only_punc.js +1 -1
  44. package/build/src/rules/local_variable_names.js +2 -2
  45. package/build/src/rules/many_parentheses.js +10 -10
  46. package/build/src/rules/max_one_method_parameter_per_line.js +7 -7
  47. package/build/src/rules/max_one_statement.js +3 -3
  48. package/build/src/rules/nesting.js +1 -1
  49. package/build/src/rules/no_public_attributes.js +1 -1
  50. package/build/src/rules/no_yoda_conditions.js +4 -4
  51. package/build/src/rules/obsolete_statement.js +36 -36
  52. package/build/src/rules/omit_parameter_name.js +3 -3
  53. package/build/src/rules/omit_receiving.js +13 -13
  54. package/build/src/rules/parser_702_chaining.js +2 -2
  55. package/build/src/rules/parser_error.js +2 -2
  56. package/build/src/rules/parser_missing_space.js +1 -1
  57. package/build/src/rules/prefer_inline.js +16 -16
  58. package/build/src/rules/prefer_is_not.js +7 -7
  59. package/build/src/rules/prefer_raise_exception_new.js +3 -3
  60. package/build/src/rules/prefer_returning_to_exporting.js +1 -1
  61. package/build/src/rules/prefer_xsdbool.js +2 -2
  62. package/build/src/rules/remove_descriptions.js +4 -4
  63. package/build/src/rules/rfc_error_handling.js +9 -9
  64. package/build/src/rules/select_add_order_by.js +5 -5
  65. package/build/src/rules/select_performance.js +2 -2
  66. package/build/src/rules/sicf_consistency.js +4 -4
  67. package/build/src/rules/space_before_dot.js +2 -2
  68. package/build/src/rules/start_at_tab.js +1 -1
  69. package/build/src/rules/sy_modification.js +2 -2
  70. package/build/src/rules/tabl_enhancement_category.js +2 -2
  71. package/build/src/rules/unused_methods.js +9 -9
  72. package/build/src/rules/unused_variables.js +6 -6
  73. package/build/src/rules/use_bool_expression.js +8 -8
  74. package/build/src/rules/use_line_exists.js +6 -6
  75. package/build/src/rules/use_new.js +2 -2
  76. package/build/src/rules/when_others_last.js +6 -6
  77. package/package.json +76 -76
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # @abaplint/core
2
-
3
- [abaplint](https://abaplint.org/) core library
4
-
5
- Exposes functionallity like the parser and rules, which can be used in other projects.
6
-
1
+ # @abaplint/core
2
+
3
+ [abaplint](https://abaplint.org/) core library
4
+
5
+ Exposes functionallity like the parser and rules, which can be used in other projects.
6
+
7
7
  For more information see https://github.com/abaplint/abaplint
@@ -2402,6 +2402,7 @@ declare interface IDDICReferences {
2402
2402
  addUsing(obj: IObject, using: IObjectAndToken | undefined): void;
2403
2403
  clear(obj: IObject): void;
2404
2404
  listUsing(obj: IObject): readonly IObjectAndToken[];
2405
+ listByFilename(filename: string, line: number): readonly IObjectAndToken[];
2405
2406
  listWhereUsed(obj: IObject): {
2406
2407
  type: string;
2407
2408
  name: string;
@@ -222,92 +222,92 @@ class BuiltIn {
222
222
  /////////////////////////////
223
223
  buildSY() {
224
224
  const components = [];
225
- components.push({ name: "abcde", type: new basic_1.CharacterType(26) });
226
- components.push({ name: "batch", type: new basic_1.CharacterType(1) });
227
- components.push({ name: "binpt", type: new basic_1.CharacterType(1) });
228
- components.push({ name: "calld", type: new basic_1.CharacterType(1) });
229
- components.push({ name: "callr", type: new basic_1.CharacterType(8) });
225
+ components.push({ name: "abcde", type: new basic_1.CharacterType(26, "sy-abcde") });
226
+ components.push({ name: "batch", type: new basic_1.CharacterType(1, "sy-batch") });
227
+ components.push({ name: "binpt", type: new basic_1.CharacterType(1, "sy-binpt") });
228
+ components.push({ name: "calld", type: new basic_1.CharacterType(1, "sy-calld") });
229
+ components.push({ name: "callr", type: new basic_1.CharacterType(8, "sy-callr") });
230
230
  components.push({ name: "colno", type: new basic_1.IntegerType() });
231
231
  components.push({ name: "cpage", type: new basic_1.IntegerType() });
232
- components.push({ name: "cprog", type: new basic_1.CharacterType(40) });
232
+ components.push({ name: "cprog", type: new basic_1.CharacterType(40, "sy-cprog") });
233
233
  components.push({ name: "cucol", type: new basic_1.IntegerType() });
234
234
  components.push({ name: "curow", type: new basic_1.IntegerType() });
235
- components.push({ name: "datar", type: new basic_1.CharacterType(1) });
235
+ components.push({ name: "datar", type: new basic_1.CharacterType(1, "sy-datar") });
236
236
  components.push({ name: "datlo", type: new basic_1.DateType() });
237
237
  components.push({ name: "datum", type: new basic_1.DateType() });
238
238
  components.push({ name: "dayst", type: new basic_1.CharacterType(1) });
239
239
  components.push({ name: "dbcnt", type: new basic_1.IntegerType() });
240
- components.push({ name: "dbnam", type: new basic_1.CharacterType(20) });
241
- components.push({ name: "dbsys", type: new basic_1.CharacterType(10) });
242
- components.push({ name: "dyngr", type: new basic_1.CharacterType(4) });
243
- components.push({ name: "dynnr", type: new basic_1.CharacterType(4) });
240
+ components.push({ name: "dbnam", type: new basic_1.CharacterType(20, "sy-dbnam") });
241
+ components.push({ name: "dbsys", type: new basic_1.CharacterType(10, "sy-dbsys") });
242
+ components.push({ name: "dyngr", type: new basic_1.CharacterType(4, "sy-dyngr") });
243
+ components.push({ name: "dynnr", type: new basic_1.CharacterType(4, "sy-dynnr") });
244
244
  components.push({ name: "fdayw", type: new basic_1.IntegerType() });
245
245
  components.push({ name: "fdpos", type: new basic_1.IntegerType() });
246
246
  components.push({ name: "fleng", type: new basic_1.IntegerType() });
247
247
  components.push({ name: "folen", type: new basic_1.IntegerType() });
248
- components.push({ name: "host", type: new basic_1.CharacterType(32) });
248
+ components.push({ name: "host", type: new basic_1.CharacterType(32, "sy-host") });
249
249
  components.push({ name: "index", type: new basic_1.IntegerType() });
250
- components.push({ name: "langu", type: new basic_1.CharacterType(1) });
251
- components.push({ name: "ldbpg", type: new basic_1.CharacterType(40) });
252
- components.push({ name: "pdest", type: new basic_1.CharacterType(4) });
250
+ components.push({ name: "langu", type: new basic_1.CharacterType(1, "sy-langu") });
251
+ components.push({ name: "ldbpg", type: new basic_1.CharacterType(40, "sy-ldbpg") });
252
+ components.push({ name: "pdest", type: new basic_1.CharacterType(4, "sy-pdest") });
253
253
  components.push({ name: "lilli", type: new basic_1.IntegerType() });
254
254
  components.push({ name: "linct", type: new basic_1.IntegerType() });
255
255
  components.push({ name: "linno", type: new basic_1.IntegerType() });
256
256
  components.push({ name: "linsz", type: new basic_1.IntegerType() });
257
- components.push({ name: "lisel", type: new basic_1.CharacterType(255) });
257
+ components.push({ name: "lisel", type: new basic_1.CharacterType(255, "sy-lisel") });
258
258
  components.push({ name: "listi", type: new basic_1.IntegerType() });
259
259
  components.push({ name: "loopc", type: new basic_1.IntegerType() });
260
260
  components.push({ name: "lsind", type: new basic_1.IntegerType() });
261
261
  components.push({ name: "macol", type: new basic_1.IntegerType() });
262
- components.push({ name: "mandt", type: new basic_1.CharacterType(3) });
262
+ components.push({ name: "mandt", type: new basic_1.CharacterType(3, "sy-mandt") });
263
263
  components.push({ name: "marow", type: new basic_1.IntegerType() });
264
264
  components.push({ name: "modno", type: new basic_1.IntegerType() });
265
- components.push({ name: "msgid", type: new basic_1.CharacterType(20) });
266
- components.push({ name: "msgli", type: new basic_1.CharacterType(60) });
267
- components.push({ name: "msgno", type: new basic_1.NumericType(3) });
268
- components.push({ name: "msgty", type: new basic_1.CharacterType(1) });
269
- components.push({ name: "msgv1", type: new basic_1.CharacterType(50) });
270
- components.push({ name: "msgv2", type: new basic_1.CharacterType(50) });
271
- components.push({ name: "msgv3", type: new basic_1.CharacterType(50) });
272
- components.push({ name: "msgv4", type: new basic_1.CharacterType(50) });
273
- components.push({ name: "opsys", type: new basic_1.CharacterType(10) });
265
+ components.push({ name: "msgid", type: new basic_1.CharacterType(20, "sy-msgid") });
266
+ components.push({ name: "msgli", type: new basic_1.CharacterType(60, "sy-msgli") });
267
+ components.push({ name: "msgno", type: new basic_1.NumericType(3, "sy-msgno") });
268
+ components.push({ name: "msgty", type: new basic_1.CharacterType(1, "sy-msgty") });
269
+ components.push({ name: "msgv1", type: new basic_1.CharacterType(50, "sy-msgv1") });
270
+ components.push({ name: "msgv2", type: new basic_1.CharacterType(50, "sy-msgv2") });
271
+ components.push({ name: "msgv3", type: new basic_1.CharacterType(50, "sy-msgv3") });
272
+ components.push({ name: "msgv4", type: new basic_1.CharacterType(50, "sy-msgv4") });
273
+ components.push({ name: "opsys", type: new basic_1.CharacterType(10, "sy-opsys") });
274
274
  components.push({ name: "pagno", type: new basic_1.IntegerType() });
275
- components.push({ name: "pfkey", type: new basic_1.CharacterType(20) });
276
- components.push({ name: "repid", type: new basic_1.CharacterType(40) });
277
- components.push({ name: "saprl", type: new basic_1.CharacterType(4) });
275
+ components.push({ name: "pfkey", type: new basic_1.CharacterType(20, "sy-pfkey") });
276
+ components.push({ name: "repid", type: new basic_1.CharacterType(40, "sy-repid") });
277
+ components.push({ name: "saprl", type: new basic_1.CharacterType(4, "sy-saprl") });
278
278
  components.push({ name: "scols", type: new basic_1.IntegerType() });
279
- components.push({ name: "slset", type: new basic_1.CharacterType(14) });
280
- components.push({ name: "spono", type: new basic_1.CharacterType(10) });
279
+ components.push({ name: "slset", type: new basic_1.CharacterType(14, "sy-slset") });
280
+ components.push({ name: "spono", type: new basic_1.CharacterType(10, "sy-spono") });
281
281
  components.push({ name: "srows", type: new basic_1.IntegerType() });
282
282
  components.push({ name: "staco", type: new basic_1.IntegerType() });
283
283
  components.push({ name: "staro", type: new basic_1.IntegerType() });
284
284
  components.push({ name: "stepl", type: new basic_1.IntegerType() });
285
285
  components.push({ name: "subrc", type: new basic_1.IntegerType() });
286
- components.push({ name: "sysid", type: new basic_1.CharacterType(3) });
286
+ components.push({ name: "sysid", type: new basic_1.CharacterType(3, "sy-sysid") });
287
287
  components.push({ name: "tabix", type: new basic_1.IntegerType() });
288
- components.push({ name: "tcode", type: new basic_1.CharacterType(20) });
288
+ components.push({ name: "tcode", type: new basic_1.CharacterType(20, "sy-tcode") });
289
289
  components.push({ name: "tfill", type: new basic_1.IntegerType() });
290
290
  components.push({ name: "timlo", type: new basic_1.TimeType() });
291
- components.push({ name: "title", type: new basic_1.CharacterType(70) });
291
+ components.push({ name: "title", type: new basic_1.CharacterType(70, "sy-title") });
292
292
  components.push({ name: "tleng", type: new basic_1.IntegerType() });
293
- components.push({ name: "tvar0", type: new basic_1.CharacterType(20) });
294
- components.push({ name: "tvar1", type: new basic_1.CharacterType(20) });
295
- components.push({ name: "tvar2", type: new basic_1.CharacterType(20) });
296
- components.push({ name: "tvar3", type: new basic_1.CharacterType(20) });
297
- components.push({ name: "tvar4", type: new basic_1.CharacterType(20) });
298
- components.push({ name: "tvar5", type: new basic_1.CharacterType(20) });
299
- components.push({ name: "tvar6", type: new basic_1.CharacterType(20) });
300
- components.push({ name: "tvar7", type: new basic_1.CharacterType(20) });
301
- components.push({ name: "tvar8", type: new basic_1.CharacterType(20) });
302
- components.push({ name: "tvar9", type: new basic_1.CharacterType(20) });
293
+ components.push({ name: "tvar0", type: new basic_1.CharacterType(20, "sy-tvar0") });
294
+ components.push({ name: "tvar1", type: new basic_1.CharacterType(20, "sy-tvar1") });
295
+ components.push({ name: "tvar2", type: new basic_1.CharacterType(20, "sy-tvar2") });
296
+ components.push({ name: "tvar3", type: new basic_1.CharacterType(20, "sy-tvar3") });
297
+ components.push({ name: "tvar4", type: new basic_1.CharacterType(20, "sy-tvar4") });
298
+ components.push({ name: "tvar5", type: new basic_1.CharacterType(20, "sy-tvar5") });
299
+ components.push({ name: "tvar6", type: new basic_1.CharacterType(20, "sy-tvar6") });
300
+ components.push({ name: "tvar7", type: new basic_1.CharacterType(20, "sy-tvar7") });
301
+ components.push({ name: "tvar8", type: new basic_1.CharacterType(20, "sy-tvar8") });
302
+ components.push({ name: "tvar9", type: new basic_1.CharacterType(20, "sy-tvar9") });
303
303
  components.push({ name: "tzone", type: new basic_1.IntegerType() });
304
- components.push({ name: "ucomm", type: new basic_1.CharacterType(70) });
305
- components.push({ name: "uline", type: new basic_1.CharacterType(255) });
306
- components.push({ name: "uname", type: new basic_1.CharacterType(12) });
304
+ components.push({ name: "ucomm", type: new basic_1.CharacterType(70, "sy-ucomm") });
305
+ components.push({ name: "uline", type: new basic_1.CharacterType(255, "sy-uline") });
306
+ components.push({ name: "uname", type: new basic_1.CharacterType(12, "sy-uname") });
307
307
  components.push({ name: "uzeit", type: new basic_1.TimeType() });
308
- components.push({ name: "vline", type: new basic_1.CharacterType(1) });
309
- components.push({ name: "wtitl", type: new basic_1.CharacterType(1) });
310
- components.push({ name: "zonlo", type: new basic_1.CharacterType(6) });
308
+ components.push({ name: "vline", type: new basic_1.CharacterType(1, "sy-vline") });
309
+ components.push({ name: "wtitl", type: new basic_1.CharacterType(1, "sy-wtitl") });
310
+ components.push({ name: "zonlo", type: new basic_1.CharacterType(6, "sy-zonlo") });
311
311
  const type = new basic_1.StructureType(components);
312
312
  const id1 = new tokens_1.Identifier(new position_1.Position(this.row++, 1), "sy");
313
313
  const sy = new _typed_identifier_1.TypedIdentifier(id1, BuiltIn.filename, type, ["read_only" /* ReadOnly */, "built-in" /* BuiltIn */]);
@@ -14,6 +14,8 @@ const basic_1 = require("../types/basic");
14
14
  const field_chain_1 = require("./expressions/field_chain");
15
15
  const types_1 = require("../types");
16
16
  const expressions_1 = require("../2_statements/expressions");
17
+ const _builtin_1 = require("./_builtin");
18
+ const position_1 = require("../../position");
17
19
  class BasicTypes {
18
20
  constructor(filename, scope) {
19
21
  this.filename = filename;
@@ -45,6 +47,10 @@ class BasicTypes {
45
47
  if (id && (lookup === null || lookup === void 0 ? void 0 : lookup.type)) {
46
48
  return new _typed_identifier_1.TypedIdentifier(id.getToken(), id.getFilename(), lookup.type);
47
49
  }
50
+ const builtin = this.scope.getDDIC().lookupBuiltinType(name);
51
+ if (builtin) {
52
+ return new _typed_identifier_1.TypedIdentifier(new identifier_1.Identifier(new position_1.Position(1, 1), name), _builtin_1.BuiltIn.filename, builtin);
53
+ }
48
54
  return undefined;
49
55
  }
50
56
  resolveLikeName(node, headerLogic = true) {
@@ -469,7 +475,7 @@ class BasicTypes {
469
475
  foundType = found === null || found === void 0 ? void 0 : found.getType();
470
476
  if (foundType === undefined) {
471
477
  const f = this.scope.getDDIC().lookupTableOrView(subs[0]);
472
- this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: f.object });
478
+ this.scope.getDDICReferences().addUsing(this.scope.getParentObj(), { object: f.object, filename: this.filename, token: expr.getFirstToken() });
473
479
  if (f.type instanceof _typed_identifier_1.TypedIdentifier) {
474
480
  foundType = f.type.getType();
475
481
  }
@@ -8,6 +8,7 @@ const method_call_chain_1 = require("./method_call_chain");
8
8
  const basic_1 = require("../../types/basic");
9
9
  const types_1 = require("../../types");
10
10
  const _reference_1 = require("../_reference");
11
+ const _object_oriented_1 = require("../_object_oriented");
11
12
  class MethodSource {
12
13
  runSyntax(node, scope, filename) {
13
14
  const context = new method_call_chain_1.MethodCallChain().runSyntax(node, scope, filename);
@@ -20,12 +21,17 @@ class MethodSource {
20
21
  if (context instanceof basic_1.ObjectReferenceType) {
21
22
  const id = context.getIdentifier();
22
23
  if (id instanceof types_1.ClassDefinition) {
23
- const method = id.getMethodDefinitions().getByName(last.concatTokens());
24
+ const methodName = last.concatTokens().toUpperCase();
25
+ const helper = new _object_oriented_1.ObjectOriented(scope);
26
+ const { method: foundMethod } = helper.searchMethodName(id, methodName);
27
+ if (foundMethod === undefined && methodName !== "CONSTRUCTOR") {
28
+ throw new Error(`MethodSource, method not found \"${methodName}\"`);
29
+ }
24
30
  const extra = {
25
31
  ooName: id.getName(),
26
32
  ooType: "CLAS"
27
33
  };
28
- scope.addReference(last.getFirstToken(), method, _reference_1.ReferenceType.MethodReference, filename, extra);
34
+ scope.addReference(last.getFirstToken(), foundMethod, _reference_1.ReferenceType.MethodReference, filename, extra);
29
35
  }
30
36
  }
31
37
  else if (context instanceof basic_1.VoidType) {
@@ -17,7 +17,7 @@ class Tables {
17
17
  }
18
18
  const found = (_b = scope.getDDIC()) === null || _b === void 0 ? void 0 : _b.lookupTableOrView(name);
19
19
  if (found) {
20
- scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found.object });
20
+ scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found.object, filename: filename, token: nameToken });
21
21
  scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, filename, found.type));
22
22
  return;
23
23
  }
package/build/src/ddic.js CHANGED
@@ -46,13 +46,13 @@ class DDIC {
46
46
  lookupBuiltinType(name, length, decimals) {
47
47
  switch (name) {
48
48
  case "STRING":
49
- return new Types.StringType();
49
+ return new Types.StringType(name);
50
50
  case "XSTRING":
51
- return new Types.XStringType();
51
+ return new Types.XStringType(name);
52
52
  case "D":
53
- return new Types.DateType();
53
+ return new Types.DateType(name);
54
54
  case "T":
55
- return new Types.TimeType();
55
+ return new Types.TimeType(name);
56
56
  case "XSEQUENCE":
57
57
  return new Types.XSequenceType();
58
58
  case "CLIKE":
@@ -79,9 +79,9 @@ class DDIC {
79
79
  return new Types.CSequenceType();
80
80
  case "I":
81
81
  case "INT8": // todo, take version into account
82
- return new Types.IntegerType();
82
+ return new Types.IntegerType(name);
83
83
  case "F":
84
- return new Types.FloatType();
84
+ return new Types.FloatType(name);
85
85
  case "P":
86
86
  if (length && decimals) {
87
87
  return new Types.PackedType(length, decimals);
@@ -3,38 +3,66 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DDICReferences = void 0;
4
4
  class DDICReferences {
5
5
  constructor() {
6
- this.index = {};
6
+ this.nameTypeIndex = {};
7
+ this.filenameIndex = {};
7
8
  }
8
9
  setUsing(obj, using) {
9
- const newName = obj.getName().toUpperCase();
10
- const newType = obj.getType();
11
- if (this.index[newName] === undefined) {
12
- this.index[newName] = {};
10
+ this.clear(obj);
11
+ for (const u of using) {
12
+ this.addUsing(obj, u);
13
13
  }
14
- this.index[newName][newType] = using;
15
14
  }
16
15
  addUsing(obj, using) {
17
16
  if (using === undefined) {
18
17
  return;
19
18
  }
19
+ // add to name and type index
20
20
  const newName = obj.getName().toUpperCase();
21
21
  const newType = obj.getType();
22
- if (this.index[newName] === undefined) {
23
- this.index[newName] = {};
22
+ if (this.nameTypeIndex[newName] === undefined) {
23
+ this.nameTypeIndex[newName] = {};
24
24
  }
25
- if (this.index[newName][newType] === undefined) {
26
- this.index[newName][newType] = [];
25
+ if (this.nameTypeIndex[newName][newType] === undefined) {
26
+ this.nameTypeIndex[newName][newType] = [];
27
+ }
28
+ this.nameTypeIndex[newName][newType].push(using);
29
+ // add to filename index
30
+ if (using.filename && using.token) {
31
+ if (this.filenameIndex[using.filename] === undefined) {
32
+ this.filenameIndex[using.filename] = {};
33
+ }
34
+ if (this.filenameIndex[using.filename][using.token.getRow()] === undefined) {
35
+ this.filenameIndex[using.filename][using.token.getRow()] = [];
36
+ }
37
+ this.filenameIndex[using.filename][using.token.getRow()].push(using);
27
38
  }
28
- this.index[newName][newType].push(using);
29
39
  }
30
40
  clear(obj) {
31
- this.setUsing(obj, []);
41
+ var _a, _b;
42
+ // remove from filenameIndex first
43
+ for (const u of this.listUsing(obj)) {
44
+ if (u.filename && u.token) {
45
+ const found = (_a = this.filenameIndex[u.filename]) === null || _a === void 0 ? void 0 : _a[u.token.getRow()];
46
+ if (found) {
47
+ found.pop(); // TODODOD, this assumes there is max one reference on each line
48
+ }
49
+ }
50
+ }
51
+ const newName = obj.getName().toUpperCase();
52
+ const newType = obj.getType();
53
+ if ((_b = this.nameTypeIndex[newName]) === null || _b === void 0 ? void 0 : _b[newType]) {
54
+ this.nameTypeIndex[newName][newType] = [];
55
+ }
56
+ }
57
+ listByFilename(filename, line) {
58
+ var _a;
59
+ return ((_a = this.filenameIndex[filename]) === null || _a === void 0 ? void 0 : _a[line]) || [];
32
60
  }
33
61
  listUsing(obj) {
34
62
  var _a;
35
63
  const newName = obj.getName().toUpperCase();
36
64
  const newType = obj.getType();
37
- const found = (_a = this.index[newName]) === null || _a === void 0 ? void 0 : _a[newType];
65
+ const found = (_a = this.nameTypeIndex[newName]) === null || _a === void 0 ? void 0 : _a[newType];
38
66
  if (found !== undefined) {
39
67
  return found;
40
68
  }
@@ -47,9 +75,9 @@ class DDICReferences {
47
75
  const ret = [];
48
76
  const searchName = obj.getName().toUpperCase();
49
77
  const searchType = obj.getType();
50
- for (const name in this.index) {
51
- for (const type in this.index[name]) {
52
- for (const f of this.index[name][type]) {
78
+ for (const name in this.nameTypeIndex) {
79
+ for (const type in this.nameTypeIndex[name]) {
80
+ for (const f of this.nameTypeIndex[name][type]) {
53
81
  if (f.object && f.object.getType() === searchType && f.object.getName() === searchName) {
54
82
  ret.push({ type, name, token: f.token, filename: f.filename });
55
83
  }
@@ -64,14 +64,20 @@ class LSPLookup {
64
64
  }
65
65
  return { hover, definition: location, implementation: location, definitionId: variable, scope: bottomScope };
66
66
  }
67
+ let hoverValue = "";
68
+ const ddicRefs = reg.getDDICReferences().listByFilename(cursor.identifier.getFilename(), cursor.identifier.getStart().getRow());
69
+ for (const d of ddicRefs) {
70
+ if (d.object && d.token && d.token.getStart().equals(cursor.identifier.getStart())) {
71
+ hoverValue += `DDIC: ${d.object.getType()} ${d.object.getName()}`;
72
+ }
73
+ }
67
74
  const refs = this.searchReferences(bottomScope, cursor.token);
68
75
  if (refs.length > 0) {
69
- let value = "";
70
76
  for (const ref of refs) {
71
- if (value !== "") {
72
- value += "\n_________________\n";
77
+ if (hoverValue !== "") {
78
+ hoverValue += "\n_________________\n";
73
79
  }
74
- value += this.referenceHover(ref, bottomScope, reg);
80
+ hoverValue += this.referenceHover(ref, bottomScope, reg);
75
81
  }
76
82
  let definition = undefined;
77
83
  if (refs[0].resolved) {
@@ -80,7 +86,10 @@ class LSPLookup {
80
86
  definition = undefined;
81
87
  }
82
88
  }
83
- return { hover: value, definition, definitionId: refs[0].resolved, scope: bottomScope };
89
+ return { hover: hoverValue, definition, definitionId: refs[0].resolved, scope: bottomScope };
90
+ }
91
+ if (hoverValue !== "") {
92
+ return { hover: hoverValue, scope: bottomScope };
84
93
  }
85
94
  return undefined;
86
95
  }
@@ -9,13 +9,13 @@ const dump_scope_1 = require("./dump_scope");
9
9
  class Help {
10
10
  static find(reg, textDocument, position) {
11
11
  let content = "";
12
- content = `
13
- <a href="#_tokens" rel="no-refresh">Tokens</a> |
14
- <a href="#_statements" rel="no-refresh">Statements</a> |
15
- <a href="#_structure" rel="no-refresh">Structure</a> |
16
- <a href="#_files" rel="no-refresh">Files</a> |
17
- <a href="#_info" rel="no-refresh">Info Dump</a>
18
- <hr>
12
+ content = `
13
+ <a href="#_tokens" rel="no-refresh">Tokens</a> |
14
+ <a href="#_statements" rel="no-refresh">Statements</a> |
15
+ <a href="#_structure" rel="no-refresh">Structure</a> |
16
+ <a href="#_files" rel="no-refresh">Files</a> |
17
+ <a href="#_info" rel="no-refresh">Info Dump</a>
18
+ <hr>
19
19
  ` +
20
20
  "<tt>" + textDocument.uri + " (" +
21
21
  (position.line + 1) + ", " +
@@ -8,7 +8,7 @@ class AssignmentServiceToAuthorizationGroup extends _abstract_object_1.AbstractO
8
8
  }
9
9
  getAllowedNaming() {
10
10
  return {
11
- maxLength: 30,
11
+ maxLength: 32,
12
12
  allowNamespace: true,
13
13
  };
14
14
  }
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.79.18";
71
+ return "2.79.22";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -23,7 +23,7 @@ class Abapdoc extends _abap_rule_1.ABAPRule {
23
23
  return {
24
24
  key: "abapdoc",
25
25
  title: "Check abapdoc",
26
- shortDescription: `Various checks regarding abapdoc.
26
+ shortDescription: `Various checks regarding abapdoc.
27
27
  Base rule checks for existence of abapdoc for public class methods and all interface methods.`,
28
28
  tags: [_irule_1.RuleTag.SingleFile],
29
29
  };
@@ -20,14 +20,14 @@ class AmbiguousStatement extends _abap_rule_1.ABAPRule {
20
20
  return {
21
21
  key: "ambiguous_statement",
22
22
  title: "Check for ambigious statements",
23
- shortDescription: `Checks for ambiguity between deleting or modifying from internal and database table
24
- Add "TABLE" keyword or "@" for escaping SQL variables
25
-
23
+ shortDescription: `Checks for ambiguity between deleting or modifying from internal and database table
24
+ Add "TABLE" keyword or "@" for escaping SQL variables
25
+
26
26
  Only works if the target version is 740sp05 or above`,
27
27
  tags: [_irule_1.RuleTag.SingleFile],
28
- badExample: `DELETE foo FROM bar.
28
+ badExample: `DELETE foo FROM bar.
29
29
  MODIFY foo FROM bar.`,
30
- goodExample: `DELETE foo FROM @bar.
30
+ goodExample: `DELETE foo FROM @bar.
31
31
  MODIFY TABLE foo FROM bar.`,
32
32
  };
33
33
  }
@@ -35,12 +35,12 @@ class AvoidUse extends _abap_rule_1.ABAPRule {
35
35
  key: "avoid_use",
36
36
  title: "Avoid use of certain statements",
37
37
  shortDescription: `Detects usage of certain statements.`,
38
- extendedInformation: `DEFAULT KEY: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-default-key
39
-
40
- Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
41
-
42
- STATICS: use CLASS-DATA instead
43
-
38
+ extendedInformation: `DEFAULT KEY: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-default-key
39
+
40
+ Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
41
+
42
+ STATICS: use CLASS-DATA instead
43
+
44
44
  DESCRIBE TABLE LINES: use lines() instead (quickfix exists)`,
45
45
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
46
46
  };
@@ -23,11 +23,11 @@ class BeginEndNames extends _abap_rule_1.ABAPRule {
23
23
  title: "Check BEGIN END names",
24
24
  shortDescription: `Check BEGIN OF and END OF names match, plus there must be statements between BEGIN and END`,
25
25
  tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
26
- badExample: `DATA: BEGIN OF stru,
27
- field TYPE i,
26
+ badExample: `DATA: BEGIN OF stru,
27
+ field TYPE i,
28
28
  END OF structure_not_the_same.`,
29
- goodExample: `DATA: BEGIN OF stru,
30
- field TYPE i,
29
+ goodExample: `DATA: BEGIN OF stru,
30
+ field TYPE i,
31
31
  END OF stru.`,
32
32
  };
33
33
  }
@@ -21,19 +21,19 @@ class BeginSingleInclude extends _abap_rule_1.ABAPRule {
21
21
  title: "BEGIN contains single INCLUDE",
22
22
  shortDescription: `Finds TYPE BEGIN with just one INCLUDE TYPE, and DATA with single INCLUDE STRUCTURE`,
23
23
  tags: [_irule_1.RuleTag.SingleFile],
24
- badExample: `TYPES: BEGIN OF dummy1.
25
- INCLUDE TYPE dselc.
26
- TYPES: END OF dummy1.
27
-
28
- DATA BEGIN OF foo.
29
- INCLUDE STRUCTURE syst.
30
- DATA END OF foo.
31
-
32
- STATICS BEGIN OF bar.
33
- INCLUDE STRUCTURE syst.
24
+ badExample: `TYPES: BEGIN OF dummy1.
25
+ INCLUDE TYPE dselc.
26
+ TYPES: END OF dummy1.
27
+
28
+ DATA BEGIN OF foo.
29
+ INCLUDE STRUCTURE syst.
30
+ DATA END OF foo.
31
+
32
+ STATICS BEGIN OF bar.
33
+ INCLUDE STRUCTURE syst.
34
34
  STATICS END OF bar.`,
35
- goodExample: `DATA BEGIN OF foo.
36
- INCLUDE STRUCTURE dselc.
35
+ goodExample: `DATA BEGIN OF foo.
36
+ INCLUDE STRUCTURE dselc.
37
37
  DATA END OF foo.`,
38
38
  };
39
39
  }
@@ -45,10 +45,10 @@ class ChainMainlyDeclarations extends _abap_rule_1.ABAPRule {
45
45
  key: "chain_mainly_declarations",
46
46
  title: "Chain mainly declarations",
47
47
  shortDescription: `Chain mainly declarations, allows chaining for the configured statements, reports errors for other statements.`,
48
- extendedInformation: `
49
- https://docs.abapopenchecks.org/checks/23/
50
-
51
- https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenchained_statements_guidl.htm
48
+ extendedInformation: `
49
+ https://docs.abapopenchecks.org/checks/23/
50
+
51
+ https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenchained_statements_guidl.htm
52
52
  `,
53
53
  tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
54
54
  badExample: `CALL METHOD: bar.`,
@@ -23,8 +23,8 @@ class CheckAbstract extends _abap_rule_1.ABAPRule {
23
23
  return {
24
24
  key: "check_abstract",
25
25
  title: "Check abstract methods and classes",
26
- shortDescription: `Checks abstract methods and classes:
27
- - class defined as abstract and final,
26
+ shortDescription: `Checks abstract methods and classes:
27
+ - class defined as abstract and final,
28
28
  - non-abstract class contains abstract methods`,
29
29
  extendedInformation: `If a class defines only constants, use an interface instead`,
30
30
  tags: [_irule_1.RuleTag.SingleFile],
@@ -27,9 +27,9 @@ class CheckComments extends _abap_rule_1.ABAPRule {
27
27
  return {
28
28
  key: "check_comments",
29
29
  title: "Check Comments",
30
- shortDescription: `
31
- Various checks for comment usage.
32
-
30
+ shortDescription: `
31
+ Various checks for comment usage.
32
+
33
33
  * End of line comments. Comments starting with "#EC" or "##" are ignored`,
34
34
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#put-comments-before-the-statement-they-relate-to`,
35
35
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
@@ -17,9 +17,9 @@ class CheckInclude {
17
17
  key: "check_include",
18
18
  title: "Check INCLUDEs",
19
19
  shortDescription: `Checks INCLUDE statements`,
20
- extendedInformation: `
21
- * Reports unused includes
22
- * Errors if the includes are not found
20
+ extendedInformation: `
21
+ * Reports unused includes
22
+ * Errors if the includes are not found
23
23
  * Error if including a main program`,
24
24
  tags: [_irule_1.RuleTag.Syntax],
25
25
  };
@@ -21,15 +21,15 @@ class CheckNoHandlerPragma extends _abap_rule_1.ABAPRule {
21
21
  title: "Check if NO_HANDLER can be removed",
22
22
  shortDescription: `Checks NO_HANDLER pragmas that can be removed`,
23
23
  tags: [_irule_1.RuleTag.SingleFile],
24
- badExample: `TRY.
25
- ...
26
- CATCH zcx_abapgit_exception ##NO_HANDLER.
27
- RETURN. " it has a handler
24
+ badExample: `TRY.
25
+ ...
26
+ CATCH zcx_abapgit_exception ##NO_HANDLER.
27
+ RETURN. " it has a handler
28
28
  ENDTRY.`,
29
- goodExample: `TRY.
30
- ...
31
- CATCH zcx_abapgit_exception.
32
- RETURN.
29
+ goodExample: `TRY.
30
+ ...
31
+ CATCH zcx_abapgit_exception.
32
+ RETURN.
33
33
  ENDTRY.`,
34
34
  };
35
35
  }