@abaplint/transpiler-cli 2.7.156 → 2.7.157

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/bundle.js +118 -18
  2. package/package.json +5 -5
package/build/bundle.js CHANGED
@@ -6145,7 +6145,7 @@ const combi_1 = __webpack_require__(/*! ../combi */ "./node_modules/@abaplint/co
6145
6145
  const _1 = __webpack_require__(/*! . */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
6146
6146
  class RaiseWith extends combi_1.Expression {
6147
6147
  getRunnable() {
6148
- const wit = (0, combi_1.seq)("WITH", _1.Source, (0, combi_1.opt)(_1.Source), (0, combi_1.opt)(_1.Source), (0, combi_1.opt)(_1.Source));
6148
+ const wit = (0, combi_1.seq)("WITH", _1.SimpleSource3, (0, combi_1.opt)(_1.SimpleSource3), (0, combi_1.opt)(_1.SimpleSource3), (0, combi_1.opt)(_1.SimpleSource3));
6149
6149
  return wit;
6150
6150
  }
6151
6151
  }
@@ -20322,11 +20322,11 @@ class CurrentScope {
20322
20322
  }
20323
20323
  this.addNamedIdentifier(identifier.getName(), identifier);
20324
20324
  }
20325
- addDeferred(token) {
20325
+ addDeferred(token, type) {
20326
20326
  if (token === undefined) {
20327
20327
  return;
20328
20328
  }
20329
- this.current.getData().deferred[token.getStr().toUpperCase()] = token;
20329
+ this.current.getData().deferred[token.getStr().toUpperCase()] = { token, ooType: type };
20330
20330
  }
20331
20331
  addListPrefix(identifiers, prefix) {
20332
20332
  for (const id of identifiers) {
@@ -20431,7 +20431,16 @@ class CurrentScope {
20431
20431
  }
20432
20432
  const def = (_c = this.current) === null || _c === void 0 ? void 0 : _c.findDeferred(name);
20433
20433
  if (def !== undefined) {
20434
- return { id: def };
20434
+ let rttiName = prefixRTTI;
20435
+ switch (def.ooType) {
20436
+ case "INTF":
20437
+ rttiName = rttiName + "\\INTERFACE=" + name;
20438
+ break;
20439
+ default:
20440
+ rttiName = rttiName + "\\CLASS=" + name;
20441
+ break;
20442
+ }
20443
+ return { id: def.id, ooType: def.ooType, RTTIName: rttiName };
20435
20444
  }
20436
20445
  return undefined;
20437
20446
  }
@@ -20461,6 +20470,11 @@ class CurrentScope {
20461
20470
  if (typePoolName.length <= 1 || typePoolName.length > 5) {
20462
20471
  return undefined;
20463
20472
  }
20473
+ if (this.parentObj.getType() === "TYPE"
20474
+ && this.parentObj.getName().toUpperCase() === typePoolName.toUpperCase()) {
20475
+ // dont recurse into itself
20476
+ return undefined;
20477
+ }
20464
20478
  const typePool = this.reg.getObject("TYPE", typePoolName);
20465
20479
  if (typePool === undefined) {
20466
20480
  return undefined;
@@ -20478,6 +20492,11 @@ class CurrentScope {
20478
20492
  if (typePoolName.length <= 2 || typePoolName.length > 5) {
20479
20493
  return undefined;
20480
20494
  }
20495
+ if (this.parentObj.getType() === "TYPE"
20496
+ && this.parentObj.getName().toUpperCase() === typePoolName.toUpperCase()) {
20497
+ // dont recurse into itself
20498
+ return undefined;
20499
+ }
20481
20500
  if (new ddic_1.DDIC(this.reg).lookupNoVoid(name) !== undefined) {
20482
20501
  // this is tricky, it should not do recursion when parsing the type pool itself,
20483
20502
  // think about DTEL ABAP_ENCOD vs TYPE ABAP
@@ -25232,7 +25251,7 @@ const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ ".
25232
25251
  const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
25233
25252
  class RaiseWith {
25234
25253
  runSyntax(node, scope, filename) {
25235
- for (const f of node.findDirectExpressions(Expressions.Source)) {
25254
+ for (const f of node.findDirectExpressions(Expressions.SimpleSource3)) {
25236
25255
  new source_1.Source().runSyntax(f, scope, filename);
25237
25256
  }
25238
25257
  }
@@ -25692,6 +25711,11 @@ class Source {
25692
25711
  else {
25693
25712
  this.addIfInferred(node, scope, filename, foundType);
25694
25713
  }
25714
+ children.shift();
25715
+ children.shift();
25716
+ children.shift();
25717
+ children.shift();
25718
+ this.traverseRemainingChildren(children, scope, filename);
25695
25719
  return foundType ? foundType : bodyType;
25696
25720
  }
25697
25721
  case "CONV":
@@ -25808,6 +25832,12 @@ class Source {
25808
25832
  return context;
25809
25833
  }
25810
25834
  ////////////////////////////////
25835
+ traverseRemainingChildren(children, scope, filename) {
25836
+ const last = children[children.length - 1];
25837
+ if (last && last.get() instanceof Expressions.Source) {
25838
+ new Source().runSyntax(last, scope, filename);
25839
+ }
25840
+ }
25811
25841
  infer(context, found) {
25812
25842
  if (context instanceof basic_1.FloatType && found instanceof basic_1.IntegerType) {
25813
25843
  return context;
@@ -26829,7 +26859,10 @@ class SpaghettiScopeNode extends ScopeData {
26829
26859
  while (search !== undefined) {
26830
26860
  const found = search.getData().deferred[name.toUpperCase()];
26831
26861
  if (found) {
26832
- return new _identifier_1.Identifier(found, search.identifier.filename);
26862
+ return {
26863
+ id: new _identifier_1.Identifier(found.token, search.identifier.filename),
26864
+ ooType: found.ooType,
26865
+ };
26833
26866
  }
26834
26867
  search = search.getParent();
26835
26868
  }
@@ -27730,7 +27763,7 @@ class ClassDeferred {
27730
27763
  runSyntax(node, scope, _filename) {
27731
27764
  var _a;
27732
27765
  const name = (_a = node.findFirstExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
27733
- scope.addDeferred(name);
27766
+ scope.addDeferred(name, "CLAS");
27734
27767
  }
27735
27768
  }
27736
27769
  exports.ClassDeferred = ClassDeferred;
@@ -29540,7 +29573,7 @@ class InterfaceDeferred {
29540
29573
  runSyntax(node, scope, _filename) {
29541
29574
  var _a;
29542
29575
  const name = (_a = node.findFirstExpression(Expressions.InterfaceName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
29543
- scope.addDeferred(name);
29576
+ scope.addDeferred(name, "INTF");
29544
29577
  }
29545
29578
  }
29546
29579
  exports.InterfaceDeferred = InterfaceDeferred;
@@ -29908,13 +29941,33 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
29908
29941
  const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
29909
29942
  const fstarget_1 = __webpack_require__(/*! ../expressions/fstarget */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/fstarget.js");
29910
29943
  const component_cond_1 = __webpack_require__(/*! ../expressions/component_cond */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_cond.js");
29944
+ const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
29911
29945
  class ModifyInternal {
29912
29946
  runSyntax(node, scope, filename) {
29913
29947
  for (const s of node.findDirectExpressions(Expressions.Source)) {
29914
29948
  new source_1.Source().runSyntax(s, scope, filename);
29915
29949
  }
29916
- for (const t of node.findDirectExpressions(Expressions.Target)) {
29917
- new target_1.Target().runSyntax(t, scope, filename);
29950
+ // there is only one
29951
+ const targetExpression = node.findFirstExpression(Expressions.Target);
29952
+ if (targetExpression) {
29953
+ // it might be a dynamic target
29954
+ const targetType = new target_1.Target().runSyntax(targetExpression, scope, filename);
29955
+ if (targetType instanceof basic_1.VoidType
29956
+ || targetType instanceof basic_1.AnyType
29957
+ || targetType instanceof basic_1.UnknownType) {
29958
+ // ok
29959
+ }
29960
+ else if (targetType instanceof basic_1.TableType) {
29961
+ if (node.findDirectTokenByText("TABLE")
29962
+ && node.findDirectTokenByText("INDEX")
29963
+ && targetType.isWithHeader() === false) {
29964
+ // MODIFY TABLE INDEX
29965
+ throw new Error("Table does not have header line");
29966
+ }
29967
+ }
29968
+ else {
29969
+ throw new Error("Not an internal table");
29970
+ }
29918
29971
  }
29919
29972
  const target = node.findDirectExpression(Expressions.FSTarget);
29920
29973
  if (target) {
@@ -30152,6 +30205,9 @@ class Parameter {
30152
30205
  if (nameToken && nameToken.getStr().length > 8) {
30153
30206
  throw new Error("Parameter name too long, " + nameToken.getStr());
30154
30207
  }
30208
+ if (node.findDirectTokenByText("RADIOBUTTON") && node.findDirectTokenByText("LENGTH")) {
30209
+ throw new Error("RADIOBUTTON and LENGTH not possible together");
30210
+ }
30155
30211
  const bfound = new basic_types_1.BasicTypes(filename, scope).parseType(node);
30156
30212
  if (nameToken && bfound) {
30157
30213
  scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, filename, bfound));
@@ -33468,6 +33524,32 @@ class ExpressionNode extends _abstract_node_1.AbstractNode {
33468
33524
  }
33469
33525
  throw new Error("ExpressionNode, getFirstToken, no children");
33470
33526
  }
33527
+ concatTokensWithLinebreaks() {
33528
+ let str = "";
33529
+ let prev;
33530
+ for (const token of this.getTokens()) {
33531
+ if (token instanceof tokens_1.Pragma) {
33532
+ continue;
33533
+ }
33534
+ if (str === "") {
33535
+ str = token.getStr();
33536
+ }
33537
+ else if (prev && prev.getStr().length + prev.getCol() === token.getCol()
33538
+ && prev.getRow() === token.getRow()) {
33539
+ str = str + token.getStr();
33540
+ }
33541
+ else {
33542
+ if (prev && prev.getRow() !== token.getRow()) {
33543
+ str = str + "\n" + token.getStr();
33544
+ }
33545
+ else {
33546
+ str = str + " " + token.getStr();
33547
+ }
33548
+ }
33549
+ prev = token;
33550
+ }
33551
+ return str;
33552
+ }
33471
33553
  concatTokens() {
33472
33554
  let str = "";
33473
33555
  let prev;
@@ -50116,7 +50198,7 @@ class Registry {
50116
50198
  }
50117
50199
  static abaplintVersion() {
50118
50200
  // magic, see build script "version.sh"
50119
- return "2.105.16";
50201
+ return "2.105.18";
50120
50202
  }
50121
50203
  getDDICReferences() {
50122
50204
  return this.ddicReferences;
@@ -51376,6 +51458,7 @@ const expressions_1 = __webpack_require__(/*! ../abap/2_statements/expressions *
51376
51458
  const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
51377
51459
  const version_1 = __webpack_require__(/*! ../version */ "./node_modules/@abaplint/core/build/src/version.js");
51378
51460
  const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
51461
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/_statement.js");
51379
51462
  class AvoidUseConf extends _basic_rule_config_1.BasicRuleConfig {
51380
51463
  constructor() {
51381
51464
  super(...arguments);
@@ -51385,11 +51468,11 @@ class AvoidUseConf extends _basic_rule_config_1.BasicRuleConfig {
51385
51468
  this.define = true;
51386
51469
  /** Detects statics */
51387
51470
  this.statics = true;
51388
- /** Detects DEFAULT KEY definitions, from version v740sp02 and up */
51471
+ /** Detects DEFAULT KEY definitions, from version v740sp02 and up. Use pseudo comment DEFAULT_KEY to ignore */
51389
51472
  this.defaultKey = true;
51390
51473
  /** Detects BREAK and BREAK-POINTS */
51391
51474
  this.break = true;
51392
- /** Detects TEST SEAMS */
51475
+ /** Detects TEST SEAMS. Use pseudo comment TEST_SEAM_USAGE to ignore */
51393
51476
  this.testSeams = true;
51394
51477
  /** Detects DESCRIBE TABLE LINES, use lines() instead */
51395
51478
  this.describeLines = true;
@@ -51437,7 +51520,9 @@ BREAK points`,
51437
51520
  var _a;
51438
51521
  const issues = [];
51439
51522
  let isStaticsBlock = false;
51440
- for (const statementNode of file.getStatements()) {
51523
+ const statements = file.getStatements();
51524
+ for (let i = 0; i < statements.length; i++) {
51525
+ const statementNode = statements[i];
51441
51526
  const statement = statementNode.get();
51442
51527
  let message = undefined;
51443
51528
  let fix = undefined;
@@ -51465,6 +51550,10 @@ BREAK points`,
51465
51550
  message = "EXPORT TO DATABASE";
51466
51551
  }
51467
51552
  else if (this.conf.testSeams && statement instanceof Statements.TestSeam) {
51553
+ const next = statements[i + 1];
51554
+ if ((next === null || next === void 0 ? void 0 : next.get()) instanceof _statement_1.Comment && next.concatTokens().includes("EC TEST_SEAM_USAGE")) {
51555
+ continue;
51556
+ }
51468
51557
  message = "TEST-SEAM";
51469
51558
  }
51470
51559
  else if (this.conf.statics && statement instanceof Statements.Static && isStaticsBlock === false) {
@@ -51484,6 +51573,10 @@ BREAK points`,
51484
51573
  const tt = (_a = statementNode.findFirstExpression(expressions_1.TypeTable)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(expressions_1.TypeTableKey);
51485
51574
  const token = tt === null || tt === void 0 ? void 0 : tt.findDirectTokenByText("DEFAULT");
51486
51575
  if (tt && token) {
51576
+ const next = statements[i + 1];
51577
+ if ((next === null || next === void 0 ? void 0 : next.get()) instanceof _statement_1.Comment && next.concatTokens().includes("EC DEFAULT_KEY")) {
51578
+ continue;
51579
+ }
51487
51580
  message = "DEFAULT KEY";
51488
51581
  issues.push(issue_1.Issue.atToken(file, token, this.getDescription(message), this.getMetadata().key, this.conf.severity));
51489
51582
  }
@@ -55915,7 +56008,7 @@ ${indentation}CATCH ${className} INTO ${targetName}.`;
55915
56008
  }
55916
56009
  startToken = node.getFirstToken();
55917
56010
  }
55918
- const withs = ((_f = node.findDirectExpression(Expressions.RaiseWith)) === null || _f === void 0 ? void 0 : _f.findDirectExpressions(Expressions.Source)) || [];
56011
+ const withs = ((_f = node.findDirectExpression(Expressions.RaiseWith)) === null || _f === void 0 ? void 0 : _f.findDirectExpressions(Expressions.SimpleSource3)) || [];
55919
56012
  const className = ((_g = node.findDirectExpression(Expressions.ClassName)) === null || _g === void 0 ? void 0 : _g.concatTokens()) || "ERROR";
55920
56013
  const uniqueName1 = this.uniqueName(node.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
55921
56014
  const uniqueName2 = this.uniqueName(node.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
@@ -56303,7 +56396,7 @@ LOOP AT ${groupTargetName}tab ${groupTarget}.`;
56303
56396
  const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
56304
56397
  let code = `CLEAR ${target.concatTokens()}.\n`;
56305
56398
  for (const fieldAssignment of fieldAssignments) {
56306
- code += indentation + target.concatTokens() + "-" + fieldAssignment.concatTokens() + `.\n`;
56399
+ code += indentation + target.concatTokens() + "-" + fieldAssignment.concatTokensWithLinebreaks() + `.\n`;
56307
56400
  }
56308
56401
  code = code.trimEnd();
56309
56402
  const start = high.getFirstToken().getStart();
@@ -56973,7 +57066,7 @@ ${indentation} output = ${uniqueName}.\n`;
56973
57066
  body += data;
56974
57067
  added = true;
56975
57068
  }
56976
- body += indentation + structureName + "-" + b.concatTokens() + ".\n";
57069
+ body += indentation + structureName + "-" + b.concatTokensWithLinebreaks() + ".\n";
56977
57070
  }
56978
57071
  else if (b.get() instanceof Expressions.Source) {
56979
57072
  // note: it wont work with APPEND for Hashed/Sorted Tables, so use INSERT,
@@ -62535,6 +62628,7 @@ exports.MethodImplementedTwice = MethodImplementedTwice;
62535
62628
  Object.defineProperty(exports, "__esModule", ({ value: true }));
62536
62629
  exports.MethodLength = exports.MethodLengthConf = void 0;
62537
62630
  const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
62631
+ const Objects = __webpack_require__(/*! ../objects */ "./node_modules/@abaplint/core/build/src/objects/index.js");
62538
62632
  const method_length_stats_1 = __webpack_require__(/*! ../utils/method_length_stats */ "./node_modules/@abaplint/core/build/src/utils/method_length_stats.js");
62539
62633
  const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
62540
62634
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
@@ -62596,6 +62690,12 @@ Abstract methods without statements are considered okay.`,
62596
62690
  return this;
62597
62691
  }
62598
62692
  run(obj) {
62693
+ var _a;
62694
+ if (this.conf.ignoreTestClasses === true
62695
+ && obj instanceof Objects.Class
62696
+ && ((_a = obj.getClassDefinition()) === null || _a === void 0 ? void 0 : _a.isForTesting) === true) {
62697
+ return [];
62698
+ }
62599
62699
  const methodStats = method_length_stats_1.MethodLengthStats.run(obj);
62600
62700
  const methodIssues = this.check(methodStats, "METHOD");
62601
62701
  let formIssues = [];
@@ -69567,7 +69667,7 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
69567
69667
  j = 1;
69568
69668
  let prevStatement = statements[i - j];
69569
69669
  while ((prevStatement === null || prevStatement === void 0 ? void 0 : prevStatement.get()) instanceof _statement_1.Comment) {
69570
- j--;
69670
+ j++;
69571
69671
  prevStatement = statements[i - j];
69572
69672
  }
69573
69673
  const next = nextStatement === null || nextStatement === void 0 ? void 0 : nextStatement.getColon();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.7.156",
3
+ "version": "2.7.157",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -26,14 +26,14 @@
26
26
  "author": "abaplint",
27
27
  "license": "MIT",
28
28
  "devDependencies": {
29
- "@abaplint/transpiler": "^2.7.156",
29
+ "@abaplint/transpiler": "^2.7.157",
30
30
  "@types/glob": "^8.1.0",
31
31
  "glob": "=7.2.0",
32
32
  "@types/progress": "^2.0.7",
33
- "@types/node": "^20.11.16",
34
- "@abaplint/core": "^2.105.16",
33
+ "@types/node": "^20.11.19",
34
+ "@abaplint/core": "^2.105.18",
35
35
  "progress": "^2.0.3",
36
- "webpack": "^5.90.1",
36
+ "webpack": "^5.90.2",
37
37
  "webpack-cli": "^5.1.4",
38
38
  "typescript": "^5.3.3"
39
39
  }