@abaplint/core 2.113.137 → 2.113.138
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/src/registry.js
CHANGED
|
@@ -11,6 +11,7 @@ const _abap_object_1 = require("../objects/_abap_object");
|
|
|
11
11
|
const severity_1 = require("../severity");
|
|
12
12
|
// todo, check for cycles/circular dependencies, method findTop
|
|
13
13
|
// todo, add configurable error for multiple use includes
|
|
14
|
+
const FMXXINCLUDE = /^(\/\w+\/)?L.+XX$/;
|
|
14
15
|
function getABAPObjects(reg) {
|
|
15
16
|
const ret = [];
|
|
16
17
|
for (const o of reg.getObjects()) {
|
|
@@ -22,40 +23,33 @@ function getABAPObjects(reg) {
|
|
|
22
23
|
}
|
|
23
24
|
class Graph {
|
|
24
25
|
constructor() {
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
26
|
+
this.verticesIncludenameIndex = {};
|
|
27
|
+
this.verticesFilenameIndex = {};
|
|
28
|
+
this.edges = {};
|
|
27
29
|
}
|
|
28
30
|
addVertex(vertex) {
|
|
29
|
-
this.
|
|
31
|
+
this.verticesIncludenameIndex[vertex.includeName.toUpperCase()] = vertex;
|
|
32
|
+
this.verticesFilenameIndex[vertex.filename.toUpperCase()] = vertex;
|
|
30
33
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (v.includeName.toUpperCase() === includeName.toUpperCase()) {
|
|
34
|
-
return v;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return undefined;
|
|
34
|
+
findVertexViaIncludename(includeName) {
|
|
35
|
+
return this.verticesIncludenameIndex[includeName.toUpperCase()];
|
|
38
36
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (v.filename.toUpperCase() === filename.toUpperCase()) {
|
|
42
|
-
return v;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return undefined;
|
|
37
|
+
findVertexByFilename(filename) {
|
|
38
|
+
return this.verticesFilenameIndex[filename.toUpperCase()];
|
|
46
39
|
}
|
|
47
40
|
addEdge(from, toFilename) {
|
|
48
|
-
this.edges
|
|
41
|
+
if (this.edges[from.filename] === undefined) {
|
|
42
|
+
this.edges[from.filename] = [];
|
|
43
|
+
}
|
|
44
|
+
this.edges[from.filename].push(toFilename);
|
|
49
45
|
}
|
|
50
46
|
findTop(filename) {
|
|
51
47
|
const ret = [];
|
|
52
|
-
for (const
|
|
53
|
-
|
|
54
|
-
ret.push(...this.findTop(e.to));
|
|
55
|
-
}
|
|
48
|
+
for (const to of this.edges[filename] || []) {
|
|
49
|
+
ret.push(...this.findTop(to));
|
|
56
50
|
}
|
|
57
51
|
if (ret.length === 0) {
|
|
58
|
-
const found = this.
|
|
52
|
+
const found = this.findVertexByFilename(filename);
|
|
59
53
|
if (found !== undefined) {
|
|
60
54
|
ret.push(found);
|
|
61
55
|
}
|
|
@@ -99,19 +93,23 @@ class IncludeGraph {
|
|
|
99
93
|
this.addVertices();
|
|
100
94
|
for (const o of getABAPObjects(this.reg)) {
|
|
101
95
|
for (const f of o.getABAPFiles()) {
|
|
96
|
+
if (f.getFilename().includes(".prog.screen_") || f.getFilename().includes(".fugr.screen_")) {
|
|
97
|
+
// skip dynpro files
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
102
100
|
for (const s of f.getStatements()) {
|
|
103
101
|
if (s.get() instanceof statements_1.Include) {
|
|
104
|
-
const ifFound = s.concatTokens().toUpperCase().includes("IF FOUND");
|
|
105
102
|
const iexp = s.findFirstExpression(expressions_1.IncludeName);
|
|
106
103
|
if (iexp === undefined) {
|
|
107
104
|
throw new Error("unexpected Include node");
|
|
108
105
|
}
|
|
109
106
|
const name = iexp.getFirstToken().getStr().toUpperCase();
|
|
110
|
-
if (name.match(
|
|
107
|
+
if (name.match(FMXXINCLUDE)) { // function module XX includes, possibily namespaced
|
|
111
108
|
continue;
|
|
112
109
|
}
|
|
113
|
-
const found = this.graph.
|
|
110
|
+
const found = this.graph.findVertexViaIncludename(name);
|
|
114
111
|
if (found === undefined) {
|
|
112
|
+
const ifFound = s.concatTokens().toUpperCase().includes("IF FOUND");
|
|
115
113
|
if (ifFound === false) {
|
|
116
114
|
const issue = issue_1.Issue.atStatement(f, s, "Include " + name + " not found", new check_include_1.CheckInclude().getMetadata().key, severity_1.Severity.Error);
|
|
117
115
|
this.issues.push(issue);
|
|
@@ -131,7 +129,7 @@ class IncludeGraph {
|
|
|
131
129
|
this.findUnusedIncludes();
|
|
132
130
|
}
|
|
133
131
|
findUnusedIncludes() {
|
|
134
|
-
for (const v of this.graph.
|
|
132
|
+
for (const v of Object.values(this.graph.verticesFilenameIndex)) {
|
|
135
133
|
if (v.include === true) {
|
|
136
134
|
if (this.listMainForInclude(v.filename).length === 0) {
|
|
137
135
|
const f = this.reg.getFileByName(v.filename);
|