@abaplint/cli 2.119.60 → 2.119.62

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 +154 -94
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -2396,24 +2396,14 @@ class Expression {
2396
2396
  for (const input of r) {
2397
2397
  const temp = this.runnable.run([input]);
2398
2398
  for (const t of temp) {
2399
- let consumed = input.remainingLength() - t.remainingLength();
2399
+ const consumed = input.remainingLength() - t.remainingLength();
2400
2400
  if (consumed > 0) {
2401
- const originalLength = t.getNodes().length;
2402
- const children = [];
2403
- while (consumed > 0) {
2404
- const sub = t.popNode();
2405
- if (sub) {
2406
- children.push(sub);
2407
- consumed = consumed - sub.countTokens();
2408
- }
2409
- }
2410
2401
  const re = new nodes_1.ExpressionNode(this);
2411
- re.setChildren(children.reverse());
2412
- const n = t.getNodes().slice(0, originalLength - consumed);
2413
- n.push(re);
2414
- t.setNodes(n);
2402
+ results.push(t.wrapConsumed(consumed, re));
2403
+ }
2404
+ else {
2405
+ results.push(t);
2415
2406
  }
2416
- results.push(t);
2417
2407
  }
2418
2408
  }
2419
2409
  // console.dir(results);
@@ -11140,11 +11130,17 @@ class Result {
11140
11130
  // nodes: matched tokens
11141
11131
  this.tokens = tokens;
11142
11132
  this.tokenIndex = tokenIndex;
11143
- this.nodes = nodes;
11144
- if (this.nodes === undefined) {
11145
- this.nodes = [];
11133
+ this.nodeCount = 0;
11134
+ if (nodes !== undefined) {
11135
+ this.setNodes(nodes);
11146
11136
  }
11147
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
+ }
11148
11144
  peek() {
11149
11145
  return this.tokens[this.tokenIndex];
11150
11146
  }
@@ -11152,18 +11148,54 @@ class Result {
11152
11148
  return this.tokens[this.tokenIndex + offset];
11153
11149
  }
11154
11150
  shift(node) {
11155
- const cp = this.nodes.slice();
11156
- cp.push(node);
11157
- return new Result(this.tokens, this.tokenIndex + 1, cp);
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;
11158
11170
  }
11159
11171
  popNode() {
11160
- return this.nodes.pop();
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;
11161
11179
  }
11162
11180
  getNodes() {
11163
- return this.nodes;
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;
11164
11191
  }
11165
11192
  setNodes(n) {
11166
- this.nodes = n;
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
+ }
11167
11199
  }
11168
11200
  getTokens() {
11169
11201
  return this.tokens;
@@ -11428,7 +11460,9 @@ class StatementParser {
11428
11460
  statement = input;
11429
11461
  }
11430
11462
  else if (length === 1 && lastToken instanceof tokens_1.Pragma) {
11431
- statement = new nodes_1.StatementNode(new _statement_1.Empty(), undefined, [lastToken]);
11463
+ // special case, everything crashes if StatementNodes doesnt have children
11464
+ statement = new nodes_1.StatementNode(new _statement_1.Empty(), undefined, [lastToken])
11465
+ .setChildren(this.tokensToNodes([lastToken]));
11432
11466
  }
11433
11467
  }
11434
11468
  return statement;
@@ -26219,7 +26253,7 @@ class CurrentScope {
26219
26253
  }
26220
26254
  findTypePoolConstant(name) {
26221
26255
  var _a;
26222
- if (name === undefined || name.includes("_") === undefined) {
26256
+ if (name === undefined || name.includes("_") === false) {
26223
26257
  return undefined;
26224
26258
  }
26225
26259
  const typePoolName = name.split("_")[0];
@@ -26241,7 +26275,7 @@ class CurrentScope {
26241
26275
  }
26242
26276
  findTypePoolType(name) {
26243
26277
  var _a;
26244
- if (name.includes("_") === undefined) {
26278
+ if (name.includes("_") === false) {
26245
26279
  return undefined;
26246
26280
  }
26247
26281
  const typePoolName = name.split("_")[0];
@@ -26555,11 +26589,9 @@ class ObjectOriented {
26555
26589
  findMethodInInterface(interfaceName, methodName) {
26556
26590
  const idef = this.scope.findInterfaceDefinition(interfaceName);
26557
26591
  if (idef) {
26558
- const methods = idef.getMethodDefinitions().getAll();
26559
- for (const method of methods) {
26560
- if (method.getName().toUpperCase() === methodName.toUpperCase()) {
26561
- return { method, def: idef };
26562
- }
26592
+ const method = idef.getMethodDefinitions().getByName(methodName);
26593
+ if (method) {
26594
+ return { method, def: idef };
26563
26595
  }
26564
26596
  return this.findMethodViaAlias(methodName, idef);
26565
26597
  }
@@ -26781,17 +26813,14 @@ class ObjectOriented {
26781
26813
  if (defs === undefined) {
26782
26814
  return undefined;
26783
26815
  }
26784
- for (const method of defs.getAll()) {
26785
- if (method.getName().toUpperCase() === methodName.toUpperCase()) {
26786
- if (method.isRedefinition()) {
26787
- return this.findMethodInSuper(def, methodName);
26788
- }
26789
- else {
26790
- return method;
26791
- }
26792
- }
26816
+ const method = defs.getByName(methodName);
26817
+ if (method === undefined) {
26818
+ return undefined;
26793
26819
  }
26794
- return undefined;
26820
+ if (method.isRedefinition()) {
26821
+ return this.findMethodInSuper(def, methodName);
26822
+ }
26823
+ return method;
26795
26824
  }
26796
26825
  findMethodInSuper(child, methodName) {
26797
26826
  let sup = child.getSuperClass();
@@ -38955,18 +38984,25 @@ class DeleteInternal {
38955
38984
  let targetType = undefined;
38956
38985
  const target = node.findDirectExpression(Expressions.Target);
38957
38986
  if (target) {
38987
+ const targetName = target.concatTokens();
38958
38988
  let tabl = undefined;
38959
- const localVariable = input.scope.findVariable(target.concatTokens());
38989
+ const localVariable = input.scope.findVariable(targetName);
38960
38990
  if (localVariable === undefined && node.getChildren().length === 5 && node.getChildren()[2].concatTokens().toUpperCase() === "FROM") {
38961
38991
  // it might be a database table
38962
- const found = (_a = input.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.lookupTableOrView(target.concatTokens());
38992
+ const found = (_a = input.scope.getDDIC()) === null || _a === void 0 ? void 0 : _a.lookupTableOrView(targetName);
38963
38993
  if ((found === null || found === void 0 ? void 0 : found.object) !== undefined) {
38964
38994
  tabl = found;
38965
38995
  input.scope.getDDICReferences().addUsing(input.scope.getParentObj(), { object: tabl.object });
38966
38996
  }
38967
38997
  }
38968
38998
  if (tabl === undefined) {
38969
- targetType = target_1.Target.runSyntax(target, input);
38999
+ const ambigiousVoids = input.scope.getRegistry().getConfig().getSyntaxSetttings().ambigiousVoids || [];
39000
+ if (ambigiousVoids.some(name => name.toUpperCase() === targetName.toUpperCase())) {
39001
+ targetType = basic_1.VoidType.get(targetName);
39002
+ }
39003
+ else {
39004
+ targetType = target_1.Target.runSyntax(target, input);
39005
+ }
38970
39006
  if (node.findDirectTokenByText("TABLE") === undefined
38971
39007
  && node.findDirectTokenByText("ADJACENT") === undefined
38972
39008
  && (node.findDirectTokenByText("FROM") || node.findDirectTokenByText("INDEX"))
@@ -50655,6 +50691,8 @@ class Attributes {
50655
50691
  this.tlist = [];
50656
50692
  this.filename = input.filename;
50657
50693
  this.parse(node, input);
50694
+ this.all = this.static.concat(this.instance);
50695
+ this.byName = this.buildByName();
50658
50696
  this.types = new type_definitions_1.TypeDefinitions(this.tlist);
50659
50697
  }
50660
50698
  getTypes() {
@@ -50667,10 +50705,7 @@ class Attributes {
50667
50705
  return this.aliases;
50668
50706
  }
50669
50707
  getAll() {
50670
- let res = [];
50671
- res = res.concat(this.static);
50672
- res = res.concat(this.instance);
50673
- return res;
50708
+ return this.all;
50674
50709
  }
50675
50710
  getStaticsByVisibility(visibility) {
50676
50711
  const attributes = [];
@@ -50705,27 +50740,29 @@ class Attributes {
50705
50740
  }
50706
50741
  return attributes;
50707
50742
  }
50708
- // todo, optimize
50709
50743
  findByName(name) {
50710
- const upper = name.toUpperCase();
50711
- for (const a of this.getStatic()) {
50712
- if (a.getName().toUpperCase() === upper) {
50713
- return a;
50714
- }
50744
+ return this.byName[name.toUpperCase()];
50745
+ }
50746
+ /////////////////////////////
50747
+ buildByName() {
50748
+ const ret = {};
50749
+ for (const a of this.static) {
50750
+ ret[a.getName().toUpperCase()] = a;
50715
50751
  }
50716
- for (const a of this.getInstance()) {
50717
- if (a.getName().toUpperCase() === upper) {
50718
- return a;
50752
+ for (const a of this.instance) {
50753
+ const name = a.getName().toUpperCase();
50754
+ if (ret[name] === undefined) {
50755
+ ret[name] = a;
50719
50756
  }
50720
50757
  }
50721
- for (const a of this.getConstants()) {
50722
- if (a.getName().toUpperCase() === upper) {
50723
- return a;
50758
+ for (const a of this.constants) {
50759
+ const name = a.getName().toUpperCase();
50760
+ if (ret[name] === undefined) {
50761
+ ret[name] = a;
50724
50762
  }
50725
50763
  }
50726
- return undefined;
50764
+ return ret;
50727
50765
  }
50728
- /////////////////////////////
50729
50766
  parse(node, input) {
50730
50767
  var _a, _b;
50731
50768
  const cdef = node.findDirectStructure(Structures.ClassDefinition);
@@ -54502,10 +54539,19 @@ class Config {
54502
54539
  for (const rule of sorted) {
54503
54540
  rules[rule.getMetadata().key] = rule.getConfig();
54504
54541
  }
54505
- const version = ver !== null && ver !== void 0 ? ver : {
54506
- release: version_1.Release.Newest.name,
54507
- language: langVer !== null && langVer !== void 0 ? langVer : version_1.LanguageVersion.Normal,
54508
- };
54542
+ const version = langVer !== undefined
54543
+ ? {
54544
+ release: ver === undefined || ver === version_1.Version.Cloud
54545
+ ? version_1.Release.Newest.name
54546
+ : typeof ver === "string"
54547
+ ? (0, version_1.versionToABAPRelease)(ver).name
54548
+ : ver.release,
54549
+ language: langVer,
54550
+ }
54551
+ : ver !== null && ver !== void 0 ? ver : {
54552
+ release: version_1.Release.Newest.name,
54553
+ language: version_1.LanguageVersion.Normal,
54554
+ };
54509
54555
  // defaults: dont skip anything, report everything. The user can decide to skip stuff
54510
54556
  // its difficult to debug errors not being reported
54511
54557
  const config = {
@@ -54530,9 +54576,9 @@ class Config {
54530
54576
  }],
54531
54577
  syntax: {
54532
54578
  version,
54533
- languageVersion: langVer,
54534
54579
  errorNamespace: "^(Z|Y|LCL\_|TY\_|LIF\_)",
54535
54580
  globalConstants: [],
54581
+ ambigiousVoids: [],
54536
54582
  globalMacros: [],
54537
54583
  },
54538
54584
  rules: rules,
@@ -54583,6 +54629,12 @@ class Config {
54583
54629
  // remove duplicates,
54584
54630
  this.config.syntax.globalConstants = [...new Set(this.config.syntax.globalConstants)];
54585
54631
  }
54632
+ if (this.config.syntax.ambigiousVoids === undefined) {
54633
+ this.config.syntax.ambigiousVoids = [];
54634
+ }
54635
+ else {
54636
+ this.config.syntax.ambigiousVoids = [...new Set(this.config.syntax.ambigiousVoids)];
54637
+ }
54586
54638
  if (this.config.global.skipIncludesWithoutMain === undefined) {
54587
54639
  this.config.global.skipIncludesWithoutMain = false;
54588
54640
  }
@@ -54632,9 +54684,6 @@ class Config {
54632
54684
  return v;
54633
54685
  }
54634
54686
  getLanguageVersion() {
54635
- if (this.config.syntax.languageVersion !== undefined) {
54636
- return this.config.syntax.languageVersion;
54637
- }
54638
54687
  const v = this.config.syntax.version;
54639
54688
  if (v !== undefined && typeof v !== "string") {
54640
54689
  return v.language;
@@ -54659,7 +54708,10 @@ class Config {
54659
54708
  return;
54660
54709
  }
54661
54710
  if (version === version_1.Version.Cloud) {
54662
- this.config.syntax.languageVersion = version_1.LanguageVersion.Cloud;
54711
+ this.config.syntax.version = {
54712
+ release: version_1.Release.Newest.name,
54713
+ language: version_1.LanguageVersion.Cloud,
54714
+ };
54663
54715
  }
54664
54716
  // OpenABAP keeps its own version identity; open-abap-ness is derived from the
54665
54717
  // release in getOpenABAP() rather than a separate stored flag.
@@ -68768,7 +68820,7 @@ class Registry {
68768
68820
  }
68769
68821
  static abaplintVersion() {
68770
68822
  // magic, see build script "version.js"
68771
- return "2.119.60";
68823
+ return "2.119.62";
68772
68824
  }
68773
68825
  getDDICReferences() {
68774
68826
  return this.ddicReferences;
@@ -75519,6 +75571,7 @@ Make sure to test the downported code, it might not always be completely correct
75519
75571
  const lowConfig = this.lowReg.getConfig().get();
75520
75572
  highConfig.syntax.errorNamespace = lowConfig.syntax.errorNamespace;
75521
75573
  highConfig.syntax.globalConstants = lowConfig.syntax.globalConstants;
75574
+ highConfig.syntax.ambigiousVoids = lowConfig.syntax.ambigiousVoids;
75522
75575
  highConfig.syntax.globalMacros = lowConfig.syntax.globalMacros;
75523
75576
  this.highReg = new registry_1.Registry();
75524
75577
  for (const o of this.lowReg.getObjects()) {
@@ -85797,7 +85850,6 @@ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/ex
85797
85850
  const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
85798
85851
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
85799
85852
  const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
85800
- const tokens_1 = __webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
85801
85853
  const expressions_1 = __webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js");
85802
85854
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
85803
85855
  class NamesNoDashConf extends _basic_rule_config_1.BasicRuleConfig {
@@ -85837,32 +85889,26 @@ class NamesNoDash extends _abap_rule_1.ABAPRule {
85837
85889
  if (obj.getType() !== "CLAS" && obj.getType() !== "INTF") {
85838
85890
  for (const form of struc.findAllStatements(Statements.Form)) {
85839
85891
  const expr = form.findFirstExpression(expressions_1.FormName);
85840
- for (const token of expr.getTokens()) {
85841
- if (token instanceof tokens_1.Dash || token instanceof tokens_1.DashW) {
85842
- const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85843
- issues.push(issue);
85844
- break;
85845
- }
85892
+ const token = expr === null || expr === void 0 ? void 0 : expr.findDirectTokenByText("-");
85893
+ if (token) {
85894
+ const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85895
+ issues.push(issue);
85846
85896
  }
85847
85897
  }
85848
85898
  for (const form of struc.findAllStatements(Statements.Parameter)) {
85849
85899
  const expr = form.findFirstExpression(Expressions.FieldSub);
85850
- for (const token of expr.getTokens()) {
85851
- if (token instanceof tokens_1.Dash || token instanceof tokens_1.DashW) {
85852
- const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85853
- issues.push(issue);
85854
- break;
85855
- }
85900
+ const token = expr === null || expr === void 0 ? void 0 : expr.findDirectTokenByText("-");
85901
+ if (token) {
85902
+ const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85903
+ issues.push(issue);
85856
85904
  }
85857
85905
  }
85858
85906
  for (const form of struc.findAllStatements(Statements.SelectOption)) {
85859
85907
  const expr = form.findFirstExpression(Expressions.FieldSub);
85860
- for (const token of expr.getTokens()) {
85861
- if (token instanceof tokens_1.Dash || token instanceof tokens_1.DashW) {
85862
- const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85863
- issues.push(issue);
85864
- break;
85865
- }
85908
+ const token = expr === null || expr === void 0 ? void 0 : expr.findDirectTokenByText("-");
85909
+ if (token) {
85910
+ const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85911
+ issues.push(issue);
85866
85912
  }
85867
85913
  }
85868
85914
  }
@@ -94870,6 +94916,7 @@ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "..
94870
94916
  const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
94871
94917
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
94872
94918
  const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
94919
+ const tokens_1 = __webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
94873
94920
  class UnnecessaryPragmaConf extends _basic_rule_config_1.BasicRuleConfig {
94874
94921
  constructor() {
94875
94922
  super(...arguments);
@@ -94938,6 +94985,17 @@ DATA: BEGIN OF blah ##NEEDED,
94938
94985
  for (let i = 0; i < statements.length; i++) {
94939
94986
  const statement = statements[i];
94940
94987
  const nextStatement = statements[i + 1];
94988
+ if (statement.get() instanceof _statement_1.Empty
94989
+ && statement.getChildren().length === 1) {
94990
+ const tokens = statement.getTokens();
94991
+ if (tokens.length === 1
94992
+ && tokens[0] instanceof tokens_1.Pragma) {
94993
+ const message = "Pragma without a statement can be removed";
94994
+ const fix = edit_helper_1.EditHelper.deleteToken(file, tokens[0]);
94995
+ issues.push(issue_1.Issue.atToken(file, tokens[0], message, this.getMetadata().key, this.conf.severity, fix));
94996
+ continue;
94997
+ }
94998
+ }
94941
94999
  if (statement.get() instanceof Statements.EndTry) {
94942
95000
  noHandler = false;
94943
95001
  }
@@ -97651,9 +97709,11 @@ const include_graph_1 = __webpack_require__(/*! ./utils/include_graph */ "../cor
97651
97709
  class SkipLogic {
97652
97710
  constructor(reg) {
97653
97711
  this.reg = reg;
97712
+ this.includeGraph = undefined;
97654
97713
  this.tobj = undefined;
97655
97714
  }
97656
97715
  skip(obj) {
97716
+ var _a;
97657
97717
  const global = this.reg.getConfig().getGlobal();
97658
97718
  if (global.skipGeneratedGatewayClasses === true
97659
97719
  && obj instanceof objects_1.Class
@@ -97663,9 +97723,9 @@ class SkipLogic {
97663
97723
  else if (global.skipIncludesWithoutMain === true
97664
97724
  && obj instanceof objects_1.Program
97665
97725
  && obj.isInclude() === true) {
97666
- const ig = new include_graph_1.IncludeGraph(this.reg);
97726
+ (_a = this.includeGraph) !== null && _a !== void 0 ? _a : (this.includeGraph = new include_graph_1.IncludeGraph(this.reg));
97667
97727
  const file = obj.getMainABAPFile();
97668
- if (file && ig.listMainForInclude(file.getFilename()).length === 0) {
97728
+ if (file && this.includeGraph.listMainForInclude(file.getFilename()).length === 0) {
97669
97729
  return true;
97670
97730
  }
97671
97731
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.119.60",
3
+ "version": "2.119.62",
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.60",
42
+ "@abaplint/core": "^2.119.62",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",