@abaplint/core 2.91.12 → 2.91.15

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.
@@ -1780,10 +1780,10 @@ declare namespace Expressions {
1780
1780
  ArithOperator,
1781
1781
  ArrowOrDash,
1782
1782
  Arrow,
1783
+ AssociationName,
1783
1784
  AttributeChain,
1784
1785
  AttributeName,
1785
1786
  BlockName,
1786
- AssociationName,
1787
1787
  CallTransformationOptions,
1788
1788
  CallTransformationParameters,
1789
1789
  Cast,
@@ -1794,7 +1794,6 @@ declare namespace Expressions {
1794
1794
  Color,
1795
1795
  CompareOperator,
1796
1796
  Compare,
1797
- TestSeamName,
1798
1797
  ComponentChainSimple,
1799
1798
  ComponentChain,
1800
1799
  ComponentCompareSimple,
@@ -1934,6 +1933,7 @@ declare namespace Expressions {
1934
1933
  SQLGroupBy,
1935
1934
  SQLHaving,
1936
1935
  SQLHints,
1936
+ SQLIn,
1937
1937
  SQLIntoStructure,
1938
1938
  SQLIntoTable,
1939
1939
  SQLJoin,
@@ -1942,6 +1942,7 @@ declare namespace Expressions {
1942
1942
  SQLSourceSimple,
1943
1943
  SQLSource,
1944
1944
  SQLTarget,
1945
+ SQLUpTo,
1945
1946
  StringTemplateFormatting,
1946
1947
  StringTemplateSource,
1947
1948
  StringTemplate,
@@ -1952,6 +1953,7 @@ declare namespace Expressions {
1952
1953
  TargetFieldSymbol,
1953
1954
  TargetField,
1954
1955
  Target,
1956
+ TestSeamName,
1955
1957
  TextElementKey,
1956
1958
  TextElementString,
1957
1959
  TextElement,
@@ -1962,9 +1964,8 @@ declare namespace Expressions {
1962
1964
  TypeTableKey,
1963
1965
  TypeTable,
1964
1966
  Type_2 as Type,
1965
- SQLUpTo,
1966
- ValueBody,
1967
1967
  ValueBodyLines,
1968
+ ValueBody,
1968
1969
  Value,
1969
1970
  WithName,
1970
1971
  WriteOffsetLength
@@ -4966,6 +4967,10 @@ declare class SQLHints extends Expression {
4966
4967
  getRunnable(): IStatementRunnable;
4967
4968
  }
4968
4969
 
4970
+ declare class SQLIn extends Expression {
4971
+ getRunnable(): IStatementRunnable;
4972
+ }
4973
+
4969
4974
  declare class SQLIntoStructure extends Expression {
4970
4975
  getRunnable(): IStatementRunnable;
4971
4976
  }
@@ -20,10 +20,10 @@ __exportStar(require("./and_return"), exports);
20
20
  __exportStar(require("./arith_operator"), exports);
21
21
  __exportStar(require("./arrow_or_dash"), exports);
22
22
  __exportStar(require("./arrow"), exports);
23
+ __exportStar(require("./association_name"), exports);
23
24
  __exportStar(require("./attribute_chain"), exports);
24
25
  __exportStar(require("./attribute_name"), exports);
25
26
  __exportStar(require("./block_name"), exports);
26
- __exportStar(require("./association_name"), exports);
27
27
  __exportStar(require("./call_transformation_options"), exports);
28
28
  __exportStar(require("./call_transformation_parameters"), exports);
29
29
  __exportStar(require("./cast"), exports);
@@ -34,7 +34,6 @@ __exportStar(require("./class_name"), exports);
34
34
  __exportStar(require("./color"), exports);
35
35
  __exportStar(require("./compare_operator"), exports);
36
36
  __exportStar(require("./compare"), exports);
37
- __exportStar(require("./test_seam_name"), exports);
38
37
  __exportStar(require("./component_chain_simple"), exports);
39
38
  __exportStar(require("./component_chain"), exports);
40
39
  __exportStar(require("./component_compare_simple"), exports);
@@ -174,6 +173,7 @@ __exportStar(require("./sql_function"), exports);
174
173
  __exportStar(require("./sql_group_by"), exports);
175
174
  __exportStar(require("./sql_having"), exports);
176
175
  __exportStar(require("./sql_hints"), exports);
176
+ __exportStar(require("./sql_in"), exports);
177
177
  __exportStar(require("./sql_into_structure"), exports);
178
178
  __exportStar(require("./sql_into_table"), exports);
179
179
  __exportStar(require("./sql_join"), exports);
@@ -182,6 +182,7 @@ __exportStar(require("./sql_path"), exports);
182
182
  __exportStar(require("./sql_source_simple"), exports);
183
183
  __exportStar(require("./sql_source"), exports);
184
184
  __exportStar(require("./sql_target"), exports);
185
+ __exportStar(require("./sql_up_to"), exports);
185
186
  __exportStar(require("./string_template_formatting"), exports);
186
187
  __exportStar(require("./string_template_source"), exports);
187
188
  __exportStar(require("./string_template"), exports);
@@ -192,6 +193,7 @@ __exportStar(require("./table_expression"), exports);
192
193
  __exportStar(require("./target_field_symbol"), exports);
193
194
  __exportStar(require("./target_field"), exports);
194
195
  __exportStar(require("./target"), exports);
196
+ __exportStar(require("./test_seam_name"), exports);
195
197
  __exportStar(require("./text_element_key"), exports);
196
198
  __exportStar(require("./text_element_string"), exports);
197
199
  __exportStar(require("./text_element"), exports);
@@ -202,9 +204,8 @@ __exportStar(require("./type_param"), exports);
202
204
  __exportStar(require("./type_table_key"), exports);
203
205
  __exportStar(require("./type_table"), exports);
204
206
  __exportStar(require("./type"), exports);
205
- __exportStar(require("./sql_up_to"), exports);
206
- __exportStar(require("./value_body"), exports);
207
207
  __exportStar(require("./value_body_lines"), exports);
208
+ __exportStar(require("./value_body"), exports);
208
209
  __exportStar(require("./value"), exports);
209
210
  __exportStar(require("./with_name"), exports);
210
211
  __exportStar(require("./write_offset_length"), exports);
@@ -3,23 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SQLCompare = void 0;
4
4
  const combi_1 = require("../combi");
5
5
  const _1 = require(".");
6
- const tokens_1 = require("../../1_lexer/tokens");
7
6
  const version_1 = require("../../../version");
8
7
  class SQLCompare extends combi_1.Expression {
9
8
  getRunnable() {
10
- const val = new _1.SQLSource();
11
- const listOld = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeft), val, (0, combi_1.starPrio)((0, combi_1.seq)(",", val)), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenRight), (0, combi_1.tok)(tokens_1.ParenRightW), (0, combi_1.tok)(tokens_1.WParenRightW)));
12
- const listNew = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), val, (0, combi_1.starPrio)((0, combi_1.seq)(",", val)), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WParenRight), (0, combi_1.tok)(tokens_1.WParenRightW)));
13
- const list = (0, combi_1.alt)(listOld, (0, combi_1.ver)(version_1.Version.v740sp02, listNew)); // version is a guess, https://github.com/abaplint/abaplint/issues/2530
14
9
  const subSelect = (0, combi_1.seq)("(", _1.Select, ")");
