@abaplint/transpiler-cli 2.5.71 → 2.5.72

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 +130 -41
  2. package/package.json +3 -3
package/build/bundle.js CHANGED
@@ -20792,13 +20792,18 @@ class BasicTypes {
20792
20792
  return undefined;
20793
20793
  }
20794
20794
  let type = undefined;
20795
- if (text.startsWith("TYPE STANDARD TABLE ") || text.startsWith("LIKE STANDARD TABLE ")) {
20795
+ if (text.startsWith("TYPE STANDARD TABLE ")
20796
+ || text.startsWith("TYPE TABLE ")
20797
+ || text.startsWith("LIKE TABLE ")
20798
+ || text.startsWith("LIKE STANDARD TABLE ")) {
20796
20799
  type = basic_1.TableAccessType.standard;
20797
20800
  }
20798
- else if (text.startsWith("TYPE SORTED TABLE ") || text.startsWith("LIKE SORTED TABLE ")) {
20801
+ else if (text.startsWith("TYPE SORTED TABLE ")
20802
+ || text.startsWith("LIKE SORTED TABLE ")) {
20799
20803
  type = basic_1.TableAccessType.sorted;
20800
20804
  }
20801
- else if (text.startsWith("TYPE HASHED TABLE ") || text.startsWith("LIKE HASHED TABLE ")) {
20805
+ else if (text.startsWith("TYPE HASHED TABLE ")
20806
+ || text.startsWith("LIKE HASHED TABLE ")) {
20802
20807
  type = basic_1.TableAccessType.hashed;
20803
20808
  }
20804
20809
  const typeTableKeys = node.findAllExpressions(expressions_1.TypeTableKey);
@@ -20815,6 +20820,9 @@ class BasicTypes {
20815
20820
  for (const k of (firstKey === null || firstKey === void 0 ? void 0 : firstKey.findDirectExpressions(expressions_1.FieldSub)) || []) {
20816
20821
  primaryKey.keyFields.push(k.concatTokens().toUpperCase());
20817
20822
  }
20823
+ if (primaryKey.keyFields.length === 0 && text.includes(" DEFAULT KEY")) {
20824
+ primaryKey.keyFields.push("TABLE_LINE");
20825
+ }
20818
20826
  }
20819
20827
  else {
20820
20828
  start = 0;
@@ -20889,6 +20897,7 @@ class BasicTypes {
20889
20897
  { name: "low", type: found },
20890
20898
  { name: "high", type: found },
20891
20899
  ]);
20900
+ options.primaryKey.type = basic_1.TableAccessType.standard;
20892
20901
  return new Types.TableType(structure, options, name);
20893
20902
  }
20894
20903
  else if (text.startsWith("LIKE RANGE OF ")) {
@@ -20903,6 +20912,7 @@ class BasicTypes {
20903
20912
  { name: "low", type: found },
20904
20913
  { name: "high", type: found },
20905
20914
  ], name);
20915
+ options.primaryKey.type = basic_1.TableAccessType.standard;
20906
20916
  return new Types.TableType(structure, options);
20907
20917
  }
20908
20918
  else if (typename && (text.startsWith("TYPE TABLE FOR CREATE ")
@@ -23235,8 +23245,10 @@ class MethodDefReturning {
23235
23245
  if (type === undefined) {
23236
23246
  throw new Error("method_parameter.ts, unexpected structure");
23237
23247
  }
23238
- const found = new basic_types_1.BasicTypes(filename, scope).parseType(type);
23239
- // console.dir(found);
23248
+ let found = new basic_types_1.BasicTypes(filename, scope).parseType(type);
23249
+ if ((found === null || found === void 0 ? void 0 : found.isGeneric()) === true) {
23250
+ found = new basic_1.UnknownType("RETURNING parameter must be fully specified");
23251
+ }
23240
23252
  if (found) {
23241
23253
  return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), filename, found, meta);
23242
23254
  }
@@ -26460,7 +26472,12 @@ class Data {
26460
26472
  runSyntax(node, scope, filename) {
26461
26473
  const dd = node.findFirstExpression(Expressions.DataDefinition);
26462
26474
  if (dd) {
26463
- return new data_definition_1.DataDefinition().runSyntax(dd, scope, filename);
26475
+ const id = new data_definition_1.DataDefinition().runSyntax(dd, scope, filename);
26476
+ if ((id === null || id === void 0 ? void 0 : id.getType().isGeneric()) === true
26477
+ && (id === null || id === void 0 ? void 0 : id.getType().containsVoid()) === false) {
26478
+ throw new Error("DATA definition cannot be generic");
26479
+ }
26480
+ return id;
26464
26481
  }
26465
26482
  const name = node.findFirstExpression(Expressions.DefinitionName);
26466
26483
  if (name) {
@@ -32697,7 +32714,8 @@ class DataReference extends _abstract_type_1.AbstractType {
32697
32714
  return "REF TO " + this.type.toABAP();
32698
32715
  }
32699
32716
  isGeneric() {
32700
- return this.type.isGeneric();
32717
+ // a DATA definition can be "REF TO data", so its not generic
32718
+ return false;
32701
32719
  }
32702
32720
  containsVoid() {
32703
32721
  return this.type.containsVoid();
@@ -32971,7 +32989,8 @@ class GenericObjectReferenceType extends _abstract_type_1.AbstractType {
32971
32989
  return "```REF TO object```";
32972
32990
  }
32973
32991
  isGeneric() {
32974
- return true;
32992
+ // a DATA definition can be "REF TO object", so its not generic
32993
+ return false;
32975
32994
  }
32976
32995
  toABAP() {
32977
32996
  return "REF TO object";
@@ -33477,6 +33496,11 @@ class TableType extends _abstract_type_1.AbstractType {
33477
33496
  }
33478
33497
  }
33479
33498
  isGeneric() {
33499
+ var _a, _b;
33500
+ if (((_a = this.options.primaryKey) === null || _a === void 0 ? void 0 : _a.type) !== TableAccessType.standard
33501
+ && ((_b = this.options.primaryKey) === null || _b === void 0 ? void 0 : _b.keyFields.length) === 0) {
33502
+ return true;
33503
+ }
33480
33504
  return this.rowType.isGeneric();
33481
33505
  }
33482
33506
  containsVoid() {
@@ -46213,7 +46237,7 @@ class Registry {
46213
46237
  }
46214
46238
  static abaplintVersion() {
46215
46239
  // magic, see build script "version.sh"
46216
- return "2.95.51";
46240
+ return "2.96.2";
46217
46241
  }
46218
46242
  getDDICReferences() {
46219
46243
  return this.references;
@@ -54533,6 +54557,75 @@ exports.FullyTypeConstants = FullyTypeConstants;
54533
54557
 
54534
54558
  /***/ }),
54535
54559
 
54560
+ /***/ "./node_modules/@abaplint/core/build/src/rules/fully_type_itabs.js":
54561
+ /*!*************************************************************************!*\
54562
+ !*** ./node_modules/@abaplint/core/build/src/rules/fully_type_itabs.js ***!
54563
+ \*************************************************************************/
54564
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
54565
+
54566
+ "use strict";
54567
+
54568
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
54569
+ exports.FullyTypeITabs = exports.FullyTypeITabsConf = void 0;
54570
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
54571
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@abaplint/core/build/src/rules/_abap_rule.js");
54572
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
54573
+ const Statements = __webpack_require__(/*! ../abap/2_statements/statements */ "./node_modules/@abaplint/core/build/src/abap/2_statements/statements/index.js");
54574
+ const Expressions = __webpack_require__(/*! ../abap/2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
54575
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
54576
+ class FullyTypeITabsConf extends _basic_rule_config_1.BasicRuleConfig {
54577
+ }
54578
+ exports.FullyTypeITabsConf = FullyTypeITabsConf;
54579
+ class FullyTypeITabs extends _abap_rule_1.ABAPRule {
54580
+ constructor() {
54581
+ super(...arguments);
54582
+ this.conf = new FullyTypeITabsConf();
54583
+ }
54584
+ getMetadata() {
54585
+ return {
54586
+ key: "fully_type_itabs",
54587
+ title: "Fully type internal tables",
54588
+ shortDescription: `No implict table types or table keys`,
54589
+ badExample: `DATA lt_foo TYPE TABLE OF ty.
54590
+ DATA lt_bar TYPE STANDARD TABLE OF ty.`,
54591
+ goodExample: `DATA lt_foo TYPE STANDARD TABLE OF ty WITH EMPTY KEY.`,
54592
+ tags: [_irule_1.RuleTag.SingleFile],
54593
+ };
54594
+ }
54595
+ getConfig() {
54596
+ return this.conf;
54597
+ }
54598
+ setConfig(conf) {
54599
+ this.conf = conf;
54600
+ }
54601
+ runParsed(file) {
54602
+ const issues = [];
54603
+ for (const statement of file.getStatements()) {
54604
+ if (!(statement.get() instanceof Statements.Data)) {
54605
+ continue;
54606
+ }
54607
+ const tt = statement.findFirstExpression(Expressions.TypeTable);
54608
+ if (tt === undefined) {
54609
+ continue;
54610
+ }
54611
+ const concat = tt.concatTokens().toUpperCase();
54612
+ if (concat.includes("TYPE TABLE OF")) {
54613
+ const message = "Specify table type";
54614
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
54615
+ }
54616
+ else if (concat.includes(" WITH ") === false) {
54617
+ const message = "Specify table key";
54618
+ issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
54619
+ }
54620
+ }
54621
+ return issues;
54622
+ }
54623
+ }
54624
+ exports.FullyTypeITabs = FullyTypeITabs;
54625
+ //# sourceMappingURL=fully_type_itabs.js.map
54626
+
54627
+ /***/ }),
54628
+
54536
54629
  /***/ "./node_modules/@abaplint/core/build/src/rules/function_module_recommendations.js":
54537
54630
  /*!****************************************************************************************!*\
54538
54631
  !*** ./node_modules/@abaplint/core/build/src/rules/function_module_recommendations.js ***!
@@ -56031,6 +56124,7 @@ __exportStar(__webpack_require__(/*! ./forbidden_pseudo_and_pragma */ "./node_mo
56031
56124
  __exportStar(__webpack_require__(/*! ./forbidden_void_type */ "./node_modules/@abaplint/core/build/src/rules/forbidden_void_type.js"), exports);
56032
56125
  __exportStar(__webpack_require__(/*! ./form_tables_obsolete */ "./node_modules/@abaplint/core/build/src/rules/form_tables_obsolete.js"), exports);
56033
56126
  __exportStar(__webpack_require__(/*! ./fully_type_constants */ "./node_modules/@abaplint/core/build/src/rules/fully_type_constants.js"), exports);
56127
+ __exportStar(__webpack_require__(/*! ./fully_type_itabs */ "./node_modules/@abaplint/core/build/src/rules/fully_type_itabs.js"), exports);
56034
56128
  __exportStar(__webpack_require__(/*! ./function_module_recommendations */ "./node_modules/@abaplint/core/build/src/rules/function_module_recommendations.js"), exports);
56035
56129
  __exportStar(__webpack_require__(/*! ./functional_writing */ "./node_modules/@abaplint/core/build/src/rules/functional_writing.js"), exports);
56036
56130
  __exportStar(__webpack_require__(/*! ./global_class */ "./node_modules/@abaplint/core/build/src/rules/global_class.js"), exports);
@@ -62103,7 +62197,8 @@ If the target is a sorted/hashed table, no issue is reported`,
62103
62197
  type = found;
62104
62198
  }
62105
62199
  if (type instanceof basic_1.TableType
62106
- && ((type === null || type === void 0 ? void 0 : type.getAccessType()) === basic_1.TableAccessType.sorted || (type === null || type === void 0 ? void 0 : type.getAccessType()) === basic_1.TableAccessType.hashed)) {
62200
+ && ((type === null || type === void 0 ? void 0 : type.getAccessType()) === basic_1.TableAccessType.sorted
62201
+ || (type === null || type === void 0 ? void 0 : type.getAccessType()) === basic_1.TableAccessType.hashed)) {
62107
62202
  return true;
62108
62203
  }
62109
62204
  }
@@ -62931,6 +63026,7 @@ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "./node_modules/@ab
62931
63026
  const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
62932
63027
  const version_1 = __webpack_require__(/*! ../version */ "./node_modules/@abaplint/core/build/src/version.js");
62933
63028
  const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
63029
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "./node_modules/@abaplint/core/build/src/edit_helper.js");
62934
63030
  class SQLEscapeHostVariablesConf extends _basic_rule_config_1.BasicRuleConfig {
62935
63031
  }
62936
63032
  exports.SQLEscapeHostVariablesConf = SQLEscapeHostVariablesConf;
@@ -62945,7 +63041,7 @@ class SQLEscapeHostVariables extends _abap_rule_1.ABAPRule {
62945
63041
  title: "Escape SQL host variables",
62946
63042
  shortDescription: `Escape SQL host variables, from 740sp05`,
62947
63043
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-obsolete-language-elements`,
62948
- tags: [_irule_1.RuleTag.Upport, _irule_1.RuleTag.Styleguide],
63044
+ tags: [_irule_1.RuleTag.Upport, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
62949
63045
  badExample: `SELECT * FROM tab INTO TABLE res WHERE field = val.`,
62950
63046
  goodExample: `SELECT * FROM tab INTO TABLE @res WHERE field = @val.`,
62951
63047
  };
@@ -62958,52 +63054,45 @@ class SQLEscapeHostVariables extends _abap_rule_1.ABAPRule {
62958
63054
  }
62959
63055
  runParsed(file, obj) {
62960
63056
  const issues = [];
62961
- if (obj.getType() === "INTF") {
63057
+ const type = obj.getType();
63058
+ if (type === "INTF" || type === "TYPE") {
62962
63059
  return [];
62963
63060
  }
62964
- if (this.reg.getConfig().getVersion() < version_1.Version.v740sp02 && this.reg.getConfig().getVersion() !== version_1.Version.Cloud) {
63061
+ if (this.reg.getConfig().getVersion() < version_1.Version.v740sp02
63062
+ && this.reg.getConfig().getVersion() !== version_1.Version.Cloud) {
62965
63063
  return [];
62966
63064
  }
62967
63065
  for (const s of file.getStatements()) {
62968
- const str = s.concatTokens().toUpperCase();
62969
- if (s.get() instanceof Statements.Select
62970
- || s.get() instanceof Statements.SelectLoop) {
62971
- // this is not completely correct and does not catch all, but okay for now
62972
- // todo: replace with logic from "else if" branch below, when/if it proves to work
62973
- if (str.includes(" INTO ( @")
62974
- || str.includes(" INTO (@")
62975
- || str.includes(" INTO @")
62976
- || str.includes(" INTO TABLE @")
62977
- || str.includes(" INTO CORRESPONDING FIELDS OF @")
62978
- || str.includes(" INTO CORRESPONDING FIELDS OF TABLE @")
62979
- || str.includes(" APPENDING TABLE @")
62980
- || (str.includes(" APPENDING ") === false && str.includes(" INTO ") === false)
62981
- || str.includes(" APPENDING CORRESPONDING FIELDS OF TABLE @")) {
62982
- continue;
62983
- }
62984
- else {
62985
- const message = "Escape SQL host variables";
62986
- const issue = issue_1.Issue.atToken(file, s.getFirstToken(), message, this.getMetadata().key, this.conf.severity);
62987
- issues.push(issue);
62988
- }
62989
- }
62990
- else if (s.get() instanceof Statements.UpdateDatabase
63066
+ if (s.get() instanceof Statements.UpdateDatabase
62991
63067
  || s.get() instanceof Statements.ModifyDatabase
63068
+ || s.get() instanceof Statements.Select
63069
+ || s.get() instanceof Statements.SelectLoop
62992
63070
  || s.get() instanceof Statements.InsertDatabase
62993
63071
  || s.get() instanceof Statements.DeleteDatabase) {
62994
- if (str.startsWith("MODIFY SCREEN FROM ")) {
62995
- continue;
62996
- }
62997
63072
  for (const o of s.findAllExpressions(Expressions.SQLSource)) {
62998
63073
  const first = o.getFirstChild();
62999
63074
  if (((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.Source && first.getChildren()[0].get() instanceof Expressions.FieldChain)
63000
63075
  || ((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.SimpleSource3 && first.getChildren()[0].get() instanceof Expressions.FieldChain)) {
63001
63076
  const message = "Escape SQL host variables";
63002
- const issue = issue_1.Issue.atToken(file, first.getFirstToken(), message, this.getMetadata().key, this.conf.severity);
63077
+ const firstToken = o.getFirstChild().getFirstToken();
63078
+ const fix = edit_helper_1.EditHelper.replaceToken(file, firstToken, "@" + (firstToken === null || firstToken === void 0 ? void 0 : firstToken.getStr()));
63079
+ const issue = issue_1.Issue.atToken(file, first.getFirstToken(), message, this.getMetadata().key, this.conf.severity, fix);
63003
63080
  issues.push(issue);
63004
63081
  break;
63005
63082
  }
63006
63083
  }
63084
+ for (const o of s.findAllExpressions(Expressions.SQLTarget)) {
63085
+ const escaped = o.findDirectTokenByText("@");
63086
+ if (escaped !== undefined) {
63087
+ continue;
63088
+ }
63089
+ const message = "Escape SQL host variables";
63090
+ const firstToken = o.getFirstChild().getFirstToken();
63091
+ const fix = edit_helper_1.EditHelper.replaceToken(file, firstToken, "@" + (firstToken === null || firstToken === void 0 ? void 0 : firstToken.getStr()));
63092
+ const issue = issue_1.Issue.atToken(file, o.getFirstToken(), message, this.getMetadata().key, this.conf.severity, fix);
63093
+ issues.push(issue);
63094
+ break;
63095
+ }
63007
63096
  }
63008
63097
  }
63009
63098
  return issues;
@@ -76273,7 +76362,7 @@ class ClassImplementationTranspiler {
76273
76362
  if (isStatic === false) {
76274
76363
  continue;
76275
76364
  }
76276
- ret += clasName + "." + alias.getName().toLowerCase() + " = " + clasName + "." + alias.getComponent().replace("~", "$") + ";\n";
76365
+ ret += traversal_1.Traversal.escapeNamespace(clasName) + "." + alias.getName().toLowerCase() + " = " + traversal_1.Traversal.escapeNamespace(clasName) + "." + traversal_1.Traversal.escapeNamespace(alias.getComponent().replace("~", "$")) + ";\n";
76277
76366
  }
76278
76367
  // this is not correct, ABAP does not invocate the class constructor at require time,
76279
76368
  // but this will probably work
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.5.71",
3
+ "version": "2.5.72",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "bin": {
6
6
  "abap_transpile": "./abap_transpile"
@@ -25,12 +25,12 @@
25
25
  "author": "abaplint",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@abaplint/transpiler": "^2.5.71",
28
+ "@abaplint/transpiler": "^2.5.72",
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.95.51",
33
+ "@abaplint/core": "^2.96.2",
34
34
  "progress": "^2.0.3",
35
35
  "webpack": "^5.77.0",
36
36
  "webpack-cli": "^5.0.1",