@abaplint/core 2.115.15 → 2.115.17

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.
@@ -214,6 +214,22 @@ class TypeUtils {
214
214
  // todo
215
215
  return true;
216
216
  }
217
+ isCompareable(source1, source2, node1, node2) {
218
+ /*
219
+ console.dir(source1);
220
+ console.dir(source2);
221
+ */
222
+ if (source1 === undefined || source2 === undefined) {
223
+ return true;
224
+ }
225
+ if (source1 instanceof basic_1.HexType && this.isCalculated(node1) && source2 instanceof basic_1.IntegerType) {
226
+ return false;
227
+ }
228
+ if (source2 instanceof basic_1.HexType && this.isCalculated(node2) && source1 instanceof basic_1.IntegerType) {
229
+ return false;
230
+ }
231
+ return true;
232
+ }
217
233
  structureContainsString(structure) {
218
234
  for (const c of structure.getComponents()) {
219
235
  if (c.type instanceof basic_1.StringType) {
@@ -243,6 +259,13 @@ class TypeUtils {
243
259
  || node.findFirstExpression(Expressions.ArithOperator) !== undefined;
244
260
  return calculated;
245
261
  }
262
+ isAssignableNew(source, target, node) {
263
+ const calculated = (node === null || node === void 0 ? void 0 : node.findFirstExpression(Expressions.ArithOperator)) !== undefined;
264
+ if (calculated && source instanceof basic_1.HexType && target instanceof basic_1.IntegerType) {
265
+ return false;
266
+ }
267
+ return this.isAssignable(source, target);
268
+ }
246
269
  isAssignableStrict(source, target, node) {
247
270
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
248
271
  const calculated = node ? this.isCalculated(node) : false;
@@ -5,10 +5,14 @@ const Expressions = require("../../2_statements/expressions");
5
5
  const source_1 = require("./source");
6
6
  const method_call_chain_1 = require("./method_call_chain");
7
7
  const source_field_symbol_1 = require("./source_field_symbol");
8
+ const _syntax_input_1 = require("../_syntax_input");
9
+ const _type_utils_1 = require("../_type_utils");
8
10
  class Compare {
9
11
  static runSyntax(node, input) {
10
- for (const t of node.findDirectExpressions(Expressions.Source)) {
11
- source_1.Source.runSyntax(t, input);
12
+ const sourceTypes = [];
13
+ const sources = node.findDirectExpressions(Expressions.Source);
14
+ for (const t of sources) {
15
+ sourceTypes.push(source_1.Source.runSyntax(t, input));
12
16
  }
13
17
  for (const t of node.findDirectExpressions(Expressions.SourceFieldSymbolChain)) {
14
18
  source_field_symbol_1.SourceFieldSymbol.runSyntax(t, input);
@@ -16,6 +20,12 @@ class Compare {
16
20
  for (const t of node.findDirectExpressions(Expressions.MethodCallChain)) {
17
21
  method_call_chain_1.MethodCallChain.runSyntax(t, input);
18
22
  }
23
+ if (node.findDirectExpression(Expressions.CompareOperator)
24
+ && new _type_utils_1.TypeUtils(input.scope).isCompareable(sourceTypes[0], sourceTypes[1], sources[0], sources[1]) === false
25
+ && sourceTypes.length === 2) {
26
+ const message = "Incompatible types for comparison";
27
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
28
+ }
19
29
  }
20
30
  }
21
31
  exports.Compare = Compare;
@@ -1,53 +1,84 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StringTemplate = void 0;
4
+ const nodes_1 = require("../../nodes");
4
5
  const basic_1 = require("../../types/basic");
5
6
  const Expressions = require("../../2_statements/expressions");
6
7
  const source_1 = require("./source");
7
8
  const _type_utils_1 = require("../_type_utils");
8
9
  const _syntax_input_1 = require("../_syntax_input");
10
+ const Tokens = require("../../1_lexer/tokens");
9
11
  class StringTemplate {
10
12
  static runSyntax(node, input) {
11
13
  const typeUtils = new _type_utils_1.TypeUtils(input.scope);
12
14
  const ret = basic_1.StringType.get();
13
- for (const templateSource of node.findAllExpressions(Expressions.StringTemplateSource)) {
14
- const s = templateSource.findDirectExpression(Expressions.Source);
15
- const type = source_1.Source.runSyntax(s, input, ret);
16
- if (type === undefined) {
17
- const message = "No target type determined";
18
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
19
- return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
15
+ for (const child of node.getChildren()) {
16
+ if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.StringTemplateSource) {
17
+ const s = child.findDirectExpression(Expressions.Source);
18
+ const type = source_1.Source.runSyntax(s, input, ret);
19
+ if (type === undefined) {
20
+ const message = "No target type determined";
21
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
22
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
23
+ }
24
+ else if ((typeUtils.isCharLike(type) === false
25
+ && typeUtils.isHexLike(type) === false
26
+ && !(type instanceof basic_1.UTCLongType))
27
+ || type instanceof basic_1.StructureType) {
28
+ const message = "String template, not character like, " + type.constructor.name;
29
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
30
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
31
+ }
32
+ const format = child.findDirectExpression(Expressions.StringTemplateFormatting);
33
+ const formatConcat = format === null || format === void 0 ? void 0 : format.concatTokens();
34
+ for (const formatSource of (format === null || format === void 0 ? void 0 : format.findAllExpressions(Expressions.Source)) || []) {
35
+ source_1.Source.runSyntax(formatSource, input);
36
+ }
37
+ if (format
38
+ && (formatConcat === null || formatConcat === void 0 ? void 0 : formatConcat.includes("ALPHA = "))
39
+ && !(type instanceof basic_1.UnknownType)
40
+ && !(type instanceof basic_1.VoidType)
41
+ && !(type instanceof basic_1.StringType)
42
+ && !(type instanceof basic_1.CLikeType)
43
+ && !(type instanceof basic_1.CharacterType)
44
+ && !(type instanceof basic_1.NumericGenericType)
45
+ && !(type instanceof basic_1.NumericType)
46
+ && !(type instanceof basic_1.AnyType)) {
47
+ const message = `Cannot apply ALPHA to this type (${type.constructor.name})`;
48
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, format.getFirstToken(), message));
49
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
50
+ }
20
51
  }
21
- else if ((typeUtils.isCharLike(type) === false
22
- && typeUtils.isHexLike(type) === false
23
- && !(type instanceof basic_1.UTCLongType))
24
- || type instanceof basic_1.StructureType) {
25
- const message = "String template, not character like, " + type.constructor.name;
26
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
27
- return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
28
- }
29
- const format = templateSource.findDirectExpression(Expressions.StringTemplateFormatting);
30
- const formatConcat = format === null || format === void 0 ? void 0 : format.concatTokens();
31
- for (const formatSource of (format === null || format === void 0 ? void 0 : format.findAllExpressions(Expressions.Source)) || []) {
32
- source_1.Source.runSyntax(formatSource, input);
33
- }
34
- if (format
35
- && (formatConcat === null || formatConcat === void 0 ? void 0 : formatConcat.includes("ALPHA = "))
36
- && !(type instanceof basic_1.UnknownType)
37
- && !(type instanceof basic_1.VoidType)
38
- && !(type instanceof basic_1.StringType)
39
- && !(type instanceof basic_1.CLikeType)
40
- && !(type instanceof basic_1.CharacterType)
41
- && !(type instanceof basic_1.NumericGenericType)
42
- && !(type instanceof basic_1.NumericType)
43
- && !(type instanceof basic_1.AnyType)) {
44
- const message = `Cannot apply ALPHA to this type (${type.constructor.name})`;
45
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, format.getFirstToken(), message));
46
- return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
52
+ else if (child instanceof nodes_1.TokenNode) {
53
+ const token = child.get();
54
+ if (token instanceof Tokens.StringTemplate
55
+ || token instanceof Tokens.StringTemplateBegin
56
+ || token instanceof Tokens.StringTemplateMiddle
57
+ || token instanceof Tokens.StringTemplateEnd) {
58
+ const issue = this.validateEscapeSequences(token.getStr(), input, child);
59
+ if (issue) {
60
+ input.issues.push(issue);
61
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
62
+ }
63
+ }
47
64
  }
48
65
  }
49
66
  return ret;
50
67
  }
68
+ static validateEscapeSequences(str, input, node) {
69
+ // Valid escape sequences in ABAP string templates: \|, \{, \}, \\, \n, \r, \t
70
+ const validEscapes = new Set(["\\|", "\\{", "\\}", "\\\\", "\\n", "\\r", "\\t"]);
71
+ for (let i = 0; i < str.length; i++) {
72
+ if (str[i] === "\\") {
73
+ const escape = str.substring(i, i + 2);
74
+ if (!validEscapes.has(escape)) {
75
+ return (0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), `Invalid escape sequence "${escape}" in string template`);
76
+ }
77
+ i++; // skip the next character as it's part of the escape sequence
78
+ }
79
+ }
80
+ return undefined;
81
+ }
51
82
  }
52
83
  exports.StringTemplate = StringTemplate;
53
84
  //# sourceMappingURL=string_template.js.map
@@ -40,7 +40,7 @@ class Move {
40
40
  return;
41
41
  }
42
42
  }
43
- else if (new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType, targetType) === false) {
43
+ else if (new _type_utils_1.TypeUtils(input.scope).isAssignableNew(sourceType, targetType, source) === false) {
44
44
  const message = "Incompatible types";
45
45
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
46
46
  return;
@@ -74,7 +74,7 @@ class Registry {
74
74
  }
75
75
  static abaplintVersion() {
76
76
  // magic, see build script "version.sh"
77
- return "2.115.15";
77
+ return "2.115.17";
78
78
  }
79
79
  getDDICReferences() {
80
80
  return this.ddicReferences;
@@ -288,7 +288,7 @@ class Registry {
288
288
  return this;
289
289
  }
290
290
  ParsingPerformance.clear();
291
- (_a = input === null || input === void 0 ? void 0 : input.progress) === null || _a === void 0 ? void 0 : _a.set(this.getObjectCount().normal, "Lexing and parsing");
291
+ (_a = input === null || input === void 0 ? void 0 : input.progress) === null || _a === void 0 ? void 0 : _a.set(this.getObjectCount().total, "Lexing and parsing");
292
292
  for (const o of this.getObjects()) {
293
293
  await ((_b = input === null || input === void 0 ? void 0 : input.progress) === null || _b === void 0 ? void 0 : _b.tick("Lexing and parsing(" + this.conf.getVersion() + ") - " + o.getType() + " " + o.getName()));
294
294
  this.parsePrivate(o);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.115.15",
3
+ "version": "2.115.17",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -53,7 +53,7 @@
53
53
  "@microsoft/api-extractor": "^7.55.2",
54
54
  "@types/chai": "^4.3.20",
55
55
  "@types/mocha": "^10.0.10",
56
- "@types/node": "^24.10.4",
56
+ "@types/node": "^24.10.9",
57
57
  "chai": "^4.5.0",
58
58
  "eslint": "^9.39.2",
59
59
  "mocha": "^11.7.5",