@abaplint/core 2.95.44 → 2.95.45

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.
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.95.44";
66
+ return "2.95.45";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
@@ -246,14 +246,16 @@ Only one transformation is applied to a statement at a time, so multiple steps m
246
246
  // actively editing the files
247
247
  continue;
248
248
  }
249
+ if (highSyntax === undefined) {
250
+ highSyntax = new syntax_1.SyntaxLogic(this.highReg, highSyntaxObj).run();
251
+ }
252
+ let containsUnknown = false;
249
253
  for (let i = 0; i < lowStatements.length; i++) {
250
254
  const low = lowStatements[i];
251
255
  const high = highStatements[i];
252
256
  if ((low.get() instanceof _statement_1.Unknown && !(high.get() instanceof _statement_1.Unknown))
253
257
  || high.findFirstExpression(Expressions.InlineData)) {
254
- if (highSyntax === undefined) {
255
- highSyntax = new syntax_1.SyntaxLogic(this.highReg, highSyntaxObj).run();
256
- }
258
+ containsUnknown = true;
257
259
  try {
258
260
  const issue = this.checkStatement(low, high, lowFile, highSyntax, highFile);
259
261
  if (issue) {
@@ -271,6 +273,18 @@ Only one transformation is applied to a statement at a time, so multiple steps m
271
273
  }
272
274
  }
273
275
  }
276
+ if (ret.length === 0 && containsUnknown) {
277
+ // this is a hack in order not to change too many unit tests
278
+ for (let i = 0; i < lowStatements.length; i++) {
279
+ const high = highStatements[i];
280
+ if (high.get() instanceof Statements.Data) {
281
+ const issue = this.anonymousTableType(high, lowFile, highSyntax);
282
+ if (issue) {
283
+ ret.push(issue);
284
+ }
285
+ }
286
+ }
287
+ }
274
288
  }
275
289
  return ret;
276
290
  }
