@abaplint/core 2.106.8 → 2.107.0
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 +1 -4
- package/build/src/abap/5_syntax/expressions/select.js +8 -4
- package/build/src/abap/5_syntax/expressions/sql_compare.js +7 -2
- package/build/src/objects/table.js +2 -0
- package/build/src/registry.js +1 -1
- package/build/src/rules/align_type_expressions.js +140 -0
- package/build/src/rules/index.js +1 -0
- package/build/src/rules/no_prefixes.js +11 -4
- package/package.json +2 -2
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;
|
|
@@ -11,6 +11,7 @@ const _scope_type_1 = require("../_scope_type");
|
|
|
11
11
|
const sql_source_1 = require("./sql_source");
|
|
12
12
|
const sql_compare_1 = require("./sql_compare");
|
|
13
13
|
const sql_order_by_1 = require("./sql_order_by");
|
|
14
|
+
const dynamic_1 = require("./dynamic");
|
|
14
15
|
const isSimple = /^\w+$/;
|
|
15
16
|
class Select {
|
|
16
17
|
runSyntax(node, scope, filename, skipImplicitInto = false) {
|
|
@@ -21,7 +22,7 @@ class Select {
|
|
|
21
22
|
if (from === undefined) {
|
|
22
23
|
throw new Error(`Missing FROM`);
|
|
23
24
|
}
|
|
24
|
-
const fields = this.findFields(node);
|
|
25
|
+
const fields = this.findFields(node, scope, filename);
|
|
25
26
|
if (fields.length === 0
|
|
26
27
|
&& node.findDirectExpression(Expressions.SQLFieldListLoop) === undefined) {
|
|
27
28
|
throw new Error(`fields missing`);
|
|
@@ -179,17 +180,20 @@ class Select {
|
|
|
179
180
|
}
|
|
180
181
|
return new basic_1.VoidType("SELECT_todo");
|
|
181
182
|
}
|
|
182
|
-
findFields(node) {
|
|
183
|
-
var _a;
|
|
183
|
+
findFields(node, scope, filename) {
|
|
184
|
+
var _a, _b;
|
|
184
185
|
let expr = undefined;
|
|
185
186
|
const ret = [];
|
|
186
187
|
expr = node.findFirstExpression(Expressions.SQLFieldList);
|
|
187
188
|
if (expr === undefined) {
|
|
188
189
|
expr = node.findDirectExpression(Expressions.SQLFieldListLoop);
|
|
189
190
|
}
|
|
191
|
+
if (((_a = expr === null || expr === void 0 ? void 0 : expr.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.Dynamic) {
|
|
192
|
+
new dynamic_1.Dynamic().runSyntax(expr.getFirstChild(), scope, filename);
|
|
193
|
+
}
|
|
190
194
|
for (const field of (expr === null || expr === void 0 ? void 0 : expr.findDirectExpressionsMulti([Expressions.SQLField, Expressions.SQLFieldName])) || []) {
|
|
191
195
|
let code = field.concatTokens().toUpperCase();
|
|
192
|
-
const as = ((
|
|
196
|
+
const as = ((_b = field.findDirectExpression(Expressions.SQLAsName)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "";
|
|
193
197
|
if (as !== "") {
|
|
194
198
|
code = code.replace(" AS " + as, "");
|
|
195
199
|
}
|
|
@@ -4,13 +4,18 @@ exports.SQLCompare = void 0;
|
|
|
4
4
|
const Expressions = require("../../2_statements/expressions");
|
|
5
5
|
const nodes_1 = require("../../nodes");
|
|
6
6
|
const basic_1 = require("../../types/basic");
|
|
7
|
+
const dynamic_1 = require("./dynamic");
|
|
7
8
|
const source_1 = require("./source");
|
|
8
9
|
const sql_source_1 = require("./sql_source");
|
|
9
10
|
class SQLCompare {
|
|
10
11
|
runSyntax(node, scope, filename, tables) {
|
|
11
|
-
var _a;
|
|
12
|
+
var _a, _b;
|
|
12
13
|
let sourceType;
|
|
13
14
|
let token;
|
|
15
|
+
if (((_a = node.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.Dynamic) {
|
|
16
|
+
new dynamic_1.Dynamic().runSyntax(node.getFirstChild(), scope, filename);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
14
19
|
for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
|
|
15
20
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
16
21
|
}
|
|
@@ -36,7 +41,7 @@ class SQLCompare {
|
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
|
-
const fieldName = (
|
|
44
|
+
const fieldName = (_b = node.findDirectExpression(Expressions.SQLFieldName)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
40
45
|
if (fieldName && sourceType && token) {
|
|
41
46
|
// check compatibility for rule sql_value_conversion
|
|
42
47
|
const targetType = this.findType(fieldName, tables, scope);
|
|
@@ -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
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AlignTypeExpressions = exports.AlignTypeExpressionsConf = void 0;
|
|
4
|
+
const issue_1 = require("../issue");
|
|
5
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
6
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
7
|
+
const _irule_1 = require("./_irule");
|
|
8
|
+
const Structures = require("../abap/3_structures/structures");
|
|
9
|
+
const Statements = require("../abap/2_statements/statements");
|
|
10
|
+
const Expressions = require("../abap/2_statements/expressions");
|
|
11
|
+
/*
|
|
12
|
+
import {EditHelper, IEdit} from "../edit_helper";
|
|
13
|
+
*/
|
|
14
|
+
class AlignTypeExpressionsConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
15
|
+
}
|
|
16
|
+
exports.AlignTypeExpressionsConf = AlignTypeExpressionsConf;
|
|
17
|
+
class AlignTypeExpressions extends _abap_rule_1.ABAPRule {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.conf = new AlignTypeExpressionsConf();
|
|
21
|
+
}
|
|
22
|
+
getMetadata() {
|
|
23
|
+
return {
|
|
24
|
+
key: "align_type_expressions",
|
|
25
|
+
title: "Align TYPE expressions",
|
|
26
|
+
shortDescription: `Align TYPE expressions in statements`,
|
|
27
|
+
extendedInformation: `
|
|
28
|
+
Currently works for METHODS + BEGIN OF
|
|
29
|
+
|
|
30
|
+
Also note that clean ABAP does not recommend aligning TYPE clauses:
|
|
31
|
+
https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-align-type-clauses`,
|
|
32
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace],
|
|
33
|
+
badExample: `
|
|
34
|
+
TYPES: BEGIN OF foo,
|
|
35
|
+
bar TYPE i,
|
|
36
|
+
foobar TYPE i,
|
|
37
|
+
END OF foo.
|
|
38
|
+
|
|
39
|
+
INTERFACE lif.
|
|
40
|
+
METHODS bar
|
|
41
|
+
IMPORTING
|
|
42
|
+
foo TYPE i
|
|
43
|
+
foobar TYPE i.
|
|
44
|
+
ENDINTERFACE.`,
|
|
45
|
+
goodExample: `
|
|
46
|
+
TYPES: BEGIN OF foo,
|
|
47
|
+
bar TYPE i,
|
|
48
|
+
foobar TYPE i,
|
|
49
|
+
END OF foo.
|
|
50
|
+
|
|
51
|
+
INTERFACE lif.
|
|
52
|
+
METHODS bar
|
|
53
|
+
IMPORTING
|
|
54
|
+
foo TYPE i
|
|
55
|
+
foobar TYPE i.
|
|
56
|
+
ENDINTERFACE.`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
getConfig() {
|
|
60
|
+
return this.conf;
|
|
61
|
+
}
|
|
62
|
+
setConfig(conf) {
|
|
63
|
+
this.conf = conf;
|
|
64
|
+
}
|
|
65
|
+
runParsed(file) {
|
|
66
|
+
const issues = [];
|
|
67
|
+
const stru = file.getStructure();
|
|
68
|
+
if (stru === undefined) {
|
|
69
|
+
return issues; // parser error
|
|
70
|
+
}
|
|
71
|
+
issues.push(...this.checkTypes(stru, file));
|
|
72
|
+
issues.push(...this.checkMethods(stru, file));
|
|
73
|
+
return issues;
|
|
74
|
+
}
|
|
75
|
+
checkMethods(stru, file) {
|
|
76
|
+
const issues = [];
|
|
77
|
+
const methods = stru.findAllStatements(Statements.MethodDef);
|
|
78
|
+
for (const m of methods) {
|
|
79
|
+
const fields = [];
|
|
80
|
+
const params = m.findAllExpressions(Expressions.MethodParam);
|
|
81
|
+
let column = 0;
|
|
82
|
+
for (const p of params) {
|
|
83
|
+
const children = p.getChildren();
|
|
84
|
+
const name = children[children.length - 2];
|
|
85
|
+
fields.push({
|
|
86
|
+
nameEnd: name.getLastToken().getEnd(),
|
|
87
|
+
after: p.findFirstExpression(Expressions.TypeParam).getFirstToken().getStart()
|
|
88
|
+
});
|
|
89
|
+
column = Math.max(column, name.getFirstToken().getEnd().getCol() + 1);
|
|
90
|
+
}
|
|
91
|
+
const ret = m.findFirstExpression(Expressions.MethodDefReturning);
|
|
92
|
+
if (ret) {
|
|
93
|
+
const children = ret.getChildren();
|
|
94
|
+
const name = children[children.length - 2];
|
|
95
|
+
fields.push({
|
|
96
|
+
nameEnd: name.getLastToken().getEnd(),
|
|
97
|
+
after: ret.findFirstExpression(Expressions.TypeParam).getFirstToken().getStart()
|
|
98
|
+
});
|
|
99
|
+
column = Math.max(column, name.getLastToken().getEnd().getCol() + 1);
|
|
100
|
+
}
|
|
101
|
+
for (const f of fields) {
|
|
102
|
+
if (f.after.getCol() !== column) {
|
|
103
|
+
// const fix = this.buildFix(f.name, column);
|
|
104
|
+
const message = `Align TYPE expressions to column ${column}`;
|
|
105
|
+
const issue = issue_1.Issue.atPosition(file, f.after, message, this.getMetadata().key, this.conf.severity);
|
|
106
|
+
issues.push(issue);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return issues;
|
|
111
|
+
}
|
|
112
|
+
checkTypes(stru, file) {
|
|
113
|
+
const issues = [];
|
|
114
|
+
const types = stru.findAllStructuresRecursive(Structures.Types);
|
|
115
|
+
for (const t of types) {
|
|
116
|
+
const fields = [];
|
|
117
|
+
let column = 0;
|
|
118
|
+
const st = t.findDirectStatements(Statements.Type);
|
|
119
|
+
for (const s of st) {
|
|
120
|
+
const name = s.getChildren()[1];
|
|
121
|
+
fields.push({
|
|
122
|
+
nameEnd: name.getLastToken().getEnd(),
|
|
123
|
+
after: s.getChildren()[2].getFirstToken().getStart()
|
|
124
|
+
});
|
|
125
|
+
column = Math.max(column, name.getFirstToken().getEnd().getCol() + 1);
|
|
126
|
+
}
|
|
127
|
+
for (const f of fields) {
|
|
128
|
+
if (f.after.getCol() !== column) {
|
|
129
|
+
// const fix = this.buildFix(f.name, column);
|
|
130
|
+
const message = `Align TYPE expressions to column ${column}`;
|
|
131
|
+
const issue = issue_1.Issue.atPosition(file, f.after, message, this.getMetadata().key, this.conf.severity);
|
|
132
|
+
issues.push(issue);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return issues;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.AlignTypeExpressions = AlignTypeExpressions;
|
|
140
|
+
//# 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);
|
|
@@ -22,6 +22,7 @@ class NoPrefixesConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
|
22
22
|
this.types = "^TY_";
|
|
23
23
|
/** importing, exporting, returning and changing parameters, case insensitive regex */
|
|
24
24
|
this.methodParameters = "^[ICER].?_";
|
|
25
|
+
this.allowIsPrefixBoolean = true;
|
|
25
26
|
// todo, public localClass: string = "";
|
|
26
27
|
// todo, public localInterface: string = "";
|
|
27
28
|
// todo, public functionModuleParameters: string = "";
|
|
@@ -166,12 +167,18 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/sub-sections/AvoidEncodi
|
|
|
166
167
|
return ret;
|
|
167
168
|
}
|
|
168
169
|
checkMethodParameters(topNode, regex, file) {
|
|
170
|
+
var _a, _b;
|
|
169
171
|
const ret = [];
|
|
170
172
|
for (const method of topNode.findAllStatements(Statements.MethodDef)) {
|
|
171
|
-
for (const
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
for (const param of method.findAllExpressionsMulti([Expressions.MethodDefReturning, Expressions.MethodParam])) {
|
|
174
|
+
const nameToken = param === null || param === void 0 ? void 0 : param.findFirstExpression(Expressions.MethodParamName);
|
|
175
|
+
const type = (_b = (_a = param === null || param === void 0 ? void 0 : param.findFirstExpression(Expressions.TypeParam)) === null || _a === void 0 ? void 0 : _a.concatTokens()) === null || _b === void 0 ? void 0 : _b.toUpperCase();
|
|
176
|
+
if (this.getConfig().allowIsPrefixBoolean === true && (type === null || type === void 0 ? void 0 : type.endsWith("TYPE ABAP_BOOL"))) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.concatTokens();
|
|
180
|
+
if (nameToken && name && name !== "" && name.match(regex)) {
|
|
181
|
+
const issue = issue_1.Issue.atToken(file, nameToken.getFirstToken(), MESSAGE, this.getMetadata().key, this.conf.severity);
|
|
175
182
|
ret.push(issue);
|
|
176
183
|
}
|
|
177
184
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.107.0",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"mocha": "^10.4.0",
|
|
60
60
|
"c8": "^9.1.0",
|
|
61
61
|
"source-map-support": "^0.5.21",
|
|
62
|
-
"ts-json-schema-generator": "
|
|
62
|
+
"ts-json-schema-generator": "=2.0.1",
|
|
63
63
|
"typescript": "^5.4.5"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|