@abaplint/transpiler-cli 2.13.45 → 2.13.47

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 +155 -14
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -31845,6 +31845,10 @@ class InlineData {
31845
31845
  static runSyntax(node, input, type) {
31846
31846
  var _a;
31847
31847
  const token = (_a = node.findFirstExpression(Expressions.TargetField)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
31848
+ if (token && token.getStr().length > 30) {
31849
+ const message = "DATA name too long, " + token.getStr();
31850
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
31851
+ }
31848
31852
  if (token && type) {
31849
31853
  if (type instanceof basic_1.CSequenceType || type instanceof basic_1.CLikeType) {
31850
31854
  type = basic_1.StringType.get();
@@ -32016,10 +32020,16 @@ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expr
32016
32020
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
32017
32021
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
32018
32022
  const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
32023
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
32019
32024
  class InlineFS {
32020
32025
  static runSyntax(node, input, type) {
32021
32026
  var _a;
32022
32027
  const token = (_a = node.findFirstExpression(Expressions.TargetFieldSymbol)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
32028
+ const fs = node.findFirstExpression(Expressions.FieldSymbol);
32029
+ if (fs && fs.concatTokens().length > 30) {
32030
+ const message = "FIELD-SYMBOLS name too long, " + fs.concatTokens();
32031
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, fs.getFirstToken(), message));
32032
+ }
32023
32033
  if (token && type) {
32024
32034
  const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, type, ["inline" /* IdentifierMeta.InlineDefinition */]);
32025
32035
  input.scope.addIdentifier(identifier);
@@ -37154,6 +37164,75 @@ exports.Assign = Assign;
37154
37164
 
37155
37165
  /***/ },
37156
37166
 
37167
+ /***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/at_selection_screen.js"
37168
+ /*!***********************************************************************************************!*\
37169
+ !*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/at_selection_screen.js ***!
37170
+ \***********************************************************************************************/
37171
+ (__unused_webpack_module, exports, __webpack_require__) {
37172
+
37173
+ "use strict";
37174
+
37175
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
37176
+ if (k2 === undefined) k2 = k;
37177
+ var desc = Object.getOwnPropertyDescriptor(m, k);
37178
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
37179
+ desc = { enumerable: true, get: function() { return m[k]; } };
37180
+ }
37181
+ Object.defineProperty(o, k2, desc);
37182
+ }) : (function(o, m, k, k2) {
37183
+ if (k2 === undefined) k2 = k;
37184
+ o[k2] = m[k];
37185
+ }));
37186
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
37187
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37188
+ }) : function(o, v) {
37189
+ o["default"] = v;
37190
+ });
37191
+ var __importStar = (this && this.__importStar) || (function () {
37192
+ var ownKeys = function(o) {
37193
+ ownKeys = Object.getOwnPropertyNames || function (o) {
37194
+ var ar = [];
37195
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
37196
+ return ar;
37197
+ };
37198
+ return ownKeys(o);
37199
+ };
37200
+ return function (mod) {
37201
+ if (mod && mod.__esModule) return mod;
37202
+ var result = {};
37203
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37204
+ __setModuleDefault(result, mod);
37205
+ return result;
37206
+ };
37207
+ })();
37208
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
37209
+ exports.AtSelectionScreen = void 0;
37210
+ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
37211
+ const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
37212
+ const source_field_1 = __webpack_require__(/*! ../expressions/source_field */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field.js");
37213
+ class AtSelectionScreen {
37214
+ runSyntax(node, input) {
37215
+ // "AT SELECTION-SCREEN ON <field>", "ON VALUE-REQUEST FOR <field>",
37216
+ // "ON HELP-REQUEST FOR <field>" and "ON END OF <field>" all reference
37217
+ // a parameter or select-option, register these as read references so
37218
+ // they are not reported as unused.
37219
+ const fields = [
37220
+ ...node.findDirectExpressions(Expressions.FieldSub),
37221
+ ...node.findDirectExpressions(Expressions.Field),
37222
+ ];
37223
+ for (const field of fields) {
37224
+ const token = field.getFirstToken();
37225
+ if (input.scope.findVariable(token.getStr()) !== undefined) {
37226
+ source_field_1.SourceField.runSyntax(field, input, _reference_1.ReferenceType.DataReadReference, false);
37227
+ }
37228
+ }
37229
+ }
37230
+ }
37231
+ exports.AtSelectionScreen = AtSelectionScreen;
37232
+ //# sourceMappingURL=at_selection_screen.js.map
37233
+
37234
+ /***/ },
37235
+
37157
37236
  /***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/authority_check.js"
37158
37237
  /*!*******************************************************************************************!*\
37159
37238
  !*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/authority_check.js ***!
@@ -40341,14 +40420,19 @@ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expr
40341
40420
  const _typed_identifier_1 = __webpack_require__(/*! ../../types/_typed_identifier */ "./node_modules/@abaplint/core/build/src/abap/types/_typed_identifier.js");
