@abaplint/cli 2.119.59 → 2.119.61
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.
- package/build/cli.js +248 -134
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -22,6 +22,37 @@ const ModeStr = 3;
|
|
|
22
22
|
const ModeTemplate = 4;
|
|
23
23
|
const ModeComment = 5;
|
|
24
24
|
const ModePragma = 6;
|
|
25
|
+
// character codes, used for integer comparisons in the hot loop
|
|
26
|
+
const EOF = -1; // no character (start/end of file)
|
|
27
|
+
const CH_TAB = 9; // "\t"
|
|
28
|
+
const CH_NL = 10; // "\n"
|
|
29
|
+
const CH_SPACE = 32; // " "
|
|
30
|
+
const CH_DQUOTE = 34; // "\""
|
|
31
|
+
const CH_HASH = 35; // "#"
|
|
32
|
+
const CH_QUOTE = 39; // "'"
|
|
33
|
+
const CH_STAR = 42; // "*"
|
|
34
|
+
const CH_DASH = 45; // "-"
|
|
35
|
+
const CH_COMMA = 44; // ","
|
|
36
|
+
const CH_DOT = 46; // "."
|
|
37
|
+
const CH_COLON = 58; // ":"
|
|
38
|
+
const CH_EQUALS = 61; // "="
|
|
39
|
+
const CH_GT = 62; // ">"
|
|
40
|
+
const CH_AT = 64; // "@"
|
|
41
|
+
const CH_BACKSLASH = 92; // "\\"
|
|
42
|
+
const CH_BACKTICK = 96; // "`"
|
|
43
|
+
const CH_LBRACE = 123; // "{"
|
|
44
|
+
const CH_PIPE = 124; // "|"
|
|
45
|
+
const CH_RBRACE = 125; // "}"
|
|
46
|
+
// characters that terminate the current token
|
|
47
|
+
const SPLITS = new Set([
|
|
48
|
+
CH_SPACE, CH_COLON, CH_DOT, CH_COMMA, CH_DASH, 43 /* + */, 40 /* ( */,
|
|
49
|
+
41 /* ) */, 91 /* [ */, 93 /* ] */, CH_BACKSLASH, CH_TAB, CH_NL
|
|
50
|
+
]);
|
|
51
|
+
// single characters that are emitted as their own token
|
|
52
|
+
const BUFS = new Set([
|
|
53
|
+
CH_DOT, CH_COMMA, CH_COLON, 40 /* ( */, 41 /* ) */, 91 /* [ */,
|
|
54
|
+
93 /* ] */, 43 /* + */, CH_AT
|
|
55
|
+
]);
|
|
25
56
|
class Lexer {
|
|
26
57
|
run(file, virtual) {
|
|
27
58
|
this.virtual = virtual;
|
|
@@ -36,15 +67,17 @@ class Lexer {
|
|
|
36
67
|
const col = this.stream.getCol();
|
|
37
68
|
const row = this.stream.getRow();
|
|
38
69
|
let whiteBefore = false;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
70
|
+
const beforeOffset = this.stream.getOffset() - s.length;
|
|
71
|
+
if (beforeOffset >= 0) {
|
|
72
|
+
const prev = this.stream.charCodeAt(beforeOffset);
|
|
73
|
+
if (prev === CH_SPACE || prev === CH_NL || prev === CH_TAB || prev === CH_COLON) {
|
|
42
74
|
whiteBefore = true;
|
|
43
75
|
}
|
|
44
76
|
}
|
|
45
77
|
let whiteAfter = false;
|
|
46
78
|
const next = this.stream.nextChar();
|
|
47
|
-
if (next ===
|
|
79
|
+
if (next === CH_SPACE || next === CH_NL || next === CH_TAB || next === CH_COLON
|
|
80
|
+
|| next === CH_COMMA || next === CH_DOT || next === EOF || next === CH_DQUOTE) {
|
|
48
81
|
whiteAfter = true;
|
|
49
82
|
}
|
|
50
83
|
let pos = new position_1.Position(row, col - s.length);
|
|
@@ -214,10 +247,10 @@ class Lexer {
|
|
|
214
247
|
}
|
|
215
248
|
}
|
|
216
249
|
if (tok === undefined && this.m === ModeNormal && s.charAt(0) === "\\") {
|
|
217
|
-
const adj = this.stream.nextChar() ===
|
|
250
|
+
const adj = this.stream.nextChar() === EOF ? 1 : 0;
|
|
218
251
|
const prevOffset = this.stream.getOffset() - s.length - adj;
|
|
219
|
-
const prevChar =
|
|
220
|
-
const whiteBeforeBackslash = prevChar ===
|
|
252
|
+
const prevChar = this.stream.charCodeAt(prevOffset);
|
|
253
|
+
const whiteBeforeBackslash = prevChar === CH_SPACE || prevChar === CH_NL || prevChar === CH_TAB || prevChar === CH_COLON;
|
|
221
254
|
if (!whiteBeforeBackslash) {
|
|
222
255
|
tok = new tokens_1.AssociationName(pos, s);
|
|
223
256
|
}
|
|
@@ -230,100 +263,77 @@ class Lexer {
|
|
|
230
263
|
this.buffer.clear();
|
|
231
264
|
}
|
|
232
265
|
process(raw) {
|
|
233
|
-
|
|
234
|
-
this.
|
|
235
|
-
|
|
236
|
-
splits[" "] = true;
|
|
237
|
-
splits[":"] = true;
|
|
238
|
-
splits["."] = true;
|
|
239
|
-
splits[","] = true;
|
|
240
|
-
splits["-"] = true;
|
|
241
|
-
splits["+"] = true;
|
|
242
|
-
splits["("] = true;
|
|
243
|
-
splits[")"] = true;
|
|
244
|
-
splits["["] = true;
|
|
245
|
-
splits["]"] = true;
|
|
246
|
-
splits["\\"] = true;
|
|
247
|
-
splits["\t"] = true;
|
|
248
|
-
splits["\n"] = true;
|
|
249
|
-
const bufs = {};
|
|
250
|
-
bufs["."] = true;
|
|
251
|
-
bufs[","] = true;
|
|
252
|
-
bufs[":"] = true;
|
|
253
|
-
bufs["("] = true;
|
|
254
|
-
bufs[")"] = true;
|
|
255
|
-
bufs["["] = true;
|
|
256
|
-
bufs["]"] = true;
|
|
257
|
-
bufs["+"] = true;
|
|
258
|
-
bufs["@"] = true;
|
|
266
|
+
const stream = new lexer_stream_1.LexerStream(raw.replace(/\r/g, ""));
|
|
267
|
+
this.stream = stream;
|
|
268
|
+
this.buffer = new lexer_buffer_1.LexerBuffer(stream.getRaw());
|
|
259
269
|
for (;;) {
|
|
260
|
-
const current =
|
|
261
|
-
|
|
262
|
-
const ahead =
|
|
263
|
-
const aahead =
|
|
270
|
+
const current = stream.currentChar();
|
|
271
|
+
this.buffer.add(stream.getOffset());
|
|
272
|
+
const ahead = stream.nextChar();
|
|
273
|
+
const aahead = stream.nextNextChar();
|
|
264
274
|
if (this.m === ModeNormal) {
|
|
265
|
-
if (
|
|
275
|
+
if (SPLITS.has(ahead)) {
|
|
266
276
|
this.add();
|
|
267
277
|
}
|
|
268
|
-
else if (ahead ===
|
|
278
|
+
else if (ahead === CH_QUOTE) {
|
|
269
279
|
// start string
|
|
270
280
|
this.add();
|
|
271
281
|
this.m = ModeStr;
|
|
272
282
|
}
|
|
273
|
-
else if (ahead ===
|
|
283
|
+
else if (ahead === CH_PIPE || ahead === CH_RBRACE) {
|
|
274
284
|
// start template
|
|
275
285
|
this.add();
|
|
276
286
|
this.m = ModeTemplate;
|
|
277
287
|
}
|
|
278
|
-
else if (ahead ===
|
|
288
|
+
else if (ahead === CH_BACKTICK) {
|
|
279
289
|
// start ping
|
|
280
290
|
this.add();
|
|
281
291
|
this.m = ModePing;
|
|
282
292
|
}
|
|
283
|
-
else if (aahead ===
|
|
293
|
+
else if (ahead === CH_HASH && aahead === CH_HASH) {
|
|
284
294
|
// start pragma
|
|
285
295
|
this.add();
|
|
286
296
|
this.m = ModePragma;
|
|
287
297
|
}
|
|
288
|
-
else if (ahead ===
|
|
289
|
-
|| (ahead ===
|
|
298
|
+
else if (ahead === CH_DQUOTE
|
|
299
|
+
|| (ahead === CH_STAR && current === CH_NL)) {
|
|
290
300
|
// start comment
|
|
291
301
|
this.add();
|
|
292
302
|
this.m = ModeComment;
|
|
293
303
|
}
|
|
294
|
-
else if (ahead ===
|
|
304
|
+
else if (ahead === CH_AT && this.buffer.get().trim().length === 0) {
|
|
295
305
|
this.add();
|
|
296
306
|
}
|
|
297
|
-
else if (aahead ===
|
|
298
|
-
|| aahead === "=>") {
|
|
307
|
+
else if ((ahead === CH_DASH || ahead === CH_EQUALS) && aahead === CH_GT) {
|
|
299
308
|
this.add();
|
|
300
309
|
}
|
|
301
|
-
else if (current ===
|
|
302
|
-
&& ahead !==
|
|
303
|
-
&& (
|
|
310
|
+
else if (current === CH_GT
|
|
311
|
+
&& ahead !== CH_SPACE
|
|
312
|
+
&& (stream.prevChar() === CH_DASH || stream.prevChar() === CH_EQUALS)) {
|
|
304
313
|
// arrows
|
|
305
314
|
this.add();
|
|
306
315
|
}
|
|
307
|
-
else if (
|
|
308
|
-
&& (
|
|
309
|
-
|| (
|
|
316
|
+
else if (this.buffer.length() === 1
|
|
317
|
+
&& (BUFS.has(current)
|
|
318
|
+
|| (current === CH_DASH && ahead !== CH_GT))) {
|
|
310
319
|
this.add();
|
|
311
320
|
}
|
|
312
321
|
}
|
|
313
|
-
else if (this.m === ModePragma && (ahead ===
|
|
322
|
+
else if (this.m === ModePragma && (ahead === CH_COMMA || ahead === CH_COLON
|
|
323
|
+
|| ahead === CH_DOT || ahead === CH_SPACE || ahead === CH_NL)) {
|
|
314
324
|
// end of pragma
|
|
315
325
|
this.add();
|
|
316
326
|
this.m = ModeNormal;
|
|
317
327
|
}
|
|
318
328
|
else if (this.m === ModePing
|
|
319
|
-
&&
|
|
320
|
-
&& current ===
|
|
321
|
-
&& aahead
|
|
322
|
-
&& ahead !==
|
|
323
|
-
&& this.buffer.countIsEven(
|
|
329
|
+
&& this.buffer.length() > 1
|
|
330
|
+
&& current === CH_BACKTICK
|
|
331
|
+
&& !(ahead === CH_BACKTICK && aahead === CH_BACKTICK)
|
|
332
|
+
&& ahead !== CH_BACKTICK
|
|
333
|
+
&& this.buffer.countIsEven(CH_BACKTICK)) {
|
|
324
334
|
// end of ping
|
|
325
335
|
this.add();
|
|
326
|
-
if (ahead ===
|
|
336
|
+
if (ahead === CH_DQUOTE) {
|
|
327
337
|
this.m = ModeComment;
|
|
328
338
|
}
|
|
329
339
|
else {
|
|
@@ -331,41 +341,41 @@ class Lexer {
|
|
|
331
341
|
}
|
|
332
342
|
}
|
|
333
343
|
else if (this.m === ModeTemplate
|
|
334
|
-
&&
|
|
335
|
-
&& (current ===
|
|
336
|
-
&& (
|
|
344
|
+
&& this.buffer.length() > 1
|
|
345
|
+
&& (current === CH_PIPE || current === CH_LBRACE)
|
|
346
|
+
&& (stream.prevChar() !== CH_BACKSLASH || (stream.prevPrevChar() === CH_BACKSLASH && stream.prevChar() === CH_BACKSLASH))) {
|
|
337
347
|
// end of template
|
|
338
348
|
this.add();
|
|
339
349
|
this.m = ModeNormal;
|
|
340
350
|
}
|
|
341
351
|
else if (this.m === ModeTemplate
|
|
342
|
-
&& ahead ===
|
|
343
|
-
&& current !==
|
|
352
|
+
&& ahead === CH_RBRACE
|
|
353
|
+
&& current !== CH_BACKSLASH) {
|
|
344
354
|
this.add();
|
|
345
355
|
}
|
|
346
356
|
else if (this.m === ModeStr
|
|
347
|
-
&& current ===
|
|
348
|
-
&&
|
|
349
|
-
&& aahead
|
|
350
|
-
&& ahead !==
|
|
351
|
-
&& this.buffer.countIsEven(
|
|
357
|
+
&& current === CH_QUOTE
|
|
358
|
+
&& this.buffer.length() > 1
|
|
359
|
+
&& !(ahead === CH_QUOTE && aahead === CH_QUOTE)
|
|
360
|
+
&& ahead !== CH_QUOTE
|
|
361
|
+
&& this.buffer.countIsEven(CH_QUOTE)) {
|
|
352
362
|
// end of string
|
|
353
363
|
this.add();
|
|
354
|
-
if (ahead ===
|
|
364
|
+
if (ahead === CH_DQUOTE) {
|
|
355
365
|
this.m = ModeComment;
|
|
356
366
|
}
|
|
357
367
|
else {
|
|
358
368
|
this.m = ModeNormal;
|
|
359
369
|
}
|
|
360
370
|
}
|
|
361
|
-
else if (ahead ===
|
|
371
|
+
else if (ahead === CH_NL && this.m !== ModeTemplate) {
|
|
362
372
|
this.add();
|
|
363
373
|
this.m = ModeNormal;
|
|
364
374
|
}
|
|
365
|
-
else if (this.m === ModeTemplate && current ===
|
|
375
|
+
else if (this.m === ModeTemplate && current === CH_NL) {
|
|
366
376
|
this.add();
|
|
367
377
|
}
|
|
368
|
-
if (!
|
|
378
|
+
if (!stream.advance()) {
|
|
369
379
|
break;
|
|
370
380
|
}
|
|
371
381
|
}
|
|
@@ -387,24 +397,38 @@ exports.Lexer = Lexer;
|
|
|
387
397
|
|
|
388
398
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
389
399
|
exports.LexerBuffer = void 0;
|
|
400
|
+
// The buffer holds a reference to the raw input and tracks the [start, end)
|
|
401
|
+
// offset range of the current token, so the token string can be sliced out with
|
|
402
|
+
// a single substring() instead of being concatenated one character at a time.
|
|
390
403
|
class LexerBuffer {
|
|
391
|
-
constructor() {
|
|
392
|
-
this.
|
|
404
|
+
constructor(raw) {
|
|
405
|
+
this.raw = raw;
|
|
406
|
+
this.start = 0;
|
|
407
|
+
this.end = 0;
|
|
408
|
+
this.empty = true;
|
|
393
409
|
}
|
|
394
|
-
add(
|
|
395
|
-
this.
|
|
396
|
-
|
|
410
|
+
add(offset) {
|
|
411
|
+
if (this.empty === true) {
|
|
412
|
+
this.start = offset < 0 ? 0 : offset;
|
|
413
|
+
this.empty = false;
|
|
414
|
+
}
|
|
415
|
+
this.end = offset + 1;
|
|
397
416
|
}
|
|
398
417
|
get() {
|
|
399
|
-
return this.
|
|
418
|
+
return this.raw.substring(this.start, this.end);
|
|
419
|
+
}
|
|
420
|
+
length() {
|
|
421
|
+
return this.end - this.start;
|
|
400
422
|
}
|
|
401
423
|
clear() {
|
|
402
|
-
this.
|
|
424
|
+
this.start = 0;
|
|
425
|
+
this.end = 0;
|
|
426
|
+
this.empty = true;
|
|
403
427
|
}
|
|
404
428
|
countIsEven(char) {
|
|
405
429
|
let count = 0;
|
|
406
|
-
for (let i =
|
|
407
|
-
if (this.
|
|
430
|
+
for (let i = this.start; i < this.end; i += 1) {
|
|
431
|
+
if (this.raw.charCodeAt(i) === char) {
|
|
408
432
|
count += 1;
|
|
409
433
|
}
|
|
410
434
|
}
|
|
@@ -426,6 +450,8 @@ exports.LexerBuffer = LexerBuffer;
|
|
|
426
450
|
|
|
427
451
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
428
452
|
exports.LexerStream = void 0;
|
|
453
|
+
const NL = 10; // "\n"
|
|
454
|
+
const EOF = -1; // no character (start/end of file)
|
|
429
455
|
class LexerStream {
|
|
430
456
|
constructor(raw) {
|
|
431
457
|
this.offset = -1;
|
|
@@ -434,7 +460,7 @@ class LexerStream {
|
|
|
434
460
|
this.col = 0;
|
|
435
461
|
}
|
|
436
462
|
advance() {
|
|
437
|
-
if (this.currentChar() ===
|
|
463
|
+
if (this.currentChar() === NL) {
|
|
438
464
|
this.col = 1;
|
|
439
465
|
this.row = this.row + 1;
|
|
440
466
|
}
|
|
@@ -452,38 +478,51 @@ class LexerStream {
|
|
|
452
478
|
getRow() {
|
|
453
479
|
return this.row;
|
|
454
480
|
}
|
|
481
|
+
// the *Char() accessors return character codes (charCodeAt) rather than
|
|
482
|
+
// single character strings, to avoid allocating a string per input character
|
|
483
|
+
// in the lexer hot loop. EOF (-1) is returned when the offset is out of range.
|
|
455
484
|
prevChar() {
|
|
456
|
-
|
|
457
|
-
|
|
485
|
+
const o = this.offset - 1;
|
|
486
|
+
if (o < 0) {
|
|
487
|
+
return EOF;
|
|
458
488
|
}
|
|
459
|
-
return this.raw.
|
|
489
|
+
return this.raw.charCodeAt(o);
|
|
460
490
|
}
|
|
461
491
|
prevPrevChar() {
|
|
462
|
-
|
|
463
|
-
|
|
492
|
+
const o = this.offset - 2;
|
|
493
|
+
if (o < 0) {
|
|
494
|
+
return EOF;
|
|
464
495
|
}
|
|
465
|
-
return this.raw.
|
|
496
|
+
return this.raw.charCodeAt(o);
|
|
466
497
|
}
|
|
467
498
|
currentChar() {
|
|
468
499
|
if (this.offset < 0) {
|
|
469
|
-
return
|
|
500
|
+
return NL; // simulate newline at start of file to handle star(*) comments
|
|
470
501
|
}
|
|
471
502
|
else if (this.offset >= this.raw.length) {
|
|
472
|
-
return
|
|
503
|
+
return EOF;
|
|
473
504
|
}
|
|
474
|
-
return this.raw.
|
|
505
|
+
return this.raw.charCodeAt(this.offset);
|
|
475
506
|
}
|
|
476
507
|
nextChar() {
|
|
477
|
-
|
|
478
|
-
|
|
508
|
+
const o = this.offset + 1;
|
|
509
|
+
if (o >= this.raw.length) {
|
|
510
|
+
return EOF;
|
|
479
511
|
}
|
|
480
|
-
return this.raw.
|
|
512
|
+
return this.raw.charCodeAt(o);
|
|
481
513
|
}
|
|
482
514
|
nextNextChar() {
|
|
483
|
-
|
|
484
|
-
|
|
515
|
+
const o = this.offset + 2;
|
|
516
|
+
if (o >= this.raw.length) {
|
|
517
|
+
return EOF;
|
|
485
518
|
}
|
|
486
|
-
return this.raw.
|
|
519
|
+
return this.raw.charCodeAt(o);
|
|
520
|
+
}
|
|
521
|
+
charCodeAt(o) {
|
|
522
|
+
if (o < 0 || o >= this.raw.length) {
|
|
523
|
+
return EOF;
|
|
524
|
+
}
|
|
525
|
+
return this.raw.charCodeAt(o);
|
|
487
526
|
}
|
|
488
527
|
getRaw() {
|
|
489
528
|
return this.raw;
|
|
@@ -1881,8 +1920,9 @@ class Word {
|
|
|
1881
1920
|
}
|
|
1882
1921
|
}
|
|
1883
1922
|
class Token {
|
|
1884
|
-
constructor(
|
|
1885
|
-
this.
|
|
1923
|
+
constructor(t) {
|
|
1924
|
+
this.tokenType = t;
|
|
1925
|
+
this.name = t.name;
|
|
1886
1926
|
}
|
|
1887
1927
|
listKeywords() {
|
|
1888
1928
|
return [];
|
|
@@ -1894,7 +1934,7 @@ class Token {
|
|
|
1894
1934
|
const result = [];
|
|
1895
1935
|
for (const input of r) {
|
|
1896
1936
|
if (input.remainingLength() !== 0
|
|
1897
|
-
&& input.peek().constructor
|
|
1937
|
+
&& input.peek().constructor === this.tokenType) {
|
|
1898
1938
|
result.push(input.shift(new nodes_1.TokenNode(input.peek())));
|
|
1899
1939
|
}
|
|
1900
1940
|
}
|
|
@@ -2090,7 +2130,12 @@ class Optional {
|
|
|
2090
2130
|
for (const input of r) {
|
|
2091
2131
|
result.push(input);
|
|
2092
2132
|
const res = this.optional.run([input]);
|
|
2093
|
-
|
|
2133
|
+
if (res.length === 1) {
|
|
2134
|
+
result.push(res[0]);
|
|
2135
|
+
}
|
|
2136
|
+
else {
|
|
2137
|
+
result.push(...res);
|
|
2138
|
+
}
|
|
2094
2139
|
}
|
|
2095
2140
|
return result;
|
|
2096
2141
|
}
|
|
@@ -2129,6 +2174,9 @@ class Star {
|
|
|
2129
2174
|
// avoid stack overflow
|
|
2130
2175
|
result = result.concat(res);
|
|
2131
2176
|
}
|
|
2177
|
+
else if (res.length === 1) {
|
|
2178
|
+
result.push(res[0]);
|
|
2179
|
+
}
|
|
2132
2180
|
else {
|
|
2133
2181
|
result.push(...res);
|
|
2134
2182
|
}
|
|
@@ -2280,6 +2328,9 @@ class Sequence {
|
|
|
2280
2328
|
// avoid stack overflow
|
|
2281
2329
|
result = result.concat(temp);
|
|
2282
2330
|
}
|
|
2331
|
+
else if (temp.length === 1) {
|
|
2332
|
+
result.push(temp[0]);
|
|
2333
|
+
}
|
|
2283
2334
|
else {
|
|
2284
2335
|
result.push(...temp);
|
|
2285
2336
|
}
|
|
@@ -2345,24 +2396,14 @@ class Expression {
|
|
|
2345
2396
|
for (const input of r) {
|
|
2346
2397
|
const temp = this.runnable.run([input]);
|
|
2347
2398
|
for (const t of temp) {
|
|
2348
|
-
|
|
2399
|
+
const consumed = input.remainingLength() - t.remainingLength();
|
|
2349
2400
|
if (consumed > 0) {
|
|
2350
|
-
const originalLength = t.getNodes().length;
|
|
2351
|
-
const children = [];
|
|
2352
|
-
while (consumed > 0) {
|
|
2353
|
-
const sub = t.popNode();
|
|
2354
|
-
if (sub) {
|
|
2355
|
-
children.push(sub);
|
|
2356
|
-
consumed = consumed - sub.countTokens();
|
|
2357
|
-
}
|
|
2358
|
-
}
|
|
2359
2401
|
const re = new nodes_1.ExpressionNode(this);
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2402
|
+
results.push(t.wrapConsumed(consumed, re));
|
|
2403
|
+
}
|
|
2404
|
+
else {
|
|
2405
|
+
results.push(t);
|
|
2364
2406
|
}
|
|
2365
|
-
results.push(t);
|
|
2366
2407
|
}
|
|
2367
2408
|
}
|
|
2368
2409
|
// console.dir(results);
|
|
@@ -2504,7 +2545,12 @@ class Alternative {
|
|
|
2504
2545
|
const result = [];
|
|
2505
2546
|
for (const sequ of this.list) {
|
|
2506
2547
|
const temp = sequ.run(r);
|
|
2507
|
-
|
|
2548
|
+
if (temp.length === 1) {
|
|
2549
|
+
result.push(temp[0]);
|
|
2550
|
+
}
|
|
2551
|
+
else {
|
|
2552
|
+
result.push(...temp);
|
|
2553
|
+
}
|
|
2508
2554
|
}
|
|
2509
2555
|
return result;
|
|
2510
2556
|
}
|
|
@@ -2562,7 +2608,12 @@ class AlternativePriority {
|
|
|
2562
2608
|
// console.log(seq.toStr());
|
|
2563
2609
|
const temp = sequ.run(r);
|
|
2564
2610
|
if (temp.length > 0) {
|
|
2565
|
-
|
|
2611
|
+
if (temp.length === 1) {
|
|
2612
|
+
result.push(temp[0]);
|
|
2613
|
+
}
|
|
2614
|
+
else {
|
|
2615
|
+
result.push(...temp);
|
|
2616
|
+
}
|
|
2566
2617
|
break;
|
|
2567
2618
|
}
|
|
2568
2619
|
}
|
|
@@ -2678,7 +2729,7 @@ function regex(r) {
|
|
|
2678
2729
|
return new Regex(r);
|
|
2679
2730
|
}
|
|
2680
2731
|
function tok(t) {
|
|
2681
|
-
return new Token(t
|
|
2732
|
+
return new Token(t);
|
|
2682
2733
|
}
|
|
2683
2734
|
const expressionSingletons = {};
|
|
2684
2735
|
const stringSingletons = {};
|
|
@@ -11079,11 +11130,17 @@ class Result {
|
|
|
11079
11130
|
// nodes: matched tokens
|
|
11080
11131
|
this.tokens = tokens;
|
|
11081
11132
|
this.tokenIndex = tokenIndex;
|
|
11082
|
-
this.
|
|
11083
|
-
if (
|
|
11084
|
-
this.nodes
|
|
11133
|
+
this.nodeCount = 0;
|
|
11134
|
+
if (nodes !== undefined) {
|
|
11135
|
+
this.setNodes(nodes);
|
|
11085
11136
|
}
|
|
11086
11137
|
}
|
|
11138
|
+
static fromChain(tokens, tokenIndex, nodes, nodeCount) {
|
|
11139
|
+
const ret = new Result(tokens, tokenIndex);
|
|
11140
|
+
ret.nodes = nodes;
|
|
11141
|
+
ret.nodeCount = nodeCount;
|
|
11142
|
+
return ret;
|
|
11143
|
+
}
|
|
11087
11144
|
peek() {
|
|
11088
11145
|
return this.tokens[this.tokenIndex];
|
|
11089
11146
|
}
|
|
@@ -11091,18 +11148,54 @@ class Result {
|
|
|
11091
11148
|
return this.tokens[this.tokenIndex + offset];
|
|
11092
11149
|
}
|
|
11093
11150
|
shift(node) {
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11151
|
+
return Result.fromChain(this.tokens, this.tokenIndex + 1, { node, previous: this.nodes }, this.nodeCount + 1);
|
|
11152
|
+
}
|
|
11153
|
+
wrapConsumed(consumedTokens, node) {
|
|
11154
|
+
let current = this.nodes;
|
|
11155
|
+
let currentCount = this.nodeCount;
|
|
11156
|
+
const children = [];
|
|
11157
|
+
while (consumedTokens > 0) {
|
|
11158
|
+
if (current === undefined) {
|
|
11159
|
+
break;
|
|
11160
|
+
}
|
|
11161
|
+
children.push(current.node);
|
|
11162
|
+
consumedTokens = consumedTokens - current.node.countTokens();
|
|
11163
|
+
current = current.previous;
|
|
11164
|
+
currentCount--;
|
|
11165
|
+
}
|
|
11166
|
+
node.setChildren(children.reverse());
|
|
11167
|
+
this.nodes = { node, previous: current };
|
|
11168
|
+
this.nodeCount = currentCount + 1;
|
|
11169
|
+
return this;
|
|
11097
11170
|
}
|
|
11098
11171
|
popNode() {
|
|
11099
|
-
|
|
11172
|
+
if (this.nodes === undefined) {
|
|
11173
|
+
return undefined;
|
|
11174
|
+
}
|
|
11175
|
+
const ret = this.nodes.node;
|
|
11176
|
+
this.nodes = this.nodes.previous;
|
|
11177
|
+
this.nodeCount--;
|
|
11178
|
+
return ret;
|
|
11100
11179
|
}
|
|
11101
11180
|
getNodes() {
|
|
11102
|
-
|
|
11181
|
+
const ret = new Array(this.nodeCount);
|
|
11182
|
+
let current = this.nodes;
|
|
11183
|
+
for (let index = this.nodeCount - 1; index >= 0; index--) {
|
|
11184
|
+
if (current === undefined) {
|
|
11185
|
+
break;
|
|
11186
|
+
}
|
|
11187
|
+
ret[index] = current.node;
|
|
11188
|
+
current = current.previous;
|
|
11189
|
+
}
|
|
11190
|
+
return ret;
|
|
11103
11191
|
}
|
|
11104
11192
|
setNodes(n) {
|
|
11105
|
-
this.nodes =
|
|
11193
|
+
this.nodes = undefined;
|
|
11194
|
+
this.nodeCount = 0;
|
|
11195
|
+
for (const node of n) {
|
|
11196
|
+
this.nodes = { node, previous: this.nodes };
|
|
11197
|
+
this.nodeCount++;
|
|
11198
|
+
}
|
|
11106
11199
|
}
|
|
11107
11200
|
getTokens() {
|
|
11108
11201
|
return this.tokens;
|
|
@@ -38894,18 +38987,25 @@ class DeleteInternal {
|
|
|
38894
38987
|
let targetType = undefined;
|
|
38895
38988
|
const target = node.findDirectExpression(Expressions.Target);
|
|
38896
38989
|
if (target) {
|
|
38990
|
+
const targetName = target.concatTokens();
|
|
38897
38991
|
let tabl = undefined;
|
|
38898
|
-
const localVariable = input.scope.findVariable(
|
|
38992
|
+
const localVariable = input.scope.findVariable(targetName);
|
|
38899
38993
|
if (localVariable === undefined && node.getChildren().length === 5 && node.getChildren()[2].concatTokens().toUpperCase() === "FROM") {
|
|
38900
38994
|
// it might be a database table
|
|
38901
|
-
const found = (_a = input.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.lookupTableOrView(
|
|
38995
|
+
const found = (_a = input.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.lookupTableOrView(targetName);
|
|
38902
38996
|
if ((found === null || found === void 0 ? void 0 : found.object) !== undefined) {
|
|
38903
38997
|
tabl = found;
|
|
38904
38998
|
input.scope.getDDICReferences().addUsing(input.scope.getParentObj(), { object: tabl.object });
|
|
38905
38999
|
}
|
|
38906
39000
|
}
|
|
38907
39001
|
if (tabl === undefined) {
|
|
38908
|
-
|
|
39002
|
+
const ambigiousVoids = input.scope.getRegistry().getConfig().getSyntaxSetttings().ambigiousVoids || [];
|
|
39003
|
+
if (ambigiousVoids.some(name => name.toUpperCase() === targetName.toUpperCase())) {
|
|
39004
|
+
targetType = basic_1.VoidType.get(targetName);
|
|
39005
|
+
}
|
|
39006
|
+
else {
|
|
39007
|
+
targetType = target_1.Target.runSyntax(target, input);
|
|
39008
|
+
}
|
|
38909
39009
|
if (node.findDirectTokenByText("TABLE") === undefined
|
|
38910
39010
|
&& node.findDirectTokenByText("ADJACENT") === undefined
|
|
38911
39011
|
&& (node.findDirectTokenByText("FROM") || node.findDirectTokenByText("INDEX"))
|
|
@@ -54472,6 +54572,7 @@ class Config {
|
|
|
54472
54572
|
languageVersion: langVer,
|
|
54473
54573
|
errorNamespace: "^(Z|Y|LCL\_|TY\_|LIF\_)",
|
|
54474
54574
|
globalConstants: [],
|
|
54575
|
+
ambigiousVoids: [],
|
|
54475
54576
|
globalMacros: [],
|
|
54476
54577
|
},
|
|
54477
54578
|
rules: rules,
|
|
@@ -54522,6 +54623,12 @@ class Config {
|
|
|
54522
54623
|
// remove duplicates,
|
|
54523
54624
|
this.config.syntax.globalConstants = [...new Set(this.config.syntax.globalConstants)];
|
|
54524
54625
|
}
|
|
54626
|
+
if (this.config.syntax.ambigiousVoids === undefined) {
|
|
54627
|
+
this.config.syntax.ambigiousVoids = [];
|
|
54628
|
+
}
|
|
54629
|
+
else {
|
|
54630
|
+
this.config.syntax.ambigiousVoids = [...new Set(this.config.syntax.ambigiousVoids)];
|
|
54631
|
+
}
|
|
54525
54632
|
if (this.config.global.skipIncludesWithoutMain === undefined) {
|
|
54526
54633
|
this.config.global.skipIncludesWithoutMain = false;
|
|
54527
54634
|
}
|
|
@@ -68707,7 +68814,7 @@ class Registry {
|
|
|
68707
68814
|
}
|
|
68708
68815
|
static abaplintVersion() {
|
|
68709
68816
|
// magic, see build script "version.js"
|
|
68710
|
-
return "2.119.
|
|
68817
|
+
return "2.119.61";
|
|
68711
68818
|
}
|
|
68712
68819
|
getDDICReferences() {
|
|
68713
68820
|
return this.ddicReferences;
|
|
@@ -74367,6 +74474,7 @@ class DangerousStatementConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
|
74367
74474
|
this.insertTextpool = true;
|
|
74368
74475
|
this.deleteDynpro = true;
|
|
74369
74476
|
this.exportDynpro = true;
|
|
74477
|
+
this.editorCallForReport = true;
|
|
74370
74478
|
/** Finds instances of dynamic SQL: SELECT, UPDATE, DELETE, INSERT, MODIFY */
|
|
74371
74479
|
this.dynamicSQL = true;
|
|
74372
74480
|
/** Ignore dynamic SQL in IF_RAP_QUERY_PROVIDER~SELECT implementations */
|
|
@@ -74451,6 +74559,11 @@ dynamic SQL can potentially create SQL injection problems`,
|
|
|
74451
74559
|
else if (this.conf.exportDynpro && statement instanceof Statements.ExportDynpro) {
|
|
74452
74560
|
message = "EXPORT DYNPRO";
|
|
74453
74561
|
}
|
|
74562
|
+
else if (this.conf.editorCallForReport
|
|
74563
|
+
&& statement instanceof Statements.EditorCall
|
|
74564
|
+
&& statementNode.findDirectTokenByText("REPORT")) {
|
|
74565
|
+
message = "EDITOR-CALL FOR REPORT";
|
|
74566
|
+
}
|
|
74454
74567
|
if (message) {
|
|
74455
74568
|
issues.push(issue_1.Issue.atStatement(file, statementNode, this.getDescription(message), this.getMetadata().key, this.conf.severity));
|
|
74456
74569
|
}
|
|
@@ -75452,6 +75565,7 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
75452
75565
|
const lowConfig = this.lowReg.getConfig().get();
|
|
75453
75566
|
highConfig.syntax.errorNamespace = lowConfig.syntax.errorNamespace;
|
|
75454
75567
|
highConfig.syntax.globalConstants = lowConfig.syntax.globalConstants;
|
|
75568
|
+
highConfig.syntax.ambigiousVoids = lowConfig.syntax.ambigiousVoids;
|
|
75455
75569
|
highConfig.syntax.globalMacros = lowConfig.syntax.globalMacros;
|
|
75456
75570
|
this.highReg = new registry_1.Registry();
|
|
75457
75571
|
for (const o of this.lowReg.getObjects()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.119.
|
|
3
|
+
"version": "2.119.61",
|
|
4
4
|
"description": "abaplint - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://abaplint.org",
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@abaplint/core": "^2.119.
|
|
42
|
+
"@abaplint/core": "^2.119.61",
|
|
43
43
|
"@types/chai": "^4.3.20",
|
|
44
44
|
"@types/minimist": "^1.2.5",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|