@abaplint/core 2.93.96 → 2.93.98

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 (30) hide show
  1. package/adhoc/lexer_performance.ts +1 -1
  2. package/build/abaplint.d.ts +9 -4
  3. package/build/adhoc/lexer_performance.js +1 -1
  4. package/build/src/abap/1_lexer/lexer.js +90 -81
  5. package/build/src/abap/1_lexer/tokens/string.js +3 -3
  6. package/build/src/abap/2_statements/expand_macros.js +1 -1
  7. package/build/src/abap/2_statements/expressions/event_handler.js +1 -1
  8. package/build/src/abap/2_statements/expressions/event_name.js +11 -0
  9. package/build/src/abap/2_statements/expressions/index.js +1 -0
  10. package/build/src/abap/2_statements/expressions/sql_in.js +1 -1
  11. package/build/src/abap/2_statements/expressions/sql_join.js +1 -1
  12. package/build/src/abap/2_statements/statements/events.js +1 -1
  13. package/build/src/abap/2_statements/statements/raise_event.js +1 -1
  14. package/build/src/abap/4_file_information/abap_file_information.js +3 -2
  15. package/build/src/abap/5_syntax/statements/raise_event.js +1 -1
  16. package/build/src/abap/abap_parser.js +1 -1
  17. package/build/src/abap/nodes/expression_node.js +1 -1
  18. package/build/src/abap/nodes/statement_node.js +2 -2
  19. package/build/src/abap/types/class_definition.js +3 -2
  20. package/build/src/abap/types/event_definition.js +1 -1
  21. package/build/src/abap/types/method_parameters.js +1 -1
  22. package/build/src/files/_abstract_file.js +4 -3
  23. package/build/src/lsp/hover.js +1 -1
  24. package/build/src/lsp/semantic.js +1 -1
  25. package/build/src/position.js +2 -1
  26. package/build/src/pretty_printer/fix_keyword_case.js +1 -1
  27. package/build/src/registry.js +1 -1
  28. package/build/src/rules/if_in_if.js +21 -2
  29. package/build/src/rules/line_length.js +1 -1
  30. package/package.json +1 -1
