@abaplint/core 2.120.88 → 2.120.89
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/abaplint.d.ts +1 -1
- package/build/src/abap/5_syntax/_type_utils.js +9 -0
- package/build/src/abap/5_syntax/expressions/method_call_param.js +8 -1
- package/build/src/abap/5_syntax/expressions/method_parameters.js +6 -1
- package/build/src/cds/cds_determine_types.js +18 -2
- package/build/src/objects/data_definition.js +5 -1
- package/build/src/registry.js +1 -1
- package/build/src/rules/prefer_string_template.js +14 -5
- package/package.json +1 -1
package/build/abaplint.d.ts
CHANGED
|
@@ -5608,7 +5608,7 @@ declare type ParsedDataDefinition = {
|
|
|
5608
5608
|
sqlViewName: string | undefined;
|
|
5609
5609
|
definitionName: string | undefined;
|
|
5610
5610
|
description: string | undefined;
|
|
5611
|
-
/** name is the name of the element, nameInSource the name in the
|
|
5611
|
+
/** name is the name of the element, nameInSource the name in the source, if aliased via "as" */
|
|
5612
5612
|
fields: {
|
|
5613
5613
|
key: boolean;
|
|
5614
5614
|
name: string;
|
|
@@ -599,6 +599,15 @@ class TypeUtils {
|
|
|
599
599
|
}
|
|
600
600
|
return this.isAssignable(source, target);
|
|
601
601
|
}
|
|
602
|
+
// character-like arguments of built-in functions must be elementary, flat character-like structures are not allowed
|
|
603
|
+
isAssignableBuiltin(source, target, node) {
|
|
604
|
+
if (target instanceof basic_1.CLikeType
|
|
605
|
+
&& (source instanceof basic_1.StructureType
|
|
606
|
+
|| (source instanceof basic_1.TableType && source.isWithHeader() && source.getRowType() instanceof basic_1.StructureType))) {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
return this.isAssignableStrict(source, target, node);
|
|
610
|
+
}
|
|
602
611
|
// Typing with the classic STRUCTURE addition, ie. "FORM foo USING bar STRUCTURE zkey",
|
|
603
612
|
// is not a compatibility check: ABAP only checks the fragment view up to the end of the
|
|
604
613
|
// formal structure, so the actual parameter is allowed to be longer. For TABLES parameters
|
|
@@ -45,6 +45,7 @@ const _syntax_input_1 = require("../_syntax_input");
|
|
|
45
45
|
const constant_1 = require("./constant");
|
|
46
46
|
const _check_offset_length_1 = require("./_check_offset_length");
|
|
47
47
|
const _check_text_symbol_1 = require("./_check_text_symbol");
|
|
48
|
+
const _builtin_1 = require("../_builtin");
|
|
48
49
|
class MethodCallParam {
|
|
49
50
|
/** returns the type of the unnamed argument, if any */
|
|
50
51
|
static runSyntax(node, input, method) {
|
|
@@ -121,7 +122,7 @@ class MethodCallParam {
|
|
|
121
122
|
else if ((0, _check_text_symbol_1.checkTextSymbol)(child, targetType, input)) {
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
|
-
else if (
|
|
125
|
+
else if (this.isAssignable(sourceType, targetType, child, method, input) === false) {
|
|
125
126
|
const message = "Method parameter type not compatible";
|
|
126
127
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
127
128
|
return;
|
|
@@ -141,6 +142,12 @@ class MethodCallParam {
|
|
|
141
142
|
}
|
|
142
143
|
return undefined;
|
|
143
144
|
}
|
|
145
|
+
static isAssignable(sourceType, targetType, child, method, input) {
|
|
146
|
+
const typeUtils = new _type_utils_1.TypeUtils(input.scope);
|
|
147
|
+
return method instanceof _builtin_1.BuiltInMethod
|
|
148
|
+
? typeUtils.isAssignableBuiltin(sourceType, targetType, child)
|
|
149
|
+
: typeUtils.isAssignableStrict(sourceType, targetType, child);
|
|
150
|
+
}
|
|
144
151
|
}
|
|
145
152
|
exports.MethodCallParam = MethodCallParam;
|
|
146
153
|
//# sourceMappingURL=method_call_param.js.map
|
|
@@ -47,6 +47,7 @@ const field_chain_1 = require("./field_chain");
|
|
|
47
47
|
const _reference_1 = require("../_reference");
|
|
48
48
|
const _check_offset_length_1 = require("./_check_offset_length");
|
|
49
49
|
const _check_text_symbol_1 = require("./_check_text_symbol");
|
|
50
|
+
const _builtin_1 = require("../_builtin");
|
|
50
51
|
function normalizeParameterName(name) {
|
|
51
52
|
return name.replace(/^!/, "").toUpperCase();
|
|
52
53
|
}
|
|
@@ -194,6 +195,10 @@ class MethodParameters {
|
|
|
194
195
|
if (this.requiredParameters === undefined) {
|
|
195
196
|
this.requiredParameters = new Set(method.getParameters().getRequiredParameters().map(i => i.getName().toUpperCase()));
|
|
196
197
|
}
|
|
198
|
+
const typeUtils = new _type_utils_1.TypeUtils(input.scope);
|
|
199
|
+
const assignable = method instanceof _builtin_1.BuiltInMethod
|
|
200
|
+
? typeUtils.isAssignableBuiltin.bind(typeUtils)
|
|
201
|
+
: typeUtils.isAssignableStrict.bind(typeUtils);
|
|
197
202
|
for (const item of items) {
|
|
198
203
|
const parameter = allImporting.find(p => p.getName().toUpperCase() === item.name);
|
|
199
204
|
if (parameter === undefined) {
|
|
@@ -204,7 +209,7 @@ class MethodParameters {
|
|
|
204
209
|
else if ((0, _check_text_symbol_1.checkTextSymbol)(item.source, parameter.getType(), input)) {
|
|
205
210
|
return;
|
|
206
211
|
}
|
|
207
|
-
else if (
|
|
212
|
+
else if (assignable(item.sourceType, parameter.getType(), item.source) === false) {
|
|
208
213
|
const message = "Method parameter type not compatible, " + item.name;
|
|
209
214
|
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
210
215
|
return;
|
|
@@ -5,7 +5,7 @@ const basic_1 = require("../abap/types/basic");
|
|
|
5
5
|
const ddic_1 = require("../ddic");
|
|
6
6
|
class CDSDetermineTypes {
|
|
7
7
|
parseType(reg, parsedData, ddlsName) {
|
|
8
|
-
var _a;
|
|
8
|
+
var _a, _b;
|
|
9
9
|
const ddic = new ddic_1.DDIC(reg);
|
|
10
10
|
if ((parsedData === null || parsedData === void 0 ? void 0 : parsedData.fields.length) === 0) {
|
|
11
11
|
return basic_1.VoidType.get("DDLS:todo");
|
|
@@ -84,13 +84,29 @@ class CDSDetermineTypes {
|
|
|
84
84
|
else {
|
|
85
85
|
components.push({
|
|
86
86
|
name: f.name,
|
|
87
|
-
type: basic_1.VoidType.get("DDLS:fieldname:" + ddlsName),
|
|
87
|
+
type: (_b = this.findInSources(ddic, parsedData, f.nameInSource)) !== null && _b !== void 0 ? _b : basic_1.VoidType.get("DDLS:fieldname:" + ddlsName),
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
return new basic_1.StructureType(components, parsedData.definitionName, parsedData.definitionName, parsedData.description);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
+
/** unprefixed field, take the type from the first source containing it, void or unknown sources are skipped */
|
|
95
|
+
findInSources(ddic, parsedData, nameInSource) {
|
|
96
|
+
if (nameInSource === undefined) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
for (const source of parsedData.sources) {
|
|
100
|
+
const lookup = ddic.lookupTableOrView(source.name);
|
|
101
|
+
if (lookup.type instanceof basic_1.StructureType) {
|
|
102
|
+
const type = lookup.type.getComponentByName(nameInSource);
|
|
103
|
+
if (type) {
|
|
104
|
+
return type;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
94
110
|
}
|
|
95
111
|
exports.CDSDetermineTypes = CDSDetermineTypes;
|
|
96
112
|
//# sourceMappingURL=cds_determine_types.js.map
|
|
@@ -150,12 +150,16 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
150
150
|
let found = (_a = e.findDirectExpression(expressions_1.CDSAs)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(expressions_1.CDSName);
|
|
151
151
|
const list = (_b = e.findDirectExpression(expressions_1.CDSPrefixedName)) === null || _b === void 0 ? void 0 : _b.findAllExpressions(expressions_1.CDSName);
|
|
152
152
|
if (list !== undefined) {
|
|
153
|
-
const redirected =
|
|
153
|
+
const redirected = e.concatTokens().toUpperCase().includes(" REDIRECTED TO ");
|
|
154
154
|
if (list.length > 1 && redirected === false) {
|
|
155
155
|
// "prefix.field" is looked up as "field" in "prefix", also when aliased via "as"
|
|
156
156
|
prefix = list[0].concatTokens();
|
|
157
157
|
nameInSource = list[list.length - 1].concatTokens();
|
|
158
158
|
}
|
|
159
|
+
else if (list.length === 1 && redirected === false) {
|
|
160
|
+
// unprefixed "field" is looked up in the sources, also when aliased via "as"
|
|
161
|
+
nameInSource = list[0].concatTokens();
|
|
162
|
+
}
|
|
159
163
|
if (found === undefined) {
|
|
160
164
|
found = redirected === true ? list[0] : list[list.length - 1];
|
|
161
165
|
}
|
package/build/src/registry.js
CHANGED
|
@@ -94,7 +94,7 @@ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
|
|
|
94
94
|
continue;
|
|
95
95
|
}
|
|
96
96
|
const operands = this.flattenChain(source);
|
|
97
|
-
if (!operands.some(op =>
|
|
97
|
+
if (!operands.some(op => this.isLiteral(op))) {
|
|
98
98
|
continue;
|
|
99
99
|
}
|
|
100
100
|
const template = this.buildTemplate(operands);
|
|
@@ -119,10 +119,11 @@ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
|
|
|
119
119
|
buildTemplate(operands) {
|
|
120
120
|
let inner = "";
|
|
121
121
|
for (const op of operands) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
if (this.isLiteral(op)) {
|
|
123
|
+
const raw = op.getFirstToken().getStr();
|
|
124
|
+
const delimiter = raw[0];
|
|
125
|
+
const value = raw.slice(1, -1).split(delimiter + delimiter).join(delimiter);
|
|
126
|
+
inner += value.replace(/[\\|{}]/g, "\\$&");
|
|
126
127
|
}
|
|
127
128
|
else {
|
|
128
129
|
inner += `{ ${op.concatTokens()} }`;
|
|
@@ -130,6 +131,14 @@ class PreferStringTemplate extends _abap_rule_1.ABAPRule {
|
|
|
130
131
|
}
|
|
131
132
|
return `|${inner}|`;
|
|
132
133
|
}
|
|
134
|
+
// plain character or string literal, ie. not text symbols or concatenated constants
|
|
135
|
+
isLiteral(op) {
|
|
136
|
+
if (op.getFirstToken() !== op.getLastToken()) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
const firstChar = op.getFirstToken().getStr()[0];
|
|
140
|
+
return firstChar === "'" || firstChar === "`";
|
|
141
|
+
}
|
|
133
142
|
}
|
|
134
143
|
exports.PreferStringTemplate = PreferStringTemplate;
|
|
135
144
|
//# sourceMappingURL=prefer_string_template.js.map
|