@abaplint/core 2.119.58 → 2.119.59

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.
@@ -1251,6 +1251,7 @@ declare class ClassDefinition_3 extends Identifier implements IClassDefinition {
1251
1251
  getCreateVisibility(): Visibility;
1252
1252
  private findSuper;
1253
1253
  private checkMethodNameLength;
1254
+ private checkClassConstructorStatic;
1254
1255
  private checkMethodsFromSuperClasses;
1255
1256
  private findFriends;
1256
1257
  private addReference;
@@ -2430,9 +2431,11 @@ declare abstract class Expression implements IStatementRunnable {
2430
2431
 
2431
2432
  declare class ExpressionNode extends AbstractNode<ExpressionNode | TokenNode> {
2432
2433
  private readonly expression;
2434
+ private tokenCount;
2433
2435
  constructor(expression: IStatementRunnable);
2434
2436
  addChild(_n: ExpressionNode | TokenNode): void;
2435
2437
  get(): IStatementRunnable;
2438
+ setChildren(children: (ExpressionNode | TokenNode)[]): ExpressionNode;
2436
2439
  countTokens(): number;
2437
2440
  getFirstToken(): Token;
2438
2441
  concatTokensWithLinebreaks(): string;
@@ -46,6 +46,7 @@ const expand_macros_1 = require("./expand_macros");
46
46
  const tokens_1 = require("../1_lexer/tokens");
47
47
  const _select_reclassify_1 = require("./_select_reclassify");
48
48
  exports.STATEMENT_MAX_TOKENS = 20000;
49
+ const EMPTY_PRAGMAS = Object.freeze([]);
49
50
  class StatementMap {
50
51
  constructor() {
51
52
  this.map = {};
@@ -244,9 +245,19 @@ class StatementParser {
244
245
  return statement;
245
246
  }
246
247
  removePragma(tokens) {
248
+ let hasPragma = false;
249
+ // skip the last token as it is the punctuation
250
+ for (let i = 0; i < tokens.length - 1; i++) {
251
+ if (tokens[i] instanceof Tokens.Pragma) {
252
+ hasPragma = true;
253
+ break;
254
+ }
255
+ }
256
+ if (hasPragma === false) {
257
+ return { tokens: tokens.slice(0, tokens.length - 1), pragmas: EMPTY_PRAGMAS };
258
+ }
247
259
  const result = [];
248
260
  const pragmas = [];
249
- // skip the last token as it is the punctuation
250
261
  for (let i = 0; i < tokens.length - 1; i++) {
251
262
  const t = tokens[i];
252
263
  if (t instanceof Tokens.Pragma) {
@@ -7,6 +7,7 @@ const _abstract_node_1 = require("./_abstract_node");
7
7
  class ExpressionNode extends _abstract_node_1.AbstractNode {
8
8
  constructor(expression) {
9
9
  super();
10
+ this.tokenCount = 0;
10
11
  this.expression = expression;
11
12
  }
12
13
  addChild(_n) {
@@ -15,12 +16,15 @@ class ExpressionNode extends _abstract_node_1.AbstractNode {
15
16
  get() {
16
17
  return this.expression;
17
18
  }
18
- countTokens() {
19
- let ret = 0;
20
- for (const c of this.getChildren()) {
21
- ret = ret + c.countTokens();
19
+ setChildren(children) {
20
+ super.setChildren(children);
21
+ for (const child of this.getChildren()) {
22
+ this.tokenCount = this.tokenCount + child.countTokens();
22
23
  }
23
- return ret;
24
+ return this;
25
+ }
26
+ countTokens() {
27
+ return this.tokenCount;
24
28
  }
25
29
  getFirstToken() {
26
30
  for (const child of this.getChildren()) {
@@ -97,6 +97,7 @@ class ClassDefinition extends _identifier_1.Identifier {
97
97
  // perform checks after everything has been initialized
98
98
  this.checkMethodsFromSuperClasses(input);
99
99
  this.checkMethodNameLength(input);
100
+ this.checkClassConstructorStatic(input);
100
101
  }
101
102
  getFriends() {
102
103
  return this.friends;
@@ -160,6 +161,13 @@ class ClassDefinition extends _identifier_1.Identifier {
160
161
  }
161
162
  }
162
163
  }
164
+ checkClassConstructorStatic(input) {
165
+ for (const m of this.methodDefs.getAll()) {
166
+ if (m.getName().toUpperCase() === "CLASS_CONSTRUCTOR" && m.isStatic() === false) {
167
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), "CLASS_CONSTRUCTOR must be static"));
168
+ }
169
+ }
170
+ }
163
171
  checkMethodsFromSuperClasses(input) {
164
172
  var _a;
165
173
  const scope = input.scope;
@@ -7,7 +7,7 @@ const cds_name_1 = require("./cds_name");
7
7
  class CDSDefineTableFunction extends combi_1.Expression {
8
8
  getRunnable() {
9
9
  const methodName = (0, combi_1.seq)(cds_name_1.CDSName, "=", ">", cds_name_1.CDSName);
10
- return (0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.str)("DEFINE TABLE FUNCTION"), cds_name_1.CDSName, (0, combi_1.optPrio)(_1.CDSWithParameters), (0, combi_1.str)("RETURNS {"), (0, combi_1.plus)((0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.optPrio)("KEY"), cds_name_1.CDSName, ":", _1.CDSType, ";")), (0, combi_1.str)("} IMPLEMENTED BY METHOD"), methodName, (0, combi_1.opt)(";"));
10
+ return (0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.str)("DEFINE TABLE FUNCTION"), cds_name_1.CDSName, (0, combi_1.optPrio)(_1.CDSWithParameters), (0, combi_1.str)("RETURNS {"), (0, combi_1.plus)((0, combi_1.seq)((0, combi_1.star)(_1.CDSAnnotation), (0, combi_1.optPrio)("KEY"), cds_name_1.CDSName, ":", _1.CDSType, (0, combi_1.star)(_1.CDSAnnotation), ";")), (0, combi_1.str)("} IMPLEMENTED BY METHOD"), methodName, (0, combi_1.opt)(";"));
11
11
  }
12
12
  }
13
13
  exports.CDSDefineTableFunction = CDSDefineTableFunction;
@@ -18,7 +18,7 @@ class CDSElement extends combi_1.Expression {
18
18
  const funcWithPath = (0, combi_1.seq)(_1.CDSFunction, (0, combi_1.plusPrio)(pathSegment));
19
19
  const body = (0, combi_1.altPrio)(extensionWildcard, includeElement, _1.CDSArithmetics, _1.CDSAggregate, _1.CDSString, _1.CDSArithParen, funcWithPath, _1.CDSFunction, cds_cast_1.CDSCast, _1.CDSCase, (0, combi_1.seq)("(", _1.CDSCase, ")"), (0, combi_1.seq)(_1.CDSPrefixedName, (0, combi_1.optPrio)(cds_as_1.CDSAs), (0, combi_1.optPrio)((0, combi_1.altPrio)(redirected, colonThing))), _1.CDSInteger);
20
20
  const elementBody = (0, combi_1.altPrio)(typedVirtual, (0, combi_1.seq)((0, combi_1.altPrio)("KEY", "VIRTUAL"), body), body);
21
- return (0, combi_1.seq)((0, combi_1.starPrio)(_1.CDSAnnotation), elementBody, (0, combi_1.optPrio)(cds_as_1.CDSAs));
21
+ return (0, combi_1.seq)((0, combi_1.starPrio)(_1.CDSAnnotation), elementBody, (0, combi_1.optPrio)(cds_as_1.CDSAs), (0, combi_1.starPrio)(_1.CDSAnnotation));
22
22
  }
23
23
  }
24
24
  exports.CDSElement = CDSElement;
@@ -5,7 +5,7 @@ const combi_1 = require("../../abap/2_statements/combi");
5
5
  class CDSName extends combi_1.Expression {
6
6
  getRunnable() {
7
7
  const pre = (0, combi_1.seq)("/", (0, combi_1.regex)(/^[\w_]+$/), "/");
8
- return (0, combi_1.seq)((0, combi_1.optPrio)(":"), (0, combi_1.optPrio)(pre), (0, combi_1.regex)(/^\$?#?[\w_]+$/));
8
+ return (0, combi_1.altPrio)((0, combi_1.regex)(/^"(?:[^"]|"")*"$/), (0, combi_1.seq)((0, combi_1.optPrio)(":"), (0, combi_1.optPrio)(pre), (0, combi_1.regex)(/^\$?#?[\w_]+$/)));
9
9
  }
10
10
  }
11
11
  exports.CDSName = CDSName;
@@ -4,7 +4,7 @@ exports.CDSString = void 0;
4
4
  const combi_1 = require("../../abap/2_statements/combi");
5
5
  class CDSString extends combi_1.Expression {
6
6
  getRunnable() {
7
- const reg = (0, combi_1.regex)(/^(?:'(?:[^'\\]|''|\\'|\\\\|\\(?!'))*'|"(?:[^"\\]|""|\\"|\\\\|\\(?!"))*")$/);
7
+ const reg = (0, combi_1.regex)(/^'(?:[^'\\]|''|\\'|\\\\|\\(?!'))*'$/);
8
8
  const abapTypeName = (0, combi_1.regex)(/^(?:int[1-9]|int8|sstring|sstr|char|numc|dats|datn|tims|timn|utcl|utclong|fltp|decfloat\d+|dec|string|rawstring|rstr|raw|xstring|clnt|lang|unit|cuky|curr|quan|geom_ewkb|d34n|d16n|d34d|d16d|d34s|d16s|d34r|d16r|d|t|p|n|c|x|f)$/i);
9
9
  const abap = (0, combi_1.seq)("abap", ".", abapTypeName, (0, combi_1.optPrio)((0, combi_1.seq)("(", (0, combi_1.regex)(/^\d+$/), ")")), reg);
10
10
  return (0, combi_1.altPrio)(abap, reg);
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.119.58";
78
+ return "2.119.59";
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.119.58",
3
+ "version": "2.119.59",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",