@abaplint/core 2.85.10 → 2.85.14

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.
package/README.md CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  [abaplint](https://abaplint.org/) core library
4
4
 
5
- Exposes functionallity like the parser and rules, which can be used in other projects.
5
+ Exposes functionality like the parser and rules, which can be used in other projects.
6
6
 
7
7
  For more information see https://github.com/abaplint/abaplint
@@ -1480,7 +1480,8 @@ declare class Domain extends AbstractObject {
1480
1480
 
1481
1481
  declare interface DomainValue {
1482
1482
  language: string;
1483
- value: string;
1483
+ low: string;
1484
+ high: string;
1484
1485
  description: string;
1485
1486
  }
1486
1487
 
@@ -11,7 +11,7 @@ class Raise {
11
11
  const exporting = (0, combi_1.seq)("EXPORTING", expressions_1.ParameterListS);
12
12
  const from = (0, combi_1.seq)("TYPE", expressions_1.ClassName, (0, combi_1.opt)((0, combi_1.alt)((0, combi_1.ver)(version_1.Version.v750, (0, combi_1.alt)(mess, messid)), (0, combi_1.ver)(version_1.Version.v752, "USING MESSAGE"))), (0, combi_1.optPrio)(exporting));
13
13
  const clas = (0, combi_1.seq)((0, combi_1.optPrio)("RESUMABLE"), "EXCEPTION", (0, combi_1.altPrio)(from, (0, combi_1.ver)(version_1.Version.v752, expressions_1.Source), expressions_1.SimpleSource2));
14
- const ret = (0, combi_1.seq)("RAISE", (0, combi_1.altPrio)(clas, expressions_1.Field));
14
+ const ret = (0, combi_1.seq)("RAISE", (0, combi_1.altPrio)(clas, expressions_1.ExceptionName));
15
15
  return ret;
16
16
  }
17
17
  }
@@ -42,7 +42,7 @@ class BuiltInMethod extends _identifier_1.Identifier {
42
42
  }
43
43
  const keys = Object.keys(this.method.mandatory);
44
44
  if (keys.length === 1) {
45
- return keys[0];
45
+ return keys[0].toUpperCase();
46
46
  }
47
47
  return undefined;
48
48
  }
