@abaplint/core 2.102.2 → 2.102.4

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.
@@ -12,6 +12,7 @@ const _typed_identifier_1 = require("../types/_typed_identifier");
12
12
  const basic_1 = require("../types/basic");
13
13
  const ddic_1 = require("../../ddic");
14
14
  const _object_oriented_1 = require("./_object_oriented");
15
+ const _reference_1 = require("./_reference");
15
16
  class Procedural {
16
17
  constructor(reg, scope) {
17
18
  this.scope = scope;
@@ -85,7 +86,19 @@ class Procedural {
85
86
  if (param.type === undefined || param.type === "") {
86
87
  found = new basic_1.AnyType();
87
88
  }
88
- else {
89
+ else if (param.type.includes("=>")) {
90
+ // then its a type from global INTF or CLAS
91
+ const [clas, name] = param.type.split("=>");
92
+ const def = this.scope.findObjectDefinition(clas);
93
+ if (def) {
94
+ const type = def.getTypeDefinitions().getByName(name);
95
+ if (type) {
96
+ this.scope.addReference(nameToken, type, _reference_1.ReferenceType.TypeReference, filename);
97
+ found = type.getType();
98
+ }
99
+ }
100
+ }
101
+ if (found === undefined) {
89
102
  found = ddic.lookup(param.type).type;
90
103
  }
91
104
  if (param.direction === types_1.FunctionModuleParameterDirection.tables) {
@@ -214,7 +214,11 @@ class TypeUtils {
214
214
  /*
215
215
  console.dir(source);
216
216
  console.dir(target);
217
+ console.dir(calculated);
217
218
  */
219
+ if (calculated && source instanceof basic_1.StringType && target instanceof basic_1.XStringType) {
220
+ return false;
221
+ }
218
222
  if (calculated) {
219
223
  return this.isAssignable(source, target);
220
224
  }
@@ -265,6 +269,9 @@ class TypeUtils {
265
269
  }
266
270
  return false;
267
271
  }
272
+ else if (target instanceof cgeneric_type_1.CGenericType) {
273
+ return false;
274
+ }
268
275
  else if (target instanceof basic_1.XSequenceType || target instanceof basic_1.XStringType) {
269
276
  if (((_g = source.getAbstractTypeData()) === null || _g === void 0 ? void 0 : _g.derivedFromConstant) === true) {
270
277
  return true;
@@ -53,6 +53,7 @@ class MethodCallParam {
53
53
  sourceType = new source_1.Source().runSyntax(child, scope, filename, targetType);
54
54
  }
55
55
  const calculated = child.findFirstExpression(Expressions.MethodCallChain) !== undefined
56
+ || child.findFirstExpression(Expressions.StringTemplate) !== undefined
56
57
  || child.findFirstExpression(Expressions.ArithOperator) !== undefined;
57
58
  if (sourceType === undefined) {
58
59
  throw new Error("No source type determined, method source");
@@ -126,10 +126,13 @@ class MethodParameters {
126
126
  }
127
127
  for (const item of items) {
128
128
  const parameter = allImporting.find(p => p.getName().toUpperCase() === item.name);
129
+ const calculated = item.source.findFirstExpression(Expressions.MethodCallChain) !== undefined
130
+ || item.source.findFirstExpression(Expressions.StringTemplate) !== undefined
131
+ || item.source.findFirstExpression(Expressions.ArithOperator) !== undefined;
129
132
  if (parameter === undefined) {
130
133
  throw new Error("Method importing parameter \"" + item.name + "\" does not exist");
131
134
  }
132
- else if (new _type_utils_1.TypeUtils(scope).isAssignableStrict(item.sourceType, parameter.getType()) === false) {
135
+ else if (new _type_utils_1.TypeUtils(scope).isAssignableStrict(item.sourceType, parameter.getType(), calculated) === false) {
133
136
  throw new Error("Method parameter type not compatible, " + item.name);
134
137
  }
135
138
  this.requiredParameters.delete(item.name);
@@ -8,9 +8,10 @@ const _type_utils_1 = require("../_type_utils");
8
8
  class StringTemplate {
9
9
  runSyntax(node, scope, filename) {
10
10
  const typeUtils = new _type_utils_1.TypeUtils(scope);
11
+ const ret = basic_1.StringType.get();
11
12
  for (const templateSource of node.findAllExpressions(Expressions.StringTemplateSource)) {
12
13
  const s = templateSource.findDirectExpression(Expressions.Source);
13
- const type = new source_1.Source().runSyntax(s, scope, filename, basic_1.StringType.get());
14
+ const type = new source_1.Source().runSyntax(s, scope, filename, ret);
14
15
  if (type === undefined) {
15
16
  throw new Error("No target type determined");
16
17
  }
@@ -34,7 +35,7 @@ class StringTemplate {
34
35
  throw new Error("Cannot apply ALPHA to this type");
35
36
  }
36
37
  }
37
- return basic_1.StringType.get();
38
+ return ret;
38
39
  }
39
40
  }
40
41
  exports.StringTemplate = StringTemplate;
@@ -21,23 +21,52 @@ class TableType extends _abstract_object_1.AbstractObject {
21
21
  };
22
22
  }
23
23
  getDescription() {
24
- // todo
25
- return undefined;
24
+ var _a;
25
+ this.parseXML();
26
+ return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.ddtext;
26
27
  }
27
28
  setDirty() {
28
29
  this.parsedXML = undefined;
29
30
  super.setDirty();
30
31
  }
31
32
  buildTableOptions() {
32
- var _a, _b, _c;
33
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
34
+ let primaryKey = undefined;
35
+ if (((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.accessmode) === "S") {
36
+ primaryKey = {
37
+ isUnique: ((_b = this.parsedXML) === null || _b === void 0 ? void 0 : _b.keykind) === "U",
38
+ type: basic_1.TableAccessType.sorted,
39
+ keyFields: [],
40
+ name: "primary_key",
41
+ };
42
+ for (const f of ((_c = this.parsedXML) === null || _c === void 0 ? void 0 : _c.dd42v) || []) {
43
+ if (f.keyname === "") {
44
+ primaryKey.keyFields.push(f.keyfield);
45
+ }
46
+ }
47
+ }
48
+ else if (((_d = this.parsedXML) === null || _d === void 0 ? void 0 : _d.accessmode) === "H") {
49
+ primaryKey = {
50
+ isUnique: ((_e = this.parsedXML) === null || _e === void 0 ? void 0 : _e.keykind) === "U",
51
+ type: basic_1.TableAccessType.hashed,
52
+ keyFields: [],
53
+ name: "primary_key",
54
+ };
55
+ for (const f of ((_f = this.parsedXML) === null || _f === void 0 ? void 0 : _f.dd42v) || []) {
56
+ if (f.keyname === "") {
57
+ primaryKey.keyFields.push(f.keyfield);
58
+ }
59
+ }
60
+ }
33
61
  const tableOptions = {
34
62
  withHeader: false,
35
63
  keyType: Types.TableKeyType.user,
64
+ primaryKey: primaryKey,
36
65
  secondary: [],
37
66
  };
38
- for (const k of ((_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.dd43v) || []) {
67
+ for (const k of ((_g = this.parsedXML) === null || _g === void 0 ? void 0 : _g.dd43v) || []) {
39
68
  const fields = [];
40
- for (const f of ((_b = this.parsedXML) === null || _b === void 0 ? void 0 : _b.dd42v) || []) {
69
+ for (const f of ((_h = this.parsedXML) === null || _h === void 0 ? void 0 : _h.dd42v) || []) {
41
70
  if (f.keyname === k.keyname) {
42
71
  fields.push(f.keyfield);
43
72
  }
@@ -53,7 +82,7 @@ class TableType extends _abstract_object_1.AbstractObject {
53
82
  default:
54
83
  break;
55
84
  }
56
- (_c = tableOptions.secondary) === null || _c === void 0 ? void 0 : _c.push({
85
+ (_j = tableOptions.secondary) === null || _j === void 0 ? void 0 : _j.push({
57
86
  name: k.keyname,
58
87
  type: accessType,
59
88
  keyFields: fields,
@@ -141,6 +170,9 @@ class TableType extends _abstract_object_1.AbstractObject {
141
170
  this.parsedXML.datatype = dd40v.DATATYPE;
142
171
  this.parsedXML.leng = dd40v.LENG;
143
172
  this.parsedXML.decimals = dd40v.DECIMALS;
173
+ this.parsedXML.accessmode = dd40v.ACCESSMODE;
174
+ this.parsedXML.keykind = dd40v.KEYKIND;
175
+ this.parsedXML.ddtext = dd40v.DDTEXT;
144
176
  for (const x of (0, xml_utils_1.xmlToArray)((_a = values.DD42V) === null || _a === void 0 ? void 0 : _a.DD42V)) {
145
177
  this.parsedXML.dd42v.push({
146
178
  keyname: x.SECKEYNAME || "",
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.102.2";
68
+ return "2.102.4";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
@@ -42,6 +42,8 @@ class PreferPragmas extends _abap_rule_1.ABAPRule {
42
42
  shortDescription: `prefer pragmas over pseudo comments `,
43
43
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-pragmas-to-pseudo-comments`,
44
44
  tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
45
+ badExample: `DATA foo1 TYPE i. "#EC NEEDED`,
46
+ goodExample: `DATA foo2 TYPE i ##NEEDED.`,
45
47
  };
46
48
  }
47
49
  getConfig() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.102.2",
3
+ "version": "2.102.4",
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.36.2",
53
+ "@microsoft/api-extractor": "^7.36.3",
54
54
  "@types/chai": "^4.3.5",
55
55
  "@types/mocha": "^10.0.1",
56
- "@types/node": "^20.4.2",
56
+ "@types/node": "^20.4.4",
57
57
  "chai": "^4.3.7",
58
58
  "eslint": "^8.45.0",
59
59
  "mocha": "^10.2.0",
@@ -63,7 +63,7 @@
63
63
  "typescript": "^5.1.6"
64
64
  },
65
65
  "dependencies": {
66
- "fast-xml-parser": "^4.2.5",
66
+ "fast-xml-parser": "^4.2.6",
67
67
  "json5": "^2.2.3",
68
68
  "vscode-languageserver-types": "^3.17.3"
69
69
  }