@abaplint/cli 2.120.4 → 2.120.5

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 +96 -65
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -30015,7 +30015,7 @@ class CondBody {
30015
30015
  type = source_1.Source.runSyntax(s, input, targetType);
30016
30016
  }
30017
30017
  else {
30018
- source_1.Source.runSyntax(s, input, targetType);
30018
+ source_1.Source.runSyntax(s, input, targetType !== null && targetType !== void 0 ? targetType : type);
30019
30019
  }
30020
30020
  }
30021
30021
  if (scoped === true) {
@@ -34084,7 +34084,7 @@ class Source {
34084
34084
  case "SWITCH":
34085
34085
  {
34086
34086
  const foundType = this.determineType(node, input, targetType);
34087
- const bodyType = switch_body_1.SwitchBody.runSyntax(node.findDirectExpression(Expressions.SwitchBody), input);
34087
+ const bodyType = switch_body_1.SwitchBody.runSyntax(node.findDirectExpression(Expressions.SwitchBody), input, foundType);
34088
34088
  if (foundType === undefined || foundType.isGeneric()) {
34089
34089
  this.addIfInferred(node, input, bodyType);
34090
34090
  }
@@ -35166,7 +35166,7 @@ const source_1 = __webpack_require__(/*! ./source */ "../core/build/src/abap/5_s
35166
35166
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
35167
35167
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
35168
35168
  class SwitchBody {
35169
- static runSyntax(node, input) {
35169
+ static runSyntax(node, input, targetType) {
35170
35170
  if (node === undefined) {
35171
35171
  return;
35172
35172
  }
@@ -35176,12 +35176,12 @@ class SwitchBody {
35176
35176
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
35177
35177
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
35178
35178
  }
35179
- const type = source_1.Source.runSyntax(thenSource, input);
35179
+ const type = source_1.Source.runSyntax(thenSource, input, targetType);
35180
35180
  for (const s of node.findDirectExpressions(Expressions.Source)) {
35181
35181
  if (s === thenSource) {
35182
35182
  continue;
35183
35183
  }
35184
- source_1.Source.runSyntax(s, input);
35184
+ source_1.Source.runSyntax(s, input, targetType !== null && targetType !== void 0 ? targetType : type);
35185
35185
  }
35186
35186
  return type;
35187
35187
  }
@@ -38313,6 +38313,10 @@ class Constant {
38313
38313
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, found.getToken(), message));
38314
38314
  return new _typed_identifier_1.TypedIdentifier(found.getToken(), input.filename, basic_2.VoidType.get(_syntax_input_1.CheckSyntaxKey), meta, val);
38315
38315
  }
38316
+ if (this.isNameTooLong(found.getName())) {
38317
+ const message = "CONSTANTS name too long, " + found.getName();
38318
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, found.getToken(), message));
38319
+ }
38316
38320
  return new _typed_identifier_1.TypedIdentifier(found.getToken(), input.filename, found.getType(), meta, val);
38317
38321
  }
38318
38322
  const fallback = node.findFirstExpression(Expressions.DefinitionName);
@@ -38321,10 +38325,17 @@ class Constant {
38321
38325
  const message = "not possible to have a name with only digits";
38322
38326
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, fallback.getFirstToken(), message));
38323
38327
  }
38328
+ if (this.isNameTooLong(fallback.concatTokens())) {
38329
+ const message = "CONSTANTS name too long, " + fallback.concatTokens();
38330
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, fallback.getFirstToken(), message));
38331
+ }
38324
38332
  return new _typed_identifier_1.TypedIdentifier(fallback.getFirstToken(), input.filename, new basic_1.UnknownType("constant, fallback"));
38325
38333
  }
38326
38334
  throw new assert_error_1.AssertError("Statement Constant: unexpected structure");
38327
38335
  }
38336
+ isNameTooLong(name) {
38337
+ return name.length > 30;
38338
+ }
38328
38339
  isOnlyDigits(name) {
38329
38340
  return /^[0-9]+$/.test(name);
38330
38341
  }
@@ -38915,6 +38926,10 @@ class Data {
38915
38926
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, id.getToken(), message));
38916
38927
  return new _typed_identifier_1.TypedIdentifier(id.getToken(), input.filename, basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey));
38917
38928
  }
38929
+ if (id && this.isNameTooLong(id.getName())) {
38930
+ const message = "DATA name too long, " + id.getName();
38931
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, id.getToken(), message));
38932
+ }
38918
38933
  if ((id === null || id === void 0 ? void 0 : id.getType().isGeneric()) === true
38919
38934
  && (id === null || id === void 0 ? void 0 : id.getType().containsVoid()) === false) {
38920
38935
  const message = "DATA definition cannot be generic, " + (name === null || name === void 0 ? void 0 : name.concatTokens());
@@ -38928,10 +38943,17 @@ class Data {
38928
38943
  const message = "not possible to have a name with only digits";
38929
38944
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, name.getFirstToken(), message));
38930
38945
  }
