@abaplint/cli 2.119.61 → 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 +80 -67
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -11460,7 +11460,9 @@ class StatementParser {
11460
11460
  statement = input;
11461
11461
  }
11462
11462
  else if (length === 1 && lastToken instanceof tokens_1.Pragma) {
11463
- 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]));
11464
11466
  }
11465
11467
  }
11466
11468
  return statement;
@@ -26251,7 +26253,7 @@ class CurrentScope {
26251
26253
  }
26252
26254
  findTypePoolConstant(name) {
26253
26255
  var _a;
26254
- if (name === undefined || name.includes("_") === undefined) {
26256
+ if (name === undefined || name.includes("_") === false) {
26255
26257
  return undefined;
26256
26258
  }
26257
26259
  const typePoolName = name.split("_")[0];
@@ -26273,7 +26275,7 @@ class CurrentScope {
26273
26275
  }
26274
26276
  findTypePoolType(name) {
26275
26277
  var _a;
26276
- if (name.includes("_") === undefined) {
26278
+ if (name.includes("_") === false) {
26277
26279
  return undefined;
26278
26280
  }
26279
26281
  const typePoolName = name.split("_")[0];
@@ -26587,11 +26589,9 @@ class ObjectOriented {
26587
26589
  findMethodInInterface(interfaceName, methodName) {
26588
26590
  const idef = this.scope.findInterfaceDefinition(interfaceName);
26589
26591
  if (idef) {
26590
- const methods = idef.getMethodDefinitions().getAll();
26591
- for (const method of methods) {
26592
- if (method.getName().toUpperCase() === methodName.toUpperCase()) {
26593
- return { method, def: idef };
26594
- }
26592
+ const method = idef.getMethodDefinitions().getByName(methodName);
26593
+ if (method) {
26594
+ return { method, def: idef };
26595
26595
  }
26596
26596
  return this.findMethodViaAlias(methodName, idef);
26597
26597
  }
@@ -26813,17 +26813,14 @@ class ObjectOriented {
26813
26813
  if (defs === undefined) {
26814
26814
  return undefined;
26815
26815
  }
26816
- for (const method of defs.getAll()) {
26817
- if (method.getName().toUpperCase() === methodName.toUpperCase()) {
26818
- if (method.isRedefinition()) {
26819
- return this.findMethodInSuper(def, methodName);
26820
- }
26821
- else {
26822
- return method;
26823
- }
26824
- }
26816
+ const method = defs.getByName(methodName);
26817
+ if (method === undefined) {
26818
+ return undefined;
26825
26819
  }
26826
- return undefined;
26820
+ if (method.isRedefinition()) {
26821
+ return this.findMethodInSuper(def, methodName);
26822
+ }
26823
+ return method;
26827
26824
  }
26828
26825
  findMethodInSuper(child, methodName) {
26829
26826
  let sup = child.getSuperClass();
@@ -50694,6 +50691,8 @@ class Attributes {
50694
50691
  this.tlist = [];
50695
50692
  this.filename = input.filename;
50696
50693
  this.parse(node, input);
50694
+ this.all = this.static.concat(this.instance);
50695
+ this.byName = this.buildByName();
50697
50696
  this.types = new type_definitions_1.TypeDefinitions(this.tlist);
50698
50697
  }
50699
50698
  getTypes() {
@@ -50706,10 +50705,7 @@ class Attributes {
50706
50705
  return this.aliases;
50707
50706
  }
50708
50707
  getAll() {
50709
- let res = [];
50710
- res = res.concat(this.static);
50711
- res = res.concat(this.instance);
50712
- return res;
50708
+ return this.all;
50713
50709
  }
50714
50710
  getStaticsByVisibility(visibility) {
50715
50711
  const attributes = [];
@@ -50744,27 +50740,29 @@ class Attributes {
50744
50740
  }
50745
50741
  return attributes;
50746
50742
  }
50747
- // todo, optimize
50748
50743
  findByName(name) {
50749
- const upper = name.toUpperCase();
50750
- for (const a of this.getStatic()) {
50751
- if (a.getName().toUpperCase() === upper) {
50752
- return a;
50753
- }
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;
50754
50751
  }
50755
- for (const a of this.getInstance()) {
50756
- if (a.getName().toUpperCase() === upper) {
50757
- return a;
50752
+ for (const a of this.instance) {
50753
+ const name = a.getName().toUpperCase();
50754
+ if (ret[name] === undefined) {
50755
+ ret[name] = a;
50758
50756
  }
50759
50757
  }
50760
- for (const a of this.getConstants()) {
50761
- if (a.getName().toUpperCase() === upper) {
50762
- return a;
50758
+ for (const a of this.constants) {
50759
+ const name = a.getName().toUpperCase();
50760
+ if (ret[name] === undefined) {
50761
+ ret[name] = a;
50763
50762
  }
50764
50763
  }
50765
- return undefined;
50764
+ return ret;
50766
50765
  }
50767
- /////////////////////////////
50768
50766
  parse(node, input) {
50769
50767
  var _a, _b;
50770
50768
  const cdef = node.findDirectStructure(Structures.ClassDefinition);
@@ -54541,10 +54539,19 @@ class Config {
54541
54539
  for (const rule of sorted) {
54542
54540
  rules[rule.getMetadata().key] = rule.getConfig();
54543
54541
  }
54544
- const version = ver !== null && ver !== void 0 ? ver : {
54545
- release: version_1.Release.Newest.name,
54546
- language: langVer !== null && langVer !== void 0 ? langVer : version_1.LanguageVersion.Normal,
54547
- };
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
+ };
54548
54555
  // defaults: dont skip anything, report everything. The user can decide to skip stuff
54549
54556
  // its difficult to debug errors not being reported
54550
54557
  const config = {
@@ -54569,7 +54576,6 @@ class Config {
54569
54576
  }],
54570
54577
  syntax: {
54571
54578
  version,
54572
- languageVersion: langVer,
54573
54579
  errorNamespace: "^(Z|Y|LCL\_|TY\_|LIF\_)",
54574
54580
  globalConstants: [],
54575
54581
  ambigiousVoids: [],
@@ -54678,9 +54684,6 @@ class Config {
54678
54684
  return v;
54679
54685
  }
54680
54686
  getLanguageVersion() {
54681
- if (this.config.syntax.languageVersion !== undefined) {
54682
- return this.config.syntax.languageVersion;
54683
- }
54684
54687
  const v = this.config.syntax.version;
54685
54688
  if (v !== undefined && typeof v !== "string") {
54686
54689
  return v.language;
@@ -54705,7 +54708,10 @@ class Config {
54705
54708
  return;
54706
54709
  }
54707
54710
  if (version === version_1.Version.Cloud) {
54708
- 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
+ };
54709
54715
  }
54710
54716
  // OpenABAP keeps its own version identity; open-abap-ness is derived from the
54711
54717
  // release in getOpenABAP() rather than a separate stored flag.
@@ -68814,7 +68820,7 @@ class Registry {
68814
68820
  }
68815
68821
  static abaplintVersion() {
68816
68822
  // magic, see build script "version.js"
68817
- return "2.119.61";
68823
+ return "2.119.62";
68818
68824
  }
68819
68825
  getDDICReferences() {
68820
68826
  return this.ddicReferences;
@@ -85844,7 +85850,6 @@ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/ex
85844
85850
  const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
85845
85851
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
85846
85852
  const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
85847
- const tokens_1 = __webpack_require__(/*! ../abap/1_lexer/tokens */ "../core/build/src/abap/1_lexer/tokens/index.js");
85848
85853
  const expressions_1 = __webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js");
85849
85854
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
85850
85855
  class NamesNoDashConf extends _basic_rule_config_1.BasicRuleConfig {
@@ -85884,32 +85889,26 @@ class NamesNoDash extends _abap_rule_1.ABAPRule {
85884
85889
  if (obj.getType() !== "CLAS" && obj.getType() !== "INTF") {
85885
85890
  for (const form of struc.findAllStatements(Statements.Form)) {
85886
85891
  const expr = form.findFirstExpression(expressions_1.FormName);
85887
- for (const token of expr.getTokens()) {
85888
- if (token instanceof tokens_1.Dash || token instanceof tokens_1.DashW) {
85889
- const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85890
- issues.push(issue);
85891
- break;
85892
- }
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);
85893
85896
  }
85894
85897
  }
85895
85898
  for (const form of struc.findAllStatements(Statements.Parameter)) {
85896
85899
  const expr = form.findFirstExpression(Expressions.FieldSub);
85897
- for (const token of expr.getTokens()) {
85898
- if (token instanceof tokens_1.Dash || token instanceof tokens_1.DashW) {
85899
- const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85900
- issues.push(issue);
85901
- break;
85902
- }
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);
85903
85904
  }
85904
85905
  }
85905
85906
  for (const form of struc.findAllStatements(Statements.SelectOption)) {
85906
85907
  const expr = form.findFirstExpression(Expressions.FieldSub);
85907
- for (const token of expr.getTokens()) {
85908
- if (token instanceof tokens_1.Dash || token instanceof tokens_1.DashW) {
85909
- const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
85910
- issues.push(issue);
85911
- break;
85912
- }
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);
85913
85912
  }
85914
85913
  }
85915
85914
  }
@@ -94917,6 +94916,7 @@ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "..
94917
94916
  const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
94918
94917
  const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
94919
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");
94920
94920
  class UnnecessaryPragmaConf extends _basic_rule_config_1.BasicRuleConfig {
94921
94921
  constructor() {
94922
94922
  super(...arguments);
@@ -94985,6 +94985,17 @@ DATA: BEGIN OF blah ##NEEDED,
94985
94985
  for (let i = 0; i < statements.length; i++) {
94986
94986
  const statement = statements[i];
94987
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
+ }
94988
94999
  if (statement.get() instanceof Statements.EndTry) {
94989
95000
  noHandler = false;
94990
95001
  }
@@ -97698,9 +97709,11 @@ const include_graph_1 = __webpack_require__(/*! ./utils/include_graph */ "../cor
97698
97709
  class SkipLogic {
97699
97710
  constructor(reg) {
97700
97711
  this.reg = reg;
97712
+ this.includeGraph = undefined;
97701
97713
  this.tobj = undefined;
97702
97714
  }
97703
97715
  skip(obj) {
97716
+ var _a;
97704
97717
  const global = this.reg.getConfig().getGlobal();
97705
97718
  if (global.skipGeneratedGatewayClasses === true
97706
97719
  && obj instanceof objects_1.Class
@@ -97710,9 +97723,9 @@ class SkipLogic {
97710
97723
  else if (global.skipIncludesWithoutMain === true
97711
97724
  && obj instanceof objects_1.Program
97712
97725
  && obj.isInclude() === true) {
97713
- 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));
97714
97727
  const file = obj.getMainABAPFile();
97715
- if (file && ig.listMainForInclude(file.getFilename()).length === 0) {
97728
+ if (file && this.includeGraph.listMainForInclude(file.getFilename()).length === 0) {
97716
97729
  return true;
97717
97730
  }
97718
97731
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.119.61",
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.61",
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",