@abaplint/cli 2.100.6 → 2.101.0

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 +209 -11
  2. package/package.json +3 -3
package/build/cli.js CHANGED
@@ -20401,6 +20401,9 @@ class CurrentScope {
20401
20401
  getVersion() {
20402
20402
  return this.reg.getConfig().getVersion();
20403
20403
  }
20404
+ getRegistry() {
20405
+ return this.reg;
20406
+ }
20404
20407
  addType(type) {
20405
20408
  if (type === undefined) {
20406
20409
  return;
@@ -20500,6 +20503,10 @@ class CurrentScope {
20500
20503
  const position = new _identifier_1.Identifier(usage, filename);
20501
20504
  (_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().references.push({ position, resolved: referencing, referenceType: type, extra });
20502
20505
  }
20506
+ addSQLConversion(fieldName, message, token) {
20507
+ var _a;
20508
+ (_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().sqlConversion.push({ fieldName, message, token });
20509
+ }
20503
20510
  ///////////////////////////
20504
20511
  findFunctionModule(name) {
20505
20512
  if (name === undefined) {
@@ -23386,7 +23393,7 @@ class DatabaseTable {
23386
23393
  const name = token.getStr();
23387
23394
  if (name === "(") {
23388
23395
  // dynamic
23389
- return;
23396
+ return undefined;
23390
23397
  }
23391
23398
  const found = scope.getDDIC().lookupTableOrView2(name);
23392
23399
  if (found === undefined && scope.getDDIC().inErrorNamespace(name) === true) {
@@ -23399,6 +23406,7 @@ class DatabaseTable {
23399
23406
  scope.addReference(token, found.getIdentifier(), _reference_1.ReferenceType.TableReference, filename);
23400
23407
  scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found, token: token, filename: filename });
23401
23408
  }
23409
+ return found;
23402
23410
  }
23403
23411
  }
23404
23412
  exports.DatabaseTable = DatabaseTable;
@@ -25283,17 +25291,16 @@ const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@ab
25283
25291
  const inline_data_1 = __webpack_require__(/*! ./inline_data */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/inline_data.js");
25284
25292
  const target_1 = __webpack_require__(/*! ./target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
25285
25293
  const sql_from_1 = __webpack_require__(/*! ./sql_from */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_from.js");
25286
- const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
25287
25294
  const sql_for_all_entries_1 = __webpack_require__(/*! ./sql_for_all_entries */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_for_all_entries.js");
25288
25295
  const _scope_type_1 = __webpack_require__(/*! ../_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
25296
+ const sql_source_1 = __webpack_require__(/*! ./sql_source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_source.js");
25297
+ const sql_compare_1 = __webpack_require__(/*! ./sql_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_compare.js");
25289
25298
  class Select {
25290
25299
  runSyntax(node, scope, filename, skipImplicitInto = false) {
25291
25300
  var _a, _b;
25292
25301
  const token = node.getFirstToken();
25293
25302
  const from = node.findDirectExpression(Expressions.SQLFrom);
25294
- if (from) {
25295
- new sql_from_1.SQLFrom().runSyntax(from, scope, filename);
25296
- }
25303
+ const dbSources = from ? new sql_from_1.SQLFrom().runSyntax(from, scope, filename) : [];
25297
25304
  for (const inline of node.findAllExpressions(Expressions.InlineData)) {
25298
25305
  // todo, for now these are voided
25299
25306
  new inline_data_1.InlineData().runSyntax(inline, scope, filename, new basic_1.VoidType("SELECT_todo"));
@@ -25319,11 +25326,22 @@ class Select {
25319
25326
  }
25320
25327
  }
25321
25328
  }
25322
- for (const s of node.findAllExpressions(Expressions.Source)) {
25323
- new source_1.Source().runSyntax(s, scope, filename);
25329
+ // OFFSET
25330
+ for (const s of node.findDirectExpressions(Expressions.SQLSource)) {
25331
+ new sql_source_1.SQLSource().runSyntax(s, scope, filename);
25324
25332
  }
25325
- for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
25326
- new source_1.Source().runSyntax(s, scope, filename);
25333
+ for (const up of node.findDirectExpressions(Expressions.SQLUpTo)) {
25334
+ for (const s of up.findDirectExpressions(Expressions.SQLSource)) {
25335
+ new sql_source_1.SQLSource().runSyntax(s, scope, filename);
25336
+ }
25337
+ }
25338
+ for (const fae of node.findDirectExpressions(Expressions.SQLForAllEntries)) {
25339
+ for (const s of fae.findDirectExpressions(Expressions.SQLSource)) {
25340
+ new sql_source_1.SQLSource().runSyntax(s, scope, filename);
25341
+ }
25342
+ }
25343
+ for (const s of node.findAllExpressions(Expressions.SQLCompare)) {
25344
+ new sql_compare_1.SQLCompare().runSyntax(s, scope, filename, dbSources);
25327
25345
  }
25328
25346
  if (scope.getType() === _scope_type_1.ScopeType.OpenSQL) {
25329
25347
  scope.pop(node.getLastToken().getEnd());
@@ -25683,6 +25701,79 @@ exports.SourceFieldSymbol = SourceFieldSymbol;
25683
25701
 
25684
25702
  /***/ }),
25685
25703
 
25704
+ /***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_compare.js":
25705
+ /*!****************************************************************************************!*\
25706
+ !*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_compare.js ***!
25707
+ \****************************************************************************************/
25708
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
25709
+
25710
+ "use strict";
25711
+
25712
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
25713
+ exports.SQLCompare = void 0;
25714
+ const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
25715
+ const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
25716
+ const sql_source_1 = __webpack_require__(/*! ./sql_source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_source.js");
25717
+ class SQLCompare {
25718
+ runSyntax(node, scope, filename, tables) {
25719
+ var _a;
25720
+ let sourceType;
25721
+ let token;
25722
+ for (const s of node.findAllExpressions(Expressions.SQLSource)) {
25723
+ token = s.getFirstToken();
25724
+ sourceType = new sql_source_1.SQLSource().runSyntax(s, scope, filename);
25725
+ }
25726
+ const fieldName = (_a = node.findDirectExpression(Expressions.SQLFieldName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
25727
+ if (fieldName && sourceType && token) {
25728
+ // check compatibility for rule sql_value_conversion
25729
+ const targetType = this.findType(fieldName, tables, scope);
25730
+ let message = "";
25731
+ if (sourceType instanceof basic_1.IntegerType
25732
+ && targetType instanceof basic_1.CharacterType) {
25733
+ message = "Integer to CHAR conversion";
25734
+ }
25735
+ else if (sourceType instanceof basic_1.IntegerType
25736
+ && targetType instanceof basic_1.NumericType) {
25737
+ message = "Integer to NUMC conversion";
25738
+ }
25739
+ else if (sourceType instanceof basic_1.NumericType
25740
+ && targetType instanceof basic_1.IntegerType) {
25741
+ message = "NUMC to Integer conversion";
25742
+ }
25743
+ else if (sourceType instanceof basic_1.CharacterType
25744
+ && targetType instanceof basic_1.IntegerType) {
25745
+ message = "CHAR to Integer conversion";
25746
+ }
25747
+ else if (sourceType instanceof basic_1.CharacterType
25748
+ && targetType instanceof basic_1.CharacterType
25749
+ && sourceType.getLength() > targetType.getLength()) {
25750
+ message = "Source field longer than database field, CHAR -> CHAR";
25751
+ }
25752
+ else if (sourceType instanceof basic_1.NumericType
25753
+ && targetType instanceof basic_1.NumericType
25754
+ && sourceType.getLength() > targetType.getLength()) {
25755
+ message = "Source field longer than database field, NUMC -> NUMC";
25756
+ }
25757
+ if (message !== "") {
25758
+ scope.addSQLConversion(fieldName, message, token);
25759
+ }
25760
+ }
25761
+ }
25762
+ findType(fieldName, tables, scope) {
25763
+ for (const t of tables) {
25764
+ const type = t === null || t === void 0 ? void 0 : t.parseType(scope.getRegistry());
25765
+ if (type instanceof basic_1.StructureType) {
25766
+ return type.getComponentByName(fieldName);
25767
+ }
25768
+ }
25769
+ return undefined;
25770
+ }
25771
+ }
25772
+ exports.SQLCompare = SQLCompare;
25773
+ //# sourceMappingURL=sql_compare.js.map
25774
+
25775
+ /***/ }),
25776
+
25686
25777
  /***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_for_all_entries.js":
25687
25778
  /*!************************************************************************************************!*\
25688
25779
  !*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_for_all_entries.js ***!
@@ -25735,6 +25826,7 @@ const dynamic_1 = __webpack_require__(/*! ./dynamic */ "./node_modules/@abaplint
25735
25826
  const database_table_1 = __webpack_require__(/*! ./database_table */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/database_table.js");
25736
25827
  class SQLFrom {
25737
25828
  runSyntax(node, scope, filename) {
25829
+ const ret = [];
25738
25830
  const fromList = node.findAllExpressions(Expressions.SQLFromSource);
25739
25831
  for (const from of fromList) {
25740
25832
  for (const d of from.findAllExpressions(Expressions.Dynamic)) {
@@ -25742,9 +25834,10 @@ class SQLFrom {
25742
25834
  }
25743
25835
  const dbtab = from.findFirstExpression(Expressions.DatabaseTable);
25744
25836
  if (dbtab !== undefined) {
25745
- new database_table_1.DatabaseTable().runSyntax(dbtab, scope, filename);
25837
+ ret.push(new database_table_1.DatabaseTable().runSyntax(dbtab, scope, filename));
25746
25838
  }
25747
25839
  }
25840
+ return ret;
25748
25841
  }
25749
25842
  }
25750
25843
  exports.SQLFrom = SQLFrom;
@@ -25752,6 +25845,34 @@ exports.SQLFrom = SQLFrom;
25752
25845
 
25753
25846
  /***/ }),
25754
25847
 
25848
+ /***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_source.js":
25849
+ /*!***************************************************************************************!*\
25850
+ !*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_source.js ***!
25851
+ \***************************************************************************************/
25852
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
25853
+
25854
+ "use strict";
25855
+
25856
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
25857
+ exports.SQLSource = void 0;
25858
+ const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
25859
+ const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
25860
+ class SQLSource {
25861
+ runSyntax(node, scope, filename) {
25862
+ for (const s of node.findAllExpressions(Expressions.Source)) {
25863
+ return new source_1.Source().runSyntax(s, scope, filename);
25864
+ }
25865
+ for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
25866
+ return new source_1.Source().runSyntax(s, scope, filename);
25867
+ }
25868
+ return undefined;
25869
+ }
25870
+ }
25871
+ exports.SQLSource = SQLSource;
25872
+ //# sourceMappingURL=sql_source.js.map
25873
+
25874
+ /***/ }),
25875
+
25755
25876
  /***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/string_template.js":
25756
25877
  /*!********************************************************************************************!*\
25757
25878
  !*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/string_template.js ***!
@@ -26349,6 +26470,7 @@ class ScopeData {
26349
26470
  extraLikeTypes: {},
26350
26471
  deferred: [],
26351
26472
  references: [],
26473
+ sqlConversion: [],
26352
26474
  };
26353
26475
  }
26354
26476
  getData() {
@@ -47757,7 +47879,7 @@ class Registry {
47757
47879
  }
47758
47880
  static abaplintVersion() {
47759
47881
  // magic, see build script "version.sh"
47760
- return "2.100.6";
47882
+ return "2.101.0";
47761
47883
  }
47762
47884
  getDDICReferences() {
47763
47885
  return this.ddicReferences;
@@ -57852,6 +57974,7 @@ __exportStar(__webpack_require__(/*! ./smim_consistency */ "./node_modules/@abap
57852
57974
  __exportStar(__webpack_require__(/*! ./space_before_colon */ "./node_modules/@abaplint/core/build/src/rules/space_before_colon.js"), exports);
57853
57975
  __exportStar(__webpack_require__(/*! ./space_before_dot */ "./node_modules/@abaplint/core/build/src/rules/space_before_dot.js"), exports);
57854
57976
  __exportStar(__webpack_require__(/*! ./sql_escape_host_variables */ "./node_modules/@abaplint/core/build/src/rules/sql_escape_host_variables.js"), exports);
57977
+ __exportStar(__webpack_require__(/*! ./sql_value_conversion */ "./node_modules/@abaplint/core/build/src/rules/sql_value_conversion.js"), exports);
57855
57978
  __exportStar(__webpack_require__(/*! ./start_at_tab */ "./node_modules/@abaplint/core/build/src/rules/start_at_tab.js"), exports);
57856
57979
  __exportStar(__webpack_require__(/*! ./static_call_via_instance */ "./node_modules/@abaplint/core/build/src/rules/static_call_via_instance.js"), exports);
57857
57980
  __exportStar(__webpack_require__(/*! ./strict_sql */ "./node_modules/@abaplint/core/build/src/rules/strict_sql.js"), exports);
@@ -64980,6 +65103,81 @@ exports.SQLEscapeHostVariables = SQLEscapeHostVariables;
64980
65103
 
64981
65104
  /***/ }),
64982
65105
 
65106
+ /***/ "./node_modules/@abaplint/core/build/src/rules/sql_value_conversion.js":
65107
+ /*!*****************************************************************************!*\
65108
+ !*** ./node_modules/@abaplint/core/build/src/rules/sql_value_conversion.js ***!
65109
+ \*****************************************************************************/
65110
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
65111
+
65112
+ "use strict";
65113
+
65114
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
65115
+ exports.SQLValueConversion = exports.SQLValueConversionConf = void 0;
65116
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
65117
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
65118
+ const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplint/core/build/src/objects/index.js");
65119
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.js");
65120
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "./node_modules/@abaplint/core/build/src/objects/_abap_object.js");
65121
+ class SQLValueConversionConf extends _basic_rule_config_1.BasicRuleConfig {
65122
+ }
65123
+ exports.SQLValueConversionConf = SQLValueConversionConf;
65124
+ class SQLValueConversion {
65125
+ constructor() {
65126
+ this.conf = new SQLValueConversionConf();
65127
+ }
65128
+ getMetadata() {
65129
+ return {
65130
+ key: "sql_value_conversion",
65131
+ title: "Implicit SQL Value Conversion",
65132
+ shortDescription: `Ensure types match when selecting from database`,
65133
+ extendedInformation: `
65134
+ * Integer to CHAR conversion
65135
+ * Integer to NUMC conversion
65136
+ * NUMC to Integer conversion
65137
+ * CHAR to Integer conversion
65138
+ * Source field longer than database field, CHAR -> CHAR
65139
+ * Source field longer than database field, NUMC -> NUMC`,
65140
+ tags: [],
65141
+ };
65142
+ }
65143
+ getConfig() {
65144
+ return this.conf;
65145
+ }
65146
+ setConfig(conf) {
65147
+ this.conf = conf;
65148
+ }
65149
+ initialize(reg) {
65150
+ this.reg = reg;
65151
+ return this;
65152
+ }
65153
+ run(obj) {
65154
+ if (!(obj instanceof _abap_object_1.ABAPObject) || obj instanceof objects_1.Interface) {
65155
+ return [];
65156
+ }
65157
+ // messages defined in sql_compare.ts
65158
+ const issues = this.traverse(new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti.getTop());
65159
+ return issues;
65160
+ }
65161
+ traverse(node) {
65162
+ const ret = [];
65163
+ for (const r of node.getData().sqlConversion) {
65164
+ const file = this.reg.getFileByName(node.getIdentifier().filename);
65165
+ if (file === undefined) {
65166
+ continue;
65167
+ }
65168
+ ret.push(issue_1.Issue.atToken(file, r.token, r.message, this.getMetadata().key, this.getConfig().severity));
65169
+ }
65170
+ for (const c of node.getChildren()) {
65171
+ ret.push(...this.traverse(c));
65172
+ }
65173
+ return ret;
65174
+ }
65175
+ }
65176
+ exports.SQLValueConversion = SQLValueConversion;
65177
+ //# sourceMappingURL=sql_value_conversion.js.map
65178
+
65179
+ /***/ }),
65180
+
64983
65181
  /***/ "./node_modules/@abaplint/core/build/src/rules/start_at_tab.js":
64984
65182
  /*!*********************************************************************!*\
64985
65183
  !*** ./node_modules/@abaplint/core/build/src/rules/start_at_tab.js ***!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.100.6",
3
+ "version": "2.101.0",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "homepage": "https://abaplint.org",
40
40
  "devDependencies": {
41
- "@abaplint/core": "^2.100.6",
41
+ "@abaplint/core": "^2.101.0",
42
42
  "@types/chai": "^4.3.5",
43
43
  "@types/glob": "^7.2.0",
44
44
  "@types/minimist": "^1.2.2",
@@ -47,7 +47,7 @@
47
47
  "@types/progress": "^2.0.5",
48
48
  "chai": "^4.3.7",
49
49
  "chalk": "^5.2.0",
50
- "eslint": "^8.40.0",
50
+ "eslint": "^8.41.0",
51
51
  "glob": "^7.2.3",
52
52
  "json5": "^2.2.3",
53
53
  "memfs": "^3.5.1",