@abaplint/transpiler-cli 2.7.101 → 2.7.103

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 +117 -33
  2. package/package.json +4 -4
package/build/bundle.js CHANGED
@@ -521,6 +521,11 @@ class Lexer {
521
521
  this.add();
522
522
  this.m = this.ModeNormal;
523
523
  }
524
+ else if (this.m === this.ModeTemplate
525
+ && ahead === "}"
526
+ && current !== "\\") {
527
+ this.add();
528
+ }
524
529
  else if (this.m === this.ModeStr
525
530
  && current === "'"
526
531
  && buf.length > 1
@@ -6570,7 +6575,7 @@ const combi_1 = __webpack_require__(/*! ../combi */ "./node_modules/@abaplint/co
6570
6575
  const _1 = __webpack_require__(/*! . */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
6571
6576
  class SQLFields extends combi_1.Expression {
6572
6577
  getRunnable() {
6573
- return (0, combi_1.seq)("FIELDS", _1.SQLFieldList);
6578
+ return (0, combi_1.seq)("FIELDS", (0, combi_1.opt)("DISTINCT"), _1.SQLFieldList);
6574
6579
  }
6575
6580
  }
6576
6581
  exports.SQLFields = SQLFields;
@@ -15547,9 +15552,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
15547
15552
  exports.TruncateDataset = void 0;
15548
15553
  const combi_1 = __webpack_require__(/*! ../combi */ "./node_modules/@abaplint/core/build/src/abap/2_statements/combi.js");
15549
15554
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
15555
+ const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
15550
15556
  class TruncateDataset {
15551
15557
  getMatcher() {
15552
- return (0, combi_1.seq)("TRUNCATE DATASET", expressions_1.Source, "AT CURRENT POSITION");
15558
+ return (0, combi_1.verNot)(version_1.Version.Cloud, (0, combi_1.seq)("TRUNCATE DATASET", expressions_1.Source, "AT CURRENT POSITION"));
15553
15559
  }
15554
15560
  }
15555
15561
  exports.TruncateDataset = TruncateDataset;
@@ -20922,6 +20928,7 @@ class TypeUtils {
20922
20928
  else if (source instanceof basic_1.XStringType) {
20923
20929
  if (target instanceof basic_1.CLikeType
20924
20930
  || target instanceof basic_1.IntegerType
20931
+ || target instanceof basic_1.StringType
20925
20932
  || target instanceof basic_1.ObjectReferenceType
20926
20933
  || target instanceof basic_1.HexType) {
20927
20934
  return false;
@@ -22898,20 +22905,30 @@ const source_field_symbol_1 = __webpack_require__(/*! ./source_field_symbol */ "
22898
22905
  const source_field_1 = __webpack_require__(/*! ./source_field */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field.js");
22899
22906
  class FieldChain {
22900
22907
  runSyntax(node, scope, filename, refType) {
22901
- const concat = node.concatTokens();
22902
- if (concat.includes("-")) {
22903
- // workaround for names with dashes
22904
- const found = scope.findVariable(concat);
22905
- if (found) {
22906
- if (refType) {
22907
- scope.addReference(node.getFirstToken(), found, refType, filename);
22908
+ var _a, _b, _c, _d, _e;
22909
+ const children = node.getChildren().slice();
22910
+ let contextName = children[0].concatTokens();
22911
+ let context = undefined;
22912
+ try {
22913
+ context = this.findTop(children.shift(), scope, filename, refType);
22914
+ }
22915
+ catch (error) {
22916
+ const concat = node.concatTokens();
22917
+ if (concat.includes("-") && ((_a = node.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.SourceField) {
22918
+ // workaround for names with dashes, eg. "sy-repid"
22919
+ const offset = ((_b = node.findDirectExpression(Expressions.FieldOffset)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "";
22920
+ const length = ((_c = node.findDirectExpression(Expressions.FieldLength)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "";
22921
+ const found = scope.findVariable(concat.replace(offset, "").replace(length, ""));
22922
+ if (found) {
22923
+ if (refType) {
22924
+ scope.addReference(node.getFirstToken(), found, refType, filename);
22925
+ }
22926
+ // this is not completely correct, but will work, dashes in names is a mess anyhow
22927
+ return found.getType();
22908
22928
  }
22909
- return found.getType();
22910
22929
  }
22930
+ throw error;
22911
22931
  }
22912
- const children = node.getChildren().slice();
22913
- let contextName = children[0].concatTokens();
22914
- let context = this.findTop(children.shift(), scope, filename, refType);
22915
22932
  while (children.length > 0) {
22916
22933
  contextName += children[0].concatTokens();
22917
22934
  const current = children.shift();
@@ -22959,7 +22976,30 @@ class FieldChain {
22959
22976
  if (context instanceof basic_1.TableType && context.isWithHeader()) {
22960
22977
  context = context.getRowType();
22961
22978
  }
22962
- context = new component_name_1.ComponentName().runSyntax(context, current);
22979
+ try {
22980
+ context = new component_name_1.ComponentName().runSyntax(context, current);
22981
+ }
22982
+ catch (error) {
22983
+ const concat = node.concatTokens();
22984
+ if (concat.includes("-")) {
22985
+ // workaround for names with dashes, eg. "sy-repid"
22986
+ const offset = ((_d = node.findDirectExpression(Expressions.FieldOffset)) === null || _d === void 0 ? void 0 : _d.concatTokens()) || "";
22987
+ const length = ((_e = node.findDirectExpression(Expressions.FieldLength)) === null || _e === void 0 ? void 0 : _e.concatTokens()) || "";
22988
+ const found = scope.findVariable(concat.replace(offset, "").replace(length, ""));
22989
+ if (found) {
22990
+ if (refType) {
22991
+ scope.addReference(node.getFirstToken(), found, refType, filename);
22992
+ }
22993
+ context = found.getType();
22994
+ }
22995
+ else {
22996
+ throw error;
22997
+ }
22998
+ }
22999
+ else {
23000
+ throw error;
23001
+ }
23002
+ }
22963
23003
  }
22964
23004
  else if (current instanceof nodes_1.ExpressionNode
22965
23005
  && current.get() instanceof Expressions.TableExpression) {
@@ -23688,6 +23728,7 @@ class MethodCallChain {
23688
23728
  if (first.get() instanceof Expressions.MethodCall) {
23689
23729
  children.unshift(first);
23690
23730
  }
23731
+ let previous = "";
23691
23732
  while (children.length > 0) {
23692
23733
  const current = children.shift();
23693
23734
  if (current === undefined) {
@@ -23708,6 +23749,9 @@ class MethodCallChain {
23708
23749
  }
23709
23750
  }
23710
23751
  else {
23752
+ if (previous === "=>" && (method === null || method === void 0 ? void 0 : method.isStatic()) === false) {
23753
+ throw new Error("Method \"" + methodName + "\" not static");
23754
+ }
23711
23755
  const extra = {
23712
23756
  ooName: foundDef === null || foundDef === void 0 ? void 0 : foundDef.getName(),
23713
23757
  ooType: foundDef instanceof class_definition_1.ClassDefinition ? "CLAS" : "INTF"
@@ -23745,6 +23789,7 @@ class MethodCallChain {
23745
23789
  else if (current instanceof nodes_1.ExpressionNode && current.get() instanceof Expressions.AttributeName) {
23746
23790
  context = new attribute_name_1.AttributeName().runSyntax(context, current, scope, filename);
23747
23791
  }
23792
+ previous = current.concatTokens();
23748
23793
  }
23749
23794
  return context;
23750
23795
  }
@@ -24728,20 +24773,23 @@ class Select {
24728
24773
  if (isDynamic) {
24729
24774
  throw new Error(`dynamic field list, inlining not possible`);
24730
24775
  }
24731
- if (isSimple.test(field.code) && dbSources.length === 1 && dbSources[0] !== undefined) {
24732
- const dbType = dbSources[0].parseType(scope.getRegistry());
24733
- let type = new basic_1.VoidType("SELECT_todo");
24734
- if (dbType instanceof basic_1.StructureType) {
24735
- type = dbType.getComponentByName(field.code);
24736
- if (type === undefined) {
24737
- throw new Error(`handleInto, internal error, should be checked earlier`);
24776
+ let type = new basic_1.VoidType("SELECT_todo");
24777
+ if (isSimple.test(field.code)) {
24778
+ for (const dbSource of dbSources) {
24779
+ if (dbSource === undefined) {
24780
+ continue;
24781
+ }
24782
+ const dbType = dbSource.parseType(scope.getRegistry());
24783
+ if (dbType instanceof basic_1.StructureType) {
24784
+ const found = dbType.getComponentByName(field.code);
24785
+ if (found) {
24786
+ type = found;
24787
+ break;
24788
+ }
24738
24789
  }
24739
24790
  }
24740
- new inline_data_1.InlineData().runSyntax(inline, scope, filename, type);
24741
- }
24742
- else {
24743
- new inline_data_1.InlineData().runSyntax(inline, scope, filename, new basic_1.VoidType("SELECT_todo"));
24744
24791
  }
24792
+ new inline_data_1.InlineData().runSyntax(inline, scope, filename, type);
24745
24793
  }
24746
24794
  }
24747
24795
  }
@@ -25402,7 +25450,8 @@ class StringTemplate {
25402
25450
  if (type === undefined) {
25403
25451
  throw new Error("No target type determined");
25404
25452
  }
25405
- else if (typeUtils.isCharLike(type) === false && typeUtils.isHexLike(type) === false) {
25453
+ else if ((typeUtils.isCharLike(type) === false && typeUtils.isHexLike(type) === false)
25454
+ || type instanceof basic_1.StructureType) {
25406
25455
  throw new Error("Not character like, " + type.constructor.name);
25407
25456
  }
25408
25457
  const format = templateSource.findDirectExpression(Expressions.StringTemplateFormatting);
@@ -26449,9 +26498,10 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
26449
26498
  const fstarget_1 = __webpack_require__(/*! ../expressions/fstarget */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/fstarget.js");
26450
26499
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
26451
26500
  const dynamic_1 = __webpack_require__(/*! ../expressions/dynamic */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/dynamic.js");
26501
+ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
26452
26502
  class Assign {
26453
26503
  runSyntax(node, scope, filename) {
26454
- var _a, _b;
26504
+ var _a;
26455
26505
  const assignSource = node.findDirectExpression(Expressions.AssignSource);
26456
26506
  const sources = (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpressions(Expressions.Source)) || [];
26457
26507
  const theSource = sources[sources.length - 1];
@@ -26470,10 +26520,18 @@ class Assign {
26470
26520
  else {
26471
26521
  sourceType = new source_1.Source().runSyntax(theSource, scope, filename);
26472
26522
  }
26473
- if (sourceType === undefined || ((_a = node.findDirectExpression(Expressions.AssignSource)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Dynamic))) {
26523
+ if ((assignSource === null || assignSource === void 0 ? void 0 : assignSource.getChildren().length) === 5
26524
+ && ((_a = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getFirstChild()) === null || _a === void 0 ? void 0 : _a.concatTokens()) === "COMPONENT") {
26525
+ const componentSource = sources[sources.length - 2];
26526
+ const componentType = new source_1.Source().runSyntax(componentSource, scope, filename);
26527
+ if (new _type_utils_1.TypeUtils(scope).isAssignable(componentType, new basic_1.CharacterType(30)) === false) {
26528
+ throw new Error("component name must be charlike");
26529
+ }
26530
+ }
26531
+ if (sourceType === undefined || (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpression(Expressions.Dynamic))) {
26474
26532
  sourceType = new basic_1.AnyType();
26475
26533
  }
26476
- for (const d of ((_b = node.findDirectExpression(Expressions.AssignSource)) === null || _b === void 0 ? void 0 : _b.findAllExpressions(Expressions.Dynamic)) || []) {
26534
+ for (const d of (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findAllExpressions(Expressions.Dynamic)) || []) {
26477
26535
  new dynamic_1.Dynamic().runSyntax(d, scope, filename);
26478
26536
  }
26479
26537
  const target = node.findDirectExpression(Expressions.FSTarget);
@@ -35994,7 +36052,8 @@ class Message {
35994
36052
  return this.message;
35995
36053
  }
35996
36054
  getPlaceholderCount() {
35997
- return (this.getMessage().match(/&/g) || []).length;
36055
+ const escaped = (this.getMessage().match(/&&/g) || []).length;
36056
+ return (this.getMessage().match(/&/g) || []).length - escaped * 2;
35998
36057
  }
35999
36058
  }
36000
36059
  exports.Message = Message;
@@ -48199,7 +48258,7 @@ class Registry {
48199
48258
  }
48200
48259
  static abaplintVersion() {
48201
48260
  // magic, see build script "version.sh"
48202
- return "2.102.51";
48261
+ return "2.102.56";
48203
48262
  }
48204
48263
  getDDICReferences() {
48205
48264
  return this.ddicReferences;
@@ -60960,6 +61019,11 @@ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./
60960
61019
  const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplint/core/build/src/objects/index.js");
60961
61020
  const position_1 = __webpack_require__(/*! ../position */ "./node_modules/@abaplint/core/build/src/position.js");
60962
61021
  class MSAGConsistencyConf extends _basic_rule_config_1.BasicRuleConfig {
61022
+ constructor() {
61023
+ super(...arguments);
61024
+ /** paramters must be numbered */
61025
+ this.numericParamters = true;
61026
+ }
60963
61027
  }
60964
61028
  exports.MSAGConsistencyConf = MSAGConsistencyConf;
60965
61029
  class MSAGConsistency {
@@ -60993,7 +61057,7 @@ class MSAGConsistency {
60993
61057
  }
60994
61058
  const numbers = new Set();
60995
61059
  for (const message of obj.getMessages()) {
60996
- // todo, get the right positions in xml file
61060
+ // todo, get the right positions in xml file, and report the issue there
60997
61061
  if (!message.getNumber().match(/\d\d\d/)) {
60998
61062
  const text = this.getDescription("Message number must be 3 digits: message " + message.getNumber());
60999
61063
  const position = new position_1.Position(1, 1);
@@ -61016,6 +61080,25 @@ class MSAGConsistency {
61016
61080
  else {
61017
61081
  numbers.add(num);
61018
61082
  }
61083
+ if (this.getConfig().numericParamters === true) {
61084
+ const placeholderCount = message.getPlaceholderCount();
61085
+ if (placeholderCount > 4) {
61086
+ const text = `More than 4 placeholders in mesasge ${message.getNumber()}`;
61087
+ const position = new position_1.Position(1, 1);
61088
+ const issue = issue_1.Issue.atPosition(obj.getFiles()[0], position, text, this.getMetadata().key, this.conf.severity);
61089
+ issues.push(issue);
61090
+ }
61091
+ for (let i = 1; i <= placeholderCount; i++) {
61092
+ const placeholder = "&" + i;
61093
+ if (message.getMessage().includes(placeholder) === false) {
61094
+ const text = `Expected placeholder ${placeholder} in message ${message.getNumber()}`;
61095
+ const position = new position_1.Position(1, 1);
61096
+ const issue = issue_1.Issue.atPosition(obj.getFiles()[0], position, text, this.getMetadata().key, this.conf.severity);
61097
+ issues.push(issue);
61098
+ break;
61099
+ }
61100
+ }
61101
+ }
61019
61102
  }
61020
61103
  return issues;
61021
61104
  }
@@ -67578,6 +67661,7 @@ class UnreachableCode extends _abap_rule_1.ABAPRule {
67578
67661
  || s instanceof Statements.EndMethod
67579
67662
  || s instanceof Statements.EndModule
67580
67663
  || s instanceof Statements.EndForm
67664
+ || s instanceof Statements.EndTestSeam
67581
67665
  || s instanceof Statements.EndAt
67582
67666
  || s instanceof Statements.EndSelect
67583
67667
  || s instanceof Statements.AtSelectionScreen
@@ -83484,7 +83568,7 @@ Builder.prototype.j2x = function(jObj, level) {
83484
83568
  let attrStr = '';
83485
83569
  let val = '';
83486
83570
  for (let key in jObj) {
83487
- if(!jObj.hasOwnProperty(key)) continue;
83571
+ if(!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
83488
83572
  if (typeof jObj[key] === 'undefined') {
83489
83573
  // supress undefined node only if it is not an attribute
83490
83574
  if (this.isAttribute(key)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.7.101",
3
+ "version": "2.7.103",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -26,12 +26,12 @@
26
26
  "author": "abaplint",
27
27
  "license": "MIT",
28
28
  "devDependencies": {
29
- "@abaplint/transpiler": "^2.7.101",
29
+ "@abaplint/transpiler": "^2.7.103",
30
30
  "@types/glob": "^7.2.0",
31
31
  "glob": "=7.2.0",
32
32
  "@types/progress": "^2.0.5",
33
- "@types/node": "^20.7.1",
34
- "@abaplint/core": "^2.102.51",
33
+ "@types/node": "^20.8.3",
34
+ "@abaplint/core": "^2.102.56",
35
35
  "progress": "^2.0.3",
36
36
  "webpack": "^5.88.2",
37
37
  "webpack-cli": "^5.1.4",