@abaplint/core 2.80.8 → 2.81.1
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/README.md +6 -6
- package/build/abaplint.d.ts +8 -0
- package/build/src/abap/2_statements/expressions/sql_arithmetics.js +2 -1
- package/build/src/abap/2_statements/expressions/sql_function.js +14 -3
- package/build/src/abap/2_statements/statements/move.js +3 -2
- package/build/src/abap/5_syntax/_current_scope.js +26 -0
- package/build/src/abap/5_syntax/_scope_type.js +1 -0
- package/build/src/abap/5_syntax/basic_types.js +5 -1
- package/build/src/abap/5_syntax/expressions/field_assignment.js +12 -6
- package/build/src/abap/5_syntax/spaghetti_scope.js +13 -0
- package/build/src/abap/5_syntax/statements/class_implementation.js +4 -2
- package/build/src/abap/5_syntax/statements/method_implementation.js +7 -3
- package/build/src/abap/5_syntax/syntax.js +6 -1
- package/build/src/abap/flow/flow_graph.js +7 -7
- package/build/src/lsp/help.js +7 -7
- package/build/src/registry.js +1 -1
- package/build/src/rules/abapdoc.js +1 -1
- package/build/src/rules/align_parameters.js +33 -33
- package/build/src/rules/ambiguous_statement.js +5 -5
- package/build/src/rules/avoid_use.js +6 -6
- package/build/src/rules/begin_end_names.js +4 -4
- package/build/src/rules/begin_single_include.js +12 -12
- package/build/src/rules/call_transaction_authority_check.js +3 -3
- package/build/src/rules/chain_mainly_declarations.js +4 -4
- package/build/src/rules/check_abstract.js +2 -2
- package/build/src/rules/check_comments.js +3 -3
- package/build/src/rules/check_include.js +3 -3
- package/build/src/rules/check_no_handler_pragma.js +8 -8
- package/build/src/rules/check_subrc.js +8 -8
- package/build/src/rules/commented_code.js +1 -1
- package/build/src/rules/constructor_visibility_public.js +4 -4
- package/build/src/rules/contains_tab.js +2 -2
- package/build/src/rules/dangerous_statement.js +1 -1
- package/build/src/rules/downport.js +35 -35
- package/build/src/rules/exit_or_check.js +3 -3
- package/build/src/rules/exporting.js +1 -1
- package/build/src/rules/forbidden_identifier.js +1 -1
- package/build/src/rules/forbidden_void_type.js +2 -2
- package/build/src/rules/functional_writing.js +17 -17
- package/build/src/rules/global_class.js +10 -10
- package/build/src/rules/identical_conditions.js +2 -2
- package/build/src/rules/identical_contents.js +15 -15
- package/build/src/rules/identical_descriptions.js +4 -4
- package/build/src/rules/if_in_if.js +7 -7
- package/build/src/rules/implement_methods.js +3 -3
- package/build/src/rules/in_statement_indentation.js +11 -11
- package/build/src/rules/index.js +2 -0
- package/build/src/rules/intf_referencing_clas.js +3 -3
- package/build/src/rules/line_break_style.js +2 -2
- package/build/src/rules/line_length.js +1 -1
- package/build/src/rules/line_only_punc.js +1 -1
- package/build/src/rules/local_variable_names.js +2 -2
- package/build/src/rules/many_parentheses.js +10 -10
- package/build/src/rules/max_one_method_parameter_per_line.js +7 -7
- package/build/src/rules/max_one_statement.js +3 -3
- package/build/src/rules/nesting.js +1 -1
- package/build/src/rules/no_chained_assignment.js +52 -0
- package/build/src/rules/no_public_attributes.js +1 -1
- package/build/src/rules/no_yoda_conditions.js +4 -4
- package/build/src/rules/obsolete_statement.js +36 -36
- package/build/src/rules/omit_parameter_name.js +3 -3
- package/build/src/rules/omit_receiving.js +13 -13
- package/build/src/rules/parser_702_chaining.js +2 -2
- package/build/src/rules/parser_error.js +2 -2
- package/build/src/rules/parser_missing_space.js +1 -1
- package/build/src/rules/prefer_inline.js +19 -18
- package/build/src/rules/prefer_is_not.js +7 -7
- package/build/src/rules/prefer_raise_exception_new.js +3 -3
- package/build/src/rules/prefer_returning_to_exporting.js +1 -1
- package/build/src/rules/prefer_xsdbool.js +2 -2
- package/build/src/rules/remove_descriptions.js +4 -4
- package/build/src/rules/rfc_error_handling.js +9 -9
- package/build/src/rules/select_add_order_by.js +5 -5
- package/build/src/rules/select_performance.js +2 -2
- package/build/src/rules/sicf_consistency.js +4 -4
- package/build/src/rules/space_before_dot.js +2 -2
- package/build/src/rules/start_at_tab.js +1 -1
- package/build/src/rules/sy_modification.js +2 -2
- package/build/src/rules/tabl_enhancement_category.js +2 -2
- package/build/src/rules/unnecessary_chaining.js +58 -0
- package/build/src/rules/unreachable_code.js +4 -0
- package/build/src/rules/unused_methods.js +9 -9
- package/build/src/rules/unused_variables.js +6 -6
- package/build/src/rules/use_bool_expression.js +8 -8
- package/build/src/rules/use_line_exists.js +6 -6
- package/build/src/rules/use_new.js +2 -2
- package/build/src/rules/when_others_last.js +6 -6
- package/package.json +66 -65
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# @abaplint/core
|
|
2
|
-
|
|
3
|
-
[abaplint](https://abaplint.org/) core library
|
|
4
|
-
|
|
5
|
-
Exposes functionallity like the parser and rules, which can be used in other projects.
|
|
6
|
-
|
|
1
|
+
# @abaplint/core
|
|
2
|
+
|
|
3
|
+
[abaplint](https://abaplint.org/) core library
|
|
4
|
+
|
|
5
|
+
Exposes functionallity like the parser and rules, which can be used in other projects.
|
|
6
|
+
|
|
7
7
|
For more information see https://github.com/abaplint/abaplint
|
package/build/abaplint.d.ts
CHANGED
|
@@ -999,6 +999,8 @@ export declare class CurrentScope {
|
|
|
999
999
|
private constructor();
|
|
1000
1000
|
addType(type: TypedIdentifier | undefined): void;
|
|
1001
1001
|
addTypeNamed(name: string, type: TypedIdentifier | undefined): void;
|
|
1002
|
+
addExtraLikeType(type: TypedIdentifier | undefined): void;
|
|
1003
|
+
addExtraLikeTypeNamed(name: string, type: TypedIdentifier | undefined): void;
|
|
1002
1004
|
addClassDefinition(c: IClassDefinition): void;
|
|
1003
1005
|
addFormDefinitions(f: readonly IFormDefinition[]): void;
|
|
1004
1006
|
addInterfaceDefinition(i: IInterfaceDefinition): void;
|
|
@@ -1024,6 +1026,7 @@ export declare class CurrentScope {
|
|
|
1024
1026
|
findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
|
|
1025
1027
|
findFormDefinition(name: string): IFormDefinition | undefined;
|
|
1026
1028
|
findType(name: string | undefined): TypedIdentifier | undefined;
|
|
1029
|
+
findExtraLikeType(name: string | undefined): TypedIdentifier | undefined;
|
|
1027
1030
|
findVariable(name: string | undefined): TypedIdentifier | undefined;
|
|
1028
1031
|
getDDIC(): DDIC;
|
|
1029
1032
|
getDDICReferences(): IDDICReferences;
|
|
@@ -3067,6 +3070,9 @@ declare interface IScopeData {
|
|
|
3067
3070
|
types: {
|
|
3068
3071
|
[name: string]: TypedIdentifier;
|
|
3069
3072
|
};
|
|
3073
|
+
extraLikeTypes: {
|
|
3074
|
+
[name: string]: TypedIdentifier;
|
|
3075
|
+
};
|
|
3070
3076
|
deferred: Token[];
|
|
3071
3077
|
cdefs: IClassDefinition[];
|
|
3072
3078
|
idefs: IInterfaceDefinition[];
|
|
@@ -4312,6 +4318,7 @@ export declare enum ScopeType {
|
|
|
4312
4318
|
Form = "form",
|
|
4313
4319
|
FunctionModule = "function",
|
|
4314
4320
|
Method = "method",
|
|
4321
|
+
MethodInstance = "method_instance",
|
|
4315
4322
|
For = "for",
|
|
4316
4323
|
OpenSQL = "open_sql"
|
|
4317
4324
|
}
|
|
@@ -4595,6 +4602,7 @@ export declare class SpaghettiScopeNode extends ScopeData implements ISpaghettiS
|
|
|
4595
4602
|
listFormDefinitions(): IFormDefinition[];
|
|
4596
4603
|
findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
|
|
4597
4604
|
findType(name: string): TypedIdentifier | undefined;
|
|
4605
|
+
findExtraLikeType(name: string): TypedIdentifier | undefined;
|
|
4598
4606
|
findVariable(name: string): TypedIdentifier | undefined;
|
|
4599
4607
|
findWriteReference(pos: Position): TypedIdentifier | undefined;
|
|
4600
4608
|
findTableReference(pos: Position): string | undefined;
|
|
@@ -7,7 +7,8 @@ const tokens_1 = require("../../1_lexer/tokens");
|
|
|
7
7
|
class SQLArithmetics extends combi_1.Expression {
|
|
8
8
|
getRunnable() {
|
|
9
9
|
const operator = (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WPlusW), (0, combi_1.tok)(tokens_1.WDashW), "*", "/");
|
|
10
|
-
|
|
10
|
+
const field = (0, combi_1.alt)(_1.SQLFieldName, _1.SQLFunction);
|
|
11
|
+
return (0, combi_1.seq)(field, (0, combi_1.starPrio)((0, combi_1.seq)(operator, field)));
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
exports.SQLArithmetics = SQLArithmetics;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SQLFunction = void 0;
|
|
4
|
+
const constant_1 = require("./constant");
|
|
4
5
|
const version_1 = require("../../../version");
|
|
5
6
|
const tokens_1 = require("../../1_lexer/tokens");
|
|
6
7
|
const combi_1 = require("../combi");
|
|
@@ -9,10 +10,20 @@ const sql_alias_field_1 = require("./sql_alias_field");
|
|
|
9
10
|
const sql_field_name_1 = require("./sql_field_name");
|
|
10
11
|
class SQLFunction extends combi_1.Expression {
|
|
11
12
|
getRunnable() {
|
|
13
|
+
const param = (0, combi_1.alt)(sql_field_name_1.SQLFieldName, sql_alias_field_1.SQLAliasField, SQLFunction, constant_1.Constant);
|
|
14
|
+
const castTypes = (0, combi_1.altPrio)((0, combi_1.seq)("CHAR", (0, combi_1.tok)(tokens_1.ParenLeftW), integer_1.Integer, (0, combi_1.tok)(tokens_1.WParenRightW)), "FLTP");
|
|
15
|
+
const abs = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("abs", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
16
|
+
const cast = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("cast", (0, combi_1.tok)(tokens_1.ParenLeftW), param, "AS", castTypes, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
17
|
+
const ceil = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("ceil", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
18
|
+
const coalesce = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("coalesce", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
19
|
+
const concat = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("concat", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
20
|
+
const div = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("div", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
21
|
+
const floor = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("floor", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
22
|
+
const length = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("length", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
23
|
+
const mod = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("mod", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
24
|
+
const replace = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("replace", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
12
25
|
const uuid = (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.seq)("uuid", (0, combi_1.tok)(tokens_1.ParenLeftW), (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
13
|
-
|
|
14
|
-
const cast = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("cast", (0, combi_1.tok)(tokens_1.ParenLeftW), (0, combi_1.altPrio)(sql_field_name_1.SQLFieldName, sql_alias_field_1.SQLAliasField), "AS CHAR", (0, combi_1.tok)(tokens_1.ParenLeftW), integer_1.Integer, (0, combi_1.tok)(tokens_1.WParenRightW), (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
15
|
-
return (0, combi_1.altPrio)(uuid, abs, cast);
|
|
26
|
+
return (0, combi_1.altPrio)(uuid, abs, ceil, floor, cast, div, mod, coalesce, concat, replace, length);
|
|
16
27
|
}
|
|
17
28
|
}
|
|
18
29
|
exports.SQLFunction = SQLFunction;
|
|
@@ -10,9 +10,10 @@ class Move {
|
|
|
10
10
|
const mov = (0, combi_1.verNot)(version_1.Version.Cloud, "MOVE");
|
|
11
11
|
const move = (0, combi_1.seq)(mov, (0, combi_1.altPrio)((0, combi_1.seq)("EXACT", expressions_1.Source, "TO", expressions_1.Target), (0, combi_1.seq)(expressions_1.Source, (0, combi_1.altPrio)("?TO", "TO"), expressions_1.Target)));
|
|
12
12
|
const calcAssign = (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.tok)(tokens_1.WPlus), "="), (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WDash), "="), "/=", "*=", "&&="));
|
|
13
|
-
const
|
|
13
|
+
const chained = (0, combi_1.seq)("=", (0, combi_1.star)((0, combi_1.seq)(expressions_1.Target, "=")));
|
|
14
|
+
const equals = (0, combi_1.altPrio)((0, combi_1.altPrio)(chained, "?="), calcAssign);
|
|
14
15
|
// todo, move "?=" to CAST?
|
|
15
|
-
const eq = (0, combi_1.seq)(
|
|
16
|
+
const eq = (0, combi_1.seq)(expressions_1.Target, equals, expressions_1.Source);
|
|
16
17
|
return (0, combi_1.altPrio)(move, eq);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -54,6 +54,25 @@ class CurrentScope {
|
|
|
54
54
|
}
|
|
55
55
|
this.current.getData().types[upper] = type;
|
|
56
56
|
}
|
|
57
|
+
addExtraLikeType(type) {
|
|
58
|
+
if (type === undefined) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.addExtraLikeTypeNamed(type.getName(), type);
|
|
62
|
+
}
|
|
63
|
+
addExtraLikeTypeNamed(name, type) {
|
|
64
|
+
if (type === undefined) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (this.current === undefined) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const upper = name.toUpperCase();
|
|
71
|
+
if (this.current.getData().extraLikeTypes[upper] !== undefined) {
|
|
72
|
+
throw new Error(`Type name "${name}" already defined`);
|
|
73
|
+
}
|
|
74
|
+
this.current.getData().extraLikeTypes[upper] = type;
|
|
75
|
+
}
|
|
57
76
|
addClassDefinition(c) {
|
|
58
77
|
var _a;
|
|
59
78
|
(_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().cdefs.push(c);
|
|
@@ -231,6 +250,13 @@ class CurrentScope {
|
|
|
231
250
|
}
|
|
232
251
|
return (_a = this.current) === null || _a === void 0 ? void 0 : _a.findType(name);
|
|
233
252
|
}
|
|
253
|
+
findExtraLikeType(name) {
|
|
254
|
+
var _a;
|
|
255
|
+
if (name === undefined) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
return (_a = this.current) === null || _a === void 0 ? void 0 : _a.findExtraLikeType(name);
|
|
259
|
+
}
|
|
234
260
|
findVariable(name) {
|
|
235
261
|
var _a;
|
|
236
262
|
if (name === undefined) {
|
|
@@ -14,6 +14,7 @@ var ScopeType;
|
|
|
14
14
|
ScopeType["Form"] = "form";
|
|
15
15
|
ScopeType["FunctionModule"] = "function";
|
|
16
16
|
ScopeType["Method"] = "method";
|
|
17
|
+
ScopeType["MethodInstance"] = "method_instance";
|
|
17
18
|
ScopeType["For"] = "for";
|
|
18
19
|
ScopeType["OpenSQL"] = "open_sql";
|
|
19
20
|
})(ScopeType = exports.ScopeType || (exports.ScopeType = {}));
|
|
@@ -79,8 +79,12 @@ class BasicTypes {
|
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
81
|
const name = children.shift().getFirstToken().getStr();
|
|
82
|
-
|
|
82
|
+
let found = this.scope.findVariable(name);
|
|
83
83
|
type = found === null || found === void 0 ? void 0 : found.getType();
|
|
84
|
+
if (found === undefined) {
|
|
85
|
+
found = this.scope.findExtraLikeType(name);
|
|
86
|
+
type = found === null || found === void 0 ? void 0 : found.getType();
|
|
87
|
+
}
|
|
84
88
|
if (found) {
|
|
85
89
|
this.scope.addReference(chain === null || chain === void 0 ? void 0 : chain.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);
|
|
86
90
|
}
|
|
@@ -6,9 +6,8 @@ const basic_1 = require("../../types/basic");
|
|
|
6
6
|
const source_1 = require("./source");
|
|
7
7
|
class FieldAssignment {
|
|
8
8
|
runSyntax(node, scope, filename, targetType) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (name === undefined) {
|
|
9
|
+
const fieldSub = node.findDirectExpression(Expressions.FieldSub);
|
|
10
|
+
if (fieldSub === undefined) {
|
|
12
11
|
throw new Error("FieldAssignment, FieldSub node not found");
|
|
13
12
|
}
|
|
14
13
|
const s = node.findDirectExpression(Expressions.Source);
|
|
@@ -17,10 +16,17 @@ class FieldAssignment {
|
|
|
17
16
|
}
|
|
18
17
|
let type = undefined;
|
|
19
18
|
if (targetType instanceof basic_1.StructureType) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
let context = targetType;
|
|
20
|
+
for (const c of fieldSub.getChildren()) {
|
|
21
|
+
const text = c.concatTokens();
|
|
22
|
+
if (text !== "-" && context instanceof basic_1.StructureType) {
|
|
23
|
+
context = context.getComponentByName(text);
|
|
24
|
+
if (context === undefined && targetType.containsVoid() === false) {
|
|
25
|
+
throw new Error(`field ${text} does not exist in structure`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
23
28
|
}
|
|
29
|
+
type = context;
|
|
24
30
|
}
|
|
25
31
|
else if (targetType instanceof basic_1.VoidType) {
|
|
26
32
|
type = targetType;
|
|
@@ -12,6 +12,7 @@ class ScopeData {
|
|
|
12
12
|
idefs: [],
|
|
13
13
|
forms: [],
|
|
14
14
|
types: {},
|
|
15
|
+
extraLikeTypes: {},
|
|
15
16
|
deferred: [],
|
|
16
17
|
references: [],
|
|
17
18
|
};
|
|
@@ -126,6 +127,18 @@ class SpaghettiScopeNode extends ScopeData {
|
|
|
126
127
|
}
|
|
127
128
|
return undefined;
|
|
128
129
|
}
|
|
130
|
+
findExtraLikeType(name) {
|
|
131
|
+
let search = this;
|
|
132
|
+
const upper = name.toUpperCase();
|
|
133
|
+
while (search !== undefined) {
|
|
134
|
+
const data = search.getData();
|
|
135
|
+
if (data.extraLikeTypes[upper]) {
|
|
136
|
+
return data.extraLikeTypes[upper];
|
|
137
|
+
}
|
|
138
|
+
search = search.getParent();
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
129
142
|
findVariable(name) {
|
|
130
143
|
let search = this;
|
|
131
144
|
const upper = name.toUpperCase();
|
|
@@ -28,8 +28,10 @@ class ClassImplementation {
|
|
|
28
28
|
scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(new tokens_1.Identifier(new position_1.Position(1, 1), "me"), _builtin_1.BuiltIn.filename, new basic_1.ObjectReferenceType(classDefinition)));
|
|
29
29
|
helper.addAliasedAttributes(classDefinition); // todo, this is not correct, take care of instance vs static
|
|
30
30
|
scope.addList(classAttributes.getConstants());
|
|
31
|
-
scope.addList(classAttributes.
|
|
32
|
-
|
|
31
|
+
scope.addList(classAttributes.getStatic());
|
|
32
|
+
for (const i of classAttributes.getInstance()) {
|
|
33
|
+
scope.addExtraLikeType(i);
|
|
34
|
+
}
|
|
33
35
|
const implemented = helper.fromSuperClass(classDefinition);
|
|
34
36
|
helper.fromInterfaces(classDefinition, implemented);
|
|
35
37
|
}
|
|
@@ -11,17 +11,21 @@ class MethodImplementation {
|
|
|
11
11
|
const className = scope.getName();
|
|
12
12
|
const methodToken = node.findFirstExpression(Expressions.MethodName).getFirstToken();
|
|
13
13
|
const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr();
|
|
14
|
-
scope.push(_scope_type_1.ScopeType.Method, methodName, node.getFirstToken().getStart(), filename);
|
|
15
14
|
const classDefinition = scope.findClassDefinition(className);
|
|
16
15
|
if (classDefinition === undefined) {
|
|
17
|
-
scope.pop(node.getLastToken().getEnd());
|
|
16
|
+
// scope.pop(node.getLastToken().getEnd());
|
|
18
17
|
throw new Error("Class definition for \"" + className + "\" not found");
|
|
19
18
|
}
|
|
20
19
|
const { method: methodDefinition } = helper.searchMethodName(classDefinition, methodName);
|
|
21
20
|
if (methodDefinition === undefined) {
|
|
22
|
-
scope.pop(node.getLastToken().getEnd());
|
|
21
|
+
// scope.pop(node.getLastToken().getEnd());
|
|
23
22
|
throw new Error("Method definition \"" + methodName + "\" not found");
|
|
24
23
|
}
|
|
24
|
+
if (methodDefinition.isStatic() === false) {
|
|
25
|
+
scope.push(_scope_type_1.ScopeType.MethodInstance, methodName, node.getFirstToken().getStart(), filename);
|
|
26
|
+
scope.addList(classDefinition.getAttributes().getInstance());
|
|
27
|
+
}
|
|
28
|
+
scope.push(_scope_type_1.ScopeType.Method, methodName, node.getFirstToken().getStart(), filename);
|
|
25
29
|
scope.addReference(methodToken, methodDefinition, _reference_1.ReferenceType.MethodImplementationReference, filename);
|
|
26
30
|
scope.addList(methodDefinition.getParameters().getAll());
|
|
27
31
|
for (const i of helper.findInterfaces(classDefinition)) {
|
|
@@ -412,11 +412,16 @@ class SyntaxLogic {
|
|
|
412
412
|
}
|
|
413
413
|
else if (s instanceof Statements.EndForm
|
|
414
414
|
|| s instanceof Statements.EndFunction
|
|
415
|
-
|| s instanceof Statements.EndMethod
|
|
416
415
|
|| s instanceof Statements.EndClass
|
|
417
416
|
|| s instanceof Statements.EndInterface) {
|
|
418
417
|
this.scope.pop(node.getLastToken().getEnd());
|
|
419
418
|
}
|
|
419
|
+
else if (s instanceof Statements.EndMethod) {
|
|
420
|
+
this.scope.pop(node.getLastToken().getEnd());
|
|
421
|
+
if (this.scope.getType() === _scope_type_1.ScopeType.MethodInstance) {
|
|
422
|
+
this.scope.pop(node.getLastToken().getEnd());
|
|
423
|
+
}
|
|
424
|
+
}
|
|
420
425
|
}
|
|
421
426
|
}
|
|
422
427
|
exports.SyntaxLogic = SyntaxLogic;
|
|
@@ -72,13 +72,13 @@ class FlowGraph {
|
|
|
72
72
|
this.label = label;
|
|
73
73
|
}
|
|
74
74
|
toDigraph() {
|
|
75
|
-
return `digraph G {
|
|
76
|
-
labelloc="t";
|
|
77
|
-
label="${this.label}";
|
|
78
|
-
graph [fontname = "helvetica"];
|
|
79
|
-
node [fontname = "helvetica", shape="box"];
|
|
80
|
-
edge [fontname = "helvetica"];
|
|
81
|
-
${this.toTextEdges()}
|
|
75
|
+
return `digraph G {
|
|
76
|
+
labelloc="t";
|
|
77
|
+
label="${this.label}";
|
|
78
|
+
graph [fontname = "helvetica"];
|
|
79
|
+
node [fontname = "helvetica", shape="box"];
|
|
80
|
+
edge [fontname = "helvetica"];
|
|
81
|
+
${this.toTextEdges()}
|
|
82
82
|
}`;
|
|
83
83
|
}
|
|
84
84
|
listSources(node) {
|
package/build/src/lsp/help.js
CHANGED
|
@@ -9,13 +9,13 @@ const dump_scope_1 = require("./dump_scope");
|
|
|
9
9
|
class Help {
|
|
10
10
|
static find(reg, textDocument, position) {
|
|
11
11
|
let content = "";
|
|
12
|
-
content = `
|
|
13
|
-
<a href="#_tokens" rel="no-refresh">Tokens</a> |
|
|
14
|
-
<a href="#_statements" rel="no-refresh">Statements</a> |
|
|
15
|
-
<a href="#_structure" rel="no-refresh">Structure</a> |
|
|
16
|
-
<a href="#_files" rel="no-refresh">Files</a> |
|
|
17
|
-
<a href="#_info" rel="no-refresh">Info Dump</a>
|
|
18
|
-
<hr>
|
|
12
|
+
content = `
|
|
13
|
+
<a href="#_tokens" rel="no-refresh">Tokens</a> |
|
|
14
|
+
<a href="#_statements" rel="no-refresh">Statements</a> |
|
|
15
|
+
<a href="#_structure" rel="no-refresh">Structure</a> |
|
|
16
|
+
<a href="#_files" rel="no-refresh">Files</a> |
|
|
17
|
+
<a href="#_info" rel="no-refresh">Info Dump</a>
|
|
18
|
+
<hr>
|
|
19
19
|
` +
|
|
20
20
|
"<tt>" + textDocument.uri + " (" +
|
|
21
21
|
(position.line + 1) + ", " +
|
package/build/src/registry.js
CHANGED
|
@@ -23,7 +23,7 @@ class Abapdoc extends _abap_rule_1.ABAPRule {
|
|
|
23
23
|
return {
|
|
24
24
|
key: "abapdoc",
|
|
25
25
|
title: "Check abapdoc",
|
|
26
|
-
shortDescription: `Various checks regarding abapdoc.
|
|
26
|
+
shortDescription: `Various checks regarding abapdoc.
|
|
27
27
|
Base rule checks for existence of abapdoc for public class methods and all interface methods.`,
|
|
28
28
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
29
29
|
};
|
|
@@ -20,42 +20,42 @@ class AlignParameters extends _abap_rule_1.ABAPRule {
|
|
|
20
20
|
key: "align_parameters",
|
|
21
21
|
title: "Align Parameters",
|
|
22
22
|
shortDescription: `Checks for vertially aligned parameters`,
|
|
23
|
-
extendedInformation: `Checks:
|
|
24
|
-
* function module calls
|
|
25
|
-
* method calls
|
|
26
|
-
* VALUE constructors
|
|
27
|
-
* NEW constructors
|
|
28
|
-
* RAISE EXCEPTION statements
|
|
29
|
-
* CREATE OBJECT statements
|
|
30
|
-
* RAISE EVENT statements
|
|
31
|
-
|
|
32
|
-
https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#align-parameters
|
|
33
|
-
|
|
34
|
-
Does not take effect on non functional method calls, use https://rules.abaplint.org/functional_writing/
|
|
35
|
-
|
|
23
|
+
extendedInformation: `Checks:
|
|
24
|
+
* function module calls
|
|
25
|
+
* method calls
|
|
26
|
+
* VALUE constructors
|
|
27
|
+
* NEW constructors
|
|
28
|
+
* RAISE EXCEPTION statements
|
|
29
|
+
* CREATE OBJECT statements
|
|
30
|
+
* RAISE EVENT statements
|
|
31
|
+
|
|
32
|
+
https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#align-parameters
|
|
33
|
+
|
|
34
|
+
Does not take effect on non functional method calls, use https://rules.abaplint.org/functional_writing/
|
|
35
|
+
|
|
36
36
|
Also https://rules.abaplint.org/max_one_method_parameter_per_line/ can help aligning parameter syntax`,
|
|
37
37
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Styleguide],
|
|
38
|
-
badExample: `CALL FUNCTION 'FOOBAR'
|
|
39
|
-
EXPORTING
|
|
40
|
-
foo = 2
|
|
41
|
-
parameter = 3.
|
|
42
|
-
|
|
43
|
-
foobar( moo = 1
|
|
44
|
-
param = 1 ).
|
|
45
|
-
|
|
46
|
-
foo = VALUE #(
|
|
47
|
-
foo = bar
|
|
38
|
+
badExample: `CALL FUNCTION 'FOOBAR'
|
|
39
|
+
EXPORTING
|
|
40
|
+
foo = 2
|
|
41
|
+
parameter = 3.
|
|
42
|
+
|
|
43
|
+
foobar( moo = 1
|
|
44
|
+
param = 1 ).
|
|
45
|
+
|
|
46
|
+
foo = VALUE #(
|
|
47
|
+
foo = bar
|
|
48
48
|
moo = 2 ).`,
|
|
49
|
-
goodExample: `CALL FUNCTION 'FOOBAR'
|
|
50
|
-
EXPORTING
|
|
51
|
-
foo = 2
|
|
52
|
-
parameter = 3.
|
|
53
|
-
|
|
54
|
-
foobar( moo = 1
|
|
55
|
-
param = 1 ).
|
|
56
|
-
|
|
57
|
-
foo = VALUE #(
|
|
58
|
-
foo = bar
|
|
49
|
+
goodExample: `CALL FUNCTION 'FOOBAR'
|
|
50
|
+
EXPORTING
|
|
51
|
+
foo = 2
|
|
52
|
+
parameter = 3.
|
|
53
|
+
|
|
54
|
+
foobar( moo = 1
|
|
55
|
+
param = 1 ).
|
|
56
|
+
|
|
57
|
+
foo = VALUE #(
|
|
58
|
+
foo = bar
|
|
59
59
|
moo = 2 ).`,
|
|
60
60
|
};
|
|
61
61
|
}
|
|
@@ -20,14 +20,14 @@ class AmbiguousStatement extends _abap_rule_1.ABAPRule {
|
|
|
20
20
|
return {
|
|
21
21
|
key: "ambiguous_statement",
|
|
22
22
|
title: "Check for ambigious statements",
|
|
23
|
-
shortDescription: `Checks for ambiguity between deleting or modifying from internal and database table
|
|
24
|
-
Add "TABLE" keyword or "@" for escaping SQL variables
|
|
25
|
-
|
|
23
|
+
shortDescription: `Checks for ambiguity between deleting or modifying from internal and database table
|
|
24
|
+
Add "TABLE" keyword or "@" for escaping SQL variables
|
|
25
|
+
|
|
26
26
|
Only works if the target version is 740sp05 or above`,
|
|
27
27
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
28
|
-
badExample: `DELETE foo FROM bar.
|
|
28
|
+
badExample: `DELETE foo FROM bar.
|
|
29
29
|
MODIFY foo FROM bar.`,
|
|
30
|
-
goodExample: `DELETE foo FROM @bar.
|
|
30
|
+
goodExample: `DELETE foo FROM @bar.
|
|
31
31
|
MODIFY TABLE foo FROM bar.`,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -35,12 +35,12 @@ class AvoidUse extends _abap_rule_1.ABAPRule {
|
|
|
35
35
|
key: "avoid_use",
|
|
36
36
|
title: "Avoid use of certain statements",
|
|
37
37
|
shortDescription: `Detects usage of certain statements.`,
|
|
38
|
-
extendedInformation: `DEFAULT KEY: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-default-key
|
|
39
|
-
|
|
40
|
-
Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
|
|
41
|
-
|
|
42
|
-
STATICS: use CLASS-DATA instead
|
|
43
|
-
|
|
38
|
+
extendedInformation: `DEFAULT KEY: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-default-key
|
|
39
|
+
|
|
40
|
+
Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
|
|
41
|
+
|
|
42
|
+
STATICS: use CLASS-DATA instead
|
|
43
|
+
|
|
44
44
|
DESCRIBE TABLE LINES: use lines() instead (quickfix exists)`,
|
|
45
45
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
46
46
|
};
|
|
@@ -23,11 +23,11 @@ class BeginEndNames extends _abap_rule_1.ABAPRule {
|
|
|
23
23
|
title: "Check BEGIN END names",
|
|
24
24
|
shortDescription: `Check BEGIN OF and END OF names match, plus there must be statements between BEGIN and END`,
|
|
25
25
|
tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
|
|
26
|
-
badExample: `DATA: BEGIN OF stru,
|
|
27
|
-
field TYPE i,
|
|
26
|
+
badExample: `DATA: BEGIN OF stru,
|
|
27
|
+
field TYPE i,
|
|
28
28
|
END OF structure_not_the_same.`,
|
|
29
|
-
goodExample: `DATA: BEGIN OF stru,
|
|
30
|
-
field TYPE i,
|
|
29
|
+
goodExample: `DATA: BEGIN OF stru,
|
|
30
|
+
field TYPE i,
|
|
31
31
|
END OF stru.`,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -21,19 +21,19 @@ class BeginSingleInclude extends _abap_rule_1.ABAPRule {
|
|
|
21
21
|
title: "BEGIN contains single INCLUDE",
|
|
22
22
|
shortDescription: `Finds TYPE BEGIN with just one INCLUDE TYPE, and DATA with single INCLUDE STRUCTURE`,
|
|
23
23
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
24
|
-
badExample: `TYPES: BEGIN OF dummy1.
|
|
25
|
-
INCLUDE TYPE dselc.
|
|
26
|
-
TYPES: END OF dummy1.
|
|
27
|
-
|
|
28
|
-
DATA BEGIN OF foo.
|
|
29
|
-
INCLUDE STRUCTURE syst.
|
|
30
|
-
DATA END OF foo.
|
|
31
|
-
|
|
32
|
-
STATICS BEGIN OF bar.
|
|
33
|
-
INCLUDE STRUCTURE syst.
|
|
24
|
+
badExample: `TYPES: BEGIN OF dummy1.
|
|
25
|
+
INCLUDE TYPE dselc.
|
|
26
|
+
TYPES: END OF dummy1.
|
|
27
|
+
|
|
28
|
+
DATA BEGIN OF foo.
|
|
29
|
+
INCLUDE STRUCTURE syst.
|
|
30
|
+
DATA END OF foo.
|
|
31
|
+
|
|
32
|
+
STATICS BEGIN OF bar.
|
|
33
|
+
INCLUDE STRUCTURE syst.
|
|
34
34
|
STATICS END OF bar.`,
|
|
35
|
-
goodExample: `DATA BEGIN OF foo.
|
|
36
|
-
INCLUDE STRUCTURE dselc.
|
|
35
|
+
goodExample: `DATA BEGIN OF foo.
|
|
36
|
+
INCLUDE STRUCTURE dselc.
|
|
37
37
|
DATA END OF foo.`,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
@@ -24,9 +24,9 @@ class CallTransactionAuthorityCheck extends _abap_rule_1.ABAPRule {
|
|
|
24
24
|
extendedInformation: `https://docs.abapopenchecks.org/checks/54/`,
|
|
25
25
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Security],
|
|
26
26
|
badExample: `CALL TRANSACTION 'FOO'.`,
|
|
27
|
-
goodExample: `TRY.
|
|
28
|
-
CALL TRANSACTION 'FOO' WITH AUTHORITY-CHECK.
|
|
29
|
-
CATCH cx_sy_authorization_error.
|
|
27
|
+
goodExample: `TRY.
|
|
28
|
+
CALL TRANSACTION 'FOO' WITH AUTHORITY-CHECK.
|
|
29
|
+
CATCH cx_sy_authorization_error.
|
|
30
30
|
ENDTRY.`,
|
|
31
31
|
};
|
|
32
32
|
}
|
|
@@ -45,10 +45,10 @@ class ChainMainlyDeclarations extends _abap_rule_1.ABAPRule {
|
|
|
45
45
|
key: "chain_mainly_declarations",
|
|
46
46
|
title: "Chain mainly declarations",
|
|
47
47
|
shortDescription: `Chain mainly declarations, allows chaining for the configured statements, reports errors for other statements.`,
|
|
48
|
-
extendedInformation: `
|
|
49
|
-
https://docs.abapopenchecks.org/checks/23/
|
|
50
|
-
|
|
51
|
-
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenchained_statements_guidl.htm
|
|
48
|
+
extendedInformation: `
|
|
49
|
+
https://docs.abapopenchecks.org/checks/23/
|
|
50
|
+
|
|
51
|
+
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenchained_statements_guidl.htm
|
|
52
52
|
`,
|
|
53
53
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
54
54
|
badExample: `CALL METHOD: bar.`,
|
|
@@ -23,8 +23,8 @@ class CheckAbstract extends _abap_rule_1.ABAPRule {
|
|
|
23
23
|
return {
|
|
24
24
|
key: "check_abstract",
|
|
25
25
|
title: "Check abstract methods and classes",
|
|
26
|
-
shortDescription: `Checks abstract methods and classes:
|
|
27
|
-
- class defined as abstract and final,
|
|
26
|
+
shortDescription: `Checks abstract methods and classes:
|
|
27
|
+
- class defined as abstract and final,
|
|
28
28
|
- non-abstract class contains abstract methods`,
|
|
29
29
|
extendedInformation: `If a class defines only constants, use an interface instead`,
|
|
30
30
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
@@ -27,9 +27,9 @@ class CheckComments extends _abap_rule_1.ABAPRule {
|
|
|
27
27
|
return {
|
|
28
28
|
key: "check_comments",
|
|
29
29
|
title: "Check Comments",
|
|
30
|
-
shortDescription: `
|
|
31
|
-
Various checks for comment usage.
|
|
32
|
-
|
|
30
|
+
shortDescription: `
|
|
31
|
+
Various checks for comment usage.
|
|
32
|
+
|
|
33
33
|
* End of line comments. Comments starting with "#EC" or "##" are ignored`,
|
|
34
34
|
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#put-comments-before-the-statement-they-relate-to`,
|
|
35
35
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
@@ -17,9 +17,9 @@ class CheckInclude {
|
|
|
17
17
|
key: "check_include",
|
|
18
18
|
title: "Check INCLUDEs",
|
|
19
19
|
shortDescription: `Checks INCLUDE statements`,
|
|
20
|
-
extendedInformation: `
|
|
21
|
-
* Reports unused includes
|
|
22
|
-
* Errors if the includes are not found
|
|
20
|
+
extendedInformation: `
|
|
21
|
+
* Reports unused includes
|
|
22
|
+
* Errors if the includes are not found
|
|
23
23
|
* Error if including a main program`,
|
|
24
24
|
tags: [_irule_1.RuleTag.Syntax],
|
|
25
25
|
};
|
|
@@ -21,15 +21,15 @@ class CheckNoHandlerPragma extends _abap_rule_1.ABAPRule {
|
|
|
21
21
|
title: "Check if NO_HANDLER can be removed",
|
|
22
22
|
shortDescription: `Checks NO_HANDLER pragmas that can be removed`,
|
|
23
23
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
24
|
-
badExample: `TRY.
|
|
25
|
-
...
|
|
26
|
-
CATCH zcx_abapgit_exception ##NO_HANDLER.
|
|
27
|
-
RETURN. " it has a handler
|
|
24
|
+
badExample: `TRY.
|
|
25
|
+
...
|
|
26
|
+
CATCH zcx_abapgit_exception ##NO_HANDLER.
|
|
27
|
+
RETURN. " it has a handler
|
|
28
28
|
ENDTRY.`,
|
|
29
|
-
goodExample: `TRY.
|
|
30
|
-
...
|
|
31
|
-
CATCH zcx_abapgit_exception.
|
|
32
|
-
RETURN.
|
|
29
|
+
goodExample: `TRY.
|
|
30
|
+
...
|
|
31
|
+
CATCH zcx_abapgit_exception.
|
|
32
|
+
RETURN.
|
|
33
33
|
ENDTRY.`,
|
|
34
34
|
};
|
|
35
35
|
}
|