@abaplint/transpiler-cli 2.7.54 → 2.7.56

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 +86 -17
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -18302,7 +18302,12 @@ class BuiltInMethod extends _identifier_1.Identifier {
18302
18302
  this.row = row;
18303
18303
  }
18304
18304
  getRequiredParameters() {
18305
- return [];
18305
+ const ret = [];
18306
+ for (const i in this.method.mandatory) {
18307
+ const id = new tokens_1.Identifier(new position_1.Position(this.row, 1), i);
18308
+ ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, this.method.mandatory[i]));
18309
+ }
18310
+ return ret;
18306
18311
  }
18307
18312
  getOptional() {
18308
18313
  throw new Error("BuiltInMethod->Method not implemented.");
@@ -20906,6 +20911,7 @@ class TypeUtils {
20906
20911
  return false;
20907
20912
  }
20908
20913
  else if (target instanceof basic_1.IntegerType
20914
+ || target instanceof basic_1.CharacterType
20909
20915
  || target instanceof basic_1.StringType) {
20910
20916
  if (source instanceof basic_1.TableType && source.isWithHeader() === false) {
20911
20917
  return false;
@@ -26693,10 +26699,15 @@ const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ ".
26693
26699
  const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
26694
26700
  class ClassLocalFriends {
26695
26701
  runSyntax(node, scope, filename) {
26696
- const found = node.findDirectExpression(Expressions.ClassName);
26702
+ const classNames = node.findAllExpressions(Expressions.ClassName);
26703
+ const found = classNames[0];
26697
26704
  if (found) {
26698
26705
  const token = found.getFirstToken();
26699
26706
  const name = token.getStr();
26707
+ if (scope.getParentObj().getType() === "CLAS"
26708
+ && name.toUpperCase() !== scope.getParentObj().getName().toUpperCase()) {
26709
+ throw new Error(`Befriending must be ` + scope.getParentObj().getName().toUpperCase());
26710
+ }
26700
26711
  const def = scope.findClassDefinition(name);
26701
26712
  if (def) {
26702
26713
  scope.addReference(token, def, _reference_1.ReferenceType.ObjectOrientedReference, filename);
@@ -26705,6 +26716,14 @@ class ClassLocalFriends {
26705
26716
  throw new Error(`Class ${name.toUpperCase()} not found`);
26706
26717
  }
26707
26718
  }
26719
+ for (let i = 1; i < classNames.length; i++) {
26720
+ const className = classNames[i].concatTokens();
26721
+ // make sure to check also DEFINITION DEFERRED
26722
+ const found = scope.existsObject(className);
26723
+ if (found.found === false) {
26724
+ throw new Error(`Class ${className.toUpperCase()} not found`);
26725
+ }
26726
+ }
26708
26727
  }
26709
26728
  }
26710
26729
  exports.ClassLocalFriends = ClassLocalFriends;
@@ -47591,7 +47610,7 @@ class Registry {
47591
47610
  }
47592
47611
  static abaplintVersion() {
47593
47612
  // magic, see build script "version.sh"
47594
- return "2.102.7";
47613
+ return "2.102.14";
47595
47614
  }
47596
47615
  getDDICReferences() {
47597
47616
  return this.ddicReferences;
@@ -51510,6 +51529,9 @@ class CyclomaticComplexity {
51510
51529
  }
51511
51530
  setConfig(conf) {
51512
51531
  this.conf = conf;
51532
+ if (this.conf.max === undefined) {
51533
+ this.conf.max = new CyclomaticComplexityConf().max;
51534
+ }
51513
51535
  }
51514
51536
  initialize(_reg) {
51515
51537
  return this;
@@ -52225,6 +52247,7 @@ const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplin
52225
52247
  const _builtin_1 = __webpack_require__(/*! ../abap/5_syntax/_builtin */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_builtin.js");
52226
52248
  const _scope_type_1 = __webpack_require__(/*! ../abap/5_syntax/_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
52227
52249
  const statements_1 = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
52250
+ const crypto = __webpack_require__(/*! crypto */ "crypto");
52228
52251
  // todo: refactor each sub-rule to new classes?
52229
52252
  // todo: add configuration
52230
52253
  class DownportConf extends _basic_rule_config_1.BasicRuleConfig {
@@ -52486,13 +52509,12 @@ Make sure to test the downported code, it might not always be completely correct
52486
52509
  }
52487
52510
  }
52488
52511
  }
52489
- else if (ret.length === 0 && / xsdbool\(/i.test(lowFile.getRaw())) {
52512
+ if (ret.length === 0 && lowFile.getRaw().includes(" xsdbool( ")) {
52490
52513
  for (let i = 0; i < lowStatements.length; i++) {
52491
52514
  const high = highStatements[i];
52492
52515
  const issue = this.replaceXsdBool(high, lowFile, highSyntax);
52493
52516
  if (issue) {
52494
52517
  ret.push(issue);
52495
- break;
52496
52518
  }
52497
52519
  }
52498
52520
  }
@@ -52527,11 +52549,13 @@ Make sure to test the downported code, it might not always be completely correct
52527
52549
  return undefined;
52528
52550
  }
52529
52551
  // downport XSDBOOL() early, as it is valid 702 syntax
52552
+ /*
52530
52553
  let found = this.replaceXsdBool(high, lowFile, highSyntax);
52531
52554
  if (found) {
52532
- return found;
52555
+ return found;
52533
52556
  }
52534
- found = this.downportEnum(low, high, lowFile, highSyntax, highFile);
52557
+ */
52558
+ let found = this.downportEnum(low, high, lowFile, highSyntax, highFile);
52535
52559
  if (found) {
52536
52560
  return found;
52537
52561
  }
@@ -54742,8 +54766,14 @@ ${indentation} output = ${uniqueName}.\n`;
54742
54766
  this.counter++;
54743
54767
  return name;
54744
54768
  }
54769
+ let postfix = "";
54770
+ if (spag.getIdentifier().stype === _scope_type_1.ScopeType.ClassDefinition) {
54771
+ // try making sure this name is not used in subclasses
54772
+ const hash = crypto.createHash("sha1").update(spag.getIdentifier().sname).digest("hex");
54773
+ postfix = "_" + hash.substring(0, 10);
54774
+ }
54745
54775
  while (true) {
54746
- const name = "temp" + this.counter;
54776
+ const name = "temp" + this.counter + postfix;
54747
54777
  const exists = this.existsRecursive(spag, name);
54748
54778
  this.counter++;
54749
54779
  if (exists === false) {
@@ -54751,13 +54781,14 @@ ${indentation} output = ${uniqueName}.\n`;
54751
54781
  }
54752
54782
  }
54753
54783
  }
54784
+ // todo, optimize, the findVariable() and findType() does a lot of redundant checks
54754
54785
  existsRecursive(spag, name) {
54755
- const existsDirect = spag.findVariable(name);
54786
+ const existsDirect = spag.findVariable(name) || spag.findType(name);
54756
54787
  if (existsDirect) {
54757
54788
  return true;
54758
54789
  }
54759
54790
  for (const child of spag.getChildren()) {
54760
- if (child.findVariable(name) || this.existsRecursive(child, name)) {
54791
+ if (child.findVariable(name) || child.findType(name) || this.existsRecursive(child, name)) {
54761
54792
  return true;
54762
54793
  }
54763
54794
  }
@@ -54769,7 +54800,20 @@ ${indentation} output = ${uniqueName}.\n`;
54769
54800
  if (r.referenceType === _reference_1.ReferenceType.BuiltinMethodReference
54770
54801
  && r.position.getName().toUpperCase() === "XSDBOOL") {
54771
54802
  const token = r.position.getToken();
54772
- const fix = edit_helper_1.EditHelper.replaceRange(lowFile, token.getStart(), token.getEnd(), "boolc");
54803
+ let source = undefined;
54804
+ for (const s of node.findAllExpressionsRecursive(Expressions.Source)) {
54805
+ if (s.getFirstToken().getStart().equals(token.getStart())) {
54806
+ source = s;
54807
+ break;
54808
+ }
54809
+ }
54810
+ const children = source === null || source === void 0 ? void 0 : source.getChildren();
54811
+ if (source === undefined || (children === null || children === void 0 ? void 0 : children.length) !== 4) {
54812
+ continue;
54813
+ }
54814
+ // make sure to convert to the correct type, RTTI might be used on the result of XSDBOOL
54815
+ const code = "CONV xsdboolean( boolc( " + children[2].concatTokens() + " ) )";
54816
+ const fix = edit_helper_1.EditHelper.replaceRange(lowFile, source.getFirstToken().getStart(), source.getLastToken().getEnd(), code);
54773
54817
  return issue_1.Issue.atToken(lowFile, token, "Use BOOLC", this.getMetadata().key, this.conf.severity, fix);
54774
54818
  }
54775
54819
  }
@@ -73860,7 +73904,11 @@ class CallFunctionTranspiler {
73860
73904
  ret.appendString(`await abap.statements.callFunction({name:${fmname},destination:${s.getCode()}${param}});`);
73861
73905
  }
73862
73906
  else {
73863
- ret.appendString(`await abap.FunctionModules[${fmname}](${param});`);
73907
+ const illegalFunc = traversal.lookupClassOrInterface("'CX_SY_DYN_CALL_ILLEGAL_FUNC'", node.getFirstToken(), true);
73908
+ const call = `abap.FunctionModules[${fmname}]`;
73909
+ ret.appendString(`if (${call} === undefined && ${illegalFunc} === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_FUNC not found"; }\n`);
73910
+ ret.appendString(`if (${call} === undefined) { throw new ${illegalFunc}(); }\n`);
73911
+ ret.appendString(`await ${call}(${param});`);
73864
73912
  }
73865
73913
  if (exceptions) {
73866
73914
  const build = call_1.CallTranspiler.buildExceptions(exceptions);
@@ -82046,10 +82094,19 @@ Builder.prototype.j2x = function(jObj, level) {
82046
82094
  let val = '';
82047
82095
  for (let key in jObj) {
82048
82096
  if (typeof jObj[key] === 'undefined') {
82049
- // supress undefined node
82097
+ // supress undefined node only if it is not an attribute
82098
+ if (this.isAttribute(key)) {
82099
+ val += '';
82100
+ }
82050
82101
  } else if (jObj[key] === null) {
82051
- if(key[0] === "?") val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;
82052
- else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
82102
+ // null attribute should be ignored by the attribute list, but should not cause the tag closing
82103
+ if (this.isAttribute(key)) {
82104
+ val += '';
82105
+ } else if (key[0] === '?') {
82106
+ val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;
82107
+ } else {
82108
+ val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
82109
+ }
82053
82110
  // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
82054
82111
  } else if (jObj[key] instanceof Date) {
82055
82112
  val += this.buildTextValNode(jObj[key], key, '', level);
@@ -82142,7 +82199,8 @@ Builder.prototype.buildObjectNode = function(val, key, attrStr, level) {
82142
82199
  tagEndExp = "";
82143
82200
  }
82144
82201
 
82145
- if (attrStr && val.indexOf('<') === -1) {
82202
+ // attrStr is an empty string in case the attribute came as undefined or null
82203
+ if ((attrStr || attrStr === '') && val.indexOf('<') === -1) {
82146
82204
  return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp );
82147
82205
  } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
82148
82206
  return this.indentate(level) + `<!--${val}-->` + this.newLine;
@@ -82215,7 +82273,7 @@ function indentate(level) {
82215
82273
  }
82216
82274
 
82217
82275
  function isAttribute(name /*, options*/) {
82218
- if (name.startsWith(this.options.attributeNamePrefix)) {
82276
+ if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {
82219
82277
  return name.substr(this.attrPrefixLen);
82220
82278
  } else {
82221
82279
  return false;
@@ -92527,6 +92585,17 @@ module.exports = require("child_process");
92527
92585
 
92528
92586
  /***/ }),
92529
92587
 
92588
+ /***/ "crypto":
92589
+ /*!*************************!*\
92590
+ !*** external "crypto" ***!
92591
+ \*************************/
92592
+ /***/ ((module) => {
92593
+
92594
+ "use strict";
92595
+ module.exports = require("crypto");
92596
+
92597
+ /***/ }),
92598
+
92530
92599
  /***/ "events":
92531
92600
  /*!*************************!*\
92532
92601
  !*** external "events" ***!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.7.54",
3
+ "version": "2.7.56",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -26,12 +26,12 @@
26
26
  "author": "abaplint",
27
27
  "license": "MIT",
28
28
  "devDependencies": {
29
- "@abaplint/transpiler": "^2.7.54",
29
+ "@abaplint/transpiler": "^2.7.56",
30
30
  "@types/glob": "^7.2.0",
31
31
  "glob": "=7.2.0",
32
32
  "@types/progress": "^2.0.5",
33
33
  "@types/node": "^20.4.5",
34
- "@abaplint/core": "^2.102.7",
34
+ "@abaplint/core": "^2.102.14",
35
35
  "progress": "^2.0.3",
36
36
  "webpack": "^5.88.2",
37
37
  "webpack-cli": "^5.1.4",