@abaplint/transpiler-cli 2.6.38 → 2.6.40

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 +167 -22
  2. package/package.json +4 -4
package/build/bundle.js CHANGED
@@ -19653,6 +19653,9 @@ class CurrentScope {
19653
19653
  return undefined;
19654
19654
  }
19655
19655
  const typePoolName = name.split("_")[0];
19656
+ if (typePoolName.length !== 4) {
19657
+ return undefined;
19658
+ }
19656
19659
  const typePool = this.reg.getObject("TYPE", typePoolName);
19657
19660
  if (typePool === undefined) {
19658
19661
  return undefined;
@@ -19667,6 +19670,11 @@ class CurrentScope {
19667
19670
  return undefined;
19668
19671
  }
19669
19672
  const typePoolName = name.split("_")[0];
19673
+ if (typePoolName.length !== 4 || new ddic_1.DDIC(this.reg).lookupNoVoid(name) !== undefined) {
19674
+ // this is tricky, it should not do recursion when parsing the type pool itself,
19675
+ // think about DTEL ABAP_ENCOD vs TYPE ABAP
19676
+ return undefined;
19677
+ }
19670
19678
  const typePool = this.reg.getObject("TYPE", typePoolName);
19671
19679
  if (typePool === undefined) {
19672
19680
  return undefined;
@@ -20593,7 +20601,7 @@ class TypeUtils {
20593
20601
  return false;
20594
20602
  }
20595
20603
  isAssignableStrict(source, target) {
20596
- var _a, _b;
20604
+ var _a, _b, _c, _d;
20597
20605
  /*
20598
20606
  console.dir(source);
20599
20607
  console.dir(target);
@@ -20612,6 +20620,20 @@ class TypeUtils {
20612
20620
  return false;
20613
20621
  }
20614
20622
  }
20623
+ else if (source instanceof basic_1.HexType) {
20624
+ if (target instanceof basic_1.HexType) {
20625
+ if (((_c = source.getAbstractTypeData()) === null || _c === void 0 ? void 0 : _c.derivedFromConstant) === true) {
20626
+ return source.getLength() <= target.getLength();
20627
+ }
20628
+ return source.getLength() === target.getLength();
20629
+ }
20630
+ else if (target instanceof basic_1.IntegerType) {
20631
+ if (((_d = source.getAbstractTypeData()) === null || _d === void 0 ? void 0 : _d.derivedFromConstant) === true) {
20632
+ return true;
20633
+ }
20634
+ return false;
20635
+ }
20636
+ }
20615
20637
  else if (source instanceof basic_1.StringType && target instanceof basic_1.StructureType) {
20616
20638
  if (this.structureContainsString(target)) {
20617
20639
  return false;
@@ -20948,7 +20970,7 @@ class BasicTypes {
20948
20970
  if (type instanceof basic_1.CharacterType
20949
20971
  && qualifiedName
20950
20972
  && qualifiedName.includes("-") === false) {
20951
- type = type.cloneType(qualifiedName);
20973
+ type = type.cloneType({ qualifiedName });
20952
20974
  }
20953
20975
  return type;
20954
20976
  }
@@ -22640,10 +22662,26 @@ class FieldChain {
22640
22662
  context = new attribute_name_1.AttributeName().runSyntax(context, current, scope, filename, refType);
22641
22663
  }
22642
22664
  else if (current.get() instanceof Expressions.FieldOffset && current instanceof nodes_1.ExpressionNode) {
22643
- new field_offset_1.FieldOffset().runSyntax(current, scope, filename);
22665
+ const offset = new field_offset_1.FieldOffset().runSyntax(current, scope, filename);
22666
+ if (offset) {
22667
+ if (context instanceof basic_1.CharacterType) {
22668
+ context = new basic_1.CharacterType(context.getLength() - offset);
22669
+ }
22670
+ else if (context instanceof basic_1.HexType) {
22671
+ context = new basic_1.HexType(context.getLength() - offset);
22672
+ }
22673
+ }
22644
22674
  }
22645
22675
  else if (current.get() instanceof Expressions.FieldLength && current instanceof nodes_1.ExpressionNode) {
22646
- new field_length_1.FieldLength().runSyntax(current, scope, filename);
22676
+ const length = new field_length_1.FieldLength().runSyntax(current, scope, filename);
22677
+ if (length) {
22678
+ if (context instanceof basic_1.CharacterType) {
22679
+ context = new basic_1.CharacterType(length);
22680
+ }
22681
+ else if (context instanceof basic_1.HexType) {
22682
+ context = new basic_1.HexType(length);
22683
+ }
22684
+ }
22647
22685
  }
22648
22686
  }
22649
22687
  return context;
@@ -22706,6 +22744,15 @@ class FieldLength {
22706
22744
  const field = node.findDirectExpression(Expressions.SimpleFieldChain2);
22707
22745
  if (field) {
22708
22746
  new field_chain_1.FieldChain().runSyntax(field, scope, filename, _reference_1.ReferenceType.DataReadReference);
22747
+ return undefined;
22748
+ }
22749
+ else {
22750
+ const children = node.getChildren();
22751
+ const num = children[children.length - 2];
22752
+ if (num.getLastToken().getStr() === "*") {
22753
+ return undefined;
22754
+ }
22755
+ return parseInt(num.getLastToken().getStr(), 10);
22709
22756
  }
22710
22757
  }
22711
22758
  }
@@ -22732,6 +22779,10 @@ class FieldOffset {
22732
22779
  const field = node.findDirectExpression(Expressions.SimpleFieldChain2);
22733
22780
  if (field) {
22734
22781
  new field_chain_1.FieldChain().runSyntax(field, scope, filename, _reference_1.ReferenceType.DataReadReference);
22782
+ return undefined;
22783
+ }
22784
+ else {
22785
+ return parseInt(node.getLastToken().getStr(), 10);
22735
22786
  }
22736
22787
  }
22737
22788
  }
@@ -32928,13 +32979,16 @@ class CharacterType extends _abstract_type_1.AbstractType {
32928
32979
  }
32929
32980
  this.length = length;
32930
32981
  }
32931
- cloneType(qualifiedName, ddicName) {
32982
+ cloneType(input) {
32932
32983
  const clone = Object.assign({}, this.getAbstractTypeData()) || {};
32933
- if (qualifiedName) {
32934
- clone.qualifiedName = qualifiedName;
32984
+ if (input.qualifiedName) {
32985
+ clone.qualifiedName = input.qualifiedName;
32986
+ }
32987
+ if (input.ddicName) {
32988
+ clone.ddicName = input.ddicName;
32935
32989
  }
32936
- if (ddicName) {
32937
- clone.ddicName = ddicName;
32990
+ if (input.derivedFromConstant) {
32991
+ clone.derivedFromConstant = input.derivedFromConstant;
32938
32992
  }
32939
32993
  return new CharacterType(this.length, clone);
32940
32994
  }
@@ -43648,6 +43702,10 @@ class MIMEObject extends _abstract_object_1.AbstractObject {
43648
43702
  this.parse();
43649
43703
  return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.CLASS;
43650
43704
  }
43705
+ isFolder() {
43706
+ var _a;
43707
+ return ((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.FOLDER) === "X";
43708
+ }
43651
43709
  getAllowedNaming() {
43652
43710
  return {
43653
43711
  maxLength: 32,
@@ -43685,6 +43743,7 @@ class MIMEObject extends _abstract_object_1.AbstractObject {
43685
43743
  }
43686
43744
  this.parsedXML.URL = parsed.abapGit["asx:abap"]["asx:values"].URL;
43687
43745
  this.parsedXML.CLASS = parsed.abapGit["asx:abap"]["asx:values"].CLASS;
43746
+ this.parsedXML.FOLDER = parsed.abapGit["asx:abap"]["asx:values"].FOLDER;
43688
43747
  const end = Date.now();
43689
43748
  return { updated: true, runtime: end - start };
43690
43749
  }
@@ -46550,7 +46609,7 @@ class Registry {
46550
46609
  }
46551
46610
  static abaplintVersion() {
46552
46611
  // magic, see build script "version.sh"
46553
- return "2.98.3";
46612
+ return "2.99.3";
46554
46613
  }
46555
46614
  getDDICReferences() {
46556
46615
  return this.references;
@@ -56538,6 +56597,7 @@ __exportStar(__webpack_require__(/*! ./sequential_blank */ "./node_modules/@abap
56538
56597
  __exportStar(__webpack_require__(/*! ./short_case */ "./node_modules/@abaplint/core/build/src/rules/short_case.js"), exports);
56539
56598
  __exportStar(__webpack_require__(/*! ./sicf_consistency */ "./node_modules/@abaplint/core/build/src/rules/sicf_consistency.js"), exports);
56540
56599
  __exportStar(__webpack_require__(/*! ./slow_parameter_passing */ "./node_modules/@abaplint/core/build/src/rules/slow_parameter_passing.js"), exports);
56600
+ __exportStar(__webpack_require__(/*! ./smim_consistency */ "./node_modules/@abaplint/core/build/src/rules/smim_consistency.js"), exports);
56541
56601
  __exportStar(__webpack_require__(/*! ./space_before_colon */ "./node_modules/@abaplint/core/build/src/rules/space_before_colon.js"), exports);
56542
56602
  __exportStar(__webpack_require__(/*! ./space_before_dot */ "./node_modules/@abaplint/core/build/src/rules/space_before_dot.js"), exports);
56543
56603
  __exportStar(__webpack_require__(/*! ./sql_escape_host_variables */ "./node_modules/@abaplint/core/build/src/rules/sql_escape_host_variables.js"), exports);
@@ -60557,6 +60617,7 @@ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/co
60557
60617
  const Expressions = __webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
60558
60618
  const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
60559
60619
  const statements_1 = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
60620
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
60560
60621
  class OmitPrecedingZerosConf extends _basic_rule_config_1.BasicRuleConfig {
60561
60622
  }
60562
60623
  exports.OmitPrecedingZerosConf = OmitPrecedingZerosConf;
@@ -60570,7 +60631,7 @@ class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
60570
60631
  key: "omit_preceding_zeros",
60571
60632
  title: "Omit preceding zeros",
60572
60633
  shortDescription: `Omit preceding zeros from integer constants`,
60573
- tags: [_irule_1.RuleTag.SingleFile],
60634
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
60574
60635
  badExample: `int = -001.`,
60575
60636
  goodExample: `int = -1.`,
60576
60637
  };
@@ -60582,7 +60643,9 @@ class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
60582
60643
  this.conf = conf;
60583
60644
  }
60584
60645
  runParsed(file) {
60646
+ var _a;
60585
60647
  const issues = [];
60648
+ const message = "Omit preceding zeros";
60586
60649
  for (const s of file.getStatements()) {
60587
60650
  for (const i of s.findAllExpressions(Expressions.Integer)) {
60588
60651
  const token = i.getLastToken();
@@ -60591,8 +60654,19 @@ class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
60591
60654
  if (s.get() instanceof statements_1.CallScreen || s.get() instanceof statements_1.SetScreen) {
60592
60655
  continue;
60593
60656
  }
60594
- const message = "Omit preceding zeros";
60595
- const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity);
60657
+ const replace = str.replace(/^0+/, "");
60658
+ const fix = edit_helper_1.EditHelper.replaceRange(file, token.getStart(), token.getEnd(), replace);
60659
+ const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity, fix);
60660
+ issues.push(issue);
60661
+ }
60662
+ }
60663
+ for (const i of s.findAllExpressions(Expressions.ParameterException)) {
60664
+ const token = (_a = i.findDirectExpression(Expressions.SimpleName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
60665
+ const str = token === null || token === void 0 ? void 0 : token.getStr();
60666
+ if (token && str && str.length > 1 && str.startsWith("0")) {
60667
+ const replace = str.replace(/^0+/, "");
60668
+ const fix = edit_helper_1.EditHelper.replaceRange(file, token.getStart(), token.getEnd(), replace);
60669
+ const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity, fix);
60596
60670
  issues.push(issue);
60597
60671
  }
60598
60672
  }
@@ -63288,6 +63362,79 @@ exports.SlowParameterPassing = SlowParameterPassing;
63288
63362
 
63289
63363
  /***/ }),
