@abaplint/core 2.93.97 → 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.
- package/adhoc/lexer_performance.ts +1 -1
- package/build/abaplint.d.ts +4 -4
- package/build/adhoc/lexer_performance.js +1 -1
- package/build/src/abap/1_lexer/lexer.js +90 -81
- package/build/src/abap/1_lexer/tokens/string.js +3 -3
- package/build/src/abap/2_statements/expand_macros.js +1 -1
- package/build/src/abap/2_statements/expressions/sql_in.js +1 -1
- package/build/src/abap/4_file_information/abap_file_information.js +3 -2
- package/build/src/abap/abap_parser.js +1 -1
- package/build/src/abap/nodes/expression_node.js +1 -1
- package/build/src/abap/nodes/statement_node.js +2 -2
- package/build/src/abap/types/class_definition.js +3 -2
- package/build/src/files/_abstract_file.js +4 -3
- package/build/src/lsp/hover.js +1 -1
- package/build/src/lsp/semantic.js +1 -1
- package/build/src/position.js +2 -1
- package/build/src/pretty_printer/fix_keyword_case.js +1 -1
- package/build/src/registry.js +1 -1
- package/build/src/rules/if_in_if.js +21 -2
- package/build/src/rules/line_length.js +1 -1
- 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;
|
package/build/abaplint.d.ts
CHANGED
|
@@ -5602,9 +5602,6 @@ declare class Stop implements IStatement {
|
|
|
5602
5602
|
getMatcher(): IStatementRunnable;
|
|
5603
5603
|
}
|
|
5604
5604
|
|
|
5605
|
-
declare class String_2 extends Token {
|
|
5606
|
-
}
|
|
5607
|
-
|
|
5608
5605
|
declare class StringTemplate extends Expression {
|
|
5609
5606
|
getRunnable(): IStatementRunnable;
|
|
5610
5607
|
}
|
|
@@ -5629,6 +5626,9 @@ declare class StringTemplateSource extends Expression {
|
|
|
5629
5626
|
getRunnable(): IStatementRunnable;
|
|
5630
5627
|
}
|
|
5631
5628
|
|
|
5629
|
+
declare class StringToken extends Token {
|
|
5630
|
+
}
|
|
5631
|
+
|
|
5632
5632
|
declare class StringType extends AbstractType {
|
|
5633
5633
|
toText(): string;
|
|
5634
5634
|
isGeneric(): boolean;
|
|
@@ -6017,7 +6017,7 @@ declare namespace Tokens {
|
|
|
6017
6017
|
WStaticArrow,
|
|
6018
6018
|
StaticArrowW,
|
|
6019
6019
|
WStaticArrowW,
|
|
6020
|
-
|
|
6020
|
+
StringToken,
|
|
6021
6021
|
StringTemplate_2 as StringTemplate,
|
|
6022
6022
|
StringTemplateBegin,
|
|
6023
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
126
|
+
tok = new tokens_1.StringTemplate(pos, s);
|
|
118
127
|
}
|
|
119
128
|
else if (first === "|" && last === "{" && whiteAfter === true) {
|
|
120
|
-
tok = new
|
|
129
|
+
tok = new tokens_1.StringTemplateBegin(pos, s);
|
|
121
130
|
}
|
|
122
131
|
else if (first === "}" && last === "|" && whiteBefore === true) {
|
|
123
|
-
tok = new
|
|
132
|
+
tok = new tokens_1.StringTemplateEnd(pos, s);
|
|
124
133
|
}
|
|
125
134
|
else if (first === "}" && last === "{" && whiteAfter === true && whiteBefore === true) {
|
|
126
|
-
tok = new
|
|
135
|
+
tok = new tokens_1.StringTemplateMiddle(pos, s);
|
|
127
136
|
}
|
|
128
137
|
else {
|
|
129
|
-
tok = new
|
|
138
|
+
tok = new tokens_1.Identifier(pos, s);
|
|
130
139
|
}
|
|
131
140
|
}
|
|
132
141
|
else if (s.substr(0, 2) === "##") {
|
|
133
|
-
tok = new
|
|
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
|
|
146
|
+
tok = new tokens_1.Punctuation(pos, s);
|
|
138
147
|
}
|
|
139
148
|
else if (s === "[") {
|
|
140
|
-
if (whiteBefore && whiteAfter) {
|
|
141
|
-
tok = new
|
|
149
|
+
if (whiteBefore === true && whiteAfter === true) {
|
|
150
|
+
tok = new tokens_1.WBracketLeftW(pos, s);
|
|
142
151
|
}
|
|
143
|
-
else if (whiteBefore) {
|
|
144
|
-
tok = new
|
|
152
|
+
else if (whiteBefore === true) {
|
|
153
|
+
tok = new tokens_1.WBracketLeft(pos, s);
|
|
145
154
|
}
|
|
146
|
-
else if (whiteAfter) {
|
|
147
|
-
tok = new
|
|
155
|
+
else if (whiteAfter === true) {
|
|
156
|
+
tok = new tokens_1.BracketLeftW(pos, s);
|
|
148
157
|
}
|
|
149
158
|
else {
|
|
150
|
-
tok = new
|
|
159
|
+
tok = new tokens_1.BracketLeft(pos, s);
|
|
151
160
|
}
|
|
152
161
|
}
|
|
153
162
|
else if (s === "(") {
|
|
154
|
-
if (whiteBefore && whiteAfter) {
|
|
155
|
-
tok = new
|
|
163
|
+
if (whiteBefore === true && whiteAfter === true) {
|
|
164
|
+
tok = new tokens_1.WParenLeftW(pos, s);
|
|
156
165
|
}
|
|
157
|
-
else if (whiteBefore) {
|
|
158
|
-
tok = new
|
|
166
|
+
else if (whiteBefore === true) {
|
|
167
|
+
tok = new tokens_1.WParenLeft(pos, s);
|
|
159
168
|
}
|
|
160
|
-
else if (whiteAfter) {
|
|
161
|
-
tok = new
|
|
169
|
+
else if (whiteAfter === true) {
|
|
170
|
+
tok = new tokens_1.ParenLeftW(pos, s);
|
|
162
171
|
}
|
|
163
172
|
else {
|
|
164
|
-
tok = new
|
|
173
|
+
tok = new tokens_1.ParenLeft(pos, s);
|
|
165
174
|
}
|
|
166
175
|
}
|
|
167
176
|
else if (s === "]") {
|
|
168
|
-
if (whiteBefore && whiteAfter) {
|
|
169
|
-
tok = new
|
|
177
|
+
if (whiteBefore === true && whiteAfter === true) {
|
|
178
|
+
tok = new tokens_1.WBracketRightW(pos, s);
|
|
170
179
|
}
|
|
171
|
-
else if (whiteBefore) {
|
|
172
|
-
tok = new
|
|
180
|
+
else if (whiteBefore === true) {
|
|
181
|
+
tok = new tokens_1.WBracketRight(pos, s);
|
|
173
182
|
}
|
|
174
|
-
else if (whiteAfter) {
|
|
175
|
-
tok = new
|
|
183
|
+
else if (whiteAfter === true) {
|
|
184
|
+
tok = new tokens_1.BracketRightW(pos, s);
|
|
176
185
|
}
|
|
177
186
|
else {
|
|
178
|
-
tok = new
|
|
187
|
+
tok = new tokens_1.BracketRight(pos, s);
|
|
179
188
|
}
|
|
180
189
|
}
|
|
181
190
|
else if (s === ")") {
|
|
182
|
-
if (whiteBefore && whiteAfter) {
|
|
183
|
-
tok = new
|
|
191
|
+
if (whiteBefore === true && whiteAfter === true) {
|
|
192
|
+
tok = new tokens_1.WParenRightW(pos, s);
|
|
184
193
|
}
|
|
185
|
-
else if (whiteBefore) {
|
|
186
|
-
tok = new
|
|
194
|
+
else if (whiteBefore === true) {
|
|
195
|
+
tok = new tokens_1.WParenRight(pos, s);
|
|
187
196
|
}
|
|
188
|
-
else if (whiteAfter) {
|
|
189
|
-
tok = new
|
|
197
|
+
else if (whiteAfter === true) {
|
|
198
|
+
tok = new tokens_1.ParenRightW(pos, s);
|
|
190
199
|
}
|
|
191
200
|
else {
|
|
192
|
-
tok = new
|
|
201
|
+
tok = new tokens_1.ParenRight(pos, s);
|
|
193
202
|
}
|
|
194
203
|
}
|
|
195
204
|
else if (s === "-") {
|
|
196
|
-
if (whiteBefore && whiteAfter) {
|
|
197
|
-
tok = new
|
|
205
|
+
if (whiteBefore === true && whiteAfter === true) {
|
|
206
|
+
tok = new tokens_1.WDashW(pos, s);
|
|
198
207
|
}
|
|
199
|
-
else if (whiteBefore) {
|
|
200
|
-
tok = new
|
|
208
|
+
else if (whiteBefore === true) {
|
|
209
|
+
tok = new tokens_1.WDash(pos, s);
|
|
201
210
|
}
|
|
202
|
-
else if (whiteAfter) {
|
|
203
|
-
tok = new
|
|
211
|
+
else if (whiteAfter === true) {
|
|
212
|
+
tok = new tokens_1.DashW(pos, s);
|
|
204
213
|
}
|
|
205
214
|
else {
|
|
206
|
-
tok = new
|
|
215
|
+
tok = new tokens_1.Dash(pos, s);
|
|
207
216
|
}
|
|
208
217
|
}
|
|
209
218
|
else if (s === "+") {
|
|
210
|
-
if (whiteBefore && whiteAfter) {
|
|
211
|
-
tok = new
|
|
219
|
+
if (whiteBefore === true && whiteAfter === true) {
|
|
220
|
+
tok = new tokens_1.WPlusW(pos, s);
|
|
212
221
|
}
|
|
213
|
-
else if (whiteBefore) {
|
|
214
|
-
tok = new
|
|
222
|
+
else if (whiteBefore === true) {
|
|
223
|
+
tok = new tokens_1.WPlus(pos, s);
|
|
215
224
|
}
|
|
216
|
-
else if (whiteAfter) {
|
|
217
|
-
tok = new
|
|
225
|
+
else if (whiteAfter === true) {
|
|
226
|
+
tok = new tokens_1.PlusW(pos, s);
|
|
218
227
|
}
|
|
219
228
|
else {
|
|
220
|
-
tok = new
|
|
229
|
+
tok = new tokens_1.Plus(pos, s);
|
|
221
230
|
}
|
|
222
231
|
}
|
|
223
232
|
else if (s === "@") {
|
|
224
|
-
if (whiteBefore && whiteAfter) {
|
|
225
|
-
tok = new
|
|
233
|
+
if (whiteBefore === true && whiteAfter === true) {
|
|
234
|
+
tok = new tokens_1.WAtW(pos, s);
|
|
226
235
|
}
|
|
227
|
-
else if (whiteBefore) {
|
|
228
|
-
tok = new
|
|
236
|
+
else if (whiteBefore === true) {
|
|
237
|
+
tok = new tokens_1.WAt(pos, s);
|
|
229
238
|
}
|
|
230
|
-
else if (whiteAfter) {
|
|
231
|
-
tok = new
|
|
239
|
+
else if (whiteAfter === true) {
|
|
240
|
+
tok = new tokens_1.AtW(pos, s);
|
|
232
241
|
}
|
|
233
242
|
else {
|
|
234
|
-
tok = new
|
|
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
|
|
249
|
+
if (whiteBefore === true && whiteAfter === true) {
|
|
250
|
+
tok = new tokens_1.WInstanceArrowW(pos, s);
|
|
242
251
|
}
|
|
243
|
-
else if (whiteBefore) {
|
|
244
|
-
tok = new
|
|
252
|
+
else if (whiteBefore === true) {
|
|
253
|
+
tok = new tokens_1.WInstanceArrow(pos, s);
|
|
245
254
|
}
|
|
246
|
-
else if (whiteAfter) {
|
|
247
|
-
tok = new
|
|
255
|
+
else if (whiteAfter === true) {
|
|
256
|
+
tok = new tokens_1.InstanceArrowW(pos, s);
|
|
248
257
|
}
|
|
249
258
|
else {
|
|
250
|
-
tok = new
|
|
259
|
+
tok = new tokens_1.InstanceArrow(pos, s);
|
|
251
260
|
}
|
|
252
261
|
}
|
|
253
262
|
else if (s === "=>") {
|
|
254
|
-
if (whiteBefore && whiteAfter) {
|
|
255
|
-
tok = new
|
|
263
|
+
if (whiteBefore === true && whiteAfter === true) {
|
|
264
|
+
tok = new tokens_1.WStaticArrowW(pos, s);
|
|
256
265
|
}
|
|
257
|
-
else if (whiteBefore) {
|
|
258
|
-
tok = new
|
|
266
|
+
else if (whiteBefore === true) {
|
|
267
|
+
tok = new tokens_1.WStaticArrow(pos, s);
|
|
259
268
|
}
|
|
260
|
-
else if (whiteAfter) {
|
|
261
|
-
tok = new
|
|
269
|
+
else if (whiteAfter === true) {
|
|
270
|
+
tok = new tokens_1.StaticArrowW(pos, s);
|
|
262
271
|
}
|
|
263
272
|
else {
|
|
264
|
-
tok = new
|
|
273
|
+
tok = new tokens_1.StaticArrow(pos, s);
|
|
265
274
|
}
|
|
266
275
|
}
|
|
267
276
|
}
|
|
268
277
|
if (tok === undefined) {
|
|
269
|
-
tok = new
|
|
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
|
-
|
|
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
|
-
&&
|
|
322
|
-
&&
|
|
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
|
-
&&
|
|
345
|
-
&&
|
|
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.
|
|
3
|
+
exports.StringTemplateMiddle = exports.StringTemplateEnd = exports.StringTemplateBegin = exports.StringTemplate = exports.StringToken = void 0;
|
|
4
4
|
const _token_1 = require("./_token");
|
|
5
|
-
class
|
|
5
|
+
class StringToken extends _token_1.Token {
|
|
6
6
|
}
|
|
7
|
-
exports.
|
|
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
|
}
|
|
@@ -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));
|
|
@@ -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
|
|
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:
|
|
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,
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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
|
|
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 =
|
|
48
|
+
this.abstract = (cdef === null || cdef === void 0 ? void 0 : cdef.findDirectTokenByText("ABSTRACT")) !== undefined;
|
|
48
49
|
}
|
|
49
50
|
getFriends() {
|
|
50
51
|
return this.friends;
|
|
@@ -9,9 +9,10 @@ class AbstractFile {
|
|
|
9
9
|
return this.filename;
|
|
10
10
|
}
|
|
11
11
|
baseName() {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
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;
|
package/build/src/lsp/hover.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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
|
package/build/src/position.js
CHANGED
|
@@ -39,7 +39,8 @@ class VirtualPosition extends Position {
|
|
|
39
39
|
if (!(p instanceof VirtualPosition)) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
|
-
|
|
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.
|
|
19
|
+
if (token instanceof Tokens.StringToken) {
|
|
20
20
|
continue;
|
|
21
21
|
}
|
|
22
22
|
this.replaceString(token.getStart(), this.formatNonKeyword(token.getStr()));
|
package/build/src/registry.js
CHANGED
|
@@ -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
|
|
22
|
-
extendedInformation: `
|
|
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
|
|
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) {
|