@abaplint/core 2.120.100 → 2.120.101
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/_raise_message.js +151 -0
- package/build/src/abap/5_syntax/expressions/_substring.js +31 -0
- package/build/src/abap/5_syntax/expressions/cond_body.js +4 -0
- package/build/src/abap/5_syntax/expressions/source.js +22 -3
- package/build/src/abap/5_syntax/expressions/switch_body.js +4 -0
- package/build/src/abap/5_syntax/statements/raise.js +2 -0
- package/build/src/abap/5_syntax/structures/try.js +91 -0
- package/build/src/abap/5_syntax/syntax.js +4 -0
- package/build/src/registry.js +1 -1
- package/build/src/rules/fully_type_constants.js +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.RaiseMessage = void 0;
|
|
37
|
+
const Expressions = __importStar(require("../2_statements/expressions"));
|
|
38
|
+
const nodes_1 = require("../nodes");
|
|
39
|
+
const _syntax_input_1 = require("./_syntax_input");
|
|
40
|
+
const T100_INTERFACES = new Set(["IF_T100_MESSAGE", "IF_T100_DYN_MSG"]);
|
|
41
|
+
// the root exception classes, they implement IF_MESSAGE and IF_SERIALIZABLE_OBJECT, but not the T100 interfaces
|
|
42
|
+
const ROOT_EXCEPTIONS = new Set(["CX_ROOT", "CX_STATIC_CHECK", "CX_DYNAMIC_CHECK", "CX_NO_CHECK"]);
|
|
43
|
+
/** RAISE EXCEPTION TYPE cx MESSAGE ... and THROW cx( MESSAGE ... ) require the exception class to implement
|
|
44
|
+
* IF_T100_MESSAGE or IF_T100_DYN_MSG, and with RAISE EXCEPTION the constructor parameter TEXTID cannot be
|
|
45
|
+
* passed in addition to MESSAGE, see the ABAP keyword documentation for RAISE EXCEPTION, MESSAGE.
|
|
46
|
+
* The interface check only reports when the full class hierarchy is known, void classes and void interfaces
|
|
47
|
+
* in the hierarchy are skipped, except for the root exception classes. */
|
|
48
|
+
class RaiseMessage {
|
|
49
|
+
static checkRaise(node, input) {
|
|
50
|
+
var _a, _b, _c;
|
|
51
|
+
var _d;
|
|
52
|
+
const classTok = (_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
53
|
+
if (classTok === undefined || RaiseMessage.hasMessage(node) === false) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const p of (_d = (_b = node.findDirectExpression(Expressions.ParameterListS)) === null || _b === void 0 ? void 0 : _b.findDirectExpressions(Expressions.ParameterS)) !== null && _d !== void 0 ? _d : []) {
|
|
57
|
+
const name = (_c = p.findDirectExpression(Expressions.ParameterName)) === null || _c === void 0 ? void 0 : _c.getFirstToken();
|
|
58
|
+
if ((name === null || name === void 0 ? void 0 : name.getStr().toUpperCase()) === "TEXTID") {
|
|
59
|
+
const message = "RAISE EXCEPTION with MESSAGE, TEXTID cannot be passed";
|
|
60
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, name, message));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
RaiseMessage.checkClass(classTok.getStr(), input, classTok);
|
|
65
|
+
}
|
|
66
|
+
static checkThrow(node, input) {
|
|
67
|
+
var _a;
|
|
68
|
+
const classTok = (_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
69
|
+
if (classTok === undefined || node.findDirectExpression(Expressions.MessageSource) === undefined) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
RaiseMessage.checkClass(classTok.getStr(), input, classTok);
|
|
73
|
+
}
|
|
74
|
+
/** MESSAGE msg or MESSAGE ID, but not USING MESSAGE */
|
|
75
|
+
static hasMessage(node) {
|
|
76
|
+
const children = node.getChildren();
|
|
77
|
+
for (let i = 0; i < children.length; i++) {
|
|
78
|
+
const c = children[i];
|
|
79
|
+
if (c instanceof nodes_1.TokenNode && c.getFirstToken().getStr().toUpperCase() === "MESSAGE") {
|
|
80
|
+
const previous = children[i - 1];
|
|
81
|
+
if (previous === undefined || previous.getFirstToken().getStr().toUpperCase() !== "USING") {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
static checkClass(className, input, classTok) {
|
|
89
|
+
const def = input.scope.findClassDefinition(className);
|
|
90
|
+
if (def === undefined) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (RaiseMessage.isT100(def, input.scope, new Set()) === false) {
|
|
94
|
+
const message = "Exception class " + def.getName().toUpperCase() +
|
|
95
|
+
" must implement IF_T100_MESSAGE or IF_T100_DYN_MSG to be raised with MESSAGE";
|
|
96
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, classTok, message));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** true or false when known, undefined when the hierarchy contains void parts */
|
|
100
|
+
static isT100(def, scope, visited) {
|
|
101
|
+
var _a;
|
|
102
|
+
const upper = def.getName().toUpperCase();
|
|
103
|
+
if (visited.has(upper)) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
visited.add(upper);
|
|
107
|
+
let unknown = false;
|
|
108
|
+
const interfaces = def.getImplementing().map(i => i.name.toUpperCase());
|
|
109
|
+
const seen = new Set();
|
|
110
|
+
while (interfaces.length > 0) {
|
|
111
|
+
const name = interfaces.pop();
|
|
112
|
+
if (seen.has(name)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
seen.add(name);
|
|
116
|
+
if (T100_INTERFACES.has(name)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
const idef = scope.findInterfaceDefinition(name);
|
|
120
|
+
if (idef === undefined) {
|
|
121
|
+
unknown = true;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
interfaces.push(...idef.getImplementing().map(i => i.name.toUpperCase()));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const superName = (_a = def.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
128
|
+
if (superName !== undefined) {
|
|
129
|
+
const superDef = scope.findClassDefinition(superName);
|
|
130
|
+
if (superDef !== undefined) {
|
|
131
|
+
const res = RaiseMessage.isT100(superDef, scope, visited);
|
|
132
|
+
if (res === true) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
else if (res === undefined) {
|
|
136
|
+
unknown = true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else if (ROOT_EXCEPTIONS.has(superName) === false) {
|
|
140
|
+
unknown = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else if (ROOT_EXCEPTIONS.has(upper) === false) {
|
|
144
|
+
// not an exception class, reported elsewhere or not at all
|
|
145
|
+
unknown = true;
|
|
146
|
+
}
|
|
147
|
+
return unknown ? undefined : false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.RaiseMessage = RaiseMessage;
|
|
151
|
+
//# sourceMappingURL=_raise_message.js.map
|
|
@@ -43,7 +43,14 @@ const _syntax_input_1 = require("../_syntax_input");
|
|
|
43
43
|
// a syntax error. Other types, a dynamic offset or length and "*" (undefined) are left alone, as is
|
|
44
44
|
// length 0. The offset is applied first, so the length is compared to what remains after the offset.
|
|
45
45
|
// A substring of a date, time or numeric text field has type n; its bounds are not checked.
|
|
46
|
+
// An offset or length on a numeric field (i, int8, p, f, decfloat) is a syntax error, whatever its value.
|
|
46
47
|
function substringType(context, offset, length, node, input) {
|
|
48
|
+
const numericName = numericTypeName(context);
|
|
49
|
+
if (numericName !== undefined) {
|
|
50
|
+
const message = `Offset or length specification not possible on a field of numeric type "${numericName}"`;
|
|
51
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
52
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
53
|
+
}
|
|
47
54
|
if (context instanceof basic_1.DateType || context instanceof basic_1.TimeType || context instanceof basic_1.NumericType) {
|
|
48
55
|
return numericSubstringType(context, offset, length);
|
|
49
56
|
}
|
|
@@ -69,6 +76,30 @@ function substringType(context, offset, length, node, input) {
|
|
|
69
76
|
}
|
|
70
77
|
return context;
|
|
71
78
|
}
|
|
79
|
+
function numericTypeName(context) {
|
|
80
|
+
if (context instanceof basic_1.IntegerType) {
|
|
81
|
+
return "I";
|
|
82
|
+
}
|
|
83
|
+
else if (context instanceof basic_1.Integer8Type) {
|
|
84
|
+
return "INT8";
|
|
85
|
+
}
|
|
86
|
+
else if (context instanceof basic_1.PackedType) {
|
|
87
|
+
return "P";
|
|
88
|
+
}
|
|
89
|
+
else if (context instanceof basic_1.FloatType || context instanceof basic_1.FloatingPointType) {
|
|
90
|
+
return "F";
|
|
91
|
+
}
|
|
92
|
+
else if (context instanceof basic_1.DecFloat16Type) {
|
|
93
|
+
return "DECFLOAT16";
|
|
94
|
+
}
|
|
95
|
+
else if (context instanceof basic_1.DecFloat34Type) {
|
|
96
|
+
return "DECFLOAT34";
|
|
97
|
+
}
|
|
98
|
+
else if (context instanceof basic_1.DecFloatType) {
|
|
99
|
+
return "DECFLOAT";
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
72
103
|
function numericSubstringType(context, offset, length) {
|
|
73
104
|
const hasOffset = offset !== undefined && offset > 0;
|
|
74
105
|
const hasLength = length !== undefined && length > 0;
|
|
@@ -38,6 +38,7 @@ const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
|
38
38
|
const source_1 = require("./source");
|
|
39
39
|
const let_1 = require("./let");
|
|
40
40
|
const cond_1 = require("./cond");
|
|
41
|
+
const _raise_message_1 = require("../_raise_message");
|
|
41
42
|
class CondBody {
|
|
42
43
|
static runSyntax(node, input, targetType) {
|
|
43
44
|
if (node === undefined) {
|
|
@@ -48,6 +49,9 @@ class CondBody {
|
|
|
48
49
|
if (l) {
|
|
49
50
|
scoped = let_1.Let.runSyntax(l, input);
|
|
50
51
|
}
|
|
52
|
+
for (const t of node.findDirectExpressions(Expressions.Throw)) {
|
|
53
|
+
_raise_message_1.RaiseMessage.checkThrow(t, input);
|
|
54
|
+
}
|
|
51
55
|
for (const s of node.findDirectExpressions(Expressions.Cond)) {
|
|
52
56
|
cond_1.Cond.runSyntax(s, input);
|
|
53
57
|
}
|
|
@@ -392,8 +392,9 @@ class Source {
|
|
|
392
392
|
/** The calculation type of an arithmetic expression is the most general of the
|
|
393
393
|
* operand types. An operand of type c, n, d, t or string is converted into it and
|
|
394
394
|
* never becomes the result: "lv_f * '0.25'" is a float, not a character field of
|
|
395
|
-
* length four.
|
|
396
|
-
*
|
|
395
|
+
* length four. Date and time operands count as numbers of days and seconds, type i:
|
|
396
|
+
* "lv_end - lv_start" is a number of days, not a date. Returns undefined when neither
|
|
397
|
+
* operand is numeric, leaving the decision to the caller. */
|
|
397
398
|
static calculationType(left, right) {
|
|
398
399
|
if (left === undefined || right === undefined) {
|
|
399
400
|
return undefined;
|
|
@@ -405,12 +406,27 @@ class Source {
|
|
|
405
406
|
else if (right instanceof basic_1.VoidType || right instanceof unknown_type_1.UnknownType) {
|
|
406
407
|
return right;
|
|
407
408
|
}
|
|
409
|
+
const dateOrTime = left instanceof basic_1.DateType || left instanceof basic_1.TimeType
|
|
410
|
+
|| right instanceof basic_1.DateType || right instanceof basic_1.TimeType;
|
|
411
|
+
if (left instanceof basic_1.DateType || left instanceof basic_1.TimeType) {
|
|
412
|
+
left = basic_1.IntegerType.get();
|
|
413
|
+
}
|
|
414
|
+
if (right instanceof basic_1.DateType || right instanceof basic_1.TimeType) {
|
|
415
|
+
right = basic_1.IntegerType.get();
|
|
416
|
+
}
|
|
408
417
|
const leftRank = this.numericRank(left);
|
|
409
418
|
const rightRank = this.numericRank(right);
|
|
410
419
|
if (leftRank === undefined && rightRank === undefined) {
|
|
411
420
|
return undefined;
|
|
412
421
|
}
|
|
413
|
-
|
|
422
|
+
// a character-like operand next to a date or time counts as p: "lv_date + '5'" is p
|
|
423
|
+
if (leftRank === undefined && this.isCharacterLike(left) && dateOrTime) {
|
|
424
|
+
return rightRank >= 3 ? right : new basic_1.PackedType(8, 0);
|
|
425
|
+
}
|
|
426
|
+
else if (rightRank === undefined && this.isCharacterLike(right) && dateOrTime) {
|
|
427
|
+
return leftRank >= 3 ? left : new basic_1.PackedType(8, 0);
|
|
428
|
+
}
|
|
429
|
+
if (rightRank === undefined) {
|
|
414
430
|
return left;
|
|
415
431
|
}
|
|
416
432
|
else if (leftRank === undefined) {
|
|
@@ -418,6 +434,9 @@ class Source {
|
|
|
418
434
|
}
|
|
419
435
|
return leftRank >= rightRank ? left : right;
|
|
420
436
|
}
|
|
437
|
+
static isCharacterLike(type) {
|
|
438
|
+
return type instanceof basic_1.CharacterType || type instanceof basic_1.NumericType || type instanceof basic_1.StringType;
|
|
439
|
+
}
|
|
421
440
|
static numericRank(type) {
|
|
422
441
|
if (type instanceof basic_1.DecFloat34Type) {
|
|
423
442
|
return 6;
|
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.SwitchBody = void 0;
|
|
37
37
|
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
38
38
|
const source_1 = require("./source");
|
|
39
|
+
const _raise_message_1 = require("../_raise_message");
|
|
39
40
|
const _syntax_input_1 = require("../_syntax_input");
|
|
40
41
|
const basic_1 = require("../../types/basic");
|
|
41
42
|
class SwitchBody {
|
|
@@ -43,6 +44,9 @@ class SwitchBody {
|
|
|
43
44
|
if (node === undefined) {
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
47
|
+
for (const t of node.findDirectExpressions(Expressions.Throw)) {
|
|
48
|
+
_raise_message_1.RaiseMessage.checkThrow(t, input);
|
|
49
|
+
}
|
|
46
50
|
const thenSource = node.findExpressionAfterToken("THEN");
|
|
47
51
|
if (!((thenSource === null || thenSource === void 0 ? void 0 : thenSource.get()) instanceof Expressions.Source)) {
|
|
48
52
|
const message = "SwitchBody, unexpected";
|
|
@@ -44,6 +44,7 @@ const raise_with_1 = require("../expressions/raise_with");
|
|
|
44
44
|
const _object_oriented_1 = require("../_object_oriented");
|
|
45
45
|
const method_parameters_1 = require("../expressions/method_parameters");
|
|
46
46
|
const _syntax_input_1 = require("../_syntax_input");
|
|
47
|
+
const _raise_message_1 = require("../_raise_message");
|
|
47
48
|
class Raise {
|
|
48
49
|
runSyntax(node, input) {
|
|
49
50
|
// todo
|
|
@@ -103,6 +104,7 @@ class Raise {
|
|
|
103
104
|
if (param) {
|
|
104
105
|
new method_parameters_1.MethodParameters().checkExporting(param, input, method, true);
|
|
105
106
|
}
|
|
107
|
+
_raise_message_1.RaiseMessage.checkRaise(node, input);
|
|
106
108
|
for (const s of node.findDirectExpressions(Expressions.RaiseWith)) {
|
|
107
109
|
raise_with_1.RaiseWith.runSyntax(s, input);
|
|
108
110
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Try = void 0;
|
|
37
|
+
const Expressions = __importStar(require("../../2_statements/expressions"));
|
|
38
|
+
const Statements = __importStar(require("../../2_statements/statements"));
|
|
39
|
+
const Structures = __importStar(require("../../3_structures/structures"));
|
|
40
|
+
const _syntax_input_1 = require("../_syntax_input");
|
|
41
|
+
// "special exceptions must be caught before general exceptions", a CATCH of a class that inherits
|
|
42
|
+
// from a class named in an earlier CATCH of the same TRY can never be reached, this is a syntax error
|
|
43
|
+
// only reported when the lineage of the later class is known up to the earlier class, void classes are skipped
|
|
44
|
+
class Try {
|
|
45
|
+
static runSyntax(node, input) {
|
|
46
|
+
const caught = new Set();
|
|
47
|
+
for (const catchStructure of node.findDirectStructures(Structures.Catch)) {
|
|
48
|
+
const statement = catchStructure.findDirectStatement(Statements.Catch);
|
|
49
|
+
if (statement === undefined) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const names = [];
|
|
53
|
+
for (const c of statement.findDirectExpressions(Expressions.ClassName)) {
|
|
54
|
+
const token = c.getFirstToken();
|
|
55
|
+
const className = token.getStr().toUpperCase();
|
|
56
|
+
names.push(className);
|
|
57
|
+
if (caught.size === 0) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const superclass = this.findCaughtSuperclass(className, caught, input);
|
|
61
|
+
if (superclass !== undefined) {
|
|
62
|
+
const message = `CATCH of ${className} after the CATCH of its superclass ${superclass}`;
|
|
63
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const name of names) {
|
|
68
|
+
caught.add(name);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
static findCaughtSuperclass(className, caught, input) {
|
|
73
|
+
var _a;
|
|
74
|
+
const visited = new Set([className]);
|
|
75
|
+
let current = input.scope.findClassDefinition(className);
|
|
76
|
+
while (current !== undefined) {
|
|
77
|
+
const superclass = (_a = current.getSuperClass()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
78
|
+
if (superclass === undefined || visited.has(superclass)) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
else if (caught.has(superclass)) {
|
|
82
|
+
return superclass;
|
|
83
|
+
}
|
|
84
|
+
visited.add(superclass);
|
|
85
|
+
current = input.scope.findClassDefinition(superclass);
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.Try = Try;
|
|
91
|
+
//# sourceMappingURL=try.js.map
|
|
@@ -51,6 +51,7 @@ const types_1 = require("./structures/types");
|
|
|
51
51
|
const statics_1 = require("./structures/statics");
|
|
52
52
|
const constants_1 = require("./structures/constants");
|
|
53
53
|
const cleanup_1 = require("./structures/cleanup");
|
|
54
|
+
const try_1 = require("./structures/try");
|
|
54
55
|
const class_definition_1 = require("../types/class_definition");
|
|
55
56
|
const interface_definition_1 = require("../types/interface_definition");
|
|
56
57
|
const delete_memory_1 = require("./statements/delete_memory");
|
|
@@ -536,6 +537,9 @@ class SyntaxLogic {
|
|
|
536
537
|
else if (stru instanceof Structures.Cleanup) {
|
|
537
538
|
cleanup_1.Cleanup.runSyntax(node, input);
|
|
538
539
|
}
|
|
540
|
+
else if (stru instanceof Structures.Try) {
|
|
541
|
+
try_1.Try.runSyntax(node, input);
|
|
542
|
+
}
|
|
539
543
|
return false;
|
|
540
544
|
}
|
|
541
545
|
updateScopeStatement(node) {
|
package/build/src/registry.js
CHANGED
|
@@ -79,13 +79,18 @@ class FullyTypeConstants extends _abap_rule_1.ABAPRule {
|
|
|
79
79
|
if ((stat.get() instanceof Statements.Constant
|
|
80
80
|
|| (this.conf.checkData === true && stat.get() instanceof Statements.Data))
|
|
81
81
|
&& !this.isTyped(stat)) {
|
|
82
|
+
if (stat.get() instanceof Statements.Data && stat.findDirectExpression(expressions_1.DataDefinition) === undefined) {
|
|
83
|
+
// unnamed field, eg. "DATA (10)." inside DATA BEGIN OF, cannot be typed
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
82
86
|
const type = stat.get() instanceof Statements.Constant ? "constant definition" : "data definition";
|
|
83
87
|
let token = (_a = stat.findFirstExpression(expressions_1.NamespaceSimpleName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
|
|
84
88
|
if (token === undefined) {
|
|
85
89
|
token = (_b = stat.findFirstExpression(expressions_1.DefinitionName)) === null || _b === void 0 ? void 0 : _b.getFirstToken();
|
|
86
90
|
}
|
|
87
91
|
if (token === undefined) {
|
|
88
|
-
|
|
92
|
+
const start = stat.getFirstToken().getStart();
|
|
93
|
+
throw new Error(`fully type constants: unexpected node, ${file.getFilename()}, row ${start.getRow()}, col ${start.getCol()}, statement "${stat.concatTokens()}"`);
|
|
89
94
|
}
|
|
90
95
|
issues.push(issue_1.Issue.atToken(file, token, this.getDescription(type), this.getMetadata().key, this.conf.severity));
|
|
91
96
|
}
|