@abaplint/transpiler-cli 2.4.8 → 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 +102 -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;
@@ -77775,20 +77796,6 @@ function Builder(options) {
77775
77796
  this.tagEndChar = '>';
77776
77797
  this.newLine = '';
77777
77798
  }
77778
-
77779
- if (this.options.suppressEmptyNode) {
77780
- this.buildTextNode = buildEmptyTextNode;
77781
- this.buildObjNode = buildEmptyObjNode;
77782
- } else {
77783
- this.buildTextNode = buildTextValNode;
77784
- this.buildObjNode = buildObjectNode;
77785
- }
77786
-
77787
- this.buildTextValNode = buildTextValNode;
77788
- this.buildObjectNode = buildObjectNode;
77789
-
77790
- this.replaceEntitiesValue = replaceEntitiesValue;
77791
- this.buildAttrPairStr = buildAttrPairStr;
77792
77799
  }
77793
77800
 
77794
77801
  Builder.prototype.build = function(jObj) {
@@ -77815,7 +77822,7 @@ Builder.prototype.j2x = function(jObj, level) {
77815
77822
  else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
77816
77823
  // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
77817
77824
  } else if (jObj[key] instanceof Date) {
77818
- val += this.buildTextNode(jObj[key], key, '', level);
77825
+ val += this.buildTextValNode(jObj[key], key, '', level);
77819
77826
  } else if (typeof jObj[key] !== 'object') {
77820
77827
  //premitive type
77821
77828
  const attr = this.isAttribute(key);
@@ -77827,7 +77834,7 @@ Builder.prototype.j2x = function(jObj, level) {
77827
77834
  let newval = this.options.tagValueProcessor(key, '' + jObj[key]);
77828
77835
  val += this.replaceEntitiesValue(newval);
77829
77836
  } else {
77830
- val += this.buildTextNode(jObj[key], key, '', level);
77837
+ val += this.buildTextValNode(jObj[key], key, '', level);
77831
77838
  }
77832
77839
  }
77833
77840
  } else if (Array.isArray(jObj[key])) {
@@ -77844,7 +77851,7 @@ Builder.prototype.j2x = function(jObj, level) {
77844
77851
  } else if (typeof item === 'object') {
77845
77852
  val += this.processTextOrObjNode(item, key, level)
77846
77853
  } else {
77847
- val += this.buildTextNode(item, key, '', level);
77854
+ val += this.buildTextValNode(item, key, '', level);
77848
77855
  }
77849
77856
  }