38946
+ if (this.isNameTooLong(name.concatTokens())) {
38947
+ const message = "DATA name too long, " + name.concatTokens();
38948
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, name.getFirstToken(), message));
38949
+ }
38931
38950
  return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), input.filename, new unknown_type_1.UnknownType("data, fallback"));
38932
38951
  }
38933
38952
  return undefined;
38934
38953
  }
38954
+ isNameTooLong(name) {
38955
+ return name.length > 30;
38956
+ }
38935
38957
  isOnlyDigits(name) {
38936
38958
  return /^[0-9]+$/.test(name);
38937
38959
  }
@@ -47548,16 +47570,17 @@ class SyntaxLogic {
47548
47570
  this.reg = reg;
47549
47571
  this.issues = [];
47550
47572
  this.object = object;
47551
- this.scope = _current_scope_1.CurrentScope.buildDefault(this.reg, object);
47552
- this.helpers = {
47553
- oooc: new _object_oriented_1.ObjectOriented(this.scope),
47554
- proc: new _procedural_1.Procedural(this.reg, this.scope),
47555
- };
47556
47573
  }
47557
47574
  run() {
47558
47575
  if (this.object.syntaxResult !== undefined) {
47559
47576
  return this.object.syntaxResult;
47560
47577
  }
47578
+ // the scope is built here instead of in the constructor, cached results must stay cheap
47579
+ this.scope = _current_scope_1.CurrentScope.buildDefault(this.reg, this.object);
47580
+ this.helpers = {
47581
+ oooc: new _object_oriented_1.ObjectOriented(this.scope),
47582
+ proc: new _procedural_1.Procedural(this.reg, this.scope),
47583
+ };
47561
47584
  this.issues = [];
47562
47585
  this.reg.getDDICReferences().clear(this.object);
47563
47586
  this.reg.getMSAGReferences().clear(this.object);
@@ -69043,7 +69066,7 @@ class Registry {
69043
69066
  }
69044
69067
  static abaplintVersion() {
69045
69068
  // magic, see build script "version.js"
69046
- return "2.120.4";
69069
+ return "2.120.5";
69047
69070
  }
69048
69071
  getDDICReferences() {
69049
69072
  return this.ddicReferences;
@@ -97006,35 +97029,38 @@ class UnusedVariablesConf extends _basic_rule_config_1.BasicRuleConfig {
97006
97029
  exports.UnusedVariablesConf = UnusedVariablesConf;
97007
97030
  class WorkArea {
97008
97031
  constructor() {
97009
- this.workarea = [];
97032
+ // keyed by filename + start position, this equals Identifier.equals()
97033
+ this.workarea = new Map();
97010
97034
  }
97011
97035
  push(id, count = 1) {
97012
- for (const w of this.workarea) {
97013
- if (id.equals(w.id)) {
97014
- return;
97015
- }
97036
+ const key = this.buildKey(id);
97037
+ if (this.workarea.has(key)) {
97038
+ return;
97016
97039
  }
97017
- this.workarea.push({ id, count });
97040
+ this.workarea.set(key, { id, count });
97018
97041
  }
97019
97042
  removeIfExists(id) {
97020
97043
  if (id === undefined) {
97021
97044
  return;
97022
97045
  }
97023
- for (let i = 0; i < this.workarea.length; i++) {
97024
- if (id.equals(this.workarea[i].id)) {
97025
- this.workarea[i].count--;
97026
- if (this.workarea[i].count === 0) {
97027
- this.workarea.splice(i, 1);
97028
- }
97029
- return;
97046
+ const key = this.buildKey(id);
97047
+ const found = this.workarea.get(key);
97048
+ if (found !== undefined) {
97049
+ found.count--;
97050
+ if (found.count === 0) {
97051
+ this.workarea.delete(key);
97030
97052
  }
97031
97053
  }
97032
97054
  }
97033
97055
  get() {
97034
- return this.workarea;
97056
+ return [...this.workarea.values()];
97035
97057
  }
97036
97058
  count() {
97037
- return this.workarea.length;
97059
+ return this.workarea.size;
97060
+ }
97061
+ buildKey(id) {
97062
+ const start = id.getStart();
97063
+ return id.getFilename() + "," + start.getRow() + "," + start.getCol();
97038
97064
  }
97039
97065
  }
97040
97066
  class UnusedVariables {
@@ -97168,6 +97194,9 @@ Errors found in INCLUDES are reported for the main program.`,
97168
97194
  }
97169
97195
  buildIssues(obj) {
97170
97196
  const ret = [];
97197
+ const metadata = this.getMetadata();
97198
+ const pragma = metadata.pragma + "";
97199
+ const files = new Map();
97171
97200
  for (const w of this.workarea.get()) {
97172
97201
  const filename = w.id.getFilename();
97173
97202
  if (this.reg.isFileDependency(filename) === true) {
@@ -97176,41 +97205,52 @@ Errors found in INCLUDES are reported for the main program.`,
97176
97205
  else if (obj instanceof objects_1.Program === false && obj.containsFile(filename) === false) {
97177
97206
  continue;
97178
97207
  }
97179
- const statement = this.findStatement(w.id);
97180
- if (statement === null || statement === void 0 ? void 0 : statement.getPragmas().map(t => t.getStr()).includes(this.getMetadata().pragma + "")) {
97181
- continue;
97208
+ if (files.has(filename) === false) {
97209
+ files.set(filename, this.findFile(filename));
97210
+ }
97211
+ const file = files.get(filename);
97212
+ let statement = undefined;
97213
+ let statementIndex = -1;
97214
+ if (file !== undefined) {
97215
+ const statements = file.getStatements();
97216
+ const token = w.id.getToken();
97217
+ for (let i = 0; i < statements.length; i++) {
97218
+ if (statements[i].includesToken(token)) {
97219
+ statement = statements[i];
97220
+ statementIndex = i;
97221
+ break;
97222
+ }
97223
+ }
97182
97224
  }
97183
- else if (this.suppressedbyPseudo(statement, w.id, obj)) {
97184
- continue;
97225
+ if (statement !== undefined && file !== undefined) {
97226
+ if (statement.getPragmas().some(t => t.getStr() === pragma)) {
97227
+ continue;
97228
+ }
97229
+ else if (this.suppressedbyPseudo(file, statementIndex, w.id, obj)) {
97230
+ continue;
97231
+ }
97185
97232
  }
97186
97233
  const name = w.id.getName();
97187
97234
  const message = "Variable \"" + name.toLowerCase() + "\" not used";
97188
- const fix = this.buildFix(w.id, obj);
97189
- ret.push(issue_1.Issue.atIdentifier(w.id, message, this.getMetadata().key, this.conf.severity, fix));
97235
+ const fix = this.buildFix(w.id, obj, statement);
97236
+ ret.push(issue_1.Issue.atIdentifier(w.id, message, metadata.key, this.conf.severity, fix));
97190
97237
  }
97191
97238
  return ret;
97192
97239
  }
97193
- suppressedbyPseudo(statement, v, obj) {
97194
- if (statement === undefined) {
97240
+ suppressedbyPseudo(file, statementIndex, v, obj) {
97241
+ // pseudo comments are only found in files belonging to the object itself, not in eg. includes
97242
+ if (obj.getABAPFileByName(v.getFilename()) === undefined) {
97195
97243
  return false;
97196
97244
  }
97197
- const file = obj.getABAPFileByName(v.getFilename());
97198
- if (file === undefined) {
97199
- return false;
97200
- }
97201
- let next = false;
97202
- for (const s of file.getStatements()) {
97203
- if (next === true && s.get() instanceof _statement_1.Comment) {
97204
- return s.concatTokens().includes(this.getMetadata().pseudoComment + "");
97205
- }
97206
- if (s === statement) {
97207
- next = true;
97208
- }
97209
- }
97210
- return false;
97245
+ const statements = file.getStatements();
97246
+ const next = statements[statementIndex + 1];
97247
+ return (next === null || next === void 0 ? void 0 : next.get()) instanceof _statement_1.Comment
97248
+ && next.concatTokens().includes(this.getMetadata().pseudoComment + "");
97249
+ // removed by dead control flow
97250
+
97211
97251
  }
97212
- findStatement(v) {
97213
- const file = this.reg.getFileByName(v.getFilename());
97252
+ findFile(filename) {
97253
+ const file = this.reg.getFileByName(filename);
97214
97254
  if (file === undefined) {
97215
97255
  return undefined;
97216
97256
  }
@@ -97218,26 +97258,17 @@ Errors found in INCLUDES are reported for the main program.`,
97218
97258
  if (!(object instanceof _abap_object_1.ABAPObject)) {
97219
97259
  return undefined;
97220
97260
  }
97221
- const abapfile = object.getABAPFileByName(v.getFilename());
97222
- if (abapfile === undefined) {
97261
+ return object.getABAPFileByName(filename);
97262
+ }
97263
+ buildFix(v, obj, statement) {
97264
+ if (statement === undefined || !(statement.get() instanceof Statements.Data)) {
97223
97265
  return undefined;
97224
97266
  }
97225
- const statement = edit_helper_1.EditHelper.findStatement(v.getToken(), abapfile);
97226
- return statement;
97227
- }
97228
- buildFix(v, obj) {
97229
97267
  const file = obj.getABAPFileByName(v.getFilename());
97230
97268
  if (file === undefined) {
97231
97269
  return undefined;
97232
97270
  }
97233
- const statement = edit_helper_1.EditHelper.findStatement(v.getToken(), file);
97234
- if (statement === undefined) {
97235
- return undefined;
97236
- }
97237
- else if (statement.get() instanceof Statements.Data) {
97238
- return edit_helper_1.EditHelper.deleteStatement(file, statement);
97239
- }
97240
- return undefined;
97271
+ return edit_helper_1.EditHelper.deleteStatement(file, statement);
97241
97272
  }
97242
97273
  }
97243
97274
  exports.UnusedVariables = UnusedVariables;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.4",
3
+ "version": "2.120.5",
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.120.4",
42
+ "@abaplint/core": "^2.120.5",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",