@@ -8,7 +8,7 @@ const file = new MemoryFile("abapgit.abap", fs.readFileSync("./lexer_performance
8
8
  let total = 0;
9
9
  for (let i = 0; i < 10; i++) {
10
10
  const before = Date.now();
11
- const result = Lexer.run(file);
11
+ const result = new Lexer().run(file);
12
12
  const runtime = Date.now() - before;
13
13
  console.log("Runtime: " + runtime + "ms");
14
14
  total += runtime;
@@ -1812,6 +1812,10 @@ declare class EventHandler extends Expression {
1812
1812
  getRunnable(): IStatementRunnable;
1813
1813
  }
1814
1814
 
1815
+ declare class EventName extends Expression {
1816
+ getRunnable(): IStatementRunnable;
1817
+ }
1818
+
1815
1819
  declare class Events implements IStatement {
1816
1820
  getMatcher(): IStatementRunnable;
1817
1821
  }
@@ -1927,6 +1931,7 @@ declare namespace Expressions {
1927
1931
  Dynamic,
1928
1932
  EntityAssociation,
1929
1933
  EventHandler,
1934
+ EventName,
1930
1935
  ExceptionName,
1931
1936
  FieldAll,
1932
1937
  FieldAssignment,
@@ -5597,9 +5602,6 @@ declare class Stop implements IStatement {
5597
5602
  getMatcher(): IStatementRunnable;
5598
5603
  }
5599
5604
 
5600
- declare class String_2 extends Token {
5601
- }
5602
-
5603
5605
  declare class StringTemplate extends Expression {
5604
5606
  getRunnable(): IStatementRunnable;
5605
5607
  }
@@ -5624,6 +5626,9 @@ declare class StringTemplateSource extends Expression {
5624
5626
  getRunnable(): IStatementRunnable;
5625
5627
  }
5626
5628
 
5629
+ declare class StringToken extends Token {
5630
+ }
5631
+
5627
5632
  declare class StringType extends AbstractType {
5628
5633
  toText(): string;
5629
5634
  isGeneric(): boolean;
@@ -6012,7 +6017,7 @@ declare namespace Tokens {
6012
6017
  WStaticArrow,
6013
6018
  StaticArrowW,
6014
6019
  WStaticArrowW,
6015
- String_2 as String,
6020
+ StringToken,
6016
6021
  StringTemplate_2 as StringTemplate,
6017
6022
  StringTemplateBegin,
6018
6023
  StringTemplateEnd,
@@ -8,7 +8,7 @@ const file = new src_1.MemoryFile("abapgit.abap", fs.readFileSync("./lexer_perfo
8
8
  let total = 0;
9
9
  for (let i = 0; i < 10; i++) {
10
10
  const before = Date.now();
11
- const result = lexer_1.Lexer.run(file);
11
+ const result = new lexer_1.Lexer().run(file);
12
12
  const runtime = Date.now() - before;
13
13
  console.log("Runtime: " + runtime + "ms");
14
14
  total += runtime;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Lexer = void 0;
4
- const Tokens = require("./tokens");
5
4
  const position_1 = require("../../position");
5
+ const tokens_1 = require("./tokens");
6
6
  var Mode;
7
7
  (function (Mode) {
8
8
  Mode[Mode["Normal"] = 0] = "Normal";
@@ -25,6 +25,15 @@ class Buffer {
25
25
  clear() {
26
26
  this.buf = "";
27
27
  }
28
+ countIsEven(char) {
29
+ let count = 0;
30
+ for (let i = 0; i < this.buf.length; i += 1) {
31
+ if (this.buf.charAt(i) === char) {
32
+ count += 1;
33
+ }
34
+ }
35
+ return count % 2 === 0;
36
+ }
28
37
  }
29
38
  class Stream {
30
39
  constructor(raw) {
@@ -77,14 +86,14 @@ class Stream {
77
86
  }
78
87
  }
79
88
  class Lexer {
80
- static run(file, virtual) {
89
+ run(file, virtual) {
81
90
  this.virtual = virtual;
82
91
  this.tokens = [];
83
92
  this.m = Mode.Normal;
84
93
  this.process(file.getRaw());
85
94
  return { file, tokens: this.tokens };
86
95
  }
87
- static add() {
96
+ add() {
88
97
  const s = this.buffer.get().trim();
89
98
  if (s.length > 0) {
90
99
  const col = this.stream.getCol();
@@ -105,174 +114,174 @@ class Lexer {
105
114
  }
106
115
  let tok = undefined;
107
116
  if (this.m === Mode.Comment) {
108
- tok = new Tokens.Comment(pos, s);
117
+ tok = new tokens_1.Comment(pos, s);
109
118
  }
110
119
  else if (this.m === Mode.Ping || this.m === Mode.Str) {
111
- tok = new Tokens.String(pos, s);
120
+ tok = new tokens_1.StringToken(pos, s);
112
121
  }
113
122
  else if (this.m === Mode.Template) {
114
123
  const first = s.charAt(0);
115
124
  const last = s.charAt(s.length - 1);
116
125
  if (first === "|" && last === "|") {
117
- tok = new Tokens.StringTemplate(pos, s);
126
+ tok = new tokens_1.StringTemplate(pos, s);
118
127
  }
119
128
  else if (first === "|" && last === "{" && whiteAfter === true) {
120
- tok = new Tokens.StringTemplateBegin(pos, s);
129
+ tok = new tokens_1.StringTemplateBegin(pos, s);
121
130
  }
122
131
  else if (first === "}" && last === "|" && whiteBefore === true) {
123
- tok = new Tokens.StringTemplateEnd(pos, s);
132
+ tok = new tokens_1.StringTemplateEnd(pos, s);
124
133
  }
125
134
  else if (first === "}" && last === "{" && whiteAfter === true && whiteBefore === true) {
126
- tok = new Tokens.StringTemplateMiddle(pos, s);
135
+ tok = new tokens_1.StringTemplateMiddle(pos, s);
127
136
  }
128
137
  else {
129
- tok = new Tokens.Identifier(pos, s);
138
+ tok = new tokens_1.Identifier(pos, s);
130
139
  }
131
140
  }
132
141
  else if (s.substr(0, 2) === "##") {
133
- tok = new Tokens.Pragma(pos, s);
142
+ tok = new tokens_1.Pragma(pos, s);
134
143
  }
135
144
  else if (s.length === 1) {
136
145
  if (s === "." || s === ",") {
137
- tok = new Tokens.Punctuation(pos, s);
146
+ tok = new tokens_1.Punctuation(pos, s);
138
147
  }
139
148
  else if (s === "[") {
140
- if (whiteBefore && whiteAfter) {
141
- tok = new Tokens.WBracketLeftW(pos, s);
149
+ if (whiteBefore === true && whiteAfter === true) {
150
+ tok = new tokens_1.WBracketLeftW(pos, s);
142
151
  }
143
- else if (whiteBefore) {
144
- tok = new Tokens.WBracketLeft(pos, s);
152
+ else if (whiteBefore === true) {
153
+ tok = new tokens_1.WBracketLeft(pos, s);
145
154
  }
146
- else if (whiteAfter) {
147
- tok = new Tokens.BracketLeftW(pos, s);
155
+ else if (whiteAfter === true) {
156
+ tok = new tokens_1.BracketLeftW(pos, s);
148
157
  }
149
158
  else {
150
- tok = new Tokens.BracketLeft(pos, s);
159
+ tok = new tokens_1.BracketLeft(pos, s);
151
160
  }
152
161
  }
153
162
  else if (s === "(") {
154
- if (whiteBefore && whiteAfter) {
155
- tok = new Tokens.WParenLeftW(pos, s);
163
+ if (whiteBefore === true && whiteAfter === true) {
164
+ tok = new tokens_1.WParenLeftW(pos, s);
156
165
  }
157
- else if (whiteBefore) {
158
- tok = new Tokens.WParenLeft(pos, s);
166
+ else if (whiteBefore === true) {
167
+ tok = new tokens_1.WParenLeft(pos, s);
159
168
  }
160
- else if (whiteAfter) {
161
- tok = new Tokens.ParenLeftW(pos, s);
169
+ else if (whiteAfter === true) {
170
+ tok = new tokens_1.ParenLeftW(pos, s);
162
171
  }
163
172
  else {
164
- tok = new Tokens.ParenLeft(pos, s);
173
+ tok = new tokens_1.ParenLeft(pos, s);
165
174
  }
166
175
  }
167
176
  else if (s === "]") {
168
- if (whiteBefore && whiteAfter) {
169
- tok = new Tokens.WBracketRightW(pos, s);
177
+ if (whiteBefore === true && whiteAfter === true) {
178
+ tok = new tokens_1.WBracketRightW(pos, s);
170
179
  }
171
- else if (whiteBefore) {
172
- tok = new Tokens.WBracketRight(pos, s);
180
+ else if (whiteBefore === true) {
181
+ tok = new tokens_1.WBracketRight(pos, s);
173
182
  }
174
- else if (whiteAfter) {
175
- tok = new Tokens.BracketRightW(pos, s);
183
+ else if (whiteAfter === true) {
184
+ tok = new tokens_1.BracketRightW(pos, s);
176
185
  }
177
186
  else {
178
- tok = new Tokens.BracketRight(pos, s);
187
+ tok = new tokens_1.BracketRight(pos, s);
179
188
  }
180
189
  }
181
190
  else if (s === ")") {
182
- if (whiteBefore && whiteAfter) {
183
- tok = new Tokens.WParenRightW(pos, s);
191
+ if (whiteBefore === true && whiteAfter === true) {
192
+ tok = new tokens_1.WParenRightW(pos, s);
184
193
  }
185
- else if (whiteBefore) {
186
- tok = new Tokens.WParenRight(pos, s);
194
+ else if (whiteBefore === true) {
195
+ tok = new tokens_1.WParenRight(pos, s);
187
196
  }
188
- else if (whiteAfter) {
189
- tok = new Tokens.ParenRightW(pos, s);
197
+ else if (whiteAfter === true) {
198
+ tok = new tokens_1.ParenRightW(pos, s);
190
199
  }
191
200
  else {
192
- tok = new Tokens.ParenRight(pos, s);
201
+ tok = new tokens_1.ParenRight(pos, s);
193
202
  }
194
203
  }
195
204
  else if (s === "-") {
196
- if (whiteBefore && whiteAfter) {
197
- tok = new Tokens.WDashW(pos, s);
205
+ if (whiteBefore === true && whiteAfter === true) {
206
+ tok = new tokens_1.WDashW(pos, s);
198
207
  }
199
- else if (whiteBefore) {
200
- tok = new Tokens.WDash(pos, s);
208
+ else if (whiteBefore === true) {
209
+ tok = new tokens_1.WDash(pos, s);
201
210
  }
202
- else if (whiteAfter) {
203
- tok = new Tokens.DashW(pos, s);
211
+ else if (whiteAfter === true) {
212
+ tok = new tokens_1.DashW(pos, s);
204
213
  }
205
214
  else {
206
- tok = new Tokens.Dash(pos, s);
215
+ tok = new tokens_1.Dash(pos, s);
207
216
  }
208
217
  }
209
218
  else if (s === "+") {
210
- if (whiteBefore && whiteAfter) {
211
- tok = new Tokens.WPlusW(pos, s);
219
+ if (whiteBefore === true && whiteAfter === true) {
220
+ tok = new tokens_1.WPlusW(pos, s);
212
221
  }
213
- else if (whiteBefore) {
214
- tok = new Tokens.WPlus(pos, s);
222
+ else if (whiteBefore === true) {
223
+ tok = new tokens_1.WPlus(pos, s);
215
224
  }
216
- else if (whiteAfter) {
217
- tok = new Tokens.PlusW(pos, s);
225
+ else if (whiteAfter === true) {
226
+ tok = new tokens_1.PlusW(pos, s);
218
227
  }
219
228
  else {
220
- tok = new Tokens.Plus(pos, s);
229
+ tok = new tokens_1.Plus(pos, s);
221
230
  }
222
231
  }
223
232
  else if (s === "@") {
224
- if (whiteBefore && whiteAfter) {
225
- tok = new Tokens.WAtW(pos, s);
233
+ if (whiteBefore === true && whiteAfter === true) {
234
+ tok = new tokens_1.WAtW(pos, s);
226
235
  }
227
- else if (whiteBefore) {
228
- tok = new Tokens.WAt(pos, s);
236
+ else if (whiteBefore === true) {
237
+ tok = new tokens_1.WAt(pos, s);
229
238
  }
230
- else if (whiteAfter) {
231
- tok = new Tokens.AtW(pos, s);
239
+ else if (whiteAfter === true) {
240
+ tok = new tokens_1.AtW(pos, s);
232
241
  }
233
242
  else {
234
- tok = new Tokens.At(pos, s);
243
+ tok = new tokens_1.At(pos, s);
235
244
  }
236
245
  }
237
246
  }
238
247
  else if (s.length === 2) {
239
248
  if (s === "->") {
240
- if (whiteBefore && whiteAfter) {
241
- tok = new Tokens.WInstanceArrowW(pos, s);
249
+ if (whiteBefore === true && whiteAfter === true) {
250
+ tok = new tokens_1.WInstanceArrowW(pos, s);
242
251
  }
243
- else if (whiteBefore) {
244
- tok = new Tokens.WInstanceArrow(pos, s);
252
+ else if (whiteBefore === true) {
253
+ tok = new tokens_1.WInstanceArrow(pos, s);
245
254
  }
246
- else if (whiteAfter) {
247
- tok = new Tokens.InstanceArrowW(pos, s);
255
+ else if (whiteAfter === true) {
256
+ tok = new tokens_1.InstanceArrowW(pos, s);
248
257
  }
249
258
  else {
250
- tok = new Tokens.InstanceArrow(pos, s);
259
+ tok = new tokens_1.InstanceArrow(pos, s);
251
260
  }
252
261
  }
253
262
  else if (s === "=>") {
254
- if (whiteBefore && whiteAfter) {
255
- tok = new Tokens.WStaticArrowW(pos, s);
263
+ if (whiteBefore === true && whiteAfter === true) {
264
+ tok = new tokens_1.WStaticArrowW(pos, s);
256
265
  }
257
- else if (whiteBefore) {
258
- tok = new Tokens.WStaticArrow(pos, s);
266
+ else if (whiteBefore === true) {
267
+ tok = new tokens_1.WStaticArrow(pos, s);
259
268
  }
260
- else if (whiteAfter) {
261
- tok = new Tokens.StaticArrowW(pos, s);
269
+ else if (whiteAfter === true) {
270
+ tok = new tokens_1.StaticArrowW(pos, s);
262
271
  }
263
272
  else {
264
- tok = new Tokens.StaticArrow(pos, s);
273
+ tok = new tokens_1.StaticArrow(pos, s);
265
274
  }
266
275
  }
267
276
  }
268
277
  if (tok === undefined) {
269
- tok = new Tokens.Identifier(pos, s);
278
+ tok = new tokens_1.Identifier(pos, s);
270
279
  }
271
280
  this.tokens.push(tok);
272
281
  }
273
282
  this.buffer.clear();
274
283
  }
275
- static process(raw) {
284
+ process(raw) {
276
285
  this.stream = new Stream(raw.replace(/\r/g, ""));
277
286
  this.buffer = new Buffer();
278
287
  for (;;) {
@@ -318,8 +327,8 @@ class Lexer {
318
327
  && buf.length > 1
319
328
  && current === "`"
320
329
  && aahead !== "``"
321
- && (buf.split("`").length - 1) % 2 === 0
322
- && ahead !== "`") {
330
+ && ahead !== "`"
331
+ && this.buffer.countIsEven("`")) {
323
332
  // end of ping
324
333
  this.add();
325
334
  if (ahead === `"`) {
@@ -341,8 +350,8 @@ class Lexer {
341
350
  && current === "'"
342
351
  && buf.length > 1
343
352
  && aahead !== "''"
344
- && (buf.split("'").length - 1) % 2 === 0
345
- && ahead !== "'") {
353
+ && ahead !== "'"
354
+ && this.buffer.countIsEven("'")) {
346
355
  // end of string
347
356
  this.add();
348
357
  if (ahead === "\"") {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StringTemplateMiddle = exports.StringTemplateEnd = exports.StringTemplateBegin = exports.StringTemplate = exports.String = void 0;
3
+ exports.StringTemplateMiddle = exports.StringTemplateEnd = exports.StringTemplateBegin = exports.StringTemplate = exports.StringToken = void 0;
4
4
  const _token_1 = require("./_token");
5
- class String extends _token_1.Token {
5
+ class StringToken extends _token_1.Token {
6
6
  }
7
- exports.String = String;
7
+ exports.StringToken = StringToken;
8
8
  class StringTemplate extends _token_1.Token {
9
9
  }
10
10
  exports.StringTemplate = StringTemplate;
@@ -133,7 +133,7 @@ class ExpandMacros {
133
133
  i++;
134
134
  }
135
135
  const file = new memory_file_1.MemoryFile("expand_macros.abap.prog", str);
136
- const lexerResult = lexer_1.Lexer.run(file, statement.getFirstToken().getStart());
136
+ const lexerResult = new lexer_1.Lexer().run(file, statement.getFirstToken().getStart());
137
137
  const result = new statement_parser_1.StatementParser(this.version, this.reg).run([lexerResult], this.macros.listMacroNames());
138
138
  return result[0].statements;
139
139
  }
@@ -5,7 +5,7 @@ const combi_1 = require("../combi");
5
5
  const _1 = require(".");
6
6
  class EventHandler extends combi_1.Expression {
7
7
  getRunnable() {
8
- const event = (0, combi_1.seq)("FOR EVENT", _1.Field, "OF", _1.ClassName, (0, combi_1.optPrio)((0, combi_1.seq)("IMPORTING", (0, combi_1.plusPrio)(_1.MethodParamName))));
8
+ const event = (0, combi_1.seq)("FOR EVENT", _1.EventName, "OF", _1.ClassName, (0, combi_1.optPrio)((0, combi_1.seq)("IMPORTING", (0, combi_1.plusPrio)(_1.MethodParamName))));
9
9
  return event;
10
10
  }
11
11
  }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventName = void 0;
4
+ const combi_1 = require("../combi");
5
+ class EventName extends combi_1.Expression {
6
+ getRunnable() {
7
+ return (0, combi_1.regex)(/^[&_!]?\*?\w*(\/\w+\/)?\d*[a-zA-Z_%\$][\w\*%\$\?#]*(~\w+)?$/);
8
+ }
9
+ }
10
+ exports.EventName = EventName;
11
+ //# sourceMappingURL=event_name.js.map
@@ -64,6 +64,7 @@ __exportStar(require("./dynamic"), exports);
64
64
  __exportStar(require("./entity_association"), exports);
65
65
  __exportStar(require("./entity_association"), exports);
66
66
  __exportStar(require("./event_handler"), exports);
67
+ __exportStar(require("./event_name"), exports);
67
68
  __exportStar(require("./exception_name"), exports);
68
69
  __exportStar(require("./field_all"), exports);
69
70
  __exportStar(require("./field_assignment"), exports);
@@ -10,7 +10,7 @@ class SQLIn extends combi_1.Expression {
10
10
  const val = new _1.SQLSource();
11
11
  const short = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.At), _1.SimpleSource3);
12
12
  const listOld = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeft), (0, combi_1.alt)((0, combi_1.ver)(version_1.Version.v740sp05, short), val), (0, combi_1.starPrio)((0, combi_1.seq)(",", val)), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenRight), (0, combi_1.tok)(tokens_1.ParenRightW), (0, combi_1.tok)(tokens_1.WParenRightW)));
13
- const listNew = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), val, (0, combi_1.starPrio)((0, combi_1.seq)(",", val)), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WParenRight), (0, combi_1.tok)(tokens_1.WParenRightW)));
13
+ const listNew = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), val, (0, combi_1.starPrio)((0, combi_1.seq)(",", (0, combi_1.altPrio)(short, val))), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WParenRight), (0, combi_1.tok)(tokens_1.WParenRightW)));
14
14
  const list = (0, combi_1.alt)(listOld, (0, combi_1.ver)(version_1.Version.v740sp02, listNew)); // version is a guess, https://github.com/abaplint/abaplint/issues/2530
15
15
  const subSelect = (0, combi_1.seq)("(", _1.Select, ")");
16
16
  const inn = (0, combi_1.seq)("IN", (0, combi_1.altPrio)(_1.SQLSource, list, subSelect));
@@ -6,7 +6,7 @@ const _1 = require(".");
6
6
  class SQLJoin extends combi_1.Expression {
7
7
  getRunnable() {
8
8
  const joinType = (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.altPrio)("INNER", "LEFT OUTER", "LEFT")), "JOIN");
9
- const join = (0, combi_1.seq)(joinType, _1.SQLFromSource, "ON", (0, combi_1.plusPrio)(_1.SQLCond));
9
+ const join = (0, combi_1.seq)(joinType, _1.SQLFromSource, "ON", _1.SQLCond);
10
10
  return join;
11
11
  }
12
12
  }
@@ -6,7 +6,7 @@ const expressions_1 = require("../expressions");
6
6
  class Events {
7
7
  getMatcher() {
8
8
  const exporting = (0, combi_1.seq)("EXPORTING", (0, combi_1.plus)(expressions_1.MethodParamOptional));
9
- return (0, combi_1.seq)((0, combi_1.alt)("CLASS-EVENTS", "EVENTS"), expressions_1.Field, (0, combi_1.opt)(exporting));
9
+ return (0, combi_1.seq)((0, combi_1.alt)("CLASS-EVENTS", "EVENTS"), expressions_1.EventName, (0, combi_1.opt)(exporting));
10
10
  }
11
11
  }
12
12
  exports.Events = Events;
@@ -6,7 +6,7 @@ const expressions_1 = require("../expressions");
6
6
  class RaiseEvent {
7
7
  getMatcher() {
8
8
  const exporting = (0, combi_1.seq)("EXPORTING", expressions_1.ParameterListS);
9
- return (0, combi_1.seq)("RAISE EVENT", expressions_1.Field, (0, combi_1.opt)(exporting));
9
+ return (0, combi_1.seq)("RAISE EVENT", expressions_1.EventName, (0, combi_1.opt)(exporting));
10
10
  }
11
11
  }
12
12
  exports.RaiseEvent = RaiseEvent;
@@ -133,7 +133,8 @@ class ABAPFileInformation {
133
133
  constants.push(...this.parseConstants(found.findFirstStructure(Structures.PrivateSection), visibility_1.Visibility.Private));
134
134
  const superClassName = (_a = found.findFirstExpression(Expressions.SuperClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
135
135
  const containsGlobal = found.findFirstExpression(Expressions.ClassGlobal);
136
- const concat = found.findFirstStatement(Statements.ClassDefinition).concatTokens().toUpperCase();
136
+ const cdef = found.findFirstStatement(Statements.ClassDefinition);
137
+ const concat = (cdef === null || cdef === void 0 ? void 0 : cdef.concatTokens().toUpperCase()) || "";
137
138
  this.classes.push({
138
139
  name: className.getStr(),
139
140
  identifier: new _identifier_1.Identifier(className, this.filename),
@@ -143,7 +144,7 @@ class ABAPFileInformation {
143
144
  superClassName,
144
145
  interfaces: this.getImplementing(found),
145
146
  isForTesting: concat.includes(" FOR TESTING"),
146
- isAbstract: concat.includes(" ABSTRACT"),
147
+ isAbstract: (cdef === null || cdef === void 0 ? void 0 : cdef.findDirectTokenByText("ABSTRACT")) !== undefined,
147
148
  isSharedMemory: concat.includes(" SHARED MEMORY ENABLED"),
148
149
  isFinal: found.findFirstExpression(Expressions.ClassFinal) !== undefined,
149
150
  aliases,
@@ -7,7 +7,7 @@ const _reference_1 = require("../_reference");
7
7
  class RaiseEvent {
8
8
  runSyntax(node, scope, filename) {
9
9
  // todo: only possible in classes
10
- const f = node.findDirectExpression(Expressions.Field);
10
+ const f = node.findDirectExpression(Expressions.EventName);
11
11
  if (f === null || f === void 0 ? void 0 : f.concatTokens().includes("~")) {
12
12
  const name = f.concatTokens().split("~")[0];
13
13
  const idef = scope.findInterfaceDefinition(name);
@@ -20,7 +20,7 @@ class ABAPParser {
20
20
  const start = Date.now();
21
21
  // 1: lexing
22
22
  const b1 = Date.now();
23
- const lexerResult = files.map(f => lexer_1.Lexer.run(f));
23
+ const lexerResult = files.map(f => new lexer_1.Lexer().run(f));
24
24
  const lexingRuntime = Date.now() - b1;
25
25
  // 2: statements
26
26
  const b2 = Date.now();
@@ -51,7 +51,7 @@ class ExpressionNode extends _abstract_node_1.AbstractNode {
51
51
  let prev;
52
52
  for (const token of this.getTokens()) {
53
53
  if (token instanceof tokens_1.Comment
54
- || token instanceof tokens_1.String
54
+ || token instanceof tokens_1.StringToken
55
55
  || token instanceof tokens_1.StringTemplate
56
56
  || token instanceof tokens_1.StringTemplateBegin
57
57
  || token instanceof tokens_1.StringTemplateMiddle
@@ -90,7 +90,7 @@ class StatementNode extends _abstract_node_1.AbstractNode {
90
90
  let prev;
91
91
  for (const token of this.getTokens()) {
92
92
  if (token instanceof comment_1.Comment
93
- || token instanceof string_1.String
93
+ || token instanceof string_1.StringToken
94
94
  || token instanceof string_1.StringTemplate
95
95
  || token instanceof string_1.StringTemplateBegin
96
96
  || token instanceof string_1.StringTemplateMiddle
@@ -226,7 +226,7 @@ class StatementNode extends _abstract_node_1.AbstractNode {
226
226
  let prev;
227
227
  for (const token of this.getTokens()) {
228
228
  if (token instanceof comment_1.Comment
229
- || token instanceof string_1.String
229
+ || token instanceof string_1.StringToken
230
230
  || token instanceof string_1.StringTemplate
231
231
  || token instanceof string_1.StringTemplateBegin
232
232
  || token instanceof string_1.StringTemplateMiddle
@@ -41,10 +41,11 @@ class ClassDefinition extends _identifier_1.Identifier {
41
41
  }
42
42
  this.methodDefs = new method_definitions_1.MethodDefinitions(this.node, this.filename, scope);
43
43
  scope.pop(node.getLastToken().getEnd());
44
- const concat = this.node.findFirstStatement(Statements.ClassDefinition).concatTokens().toUpperCase();
44
+ const cdef = this.node.findFirstStatement(Statements.ClassDefinition);
45
+ const concat = cdef.concatTokens().toUpperCase();
45
46
  this.testing = concat.includes(" FOR TESTING");
46
47
  this.sharedMemory = concat.includes(" SHARED MEMORY ENABLED");
47
- this.abstract = concat.includes(" ABSTRACT");
48
+ this.abstract = (cdef === null || cdef === void 0 ? void 0 : cdef.findDirectTokenByText("ABSTRACT")) !== undefined;
48
49
  }
49
50
  getFriends() {
50
51
  return this.friends;
@@ -11,7 +11,7 @@ class EventDefinition extends _identifier_1.Identifier {
11
11
  if (!(node.get() instanceof events_1.Events)) {
12
12
  throw new Error("MethodDefinition, expected MethodDef as part of input node");
13
13
  }
14
- const found = node.findFirstExpression(Expressions.Field);
14
+ const found = node.findFirstExpression(Expressions.EventName);
15
15
  if (found === undefined) {
16
16
  throw new Error("MethodDefinition, expected MethodDef as part of input node");
17
17
  }
@@ -113,7 +113,7 @@ class MethodParameters {
113
113
  else if (doVoid && ooName) {
114
114
  scope.addReference(nameToken, undefined, _reference_1.ReferenceType.ObjectOrientedVoidReference, this.filename, { ooName: ooName.toUpperCase() });
115
115
  }
116
- const eventName = (_b = node.findFirstExpression(Expressions.Field)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
116
+ const eventName = (_b = node.findFirstExpression(Expressions.EventName)) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr();
117
117
  const event = new _object_oriented_1.ObjectOriented(scope).searchEvent(def, eventName);
118
118
  for (const p of handler.findAllExpressions(Expressions.MethodParamName)) {
119
119
  const token = p.getFirstToken();
@@ -9,9 +9,10 @@ class AbstractFile {
9
9
  return this.filename;
10
10
  }
11
11
  baseName() {
12
- const base1 = this.getFilename().split("\\").reverse()[0];
13
- const base2 = base1.split("/").reverse()[0];
14
- return base2;
12
+ const first = this.getFilename().split("\\");
13
+ const base1 = first[first.length - 1];
14
+ const base2 = base1.split("/");
15
+ return base2[base2.length - 1];
15
16
  }
16
17
  getObjectType() {
17
18
  var _a;
@@ -36,7 +36,7 @@ class Hover {
36
36
  if (lookup === null || lookup === void 0 ? void 0 : lookup.hover) {
37
37
  return { kind: LServer.MarkupKind.Markdown, value: lookup.hover };
38
38
  }
39
- if (found.token instanceof Tokens.String) {
39
+ if (found.token instanceof Tokens.StringToken) {
40
40
  return { kind: LServer.MarkupKind.Markdown, value: "String" };
41
41
  }
42
42
  return undefined;
@@ -76,7 +76,7 @@ class SemanticHighlighting {
76
76
  || statementInstance instanceof Statements.EndForm) {
77
77
  tokenType = BLOCK_ABAP;
78
78
  }
79
- else if (tokenInstance instanceof tokens_1.String
79
+ else if (tokenInstance instanceof tokens_1.StringToken
80
80
  || tokenInstance instanceof tokens_1.StringTemplate
81
81
  || tokenInstance instanceof tokens_1.StringTemplateBegin
82
82
  || tokenInstance instanceof tokens_1.StringTemplateEnd
@@ -39,7 +39,8 @@ class VirtualPosition extends Position {
39
39
  if (!(p instanceof VirtualPosition)) {
40
40
  return false;
41
41
  }
42
- return super.equals(this.virtual) && this.vrow === p.vrow && this.vcol === p.vcol;
42
+ const bar = p; // widening cast for ABAP translation
43
+ return super.equals(this.virtual) && this.vrow === bar.vrow && this.vcol === bar.vcol;
43
44
  }
44
45
  }
45
46
  exports.VirtualPosition = VirtualPosition;
@@ -16,7 +16,7 @@ class FixCase {
16
16
  for (const child of statement.getChildren()) {
17
17
  if (child instanceof nodes_1.TokenNodeRegex) {
18
18
  const token = child.get();
19
- if (token instanceof Tokens.String) {
19
+ if (token instanceof Tokens.StringToken) {
20
20
  continue;
21
21
  }
22
22
  this.replaceString(token.getStart(), this.formatNonKeyword(token.getStr()));
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.93.96";
66
+ return "2.93.98";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
@@ -18,16 +18,35 @@ class IfInIf extends _abap_rule_1.ABAPRule {
18
18
  return {
19
19
  key: "if_in_if",
20
20
  title: "IF in IF",
21
- shortDescription: `Detects nested ifs which can be refactored to a single condition using AND.`,
22
- extendedInformation: `https://docs.abapopenchecks.org/checks/01/
21
+ shortDescription: `Detects nested ifs which can be refactored.`,
22
+ extendedInformation: `
23
+ Directly nested IFs without ELSE can be refactored to a single condition using AND.
24
+
25
+ ELSE condtions with directly nested IF refactored to ELSEIF.
26
+
27
+ https://docs.abapopenchecks.org/checks/01/
23
28
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#keep-the-nesting-depth-low`,
24
29
  badExample: `IF condition1.
25
30
  IF condition2.
26
31
  ...
27
32
  ENDIF.
33
+ ENDIF.
34
+
35
+ IF condition1.
36
+ ...
37
+ ELSE.
38
+ IF condition2.
39
+ ...
40
+ ENDIF.
28
41
  ENDIF.`,
29
42
  goodExample: `IF ( condition1 ) AND ( condition2 ).
30
43
  ...
44
+ ENDIF.
45
+
46
+ IF condition1.
47
+ ...
48
+ ELSEIF condition2.
49
+ ...
31
50
  ENDIF.`,
32
51
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
33
52
  };
@@ -42,7 +42,7 @@ https://docs.abapopenchecks.org/checks/04/`,
42
42
  for (let rowIndex = 0; rowIndex < array.length; rowIndex++) {
43
43
  const row = array[rowIndex].replace("\r", "");
44
44
  if (row.length > maxLineLength) {
45
- const message = `Maximum allowed line length of ${maxLineLength} exceeded, currently ${row.length}`;
45
+ const message = `Maximum allowed line length of ${maxLineLength} exceeded, currently ${row.length}`;
46
46
  issues.push(issue_1.Issue.atRow(file, rowIndex + 1, message, this.getMetadata().key, this.conf.severity));
47
47
  }
48
48
  else if (row.length > this.conf.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.93.96",
3
+ "version": "2.93.98",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",