@abaplint/core 2.120.46 → 2.120.48
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/build/src/abap/5_syntax/_type_utils.js +7 -0
- package/build/src/abap/5_syntax/expressions/compare.js +11 -2
- package/build/src/abap/5_syntax/expressions/inline_data.js +32 -1
- package/build/src/abap/5_syntax/statements/get_time.js +19 -1
- package/build/src/registry.js +1 -1
- package/package.json +1 -1
|
@@ -94,6 +94,13 @@ class TypeUtils {
|
|
|
94
94
|
|| type instanceof basic_1.UnknownType
|
|
95
95
|
|| type instanceof basic_1.VoidType;
|
|
96
96
|
}
|
|
97
|
+
isCharLikeForCompare(type) {
|
|
98
|
+
return type === undefined
|
|
99
|
+
|| type instanceof basic_1.StringType
|
|
100
|
+
|| type instanceof basic_1.CLikeType
|
|
101
|
+
|| type instanceof basic_1.CSequenceType
|
|
102
|
+
|| this.isCharLikeField(type);
|
|
103
|
+
}
|
|
97
104
|
isCharLike(type) {
|
|
98
105
|
if (type === undefined) {
|
|
99
106
|
return false;
|
|
@@ -43,6 +43,7 @@ const basic_1 = require("../../types/basic");
|
|
|
43
43
|
const _type_utils_1 = require("../_type_utils");
|
|
44
44
|
class Compare {
|
|
45
45
|
static runSyntax(node, input) {
|
|
46
|
+
var _a;
|
|
46
47
|
const sourceTypes = [];
|
|
47
48
|
const sources = node.findDirectExpressions(Expressions.Source);
|
|
48
49
|
for (const t of sources) {
|
|
@@ -54,8 +55,16 @@ class Compare {
|
|
|
54
55
|
for (const t of node.findDirectExpressions(Expressions.MethodCallChain)) {
|
|
55
56
|
method_call_chain_1.MethodCallChain.runSyntax(t, input);
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const typeUtils = new _type_utils_1.TypeUtils(input.scope);
|
|
59
|
+
const compareOperator = (_a = node.findDirectExpression(Expressions.CompareOperator)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
|
|
60
|
+
if (compareOperator === "CS"
|
|
61
|
+
&& sourceTypes.length === 2
|
|
62
|
+
&& sourceTypes.some((type) => typeUtils.isCharLikeForCompare(type) === false)) {
|
|
63
|
+
const message = "CS operands must be character-like (data type C, N, D, T, or STRING)";
|
|
64
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
65
|
+
}
|
|
66
|
+
else if (node.findDirectExpression(Expressions.CompareOperator)
|
|
67
|
+
&& typeUtils.isCompareable(sourceTypes[0], sourceTypes[1], sources[0], sources[1]) === false
|
|
59
68
|
&& sourceTypes.length === 2) {
|
|
60
69
|
let message = "Incompatible types for comparison";
|
|
61
70
|
if ((sourceTypes[0] instanceof basic_1.DateType
|
|
@@ -32,6 +32,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
+
t[p[i]] = s[p[i]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.InlineData = void 0;
|
|
37
48
|
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
@@ -64,7 +75,7 @@ class InlineData {
|
|
|
64
75
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
65
76
|
type = basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
66
77
|
}
|
|
67
|
-
const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, type, ["inline" /* IdentifierMeta.InlineDefinition */]);
|
|
78
|
+
const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, this.stripDerivedFromConstant(type), ["inline" /* IdentifierMeta.InlineDefinition */]);
|
|
68
79
|
input.scope.addIdentifier(identifier);
|
|
69
80
|
input.scope.addReference(token, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename);
|
|
70
81
|
}
|
|
@@ -75,6 +86,26 @@ class InlineData {
|
|
|
75
86
|
input.scope.addReference(token, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename);
|
|
76
87
|
}
|
|
77
88
|
}
|
|
89
|
+
// The inferred type is taken from the source expression, which might be a literal.
|
|
90
|
+
// The variable itself is not a constant, so the relaxations that apply to literals
|
|
91
|
+
// must not be inherited, eg. a "c" variable is not assignable to a "string" parameter
|
|
92
|
+
static stripDerivedFromConstant(type) {
|
|
93
|
+
const data = type.getAbstractTypeData();
|
|
94
|
+
if ((data === null || data === void 0 ? void 0 : data.derivedFromConstant) !== true) {
|
|
95
|
+
return type;
|
|
96
|
+
}
|
|
97
|
+
const { derivedFromConstant } = data, rest = __rest(data, ["derivedFromConstant"]);
|
|
98
|
+
if (type instanceof basic_1.CharacterType) {
|
|
99
|
+
return new basic_1.CharacterType(type.getLength(), rest);
|
|
100
|
+
}
|
|
101
|
+
else if (type instanceof basic_1.IntegerType) {
|
|
102
|
+
return basic_1.IntegerType.get(rest);
|
|
103
|
+
}
|
|
104
|
+
else if (type instanceof basic_1.StringType) {
|
|
105
|
+
return basic_1.StringType.get(rest);
|
|
106
|
+
}
|
|
107
|
+
return type;
|
|
108
|
+
}
|
|
78
109
|
}
|
|
79
110
|
exports.InlineData = InlineData;
|
|
80
111
|
//# sourceMappingURL=inline_data.js.map
|
|
@@ -38,17 +38,35 @@ const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
|
38
38
|
const inline_data_1 = require("../expressions/inline_data");
|
|
39
39
|
const basic_1 = require("../../types/basic");
|
|
40
40
|
const target_1 = require("../expressions/target");
|
|
41
|
+
const _syntax_input_1 = require("../_syntax_input");
|
|
41
42
|
class GetTime {
|
|
42
43
|
runSyntax(node, input) {
|
|
43
44
|
const target = node.findDirectExpression(Expressions.Target);
|
|
45
|
+
const stamp = node.findDirectTokenByText("STAMP") !== undefined;
|
|
44
46
|
const inline = target === null || target === void 0 ? void 0 : target.findDirectExpression(Expressions.InlineData);
|
|
45
47
|
if (inline) {
|
|
46
48
|
inline_data_1.InlineData.runSyntax(inline, input, new basic_1.PackedType(8, 0));
|
|
47
49
|
}
|
|
48
50
|
else if (target) {
|
|
49
|
-
target_1.Target.runSyntax(target, input);
|
|
51
|
+
const type = target_1.Target.runSyntax(target, input);
|
|
52
|
+
if (stamp === true && this.compatibleTimeStamp(type) === false) {
|
|
53
|
+
const message = "GET TIME STAMP FIELD, target type not compatible";
|
|
54
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
50
57
|
}
|
|
51
58
|
}
|
|
59
|
+
// the target must be a timestamp, ie. packed(timestamp and timestampl) or utclong
|
|
60
|
+
compatibleTimeStamp(type) {
|
|
61
|
+
return type === undefined
|
|
62
|
+
|| type instanceof basic_1.PackedType
|
|
63
|
+
|| type instanceof basic_1.UTCLongType
|
|
64
|
+
|| type instanceof basic_1.VoidType
|
|
65
|
+
|| type instanceof basic_1.AnyType
|
|
66
|
+
|| type instanceof basic_1.DataType
|
|
67
|
+
|| type instanceof basic_1.UnknownType
|
|
68
|
+
|| type.isGeneric();
|
|
69
|
+
}
|
|
52
70
|
}
|
|
53
71
|
exports.GetTime = GetTime;
|
|
54
72
|
//# sourceMappingURL=get_time.js.map
|
package/build/src/registry.js
CHANGED