@abaplint/cli 2.120.52 → 2.120.54

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/cli.js +227 -10
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -12387,7 +12387,7 @@ class CallTransaction {
12387
12387
  getMatcher() {
12388
12388
  const options = (0, combi_1.seq)("OPTIONS FROM", expressions_1.Source);
12389
12389
  const messages = (0, combi_1.seq)("MESSAGES INTO", expressions_1.Target);
12390
- const auth = (0, combi_1.seq)((0, combi_1.altPrio)("WITH", "WITHOUT"), "AUTHORITY-CHECK");
12390
+ const auth = (0, combi_1.ver)(version_1.Release.v740sp02, (0, combi_1.seq)((0, combi_1.altPrio)("WITH", "WITHOUT"), "AUTHORITY-CHECK"));
12391
12391
  const perm = (0, combi_1.per)((0, combi_1.seq)("UPDATE", expressions_1.Source), "AND SKIP FIRST SCREEN", options, messages, (0, combi_1.seq)("MODE", expressions_1.Source));
12392
12392
  const ret = (0, combi_1.seq)("CALL TRANSACTION", expressions_1.Source, (0, combi_1.optPrio)(auth), (0, combi_1.optPrio)((0, combi_1.seq)("USING", expressions_1.Source)), (0, combi_1.opt)(perm));
12393
12393
  return (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, ret);
@@ -24665,12 +24665,15 @@ class ABAPFileInformationParser {
24665
24665
  continue;
24666
24666
  }
24667
24667
  const parameters = this.parseMethodParameters(def);
24668
+ const concatenated = def.concatTokens().toUpperCase();
24668
24669
  methods.push({
24669
24670
  name: methodName.getStr(),
24670
24671
  identifier: new _identifier_1.Identifier(methodName, this.filename),
24671
24672
  isRedefinition: def.findDirectExpression(Expressions.Redefinition) !== undefined,
24672
- isForTesting: def.concatTokens().toUpperCase().includes(" FOR TESTING"),
24673
- isFinal: def.concatTokens().toUpperCase().includes(" FINAL"),
24673
+ isForTesting: concatenated.includes(" FOR TESTING"),
24674
+ isFinal: concatenated.includes(" FINAL"),
24675
+ isDefaultIgnore: concatenated.includes(" DEFAULT IGNORE"),
24676
+ isDefaultFail: concatenated.includes(" DEFAULT FAIL"),
24674
24677
  isAbstract: def.findDirectExpression(Expressions.Abstract) !== undefined,
24675
24678
  isEventHandler: def.findDirectExpression(Expressions.EventHandler) !== undefined,
24676
24679
  visibility,
@@ -34836,11 +34839,15 @@ class Source {
34836
34839
  }
34837
34840
  let hexExpected = false;
34838
34841
  let hexNext = false;
34842
+ // an arithmetic operator has been seen, so the operands that follow
34843
+ // determine a calculation type rather than simply replacing the context
34844
+ let arithmetic = false;
34839
34845
  while (children.length >= 0) {
34840
34846
  if (first instanceof nodes_1.ExpressionNode) {
34841
34847
  const get = first.get();
34842
34848
  if (get instanceof Expressions.MethodCallChain) {
34843
- context = method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
34849
+ const found = method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
34850
+ context = arithmetic === true ? this.infer(context, found, true) : found;
34844
34851
  if (context === undefined) {
34845
34852
  const message = "Method has no RETURNING value";
34846
34853
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -34848,18 +34855,19 @@ class Source {
34848
34855
  }
34849
34856
  }
34850
34857
  else if (get instanceof Expressions.FieldChain) {
34851
- context = field_chain_1.FieldChain.runSyntax(first, input, type, allowGenericDeference);
34858
+ const found = field_chain_1.FieldChain.runSyntax(first, input, type, allowGenericDeference);
34859
+ context = arithmetic === true ? this.infer(context, found, true) : found;
34852
34860
  }
34853
34861
  else if (get instanceof Expressions.StringTemplate) {
34854
34862
  context = string_template_1.StringTemplate.runSyntax(first, input);
34855
34863
  }
34856
34864
  else if (get instanceof Expressions.Source) {
34857
34865
  const found = Source.runSyntax(first, input);
34858
- context = this.infer(context, found);
34866
+ context = this.infer(context, found, arithmetic);
34859
34867
  }
34860
34868
  else if (get instanceof Expressions.Constant) {
34861
34869
  const found = constant_1.Constant.runSyntax(first);
34862
- context = this.infer(context, found);
34870
+ context = this.infer(context, found, arithmetic);
34863
34871
  }
34864
34872
  else if (get instanceof Expressions.Dereference) {
34865
34873
  context = dereference_1.Dereference.runSyntax(first, context, input);
@@ -34868,6 +34876,7 @@ class Source {
34868
34876
  context = component_chain_1.ComponentChain.runSyntax(context, first, input);
34869
34877
  }
34870
34878
  else if (get instanceof Expressions.ArithOperator) {
34879
+ arithmetic = true;
34871
34880
  if (first.concatTokens() === "**") {
34872
34881
  context = new basic_1.FloatType();
34873
34882
  }
@@ -34914,7 +34923,13 @@ class Source {
34914
34923
  Source.runSyntax(last, input);
34915
34924
  }
34916
34925
  }
34917
- static infer(context, found) {
34926
+ static infer(context, found, arithmetic = false) {
34927
+ if (arithmetic === true) {
34928
+ const calculation = this.calculationType(context, found);
34929
+ if (calculation !== undefined) {
34930
+ return calculation;
34931
+ }
34932
+ }
34918
34933
  if (context instanceof basic_1.FloatType && found instanceof basic_1.IntegerType) {
34919
34934
  return context;
34920
34935
  }
@@ -34928,6 +34943,56 @@ class Source {
34928
34943
  return found;
34929
34944
  }
34930
34945
  }
34946
+ /** The calculation type of an arithmetic expression is the most general of the
34947
+ * operand types. An operand of type c, n, d, t or string is converted into it and
34948
+ * never becomes the result: "lv_f * '0.25'" is a float, not a character field of
34949
+ * length four. Returns undefined when neither operand is numeric, leaving the
34950
+ * decision to the caller. */
34951
+ static calculationType(left, right) {
34952
+ if (left === undefined || right === undefined) {
34953
+ return undefined;
34954
+ }
34955
+ else if (left instanceof basic_1.VoidType || left instanceof unknown_type_1.UnknownType) {
34956
+ // not knowing an operand means not knowing the result
34957
+ return left;
34958
+ }
34959
+ else if (right instanceof basic_1.VoidType || right instanceof unknown_type_1.UnknownType) {
34960
+ return right;
34961
+ }
34962
+ const leftRank = this.numericRank(left);
34963
+ const rightRank = this.numericRank(right);
34964
+ if (leftRank === undefined && rightRank === undefined) {
34965
+ return undefined;
34966
+ }
34967
+ else if (rightRank === undefined) {
34968
+ return left;
34969
+ }
34970
+ else if (leftRank === undefined) {
34971
+ return right;
34972
+ }
34973
+ return leftRank >= rightRank ? left : right;
34974
+ }
34975
+ static numericRank(type) {
34976
+ if (type instanceof basic_1.DecFloat34Type) {
34977
+ return 6;
34978
+ }
34979
+ else if (type instanceof basic_1.DecFloat16Type) {
34980
+ return 5;
34981
+ }
34982
+ else if (type instanceof basic_1.FloatType) {
34983
+ return 4;
34984
+ }
34985
+ else if (type instanceof basic_1.PackedType) {
34986
+ return 3;
34987
+ }
34988
+ else if (type instanceof basic_1.Integer8Type) {
34989
+ return 2;
34990
+ }
34991
+ else if (type instanceof basic_1.IntegerType) {
34992
+ return 1;
34993
+ }
34994
+ return undefined;
34995
+ }
34931
34996
  static addIfInferred(node, input, inferredType) {
34932
34997
  const basic = new basic_types_1.BasicTypes(input);
34933
34998
  const typeExpression = node.findDirectExpression(Expressions.TypeNameOrInfer);
@@ -70579,7 +70644,7 @@ class Registry {
70579
70644
  }
70580
70645
  static abaplintVersion() {
70581
70646
  // magic, see build script "version.js"
70582
- return "2.120.52";
70647
+ return "2.120.54";
70583
70648
  }
70584
70649
  getDDICReferences() {
70585
70650
  return this.ddicReferences;
@@ -78039,7 +78104,11 @@ Make sure to test the downported code, it might not always be completely correct
78039
78104
  return found;
78040
78105
  }
78041
78106
  */
78042
- let found = this.downportEnum(low, high, lowFile, highSyntax, highFile);
78107
+ let found = this.stripCallTransactionAuthorityCheck(high, lowFile);
78108
+ if (found) {
78109
+ return found;
78110
+ }
78111
+ found = this.downportEnum(low, high, lowFile, highSyntax, highFile);
78043
78112
  if (found) {
78044
78113
  return found;
78045
78114
  }
@@ -80533,6 +80602,27 @@ ${indentation} output = ${uniqueName}.\n`;
80533
80602
  }
80534
80603
  return false;
80535
80604
  }
80605
+ /** WITH/WITHOUT AUTHORITY-CHECK on CALL TRANSACTION requires v740sp02, so the statement is
80606
+ * Unknown in the low version, note that only WITHOUT is handled here */
80607
+ stripCallTransactionAuthorityCheck(high, lowFile) {
80608
+ if (!(high.get() instanceof Statements.CallTransaction)) {
80609
+ return undefined;
80610
+ }
80611
+ const tokens = high.getTokens();
80612
+ // the lexer splits "AUTHORITY-CHECK" into three tokens: AUTHORITY, -, CHECK
80613
+ for (let i = 1; i < tokens.length - 3; i++) {
80614
+ if (tokens[i].getStr().toUpperCase() === "WITHOUT"
80615
+ && tokens[i + 1].getStr().toUpperCase() === "AUTHORITY"
80616
+ && tokens[i + 2].getStr() === "-"
80617
+ && tokens[i + 3].getStr().toUpperCase() === "CHECK") {
80618
+ // also remove the preceding space so no double space is left behind
80619
+ const fix = edit_helper_1.EditHelper.deleteRange(lowFile, tokens[i - 1].getEnd(), tokens[i + 3].getEnd());
80620
+ const message = "Remove WITHOUT AUTHORITY-CHECK from CALL TRANSACTION";
80621
+ return issue_1.Issue.atToken(lowFile, tokens[i], message, this.getMetadata().key, this.conf.severity, fix);
80622
+ }
80623
+ }
80624
+ return undefined;
80625
+ }
80536
80626
  replaceXsdBool(node, lowFile, highSyntax) {
80537
80627
  if (this.lowReg.getConfig().isOpenABAP()) {
80538
80628
  return undefined;
@@ -84186,6 +84276,11 @@ class ImplementMethods extends _abap_rule_1.ABAPRule {
84186
84276
  return [idef];
84187
84277
  }
84188
84278
  for (const m of this.findInterfaceMethods(idef)) {
84279
+ if (m.method.isDefaultIgnore === true || m.method.isDefaultFail === true) {
84280
+ // the interface says an implementation is optional, so asking for one
84281
+ // reports an error where ABAP reports none
84282
+ continue;
84283
+ }
84189
84284
  if (this.isAbstract(m, interfaceInfo, def)) {
84190
84285
  if (def.isAbstract) {
84191
84286
  continue;
@@ -84937,6 +85032,7 @@ __exportStar(__webpack_require__(/*! ./parser_missing_space */ "../core/build/sr
84937
85032
  __exportStar(__webpack_require__(/*! ./pragma_style */ "../core/build/src/rules/pragma_style.js"), exports);
84938
85033
  __exportStar(__webpack_require__(/*! ./prefer_corresponding */ "../core/build/src/rules/prefer_corresponding.js"), exports);
84939
85034
  __exportStar(__webpack_require__(/*! ./prefer_inline */ "../core/build/src/rules/prefer_inline.js"), exports);
85035
+ __exportStar(__webpack_require__(/*! ./prefer_insert_into_table */ "../core/build/src/rules/prefer_insert_into_table.js"), exports);
84940
85036
  __exportStar(__webpack_require__(/*! ./prefer_is_not */ "../core/build/src/rules/prefer_is_not.js"), exports);
84941
85037
  __exportStar(__webpack_require__(/*! ./prefer_pragmas */ "../core/build/src/rules/prefer_pragmas.js"), exports);
84942
85038
  __exportStar(__webpack_require__(/*! ./prefer_raise_exception_new */ "../core/build/src/rules/prefer_raise_exception_new.js"), exports);
@@ -92616,6 +92712,127 @@ exports.PreferInline = PreferInline;
92616
92712
 
92617
92713
  /***/ },
92618
92714
 
92715
+ /***/ "../core/build/src/rules/prefer_insert_into_table.js"
92716
+ /*!***********************************************************!*\
92717
+ !*** ../core/build/src/rules/prefer_insert_into_table.js ***!
92718
+ \***********************************************************/
92719
+ (__unused_webpack_module, exports, __webpack_require__) {
92720
+
92721
+ "use strict";
92722
+
92723
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
92724
+ if (k2 === undefined) k2 = k;
92725
+ var desc = Object.getOwnPropertyDescriptor(m, k);
92726
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
92727
+ desc = { enumerable: true, get: function() { return m[k]; } };
92728
+ }
92729
+ Object.defineProperty(o, k2, desc);
92730
+ }) : (function(o, m, k, k2) {
92731
+ if (k2 === undefined) k2 = k;
92732
+ o[k2] = m[k];
92733
+ }));
92734
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
92735
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
92736
+ }) : function(o, v) {
92737
+ o["default"] = v;
92738
+ });
92739
+ var __importStar = (this && this.__importStar) || (function () {
92740
+ var ownKeys = function(o) {
92741
+ ownKeys = Object.getOwnPropertyNames || function (o) {
92742
+ var ar = [];
92743
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
92744
+ return ar;
92745
+ };
92746
+ return ownKeys(o);
92747
+ };
92748
+ return function (mod) {
92749
+ if (mod && mod.__esModule) return mod;
92750
+ var result = {};
92751
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
92752
+ __setModuleDefault(result, mod);
92753
+ return result;
92754
+ };
92755
+ })();
92756
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
92757
+ exports.PreferInsertIntoTable = exports.PreferInsertIntoTableConf = void 0;
92758
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
92759
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
92760
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
92761
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
92762
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
92763
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
92764
+ class PreferInsertIntoTableConf extends _basic_rule_config_1.BasicRuleConfig {
92765
+ }
92766
+ exports.PreferInsertIntoTableConf = PreferInsertIntoTableConf;
92767
+ class PreferInsertIntoTable extends _abap_rule_1.ABAPRule {
92768
+ constructor() {
92769
+ super(...arguments);
92770
+ this.conf = new PreferInsertIntoTableConf();
92771
+ }
92772
+ getMetadata() {
92773
+ return {
92774
+ key: "prefer_insert_into_table",
92775
+ title: "Prefer INSERT INTO TABLE over APPEND",
92776
+ shortDescription: `Prefer INSERT INTO TABLE over APPEND`,
92777
+ extendedInformation: `INSERT INTO TABLE respects the table type, while APPEND always adds to the end regardless of table type.
92778
+
92779
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md`,
92780
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
92781
+ badExample: `APPEND row TO itab.`,
92782
+ goodExample: `INSERT row INTO TABLE itab.`,
92783
+ };
92784
+ }
92785
+ getConfig() { return this.conf; }
92786
+ setConfig(conf) { this.conf = conf; }
92787
+ runParsed(file) {
92788
+ const issues = [];
92789
+ for (const stat of file.getStatements()) {
92790
+ if (!(stat.get() instanceof Statements.Append)) {
92791
+ continue;
92792
+ }
92793
+ if (stat.concatTokens().toUpperCase().includes(" SORTED BY ")) {
92794
+ continue;
92795
+ }
92796
+ const fix = this.buildFix(file, stat);
92797
+ const message = "Prefer INSERT INTO TABLE over APPEND";
92798
+ issues.push(issue_1.Issue.atStatement(file, stat, message, this.getMetadata().key, this.conf.severity, fix));
92799
+ }
92800
+ return issues;
92801
+ }
92802
+ buildFix(file, stat) {
92803
+ const tokens = stat.getTokens();
92804
+ // Find the APPEND token (first token)
92805
+ const appendToken = tokens[0];
92806
+ if (appendToken.getStr().toUpperCase() !== "APPEND") {
92807
+ return undefined;
92808
+ }
92809
+ // Find the last "TO" token that precedes the table target.
92810
+ // In all fixable forms the table target follows the last standalone "TO":
92811
+ // APPEND row TO itab
92812
+ // APPEND LINES OF itab2 TO itab
92813
+ // APPEND LINES OF itab2 FROM 1 TO 3 TO itab <- last TO is the table
92814
+ // APPEND INITIAL LINE TO itab
92815
+ let lastToIndex = -1;
92816
+ for (let i = tokens.length - 1; i >= 0; i--) {
92817
+ if (tokens[i].getStr().toUpperCase() === "TO") {
92818
+ lastToIndex = i;
92819
+ break;
92820
+ }
92821
+ }
92822
+ if (lastToIndex < 0) {
92823
+ return undefined;
92824
+ }
92825
+ const toToken = tokens[lastToIndex];
92826
+ const fix1 = edit_helper_1.EditHelper.replaceToken(file, appendToken, "INSERT");
92827
+ const fix2 = edit_helper_1.EditHelper.replaceToken(file, toToken, "INTO TABLE");
92828
+ return edit_helper_1.EditHelper.merge(fix1, fix2);
92829
+ }
92830
+ }
92831
+ exports.PreferInsertIntoTable = PreferInsertIntoTable;
92832
+ //# sourceMappingURL=prefer_insert_into_table.js.map
92833
+
92834
+ /***/ },
92835
+
92619
92836
  /***/ "../core/build/src/rules/prefer_is_not.js"
92620
92837
  /*!************************************************!*\
92621
92838
  !*** ../core/build/src/rules/prefer_is_not.js ***!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.52",
3
+ "version": "2.120.54",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.120.52",
42
+ "@abaplint/core": "^2.120.54",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",