@abaplint/core 2.97.7 → 2.97.8

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.
@@ -111,6 +111,7 @@ export declare abstract class AbstractType {
111
111
  declare type AbstractTypeData = {
112
112
  qualifiedName?: string;
113
113
  conversionExit?: string;
114
+ derivedFromConstant?: boolean;
114
115
  ddicName?: string;
115
116
  };
116
117
 
@@ -379,6 +380,7 @@ declare class Back implements IStatement {
379
380
  declare namespace BasicTypes {
380
381
  export {
381
382
  AnyType,
383
+ CGenericType,
382
384
  CharacterType,
383
385
  CLikeType,
384
386
  CSequenceType,
@@ -784,6 +786,14 @@ declare class CDSWithParameters extends Expression {
784
786
  getRunnable(): IStatementRunnable;
785
787
  }
786
788
 
789
+ declare class CGenericType extends AbstractType {
790
+ toText(): string;
791
+ isGeneric(): boolean;
792
+ toABAP(): string;
793
+ containsVoid(): boolean;
794
+ toCDS(): string;
795
+ }
796
+
787
797
  declare class ChangeDocument extends AbstractObject {
788
798
  getType(): string;
789
799
  getAllowedNaming(): {
@@ -17,7 +17,8 @@ class Message {
17
17
  const mwith = (0, combi_1.seq)("WITH", s, (0, combi_1.opt)(sourc));
18
18
  const foo = (0, combi_1.seq)(expressions_1.MessageSource, (0, combi_1.opt)(options), (0, combi_1.opt)(mwith));
19
19
  const text = (0, combi_1.seq)(s, type, (0, combi_1.optPrio)(like), (0, combi_1.optPrio)(raising));
20
- const ret = (0, combi_1.seq)("MESSAGE", (0, combi_1.altPrio)(foo, text));
20
+ const cloud = (0, combi_1.seq)(expressions_1.MessageSource, (0, combi_1.opt)((0, combi_1.seq)("WITH", expressions_1.Source, (0, combi_1.opt)(expressions_1.Source), (0, combi_1.opt)(expressions_1.Source), (0, combi_1.opt)(expressions_1.Source))), into);
21
+ const ret = (0, combi_1.seq)("MESSAGE", (0, combi_1.altPrio)((0, combi_1.verNot)(version_1.Version.Cloud, foo), (0, combi_1.verNot)(version_1.Version.Cloud, text), (0, combi_1.ver)(version_1.Version.Cloud, cloud)));
21
22
  return ret;
22
23
  }
23
24
  }
@@ -147,7 +147,7 @@ class BuiltIn {
147
147
  ret.push(this.buildConstant("col_normal", new basic_1.IntegerType(), "2"));
148
148
  ret.push(this.buildConstant("col_positive", new basic_1.IntegerType(), "5"));
149
149
  ret.push(this.buildConstant("col_total", new basic_1.IntegerType(), "3"));
150
- ret.push(this.buildConstant("space", new basic_1.CharacterType(1), "' '"));
150
+ ret.push(this.buildConstant("space", new basic_1.CharacterType(1, { derivedFromConstant: true }), "' '"));
151
151
  for (const e of extras) {
152
152
  const id = new tokens_1.Identifier(new position_1.Position(this.row++, 1), e);
153
153
  ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, new basic_1.VoidType(e), ["read_only" /* IdentifierMeta.ReadOnly */, "built-in" /* IdentifierMeta.BuiltIn */], "'?'"));
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TypeUtils = void 0;
4
4
  const types_1 = require("../types");
5
5
  const basic_1 = require("../types/basic");
6
+ const cgeneric_type_1 = require("../types/basic/cgeneric_type");
6
7
  class TypeUtils {
7
8
  constructor(scope) {
8
9
  this.scope = scope;
@@ -23,6 +24,7 @@ class TypeUtils {
23
24
  || type instanceof basic_1.AnyType
24
25
  || type instanceof basic_1.CharacterType
25
26
  || type instanceof basic_1.SimpleType
27
+ || type instanceof cgeneric_type_1.CGenericType
26
28
  || type instanceof basic_1.CLikeType
27
29
  || type instanceof basic_1.DateType
28
30
  || type instanceof basic_1.CSequenceType
@@ -51,6 +53,7 @@ class TypeUtils {
51
53
  return true;
52
54
  }
53
55
  else if (type instanceof basic_1.StringType
56
+ || type instanceof basic_1.CharacterType
54
57
  || type instanceof basic_1.VoidType
55
58
  || type instanceof basic_1.AnyType
56
59
  || type instanceof basic_1.UnknownType
@@ -64,11 +67,11 @@ class TypeUtils {
64
67
  || type instanceof basic_1.DecFloat34Type
65
68
  || type instanceof basic_1.NumericGenericType
66
69
  || type instanceof basic_1.CSequenceType
70
+ || type instanceof cgeneric_type_1.CGenericType
67
71
  || type instanceof basic_1.DateType
68
72
  || type instanceof basic_1.CLikeType
69
73
  || type instanceof basic_1.PackedType
70
- || type instanceof basic_1.TimeType
71
- || type instanceof basic_1.CharacterType) {
74
+ || type instanceof basic_1.TimeType) {
72
75
  return true;
73
76
  }
74
77
  return false;
@@ -187,6 +190,16 @@ class TypeUtils {
187
190
  // todo
188
191
  return true;
189
192
  }
193
+ isAssignableStrict(source, target) {
194
+ var _a;
195
+ if (source instanceof basic_1.CharacterType && target instanceof basic_1.CharacterType) {
196
+ if (((_a = source.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true) {
197
+ return source.getLength() <= target.getLength();
198
+ }
199
+ return source.getLength() === target.getLength();
200
+ }
201
+ return this.isAssignable(source, target);
202
+ }
190
203
  isAssignable(source, target) {
191
204
  /*
192
205
  console.dir(source);
@@ -13,7 +13,7 @@ class Constant {
13
13
  if (len <= 0) {
14
14
  len = 1;
15
15
  }
16
- return new basic_1.CharacterType(len);
16
+ return new basic_1.CharacterType(len, { derivedFromConstant: true });
17
17
  }
18
18
  else {
19
19
  return new basic_1.StringType({ qualifiedName: "STRING" });
@@ -15,6 +15,7 @@ class MethodCallBody {
15
15
  if (param) {
16
16
  new method_call_param_1.MethodCallParam().runSyntax(param, scope, method, filename);
17
17
  }
18
+ // for PARAMETER-TABLE and EXCEPTION-TABLE
18
19
  for (const s of node.findDirectExpressions(Expressions.Source)) {
19
20
  new source_1.Source().runSyntax(s, scope, filename);
20
21
  }
@@ -55,7 +55,7 @@ class MethodCallParam {
55
55
  if (sourceType === undefined) {
56
56
  throw new Error("No source type determined, method source");
57
57
  }
58
- else if (new _type_utils_1.TypeUtils(scope).isAssignable(sourceType, targetType) === false) {
58
+ else if (new _type_utils_1.TypeUtils(scope).isAssignableStrict(sourceType, targetType) === false) {
59
59
  throw new Error("Method parameter type not compatible");
60
60
  }
61
61
  }
@@ -6,6 +6,7 @@ const basic_1 = require("../../types/basic");
6
6
  const basic_types_1 = require("../basic_types");
7
7
  const Expressions = require("../../2_statements/expressions");
8
8
  const default_1 = require("./default");
9
+ const cgeneric_type_1 = require("../../types/basic/cgeneric_type");
9
10
  class MethodParam {
10
11
  runSyntax(node, scope, filename, meta) {
11
12
  const name = node.findDirectExpression(Expressions.MethodParamName);
@@ -25,6 +26,10 @@ class MethodParam {
25
26
  return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), filename, new basic_1.UnknownType(e.toString()), meta);
26
27
  }
27
28
  }
29
+ const concat = type.concatTokens().toUpperCase();
30
+ if (concat === "TYPE C" || concat.startsWith("TYPE C ")) {
31
+ return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), filename, new cgeneric_type_1.CGenericType(), meta);
32
+ }
28
33
  const found = new basic_types_1.BasicTypes(filename, scope).parseType(type);
29
34
  if (found) {
30
35
  return new _typed_identifier_1.TypedIdentifier(name.getFirstToken(), filename, found, meta);
@@ -129,7 +129,7 @@ class MethodParameters {
129
129
  if (parameter === undefined) {
130
130
  throw new Error("Method importing parameter \"" + item.name + "\" does not exist");
131
131
  }
132
- else if (new _type_utils_1.TypeUtils(scope).isAssignable(item.sourceType, parameter.getType()) === false) {
132
+ else if (new _type_utils_1.TypeUtils(scope).isAssignableStrict(item.sourceType, parameter.getType()) === false) {
133
133
  throw new Error("Method parameter type not compatible, " + item.name);
134
134
  }
135
135
  this.requiredParameters.delete(item.name);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CGenericType = void 0;
4
+ const _abstract_type_1 = require("./_abstract_type");
5
+ class CGenericType extends _abstract_type_1.AbstractType {
6
+ toText() {
7
+ return "```c```";
8
+ }
9
+ isGeneric() {
10
+ return true;
11
+ }
12
+ toABAP() {
13
+ throw new Error("c, generic");
14
+ }
15
+ containsVoid() {
16
+ return false;
17
+ }
18
+ toCDS() {
19
+ return "abap.TODO_CGENERIC";
20
+ }
21
+ }
22
+ exports.CGenericType = CGenericType;
23
+ //# sourceMappingURL=cgeneric_type.js.map
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./any_type"), exports);
18
+ __exportStar(require("./cgeneric_type"), exports);
18
19
  __exportStar(require("./character_type"), exports);
19
20
  __exportStar(require("./clike_type"), exports);
20
21
  __exportStar(require("./csequence_type"), exports);
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.97.7";
66
+ return "2.97.8";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.97.7",
3
+ "version": "2.97.8",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -60,7 +60,7 @@
60
60
  "typescript": "^5.0.4"
61
61
  },
62
62
  "dependencies": {
63
- "fast-xml-parser": "^4.1.4",
63
+ "fast-xml-parser": "^4.2.0",
64
64
  "json5": "^2.2.3",
65
65
  "vscode-languageserver-types": "^3.17.3"
66
66
  }