-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathComponentClass.java
More file actions
73 lines (59 loc) · 2.26 KB
/
ComponentClass.java
File metadata and controls
73 lines (59 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package extractor;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.github.javaparser.JavaParser;
import com.github.javaparser.ParseException;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
public class ComponentClass<Object> extends VoidVisitorAdapter<Object>{
private Map<Object,List<MethodDeclaration>> methods;
private Map<Object,NodeList<ClassOrInterfaceType>> inheritance;
private Set<ClassOrInterfaceDeclaration> classes;
public ComponentClass() {
this.methods = new HashMap<Object,List<MethodDeclaration>>();
this.inheritance = (new HashMap<Object, NodeList<ClassOrInterfaceType>>());
this.classes = new HashSet<>();
}
public void visit(ClassOrInterfaceDeclaration n, Object arg) {
super.visit(n, arg);
this.getInheritance().put((Object) n.getNameAsString(), n.getExtendedTypes());
this.methods.put((Object) n.getNameAsString(), n.getMethods());
this.classes.add(n);
}
public Set<ClassOrInterfaceDeclaration> getClasses() {
return classes;
}
public void setClasses(Set<ClassOrInterfaceDeclaration> classes) {
this.classes = classes;
}
public void getAllMethods(File projectDir) throws ParseException, IOException {
new DirExplorer((level, path, file) -> path.endsWith(".java"), (level, path, file) -> {
Object a = (Object) path;
try {
this.visit(JavaParser.parse(file), a);
} catch (IOException e) {
new RuntimeException(e);
}
}).explore(projectDir);
}
public Map<Object,List<MethodDeclaration>> getMethods() {
return methods;
}
public void setMethods(Map<Object,List<MethodDeclaration>> methods) {
this.methods = methods;
}
public Map<Object,NodeList<ClassOrInterfaceType>> getInheritance() {
return inheritance;
}
public void setInheritance(Map<Object,NodeList<ClassOrInterfaceType>> inheritance) {
this.inheritance = inheritance;
}
}