@abaplint/core 2.83.22 → 2.84.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 +10 -1
- package/build/src/abap/2_statements/expressions/compare.js +3 -2
- package/build/src/abap/5_syntax/_current_scope.js +8 -2
- package/build/src/abap/5_syntax/expressions/database_table.js +1 -0
- package/build/src/abap/5_syntax/spaghetti_scope.js +4 -5
- package/build/src/abap/5_syntax/statements/create_object.js +1 -0
- package/build/src/objects/icf_service.js +26 -6
- package/build/src/registry.js +1 -1
- package/build/src/rules/downport.js +11 -3
- package/build/src/rules/index.js +1 -0
- package/build/src/rules/method_length.js +9 -8
- package/build/src/rules/omit_preceding_zeros.js +47 -0
- package/build/src/rules/unknown_types.js +7 -5
- package/package.json +4 -4
package/build/abaplint.d.ts
CHANGED
|
@@ -2529,13 +2529,20 @@ declare interface IBuiltinMethod {
|
|
|
2529
2529
|
}
|
|
2530
2530
|
|
|
2531
2531
|
declare class ICFService extends AbstractObject {
|
|
2532
|
+
private parsedXML;
|
|
2532
2533
|
getType(): string;
|
|
2533
2534
|
getAllowedNaming(): {
|
|
2534
2535
|
maxLength: number;
|
|
2535
2536
|
allowNamespace: boolean;
|
|
2536
2537
|
};
|
|
2538
|
+
setDirty(): void;
|
|
2537
2539
|
getDescription(): string | undefined;
|
|
2540
|
+
getURL(): string | undefined;
|
|
2538
2541
|
getHandlerList(): string[] | undefined;
|
|
2542
|
+
parse(): {
|
|
2543
|
+
updated: boolean;
|
|
2544
|
+
runtime: number;
|
|
2545
|
+
};
|
|
2539
2546
|
}
|
|
2540
2547
|
|
|
2541
2548
|
export declare interface IClassDefinition extends IInterfaceDefinition {
|
|
@@ -3245,7 +3252,9 @@ declare interface IScopeData {
|
|
|
3245
3252
|
[name: string]: TypedIdentifier;
|
|
3246
3253
|
};
|
|
3247
3254
|
deferred: Token[];
|
|
3248
|
-
cdefs:
|
|
3255
|
+
cdefs: {
|
|
3256
|
+
[name: string]: IClassDefinition;
|
|
3257
|
+
};
|
|
3249
3258
|
idefs: IInterfaceDefinition[];
|
|
3250
3259
|
forms: IFormDefinition[];
|
|
3251
3260
|
references: IReference[];
|
|
@@ -10,11 +10,12 @@ class Compare extends combi_1.Expression {
|
|
|
10
10
|
const val = (0, combi_1.altPrio)(_1.FieldSub, _1.Constant);
|
|
11
11
|
const list = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeft), val, (0, combi_1.plus)((0, combi_1.seq)(",", val)), (0, combi_1.tok)(tokens_1.ParenRightW));
|
|
12
12
|
const inn = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), "IN", (0, combi_1.altPrio)(_1.Source, list));
|
|
13
|
-
const sopt = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)("SUPPLIED", "BOUND", (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("INSTANCE OF", _1.ClassName)), "REQUESTED", "
|
|
13
|
+
const sopt = (0, combi_1.seq)("IS", (0, combi_1.optPrio)("NOT"), (0, combi_1.altPrio)("SUPPLIED", "BOUND", (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("INSTANCE OF", _1.ClassName)), "REQUESTED", "INITIAL"));
|
|
14
14
|
const between = (0, combi_1.seq)((0, combi_1.optPrio)("NOT"), "BETWEEN", _1.Source, "AND", _1.Source);
|
|
15
15
|
const predicate = (0, combi_1.ver)(version_1.Version.v740sp08, _1.MethodCallChain);
|
|
16
16
|
const rett = (0, combi_1.seq)(_1.Source, (0, combi_1.altPrio)((0, combi_1.seq)(_1.CompareOperator, _1.Source), inn, between, sopt));
|
|
17
|
-
const
|
|
17
|
+
const fsassign = (0, combi_1.seq)(_1.SourceFieldSymbol, "IS", (0, combi_1.optPrio)("NOT"), "ASSIGNED");
|
|
18
|
+
const ret = (0, combi_1.seq)((0, combi_1.opt)("NOT"), (0, combi_1.altPrio)(rett, predicate, fsassign));
|
|
18
19
|
return ret;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -74,8 +74,14 @@ class CurrentScope {
|
|
|
74
74
|
this.current.getData().extraLikeTypes[upper] = type;
|
|
75
75
|
}
|
|
76
76
|
addClassDefinition(c) {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
if (this.current === undefined) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const name = c.getName().toUpperCase();
|
|
81
|
+
if (this.current.getData().cdefs[name] !== undefined) {
|
|
82
|
+
throw new Error(`Class "${name}" already defined`);
|
|
83
|
+
}
|
|
84
|
+
this.current.getData().cdefs[name] = c;
|
|
79
85
|
}
|
|
80
86
|
addFormDefinitions(f) {
|
|
81
87
|
if (this.current === undefined) {
|
|
@@ -19,6 +19,7 @@ class DatabaseTable {
|
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
scope.addReference(token, found.getIdentifier(), _reference_1.ReferenceType.TableReference, filename);
|
|
22
|
+
scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found, token: token, filename: filename });
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
}
|
|
@@ -8,7 +8,7 @@ class ScopeData {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
this.data = {
|
|
10
10
|
vars: {},
|
|
11
|
-
cdefs:
|
|
11
|
+
cdefs: {},
|
|
12
12
|
idefs: [],
|
|
13
13
|
forms: [],
|
|
14
14
|
types: {},
|
|
@@ -68,10 +68,9 @@ class SpaghettiScopeNode extends ScopeData {
|
|
|
68
68
|
let search = this;
|
|
69
69
|
const upper = name.toUpperCase();
|
|
70
70
|
while (search !== undefined) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
71
|
+
const c = search.getData().cdefs[upper];
|
|
72
|
+
if (c !== undefined) {
|
|
73
|
+
return c;
|
|
75
74
|
}
|
|
76
75
|
search = search.getParent();
|
|
77
76
|
}
|
|
@@ -44,6 +44,7 @@ class CreateObject {
|
|
|
44
44
|
continue;
|
|
45
45
|
}
|
|
46
46
|
else if (!(found instanceof basic_1.ObjectReferenceType)
|
|
47
|
+
&& !(found instanceof basic_1.AnyType)
|
|
47
48
|
&& !(found instanceof basic_1.GenericObjectReferenceType)) {
|
|
48
49
|
throw new Error("Target must be a object reference");
|
|
49
50
|
}
|
|
@@ -13,26 +13,46 @@ class ICFService extends _abstract_object_1.AbstractObject {
|
|
|
13
13
|
allowNamespace: true,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
+
setDirty() {
|
|
17
|
+
this.parsedXML = undefined;
|
|
18
|
+
super.setDirty();
|
|
19
|
+
}
|
|
16
20
|
getDescription() {
|
|
17
21
|
// todo
|
|
18
22
|
return undefined;
|
|
19
23
|
}
|
|
20
|
-
|
|
24
|
+
getURL() {
|
|
25
|
+
var _a;
|
|
26
|
+
this.parse();
|
|
27
|
+
return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.url;
|
|
28
|
+
}
|
|
21
29
|
getHandlerList() {
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
var _a;
|
|
31
|
+
this.parse();
|
|
32
|
+
return (_a = this.parsedXML) === null || _a === void 0 ? void 0 : _a.handlers;
|
|
33
|
+
}
|
|
34
|
+
parse() {
|
|
35
|
+
if (this.parsedXML) {
|
|
36
|
+
return { updated: false, runtime: 0 };
|
|
37
|
+
}
|
|
38
|
+
const start = Date.now();
|
|
39
|
+
this.parsedXML = {};
|
|
40
|
+
const parsed = super.parseRaw2();
|
|
24
41
|
if (parsed === undefined
|
|
25
42
|
|| parsed.abapGit === undefined
|
|
26
43
|
|| parsed.abapGit["asx:abap"]["asx:values"] === undefined) {
|
|
27
|
-
return
|
|
44
|
+
return { updated: false, runtime: 0 };
|
|
28
45
|
}
|
|
29
46
|
const table = parsed.abapGit["asx:abap"]["asx:values"].ICFHANDLER_TABLE;
|
|
47
|
+
this.parsedXML.handlers = [];
|
|
30
48
|
for (const h of (0, xml_utils_1.xmlToArray)(table)) {
|
|
31
49
|
if (h.ICFHANDLER !== undefined) {
|
|
32
|
-
|
|
50
|
+
this.parsedXML.handlers.push(h.ICFHANDLER.ICFHANDLER);
|
|
33
51
|
}
|
|
34
52
|
}
|
|
35
|
-
|
|
53
|
+
this.parsedXML.url = parsed.abapGit["asx:abap"]["asx:values"].URL;
|
|
54
|
+
const end = Date.now();
|
|
55
|
+
return { updated: true, runtime: end - start };
|
|
36
56
|
}
|
|
37
57
|
}
|
|
38
58
|
exports.ICFService = ICFService;
|
package/build/src/registry.js
CHANGED
|
@@ -236,8 +236,12 @@ Only one transformation is applied to a statement at a time, so multiple steps m
|
|
|
236
236
|
if (!(low.get() instanceof _statement_1.Unknown)) {
|
|
237
237
|
return undefined;
|
|
238
238
|
}
|
|
239
|
-
// todo:
|
|
240
|
-
if (!(high.get() instanceof Statements.Select)
|
|
239
|
+
// todo: select loop
|
|
240
|
+
if (!(high.get() instanceof Statements.Select)
|
|
241
|
+
&& !(high.get() instanceof Statements.UpdateDatabase)
|
|
242
|
+
&& !(high.get() instanceof Statements.ModifyDatabase)
|
|
243
|
+
&& !(high.get() instanceof Statements.DeleteDatabase)
|
|
244
|
+
&& !(high.get() instanceof Statements.InsertDatabase)) {
|
|
241
245
|
return undefined;
|
|
242
246
|
}
|
|
243
247
|
let fix = undefined;
|
|
@@ -361,10 +365,14 @@ ${indentation}`);
|
|
|
361
365
|
}
|
|
362
366
|
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
363
367
|
const name = ((_c = inlineData.findFirstExpression(Expressions.TargetField)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "error";
|
|
364
|
-
|
|
368
|
+
let fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getStart(), `TYPES: BEGIN OF ${uniqueName},
|
|
365
369
|
${fieldDefinitions}${indentation} END OF ${uniqueName}.
|
|
366
370
|
${indentation}DATA ${name} TYPE STANDARD TABLE OF ${uniqueName} WITH DEFAULT KEY.
|
|
367
371
|
${indentation}`);
|
|
372
|
+
if (fieldDefinitions === "") {
|
|
373
|
+
fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getStart(), `DATA ${name} TYPE STANDARD TABLE OF ${tableName} WITH DEFAULT KEY.
|
|
374
|
+
${indentation}`);
|
|
375
|
+
}
|
|
368
376
|
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, inlineData.getFirstToken().getStart(), inlineData.getLastToken().getEnd(), name);
|
|
369
377
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
370
378
|
return issue_1.Issue.atToken(lowFile, inlineData.getFirstToken(), "Outline SELECT @DATA", this.getMetadata().key, this.conf.severity, fix);
|
package/build/src/rules/index.js
CHANGED
|
@@ -100,6 +100,7 @@ __exportStar(require("./no_yoda_conditions"), exports);
|
|
|
100
100
|
__exportStar(require("./object_naming"), exports);
|
|
101
101
|
__exportStar(require("./obsolete_statement"), exports);
|
|
102
102
|
__exportStar(require("./omit_parameter_name"), exports);
|
|
103
|
+
__exportStar(require("./omit_preceding_zeros"), exports);
|
|
103
104
|
__exportStar(require("./omit_receiving"), exports);
|
|
104
105
|
__exportStar(require("./parser_702_chaining"), exports);
|
|
105
106
|
__exportStar(require("./parser_error"), exports);
|
|
@@ -38,13 +38,13 @@ class MethodLength {
|
|
|
38
38
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
getDescription(issueType, actual) {
|
|
41
|
+
getDescription(issueType, actual, type) {
|
|
42
42
|
switch (issueType) {
|
|
43
43
|
case IssueType.EmptyMethod: {
|
|
44
|
-
return "Empty
|
|
44
|
+
return "Empty " + type;
|
|
45
45
|
}
|
|
46
46
|
case IssueType.MaxStatements: {
|
|
47
|
-
return "Reduce
|
|
47
|
+
return "Reduce " + type + " length to max " + this.conf.statements + " statements, currently " + actual;
|
|
48
48
|
}
|
|
49
49
|
default: {
|
|
50
50
|
return "";
|
|
@@ -62,15 +62,16 @@ class MethodLength {
|
|
|
62
62
|
}
|
|
63
63
|
run(obj) {
|
|
64
64
|
const methodStats = method_length_stats_1.MethodLengthStats.run(obj);
|
|
65
|
-
const methodIssues = this.check(methodStats);
|
|
65
|
+
const methodIssues = this.check(methodStats, "METHOD");
|
|
66
66
|
let formIssues = [];
|
|
67
67
|
if (this.conf.checkForms) {
|
|
68
68
|
const formStats = form_length_stats_1.FormLengthStats.run(obj);
|
|
69
|
-
formIssues = this.check(formStats);
|
|
69
|
+
formIssues = this.check(formStats, "FORM");
|
|
70
70
|
}
|
|
71
71
|
return methodIssues.concat(formIssues);
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
// ***********************
|
|
74
|
+
check(stats, type) {
|
|
74
75
|
const issues = [];
|
|
75
76
|
for (const s of stats) {
|
|
76
77
|
if ((this.conf.ignoreTestClasses === true)
|
|
@@ -78,12 +79,12 @@ class MethodLength {
|
|
|
78
79
|
continue;
|
|
79
80
|
}
|
|
80
81
|
if (s.count === 0 && this.conf.errorWhenEmpty === true) {
|
|
81
|
-
const issue = issue_1.Issue.atPosition(s.file, s.pos, this.getDescription(IssueType.EmptyMethod, "0"), this.getMetadata().key, this.conf.severity);
|
|
82
|
+
const issue = issue_1.Issue.atPosition(s.file, s.pos, this.getDescription(IssueType.EmptyMethod, "0", type), this.getMetadata().key, this.conf.severity);
|
|
82
83
|
issues.push(issue);
|
|
83
84
|
continue;
|
|
84
85
|
}
|
|
85
86
|
if (s.count > this.conf.statements) {
|
|
86
|
-
const message = this.getDescription(IssueType.MaxStatements, s.count.toString());
|
|
87
|
+
const message = this.getDescription(IssueType.MaxStatements, s.count.toString(), type);
|
|
87
88
|
const issue = issue_1.Issue.atPosition(s.file, s.pos, message, this.getMetadata().key, this.conf.severity);
|
|
88
89
|
issues.push(issue);
|
|
89
90
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmitPrecedingZeros = exports.OmitPrecedingZerosConf = void 0;
|
|
4
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
5
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
6
|
+
const issue_1 = require("../issue");
|
|
7
|
+
const Expressions = require("../abap/2_statements/expressions");
|
|
8
|
+
const _irule_1 = require("./_irule");
|
|
9
|
+
class OmitPrecedingZerosConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
10
|
+
}
|
|
11
|
+
exports.OmitPrecedingZerosConf = OmitPrecedingZerosConf;
|
|
12
|
+
class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.conf = new OmitPrecedingZerosConf();
|
|
16
|
+
}
|
|
17
|
+
getMetadata() {
|
|
18
|
+
return {
|
|
19
|
+
key: "omit_preceding_zeros",
|
|
20
|
+
title: "Omit preceding zeros",
|
|
21
|
+
shortDescription: `Omit preceding zeros from integer constants`,
|
|
22
|
+
tags: [_irule_1.RuleTag.SingleFile],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
getConfig() {
|
|
26
|
+
return this.conf;
|
|
27
|
+
}
|
|
28
|
+
setConfig(conf) {
|
|
29
|
+
this.conf = conf;
|
|
30
|
+
}
|
|
31
|
+
runParsed(file) {
|
|
32
|
+
var _a;
|
|
33
|
+
const issues = [];
|
|
34
|
+
for (const i of ((_a = file.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllExpressions(Expressions.Integer)) || []) {
|
|
35
|
+
const token = i.getLastToken();
|
|
36
|
+
const str = token.getStr();
|
|
37
|
+
if (str.length > 1 && str.startsWith("0")) {
|
|
38
|
+
const message = "Omit preceding zeros";
|
|
39
|
+
const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity);
|
|
40
|
+
issues.push(issue);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return issues;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.OmitPrecedingZeros = OmitPrecedingZeros;
|
|
47
|
+
//# sourceMappingURL=omit_preceding_zeros.js.map
|
|
@@ -64,14 +64,15 @@ class UnknownTypes {
|
|
|
64
64
|
traverse(node) {
|
|
65
65
|
var _a;
|
|
66
66
|
const ret = [];
|
|
67
|
-
|
|
67
|
+
const nodeData = node.getData();
|
|
68
|
+
for (const r of nodeData.references) {
|
|
68
69
|
if (r.referenceType === _reference_1.ReferenceType.ObjectOrientedUnknownReference && ((_a = r.extra) === null || _a === void 0 ? void 0 : _a.ooName)) {
|
|
69
70
|
const message = r.extra.ooName + " unknown";
|
|
70
71
|
ret.push(issue_1.Issue.atIdentifier(r.position, message, this.getMetadata().key, this.conf.severity));
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
if (node.getIdentifier().stype !== _scope_type_1.ScopeType.ClassImplementation) {
|
|
74
|
-
const vars =
|
|
75
|
+
const vars = nodeData.vars;
|
|
75
76
|
for (const name in vars) {
|
|
76
77
|
const identifier = vars[name];
|
|
77
78
|
const found = this.containsUnknown(identifier.getType());
|
|
@@ -80,7 +81,7 @@ class UnknownTypes {
|
|
|
80
81
|
ret.push(issue_1.Issue.atIdentifier(identifier, message, this.getMetadata().key, this.conf.severity));
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
const types =
|
|
84
|
+
const types = nodeData.types;
|
|
84
85
|
for (const name in types) {
|
|
85
86
|
const identifier = types[name];
|
|
86
87
|
const found = this.containsUnknown(identifier.getType());
|
|
@@ -90,14 +91,15 @@ class UnknownTypes {
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
for (const v of
|
|
94
|
+
for (const v of nodeData.idefs) {
|
|
94
95
|
const found = this.checkMethodParameters(v);
|
|
95
96
|
if (found) {
|
|
96
97
|
const message = "Contains unknown, " + found.found;
|
|
97
98
|
ret.push(issue_1.Issue.atIdentifier(found.id, message, this.getMetadata().key, this.conf.severity));
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
for (const
|
|
101
|
+
for (const name in nodeData.cdefs) {
|
|
102
|
+
const v = nodeData.cdefs[name];
|
|
101
103
|
const found = this.checkMethodParameters(v);
|
|
102
104
|
if (found) {
|
|
103
105
|
const message = "Contains unknown, " + found.found;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.84.0",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"@microsoft/api-extractor": "^7.19.4",
|
|
49
49
|
"@types/chai": "^4.3.0",
|
|
50
50
|
"@types/mocha": "^9.0.0",
|
|
51
|
-
"@types/node": "^17.0.
|
|
51
|
+
"@types/node": "^17.0.9",
|
|
52
52
|
"chai": "^4.3.4",
|
|
53
|
-
"eslint": "^8.
|
|
54
|
-
"mocha": "^9.1.
|
|
53
|
+
"eslint": "^8.7.0",
|
|
54
|
+
"mocha": "^9.1.4",
|
|
55
55
|
"c8": "^7.11.0",
|
|
56
56
|
"source-map-support": "^0.5.21",
|
|
57
57
|
"ts-json-schema-generator": "^0.97.0",
|