@abaplint/core 2.119.61 → 2.119.63
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 +5 -1
- package/build/src/abap/2_statements/statement_parser.js +3 -1
- package/build/src/abap/2_statements/statements/type_mesh.js +1 -1
- package/build/src/abap/5_syntax/_current_scope.js +2 -2
- package/build/src/abap/5_syntax/_object_oriented.js +10 -15
- package/build/src/abap/types/class_attributes.js +19 -18
- package/build/src/config.js +17 -9
- package/build/src/objects/_dynpros.js +1 -0
- package/build/src/objects/data_definition.js +2 -3
- package/build/src/registry.js +1 -1
- package/build/src/rules/begin_end_names.js +9 -4
- package/build/src/rules/downport.js +1 -1
- package/build/src/rules/dynpro_checks.js +6 -2
- package/build/src/rules/names_no_dash.js +12 -19
- package/build/src/rules/obsolete_statement.js +5 -5
- package/build/src/rules/short_case.js +3 -3
- package/build/src/rules/try_without_catch.js +3 -3
- package/build/src/rules/unnecessary_pragma.js +12 -0
- package/build/src/skip_logic.js +4 -2
- package/package.json +1 -1
package/build/abaplint.d.ts
CHANGED
|
@@ -412,6 +412,8 @@ declare class Attributes implements IAttributes {
|
|
|
412
412
|
private readonly filename;
|
|
413
413
|
private readonly aliases;
|
|
414
414
|
private readonly declaredInterfaces;
|
|
415
|
+
private readonly all;
|
|
416
|
+
private readonly byName;
|
|
415
417
|
constructor(node: StructureNode, input: SyntaxInput);
|
|
416
418
|
getTypes(): TypeDefinitions;
|
|
417
419
|
getStatic(): ClassAttribute[];
|
|
@@ -423,6 +425,7 @@ declare class Attributes implements IAttributes {
|
|
|
423
425
|
getConstants(): ClassConstant[];
|
|
424
426
|
getConstantsByVisibility(visibility: Visibility): ClassConstant[];
|
|
425
427
|
findByName(name: string): ClassAttribute | ClassConstant | undefined;
|
|
428
|
+
private buildByName;
|
|
426
429
|
private parse;
|
|
427
430
|
private parseSection;
|
|
428
431
|
private parseAlias;
|
|
@@ -2078,6 +2081,7 @@ declare class Dynamic extends Expression {
|
|
|
2078
2081
|
declare type DynproField = {
|
|
2079
2082
|
name: string;
|
|
2080
2083
|
type: string;
|
|
2084
|
+
contType: string;
|
|
2081
2085
|
length: number;
|
|
2082
2086
|
vislength: number;
|
|
2083
2087
|
line: number;
|
|
@@ -4398,7 +4402,6 @@ declare interface ISyntaxResult {
|
|
|
4398
4402
|
declare interface ISyntaxSettings {
|
|
4399
4403
|
/** ABAP language version */
|
|
4400
4404
|
version?: VersionOldOrNew;
|
|
4401
|
-
languageVersion?: LanguageVersion;
|
|
4402
4405
|
/** Report error for objects in this regex namespace. Types not in namespace will be void. Case insensitive */
|
|
4403
4406
|
errorNamespace: string;
|
|
4404
4407
|
/** List of full named global constants (regex not possible)
|
|
@@ -6759,6 +6762,7 @@ declare class Skip implements IStatement {
|
|
|
6759
6762
|
|
|
6760
6763
|
export declare class SkipLogic {
|
|
6761
6764
|
private readonly reg;
|
|
6765
|
+
private includeGraph;
|
|
6762
6766
|
/** TOBJ cache hashmap */
|
|
6763
6767
|
private tobj;
|
|
6764
6768
|
constructor(reg: IRegistry);
|
|
@@ -239,7 +239,9 @@ class StatementParser {
|
|
|
239
239
|
statement = input;
|
|
240
240
|
}
|
|
241
241
|
else if (length === 1 && lastToken instanceof tokens_1.Pragma) {
|
|
242
|
-
|
|
242
|
+
// special case, everything crashes if StatementNodes doesnt have children
|
|
243
|
+
statement = new nodes_1.StatementNode(new _statement_1.Empty(), undefined, [lastToken])
|
|
244
|
+
.setChildren(this.tokensToNodes([lastToken]));
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
247
|
return statement;
|
|
@@ -9,7 +9,7 @@ class TypeMesh {
|
|
|
9
9
|
const on = (0, combi_1.seq)("ON", expressions_1.NamespaceSimpleName, "=", expressions_1.NamespaceSimpleName, (0, combi_1.star)((0, combi_1.seq)("AND", expressions_1.NamespaceSimpleName, "=", expressions_1.NamespaceSimpleName)));
|
|
10
10
|
const using = (0, combi_1.seq)("USING KEY", expressions_1.NamespaceSimpleName);
|
|
11
11
|
const association = (0, combi_1.seq)("ASSOCIATION", expressions_1.NamespaceSimpleName, "TO", expressions_1.NamespaceSimpleName, (0, combi_1.plus)(on));
|
|
12
|
-
const ret = (0, combi_1.ver)(version_1.Release.
|
|
12
|
+
const ret = (0, combi_1.ver)(version_1.Release.v740sp05, (0, combi_1.seq)("TYPES", expressions_1.NamespaceSimpleName, "TYPE", (0, combi_1.opt)("REF TO"), expressions_1.TypeName, (0, combi_1.plus)(association), (0, combi_1.opt)(using)));
|
|
13
13
|
return ret;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -296,7 +296,7 @@ class CurrentScope {
|
|
|
296
296
|
}
|
|
297
297
|
findTypePoolConstant(name) {
|
|
298
298
|
var _a;
|
|
299
|
-
if (name === undefined || name.includes("_") ===
|
|
299
|
+
if (name === undefined || name.includes("_") === false) {
|
|
300
300
|
return undefined;
|
|
301
301
|
}
|
|
302
302
|
const typePoolName = name.split("_")[0];
|
|
@@ -318,7 +318,7 @@ class CurrentScope {
|
|
|
318
318
|
}
|
|
319
319
|
findTypePoolType(name) {
|
|
320
320
|
var _a;
|
|
321
|
-
if (name.includes("_") ===
|
|
321
|
+
if (name.includes("_") === false) {
|
|
322
322
|
return undefined;
|
|
323
323
|
}
|
|
324
324
|
const typePoolName = name.split("_")[0];
|
|
@@ -108,11 +108,9 @@ class ObjectOriented {
|
|
|
108
108
|
findMethodInInterface(interfaceName, methodName) {
|
|
109
109
|
const idef = this.scope.findInterfaceDefinition(interfaceName);
|
|
110
110
|
if (idef) {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return { method, def: idef };
|
|
115
|
-
}
|
|
111
|
+
const method = idef.getMethodDefinitions().getByName(methodName);
|
|
112
|
+
if (method) {
|
|
113
|
+
return { method, def: idef };
|
|
116
114
|
}
|
|
117
115
|
return this.findMethodViaAlias(methodName, idef);
|
|
118
116
|
}
|
|
@@ -334,17 +332,14 @@ class ObjectOriented {
|
|
|
334
332
|
if (defs === undefined) {
|
|
335
333
|
return undefined;
|
|
336
334
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return this.findMethodInSuper(def, methodName);
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
return method;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
335
|
+
const method = defs.getByName(methodName);
|
|
336
|
+
if (method === undefined) {
|
|
337
|
+
return undefined;
|
|
346
338
|
}
|
|
347
|
-
|
|
339
|
+
if (method.isRedefinition()) {
|
|
340
|
+
return this.findMethodInSuper(def, methodName);
|
|
341
|
+
}
|
|
342
|
+
return method;
|
|
348
343
|
}
|
|
349
344
|
findMethodInSuper(child, methodName) {
|
|
350
345
|
let sup = child.getSuperClass();
|
|
@@ -63,6 +63,8 @@ class Attributes {
|
|
|
63
63
|
this.tlist = [];
|
|
64
64
|
this.filename = input.filename;
|
|
65
65
|
this.parse(node, input);
|
|
66
|
+
this.all = this.static.concat(this.instance);
|
|
67
|
+
this.byName = this.buildByName();
|
|
66
68
|
this.types = new type_definitions_1.TypeDefinitions(this.tlist);
|
|
67
69
|
}
|
|
68
70
|
getTypes() {
|
|
@@ -75,10 +77,7 @@ class Attributes {
|
|
|
75
77
|
return this.aliases;
|
|
76
78
|
}
|
|
77
79
|
getAll() {
|
|
78
|
-
|
|
79
|
-
res = res.concat(this.static);
|
|
80
|
-
res = res.concat(this.instance);
|
|
81
|
-
return res;
|
|
80
|
+
return this.all;
|
|
82
81
|
}
|
|
83
82
|
getStaticsByVisibility(visibility) {
|
|
84
83
|
const attributes = [];
|
|
@@ -113,27 +112,29 @@ class Attributes {
|
|
|
113
112
|
}
|
|
114
113
|
return attributes;
|
|
115
114
|
}
|
|
116
|
-
// todo, optimize
|
|
117
115
|
findByName(name) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
return this.byName[name.toUpperCase()];
|
|
117
|
+
}
|
|
118
|
+
/////////////////////////////
|
|
119
|
+
buildByName() {
|
|
120
|
+
const ret = {};
|
|
121
|
+
for (const a of this.static) {
|
|
122
|
+
ret[a.getName().toUpperCase()] = a;
|
|
123
123
|
}
|
|
124
|
-
for (const a of this.
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
for (const a of this.instance) {
|
|
125
|
+
const name = a.getName().toUpperCase();
|
|
126
|
+
if (ret[name] === undefined) {
|
|
127
|
+
ret[name] = a;
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
for (const a of this.
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
for (const a of this.constants) {
|
|
131
|
+
const name = a.getName().toUpperCase();
|
|
132
|
+
if (ret[name] === undefined) {
|
|
133
|
+
ret[name] = a;
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
|
-
return
|
|
136
|
+
return ret;
|
|
135
137
|
}
|
|
136
|
-
/////////////////////////////
|
|
137
138
|
parse(node, input) {
|
|
138
139
|
var _a, _b;
|
|
139
140
|
const cdef = node.findDirectStructure(Structures.ClassDefinition);
|
package/build/src/config.js
CHANGED
|
@@ -47,10 +47,19 @@ class Config {
|
|
|
47
47
|
for (const rule of sorted) {
|
|
48
48
|
rules[rule.getMetadata().key] = rule.getConfig();
|
|
49
49
|
}
|
|
50
|
-
const version =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const version = langVer !== undefined
|
|
51
|
+
? {
|
|
52
|
+
release: ver === undefined || ver === version_1.Version.Cloud
|
|
53
|
+
? version_1.Release.Newest.name
|
|
54
|
+
: typeof ver === "string"
|
|
55
|
+
? (0, version_1.versionToABAPRelease)(ver).name
|
|
56
|
+
: ver.release,
|
|
57
|
+
language: langVer,
|
|
58
|
+
}
|
|
59
|
+
: ver !== null && ver !== void 0 ? ver : {
|
|
60
|
+
release: version_1.Release.Newest.name,
|
|
61
|
+
language: version_1.LanguageVersion.Normal,
|
|
62
|
+
};
|
|
54
63
|
// defaults: dont skip anything, report everything. The user can decide to skip stuff
|
|
55
64
|
// its difficult to debug errors not being reported
|
|
56
65
|
const config = {
|
|
@@ -75,7 +84,6 @@ class Config {
|
|
|
75
84
|
}],
|
|
76
85
|
syntax: {
|
|
77
86
|
version,
|
|
78
|
-
languageVersion: langVer,
|
|
79
87
|
errorNamespace: "^(Z|Y|LCL\_|TY\_|LIF\_)",
|
|
80
88
|
globalConstants: [],
|
|
81
89
|
ambigiousVoids: [],
|
|
@@ -184,9 +192,6 @@ class Config {
|
|
|
184
192
|
return v;
|
|
185
193
|
}
|
|
186
194
|
getLanguageVersion() {
|
|
187
|
-
if (this.config.syntax.languageVersion !== undefined) {
|
|
188
|
-
return this.config.syntax.languageVersion;
|
|
189
|
-
}
|
|
190
195
|
const v = this.config.syntax.version;
|
|
191
196
|
if (v !== undefined && typeof v !== "string") {
|
|
192
197
|
return v.language;
|
|
@@ -211,7 +216,10 @@ class Config {
|
|
|
211
216
|
return;
|
|
212
217
|
}
|
|
213
218
|
if (version === version_1.Version.Cloud) {
|
|
214
|
-
this.config.syntax.
|
|
219
|
+
this.config.syntax.version = {
|
|
220
|
+
release: version_1.Release.Newest.name,
|
|
221
|
+
language: version_1.LanguageVersion.Cloud,
|
|
222
|
+
};
|
|
215
223
|
}
|
|
216
224
|
// OpenABAP keeps its own version identity; open-abap-ness is derived from the
|
|
217
225
|
// release in getOpenABAP() rather than a separate stored flag.
|
|
@@ -155,9 +155,8 @@ class DataDefinition extends _abstract_object_1.AbstractObject {
|
|
|
155
155
|
}
|
|
156
156
|
if (found === undefined) {
|
|
157
157
|
// typed virtual element: VIRTUAL <name> : <type>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
found = names[0];
|
|
158
|
+
if (e.findDirectTokenByText("VIRTUAL") !== undefined) {
|
|
159
|
+
found = e.findFirstExpression(expressions_1.CDSName);
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
if (found === undefined) {
|
package/build/src/registry.js
CHANGED
|
@@ -92,17 +92,22 @@ class BeginEndNames extends _abap_rule_1.ABAPRule {
|
|
|
92
92
|
test(stru, type, b, e, file) {
|
|
93
93
|
const output = [];
|
|
94
94
|
for (const sub of stru.findAllStructuresRecursive(type)) {
|
|
95
|
-
|
|
95
|
+
const beginStatement = sub.findDirectStatement(b);
|
|
96
|
+
const endStatement = sub.findDirectStatement(e);
|
|
97
|
+
if (beginStatement === undefined || endStatement === undefined) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
let begin = beginStatement.findFirstExpression(Expressions.NamespaceSimpleName);
|
|
96
101
|
if (begin === undefined) {
|
|
97
|
-
begin =
|
|
102
|
+
begin = beginStatement.findFirstExpression(Expressions.DefinitionName);
|
|
98
103
|
}
|
|
99
104
|
if (begin === undefined) {
|
|
100
105
|
continue;
|
|
101
106
|
}
|
|
102
107
|
const first = begin.getFirstToken();
|
|
103
|
-
let end =
|
|
108
|
+
let end = endStatement.findFirstExpression(Expressions.NamespaceSimpleName);
|
|
104
109
|
if (end === undefined) {
|
|
105
|
-
end =
|
|
110
|
+
end = endStatement.findFirstExpression(Expressions.DefinitionName);
|
|
106
111
|
}
|
|
107
112
|
if (end === undefined) {
|
|
108
113
|
continue;
|
|
@@ -2984,7 +2984,7 @@ ${indentation} output = ${uniqueName}.\n`;
|
|
|
2984
2984
|
}
|
|
2985
2985
|
}
|
|
2986
2986
|
}
|
|
2987
|
-
if (fix === undefined
|
|
2987
|
+
if (fix === undefined) {
|
|
2988
2988
|
const found = high.findFirstExpression(Expressions.NewObject);
|
|
2989
2989
|
if (found === undefined) {
|
|
2990
2990
|
return undefined;
|
|
@@ -55,12 +55,13 @@ class DynproChecks {
|
|
|
55
55
|
const ret = [];
|
|
56
56
|
for (let index = 0; index < dynpro.fields.length; index++) {
|
|
57
57
|
const current = dynpro.fields[index];
|
|
58
|
-
if (current.name === undefined || current.type === "FRAME") {
|
|
58
|
+
if (current.name === undefined || current.type === "FRAME" || this.hasContainerRelativeCoordinates(current)) {
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
61
|
for (let compare = index + 1; compare < dynpro.fields.length; compare++) {
|
|
62
62
|
const other = dynpro.fields[compare];
|
|
63
|
-
if (other.name === undefined || other.type === "FRAME" || this.
|
|
63
|
+
if (other.name === undefined || other.type === "FRAME" || this.hasContainerRelativeCoordinates(other)
|
|
64
|
+
|| this.overlaps(current, other) === false) {
|
|
64
65
|
continue;
|
|
65
66
|
}
|
|
66
67
|
const message = `Screen ${dynpro.number}, ${current.type} ${current.name} and ${other.type} ${other.name} are overlapping`;
|
|
@@ -69,6 +70,9 @@ class DynproChecks {
|
|
|
69
70
|
}
|
|
70
71
|
return ret;
|
|
71
72
|
}
|
|
73
|
+
hasContainerRelativeCoordinates(field) {
|
|
74
|
+
return field.contType === "TABLE_CTRL" || field.contType === "LOOP";
|
|
75
|
+
}
|
|
72
76
|
overlaps(first, second) {
|
|
73
77
|
if (first.line === 0 || second.line === 0 || first.column === 0 || second.column === 0) {
|
|
74
78
|
return false;
|
|
@@ -39,7 +39,6 @@ const Expressions = __importStar(require("../abap/2_statements/expressions"));
|
|
|
39
39
|
const _abap_rule_1 = require("./_abap_rule");
|
|
40
40
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
41
41
|
const issue_1 = require("../issue");
|
|
42
|
-
const tokens_1 = require("../abap/1_lexer/tokens");
|
|
43
42
|
const expressions_1 = require("../abap/2_statements/expressions");
|
|
44
43
|
const _irule_1 = require("./_irule");
|
|
45
44
|
class NamesNoDashConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
@@ -79,32 +78,26 @@ class NamesNoDash extends _abap_rule_1.ABAPRule {
|
|
|
79
78
|
if (obj.getType() !== "CLAS" && obj.getType() !== "INTF") {
|
|
80
79
|
for (const form of struc.findAllStatements(Statements.Form)) {
|
|
81
80
|
const expr = form.findFirstExpression(expressions_1.FormName);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
81
|
+
const token = expr === null || expr === void 0 ? void 0 : expr.findDirectTokenByText("-");
|
|
82
|
+
if (token) {
|
|
83
|
+
const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
|
|
84
|
+
issues.push(issue);
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
for (const form of struc.findAllStatements(Statements.Parameter)) {
|
|
91
88
|
const expr = form.findFirstExpression(Expressions.FieldSub);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
89
|
+
const token = expr === null || expr === void 0 ? void 0 : expr.findDirectTokenByText("-");
|
|
90
|
+
if (token) {
|
|
91
|
+
const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
|
|
92
|
+
issues.push(issue);
|
|
98
93
|
}
|
|
99
94
|
}
|
|
100
95
|
for (const form of struc.findAllStatements(Statements.SelectOption)) {
|
|
101
96
|
const expr = form.findFirstExpression(Expressions.FieldSub);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
97
|
+
const token = expr === null || expr === void 0 ? void 0 : expr.findDirectTokenByText("-");
|
|
98
|
+
if (token) {
|
|
99
|
+
const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
|
|
100
|
+
issues.push(issue);
|
|
108
101
|
}
|
|
109
102
|
}
|
|
110
103
|
}
|
|
@@ -394,11 +394,11 @@ ENDIF.`,
|
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
else {
|
|
397
|
-
const classNameExpression = staNode.
|
|
398
|
-
const methodNameExpression = staNode.
|
|
399
|
-
if (classNameExpression
|
|
400
|
-
const className = classNameExpression
|
|
401
|
-
const methodName = methodNameExpression
|
|
397
|
+
const classNameExpression = staNode.findFirstExpression(Expressions.ClassName);
|
|
398
|
+
const methodNameExpression = staNode.findFirstExpression(Expressions.MethodName);
|
|
399
|
+
if (classNameExpression && methodNameExpression) {
|
|
400
|
+
const className = classNameExpression.concatTokens();
|
|
401
|
+
const methodName = methodNameExpression.concatTokens();
|
|
402
402
|
if (className === "cl_abap_regex") {
|
|
403
403
|
if (methodName === "create_posix") {
|
|
404
404
|
const issue = issue_1.Issue.atStatement(file, staNode, "create_posix obsolete, use create_pcre", this.getMetadata().key, this.conf.severity);
|
|
@@ -87,12 +87,12 @@ class ShortCase extends _abap_rule_1.ABAPRule {
|
|
|
87
87
|
return [];
|
|
88
88
|
}
|
|
89
89
|
for (const c of struc.findAllStructures(Structures.Case)) {
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
90
|
+
const caseStatement = c.findDirectStatement(Statements.Case);
|
|
91
|
+
if (caseStatement && this.conf.allow && this.conf.allow.find((e) => { return e === caseStatement.getTokens()[1].getStr(); })) {
|
|
92
92
|
continue;
|
|
93
93
|
}
|
|
94
94
|
if (c.findDirectStructures(Structures.When).length <= this.conf.length) {
|
|
95
|
-
if (c.
|
|
95
|
+
if (c.findFirstExpression(Expressions.Or)) {
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
98
|
const issue = issue_1.Issue.atToken(file, c.getFirstToken(), this.getMessage(), this.getMetadata().key, this.conf.severity);
|
|
@@ -40,9 +40,9 @@ class TryWithoutCatch extends _abap_rule_1.ABAPRule {
|
|
|
40
40
|
}
|
|
41
41
|
const tries = stru.findAllStructures(structures_1.Try);
|
|
42
42
|
for (const t of tries) {
|
|
43
|
-
const clean = t.
|
|
44
|
-
const c = t.
|
|
45
|
-
if (c
|
|
43
|
+
const clean = t.findDirectStructure(structures_1.Cleanup);
|
|
44
|
+
const c = t.findDirectStructure(structures_1.Catch);
|
|
45
|
+
if (c === undefined && clean === undefined) {
|
|
46
46
|
const issue = issue_1.Issue.atToken(file, t.getFirstToken(), this.getMessage(), this.getMetadata().key, this.conf.severity);
|
|
47
47
|
issues.push(issue);
|
|
48
48
|
}
|
|
@@ -42,6 +42,7 @@ const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
|
42
42
|
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
43
43
|
const _irule_1 = require("./_irule");
|
|
44
44
|
const edit_helper_1 = require("../edit_helper");
|
|
45
|
+
const tokens_1 = require("../abap/1_lexer/tokens");
|
|
45
46
|
class UnnecessaryPragmaConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
46
47
|
constructor() {
|
|
47
48
|
super(...arguments);
|
|
@@ -110,6 +111,17 @@ DATA: BEGIN OF blah ##NEEDED,
|
|
|
110
111
|
for (let i = 0; i < statements.length; i++) {
|
|
111
112
|
const statement = statements[i];
|
|
112
113
|
const nextStatement = statements[i + 1];
|
|
114
|
+
if (statement.get() instanceof _statement_1.Empty
|
|
115
|
+
&& statement.getChildren().length === 1) {
|
|
116
|
+
const tokens = statement.getTokens();
|
|
117
|
+
if (tokens.length === 1
|
|
118
|
+
&& tokens[0] instanceof tokens_1.Pragma) {
|
|
119
|
+
const message = "Pragma without a statement can be removed";
|
|
120
|
+
const fix = edit_helper_1.EditHelper.deleteToken(file, tokens[0]);
|
|
121
|
+
issues.push(issue_1.Issue.atToken(file, tokens[0], message, this.getMetadata().key, this.conf.severity, fix));
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
113
125
|
if (statement.get() instanceof Statements.EndTry) {
|
|
114
126
|
noHandler = false;
|
|
115
127
|
}
|
package/build/src/skip_logic.js
CHANGED
|
@@ -6,9 +6,11 @@ const include_graph_1 = require("./utils/include_graph");
|
|
|
6
6
|
class SkipLogic {
|
|
7
7
|
constructor(reg) {
|
|
8
8
|
this.reg = reg;
|
|
9
|
+
this.includeGraph = undefined;
|
|
9
10
|
this.tobj = undefined;
|
|
10
11
|
}
|
|
11
12
|
skip(obj) {
|
|
13
|
+
var _a;
|
|
12
14
|
const global = this.reg.getConfig().getGlobal();
|
|
13
15
|
if (global.skipGeneratedGatewayClasses === true
|
|
14
16
|
&& obj instanceof objects_1.Class
|
|
@@ -18,9 +20,9 @@ class SkipLogic {
|
|
|
18
20
|
else if (global.skipIncludesWithoutMain === true
|
|
19
21
|
&& obj instanceof objects_1.Program
|
|
20
22
|
&& obj.isInclude() === true) {
|
|
21
|
-
|
|
23
|
+
(_a = this.includeGraph) !== null && _a !== void 0 ? _a : (this.includeGraph = new include_graph_1.IncludeGraph(this.reg));
|
|
22
24
|
const file = obj.getMainABAPFile();
|
|
23
|
-
if (file &&
|
|
25
|
+
if (file && this.includeGraph.listMainForInclude(file.getFilename()).length === 0) {
|
|
24
26
|
return true;
|
|
25
27
|
}
|
|
26
28
|
}
|