@abaplint/core 2.120.59 → 2.120.61
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 +2 -0
- package/build/src/abap/2_statements/expressions/method_def_exceptions.js +3 -1
- package/build/src/abap/2_statements/expressions/method_def_raising.js +3 -1
- package/build/src/abap/2_statements/statements/method_def.js +1 -1
- package/build/src/abap/2_statements/statements/method_implementation.js +2 -1
- package/build/src/abap/5_syntax/_builtin.js +12 -0
- package/build/src/abap/5_syntax/statements/case.js +37 -0
- package/build/src/abap/5_syntax/statements/create_data.js +13 -1
- package/build/src/abap/5_syntax/statements/create_object.js +5 -0
- package/build/src/abap/5_syntax/statements/when.js +4 -0
- package/build/src/registry.js +1 -1
- package/build/src/rules/abapdoc.js +4 -3
- package/package.json +1 -1
package/build/abaplint.d.ts
CHANGED
|
@@ -643,6 +643,8 @@ export declare class BuiltIn {
|
|
|
643
643
|
private row;
|
|
644
644
|
private static buildDefinition;
|
|
645
645
|
static searchBuiltin(name: string | undefined): IMethodDefinition | undefined;
|
|
646
|
+
private static readonly unnamedArgument;
|
|
647
|
+
static hasUnnamedArgument(name: string | undefined): boolean;
|
|
646
648
|
static isPredicate(name: string | undefined): boolean | undefined;
|
|
647
649
|
getTypes(): TypedIdentifier[];
|
|
648
650
|
get(extras: string[]): TypedIdentifier[];
|
|
@@ -5,7 +5,9 @@ const combi_1 = require("../combi");
|
|
|
5
5
|
const _1 = require(".");
|
|
6
6
|
class MethodDefExceptions extends combi_1.Expression {
|
|
7
7
|
getRunnable() {
|
|
8
|
-
|
|
8
|
+
// parameter section keywords cannot be exception names
|
|
9
|
+
const name = (0, combi_1.seq)((0, combi_1.stopBefore1)("IMPORTING", "EXPORTING", "CHANGING", "RETURNING", "RAISING", "EXCEPTIONS"), _1.NamespaceSimpleName);
|
|
10
|
+
const exceptions = (0, combi_1.seq)("EXCEPTIONS", (0, combi_1.plusPrio)(name));
|
|
9
11
|
return exceptions;
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -7,7 +7,9 @@ const class_name_1 = require("./class_name");
|
|
|
7
7
|
class MethodDefRaising extends combi_1.Expression {
|
|
8
8
|
getRunnable() {
|
|
9
9
|
const resumable = (0, combi_1.seq)("RESUMABLE", (0, combi_1.tok)(tokens_1.ParenLeft), class_name_1.ClassName, (0, combi_1.tok)(tokens_1.ParenRightW));
|
|
10
|
-
|
|
10
|
+
// parameter section keywords cannot be exception names
|
|
11
|
+
const name = (0, combi_1.seq)((0, combi_1.stopBefore1)("IMPORTING", "EXPORTING", "CHANGING", "RETURNING", "RAISING", "EXCEPTIONS"), class_name_1.ClassName);
|
|
12
|
+
const raising = (0, combi_1.seq)("RAISING", (0, combi_1.plus)((0, combi_1.altPrio)(resumable, name)));
|
|
11
13
|
return raising;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
@@ -26,7 +26,7 @@ class MethodDef {
|
|
|
26
26
|
(0, combi_1.seq)("VALIDATE ON SAVE IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("MODIFY", (0, combi_1.opt)("IMPORTING"), (0, combi_1.plus)((0, combi_1.seq)(expressions_1.MethodParamName, modify))), (0, combi_1.seq)("PRECHECK IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("DETERMINATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("VALIDATION", expressions_1.TypeName, "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("NUMBERING IMPORTING", expressions_1.MethodParamName, modify), (0, combi_1.seq)("READ IMPORTING", expressions_1.MethodParamName, (0, combi_1.altPrio)(forRead, forfunction)), (0, combi_1.seq)("FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.NamespaceSimpleName, "FOR", expressions_1.NamespaceSimpleName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR CREATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName, expressions_1.MethodParamName, "FOR DELETE", expressions_1.TypeName), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR READ", expressions_1.TypeName, result), (0, combi_1.seq)("BEHAVIOR IMPORTING", expressions_1.MethodParamName, "FOR UPDATE", expressions_1.TypeName), (0, combi_1.seq)((0, combi_1.alt)("BEHAVIOR", "LOCK"), "IMPORTING", expressions_1.MethodParamName, "FOR LOCK", expressions_1.TypeName), (0, combi_1.seq)("DETERMINE", (0, combi_1.alt)("ON MODIFY", "ON SAVE"), "IMPORTING", expressions_1.MethodParamName, "FOR", expressions_1.TypeName), (0, combi_1.seq)("GLOBAL AUTHORIZATION IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("GLOBAL FEATURES IMPORTING REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)((0, combi_1.seq)((0, combi_1.opt)("INSTANCE"), "AUTHORIZATION IMPORTING"), expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result), (0, combi_1.seq)("INSTANCE FEATURES IMPORTING", expressions_1.MethodParamName, "REQUEST", expressions_1.MethodParamName, "FOR", expressions_1.TypeName, result));
|
|
27
27
|
// todo, this is only from version something
|
|
28
28
|
// AMDP OPTIONS clause blocked in KeyUser
|
|
29
|
-
const amdp = (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("AMDP OPTIONS", (0, combi_1.
|
|
29
|
+
const amdp = (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("AMDP OPTIONS", (0, combi_1.per)("READ-ONLY", (0, combi_1.seq)("CDS SESSION CLIENT", (0, combi_1.alt)("CURRENT", "DEPENDENT"))), (0, combi_1.optPrio)(expressions_1.MethodDefImporting), (0, combi_1.optPrio)(expressions_1.MethodDefExporting), (0, combi_1.optPrio)(expressions_1.MethodDefRaising)));
|
|
30
30
|
// FOR DDL OBJECT / FOR TABLE FUNCTION / FOR SCALAR FUNCTION blocked in KeyUser
|
|
31
31
|
const regular = (0, combi_1.seq)((0, combi_1.altPrio)("CLASS-METHODS", "METHODS"), expressions_1.MethodName, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.optPrio)(expressions_1.Abstract), (0, combi_1.optPrio)(def), expressions_1.EventHandler), parameters, testing, (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("FOR", behavior)), amdp, "NOT AT END OF MODE", (0, combi_1.optPrio)(expressions_1.Redefinition)));
|
|
32
32
|
// RAP event handlers are instance methods; CLASS-METHODS is not allowed.
|
|
@@ -9,7 +9,8 @@ class MethodImplementation {
|
|
|
9
9
|
const name = (0, combi_1.regex)(/[\w~]+/);
|
|
10
10
|
const kernel = (0, combi_1.seq)("KERNEL MODULE", (0, combi_1.plus)(name), (0, combi_1.optPrio)((0, combi_1.altPrio)("FAIL", "IGNORE")));
|
|
11
11
|
const using = (0, combi_1.seq)("USING", (0, combi_1.plus)(expressions_1.SimpleFieldChain));
|
|
12
|
-
const
|
|
12
|
+
const options = (0, combi_1.seq)("OPTIONS", (0, combi_1.per)("READ-ONLY", "SUPPRESS SYNTAX ERRORS", "DETERMINISTIC"));
|
|
13
|
+
const database = (0, combi_1.seq)("DATABASE", (0, combi_1.alt)("PROCEDURE", "FUNCTION", "GRAPH WORKSPACE"), "FOR HDB", expressions_1.Language, (0, combi_1.opt)(options), (0, combi_1.opt)(using));
|
|
13
14
|
// BY DATABASE and BY KERNEL both blocked in KeyUser
|
|
14
15
|
const by = (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("BY", (0, combi_1.alt)(kernel, database)));
|
|
15
16
|
return (0, combi_1.seq)("METHOD", expressions_1.MethodName, (0, combi_1.optPrio)(by));
|
|
@@ -118,6 +118,12 @@ class BuiltIn {
|
|
|
118
118
|
}
|
|
119
119
|
return this.buildDefinition(def, name);
|
|
120
120
|
}
|
|
121
|
+
static hasUnnamedArgument(name) {
|
|
122
|
+
if (name === undefined) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return BuiltIn.unnamedArgument.has(name.toUpperCase());
|
|
126
|
+
}
|
|
121
127
|
static isPredicate(name) {
|
|
122
128
|
if (name === undefined) {
|
|
123
129
|
return undefined;
|
|
@@ -1219,4 +1225,10 @@ BuiltIn.methods = {
|
|
|
1219
1225
|
return: basic_1.IntegerType.get(),
|
|
1220
1226
|
},
|
|
1221
1227
|
};
|
|
1228
|
+
// functions called with exactly one unnamed argument, all others take named arguments like "val"
|
|
1229
|
+
BuiltIn.unnamedArgument = new Set([
|
|
1230
|
+
"ABS", "ACOS", "ASIN", "ATAN", "BOOLC", "CEIL", "CHARLEN", "COS", "COSH", "DBMAXLEN", "EXP", "FLOOR",
|
|
1231
|
+
"FRAC", "LINES", "LOG", "LOG10", "NUMOFCHAR", "SIGN", "SIN", "SINH", "SQRT", "STRLEN", "TAN", "TANH",
|
|
1232
|
+
"TRUNC", "XSTRLEN"
|
|
1233
|
+
]);
|
|
1222
1234
|
//# sourceMappingURL=_builtin.js.map
|
|
@@ -34,15 +34,52 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Case = void 0;
|
|
37
|
+
exports.checkCaseOperand = checkCaseOperand;
|
|
37
38
|
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
38
39
|
const source_1 = require("../expressions/source");
|
|
40
|
+
const _syntax_input_1 = require("../_syntax_input");
|
|
41
|
+
const _builtin_1 = require("../_builtin");
|
|
42
|
+
const _object_oriented_1 = require("../_object_oriented");
|
|
43
|
+
const basic_1 = require("../../types/basic");
|
|
44
|
+
const version_1 = require("../../../version");
|
|
39
45
|
class Case {
|
|
40
46
|
runSyntax(node, input) {
|
|
41
47
|
// just recurse
|
|
42
48
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
43
49
|
source_1.Source.runSyntax(s, input);
|
|
50
|
+
checkCaseOperand(s, input);
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
exports.Case = Case;
|
|
55
|
+
// Before 7.40 SP02 the operands of CASE and WHEN are enhanced functional operand positions: besides
|
|
56
|
+
// data objects and functional methods, only built-in functions with exactly one unnamed argument are allowed
|
|
57
|
+
function checkCaseOperand(source, input) {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
if ((0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v740sp02)
|
|
60
|
+
|| input.scope.getLanguageVersion() === version_1.LanguageVersion.Cloud
|
|
61
|
+
|| input.scope.getOpenABAP()) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const chain = source.findDirectExpression(Expressions.MethodCallChain);
|
|
65
|
+
if (chain === undefined || source.getChildren().length !== 1 || chain.getChildren().length !== 1) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const call = chain.findDirectExpression(Expressions.MethodCall);
|
|
69
|
+
const nameToken = (_a = call === null || call === void 0 ? void 0 : call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
70
|
+
const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr();
|
|
71
|
+
if (nameToken === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined || _builtin_1.BuiltIn.hasUnnamedArgument(name)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// a method of the enclosing class takes precedence over the built-in function
|
|
75
|
+
const meType = (_b = input.scope.findVariable("me")) === null || _b === void 0 ? void 0 : _b.getType();
|
|
76
|
+
if (meType instanceof basic_1.ObjectReferenceType) {
|
|
77
|
+
const def = input.scope.findObjectDefinition(meType.getIdentifierName());
|
|
78
|
+
if (new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(def, name).method !== undefined) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const message = "Built-in function " + name + " not allowed as CASE/WHEN operand before v740sp02";
|
|
83
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, nameToken, message));
|
|
84
|
+
}
|
|
48
85
|
//# sourceMappingURL=case.js.map
|
|
@@ -42,10 +42,22 @@ const basic_types_1 = require("../basic_types");
|
|
|
42
42
|
const basic_1 = require("../../types/basic");
|
|
43
43
|
const _typed_identifier_1 = require("../../types/_typed_identifier");
|
|
44
44
|
const _reference_1 = require("../_reference");
|
|
45
|
+
const _syntax_input_1 = require("../_syntax_input");
|
|
45
46
|
class CreateData {
|
|
46
47
|
runSyntax(node, input) {
|
|
48
|
+
const likeLineOf = node.concatTokens().toUpperCase().includes(" LIKE LINE OF ");
|
|
47
49
|
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
48
|
-
source_1.Source.runSyntax(s, input);
|
|
50
|
+
const sourceType = source_1.Source.runSyntax(s, input);
|
|
51
|
+
if (likeLineOf === true
|
|
52
|
+
&& sourceType !== undefined
|
|
53
|
+
&& !(sourceType instanceof basic_1.TableType)
|
|
54
|
+
&& !(sourceType instanceof basic_1.VoidType)
|
|
55
|
+
&& !(sourceType instanceof basic_1.UnknownType)
|
|
56
|
+
&& !(sourceType instanceof basic_1.AnyType)) {
|
|
57
|
+
const message = `"${s.concatTokens()}" is not an internal table`;
|
|
58
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
49
61
|
}
|
|
50
62
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
51
63
|
target_1.Target.runSyntax(t, input);
|
|
@@ -141,6 +141,11 @@ class CreateObject {
|
|
|
141
141
|
ooName = found.getVoided();
|
|
142
142
|
}
|
|
143
143
|
input.scope.addReference(t === null || t === void 0 ? void 0 : t.getFirstToken(), cdef, _reference_1.ReferenceType.ConstructorReference, input.filename, { ooName: ooName });
|
|
144
|
+
if (type && type.get() instanceof Expressions.Dynamic) {
|
|
145
|
+
// the class is only known at runtime, cdef is the static type of the target
|
|
146
|
+
this.validateParameters(undefined, node, input);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
144
149
|
if (cdef !== undefined) {
|
|
145
150
|
const err = CreateObject.checkInstantiationAllowed(cdef, input);
|
|
146
151
|
if (err) {
|
|
@@ -36,11 +36,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.When = void 0;
|
|
37
37
|
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
38
38
|
const source_1 = require("../expressions/source");
|
|
39
|
+
const case_1 = require("./case");
|
|
39
40
|
class When {
|
|
40
41
|
runSyntax(node, input) {
|
|
41
42
|
for (const s of node.findAllExpressions(Expressions.Source)) {
|
|
42
43
|
source_1.Source.runSyntax(s, input);
|
|
43
44
|
}
|
|
45
|
+
for (const s of node.findDirectExpressions(Expressions.Source)) {
|
|
46
|
+
(0, case_1.checkCaseOperand)(s, input);
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
exports.When = When;
|
package/build/src/registry.js
CHANGED
|
@@ -110,12 +110,13 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#abap-doc-on
|
|
|
110
110
|
return issues;
|
|
111
111
|
}
|
|
112
112
|
getAbapdoc(rows, pos) {
|
|
113
|
+
var _a, _b, _c;
|
|
113
114
|
let previousRow = pos.getRow() - 2;
|
|
114
|
-
let rowText = rows[previousRow].trim().toUpperCase();
|
|
115
|
+
let rowText = ((_a = rows[previousRow]) !== null && _a !== void 0 ? _a : "").trim().toUpperCase();
|
|
115
116
|
const text = [];
|
|
116
117
|
if (rowText === "METHODS" || rowText === "CLASS-METHODS") {
|
|
117
118
|
previousRow--;
|
|
118
|
-
rowText = rows[previousRow].trim().toUpperCase();
|
|
119
|
+
rowText = ((_b = rows[previousRow]) !== null && _b !== void 0 ? _b : "").trim().toUpperCase();
|
|
119
120
|
}
|
|
120
121
|
text.push(rowText);
|
|
121
122
|
//we need to push the first row despite if it is actually an abapdoc or not
|
|
@@ -123,7 +124,7 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#abap-doc-on
|
|
|
123
124
|
if (rowText.trim().substring(0, 2) === "\"!") {
|
|
124
125
|
while (previousRow >= 0) {
|
|
125
126
|
previousRow--;
|
|
126
|
-
rowText = rows[previousRow].trim().toUpperCase();
|
|
127
|
+
rowText = ((_c = rows[previousRow]) !== null && _c !== void 0 ? _c : "").trim().toUpperCase();
|
|
127
128
|
if (rowText.trim().substring(0, 2) !== "\"!") {
|
|
128
129
|
break;
|
|
129
130
|
}
|