@abaplint/core 2.82.11 → 2.82.15
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 +11 -17
- package/build/src/abap/5_syntax/_object_oriented.js +12 -0
- package/build/src/abap/5_syntax/statements/get_badi.js +1 -1
- package/build/src/abap/5_syntax/structures/type_enum.js +2 -1
- package/build/src/abap/types/class_definition.js +1 -0
- package/build/src/issue.js +2 -1
- package/build/src/objects/concepts_of_package.js +1 -0
- package/build/src/objects/namespace.js +1 -0
- package/build/src/objects/web_mime.js +1 -0
- package/build/src/registry.js +1 -1
- package/build/src/rules/allowed_object_naming.js +6 -5
- package/build/src/rules/space_before_colon.js +7 -3
- package/build/src/rules/unnecessary_chaining.js +15 -5
- package/package.json +4 -4
package/build/abaplint.d.ts
CHANGED
|
@@ -879,10 +879,7 @@ declare class ConcatenatedConstant extends Expression {
|
|
|
879
879
|
|
|
880
880
|
declare class ConceptsOfPackage extends AbstractObject {
|
|
881
881
|
getType(): string;
|
|
882
|
-
getAllowedNaming():
|
|
883
|
-
maxLength: number;
|
|
884
|
-
allowNamespace: boolean;
|
|
885
|
-
};
|
|
882
|
+
getAllowedNaming(): IAllowedNaming;
|
|
886
883
|
getDescription(): string | undefined;
|
|
887
884
|
}
|
|
888
885
|
|
|
@@ -2347,12 +2344,15 @@ declare interface IAliases {
|
|
|
2347
2344
|
getAll(): readonly Alias[];
|
|
2348
2345
|
}
|
|
2349
2346
|
|
|
2347
|
+
declare interface IAllowedNaming {
|
|
2348
|
+
maxLength: number;
|
|
2349
|
+
allowNamespace: boolean;
|
|
2350
|
+
customRegex?: RegExp;
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2350
2353
|
declare interface IArtifact {
|
|
2351
2354
|
getType(): string;
|
|
2352
|
-
getAllowedNaming():
|
|
2353
|
-
maxLength: number;
|
|
2354
|
-
allowNamespace: boolean;
|
|
2355
|
-
};
|
|
2355
|
+
getAllowedNaming(): IAllowedNaming;
|
|
2356
2356
|
}
|
|
2357
2357
|
|
|
2358
2358
|
declare interface IAttributes {
|
|
@@ -3150,7 +3150,7 @@ export declare class Issue {
|
|
|
3150
3150
|
static atRow(file: IFile, row: number, message: string, key: string, severity?: Severity): Issue;
|
|
3151
3151
|
static atStatement(file: IFile, statement: StatementNode, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
|
|
3152
3152
|
static atPosition(file: IFile, start: Position, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
|
|
3153
|
-
static atRowRange(file: IFile, row: number, startCol: number, endCol: number, message: string, key: string, severity?: Severity): Issue;
|
|
3153
|
+
static atRowRange(file: IFile, row: number, startCol: number, endCol: number, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
|
|
3154
3154
|
static atRange(file: IFile, start: Position, end: Position, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
|
|
3155
3155
|
static atToken(file: IFile, token: Token, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
|
|
3156
3156
|
static atIdentifier(identifier: Identifier, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
|
|
@@ -3608,10 +3608,7 @@ declare class Multiply implements IStatement {
|
|
|
3608
3608
|
|
|
3609
3609
|
declare class Namespace extends AbstractObject {
|
|
3610
3610
|
getType(): string;
|
|
3611
|
-
getAllowedNaming():
|
|
3612
|
-
maxLength: number;
|
|
3613
|
-
allowNamespace: boolean;
|
|
3614
|
-
};
|
|
3611
|
+
getAllowedNaming(): IAllowedNaming;
|
|
3615
3612
|
getDescription(): string | undefined;
|
|
3616
3613
|
}
|
|
3617
3614
|
|
|
@@ -5911,10 +5908,7 @@ declare class WebDynproComponentConfiguration extends AbstractObject {
|
|
|
5911
5908
|
|
|
5912
5909
|
declare class WebMIME extends AbstractObject {
|
|
5913
5910
|
getType(): string;
|
|
5914
|
-
getAllowedNaming():
|
|
5915
|
-
maxLength: number;
|
|
5916
|
-
allowNamespace: boolean;
|
|
5917
|
-
};
|
|
5911
|
+
getAllowedNaming(): IAllowedNaming;
|
|
5918
5912
|
getDescription(): string | undefined;
|
|
5919
5913
|
}
|
|
5920
5914
|
|
|
@@ -44,6 +44,18 @@ class ObjectOriented {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
addAliasedTypes(aliases) {
|
|
48
|
+
for (const alias of aliases.getAll()) {
|
|
49
|
+
const comp = alias.getComponent();
|
|
50
|
+
const idef = this.scope.findInterfaceDefinition(comp.split("~")[0]);
|
|
51
|
+
if (idef) {
|
|
52
|
+
const found = idef.getTypeDefinitions().getByName(comp.split("~")[1]);
|
|
53
|
+
if (found) {
|
|
54
|
+
this.scope.addTypeNamed(alias.getName(), found);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
47
59
|
findMethodInInterface(interfaceName, methodName) {
|
|
48
60
|
const idef = this.scope.findInterfaceDefinition(interfaceName);
|
|
49
61
|
if (idef) {
|
|
@@ -7,7 +7,7 @@ const target_1 = require("../expressions/target");
|
|
|
7
7
|
const dynamic_1 = require("../expressions/dynamic");
|
|
8
8
|
class GetBadi {
|
|
9
9
|
runSyntax(node, scope, filename) {
|
|
10
|
-
for (const s of node.
|
|
10
|
+
for (const s of node.findAllExpressions(Expressions.Source)) {
|
|
11
11
|
new source_1.Source().runSyntax(s, scope, filename);
|
|
12
12
|
}
|
|
13
13
|
for (const t of node.findDirectExpressions(Expressions.Target)) {
|
|
@@ -11,7 +11,7 @@ const enum_type_1 = require("../../types/basic/enum_type");
|
|
|
11
11
|
class TypeEnum {
|
|
12
12
|
runSyntax(node, scope, filename) {
|
|
13
13
|
var _a;
|
|
14
|
-
|
|
14
|
+
let values = [];
|
|
15
15
|
const types = [];
|
|
16
16
|
if (!(node.get() instanceof Structures.TypeEnum)) {
|
|
17
17
|
throw new Error("TypeEnum, unexpected type");
|
|
@@ -61,6 +61,7 @@ class TypeEnum {
|
|
|
61
61
|
type: r.getType(),
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
+
values = [];
|
|
64
65
|
const id = new _typed_identifier_1.TypedIdentifier(stru.getFirstToken(), filename, new basic_1.StructureType(components), ["enum" /* Enum */]);
|
|
65
66
|
values.push(id);
|
|
66
67
|
}
|
|
@@ -32,6 +32,7 @@ class ClassDefinition extends _identifier_1.Identifier {
|
|
|
32
32
|
this.parse(filename, scope);
|
|
33
33
|
const helper = new _object_oriented_1.ObjectOriented(scope);
|
|
34
34
|
helper.fromSuperClassesAndInterfaces(this);
|
|
35
|
+
helper.addAliasedTypes(this.aliases);
|
|
35
36
|
this.attributes = new class_attributes_1.Attributes(this.node, this.filename, scope);
|
|
36
37
|
this.types = this.attributes.getTypes();
|
|
37
38
|
this.methodDefs = new method_definitions_1.MethodDefinitions(this.node, this.filename, scope);
|
package/build/src/issue.js
CHANGED
|
@@ -48,7 +48,7 @@ class Issue {
|
|
|
48
48
|
severity,
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
static atRowRange(file, row, startCol, endCol, message, key, severity) {
|
|
51
|
+
static atRowRange(file, row, startCol, endCol, message, key, severity, fix) {
|
|
52
52
|
const start = new position_1.Position(row, startCol);
|
|
53
53
|
const end = new position_1.Position(row, endCol);
|
|
54
54
|
severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
|
|
@@ -58,6 +58,7 @@ class Issue {
|
|
|
58
58
|
key,
|
|
59
59
|
start,
|
|
60
60
|
end,
|
|
61
|
+
fix,
|
|
61
62
|
severity,
|
|
62
63
|
});
|
|
63
64
|
}
|
package/build/src/registry.js
CHANGED
|
@@ -30,19 +30,20 @@ class AllowedObjectNaming {
|
|
|
30
30
|
}
|
|
31
31
|
run(obj) {
|
|
32
32
|
const allowed = obj.getAllowedNaming();
|
|
33
|
+
const name = obj.getName();
|
|
33
34
|
let message = "";
|
|
34
|
-
if (
|
|
35
|
+
if (name.length > allowed.maxLength) {
|
|
35
36
|
message = "Name exceeds max length";
|
|
36
37
|
}
|
|
37
|
-
else if (allowed.allowNamespace === false &&
|
|
38
|
+
else if (allowed.allowNamespace === false && name.indexOf("/") >= 0) {
|
|
38
39
|
message = "Namespace not allowed for object type";
|
|
39
40
|
}
|
|
40
|
-
else if (
|
|
41
|
-
if (
|
|
41
|
+
else if (allowed.customRegex !== undefined) {
|
|
42
|
+
if (name.match(allowed.customRegex) === null) {
|
|
42
43
|
message = "Name not allowed";
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
|
-
else if (
|
|
46
|
+
else if (name.match(/^(\/[A-Z_\d]{3,8}\/)?[A-Z_\d<> ]+$/i) === null) {
|
|
46
47
|
message = "Name not allowed";
|
|
47
48
|
}
|
|
48
49
|
if (message.length > 0) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpaceBeforeColon = exports.SpaceBeforeColonConf = void 0;
|
|
4
|
+
const position_1 = require("../position");
|
|
5
|
+
const edit_helper_1 = require("../edit_helper");
|
|
4
6
|
const issue_1 = require("../issue");
|
|
5
7
|
const _abap_rule_1 = require("./_abap_rule");
|
|
6
8
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
@@ -19,7 +21,7 @@ class SpaceBeforeColon extends _abap_rule_1.ABAPRule {
|
|
|
19
21
|
title: "Space before colon",
|
|
20
22
|
shortDescription: `Checks that there are no spaces in front of colons in chained statements.`,
|
|
21
23
|
extendedInformation: `https://docs.abapopenchecks.org/checks/80/`,
|
|
22
|
-
tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.SingleFile],
|
|
24
|
+
tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
23
25
|
badExample: `DATA : foo TYPE string.`,
|
|
24
26
|
goodExample: `DATA: foo TYPE string.`,
|
|
25
27
|
};
|
|
@@ -44,8 +46,10 @@ class SpaceBeforeColon extends _abap_rule_1.ABAPRule {
|
|
|
44
46
|
else if (token.getStr() === ":"
|
|
45
47
|
&& prev.getRow() === token.getRow()
|
|
46
48
|
&& prev.getCol() + prev.getStr().length < token.getCol()) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
+
const start = new position_1.Position(token.getRow(), prev.getEnd().getCol());
|
|
50
|
+
const end = new position_1.Position(token.getRow(), token.getStart().getCol());
|
|
51
|
+
const fix = edit_helper_1.EditHelper.deleteRange(file, start, end);
|
|
52
|
+
const issue = issue_1.Issue.atRowRange(file, start.getRow(), start.getCol(), end.getCol(), this.getMessage(), this.getMetadata().key, this.conf.severity, fix);
|
|
49
53
|
issues.push(issue);
|
|
50
54
|
}
|
|
51
55
|
prev = token;
|
|
@@ -5,6 +5,8 @@ const issue_1 = require("../issue");
|
|
|
5
5
|
const _abap_rule_1 = require("./_abap_rule");
|
|
6
6
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
7
7
|
const _irule_1 = require("./_irule");
|
|
8
|
+
const edit_helper_1 = require("../edit_helper");
|
|
9
|
+
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
8
10
|
class UnnecessaryChainingConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
9
11
|
}
|
|
10
12
|
exports.UnnecessaryChainingConf = UnnecessaryChainingConf;
|
|
@@ -19,7 +21,7 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
|
|
|
19
21
|
title: "Unnecessary Chaining",
|
|
20
22
|
shortDescription: `Find unnecessary chaining, all statements are checked`,
|
|
21
23
|
extendedInformation: ``,
|
|
22
|
-
tags: [_irule_1.RuleTag.SingleFile],
|
|
24
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
23
25
|
badExample: `WRITE: bar.`,
|
|
24
26
|
goodExample: `WRITE bar.`,
|
|
25
27
|
};
|
|
@@ -31,7 +33,7 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
|
|
|
31
33
|
this.conf = conf;
|
|
32
34
|
}
|
|
33
35
|
runParsed(file) {
|
|
34
|
-
var _a
|
|
36
|
+
var _a;
|
|
35
37
|
const issues = [];
|
|
36
38
|
const statements = file.getStatements();
|
|
37
39
|
for (let i = 0; i < statements.length; i++) {
|
|
@@ -39,16 +41,24 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
|
|
|
39
41
|
if (colon === undefined) {
|
|
40
42
|
continue;
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
// find the next non Comment statement
|
|
45
|
+
let j = 1;
|
|
46
|
+
let nextStatement = statements[i + j];
|
|
47
|
+
while ((nextStatement === null || nextStatement === void 0 ? void 0 : nextStatement.get()) instanceof _statement_1.Comment) {
|
|
48
|
+
j++;
|
|
49
|
+
nextStatement = statements[i + j];
|
|
50
|
+
}
|
|
51
|
+
const next = nextStatement === null || nextStatement === void 0 ? void 0 : nextStatement.getColon();
|
|
52
|
+
const prev = (_a = statements[i - 1]) === null || _a === void 0 ? void 0 : _a.getColon();
|
|
44
53
|
if (next !== undefined && colon.getStart().equals(next.getStart())) {
|
|
45
54
|
continue;
|
|
46
55
|
}
|
|
47
56
|
else if (prev !== undefined && colon.getStart().equals(prev.getStart())) {
|
|
48
57
|
continue;
|
|
49
58
|
}
|
|
59
|
+
const fix = edit_helper_1.EditHelper.deleteRange(file, colon.getStart(), colon.getEnd());
|
|
50
60
|
const message = "Unnecessary chaining";
|
|
51
|
-
const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key);
|
|
61
|
+
const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key, this.conf.severity, fix);
|
|
52
62
|
issues.push(issue);
|
|
53
63
|
}
|
|
54
64
|
return issues;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.82.
|
|
3
|
+
"version": "2.82.15",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://abaplint.org",
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@microsoft/api-extractor": "^7.18.
|
|
48
|
+
"@microsoft/api-extractor": "^7.18.21",
|
|
49
49
|
"@types/chai": "^4.2.22",
|
|
50
50
|
"@types/mocha": "^9.0.0",
|
|
51
|
-
"@types/node": "^16.11.
|
|
51
|
+
"@types/node": "^16.11.12",
|
|
52
52
|
"chai": "^4.3.4",
|
|
53
|
-
"eslint": "^8.
|
|
53
|
+
"eslint": "^8.4.1",
|
|
54
54
|
"mocha": "^9.1.3",
|
|
55
55
|
"c8": "^7.10.0",
|
|
56
56
|
"source-map-support": "^0.5.21",
|