@abaplint/core 2.106.9 → 2.107.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/build/abaplint.d.ts
CHANGED
|
@@ -6490,10 +6490,7 @@ declare class Table extends AbstractObject {
|
|
|
6490
6490
|
private parsedData;
|
|
6491
6491
|
getType(): string;
|
|
6492
6492
|
getDescription(): string | undefined;
|
|
6493
|
-
getAllowedNaming():
|
|
6494
|
-
maxLength: number;
|
|
6495
|
-
allowNamespace: boolean;
|
|
6496
|
-
};
|
|
6493
|
+
getAllowedNaming(): IAllowedNaming;
|
|
6497
6494
|
setDirty(): void;
|
|
6498
6495
|
listKeys(reg: IRegistry): string[];
|
|
6499
6496
|
parseType(reg: IRegistry): AbstractType;
|
|
@@ -35,12 +35,14 @@ class Table extends _abstract_object_1.AbstractObject {
|
|
|
35
35
|
}
|
|
36
36
|
getAllowedNaming() {
|
|
37
37
|
let length = 30;
|
|
38
|
+
const regex = /^((\/[A-Z_\d]{3,8}\/)|[a-zA-Z0-9]{3})\w+$/;
|
|
38
39
|
if (this.getTableCategory() === TableCategory.Transparent) {
|
|
39
40
|
length = 16;
|
|
40
41
|
}
|
|
41
42
|
return {
|
|
42
43
|
maxLength: length,
|
|
43
44
|
allowNamespace: true,
|
|
45
|
+
customRegex: regex,
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
setDirty() {
|
package/build/src/registry.js
CHANGED
|
@@ -23,6 +23,8 @@ https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abencharacter_set_gui
|
|
|
23
23
|
|
|
24
24
|
Checkes files with extensions ".abap" and ".asddls"`,
|
|
25
25
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
26
|
+
badExample: `WRITE '뽑'.`,
|
|
27
|
+
goodExample: `WRITE cl_abap_conv_in_ce=>uccp( 'BF51' ).`,
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
30
|
initialize(_reg) {
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AlignTypeExpressions = exports.AlignTypeExpressionsConf = void 0;
|
|
4
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
5
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
6
|
+
const objects_1 = require("../objects");
|
|
7
|
+
const ddic_1 = require("../ddic");
|
|
8
|
+
const _irule_1 = require("./_irule");
|
|
9
|
+
const issue_1 = require("../issue");
|
|
10
|
+
const position_1 = require("../position");
|
|
11
|
+
const Expressions = require("../abap/2_statements/expressions");
|
|
12
|
+
const Statements = require("../abap/2_statements/statements");
|
|
13
|
+
const Structures = require("../abap/3_structures/structures");
|
|
14
|
+
const edit_helper_1 = require("../edit_helper");
|
|
15
|
+
class AlignTypeExpressionsConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
/** Ignore global exception classes */
|
|
19
|
+
this.ignoreExceptions = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.AlignTypeExpressionsConf = AlignTypeExpressionsConf;
|
|
23
|
+
class AlignTypeExpressions extends _abap_rule_1.ABAPRule {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.conf = new AlignTypeExpressionsConf();
|
|
27
|
+
}
|
|
28
|
+
getMetadata() {
|
|
29
|
+
return {
|
|
30
|
+
key: "align_type_expressions",
|
|
31
|
+
title: "Align TYPE expressions",
|
|
32
|
+
shortDescription: `Align TYPE expressions in statements`,
|
|
33
|
+
extendedInformation: `
|
|
34
|
+
Currently works for METHODS + BEGIN OF
|
|
35
|
+
|
|
36
|
+
If BEGIN OF has an INCLUDE TYPE its ignored
|
|
37
|
+
|
|
38
|
+
Also note that clean ABAP does not recommend aligning TYPE clauses:
|
|
39
|
+
https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-align-type-clauses`,
|
|
40
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix],
|
|
41
|
+
badExample: `
|
|
42
|
+
TYPES: BEGIN OF foo,
|
|
43
|
+
bar TYPE i,
|
|
44
|
+
foobar TYPE i,
|
|
45
|
+
END OF foo.
|
|
46
|
+
|
|
47
|
+
INTERFACE lif.
|
|
48
|
+
METHODS bar
|
|
49
|
+
IMPORTING
|
|
50
|
+
foo TYPE i
|
|
51
|
+
foobar TYPE i.
|
|
52
|
+
ENDINTERFACE.`,
|
|
53
|
+
goodExample: `
|
|
54
|
+
TYPES: BEGIN OF foo,
|
|
55
|
+
bar TYPE i,
|
|
56
|
+
foobar TYPE i,
|
|
57
|
+
END OF foo.
|
|
58
|
+
|
|
59
|
+
INTERFACE lif.
|
|
60
|
+
METHODS bar
|
|
61
|
+
IMPORTING
|
|
62
|
+
foo TYPE i
|
|
63
|
+
foobar TYPE i.
|
|
64
|
+
ENDINTERFACE.`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
getConfig() {
|
|
68
|
+
return this.conf;
|
|
69
|
+
}
|
|
70
|
+
setConfig(conf) {
|
|
71
|
+
this.conf = conf;
|
|
72
|
+
}
|
|
73
|
+
runParsed(file, obj) {
|
|
74
|
+
const issues = [];
|
|
75
|
+
const stru = file.getStructure();
|
|
76
|
+
if (stru === undefined) {
|
|
77
|
+
return issues; // parser error
|
|
78
|
+
}
|
|
79
|
+
const ddic = new ddic_1.DDIC(this.reg);
|
|
80
|
+
if (obj instanceof objects_1.Class) {
|
|
81
|
+
const definition = obj.getClassDefinition();
|
|
82
|
+
if (definition === undefined) {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
else if (this.conf.ignoreExceptions && ddic.isException(definition, obj)) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
issues.push(...this.checkTypes(stru, file));
|
|
90
|
+
issues.push(...this.checkMethods(stru, file));
|
|
91
|
+
return issues;
|
|
92
|
+
}
|
|
93
|
+
check(fields, column, file) {
|
|
94
|
+
const issues = [];
|
|
95
|
+
for (const f of fields) {
|
|
96
|
+
if (f.after.getCol() === column) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
let fix = undefined;
|
|
100
|
+
if (f.after.getCol() < column) {
|
|
101
|
+
fix = edit_helper_1.EditHelper.insertAt(file, f.after, " ".repeat(column - f.after.getCol()));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
fix = edit_helper_1.EditHelper.deleteRange(file, new position_1.Position(f.after.getRow(), column), f.after);
|
|
105
|
+
}
|
|
106
|
+
const message = `Align TYPE expressions to column ${column}`;
|
|
107
|
+
const issue = issue_1.Issue.atPosition(file, f.after, message, this.getMetadata().key, this.conf.severity, fix);
|
|
108
|
+
issues.push(issue);
|
|
109
|
+
}
|
|
110
|
+
return issues;
|
|
111
|
+
}
|
|
112
|
+
checkMethods(stru, file) {
|
|
113
|
+
const issues = [];
|
|
114
|
+
const methods = stru.findAllStatements(Statements.MethodDef);
|
|
115
|
+
for (const m of methods) {
|
|
116
|
+
const fields = [];
|
|
117
|
+
const params = m.findAllExpressions(Expressions.MethodParam);
|
|
118
|
+
let column = 0;
|
|
119
|
+
for (const p of params) {
|
|
120
|
+
const children = p.getChildren();
|
|
121
|
+
const name = children[children.length - 2];
|
|
122
|
+
fields.push({
|
|
123
|
+
nameEnd: name.getLastToken().getEnd(),
|
|
124
|
+
after: p.findFirstExpression(Expressions.TypeParam).getFirstToken().getStart()
|
|
125
|
+
});
|
|
126
|
+
column = Math.max(column, name.getFirstToken().getEnd().getCol() + 1);
|
|
127
|
+
}
|
|
128
|
+
const ret = m.findFirstExpression(Expressions.MethodDefReturning);
|
|
129
|
+
if (ret) {
|
|
130
|
+
const children = ret.getChildren();
|
|
131
|
+
const name = children[children.length - 2];
|
|
132
|
+
fields.push({
|
|
133
|
+
nameEnd: name.getLastToken().getEnd(),
|
|
134
|
+
after: ret.findFirstExpression(Expressions.TypeParam).getFirstToken().getStart()
|
|
135
|
+
});
|
|
136
|
+
column = Math.max(column, name.getLastToken().getEnd().getCol() + 1);
|
|
137
|
+
}
|
|
138
|
+
issues.push(...this.check(fields, column, file));
|
|
139
|
+
}
|
|
140
|
+
return issues;
|
|
141
|
+
}
|
|
142
|
+
checkTypes(stru, file) {
|
|
143
|
+
const issues = [];
|
|
144
|
+
const types = stru.findAllStructuresRecursive(Structures.Types);
|
|
145
|
+
for (const t of types) {
|
|
146
|
+
if (t.findDirectStatement(Statements.IncludeType)) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const fields = [];
|
|
150
|
+
let column = 0;
|
|
151
|
+
const st = t.findDirectStatements(Statements.Type);
|
|
152
|
+
for (const s of st) {
|
|
153
|
+
const name = s.getChildren()[1];
|
|
154
|
+
fields.push({
|
|
155
|
+
nameEnd: name.getLastToken().getEnd(),
|
|
156
|
+
after: s.getChildren()[2].getFirstToken().getStart()
|
|
157
|
+
});
|
|
158
|
+
column = Math.max(column, name.getFirstToken().getEnd().getCol() + 1);
|
|
159
|
+
}
|
|
160
|
+
issues.push(...this.check(fields, column, file));
|
|
161
|
+
}
|
|
162
|
+
return issues;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.AlignTypeExpressions = AlignTypeExpressions;
|
|
166
|
+
//# sourceMappingURL=align_type_expressions.js.map
|
package/build/src/rules/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./7bit_ascii"), exports);
|
|
18
18
|
__exportStar(require("./abapdoc"), exports);
|
|
19
19
|
__exportStar(require("./align_parameters"), exports);
|
|
20
|
+
__exportStar(require("./align_type_expressions"), exports);
|
|
20
21
|
__exportStar(require("./allowed_object_naming"), exports);
|
|
21
22
|
__exportStar(require("./allowed_object_types"), exports);
|
|
22
23
|
__exportStar(require("./ambiguous_statement"), exports);
|