@abaplint/transpiler-cli 2.4.7 → 2.4.9

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 +107 -90
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -7322,7 +7322,7 @@ const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules
7322
7322
  class Throw extends combi_1.Expression {
7323
7323
  getRunnable() {
7324
7324
  // todo, MESSAGE
7325
- return (0, combi_1.seq)("THROW", (0, combi_1.opt)("RESUMABLE"), _1.ClassName, (0, combi_1.tok)(tokens_1.ParenLeftW), (0, combi_1.opt)((0, combi_1.alt)(_1.Source, _1.ParameterListS)), (0, combi_1.tok)(tokens_1.WParenRightW));
7325
+ return (0, combi_1.seq)("THROW", (0, combi_1.opt)("RESUMABLE"), _1.ClassName, (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenLeftW), (0, combi_1.tok)(tokens_1.ParenLeft)), (0, combi_1.opt)((0, combi_1.alt)(_1.Source, _1.ParameterListS)), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WParenRightW), (0, combi_1.tok)(tokens_1.ParenRightW)));
7326
7326
  }
7327
7327
  }
7328
7328
  exports.Throw = Throw;
@@ -21431,16 +21431,17 @@ const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@ab
21431
21431
  const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
21432
21432
  const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
21433
21433
  const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
21434
+ const basic_types_1 = __webpack_require__(/*! ../basic_types */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js");
21434
21435
  class Cast {
21435
21436
  runSyntax(node, scope, targetType, filename) {
21436
- var _a;
21437
21437
  const sourceNode = node.findDirectExpression(Expressions.Source);
21438
21438
  if (sourceNode === undefined) {
21439
21439
  throw new Error("Cast, source node not found");
21440
21440
  }
21441
21441
  const sourceType = new source_1.Source().runSyntax(sourceNode, scope, filename);
21442
21442
  let tt = undefined;
21443
- const typeName = (_a = node.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
21443
+ const typeExpression = node.findDirectExpression(Expressions.TypeNameOrInfer);
21444
+ const typeName = typeExpression === null || typeExpression === void 0 ? void 0 : typeExpression.concatTokens();
21444
21445
  if (typeName === undefined) {
21445
21446
  throw new Error("Cast, child TypeNameOrInfer not found");
21446
21447
  }
@@ -21450,18 +21451,28 @@ class Cast {
21450
21451
  else if (typeName === "#") {
21451
21452
  throw new Error("Cast, todo, infer type");
21452
21453
  }
21453
- if (tt === undefined) {
21454
- const found = scope.findObjectDefinition(typeName);
21455
- if (found === undefined && scope.getDDIC().inErrorNamespace(typeName) === false) {
21454
+ if (tt === undefined && typeExpression) {
21455
+ const basic = new basic_types_1.BasicTypes(filename, scope);
21456
+ tt = basic.parseType(typeExpression);
21457
+ if (tt === undefined || tt instanceof basic_1.VoidType || tt instanceof basic_1.UnknownType) {
21458
+ const found = scope.findObjectDefinition(typeName);
21459
+ if (found) {
21460
+ tt = new basic_1.ObjectReferenceType(found, typeName);
21461
+ }
21462
+ }
21463
+ else {
21464
+ tt = new basic_1.DataReference(tt, typeName);
21465
+ }
21466
+ if (tt === undefined && scope.getDDIC().inErrorNamespace(typeName) === false) {
21456
21467
  tt = new basic_1.VoidType(typeName);
21457
21468
  }
21458
- else if (found === undefined) {
21469
+ else if (typeName.toUpperCase() === "OBJECT") {
21470
+ return new basic_1.GenericObjectReferenceType();
21471
+ }
21472
+ else if (tt === undefined) {
21459
21473
  // todo, this should be an UnknownType instead?
21460
21474
  throw new Error("Type \"" + typeName + "\" not found in scope, Cast");
21461
21475
  }
21462
- else {
21463
- tt = new basic_1.ObjectReferenceType(found, typeName);
21464
- }
21465
21476
  }
21466
21477
  new source_1.Source().addIfInferred(node, scope, filename, tt);
21467
21478
  if (new _type_utils_1.TypeUtils(scope).isCastable(sourceType, tt) === false) {
@@ -24583,6 +24594,11 @@ class ValueBody {
24583
24594
  if (node === undefined) {
24584
24595
  return targetType;
24585
24596
  }
24597
+ let letScoped = false;
24598
+ const letNode = node.findDirectExpression(Expressions.Let);
24599
+ if (letNode) {
24600
+ letScoped = new let_1.Let().runSyntax(letNode, scope, filename);
24601
+ }
24586
24602
  let forScopes = 0;
24587
24603
  for (const forNode of node.findDirectExpressions(Expressions.For) || []) {
24588
24604
  const scoped = new for_1.For().runSyntax(forNode, scope, filename);
@@ -24590,11 +24606,6 @@ class ValueBody {
24590
24606
  forScopes++;
24591
24607
  }
24592
24608
  }
24593
- let letScoped = false;
24594
- const letNode = node.findDirectExpression(Expressions.Let);
24595
- if (letNode) {
24596
- letScoped = new let_1.Let().runSyntax(letNode, scope, filename);
24597
- }
24598
24609
  for (const s of node.findDirectExpressions(Expressions.FieldAssignment)) {
24599
24610
  new field_assignment_1.FieldAssignment().runSyntax(s, scope, filename, targetType);
24600
24611
  }
@@ -27992,6 +28003,9 @@ class Parameter {
27992
28003
  runSyntax(node, scope, filename) {
27993
28004
  var _a;
27994
28005
  const nameToken = (_a = node.findFirstExpression(Expressions.FieldSub)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
28006
+ if (nameToken && nameToken.getStr().length > 8) {
28007
+ throw new Error("Parameter name too long, " + nameToken.getStr());
28008
+ }
27995
28009
  const bfound = new basic_types_1.BasicTypes(filename, scope).parseType(node);
27996
28010
  if (nameToken && bfound) {
27997
28011
  scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(nameToken, filename, bfound));
@@ -28641,6 +28655,9 @@ class SelectOption {
28641
28655
  runSyntax(node, scope, filename) {
28642
28656
  var _a;
28643
28657
  const nameToken = (_a = node.findFirstExpression(Expressions.FieldSub)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
28658
+ if (nameToken && nameToken.getStr().length > 8) {
28659
+ throw new Error("Select-option name too long, " + nameToken.getStr());
28660
+ }
28644
28661
  for (const d of node.findDirectExpressions(Expressions.Dynamic)) {
28645
28662
  new dynamic_1.Dynamic().runSyntax(d, scope, filename);
28646
28663
  }
@@ -44407,8 +44424,12 @@ class Table extends _abstract_object_1.AbstractObject {
44407
44424
  return undefined;
44408
44425
  }
44409
44426
  getAllowedNaming() {
44427
+ let length = 30;
44428
+ if (this.getTableCategory() === TableCategory.Transparent) {
44429
+ length = 16;
44430
+ }
44410
44431
  return {
44411
- maxLength: 30,
44432
+ maxLength: length,
44412
44433
  allowNamespace: true,
44413
44434
  };
44414
44435
  }
@@ -44963,7 +44984,7 @@ class View extends _abstract_object_1.AbstractObject {
44963
44984
  }
44964
44985
  getAllowedNaming() {
44965
44986
  return {
44966
- maxLength: 30,
44987
+ maxLength: 16,
44967
44988
  allowNamespace: true,
44968
44989
  };
44969
44990
  }
@@ -45829,7 +45850,7 @@ class Registry {
45829
45850
  }
45830
45851
  static abaplintVersion() {
45831
45852
  // magic, see build script "version.sh"
45832
- return "2.95.9";
45853
+ return "2.95.13";
45833
45854
  }
45834
45855
  getDDICReferences() {
45835
45856
  return this.references;
@@ -73708,6 +73729,7 @@ exports.RetryTranspiler = RetryTranspiler;
73708
73729
 
73709
73730
  Object.defineProperty(exports, "__esModule", ({ value: true }));
73710
73731
  exports.ReturnTranspiler = void 0;
73732
+ const abaplint = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
73711
73733
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
73712
73734
  const unique_identifier_1 = __webpack_require__(/*! ../unique_identifier */ "./node_modules/@abaplint/transpiler/build/src/unique_identifier.js");
73713
73735
  class ReturnTranspiler {
@@ -73725,6 +73747,10 @@ class ReturnTranspiler {
73725
73747
  if (traversal.isInsideDoOrWhile(node)) {
73726
73748
  pre = `abap.builtin.sy.get().index.set(${unique_identifier_1.UniqueIdentifier.getIndexBackup1()});\n`;
73727
73749
  }
73750
+ if ((scope === null || scope === void 0 ? void 0 : scope.getIdentifier().stype) === abaplint.ScopeType.Method
73751
+ && (scope === null || scope === void 0 ? void 0 : scope.getIdentifier().sname.toLowerCase()) === "constructor") {
73752
+ extra = " this";
73753
+ }
73728
73754
  return new chunk_1.Chunk().append(pre + "return" + extra + ";", node, traversal);
73729
73755
  }
73730
73756
  }
@@ -77770,20 +77796,6 @@ function Builder(options) {
77770
77796
  this.tagEndChar = '>';
77771
77797
  this.newLine = '';
77772
77798
  }
77773
-
77774
- if (this.options.suppressEmptyNode) {
77775
- this.buildTextNode = buildEmptyTextNode;
77776
- this.buildObjNode = buildEmptyObjNode;
77777
- } else {
77778
- this.buildTextNode = buildTextValNode;
77779
- this.buildObjNode = buildObjectNode;
77780
- }
77781
-
77782
- this.buildTextValNode = buildTextValNode;
77783
- this.buildObjectNode = buildObjectNode;
77784
-
77785
- this.replaceEntitiesValue = replaceEntitiesValue;
77786
- this.buildAttrPairStr = buildAttrPairStr;
77787
77799
  }
77788
77800
 
77789
77801
  Builder.prototype.build = function(jObj) {
@@ -77810,7 +77822,7 @@ Builder.prototype.j2x = function(jObj, level) {
77810
77822
  else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
77811
77823
  // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
77812
77824
  } else if (jObj[key] instanceof Date) {
77813
- val += this.buildTextNode(jObj[key], key, '', level);
77825
+ val += this.buildTextValNode(jObj[key], key, '', level);
77814
77826
  } else if (typeof jObj[key] !== 'object') {
77815
77827
  //premitive type
77816
77828
  const attr = this.isAttribute(key);
@@ -77822,7 +77834,7 @@ Builder.prototype.j2x = function(jObj, level) {
77822
77834
  let newval = this.options.tagValueProcessor(key, '' + jObj[key]);
77823
77835
  val += this.replaceEntitiesValue(newval);
77824
77836
  } else {
77825
- val += this.buildTextNode(jObj[key], key, '', level);
77837
+ val += this.buildTextValNode(jObj[key], key, '', level);
77826
77838
  }
77827
77839
  }
77828
77840
  } else if (Array.isArray(jObj[key])) {
@@ -77839,7 +77851,7 @@ Builder.prototype.j2x = function(jObj, level) {
77839
77851
  } else if (typeof item === 'object') {
77840
77852
  val += this.processTextOrObjNode(item, key, level)
77841
77853
  } else {
77842
- val += this.buildTextNode(item, key, '', level);
77854
+ val += this.buildTextValNode(item, key, '', level);
77843
77855
  }
77844
77856
  }
77845
77857
  } else {
@@ -77858,7 +77870,7 @@ Builder.prototype.j2x = function(jObj, level) {
77858
77870
  return {attrStr: attrStr, val: val};
77859
77871
  };
77860
77872
 
77861
- function buildAttrPairStr(attrName, val){
77873
+ Builder.prototype.buildAttrPairStr = function(attrName, val){
77862
77874
  val = this.options.attributeValueProcessor(attrName, '' + val);
77863
77875
  val = this.replaceEntitiesValue(val);
77864
77876
  if (this.options.suppressBooleanAttributes && val === "true") {
@@ -77869,31 +77881,51 @@ function buildAttrPairStr(attrName, val){
77869
77881
  function processTextOrObjNode (object, key, level) {
77870
77882
  const result = this.j2x(object, level + 1);
77871
77883
  if (object[this.options.textNodeName] !== undefined && Object.keys(object).length === 1) {
77872
- return this.buildTextNode(object[this.options.textNodeName], key, result.attrStr, level);
77884
+ return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
77873
77885
  } else {
77874
- return this.buildObjNode(result.val, key, result.attrStr, level);
77886
+ return this.buildObjectNode(result.val, key, result.attrStr, level);
77875
77887
  }
77876
77888
  }
77877
77889
 
77878
- function buildObjectNode(val, key, attrStr, level) {
77879
- let tagEndExp = '</' + key + this.tagEndChar;
77880
- let piClosingChar = "";
77890
+ Builder.prototype.buildObjectNode = function(val, key, attrStr, level) {
77891
+ if(val === ""){
77892
+ if(key[0] === "?") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;
77893
+ else {
77894
+ return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;
77895
+ }
77896
+ }else{
77897
+
77898
+ let tagEndExp = '</' + key + this.tagEndChar;
77899
+ let piClosingChar = "";
77900
+
77901
+ if(key[0] === "?") {
77902
+ piClosingChar = "?";
77903
+ tagEndExp = "";
77904
+ }
77881
77905
 
77882
- if(key[0] === "?") {
77883
- piClosingChar = "?";
77884
- tagEndExp = "";
77906
+ if (attrStr && val.indexOf('<') === -1) {
77907
+ return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp );
77908
+ } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
77909
+ return this.indentate(level) + `<!--${val}-->` + this.newLine;
77910
+ }else {
77911
+ return (
77912
+ this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar +
77913
+ val +
77914
+ this.indentate(level) + tagEndExp );
77915
+ }
77885
77916
  }
77917
+ }
77886
77918
 
77887
- if (attrStr && val.indexOf('<') === -1) {
77888
- return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp );
77889
- } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
77890
- return this.indentate(level) + `<!--${val}-->` + this.newLine;
77891
- }else {
77892
- return (
77893
- this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar +
77894
- val +
77895
- this.indentate(level) + tagEndExp );
77919
+ Builder.prototype.closeTag = function(key){
77920
+ let closeTag = "";
77921
+ if(this.options.unpairedTags.indexOf(key) !== -1){ //unpaired
77922
+ if(!this.options.suppressUnpairedNode) closeTag = "/"
77923
+ }else if(this.options.suppressEmptyNode){ //empty
77924
+ closeTag = "/";
77925
+ }else{
77926
+ closeTag = `></${key}`
77896
77927
  }
77928
+ return closeTag;
77897
77929
  }
77898
77930
 
77899
77931
  function buildEmptyObjNode(val, key, attrStr, level) {
@@ -77901,36 +77933,35 @@ function buildEmptyObjNode(val, key, attrStr, level) {
77901
77933
  return this.buildObjectNode(val, key, attrStr, level);
77902
77934
  } else {
77903
77935
  if(key[0] === "?") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;
77904
- else return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar;
77936
+ else {
77937
+ return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar;
77938
+ // return this.buildTagStr(level,key, attrStr);
77939
+ }
77905
77940
  }
77906
77941
  }
77907
77942
 
77908
- function buildTextValNode(val, key, attrStr, level) {
77943
+ Builder.prototype.buildTextValNode = function(val, key, attrStr, level) {
77909
77944
  if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
77910
77945
  return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;
77911
77946
  }else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
77912
77947
  return this.indentate(level) + `<!--${val}-->` + this.newLine;
77948
+ }else if(key[0] === "?") {//PI tag
77949
+ return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;
77913
77950
  }else{
77914
77951
  let textValue = this.options.tagValueProcessor(key, val);
77915
77952
  textValue = this.replaceEntitiesValue(textValue);
77916
77953
 
77917
- if( textValue === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired
77918
- if(this.options.suppressUnpairedNode){
77919
- return this.indentate(level) + '<' + key + this.tagEndChar;
77920
- }else{
77921
- return this.indentate(level) + '<' + key + "/" + this.tagEndChar;
77922
- }
77923
- } else{
77924
- return (
77925
- this.indentate(level) + '<' + key + attrStr + '>' +
77954
+ if( textValue === ''){
77955
+ return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;
77956
+ }else{
77957
+ return this.indentate(level) + '<' + key + attrStr + '>' +
77926
77958
  textValue +
77927
- '</' + key + this.tagEndChar );
77959
+ '</' + key + this.tagEndChar;
77928
77960
  }
77929
-
77930
77961
  }
77931
77962
  }
77932
77963
 
77933
- function replaceEntitiesValue(textValue){
77964
+ Builder.prototype.replaceEntitiesValue = function(textValue){
77934
77965
  if(textValue && textValue.length > 0 && this.options.processEntities){
77935
77966
  for (let i=0; i<this.options.entities.length; i++) {
77936
77967
  const entity = this.options.entities[i];
@@ -77940,21 +77971,6 @@ function replaceEntitiesValue(textValue){
77940
77971
  return textValue;
77941
77972
  }
77942
77973
 
77943
- function buildEmptyTextNode(val, key, attrStr, level) {
77944
- if( val === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired
77945
- if(this.options.suppressUnpairedNode){
77946
- return this.indentate(level) + '<' + key + this.tagEndChar;
77947
- }else{
77948
- return this.indentate(level) + '<' + key + "/" + this.tagEndChar;
77949
- }
77950
- }else if (val !== '') { //empty
77951
- return this.buildTextValNode(val, key, attrStr, level);
77952
- } else {
77953
- if(key[0] === "?") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar; //PI tag
77954
- else return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar; //normal
77955
- }
77956
- }
77957
-
77958
77974
  function indentate(level) {
77959
77975
  return this.options.indentBy.repeat(level);
77960
77976
  }
@@ -78135,7 +78151,7 @@ function readDocType(xmlData, i){
78135
78151
  let hasBody = false, entity = false, comment = false;
78136
78152
  let exp = "";
78137
78153
  for(;i<xmlData.length;i++){
78138
- if (xmlData[i] === '<') {
78154
+ if (xmlData[i] === '<' && !comment) {
78139
78155
  if( hasBody &&
78140
78156
  xmlData[i+1] === '!' &&
78141
78157
  xmlData[i+2] === 'E' &&
@@ -78199,14 +78215,15 @@ function readDocType(xmlData, i){
78199
78215
  if(comment){
78200
78216
  if( xmlData[i - 1] === "-" && xmlData[i - 2] === "-"){
78201
78217
  comment = false;
78202
- }else{
78203
- throw new Error(`Invalid XML comment in DOCTYPE`);
78218
+ angleBracketsCount--;
78219
+ }
78220
+ }else{
78221
+ if(entity) {
78222
+ parseEntityExp(exp, entities);
78223
+ entity = false;
78204
78224
  }
78205
- }else if(entity){
78206
- parseEntityExp(exp, entities);
78207
- entity = false;
78225
+ angleBracketsCount--;
78208
78226
  }
78209
- angleBracketsCount--;
78210
78227
  if (angleBracketsCount === 0) {
78211
78228
  break;
78212
78229
  }
@@ -78262,7 +78279,7 @@ const defaultOptions = {
78262
78279
  numberParseOptions: {
78263
78280
  hex: true,
78264
78281
  leadingZeros: true,
78265
- eNotation: false
78282
+ eNotation: true
78266
78283
  },
78267
78284
  tagValueProcessor: function(tagName, val) {
78268
78285
  return val;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.4.7",
3
+ "version": "2.4.9",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,11 +25,11 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.4.7",
28
+ "@abaplint/transpiler": "^2.4.9",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",
32
- "@abaplint/core": "^2.95.9",
32
+ "@abaplint/core": "^2.95.13",
33
33
  "progress": "^2.0.3",
34
34
  "webpack": "^5.75.0",
35
35
  "webpack-cli": "^5.0.1",