63290
63364
 
63365
+ /***/ "./node_modules/@abaplint/core/build/src/rules/smim_consistency.js":
63366
+ /*!*************************************************************************!*\
63367
+ !*** ./node_modules/@abaplint/core/build/src/rules/smim_consistency.js ***!
63368
+ \*************************************************************************/
63369
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
63370
+
63371
+ "use strict";
63372
+
63373
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
63374
+ exports.SMIMConsistency = exports.SMIMConsistencyConf = void 0;
63375
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
63376
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
63377
+ const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplint/core/build/src/objects/index.js");
63378
+ const position_1 = __webpack_require__(/*! ../position */ "./node_modules/@abaplint/core/build/src/position.js");
63379
+ class SMIMConsistencyConf extends _basic_rule_config_1.BasicRuleConfig {
63380
+ }
63381
+ exports.SMIMConsistencyConf = SMIMConsistencyConf;
63382
+ class SMIMConsistency {
63383
+ constructor() {
63384
+ this.conf = new SMIMConsistencyConf();
63385
+ }
63386
+ getMetadata() {
63387
+ return {
63388
+ key: "smim_consistency",
63389
+ title: "SMIM consistency check",
63390
+ shortDescription: `SMIM consistency check`,
63391
+ extendedInformation: "Check folders exists",
63392
+ };
63393
+ }
63394
+ getConfig() {
63395
+ return this.conf;
63396
+ }
63397
+ setConfig(conf) {
63398
+ this.conf = conf;
63399
+ }
63400
+ initialize(reg) {
63401
+ this.reg = reg;
63402
+ return this;
63403
+ }
63404
+ run(obj) {
63405
+ const issues = [];
63406
+ if (!(obj instanceof objects_1.MIMEObject)) {
63407
+ return [];
63408
+ }
63409
+ const base = this.base(obj.getURL() || "");
63410
+ if (base !== "" && this.findFolder(base) === false) {
63411
+ const message = `Parent folder "${base}" not found`;
63412
+ const position = new position_1.Position(1, 1);
63413
+ const issue = issue_1.Issue.atPosition(obj.getFiles()[0], position, message, this.getMetadata().key, this.conf.severity);
63414
+ issues.push(issue);
63415
+ }
63416
+ return issues;
63417
+ }
63418
+ base(full) {
63419
+ const components = full.split("/");
63420
+ components.pop();
63421
+ return components.join("/");
63422
+ }
63423
+ findFolder(base) {
63424
+ for (const smim of this.reg.getObjectsByType("SMIM")) {
63425
+ const mime = smim;
63426
+ if (base === mime.getURL() && mime.isFolder() === true) {
63427
+ return true;
63428
+ }
63429
+ }
63430
+ return false;
63431
+ }
63432
+ }
63433
+ exports.SMIMConsistency = SMIMConsistency;
63434
+ //# sourceMappingURL=smim_consistency.js.map
63435
+
63436
+ /***/ }),
63437
+
63291
63438
  /***/ "./node_modules/@abaplint/core/build/src/rules/space_before_colon.js":