40342
40421
  const basic_types_1 = __webpack_require__(/*! ../basic_types */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/basic_types.js");
40343
40422
  const unknown_type_1 = __webpack_require__(/*! ../../types/basic/unknown_type */ "./node_modules/@abaplint/core/build/src/abap/types/basic/unknown_type.js");
40423
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
40344
40424
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
40345
40425
  class FieldSymbol {
40346
40426
  runSyntax(node, input) {
40347
- var _a;
40348
- const fsname = (_a = node.findFirstExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
40349
- if (fsname === undefined) {
40427
+ const fs = node.findFirstExpression(Expressions.FieldSymbol);
40428
+ const fsname = fs === null || fs === void 0 ? void 0 : fs.getFirstToken();
40429
+ if (fs === undefined || fsname === undefined) {
40350
40430
  return;
40351
40431
  }
40432
+ if (fs.concatTokens().length > 30) {
40433
+ const message = "FIELD-SYMBOLS name too long, " + fs.concatTokens();
40434
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, fsname, message));
40435
+ }
40352
40436
  if (node.getChildren().length === 5) {
40353
40437
  // no type specified
40354
40438
  input.scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(fsname, input.filename, basic_1.VoidType.get("FS-SIMPLE")));
@@ -47751,6 +47835,7 @@ const if_1 = __webpack_require__(/*! ./statements/if */ "./node_modules/@abaplin
47751
47835
  const else_if_1 = __webpack_require__(/*! ./statements/else_if */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/else_if.js");
47752
47836
  const append_1 = __webpack_require__(/*! ./statements/append */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/append.js");
47753
47837
  const selection_screen_1 = __webpack_require__(/*! ./statements/selection_screen */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/selection_screen.js");
47838
+ const at_selection_screen_1 = __webpack_require__(/*! ./statements/at_selection_screen */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/at_selection_screen.js");
47754
47839
  const ranges_1 = __webpack_require__(/*! ./statements/ranges */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/ranges.js");
47755
47840
  const write_1 = __webpack_require__(/*! ./statements/write */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/write.js");
47756
47841
  const case_1 = __webpack_require__(/*! ./statements/case */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/statements/case.js");
@@ -47958,6 +48043,7 @@ if (Object.keys(map).length === 0) {
47958
48043
  addToMap(new authority_check_1.AuthorityCheck());
47959
48044
  addToMap(new insert_report_1.InsertReport());
47960
48045
  addToMap(new selection_screen_1.SelectionScreen());
48046
+ addToMap(new at_selection_screen_1.AtSelectionScreen());
47961
48047
  addToMap(new ranges_1.Ranges());
47962
48048
  addToMap(new add_1.Add());
47963
48049
  addToMap(new raise_event_1.RaiseEvent());
@@ -51657,6 +51743,7 @@ class ClassDefinition extends _identifier_1.Identifier {
51657
51743
  this.createVisibilityValue = visibility_1.Visibility.Public;
51658
51744
  }
51659
51745
  // perform checks after everything has been initialized
51746
+ this.checkInterfaceVisibility(input, node);
51660
51747
  this.checkMethodsFromSuperClasses(input);
51661
51748
  this.checkMethodNameLength(input);
51662
51749
  this.checkClassConstructorStatic(input);
@@ -51730,6 +51817,17 @@ class ClassDefinition extends _identifier_1.Identifier {
51730
51817
  }
51731
51818
  }
51732
51819
  }
51820
+ checkInterfaceVisibility(input, node) {
51821
+ const sections = [
51822
+ node.findDirectStructure(Structures.ProtectedSection),
51823
+ node.findDirectStructure(Structures.PrivateSection),
51824
+ ];
51825
+ for (const section of sections) {
51826
+ for (const statement of (section === null || section === void 0 ? void 0 : section.findAllStatements(Statements.InterfaceDef)) || []) {
51827
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, statement.getFirstToken(), "INTERFACES can only be declared in public sections"));
51828
+ }
51829
+ }
51830
+ }
51733
51831
  checkMethodsFromSuperClasses(input) {
51734
51832
  var _a;
51735
51833
  const scope = input.scope;
@@ -69492,7 +69590,7 @@ class Registry {
69492
69590
  }
69493
69591
  static abaplintVersion() {
69494
69592
  // magic, see build script "version.js"
69495
- return "2.120.5";
69593
+ return "2.120.6";
69496
69594
  }
69497
69595
  getDDICReferences() {
69498
69596
  return this.ddicReferences;
@@ -102092,7 +102190,7 @@ class ConstantTranspiler {
102092
102190
  str = node.findDirectExpression(core_1.Expressions.TextElementString);
102093
102191
  }
102094
102192
  if (str) {
102095
- let res = str.getFirstToken().getStr();
102193
+ const res = str.getFirstToken().getStr();
102096
102194
  if (res.startsWith("'") && this.addGet === false) {
102097
102195
  const code = this.handleCharacter(res);
102098
102196
  return new chunk_1.Chunk().append(code, node, traversal);
@@ -102102,10 +102200,7 @@ class ConstantTranspiler {
102102
102200
  return new chunk_1.Chunk().append(code, node, traversal);
102103
102201
  }
102104
102202
  else {
102105
- if (res.startsWith("'")) {
102106
- res = "'" + res.substring(1, res.length - 1).trimEnd() + "'";
102107
- }
102108
- const code = ConstantTranspiler.escape(res);
102203
+ const code = ConstantTranspiler.escape(ConstantTranspiler.trimTextFieldLiteral(res));
102109
102204
  return new chunk_1.Chunk().append(code, node, traversal);
102110
102205
  }
102111
102206
  }
@@ -102146,6 +102241,13 @@ class ConstantTranspiler {
102146
102241
  // const code = "new abap.types.Character(" + length + ").set(" + ConstantTranspiler.escape(res) + ")";
102147
102242
  return code;
102148
102243
  }
102244
+ // text field literals are of type c, trailing blanks are not part of the value
102245
+ static trimTextFieldLiteral(str) {
102246
+ if (str.startsWith("'") && str.endsWith("'") && str.length >= 2) {
102247
+ return "'" + str.substring(1, str.length - 1).trimEnd() + "'";
102248
+ }
102249
+ return str;
102250
+ }
102149
102251
  static escape(str) {
102150
102252
  str = str.replace(/\\/g, "\\\\");
102151
102253
  if (str.startsWith("'")) {
@@ -110297,6 +110399,30 @@ const constant_1 = __webpack_require__(/*! ../expressions/constant */ "./node_mo
110297
110399
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/transpiler/build/src/expressions/index.js");
110298
110400
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
110299
110401
  class DataTranspiler {
110402
+ skipLoopScoping;
110403
+ variableName = "";
110404
+ loopScoped = false;
110405
+ constructor(options) {
110406
+ this.skipLoopScoping = options?.skipLoopScoping === true;
110407
+ }
110408
+ /** name of the declared javascript variable, set by transpile() */
110409
+ getVariableName() {
110410
+ return this.variableName;
110411
+ }
110412
+ /** set by transpile(), true if the declaration is inside a loop */
110413
+ isLoopScoped() {
110414
+ return this.loopScoped;
110415
+ }
110416
+ /** DATA is scoped to the enclosing method/form/program, but when the statement is inside a
110417
+ * loop the generated declaration ends up inside the javascript block of the loop. Declaring
110418
+ * with "var" hoists it out of the block, and the guard makes sure its constructed only on the
110419
+ * first pass, ie. contents are kept across iterations, matching ABAP */
110420
+ static wrapLoopScoped(name, chunk) {
110421
+ return new chunk_1.Chunk()
110422
+ .appendString(`if (${name} === undefined) {\n`)
110423
+ .appendChunk(chunk)
110424
+ .appendString("\n}");
110425
+ }
110300
110426
  transpile(node, traversal) {
110301
110427
  const token = node.findFirstExpression(abaplint.Expressions.DefinitionName)?.getFirstToken();
110302
110428
  if (token === undefined) {
@@ -110324,12 +110450,17 @@ class DataTranspiler {
110324
110450
  value = "\n" + traversal_1.Traversal.prefixVariable(found.getName().toLowerCase()) + ".set(\"" + enumDefault + "\");";
110325
110451
  }
110326
110452
  }
110453
+ this.variableName = traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(found.getName().toLowerCase()));
110454
+ this.loopScoped = traversal.isInsideLoop(node);
110327
110455
  const ret = new chunk_1.Chunk()
110328
- .appendString("let ")
110329
- .appendString(traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(found.getName().toLowerCase())))
110456
+ .appendString(this.loopScoped === true ? "var " : "let ")
110457
+ .appendString(this.variableName)
110330
110458
  .appendString(" = " + transpile_types_1.TranspileTypes.toType(found.getType()))
110331
110459
  .appendString(";")
110332
110460
  .appendString(value);
110461
+ if (this.loopScoped === true && this.skipLoopScoping === false) {
110462
+ return DataTranspiler.wrapLoopScoped(this.variableName, ret);
110463
+ }
110333
110464
  return ret;
110334
110465
  }
110335
110466
  static findEnumDefault(scope, _enumType) {
@@ -110361,7 +110492,7 @@ class DataTranspiler {
110361
110492
  int = val.findFirstExpression(abaplint.Expressions.ConstantString);
110362
110493
  }
110363
110494
  if (int) {
110364
- const escaped = constant_1.ConstantTranspiler.escape(int.concatTokens());
110495
+ const escaped = constant_1.ConstantTranspiler.escape(constant_1.ConstantTranspiler.trimTextFieldLiteral(int.concatTokens()));
110365
110496
  value = "\n" + name + ".set(" + escaped + ");";
110366
110497
  }
110367
110498
  else if (val.getChildren()[1].get() instanceof abaplint.Expressions.SimpleFieldChain) {
@@ -117919,13 +118050,18 @@ class DataTranspiler {
117919
118050
  return new chunk_1.Chunk("");
117920
118051
  }
117921
118052
  const topName = begin.findDirectExpression(abaplint.Expressions.DefinitionName)?.concatTokens().toLowerCase();
117922
- const chunk = new statements_1.DataTranspiler().transpile(begin, traversal).ensureStartMapping(begin, traversal);
118053
+ // the component values are part of the declaration, so they must stay inside the loop guard
118054
+ const statement = new statements_1.DataTranspiler({ skipLoopScoping: true });
118055
+ let chunk = statement.transpile(begin, traversal).ensureStartMapping(begin, traversal);
117923
118056
  for (const d of node.findDirectStatements(abaplint.Statements.Data)) {
117924
118057
  const subName = d.findFirstExpression(abaplint.Expressions.DefinitionName)?.concatTokens().toLowerCase();
117925
118058
  if (subName && topName) {
117926
118059
  chunk.appendString(statements_1.DataTranspiler.buildValue(d, topName + ".get()." + subName, traversal));
117927
118060
  }
117928
118061
  }
118062
+ if (statement.isLoopScoped() === true) {
118063
+ chunk = statements_1.DataTranspiler.wrapLoopScoped(statement.getVariableName(), chunk);
118064
+ }
117929
118065
  chunk.appendString("\n");
117930
118066
  return chunk;
117931
118067
  }
@@ -119789,10 +119925,15 @@ class Traversal {
119789
119925
  }
119790
119926
  buildThisAttributes(def, cName) {
119791
119927
  let ret = "";
119928
+ const constants = def.getAttributes()?.getConstants() || [];
119792
119929
  for (const a of def.getAttributes()?.getAll() || []) {
119793
119930
  let escaped = Traversal.escapeNamespace(a.getName().toLowerCase());
119794
119931
  if (a.getMeta().includes("static" /* abaplint.IdentifierMeta.Static */) === true) {
119795
119932
  ret += "this." + escaped + " = " + cName + "." + escaped + ";\n";
119933
+ const isConstant = constants.some(c => c.getName().toUpperCase() === a.getName().toUpperCase());
119934
+ if (a.getVisibility() === abaplint.Visibility.Private && isConstant === false) {
119935
+ ret += `this.FRIENDS_ACCESS_INSTANCE["${escaped}"] = this.${escaped};\n`;
119936
+ }
119796
119937
  }
119797
119938
  else {
119798
119939
  if (a.getVisibility() === abaplint.Visibility.Private) {
@@ -120144,7 +120285,7 @@ this.INTERNAL_ID = abap.internalIdCounter++;\n`;
120144
120285
  }
120145
120286
  const handle = (val, name) => {
120146
120287
  if (typeof val === "string") {
120147
- const e = expressions_1.ConstantTranspiler.escape(val);
120288
+ const e = expressions_1.ConstantTranspiler.escape(expressions_1.ConstantTranspiler.trimTextFieldLiteral(val));
120148
120289
  ret += name + ".set(" + e + ");\n";
120149
120290
  }
120150
120291
  else if (typeof val === "object") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.13.45",
3
+ "version": "2.13.47",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -27,8 +27,8 @@
27
27
  "author": "abaplint",
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
- "@abaplint/core": "^2.120.5",
31
- "@abaplint/transpiler": "^2.13.45",
30
+ "@abaplint/core": "^2.120.6",
31
+ "@abaplint/transpiler": "^2.13.47",
32
32
  "@types/glob": "^8.1.0",
33
33
  "@types/node": "^24.12.2",
34
34
  "@types/progress": "^2.0.7",