15
- const inn = (0, combi_1.seq)("IN", (0, combi_1.altPrio)(_1.SQLSource, list, subSelect));
16
10
  const between = (0, combi_1.seq)("BETWEEN", _1.SQLSource, "AND", _1.SQLSource);
17
11
  const like = (0, combi_1.seq)("LIKE", _1.SQLSource, (0, combi_1.optPrio)((0, combi_1.seq)("ESCAPE", _1.SQLSource)));
18
12
  const nul = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)("NULL", (0, combi_1.ver)(version_1.Version.v753, "INITIAL")));
19
13
  const source = new _1.SQLSource();
20
14
  const sub = (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.altPrio)("ALL", "ANY", "SOME")), subSelect);
21
15
  const arith = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.plusPrio)((0, combi_1.seq)((0, combi_1.altPrio)("+", "-", "*", "/"), _1.SQLFieldName)));
22
- const rett = (0, combi_1.seq)((0, combi_1.altPrio)(_1.SQLFunction, (0, combi_1.seq)(_1.SQLFieldName, (0, combi_1.optPrio)(arith))), (0, combi_1.altPrio)((0, combi_1.seq)(_1.SQLCompareOperator, (0, combi_1.altPrio)(sub, source)), (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)(inn, like, between)), nul));
16
+ const rett = (0, combi_1.seq)((0, combi_1.altPrio)(_1.SQLFunction, (0, combi_1.seq)(_1.SQLFieldName, (0, combi_1.optPrio)(arith))), (0, combi_1.altPrio)((0, combi_1.seq)(_1.SQLCompareOperator, (0, combi_1.altPrio)(sub, source)), (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)(_1.SQLIn, like, between)), nul));
23
17
  const exists = (0, combi_1.seq)("EXISTS", subSelect);