63292
63439
  /*!***************************************************************************!*\
63293
63440
  !*** ./node_modules/@abaplint/core/build/src/rules/space_before_colon.js ***!
@@ -75002,6 +75149,7 @@ exports.RaiseTranspiler = void 0;
75002
75149
  const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
75003
75150
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
75004
75151
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
75152
+ const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
75005
75153
  class RaiseTranspiler {
75006
75154
  transpile(node, traversal) {
75007
75155
  var _a, _b;
@@ -75021,15 +75169,12 @@ class RaiseTranspiler {
75021
75169
  if (parameters) {
75022
75170
  p = traversal.traverse(parameters).getCode();
75023
75171
  }
75024
- const extra = `"INTERNAL_FILENAME": "${traversal.getFilename()}","INTERNAL_LINE": ${node.getStart().getRow()}`;
75025
- if (p === "") {
75026
- p = "{" + extra + "}";
75027
- }
75028
- else {
75029
- p = p.substring(0, p.length - 1) + "," + extra + "}";
75030
- }
75031
- const look = traversal.lookupClassOrInterface(classNameToken === null || classNameToken === void 0 ? void 0 : classNameToken.getStr(), classNameToken);
75032
- return new chunk_1.Chunk().append(`throw await (new ${look}()).constructor_(${p});`, node, traversal);
75172
+ const extra = `{"INTERNAL_FILENAME": "${traversal.getFilename()}","INTERNAL_LINE": ${node.getStart().getRow()}}`;
75173
+ const lookup = traversal.lookupClassOrInterface(classNameToken === null || classNameToken === void 0 ? void 0 : classNameToken.getStr(), classNameToken);
75174
+ const id = unique_identifier_1.UniqueIdentifier.get();
75175
+ return new chunk_1.Chunk().append(`const ${id} = await (new ${lookup}()).constructor_(${p});
75176
+ ${id}.EXTRA_CX = ${extra};
75177
+ throw ${id};`, node, traversal);
75033
75178
  }
75034
75179
  }
75035
75180
  exports.RaiseTranspiler = RaiseTranspiler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.6.38",
3
+ "version": "2.6.40",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,12 +25,12 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.6.38",
28
+ "@abaplint/transpiler": "^2.6.40",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",
32
- "@types/node": "^18.16.2",
33
- "@abaplint/core": "^2.98.3",
32
+ "@types/node": "^18.16.3",
33
+ "@abaplint/core": "^2.99.3",
34
34
  "progress": "^2.0.3",
35
35
  "webpack": "^5.81.0",
36
36
  "webpack-cli": "^5.0.2",