@abaplint/transpiler-cli 2.5.76 → 2.5.78

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 +114 -104
  2. package/package.json +5 -5
package/build/bundle.js CHANGED
@@ -8581,7 +8581,7 @@ const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/
8581
8581
  const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
8582
8582
  class CallFunction {
8583
8583
  getMatcher() {
8584
- const starting = (0, combi_1.seq)("STARTING NEW TASK", expressions_1.SimpleSource2);
8584
+ const starting = (0, combi_1.verNot)(version_1.Version.Cloud, (0, combi_1.seq)("STARTING NEW TASK", expressions_1.SimpleSource2));
8585
8585
  const update = (0, combi_1.verNot)(version_1.Version.Cloud, (0, combi_1.str)("IN UPDATE TASK"));
8586
8586
  const unit = (0, combi_1.seq)("UNIT", expressions_1.Source);
8587
8587
  const background = (0, combi_1.verNot)(version_1.Version.Cloud, (0, combi_1.seq)("IN BACKGROUND", (0, combi_1.altPrio)("TASK", unit)));
@@ -19434,6 +19434,18 @@ class CurrentScope {
19434
19434
  (_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().references.push({ position, resolved: referencing, referenceType: type, extra });
19435
19435
  }
19436
19436
  ///////////////////////////
19437
+ findFunctionModule(name) {
19438
+ if (name === undefined) {
19439
+ return undefined;
19440
+ }
19441
+ for (const fugr of this.reg.getObjectsByType("FUGR")) {
19442
+ const func = fugr.getModule(name);
19443
+ if (func !== undefined) {
19444
+ return func;
19445
+ }
19446
+ }
19447
+ return undefined;
19448
+ }
19437
19449
  findObjectDefinition(name) {
19438
19450
  if (name === undefined) {
19439
19451
  return undefined;
@@ -23566,9 +23578,10 @@ const tokens_1 = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules
23566
23578
  const attribute_name_1 = __webpack_require__(/*! ./attribute_name */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/attribute_name.js");
23567
23579
  const component_name_1 = __webpack_require__(/*! ./component_name */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/component_name.js");
23568
23580
  const types_1 = __webpack_require__(/*! ../../types */ "./node_modules/@abaplint/core/build/src/abap/types/index.js");
23581
+ const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
23569
23582
  class MethodSource {
23570
23583
  runSyntax(node, scope, filename) {
23571
- var _a;
23584
+ var _a, _b, _c;
23572
23585
  const helper = new _object_oriented_1.ObjectOriented(scope);
23573
23586
  const children = node.getChildren().slice();
23574
23587
  const first = children.shift();
@@ -23580,6 +23593,15 @@ class MethodSource {
23580
23593
  context = (_a = scope.findVariable("me")) === null || _a === void 0 ? void 0 : _a.getType();
23581
23594
  children.unshift(first);
23582
23595
  }
23596
+ if (scope.getVersion() === version_1.Version.Cloud
23597
+ && first.get() instanceof Expressions.Dynamic
23598
+ && first instanceof nodes_1.ExpressionNode
23599
+ && ((_b = children[0]) === null || _b === void 0 ? void 0 : _b.concatTokens()) === "=>") {
23600
+ const name = (_c = first.findDirectExpression(Expressions.Constant)) === null || _c === void 0 ? void 0 : _c.concatTokens().replace(/'/g, "");
23601
+ if (name !== undefined && scope.findClassDefinition(name) === undefined) {
23602
+ throw new Error(`Class "${name}" not found/released`);
23603
+ }
23604
+ }
23583
23605
  if (context instanceof basic_1.VoidType) {
23584
23606
  // todo, if there are more dynamic with variables, the references for the variables are not added?
23585
23607
  return context;
@@ -23610,7 +23632,7 @@ class MethodSource {
23610
23632
  continue;
23611
23633
  }
23612
23634
  }
23613
- catch (_b) {
23635
+ catch (_d) {
23614
23636
  // ignore
23615
23637
  }
23616
23638
  // try looking for method name
@@ -25598,6 +25620,7 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
25598
25620
  const target_1 = __webpack_require__(/*! ../expressions/target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
25599
25621
  const field_chain_1 = __webpack_require__(/*! ../expressions/field_chain */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/field_chain.js");
25600
25622
  const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
25623
+ const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
25601
25624
  class CallFunction {
25602
25625
  runSyntax(node, scope, filename) {
25603
25626
  // todo, lots of work here, similar to receive.ts
@@ -25606,6 +25629,13 @@ class CallFunction {
25606
25629
  if (chain) {
25607
25630
  new field_chain_1.FieldChain().runSyntax(chain, scope, filename, _reference_1.ReferenceType.DataReadReference);
25608
25631
  }
25632
+ else if (scope.getVersion() === version_1.Version.Cloud
25633
+ && node.findDirectExpression(Expressions.Destination) === undefined) {
25634
+ const functionName = name === null || name === void 0 ? void 0 : name.concatTokens().replace(/'/, "");
25635
+ if (scope.findFunctionModule(functionName) === undefined) {
25636
+ throw new Error(`Function module "${functionName}" not found/released`);
25637
+ }
25638
+ }
25609
25639
  // just recurse
25610
25640
  for (const s of node.findAllExpressions(Expressions.Source)) {
25611
25641
  new source_1.Source().runSyntax(s, scope, filename);
@@ -26416,7 +26446,10 @@ class CreateObject {
26416
26446
  }
26417
26447
  else if (found instanceof basic_1.ObjectReferenceType) {
26418
26448
  const id = found.getIdentifier();
26419
- if (id instanceof types_1.ClassDefinition && cdef === undefined) {
26449
+ if (id instanceof types_1.InterfaceDefinition && type === undefined) {
26450
+ throw new Error("Interface reference, cannot be instantiated");
26451
+ }
26452
+ else if (id instanceof types_1.ClassDefinition && cdef === undefined) {
26420
26453
  cdef = id;
26421
26454
  }
26422
26455
  if (type === undefined && id instanceof types_1.ClassDefinition && id.isAbstract() === true) {
@@ -39166,10 +39199,15 @@ class LanguageServer {
39166
39199
  }
39167
39200
  const text = new pretty_printer_1.PrettyPrinter(file, this.reg.getConfig()).run();
39168
39201
  const rows = file.getRawRows();
39169
- return [{
39170
- range: LServer.Range.create(0, 0, rows.length, rows[rows.length - 1].length + 1),
39171
- newText: text,
39172
- }];
39202
+ if (text === file.getRaw()) {
39203
+ return [];
39204
+ }
39205
+ else {
39206
+ return [{
39207
+ range: LServer.Range.create(0, 0, rows.length, rows[rows.length - 1].length + 1),
39208
+ newText: text,
39209
+ }];
39210
+ }
39173
39211
  }
39174
39212
  // https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_publishDiagnostics
39175
39213
  diagnostics(textDocument) {
@@ -46079,7 +46117,6 @@ exports.PrettyPrinter = void 0;
46079
46117
  const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/_statement.js");
46080
46118
  const fix_keyword_case_1 = __webpack_require__(/*! ./fix_keyword_case */ "./node_modules/@abaplint/core/build/src/pretty_printer/fix_keyword_case.js");
46081
46119
  const indent_1 = __webpack_require__(/*! ./indent */ "./node_modules/@abaplint/core/build/src/pretty_printer/indent.js");
46082
- const remove_sequential_blanks_1 = __webpack_require__(/*! ./remove_sequential_blanks */ "./node_modules/@abaplint/core/build/src/pretty_printer/remove_sequential_blanks.js");
46083
46120
  const position_1 = __webpack_require__(/*! ../position */ "./node_modules/@abaplint/core/build/src/position.js");
46084
46121
  const indentation_1 = __webpack_require__(/*! ../rules/indentation */ "./node_modules/@abaplint/core/build/src/rules/indentation.js");
46085
46122
  class PrettyPrinter {
@@ -46109,8 +46146,6 @@ class PrettyPrinter {
46109
46146
  }
46110
46147
  const indentation = new indent_1.Indent(this.options);
46111
46148
  this.result = indentation.execute(this.file, this.result);
46112
- const removeBlanks = new remove_sequential_blanks_1.RemoveSequentialBlanks(this.config);
46113
- this.result = removeBlanks.execute(this.file, this.result);
46114
46149
  return this.result;
46115
46150
  }
46116
46151
  }
@@ -46119,66 +46154,6 @@ exports.PrettyPrinter = PrettyPrinter;
46119
46154
 
46120
46155
  /***/ }),
46121
46156
 
46122
- /***/ "./node_modules/@abaplint/core/build/src/pretty_printer/remove_sequential_blanks.js":
46123
- /*!******************************************************************************************!*\
46124
- !*** ./node_modules/@abaplint/core/build/src/pretty_printer/remove_sequential_blanks.js ***!
46125
- \******************************************************************************************/
46126
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
46127
-
46128
- "use strict";
46129
-
46130
- Object.defineProperty(exports, "__esModule", ({ value: true }));
46131
- exports.RemoveSequentialBlanks = void 0;
46132
- const rules_1 = __webpack_require__(/*! ../rules */ "./node_modules/@abaplint/core/build/src/rules/index.js");
46133
- class RemoveSequentialBlanks {
46134
- constructor(config) {
46135
- this.config = config;
46136
- }
46137
- execute(file, modified) {
46138
- const sequentialBlankConfig = this.getSequentialBlankConfig();
46139
- if (sequentialBlankConfig) {
46140
- return this.withoutSequentialBlanks(file, modified, sequentialBlankConfig.lines);
46141
- }
46142
- return modified;
46143
- }
46144
- withoutSequentialBlanks(file, modified, threshold) {
46145
- const rows = file.getRawRows();
46146
- let blanks = 0;
46147
- const rowsToRemove = [];
46148
- const newBlankCount = (current, row) => {
46149
- return rules_1.SequentialBlank.isBlankOrWhitespace(row) ? current + 1 : 0;
46150
- };
46151
- for (let i = 0; i < rows.length; i++) {
46152
- blanks = newBlankCount(blanks, rows[i]);
46153
- if (blanks === threshold) {
46154
- // count additional blanks
46155
- for (let j = i; j < rows.length; j++) {
46156
- if (rules_1.SequentialBlank.isBlankOrWhitespace(rows[j])) {
46157
- rowsToRemove.push(j);
46158
- }
46159
- else {
46160
- break;
46161
- }
46162
- }
46163
- }
46164
- }
46165
- return this.removeRows(modified.split("\n"), rowsToRemove);
46166
- }
46167
- removeRows(lines, rowsToRemove) {
46168
- const withoutRemoved = lines.filter((_, idx) => {
46169
- return rowsToRemove.indexOf(idx) === -1;
46170
- });
46171
- return withoutRemoved.join("\n").trim();
46172
- }
46173
- getSequentialBlankConfig() {
46174
- return this.config.readByRule(new rules_1.SequentialBlank().getMetadata().key);
46175
- }
46176
- }
46177
- exports.RemoveSequentialBlanks = RemoveSequentialBlanks;
46178
- //# sourceMappingURL=remove_sequential_blanks.js.map
46179
-
46180
- /***/ }),
46181
-
46182
46157
  /***/ "./node_modules/@abaplint/core/build/src/registry.js":
46183
46158
  /*!***********************************************************!*\
46184
46159
  !*** ./node_modules/@abaplint/core/build/src/registry.js ***!
@@ -46251,7 +46226,7 @@ class Registry {
46251
46226
  }
46252
46227
  static abaplintVersion() {
46253
46228
  // magic, see build script "version.sh"
46254
- return "2.97.4";
46229
+ return "2.97.7";
46255
46230
  }
46256
46231
  getDDICReferences() {
46257
46232
  return this.references;
@@ -71307,7 +71282,7 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
71307
71282
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
71308
71283
  class CallTranspiler {
71309
71284
  transpile(node, traversal) {
71310
- var _a, _b, _c, _d, _e;
71285
+ var _a, _b, _c, _d;
71311
71286
  const chain = node.findDirectExpression(abaplint.Expressions.MethodCallChain);
71312
71287
  if (chain) {
71313
71288
  let pre = "";
@@ -71317,34 +71292,12 @@ class CallTranspiler {
71317
71292
  pre = traversal.traverse(receiving).getCode() + ".set(";
71318
71293
  post = ")";
71319
71294
  }
71295
+ post += ";";
71320
71296
  const exceptions = node.findFirstExpression(abaplint.Expressions.ParameterListExceptions);
71321
71297
  if (exceptions) {
71322
- pre = "try {\n" + pre;
71323
- }
71324
- post += ";";
71325
- if (exceptions) {
71326
- post += `\nabap.builtin.sy.get().subrc.set(0);
71327
- } catch (e) {
71328
- if (e.classic) {
71329
- switch (e.classic.toUpperCase()) {\n`;
71330
- for (const e of exceptions.findAllExpressions(abaplint.Expressions.ParameterException)) {
71331
- const name = e.getFirstToken().getStr().toUpperCase();
71332
- const value = (_c = e.findFirstExpression(abaplint.Expressions.SimpleName)) === null || _c === void 0 ? void 0 : _c.getFirstToken().getStr().toUpperCase();
71333
- if (value === undefined) {
71334
- continue;
71335
- }
71336
- if (name === "OTHERS") {
71337
- post += `default: abap.builtin.sy.get().subrc.set(${value}); break;\n`;
71338
- }
71339
- else {
71340
- post += `case "${name}": abap.builtin.sy.get().subrc.set(${value}); break;\n`;
71341
- }
71342
- }
71343
- post += ` }
71344
- } else {
71345
- throw e;
71346
- }
71347
- }`;
71298
+ const build = this.buildExceptions(exceptions);
71299
+ pre = build.pre + pre;
71300
+ post += build.post;
71348
71301
  }
71349
71302
  const chainChunk = traversal.traverse(chain);
71350
71303
  let chainCode = chainChunk.getCode();
@@ -71360,7 +71313,7 @@ if (e.classic) {
71360
71313
  const methodSource = node.findDirectExpression(abaplint.Expressions.MethodSource);
71361
71314
  if (methodSource) {
71362
71315
  let body = "";
71363
- const nameToken = (_d = methodSource.getLastChild()) === null || _d === void 0 ? void 0 : _d.getFirstToken();
71316
+ const nameToken = (_c = methodSource.getLastChild()) === null || _c === void 0 ? void 0 : _c.getFirstToken();
71364
71317
  const m = nameToken ? traversal.findMethodReference(nameToken, traversal.findCurrentScopeByToken(nameToken)) : undefined;
71365
71318
  const methodCallBody = node.findDirectExpression(abaplint.Expressions.MethodCallBody);
71366
71319
  if (methodCallBody) {
@@ -71368,12 +71321,18 @@ if (e.classic) {
71368
71321
  }
71369
71322
  let pre = "";
71370
71323
  let post = "";
71371
- const receiving = (_e = node.findFirstExpression(abaplint.Expressions.MethodParameters)) === null || _e === void 0 ? void 0 : _e.findExpressionAfterToken("RECEIVING");
71324
+ const receiving = (_d = node.findFirstExpression(abaplint.Expressions.MethodParameters)) === null || _d === void 0 ? void 0 : _d.findExpressionAfterToken("RECEIVING");
71372
71325
  if (receiving) {
71373
71326
  const target = traversal.traverse(receiving.findDirectExpression(abaplint.Expressions.Target));
71374
71327
  pre = target.getCode() + ".set(";
71375
71328
  post = ")";
71376
71329
  }
71330
+ const exceptions = node.findFirstExpression(abaplint.Expressions.ParameterListExceptions);
71331
+ if (exceptions) {
71332
+ const build = this.buildExceptions(exceptions);
71333
+ pre = build.pre + pre;
71334
+ post += build.post;
71335
+ }
71377
71336
  let ms = new expressions_1.MethodSourceTranspiler(pre).transpile(methodSource, traversal).getCode();
71378
71337
  if (ms === "await super.get().constructor") {
71379
71338
  // semantics of constructors in JS vs ABAP is different, so the "constructor_" has been introduced,
@@ -71386,6 +71345,35 @@ if (e.classic) {
71386
71345
  }
71387
71346
  throw new Error("CallTranspiler, todo");
71388
71347
  }
71348
+ buildExceptions(node) {
71349
+ var _a;
71350
+ let pre = "";
71351
+ let post = "";
71352
+ pre = "try {\n" + pre;
71353
+ post += `\nabap.builtin.sy.get().subrc.set(0);
71354
+ } catch (e) {
71355
+ if (e.classic) {
71356
+ switch (e.classic.toUpperCase()) {\n`;
71357
+ for (const e of node.findAllExpressions(abaplint.Expressions.ParameterException)) {
71358
+ const name = e.getFirstToken().getStr().toUpperCase();
71359
+ const value = (_a = e.findFirstExpression(abaplint.Expressions.SimpleName)) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr().toUpperCase();
71360
+ if (value === undefined) {
71361
+ continue;
71362
+ }
71363
+ if (name === "OTHERS") {
71364
+ post += `default: abap.builtin.sy.get().subrc.set(${value}); break;\n`;
71365
+ }
71366
+ else {
71367
+ post += `case "${name}": abap.builtin.sy.get().subrc.set(${value}); break;\n`;
71368
+ }
71369
+ }
71370
+ post += ` }
71371
+ } else {
71372
+ throw e;
71373
+ }
71374
+ }`;
71375
+ return { pre, post };
71376
+ }
71389
71377
  }
71390
71378
  exports.CallTranspiler = CallTranspiler;
71391
71379
  //# sourceMappingURL=call.js.map
@@ -79278,6 +79266,7 @@ const defaultOptions = {
79278
79266
  stopNodes: [],
79279
79267
  // transformTagName: false,
79280
79268
  // transformAttributeName: false,
79269
+ oneListGroup: false
79281
79270
  };
79282
79271
 
79283
79272
  function Builder(options) {
@@ -79348,6 +79337,7 @@ Builder.prototype.j2x = function(jObj, level) {
79348
79337
  } else if (Array.isArray(jObj[key])) {
79349
79338
  //repeated nodes
79350
79339
  const arrLen = jObj[key].length;
79340
+ let listTagVal = "";
79351
79341
  for (let j = 0; j < arrLen; j++) {
79352
79342
  const item = jObj[key][j];
79353
79343
  if (typeof item === 'undefined') {
@@ -79357,11 +79347,19 @@ Builder.prototype.j2x = function(jObj, level) {
79357
79347
  else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
79358
79348
  // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
79359
79349
  } else if (typeof item === 'object') {
79360
- val += this.processTextOrObjNode(item, key, level)
79350
+ if(this.options.oneListGroup ){
79351
+ listTagVal += this.j2x(item, level + 1).val;
79352
+ }else{
79353
+ listTagVal += this.processTextOrObjNode(item, key, level)
79354
+ }
79361
79355
  } else {
79362
- val += this.buildTextValNode(item, key, '', level);
79356
+ listTagVal += this.buildTextValNode(item, key, '', level);
79363
79357
  }
79364
79358
  }
79359
+ if(this.options.oneListGroup){
79360
+ listTagVal = this.buildObjectNode(listTagVal, key, '', level);
79361
+ }
79362
+ val += listTagVal;
79365
79363
  } else {
79366
79364
  //nested node
79367
79365
  if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
@@ -80588,8 +80586,20 @@ function assignAttributes(obj, attrMap, jpath, options){
80588
80586
  }
80589
80587
 
80590
80588
  function isLeafTag(obj, options){
80589
+ const { textNodeName } = options;
80591
80590
  const propCount = Object.keys(obj).length;
80592
- if( propCount === 0 || (propCount === 1 && obj[options.textNodeName]) ) return true;
80591
+
80592
+ if (propCount === 0) {
80593
+ return true;
80594
+ }
80595
+
80596
+ if (
80597
+ propCount === 1 &&
80598
+ (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)
80599
+ ) {
80600
+ return true;
80601
+ }
80602
+
80593
80603
  return false;
80594
80604
  }
80595
80605
  exports.prettify = prettify;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.5.76",
3
+ "version": "2.5.78",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,15 +25,15 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.5.76",
28
+ "@abaplint/transpiler": "^2.5.78",
29
29
  "@types/glob": "^7.2.0",
30
30
  "glob": "=7.2.0",
31
31
  "@types/progress": "^2.0.5",
32
32
  "@types/node": "^18.15.11",
33
- "@abaplint/core": "^2.97.4",
33
+ "@abaplint/core": "^2.97.7",
34
34
  "progress": "^2.0.3",
35
- "webpack": "^5.77.0",
35
+ "webpack": "^5.78.0",
36
36
  "webpack-cli": "^5.0.1",
37
- "typescript": "^5.0.3"
37
+ "typescript": "^5.0.4"
38
38
  }
39
39
  }