24
18
  return (0, combi_1.altPrio)(exists, _1.Dynamic, rett);
25
19
  }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SQLIn = void 0;
4
+ const combi_1 = require("../combi");
5
+ const _1 = require(".");
6
+ const tokens_1 = require("../../1_lexer/tokens");
7
+ const version_1 = require("../../../version");
8
+ class SQLIn extends combi_1.Expression {
9
+ getRunnable() {
10
+ const val = new _1.SQLSource();
11
+ const listOld = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeft), val, (0, combi_1.starPrio)((0, combi_1.seq)(",", val)), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.ParenRight), (0, combi_1.tok)(tokens_1.ParenRightW), (0, combi_1.tok)(tokens_1.WParenRightW)));
12
+ const listNew = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), val, (0, combi_1.starPrio)((0, combi_1.seq)(",", val)), (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WParenRight), (0, combi_1.tok)(tokens_1.WParenRightW)));
13
+ const list = (0, combi_1.alt)(listOld, (0, combi_1.ver)(version_1.Version.v740sp02, listNew)); // version is a guess, https://github.com/abaplint/abaplint/issues/2530
14
+ const subSelect = (0, combi_1.seq)("(", _1.Select, ")");
15
+ const inn = (0, combi_1.seq)("IN", (0, combi_1.altPrio)(_1.SQLSource, list, subSelect));
16
+ return inn;
17
+ }
18
+ }
19
+ exports.SQLIn = SQLIn;
20
+ //# sourceMappingURL=sql_in.js.map
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.91.12";
71
+ return "2.91.15";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -200,7 +200,11 @@ Only one transformation is applied to a statement at a time, so multiple steps m
200
200
  if (found) {
201
201
  return found;
202
202
  }
203
- found = this.moveWithSimpleRef(high, lowFile);
203
+ found = this.downportRefSimple(high, lowFile);
204
+ if (found) {
205
+ return found;
206
+ }
207
+ found = this.downportRef(high, lowFile, highSyntax);
204
208
  if (found) {
205
209
  return found;
206
210
  }
@@ -280,6 +284,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
280
284
  if (found) {
281
285
  return found;
282
286
  }
287
+ found = this.getReference(high, lowFile, highSyntax);
288
+ if (found) {
289
+ return found;
290
+ }
283
291
  found = this.replaceContains(high, lowFile, highSyntax);
284
292
  if (found) {
285
293
  return found;
@@ -344,12 +352,28 @@ Only one transformation is applied to a statement at a time, so multiple steps m
344
352
  }
345
353
  }
346
354
  }
347
- if (fix === undefined) {
348
- return undefined;
349
- }
350
- else {
355
+ if (fix !== undefined) {
351
356
  return issue_1.Issue.atToken(lowFile, low.getFirstToken(), "SQL, remove \" and ,", this.getMetadata().key, this.conf.severity, fix);
352
357
  }
358
+ for (const c of high.findAllExpressionsRecursive(Expressions.SQLIn)) {
359
+ const children = c.getChildren();
360
+ const first = children[1];
361
+ if (!(first.get() instanceof tokens_1.WParenLeftW)) {
362
+ continue;
363
+ }
364
+ const last = children[children.length - 1];
365
+ if (last.get() instanceof tokens_1.WParenRightW || last.get() instanceof tokens_1.WParenRight) {
366
+ const firstEnd = first.getFirstToken().getEnd();
367
+ const endDelete = new position_1.Position(firstEnd.getRow(), firstEnd.getCol() + 1);
368
+ const fix1 = edit_helper_1.EditHelper.deleteRange(lowFile, firstEnd, endDelete);
369
+ const lastStart = last.getFirstToken().getStart();
370
+ const startDelete = new position_1.Position(lastStart.getRow(), lastStart.getCol() - 1);
371
+ const fix2 = edit_helper_1.EditHelper.deleteRange(lowFile, startDelete, lastStart);
372
+ fix = edit_helper_1.EditHelper.merge(fix2, fix1);
373
+ return issue_1.Issue.atToken(lowFile, low.getFirstToken(), "SQL, remove spaces", this.getMetadata().key, this.conf.severity, fix);
374
+ }
375
+ }
376
+ return undefined;
353
377
  }