77850
77857
  } else {
@@ -77863,7 +77870,7 @@ Builder.prototype.j2x = function(jObj, level) {
77863
77870
  return {attrStr: attrStr, val: val};
77864
77871
  };
77865
77872
 
77866
- function buildAttrPairStr(attrName, val){
77873
+ Builder.prototype.buildAttrPairStr = function(attrName, val){
77867
77874
  val = this.options.attributeValueProcessor(attrName, '' + val);
77868
77875
  val = this.replaceEntitiesValue(val);
77869
77876
  if (this.options.suppressBooleanAttributes && val === "true") {
@@ -77874,31 +77881,51 @@ function buildAttrPairStr(attrName, val){
77874
77881
  function processTextOrObjNode (object, key, level) {
77875
77882
  const result = this.j2x(object, level + 1);
77876
77883
  if (object[this.options.textNodeName] !== undefined && Object.keys(object).length === 1) {
77877
- return this.buildTextNode(object[this.options.textNodeName], key, result.attrStr, level);
77884
+ return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
77878
77885
  } else {
77879
- return this.buildObjNode(result.val, key, result.attrStr, level);
77886
+ return this.buildObjectNode(result.val, key, result.attrStr, level);
77880
77887
  }
77881
77888
  }
77882
77889
 
77883
- function buildObjectNode(val, key, attrStr, level) {
77884
- let tagEndExp = '</' + key + this.tagEndChar;
77885
- 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
+ }
77886
77905
 
77887
- if(key[0] === "?") {
77888
- piClosingChar = "?";
77889
- 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
+ }
77890
77916
  }
77917
+ }
77891
77918
 
77892
- if (attrStr && val.indexOf('<') === -1) {
77893
- return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp );
77894
- } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
77895
- return this.indentate(level) + `<!--${val}-->` + this.newLine;
77896
- }else {
77897
- return (
77898
- this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar +
77899
- val +
77900
- 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}`
77901
77927
  }
77928
+ return closeTag;
77902
77929
  }
77903
77930
 
77904
77931
  function buildEmptyObjNode(val, key, attrStr, level) {
@@ -77906,36 +77933,35 @@ function buildEmptyObjNode(val, key, attrStr, level) {
77906
77933
  return this.buildObjectNode(val, key, attrStr, level);
77907
77934
  } else {
77908
77935
  if(key[0] === "?") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;
77909
- 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
+ }
77910
77940
  }
77911
77941
  }
77912
77942
 
77913
- function buildTextValNode(val, key, attrStr, level) {
77943
+ Builder.prototype.buildTextValNode = function(val, key, attrStr, level) {
77914
77944
  if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
77915
77945
  return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;
77916
77946
  }else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
77917
77947
  return this.indentate(level) + `<!--${val}-->` + this.newLine;
77948
+ }else if(key[0] === "?") {//PI tag
77949
+ return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;
77918
77950
  }else{
77919
77951
  let textValue = this.options.tagValueProcessor(key, val);
77920
77952
  textValue = this.replaceEntitiesValue(textValue);
77921
77953
 
77922
- if( textValue === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired
77923
- if(this.options.suppressUnpairedNode){
77924
- return this.indentate(level) + '<' + key + this.tagEndChar;
77925
- }else{
77926
- return this.indentate(level) + '<' + key + "/" + this.tagEndChar;
77927
- }
77928
- } else{
77929
- return (
77930
- 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 + '>' +
77931
77958
  textValue +
77932
- '</' + key + this.tagEndChar );
77959
+ '</' + key + this.tagEndChar;
77933
77960
  }
77934
-
77935
77961
  }
77936
77962
  }
77937
77963
 
77938
- function replaceEntitiesValue(textValue){
77964
+ Builder.prototype.replaceEntitiesValue = function(textValue){
77939
77965
  if(textValue && textValue.length > 0 && this.options.processEntities){
77940
77966
  for (let i=0; i<this.options.entities.length; i++) {
77941
77967
  const entity = this.options.entities[i];
@@ -77945,21 +77971,6 @@ function replaceEntitiesValue(textValue){
77945
77971
  return textValue;
77946
77972
  }
77947
77973
 
77948
- function buildEmptyTextNode(val, key, attrStr, level) {
77949
- if( val === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired
77950
- if(this.options.suppressUnpairedNode){
77951
- return this.indentate(level) + '<' + key + this.tagEndChar;
77952
- }else{
77953
- return this.indentate(level) + '<' + key + "/" + this.tagEndChar;
77954
- }
77955
- }else if (val !== '') { //empty
77956
- return this.buildTextValNode(val, key, attrStr, level);
77957
- } else {
77958
- if(key[0] === "?") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar; //PI tag
77959
- else return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar; //normal
77960
- }
77961
- }
77962
-
77963
77974
  function indentate(level) {
77964
77975
  return this.options.indentBy.repeat(level);
77965
77976
  }
@@ -78140,7 +78151,7 @@ function readDocType(xmlData, i){
78140
78151
  let hasBody = false, entity = false, comment = false;
78141
78152
  let exp = "";
78142
78153
  for(;i<xmlData.length;i++){
78143
- if (xmlData[i] === '<') {
78154
+ if (xmlData[i] === '<' && !comment) {
78144
78155
  if( hasBody &&
78145
78156
  xmlData[i+1] === '!' &&
78146
78157
  xmlData[i+2] === 'E' &&
@@ -78204,14 +78215,15 @@ function readDocType(xmlData, i){
78204
78215
  if(comment){
78205
78216
  if( xmlData[i - 1] === "-" && xmlData[i - 2] === "-"){
78206
78217
  comment = false;
78207
- }else{
78208
- throw new Error(`Invalid XML comment in DOCTYPE`);
78218
+ angleBracketsCount--;
78219
+ }
78220
+ }else{
78221
+ if(entity) {
78222
+ parseEntityExp(exp, entities);
78223
+ entity = false;
78209
78224
  }
78210
- }else if(entity){
78211
- parseEntityExp(exp, entities);
78212
- entity = false;
78225
+ angleBracketsCount--;
78213
78226
  }
78214
- angleBracketsCount--;
78215
78227
  if (angleBracketsCount === 0) {
78216
78228
  break;
78217
78229
  }
@@ -78267,7 +78279,7 @@ const defaultOptions = {
78267
78279
  numberParseOptions: {
78268
78280
  hex: true,
78269
78281
  leadingZeros: true,
78270
- eNotation: false
78282
+ eNotation: true
78271
78283
  },
78272
78284
  tagValueProcessor: function(tagName, val) {
78273
78285
  return val;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.4.8",
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.8",
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",