@abaplint/core 2.102.65 → 2.102.67

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.
@@ -8,6 +8,7 @@ const source_1 = require("./source");
8
8
  const _object_oriented_1 = require("../_object_oriented");
9
9
  const method_parameters_1 = require("./method_parameters");
10
10
  const basic_types_1 = require("../basic_types");
11
+ const _type_utils_1 = require("../_type_utils");
11
12
  class NewObject {
12
13
  runSyntax(node, scope, targetType, filename) {
13
14
  let ret = undefined;
@@ -89,7 +90,10 @@ class NewObject {
89
90
  if (type === undefined) {
90
91
  throw new Error("NewObject, no default importing parameter found for constructor, " + name);
91
92
  }
92
- new source_1.Source().runSyntax(source, scope, filename, type);
93
+ const sourceType = new source_1.Source().runSyntax(source, scope, filename, type);
94
+ if (new _type_utils_1.TypeUtils(scope).isAssignableStrict(sourceType, type) === false) {
95
+ throw new Error(`NEW parameter type not compatible`);
96
+ }
93
97
  }
94
98
  else if (parameters) {
95
99
  // parameters with names
@@ -25,7 +25,12 @@ class ReduceBody {
25
25
  scope.push(_scope_type_1.ScopeType.Let, "LET", node.getFirstToken().getStart(), filename);
26
26
  scoped = true;
27
27
  }
28
- const found = new inline_field_definition_1.InlineFieldDefinition().runSyntax(i, scope, filename, targetType);
28
+ let foundType = targetType;
29
+ const source = i.findDirectExpression(Expressions.Source);
30
+ if (source) {
31
+ foundType = new source_1.Source().runSyntax(source, scope, filename, targetType);
32
+ }
33
+ const found = new inline_field_definition_1.InlineFieldDefinition().runSyntax(i, scope, filename, foundType);
29
34
  if (found && first === undefined) {
30
35
  first = found;
31
36
  }
@@ -18,6 +18,9 @@ class Select {
18
18
  const token = node.getFirstToken();
19
19
  const from = node.findDirectExpression(Expressions.SQLFrom);
20
20
  const dbSources = from ? new sql_from_1.SQLFrom().runSyntax(from, scope, filename) : [];
21
+ if (dbSources.length === 0) {
22
+ throw new Error(`Missing FROM`);
23
+ }
21
24
  const fields = this.findFields(node);
22
25
  if (fields.length === 0
23
26
  && node.findDirectExpression(Expressions.SQLFieldListLoop) === undefined) {
@@ -17,7 +17,7 @@ class StringTemplate {
17
17
  }
18
18
  else if ((typeUtils.isCharLike(type) === false && typeUtils.isHexLike(type) === false)
19
19
  || type instanceof basic_1.StructureType) {
20
- throw new Error("Not character like, " + type.constructor.name);
20
+ throw new Error("String template, not character like, " + type.constructor.name);
21
21
  }
22
22
  const format = templateSource.findDirectExpression(Expressions.StringTemplateFormatting);
23
23
  const formatConcat = format === null || format === void 0 ? void 0 : format.concatTokens();
@@ -9,6 +9,7 @@ const _reference_1 = require("../_reference");
9
9
  const basic_1 = require("../../types/basic");
10
10
  const types_1 = require("../../types");
11
11
  const _object_oriented_1 = require("../_object_oriented");
12
+ const _type_utils_1 = require("../_type_utils");
12
13
  class CreateObject {
13
14
  runSyntax(node, scope, filename) {
14
15
  let cdef = undefined;
@@ -32,7 +33,7 @@ class CreateObject {
32
33
  }
33
34
  }
34
35
  // just recurse
35
- for (const s of node.findAllExpressions(Expressions.Source)) {
36
+ for (const s of node.findDirectExpressions(Expressions.Source)) {
36
37
  new source_1.Source().runSyntax(s, scope, filename);
37
38
  }
38
39
  let first = true;
@@ -76,26 +77,35 @@ class CreateObject {
76
77
  for (const t of node.findDirectExpressions(Expressions.Dynamic)) {
77
78
  new dynamic_1.Dynamic().runSyntax(t, scope, filename);
78
79
  }
79
- this.validateParameters(cdef, node, scope);
80
+ this.validateParameters(cdef, node, scope, filename);
80
81
  }
81
- validateParameters(cdef, node, scope) {
82
- var _a, _b, _c;
82
+ validateParameters(cdef, node, scope, filename) {
83
+ var _a, _b, _c, _d;
83
84
  if (cdef === undefined) {
85
+ const sources = (_a = node.findDirectExpression(Expressions.ParameterListS)) === null || _a === void 0 ? void 0 : _a.findAllExpressions(Expressions.Source);
86
+ for (const s of sources || []) {
87
+ new source_1.Source().runSyntax(s, scope, filename);
88
+ }
84
89
  return;
85
90
  }
86
91
  const methodDef = new _object_oriented_1.ObjectOriented(scope).searchMethodName(cdef, "CONSTRUCTOR");
87
- const methodParameters = (_a = methodDef.method) === null || _a === void 0 ? void 0 : _a.getParameters();
92
+ const methodParameters = (_b = methodDef.method) === null || _b === void 0 ? void 0 : _b.getParameters();
88
93
  const allImporting = (methodParameters === null || methodParameters === void 0 ? void 0 : methodParameters.getImporting()) || [];
89
94
  const requiredImporting = new Set(methodParameters === null || methodParameters === void 0 ? void 0 : methodParameters.getRequiredParameters().map(i => i.getName().toUpperCase()));
90
- // todo, validate types
91
- for (const p of ((_b = node.findDirectExpression(Expressions.ParameterListS)) === null || _b === void 0 ? void 0 : _b.findAllExpressions(Expressions.ParameterS)) || []) {
92
- const name = (_c = p.findDirectExpression(Expressions.ParameterName)) === null || _c === void 0 ? void 0 : _c.concatTokens().toUpperCase();
95
+ for (const p of ((_c = node.findDirectExpression(Expressions.ParameterListS)) === null || _c === void 0 ? void 0 : _c.findAllExpressions(Expressions.ParameterS)) || []) {
96
+ const name = (_d = p.findDirectExpression(Expressions.ParameterName)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();
93
97
  if (name === undefined) {
94
98
  continue;
95
99
  }
96
- if ((allImporting === null || allImporting === void 0 ? void 0 : allImporting.some(p => p.getName().toUpperCase() === name)) === false) {
100
+ const source = p.findDirectExpression(Expressions.Source);
101
+ const sourceType = new source_1.Source().runSyntax(source, scope, filename);
102
+ const found = allImporting === null || allImporting === void 0 ? void 0 : allImporting.find(p => p.getName().toUpperCase() === name);
103
+ if (found === undefined) {
97
104
  throw new Error(`constructor parameter "${name}" does not exist`);
98
105
  }
106
+ else if (new _type_utils_1.TypeUtils(scope).isAssignableStrict(sourceType, found.getType()) === false) {
107
+ throw new Error(`constructor parameter "${name}" type not compatible`);
108
+ }
99
109
  requiredImporting.delete(name);
100
110
  }
101
111
  for (const r of requiredImporting.values()) {
@@ -9,10 +9,17 @@ class AbstractFile {
9
9
  return this.filename;
10
10
  }
11
11
  baseName() {
12
- const first = this.getFilename().split("\\");
13
- const base1 = first[first.length - 1];
14
- const base2 = base1.split("/");
15
- return base2[base2.length - 1];
12
+ let name = this.getFilename();
13
+ let index = name.lastIndexOf("\\");
14
+ if (index) {
15
+ index = index + 1;
16
+ }
17
+ name = name.substring(index);
18
+ index = name.lastIndexOf("/");
19
+ if (index) {
20
+ index = index + 1;
21
+ }
22
+ return name.substring(index);
16
23
  }
17
24
  getObjectType() {
18
25
  var _a;
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.102.65";
68
+ return "2.102.67";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.102.65",
3
+ "version": "2.102.67",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -50,10 +50,10 @@
50
50
  },
51
51
  "homepage": "https://abaplint.org",
52
52
  "devDependencies": {
53
- "@microsoft/api-extractor": "^7.38.0",
53
+ "@microsoft/api-extractor": "^7.38.1",
54
54
  "@types/chai": "^4.3.9",
55
55
  "@types/mocha": "^10.0.3",
56
- "@types/node": "^20.8.9",
56
+ "@types/node": "^20.8.10",
57
57
  "chai": "^4.3.10",
58
58
  "eslint": "^8.52.0",
59
59
  "mocha": "^10.2.0",