354
378
  downportSelectInline(low, high, lowFile, highSyntax) {
355
379
  if (!(low.get() instanceof _statement_1.Unknown)) {
@@ -814,7 +838,7 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
814
838
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
815
839
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, call function parameter", this.getMetadata().key, this.conf.severity, fix);
816
840
  }
817
- moveWithSimpleRef(high, lowFile) {
841
+ downportRefSimple(high, lowFile) {
818
842
  var _a;
819
843
  if (!(high.get() instanceof Statements.Move)
820
844
  || high.getChildren().length !== 4
@@ -835,6 +859,24 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
835
859
  const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
836
860
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple REF move", this.getMetadata().key, this.conf.severity, fix);
837
861
  }
862
+ downportRef(high, lowFile, highSyntax) {
863
+ let found = undefined;
864
+ for (const s of high.findAllExpressionsRecursive(Expressions.Source)) {
865
+ if (s.getFirstToken().getStr().toUpperCase() === "REF"
866
+ && s.findDirectExpression(Expressions.TypeNameOrInfer)) {
867
+ found = s;
868
+ }
869
+ }
870
+ if (found === undefined) {
871
+ return undefined;
872
+ }
873
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
874
+ const code = `DATA(${uniqueName}) = ${found.concatTokens()}.\n`;
875
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), code);
876
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, found.getFirstToken().getStart(), found.getLastToken().getEnd(), uniqueName);
877
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
878
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, REF", this.getMetadata().key, this.conf.severity, fix);
879
+ }
838
880
  moveWithSimpleValue(high, lowFile) {
839
881
  if (!(high.get() instanceof Statements.Move)
840
882
  || high.getChildren().length !== 4) {
@@ -1719,6 +1761,26 @@ ${indentation} output = ${topTarget}.`;
1719
1761
  }
1720
1762
  return undefined;
1721
1763
  }
1764
+ getReference(node, lowFile, _highSyntax) {
1765
+ var _a, _b, _c;
1766
+ if (!(node.get() instanceof Statements.GetReference)) {
1767
+ return undefined;
1768
+ }
1769
+ const inline = (_a = node.findDirectExpression(Expressions.Target)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.InlineData);
1770
+ if (inline === undefined) {
1771
+ return undefined;
1772
+ }
1773
+ const targetName = (_b = inline.findDirectExpression(Expressions.TargetField)) === null || _b === void 0 ? void 0 : _b.concatTokens();
1774
+ const sourceName = (_c = node.findDirectExpression(Expressions.Source)) === null || _c === void 0 ? void 0 : _c.concatTokens();
1775
+ if (targetName === undefined || sourceName === undefined) {
1776
+ return undefined;
1777
+ }
1778
+ const code = `DATA ${targetName} LIKE REF TO ${sourceName}.\n`;
1779
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
1780
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, inline.getFirstToken().getStart(), inline.getLastToken().getEnd(), targetName);
1781
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
1782
+ return issue_1.Issue.atToken(lowFile, inline.getFirstToken(), "Downport, outline DATA ref", this.getMetadata().key, this.conf.severity, fix);
1783
+ }
1722
1784
  replaceContains(node, lowFile, highSyntax) {
1723
1785
  const spag = highSyntax.spaghetti.lookupPosition(node.getFirstToken().getStart(), lowFile.getFilename());
1724
1786
  // only downport if its an single method call condition
@@ -1810,8 +1872,10 @@ ${indentation} output = ${topTarget}.`;
1810
1872
  const target = node.findDirectExpression(Expressions.Target);
1811
1873
  const found = source === null || source === void 0 ? void 0 : source.findFirstExpression(Expressions.NewObject);
1812
1874
  // must be at top level of the source for quickfix to work(todo: handle more scenarios)
1813
- // todo, assumption: the target is not an inline definition
1814
- if (target && found && source.concatTokens() === found.concatTokens()) {
1875
+ if (target
1876
+ && found
1877
+ && source.concatTokens() === found.concatTokens()
1878
+ && target.findDirectExpression(Expressions.InlineData) === undefined) {
1815
1879
  const abap = this.newParameters(found, target.concatTokens(), highSyntax, lowFile);
1816
1880
  if (abap !== undefined) {
1817
1881
  fix = edit_helper_1.EditHelper.replaceRange(lowFile, node.getFirstToken().getStart(), node.getLastToken().getEnd(), abap);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.91.12",
3
+ "version": "2.91.15",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -48,7 +48,7 @@
48
48
  "@microsoft/api-extractor": "^7.28.6",
49
49
  "@types/chai": "^4.3.1",
50
50
  "@types/mocha": "^9.1.1",
51
- "@types/node": "^18.0.6",
51
+ "@types/node": "^18.6.1",
52
52
  "chai": "^4.3.6",
53
53
  "eslint": "^8.20.0",
54
54
  "mocha": "^10.0.0",