@abaplint/cli 2.119.57 → 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.
Files changed (2) hide show
  1. package/build/cli.js +73 -33
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -11174,6 +11174,7 @@ const expand_macros_1 = __webpack_require__(/*! ./expand_macros */ "../core/buil
11174
11174
  const tokens_1 = __webpack_require__(/*! ../1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
11175
11175
  const _select_reclassify_1 = __webpack_require__(/*! ./_select_reclassify */ "../core/build/src/abap/2_statements/_select_reclassify.js");
11176
11176
  exports.STATEMENT_MAX_TOKENS = 20000;
11177
+ const EMPTY_PRAGMAS = Object.freeze([]);
11177
11178
  class StatementMap {
11178
11179
  constructor() {
11179
11180
  this.map = {};
@@ -11372,9 +11373,19 @@ class StatementParser {
11372
11373
  return statement;
11373
11374
  }
11374
11375
  removePragma(tokens) {
11376
+ let hasPragma = false;
11377
+ // skip the last token as it is the punctuation
11378
+ for (let i = 0; i < tokens.length - 1; i++) {
11379
+ if (tokens[i] instanceof Tokens.Pragma) {
11380
+ hasPragma = true;
11381
+ break;
11382
+ }
11383
+ }
11384
+ if (hasPragma === false) {
11385
+ return { tokens: tokens.slice(0, tokens.length - 1), pragmas: EMPTY_PRAGMAS };
11386
+ }
11375
11387
  const result = [];
11376
11388
  const pragmas = [];
11377
- // skip the last token as it is the punctuation
11378
11389
  for (let i = 0; i < tokens.length - 1; i++) {
11379
11390
  const t = tokens[i];
11380
11391
  if (t instanceof Tokens.Pragma) {
@@ -24748,16 +24759,20 @@ class BuiltIn {
24748
24759
  return def.predicate;
24749
24760
  }
24750
24761
  getTypes() {
24751
- const ret = this.buildSY();
24752
- {
24753
- const id = new tokens_1.Identifier(new position_1.Position(1, 1), "abap_bool");
24754
- ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, new basic_1.CharacterType(1, { qualifiedName: "ABAP_BOOL", ddicName: "ABAP_BOOL" })));
24755
- }
24756
- {
24757
- const id = new tokens_1.Identifier(new position_1.Position(1, 1), "cursor");
24758
- ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, basic_1.IntegerType.get({ qualifiedName: "CURSOR", ddicName: "CURSOR" })));
24762
+ // the identifiers are identical for every object, share them to reduce memory usage
24763
+ if (BuiltIn.typesCache === undefined) {
24764
+ const ret = this.buildSY();
24765
+ {
24766
+ const id = new tokens_1.Identifier(new position_1.Position(1, 1), "abap_bool");
24767
+ ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, new basic_1.CharacterType(1, { qualifiedName: "ABAP_BOOL", ddicName: "ABAP_BOOL" })));
24768
+ }
24769
+ {
24770
+ const id = new tokens_1.Identifier(new position_1.Position(1, 1), "cursor");
24771
+ ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, basic_1.IntegerType.get({ qualifiedName: "CURSOR", ddicName: "CURSOR" })));
24772
+ }
24773
+ BuiltIn.typesCache = ret;
24759
24774
  }
24760
- return ret;
24775
+ return BuiltIn.typesCache;
24761
24776
  }
24762
24777
  get(extras) {
24763
24778
  const ret = [];
@@ -24790,10 +24805,17 @@ class BuiltIn {
24790
24805
  BuiltIn.getCache.push(this.buildConstant("space", new basic_1.CharacterType(1, { derivedFromConstant: true }), "' '"));
24791
24806
  }
24792
24807
  ret.push(...BuiltIn.getCache);
24793
- for (const e of extras) {
24794
- const id = new tokens_1.Identifier(new position_1.Position(this.row++, 1), e);
24795
- ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, basic_1.VoidType.get(e), ["read_only" /* IdentifierMeta.ReadOnly */, "built-in" /* IdentifierMeta.BuiltIn */], "'?'"));
24808
+ // the extras are identical for every object, share them to reduce memory usage
24809
+ const key = extras.join("|");
24810
+ if (key !== BuiltIn.extrasCacheKey) {
24811
+ BuiltIn.extrasCacheKey = key;
24812
+ BuiltIn.extrasCache = [];
24813
+ for (const e of extras) {
24814
+ const id = new tokens_1.Identifier(new position_1.Position(this.row++, 1), e);
24815
+ BuiltIn.extrasCache.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, basic_1.VoidType.get(e), ["read_only" /* IdentifierMeta.ReadOnly */, "built-in" /* IdentifierMeta.BuiltIn */], "'?'"));
24816
+ }
24796
24817
  }
24818
+ ret.push(...BuiltIn.extrasCache);
24797
24819
  return ret;
24798
24820
  }
24799
24821
  /////////////////////////////
@@ -25002,6 +25024,9 @@ exports.BuiltIn = BuiltIn;
25002
25024
  BuiltIn.filename = "_builtin.prog.abap";
