@abaplint/core 2.120.87 → 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 +32 -1
- package/build/src/abap/2_statements/expressions/form_param_type.js +9 -4
- 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/index.js +4 -2
- package/build/src/objects/data_definition.js +5 -1
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +73 -0
- package/build/src/rules/prefer_string_template.js +14 -5
- package/package.json +1 -1
package/build/abaplint.d.ts
CHANGED
|
@@ -42,6 +42,18 @@ export declare abstract class ABAPObject extends AbstractObject {
|
|
|
42
42
|
private findTextsTranslations;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
export declare class ABAPParser {
|
|
46
|
+
private readonly release;
|
|
47
|
+
private readonly languageVersion;
|
|
48
|
+
private readonly globalMacros;
|
|
49
|
+
private readonly reg?;
|
|
50
|
+
/** @deprecated Use `new ABAPParser(options)` instead */
|
|
51
|
+
constructor(release: ABAPRelease, globalMacros?: readonly string[], reg?: IRegistry);
|
|
52
|
+
constructor(options?: IABAPParserOptions);
|
|
53
|
+
private static isRelease;
|
|
54
|
+
parse(files: readonly IFile[]): IABAPParserResult;
|
|
55
|
+
}
|
|
56
|
+
|
|
45
57
|
declare class ABAPQueryFunctionalArea extends AbstractObject {
|
|
46
58
|
getType(): string;
|
|
47
59
|
getAllowedNaming(): {
|
|
@@ -3304,6 +3316,25 @@ declare interface IAbaplintAppSettings {
|
|
|
3304
3316
|
observations?: boolean;
|
|
3305
3317
|
}
|
|
3306
3318
|
|
|
3319
|
+
export declare interface IABAPParserOptions {
|
|
3320
|
+
release?: ABAPRelease;
|
|
3321
|
+
languageVersion?: LanguageVersion;
|
|
3322
|
+
globalMacros?: readonly string[];
|
|
3323
|
+
reg?: IRegistry;
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3326
|
+
export declare interface IABAPParserResult {
|
|
3327
|
+
issues: readonly Issue[];
|
|
3328
|
+
output: readonly ABAPFile[];
|
|
3329
|
+
/** runtime in milliseconds */
|
|
3330
|
+
runtime: number;
|
|
3331
|
+
runtimeExtra: {
|
|
3332
|
+
lexing: number;
|
|
3333
|
+
statements: number;
|
|
3334
|
+
structure: number;
|
|
3335
|
+
};
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3307
3338
|
declare class IACBinaryData extends AbstractObject {
|
|
3308
3339
|
getType(): string;
|
|
3309
3340
|
getAllowedNaming(): {
|
|
@@ -5577,7 +5608,7 @@ declare type ParsedDataDefinition = {
|
|
|
5577
5608
|
sqlViewName: string | undefined;
|
|
5578
5609
|
definitionName: string | undefined;
|
|
5579
5610
|
description: string | undefined;
|
|
5580
|
-
/** 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" */
|
|
5581
5612
|
fields: {
|
|
5582
5613
|
key: boolean;
|
|
5583
5614
|
name: string;
|
|
@@ -8,10 +8,15 @@ class FormParamType extends combi_1.Expression {
|
|
|
8
8
|
getRunnable() {
|
|
9
9
|
const def = (0, combi_1.seq)("DEFAULT", (0, combi_1.alt)(_1.Constant, _1.FieldChain));
|
|
10
10
|
const table = (0, combi_1.seq)((0, combi_1.alt)("STANDARD", "HASHED", "INDEX", "SORTED", "ANY"), "TABLE");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
11
|
+
// the following are not valid FORM typings, fail instead of reading the
|
|
12
|
+
// remaining words as additional parameters
|
|
13
|
+
const inline = (0, combi_1.seq)((0, combi_1.alt)("TABLE", "RANGE"), "OF", (0, combi_1.failCombinator)());
|
|
14
|
+
const tableKey = (0, combi_1.seq)("WITH", (0, combi_1.failCombinator)());
|
|
15
|
+
const lengthDecimals = (0, combi_1.seq)((0, combi_1.alt)("LENGTH", "DECIMALS"), _1.Integer, (0, combi_1.failCombinator)());
|
|
16
|
+
const tabseq = (0, combi_1.seq)(table, (0, combi_1.optPrio)((0, combi_1.seq)("OF", (0, combi_1.altPrio)((0, combi_1.seq)("REF TO", (0, combi_1.failCombinator)()), _1.TypeName))), (0, combi_1.optPrio)(tableKey));
|
|
17
|
+
const ret = (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.alt)("REF TO", "LINE OF")), _1.TypeName, (0, combi_1.optPrio)(lengthDecimals), (0, combi_1.opt)(def));
|
|
18
|
+
const like = (0, combi_1.seq)("LIKE", (0, combi_1.altPrio)(inline, (0, combi_1.seq)(table, (0, combi_1.failCombinator)()), (0, combi_1.seq)((0, combi_1.optPrio)((0, combi_1.alt)("REF TO", "LINE OF")), _1.FieldChain)));
|
|
19
|
+
return (0, combi_1.alt)((0, combi_1.seq)("TYPE", (0, combi_1.altPrio)(tabseq, (0, combi_1.ver)(version_1.Release.v916, (0, combi_1.seq)("ANY", "STRUCTURE")), inline, ret)), like);
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
22
|
exports.FormParamType = FormParamType;
|
|
@@ -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
|
package/build/src/index.js
CHANGED
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
37
|
-
exports.LSPEdit = exports.RuleTag = exports.Severity = exports.Visibility = exports.Info = exports.Diagnostics = exports.Rename = exports.PrettyPrinter = exports.Position = exports.CurrentScope = exports.RulesRunner = exports.SpaghettiScope = exports.SyntaxLogic = void 0;
|
|
36
|
+
exports.Tokens = exports.ABAPParser = exports.ExpressionsCDS = exports.CDSParser = exports.LanguageServerTypes = exports.DDLKind = exports.DDLParser = exports.AbstractFile = exports.ABAPFile = exports.MemoryFile = exports.Edits = exports.ReferenceType = exports.NativeSQL = exports.MacroContent = exports.MacroCall = exports.SpaghettiScopeNode = exports.Token = exports.ScopeType = exports.BasicTypes = exports.TypedIdentifier = exports.AbstractType = exports.VirtualPosition = exports.Comment = exports.Unknown = exports.Empty = exports.Identifier = exports.Nodes = exports.Types = exports.Expressions = exports.Statements = exports.Structures = exports.SkipLogic = exports.Objects = exports.ArtifactsRules = exports.ArtifactsObjects = exports.ArtifactsABAP = exports.BuiltIn = exports.FormLengthStats = exports.FunctionLengthStats = exports.MethodLengthStats = exports.LanguageServer = exports.Registry = exports.CyclomaticComplexityStats = exports.versionToABAPRelease = exports.releaseAtLeast = exports.Release = exports.LanguageVersion = exports.Version = exports.Config = exports.Issue = void 0;
|
|
37
|
+
exports.LSPEdit = exports.RuleTag = exports.Severity = exports.Visibility = exports.Info = exports.Diagnostics = exports.Rename = exports.PrettyPrinter = exports.Position = exports.CurrentScope = exports.RulesRunner = exports.SpaghettiScope = exports.SyntaxLogic = exports.ABAPObject = void 0;
|
|
38
38
|
const issue_1 = require("./issue");
|
|
39
39
|
Object.defineProperty(exports, "Issue", { enumerable: true, get: function () { return issue_1.Issue; } });
|
|
40
40
|
const config_1 = require("./config");
|
|
@@ -131,6 +131,8 @@ Object.defineProperty(exports, "DDLParser", { enumerable: true, get: function ()
|
|
|
131
131
|
Object.defineProperty(exports, "DDLKind", { enumerable: true, get: function () { return ddl_parser_1.DDLKind; } });
|
|
132
132
|
const cds_parser_1 = require("./cds/cds_parser");
|
|
133
133
|
Object.defineProperty(exports, "CDSParser", { enumerable: true, get: function () { return cds_parser_1.CDSParser; } });
|
|
134
|
+
const abap_parser_1 = require("./abap/abap_parser");
|
|
135
|
+
Object.defineProperty(exports, "ABAPParser", { enumerable: true, get: function () { return abap_parser_1.ABAPParser; } });
|
|
134
136
|
const rules_runner_1 = require("./rules_runner");
|
|
135
137
|
Object.defineProperty(exports, "RulesRunner", { enumerable: true, get: function () { return rules_runner_1.RulesRunner; } });
|
|
136
138
|
const _irule_1 = require("./rules/_irule");
|
|
@@ -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
|
@@ -331,6 +331,18 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
+
// a chained call with EXPORTING/IMPORTING/CHANGING/RECEIVING/EXCEPTIONS parses in the low
|
|
335
|
+
// version, but 702 reads the last call of a chain as a functional call,
|
|
336
|
+
// "Unexpected word CHANGING in functional method call"
|
|
337
|
+
if (ret.length === 0) {
|
|
338
|
+
for (let i = 0; i < lowStatements.length; i++) {
|
|
339
|
+
const issue = this.outlineChainedCallParameters(lowStatements[i], highStatements[i], lowFile, highSyntax);
|
|
340
|
+
if (issue) {
|
|
341
|
+
ret.push(issue);
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
334
346
|
// INSERT with a 702 built-in function as the operand parses in the low version, but 702
|
|
335
347
|
// reads the function as a method call, "Method SUBSTRING does not exist"
|
|
336
348
|
if (ret.length === 0) {
|
|
@@ -2912,6 +2924,67 @@ ${indentation} output = ${uniqueName}.\n`;
|
|
|
2912
2924
|
}
|
|
2913
2925
|
return undefined;
|
|
2914
2926
|
}
|
|
2927
|
+
/** a( )->b( CHANGING c = d ), the object the last method is called on is outlined into a
|
|
2928
|
+
* variable typed via the RETURNING parameter of the method before it */
|
|
2929
|
+
outlineChainedCallParameters(low, high, lowFile, highSyntax) {
|
|
2930
|
+
var _a, _b, _c, _d;
|
|
2931
|
+
if (!(high.get() instanceof Statements.Call)) {
|
|
2932
|
+
return undefined;
|
|
2933
|
+
}
|
|
2934
|
+
else if (this.lowReg.getConfig().isOpenABAP()) {
|
|
2935
|
+
return undefined;
|
|
2936
|
+
}
|
|
2937
|
+
else if (low.getFirstToken().getStart() instanceof virtual_position_1.VirtualPosition) {
|
|
2938
|
+
return undefined;
|
|
2939
|
+
}
|
|
2940
|
+
const chain = high.findDirectExpression(Expressions.MethodCallChain);
|
|
2941
|
+
const children = (chain === null || chain === void 0 ? void 0 : chain.getChildren()) || [];
|
|
2942
|
+
const last = children[children.length - 1];
|
|
2943
|
+
const arrow = children[children.length - 2];
|
|
2944
|
+
const previous = children[children.length - 3];
|
|
2945
|
+
if (chain === undefined
|
|
2946
|
+
|| !(last instanceof nodes_1.ExpressionNode)
|
|
2947
|
+
|| !(last.get() instanceof Expressions.MethodCall)
|
|
2948
|
+
|| (arrow === null || arrow === void 0 ? void 0 : arrow.getFirstToken().getStr()) !== "->"
|
|
2949
|
+
|| !(previous instanceof nodes_1.ExpressionNode)
|
|
2950
|
+
|| !(previous.get() instanceof Expressions.MethodCall)) {
|
|
2951
|
+
return undefined;
|
|
2952
|
+
}
|
|
2953
|
+
const parameters = (_a = last.findDirectExpression(Expressions.MethodCallParam)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.MethodParameters);
|
|
2954
|
+
if (parameters === undefined) {
|
|
2955
|
+
return undefined;
|
|
2956
|
+
}
|
|
2957
|
+
// the type of the object, from the method that returns it
|
|
2958
|
+
const methodToken = (_b = previous.findDirectExpression(Expressions.MethodName)) === null || _b === void 0 ? void 0 : _b.getFirstToken();
|
|
2959
|
+
if (methodToken === undefined) {
|
|
2960
|
+
return undefined;
|
|
2961
|
+
}
|
|
2962
|
+
const spag = highSyntax.spaghetti.lookupPosition(methodToken.getStart(), lowFile.getFilename());
|
|
2963
|
+
let type = undefined;
|
|
2964
|
+
for (const r of (spag === null || spag === void 0 ? void 0 : spag.getData().references) || []) {
|
|
2965
|
+
if (r.referenceType === _reference_1.ReferenceType.MethodReference
|
|
2966
|
+
&& r.position.getStart().equals(methodToken.getStart())) {
|
|
2967
|
+
const returning = (_d = (_c = r.resolved) === null || _c === void 0 ? void 0 : _c.getParameters().getReturning()) === null || _d === void 0 ? void 0 : _d.getType();
|
|
2968
|
+
if (returning instanceof basic_1.ObjectReferenceType) {
|
|
2969
|
+
type = returning.toABAP();
|
|
2970
|
+
}
|
|
2971
|
+
break;
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
if (type === undefined) {
|
|
2975
|
+
return undefined;
|
|
2976
|
+
}
|
|
2977
|
+
const object = children.slice(0, children.length - 2).map(c => c.concatTokens()).join("");
|
|
2978
|
+
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
2979
|
+
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
2980
|
+
const code = `DATA ${uniqueName} TYPE ${type}.\n` +
|
|
2981
|
+
indentation + `${uniqueName} = ${object}.\n` +
|
|
2982
|
+
indentation;
|
|
2983
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), code);
|
|
2984
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, chain.getFirstToken().getStart(), previous.getLastToken().getEnd(), uniqueName);
|
|
2985
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
2986
|
+
return issue_1.Issue.atToken(lowFile, chain.getFirstToken(), "Outline object of chained call with parameter keywords", this.getMetadata().key, this.conf.severity, fix);
|
|
2987
|
+
}
|
|
2915
2988
|
/** if the source expression is the complete source of an INSERT or APPEND statement, then the
|
|
2916
2989
|
* outlined variable must be typed via the row type of the table, returns the table name */
|
|
2917
2990
|
findRowTypeOf(high, source) {
|
|
@@ -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
|