@abaplint/core 2.120.56 → 2.120.57

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.
@@ -39,7 +39,8 @@ const Expressions = __importStar(require("."));
39
39
  const tokens_1 = require("../../1_lexer/tokens");
40
40
  class MethodDefReturning extends combi_1.Expression {
41
41
  getRunnable() {
42
- const value = (0, combi_1.seq)("VALUE", (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
42
+ // see MethodParam: the lexer gives "!VALUE" as one Identifier
43
+ const value = (0, combi_1.seq)((0, combi_1.altPrio)("VALUE", "!VALUE"), (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
43
44
  return (0, combi_1.seq)("RETURNING", value, Expressions.TypeParam);
44
45
  }
45
46
  }
@@ -39,8 +39,11 @@ const Expressions = __importStar(require("."));
39
39
  const tokens_1 = require("../../1_lexer/tokens");
40
40
  class MethodParam extends combi_1.Expression {
41
41
  getRunnable() {
42
- const ref = (0, combi_1.seq)("REFERENCE", (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
43
- const value = (0, combi_1.seq)("VALUE", (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
42
+ // The escape is part of the token: the lexer gives "!VALUE" as a single
43
+ // Identifier, so a literal "VALUE" cannot match it and the whole METHODS
44
+ // statement falls back to Unknown.
45
+ const ref = (0, combi_1.seq)((0, combi_1.altPrio)("REFERENCE", "!REFERENCE"), (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
46
+ const value = (0, combi_1.seq)((0, combi_1.altPrio)("VALUE", "!VALUE"), (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.MethodParamName, (0, combi_1.tok)(tokens_1.ParenRightW));
44
47
  const fieldsOrValue = (0, combi_1.seq)((0, combi_1.altPrio)(value, ref, Expressions.MethodParamName), Expressions.TypeParam);
45
48
  return fieldsOrValue;
46
49
  }
@@ -305,6 +305,10 @@ class StatementParser {
305
305
  let add = [];
306
306
  let pre = [];
307
307
  let colon = undefined;
308
+ // inside EXEC SQL and an AMDP body a colon reads a host variable, ":lv_a",
309
+ // and is not the chaining marker; recognized here because nativeSQL() runs
310
+ // afterwards and can only re-wrap what this has already cut
311
+ let native = false;
308
312
  for (const token of wa.tokens) {
309
313
  if (token instanceof Tokens.Comment) {
310
314
  wa.statements.push(new nodes_1.StatementNode(new _statement_1.Comment()).setChildren(this.tokensToNodes([token])));
@@ -314,6 +318,7 @@ class StatementParser {
314
318
  const str = token.getStr();
315
319
  if (str.length === 1) {
316
320
  if (str === ".") {
321
+ native = this.nativeAfter(native, add, colon);
317
322
  wa.addUnknown(pre, add, colon);
318
323
  add = [];
319
324
  pre = [];
@@ -323,13 +328,13 @@ class StatementParser {
323
328
  wa.addUnknown(pre, add, colon);
324
329
  add = [];
325
330
  }
326
- else if (str === ":" && colon === undefined) {
331
+ else if (str === ":" && colon === undefined && native === false) {
327
332
  colon = token;
328
333
  add.pop(); // do not add colon token to statement
329
334
  pre.push(...add);
330
335
  add = [];
331
336
  }
332
- else if (str === ":") {
337
+ else if (str === ":" && native === false) {
333
338
  add.pop(); // do not add colon token to statement
334
339
  }
335
340
  }
@@ -338,6 +343,36 @@ class StatementParser {
338
343
  wa.addUnknown(pre, add, colon);
339
344
  }
340
345
  }
346
+ /** whether the statement that just ended opens or closes a region where a
347
+ * colon belongs to the statement rather than chaining it */
348
+ nativeAfter(native, tokens, colon) {
349
+ // a pragma sits between the closing keyword and the period, so it is left
350
+ // out before the last word is read: "ENDEXEC ##NEEDED." closes the region
351
+ const words = tokens.filter(t => !(t instanceof Tokens.Pragma)).map(t => t.getStr().toUpperCase());
352
+ // a native body usually arrives as one blob terminated by its own closing
353
+ // keyword, so the terminator is the word before the period
354
+ if (words[words.length - 2] === "ENDEXEC" || words[words.length - 2] === "ENDMETHOD") {
355
+ return false;
356
+ }
357
+ if (colon !== undefined) {
358
+ // a fragment of a chain cannot OPEN a region: it is only part of a
359
+ // statement, and taking "DATA: lv_a TYPE i, exec sql." for one would
360
+ // turn chaining off for the rest of the file
361
+ return native;
362
+ }
363
+ if (words[0] === "EXEC" && words[1] === "SQL") {
364
+ return true;
365
+ }
366
+ // "BY DATABASE" as well as LANGUAGE, and not LANGUAGE alone: a method
367
+ // may be NAMED language
368
+ if (words[0] === "METHOD"
369
+ && words.includes("BY")
370
+ && words.includes("DATABASE")
371
+ && words.includes("LANGUAGE")) {
372
+ return true;
373
+ }
374
+ return native;
375
+ }
341
376
  }
342
377
  exports.StatementParser = StatementParser;
343
378
  //# sourceMappingURL=statement_parser.js.map
@@ -333,7 +333,9 @@ class MethodParameters {
333
333
  }
334
334
  isPassByValue(param) {
335
335
  var _a;
336
- return param.getFirstToken().getStr().toUpperCase() === "VALUE"
336
+ // "!" is the identifier escape, generated code has eg. "IMPORTING !VALUE(iv_foo)"
337
+ const first = param.getFirstToken().getStr().toUpperCase();
338
+ return (first === "VALUE" || first === "!VALUE")
337
339
  && ((_a = param.getChildren()[1]) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr()) === "(";
338
340
  }
339
341
  }
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.56";
78
+ return "2.120.57";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.56",
3
+ "version": "2.120.57",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",