25003
25025
  BuiltIn.counter = 1;
25004
25026
  BuiltIn.getCache = [];
25027
+ BuiltIn.typesCache = undefined;
25028
+ BuiltIn.extrasCacheKey = undefined;
25029
+ BuiltIn.extrasCache = [];
25005
25030
  // todo: "pcre" vs "regex", only one of these parameters are allowed
25006
25031
  // todo: "pcre", only possible from 755
25007
25032
  BuiltIn.methods = {
@@ -47867,15 +47892,21 @@ exports.CrossIncludeMacros = CrossIncludeMacros;
47867
47892
 
47868
47893
  Object.defineProperty(exports, "__esModule", ({ value: true }));
47869
47894
  exports.AbstractNode = void 0;
47895
+ // shared constant, so nodes without children don't waste memory on empty arrays
47896
+ const EMPTY = Object.freeze([]);
47870
47897
  class AbstractNode {
47871
47898
  constructor() {
47872
- this.children = [];
47899
+ this.children = EMPTY;
47873
47900
  }
47874
47901
  addChild(n) {
47902
+ if (this.children === EMPTY) {
47903
+ this.children = [];
47904
+ }
47875
47905
  this.children.push(n);
47876
47906
  }
47877
47907
  setChildren(children) {
47878
- this.children = children;
47908
+ // copy, input arrays are built via push() and carry over-allocated backing stores
47909
+ this.children = children.slice();
47879
47910
  }
47880
47911
  getChildren() {
47881
47912
  return this.children;
@@ -47908,6 +47939,7 @@ const _abstract_node_1 = __webpack_require__(/*! ./_abstract_node */ "../core/bu
47908
47939
  class ExpressionNode extends _abstract_node_1.AbstractNode {
47909
47940
  constructor(expression) {
47910
47941
  super();
47942
+ this.tokenCount = 0;
47911
47943
  this.expression = expression;
47912
47944
  }
47913
47945
  addChild(_n) {
@@ -47916,12 +47948,15 @@ class ExpressionNode extends _abstract_node_1.AbstractNode {
47916
47948
  get() {
47917
47949
  return this.expression;
47918
47950
  }
47919
- countTokens() {
47920
- let ret = 0;
47921
- for (const c of this.getChildren()) {
47922
- ret = ret + c.countTokens();
47951
+ setChildren(children) {
47952
+ super.setChildren(children);
47953
+ for (const child of this.getChildren()) {
47954
+ this.tokenCount = this.tokenCount + child.countTokens();
47923
47955
  }
47924
- return ret;
47956
+ return this;
47957
+ }
47958
+ countTokens() {
47959
+ return this.tokenCount;
47925
47960
  }
47926
47961
  getFirstToken() {
47927
47962
  for (const child of this.getChildren()) {
@@ -48231,17 +48266,13 @@ const string_template_middle_1 = __webpack_require__(/*! ../1_lexer/tokens/strin
48231
48266
  const string_template_end_1 = __webpack_require__(/*! ../1_lexer/tokens/string_template_end */ "../core/build/src/abap/1_lexer/tokens/string_template_end.js");
48232
48267
  const string_template_begin_1 = __webpack_require__(/*! ../1_lexer/tokens/string_template_begin */ "../core/build/src/abap/1_lexer/tokens/string_template_begin.js");
48233
48268
  const string_template_1 = __webpack_require__(/*! ../1_lexer/tokens/string_template */ "../core/build/src/abap/1_lexer/tokens/string_template.js");
48269
+ const EMPTY_PRAGMAS = Object.freeze([]);
48234
48270
  class StatementNode extends _abstract_node_1.AbstractNode {
48235
48271
  constructor(statement, colon, pragmas) {
48236
48272
  super();
48237
48273
  this.statement = statement;
48238
48274
  this.colon = colon;
48239
- if (pragmas) {
48240
- this.pragmas = pragmas;
48241
- }
48242
- else {
48243
- this.pragmas = [];
48244
- }
48275
+ this.pragmas = pragmas !== null && pragmas !== void 0 ? pragmas : EMPTY_PRAGMAS;
48245
48276
  }
48246
48277
  get() {
48247
48278
  return this.statement;
@@ -48256,7 +48287,7 @@ class StatementNode extends _abstract_node_1.AbstractNode {
48256
48287
  if (children.length === 0) {
48257
48288
  throw new Error("statement: zero children");
48258
48289
  }
48259
- this.children = children;
48290
+ super.setChildren(children);
48260
48291
  return this;
48261
48292
  }
48262
48293
  getStart() {
@@ -48837,6 +48868,7 @@ exports.StructureNode = StructureNode;
48837
48868
 
48838
48869
  Object.defineProperty(exports, "__esModule", ({ value: true }));
48839
48870
  exports.TokenNode = void 0;
48871
+ const EMPTY_CHILDREN = Object.freeze([]);
48840
48872
  class TokenNode {
48841
48873
  constructor(token) {
48842
48874
  this.token = token;
@@ -48848,7 +48880,7 @@ class TokenNode {
48848
48880
  throw new Error("TokenNode, Method not implemented.");
48849
48881
  }
48850
48882
  getChildren() {
48851
- return [];
48883
+ return EMPTY_CHILDREN;
48852
48884
  }
48853
48885
  concatTokens() {
48854
48886
  return this.token.getStr();
@@ -50927,6 +50959,7 @@ class ClassDefinition extends _identifier_1.Identifier {
50927
50959
  // perform checks after everything has been initialized
50928
50960
  this.checkMethodsFromSuperClasses(input);
50929
50961
  this.checkMethodNameLength(input);
50962
+ this.checkClassConstructorStatic(input);
50930
50963
  }
50931
50964
  getFriends() {
50932
50965
  return this.friends;
@@ -50990,6 +51023,13 @@ class ClassDefinition extends _identifier_1.Identifier {
50990
51023
  }
50991
51024
  }
50992
51025
  }
51026
+ checkClassConstructorStatic(input) {
51027
+ for (const m of this.methodDefs.getAll()) {
51028
+ if (m.getName().toUpperCase() === "CLASS_CONSTRUCTOR" && m.isStatic() === false) {
51029
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, m.getToken(), "CLASS_CONSTRUCTOR must be static"));
51030
+ }
51031
+ }
51032
+ }
50993
51033
  checkMethodsFromSuperClasses(input) {
50994
51034
  var _a;
50995
51035
  const scope = input.scope;
@@ -53617,7 +53657,7 @@ const cds_name_1 = __webpack_require__(/*! ./cds_name */ "../core/build/src/cds/
53617
53657
  class CDSDefineTableFunction extends combi_1.Expression {
53618
53658
  getRunnable() {
53619
53659
  const methodName = (0, combi_1.seq)(cds_name_1.CDSName, "=", ">", cds_name_1.CDSName);
53620
- 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)(";"));
53660
+ 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)(";"));
53621
53661
  }
53622
53662
  }
53623
53663
  exports.CDSDefineTableFunction = CDSDefineTableFunction;
@@ -53682,7 +53722,7 @@ class CDSElement extends combi_1.Expression {
53682
53722
  const funcWithPath = (0, combi_1.seq)(_1.CDSFunction, (0, combi_1.plusPrio)(pathSegment));
53683
53723
  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);
53684
53724
  const elementBody = (0, combi_1.altPrio)(typedVirtual, (0, combi_1.seq)((0, combi_1.altPrio)("KEY", "VIRTUAL"), body), body);
53685
- return (0, combi_1.seq)((0, combi_1.starPrio)(_1.CDSAnnotation), elementBody, (0, combi_1.optPrio)(cds_as_1.CDSAs));
53725
+ 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));
53686
53726
  }
53687
53727
  }
53688
53728
  exports.CDSElement = CDSElement;
@@ -53951,7 +53991,7 @@ const combi_1 = __webpack_require__(/*! ../../abap/2_statements/combi */ "../cor
53951
53991
  class CDSName extends combi_1.Expression {
53952
53992
  getRunnable() {
53953
53993
  const pre = (0, combi_1.seq)("/", (0, combi_1.regex)(/^[\w_]+$/), "/");
53954
- return (0, combi_1.seq)((0, combi_1.optPrio)(":"), (0, combi_1.optPrio)(pre), (0, combi_1.regex)(/^\$?#?[\w_]+$/));
53994
+ 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_]+$/)));
53955
53995
  }
53956
53996
  }
53957
53997
  exports.CDSName = CDSName;
@@ -54166,7 +54206,7 @@ exports.CDSString = void 0;
54166
54206
  const combi_1 = __webpack_require__(/*! ../../abap/2_statements/combi */ "../core/build/src/abap/2_statements/combi.js");
54167
54207
  class CDSString extends combi_1.Expression {
54168
54208
  getRunnable() {
54169
- const reg = (0, combi_1.regex)(/^(?:'(?:[^'\\]|''|\\'|\\\\|\\(?!'))*'|"(?:[^"\\]|""|\\"|\\\\|\\(?!"))*")$/);
54209
+ const reg = (0, combi_1.regex)(/^'(?:[^'\\]|''|\\'|\\\\|\\(?!'))*'$/);
54170
54210
  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);
54171
54211
  const abap = (0, combi_1.seq)("abap", ".", abapTypeName, (0, combi_1.optPrio)((0, combi_1.seq)("(", (0, combi_1.regex)(/^\d+$/), ")")), reg);
54172
54212
  return (0, combi_1.altPrio)(abap, reg);
@@ -68667,7 +68707,7 @@ class Registry {
68667
68707
  }
68668
68708
  static abaplintVersion() {
68669
68709
  // magic, see build script "version.js"
68670
- return "2.119.57";
68710
+ return "2.119.59";
68671
68711
  }
68672
68712
  getDDICReferences() {
68673
68713
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.119.57",
3
+ "version": "2.119.59",
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.57",
42
+ "@abaplint/core": "^2.119.59",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",