@@ -651,7 +651,7 @@ BuiltIn.methods = [
651
651
  {
652
652
  name: "LINE_EXISTS",
653
653
  mandatory: {
654
- "val": new basic_1.TableType(new basic_1.AnyType(), { withHeader: false }),
654
+ "val": new basic_1.AnyType(),
655
655
  },
656
656
  return: new basic_1.CharacterType(1),
657
657
  version: version_1.Version.v740sp02,
@@ -7,6 +7,9 @@ class TypeUtils {
7
7
  if (type === undefined) {
8
8
  return false;
9
9
  }
10
+ else if (type instanceof basic_1.TableType && type.isWithHeader()) {
11
+ return this.isCharLike(type.getRowType());
12
+ }
10
13
  else if (type instanceof basic_1.StructureType) {
11
14
  for (const c of type.getComponents()) {
12
15
  if (this.isCharLike(c.type) === false) {
@@ -20,6 +23,13 @@ class TypeUtils {
20
23
  || type instanceof basic_1.AnyType
21
24
  || type instanceof basic_1.UnknownType
22
25
  || type instanceof basic_1.NumericType
26
+ || type instanceof basic_1.IntegerType
27
+ || type instanceof basic_1.FloatType
28
+ || type instanceof basic_1.FloatingPointType
29
+ || type instanceof basic_1.DecFloatType
30
+ || type instanceof basic_1.DecFloat16Type
31
+ || type instanceof basic_1.DecFloat34Type
32
+ || type instanceof basic_1.NumericGenericType
23
33
  || type instanceof basic_1.CSequenceType
24
34
  || type instanceof basic_1.DateType
25
35
  || type instanceof basic_1.CLikeType
@@ -53,8 +63,8 @@ class TypeUtils {
53
63
  }
54
64
  static isAssignable(source, target) {
55
65
  /*
56
- console.dir(source);
57
- console.dir(target);
66
+ console.dir(source);
67
+ console.dir(target);
58
68
  */
59
69
  if (target instanceof basic_1.TableType) {
60
70
  if (target.isWithHeader()) {
@@ -97,8 +107,13 @@ class TypeUtils {
97
107
  || source instanceof basic_1.UnknownType) {
98
108
  return true;
99
109
  }
100
- else if (this.isCharLike(target)
101
- && (this.isCharLike(source) || source instanceof basic_1.IntegerType)) {
110
+ else if (target.containsVoid() === true) {
111
+ return true;
112
+ }
113
+ else if (source instanceof basic_1.IntegerType) {
114
+ return false;
115
+ }
116
+ else if (this.isCharLike(target) && this.isCharLike(source)) {
102
117
  return true;
103
118
  }
104
119
  return false;
@@ -18,7 +18,7 @@ class AttributeChain {
18
18
  if (!(first.get() instanceof expressions_1.AttributeName)) {
19
19
  throw new Error("AttributeChain, unexpected first child");
20
20
  }
21
- const def = scope.findClassDefinition(inputContext.getIdentifierName());
21
+ const def = scope.findObjectDefinition(inputContext.getIdentifierName());
22
22
  if (def === undefined) {
23
23
  throw new Error("Definition for \"" + inputContext.getIdentifierName() + "\" not found in scope(AttributeChain)");
24
24
  }
@@ -8,6 +8,9 @@ class Constant {
8
8
  if (node.findDirectExpression(expressions_1.Integer)) {
9
9
  return new basic_1.IntegerType("I");
10
10
  }
11
+ else if (node.getFirstToken().getStr().startsWith("'")) {
12
+ return new basic_1.CharacterType(10);
13
+ }
11
14
  else {
12
15
  return new basic_1.StringType("STRING");
13
16
  }
@@ -25,7 +25,6 @@ class MethodCallParam {
25
25
  throw new Error("Parameter \"" + required[0].getName() + "\" must be supplied");
26
26
  }
27
27
  }
28
- return;
29
28
  }
30
29
  else if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.Source) {
31
30
  if (!(method instanceof basic_1.VoidType) && method.getParameters().getImporting().length === 0) {
@@ -7,6 +7,7 @@ const nodes_1 = require("../../nodes");
7
7
  const inline_data_1 = require("./inline_data");
8
8
  const target_1 = require("./target");
9
9
  const source_1 = require("./source");
10
+ const _type_utils_1 = require("../_type_utils");
10
11
  class MethodParameters {
11
12
  constructor() {
12
13
  this.requiredParameters = undefined;
@@ -63,7 +64,10 @@ class MethodParameters {
63
64
  new inline_data_1.InlineData().runSyntax(inline, scope, filename, type);
64
65
  }
65
66
  else if (target) {
66
- new target_1.Target().runSyntax(target, scope, filename);
67
+ const targetType = new target_1.Target().runSyntax(target, scope, filename);
68
+ if (targetType && _type_utils_1.TypeUtils.isAssignable(type, targetType) === false) {
69
+ throw new Error("Method returning value not type compatible");
70
+ }
67
71
  }
68
72
  }
69
73
  checkImporting(node, scope, method, filename) {
@@ -86,8 +90,8 @@ class MethodParameters {
86
90
  else if (item.targetType === undefined) {
87
91
  throw new Error("Could not determine target type");
88
92
  }
89
- else if (item.targetType) {
90
- // todo, check that targetType and parameterType are compatible
93
+ else if (item.targetType && _type_utils_1.TypeUtils.isAssignable(parameterType, item.targetType) === false) {
94
+ throw new Error("Method parameter type not compatible, " + item.name);
91
95
  }
92
96
  }
93
97
  }
@@ -105,34 +109,28 @@ class MethodParameters {
105
109
  }
106
110
  parameterType = parameter.getType();
107
111
  }
108
- if (item.targetType) {
109
- // todo, check that targetType and parameterType are compatible
110
- if (0) {
111
- console.log(parameterType); // todo
112
- }
112
+ if (item.targetType && _type_utils_1.TypeUtils.isAssignable(parameterType, item.targetType) === false) {
113
+ throw new Error("Method parameter type not compatible, " + item.name);
113
114
  }
114
115
  (_a = this.requiredParameters) === null || _a === void 0 ? void 0 : _a.delete(item.name);
115
116
  }
116
117
  }
117
118
  checkExporting(node, scope, method, filename, errors = true) {
119
+ const items = this.parameterListS(node, scope, filename, method);
118
120
  if (method instanceof basic_1.VoidType) {
119
- this.parameterListS(node, scope, filename, method);
120
121
  return;
121
122
  }
122
123
  const allImporting = method.getParameters().getImporting();
123
124
  if (this.requiredParameters === undefined) {
124
125
  this.requiredParameters = new Set(method.getParameters().getRequiredParameters().map(i => i.getName().toUpperCase()));
125
126
  }
126
- for (const item of this.parameterListS(node, scope, filename, method)) {
127
- let parameterType = undefined;
127
+ for (const item of items) {
128
128
  const parameter = allImporting.find(p => p.getName().toUpperCase() === item.name);
129
129
  if (parameter === undefined) {
130
130
  throw new Error("Method importing parameter \"" + item.name + "\" does not exist");
131
131
  }
132
- parameterType = parameter.getType();
133
- // todo, check that targetType and parameterType are compatible
134
- if (0) {
135
- console.log(parameterType); // todo
132
+ else if (_type_utils_1.TypeUtils.isAssignable(parameter.getType(), item.sourceType) === false) {
133
+ throw new Error("Method parameter type not compatible, " + item.name);
136
134
  }
137
135
  this.requiredParameters.delete(item.name);
138
136
  }
@@ -5,11 +5,18 @@ const Expressions = require("../../2_statements/expressions");
5
5
  const source_1 = require("../expressions/source");
6
6
  const target_1 = require("../expressions/target");
7
7
  const dynamic_1 = require("../expressions/dynamic");
8
+ const _type_utils_1 = require("../_type_utils");
8
9
  class Write {
9
10
  runSyntax(node, scope, filename) {
10
11
  // todo, more
12
+ const second = node.getChildren()[1];
11
13
  for (const s of node.findAllExpressions(Expressions.Source)) {
12
- new source_1.Source().runSyntax(s, scope, filename);
14
+ const type = new source_1.Source().runSyntax(s, scope, filename);
15
+ if (s === second
16
+ && _type_utils_1.TypeUtils.isCharLike(type) === false
17
+ && _type_utils_1.TypeUtils.isHexLike(type) === false) {
18
+ throw new Error("Source not character like");
19
+ }
13
20
  }
14
21
  for (const s of node.findAllExpressions(Expressions.Dynamic)) {
15
22
  new dynamic_1.Dynamic().runSyntax(s, scope, filename);
@@ -43,7 +43,7 @@ class StructureType extends _abstract_type_1.AbstractType {
43
43
  return "StructureTypetoABAPtodo";
44
44
  }
45
45
  containsVoid() {
46
- return this.getComponents().some(c => { c.type.containsVoid(); });
46
+ return this.getComponents().some(c => { return c.type.containsVoid(); });
47
47
  }
48
48
  toCDS() {
49
49
  return "abap.TODO_STRUCTURE";
@@ -52,7 +52,8 @@ class Domain extends _abstract_object_1.AbstractObject {
52
52
  for (const ddo7v of dd07v_tab) {
53
53
  const value = {
54
54
  description: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DDTEXT,
55
- value: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DOMVALUE_L,
55
+ low: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DOMVALUE_L,
56
+ high: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DOMVALUE_H,
56
57
  language: ddo7v === null || ddo7v === void 0 ? void 0 : ddo7v.DDLANGUAGE,
57
58
  };
58
59
  values.push(value);
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.85.10";
71
+ return "2.85.14";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -61,7 +61,7 @@ class ConstantClasses {
61
61
  return [];
62
62
  }
63
63
  const domainValueInfo = obj.getFixedValues();
64
- const domainValues = domainValueInfo.map(x => x.value);
64
+ const domainValues = domainValueInfo.map(x => x.low);
65
65
  const issues = [];
66
66
  if (obj.getFixedValues().length === 0) {
67
67
  // possibly this is not even a domain with fixed values
@@ -94,8 +94,8 @@ class ConstantClasses {
94
94
  }
95
95
  }
96
96
  for (const d of domainValueInfo) {
97
- if (!def.constants.find(c => c.value === d.value)) {
98
- issues.push(issue_1.Issue.atStatement(classContents, classContents.getStatements()[0], `Missing constant for ${d.value} (domain ${configEntry.domain})`, this.getMetadata().key, this.conf.severity));
97
+ if (!def.constants.find(c => c.value === d.low)) {
98
+ issues.push(issue_1.Issue.atStatement(classContents, classContents.getStatements()[0], `Missing constant for ${d.low} (domain ${configEntry.domain})`, this.getMetadata().key, this.conf.severity));
99
99
  // quickfix will add constant
100
100
  }
101
101
  }
@@ -66,7 +66,7 @@ class UnusedVariables {
66
66
  shortDescription: `Checks for unused variables and constants`,
67
67
  extendedInformation: `WARNING: slow
68
68
 
69
- Experimental, might give false positives. Skips event parameters.
69
+ Skips event parameters.
70
70
 
71
71
  Note that this currently does not work if the source code uses macros.
72
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.85.10",
3
+ "version": "2.85.14",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -48,7 +48,7 @@
48
48
  "@microsoft/api-extractor": "^7.19.4",
49
49
  "@types/chai": "^4.3.0",
50
50
  "@types/mocha": "^9.1.0",
51
- "@types/node": "^17.0.15",
51
+ "@types/node": "^17.0.17",
52
52
  "chai": "^4.3.6",
53
53
  "eslint": "^8.8.0",
54
54
  "mocha": "^9.2.0",