@@ -684,6 +698,22 @@ ${indentation}`);
684
698
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
685
699
  return issue_1.Issue.atToken(lowFile, inlineData.getFirstToken(), "Outline SELECT @DATA", this.getMetadata().key, this.conf.severity, fix);
686
700
  }
701
+ // the anonymous type minght be used in inferred type statements, define it so it can be referred
702
+ anonymousTableType(high, lowFile, highSyntax) {
703
+ if (!(high.get() instanceof Statements.Data)) {
704
+ return undefined;
705
+ }
706
+ const tt = high.findFirstExpression(Expressions.TypeTable);
707
+ if (tt === undefined) {
708
+ return undefined;
709
+ }
710
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
711
+ const code = `TYPES ${uniqueName} ${tt.concatTokens()}.\n`;
712
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getStart(), code);
713
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, tt.getFirstToken().getStart(), tt.getLastToken().getEnd(), "TYPE " + uniqueName);
714
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
715
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Add type for table definition", this.getMetadata().key, this.conf.severity, fix);
716
+ }
687
717
  downportMessage(high, lowFile, highSyntax) {
688
718
  var _a, _b;
689
719
  if (!(high.get() instanceof Statements.Message)) {
@@ -1876,7 +1906,12 @@ ${indentation} output = ${topTarget}.`;
1876
1906
  const s = (_a = init.findFirstExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
1877
1907
  const t = (_b = init.findFirstExpression(Expressions.TypeName)) === null || _b === void 0 ? void 0 : _b.concatTokens();
1878
1908
  if (s) {
1879
- body += indentation + `DATA(${name}) = ${s}.\n`;
1909
+ if (s.toUpperCase().startsWith("VALUE #")) {
1910
+ body += indentation + `DATA(${name}) = ${s.replace("#", type)}.\n`;
1911
+ }
1912
+ else {
1913
+ body += indentation + `DATA(${name}) = ${s}.\n`;
1914
+ }
1880
1915
  }
1881
1916
  else {
1882
1917
  body += indentation + `DATA ${name} TYPE ${t}.\n`;
@@ -1921,7 +1956,7 @@ ${indentation} output = ${topTarget}.`;
1921
1956
  return undefined;
1922
1957
  }
1923
1958
  outlineValue(low, high, lowFile, highSyntax) {
1924
- var _a, _b, _c;
1959
+ var _a, _b, _c, _d;
1925
1960
  if (!(low.get() instanceof _statement_1.Unknown)) {
1926
1961
  return undefined;
1927
1962
  }
@@ -1931,6 +1966,7 @@ ${indentation} output = ${topTarget}.`;
1931
1966
  if (firstToken.getStr().toUpperCase() !== "VALUE") {
1932
1967
  continue;
1933
1968
  }
1969
+ const valueBody = s.findDirectExpression(Expressions.ValueBody);
1934
1970
  let type = this.findType(s, lowFile, highSyntax);
1935
1971
  if (type === undefined) {
1936
1972
  if (high.get() instanceof Statements.Move && high.findDirectExpression(Expressions.Source) === s) {
@@ -1943,7 +1979,6 @@ ${indentation} output = ${topTarget}.`;
1943
1979
  else {
1944
1980
  type = "TYPE " + type;
1945
1981
  }
1946
- const valueBody = s.findDirectExpression(Expressions.ValueBody);
1947
1982
  const uniqueName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
1948
1983
  let indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
1949
1984
  let body = "";
@@ -1956,6 +1991,16 @@ ${indentation} output = ${topTarget}.`;
1956
1991
  let added = false;
1957
1992
  let data = "";
1958
1993
  let previous = undefined;
1994
+ if ((valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpression(Expressions.ValueBodyLine)) !== undefined
1995
+ && (valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpression(Expressions.For)) === undefined) {
1996
+ structureName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
1997
+ data = indentation + `DATA ${structureName} LIKE LINE OF ${uniqueName}.\n`;
1998
+ }
1999
+ else if ((valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpression(Expressions.ValueBodyLine)) !== undefined
2000
+ && ((_b = valueBody === null || valueBody === void 0 ? void 0 : valueBody.findDirectExpression(Expressions.For)) === null || _b === void 0 ? void 0 : _b.findDirectTokenByText("GROUPS")) !== undefined) {
2001
+ structureName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
2002
+ data = indentation + ` DATA ${structureName} LIKE LINE OF ${uniqueName}.\n`;
2003
+ }
1959
2004
  for (const a of (valueBody === null || valueBody === void 0 ? void 0 : valueBody.getChildren()) || []) {
1960
2005
  if (a.get() instanceof Expressions.FieldAssignment) {
1961
2006
  if (added === false) {
@@ -1982,10 +2027,6 @@ ${indentation} output = ${topTarget}.`;
1982
2027
  if (a instanceof nodes_1.ExpressionNode && a.get() instanceof Expressions.ValueBodyLine) {
1983
2028
  let skip = false;
1984
2029
  for (const b of (a === null || a === void 0 ? void 0 : a.getChildren()) || []) {
1985
- if (b.concatTokens() === "(" && added === false) {
1986
- structureName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
1987
- data = indentation + `DATA ${structureName} LIKE LINE OF ${uniqueName}.\n`;
1988
- }
1989
2030
  if (b.get() instanceof Expressions.FieldAssignment) {
1990
2031
  if (added === false) {
1991
2032
  body += data;
@@ -2014,7 +2055,7 @@ ${indentation} output = ${topTarget}.`;
2014
2055
  }
2015
2056
  }
2016
2057
  }
2017
- if (body === "" && ((_b = valueBody === null || valueBody === void 0 ? void 0 : valueBody.getLastChild()) === null || _b === void 0 ? void 0 : _b.getFirstToken().getStr().toUpperCase()) === "OPTIONAL") {
2058
+ if (body === "" && ((_c = valueBody === null || valueBody === void 0 ? void 0 : valueBody.getLastChild()) === null || _c === void 0 ? void 0 : _c.getFirstToken().getStr().toUpperCase()) === "OPTIONAL") {
2018
2059
  const fieldChain = valueBody.findFirstExpression(Expressions.FieldChain);
2019
2060
  const rowName = this.uniqueName(firstToken.getStart(), lowFile.getFilename(), highSyntax);
2020
2061
  let tableExpression = undefined;
@@ -2033,7 +2074,7 @@ ${indentation} output = ${topTarget}.`;
2033
2074
  }
2034
2075
  let condition = "";
2035
2076
  if ((tableExpression === null || tableExpression === void 0 ? void 0 : tableExpression.getChildren().length) === 3) {
2036
- condition = "INDEX " + ((_c = tableExpression === null || tableExpression === void 0 ? void 0 : tableExpression.findDirectExpression(Expressions.Source)) === null || _c === void 0 ? void 0 : _c.concatTokens());
2077
+ condition = "INDEX " + ((_d = tableExpression === null || tableExpression === void 0 ? void 0 : tableExpression.findDirectExpression(Expressions.Source)) === null || _d === void 0 ? void 0 : _d.concatTokens());
2037
2078
  }
2038
2079
  else {
2039
2080
  condition = "WITH KEY " + (tableExpression === null || tableExpression === void 0 ? void 0 : tableExpression.concatTokens().replace("[ ", "").replace(" ]", ""));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.95.44",
3
+ "version": "2.95.45",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",