47 lines
1.0 KiB
Java
47 lines
1.0 KiB
Java
package ch.usi.inf.sp.callgraph;
|
|
|
|
import ch.usi.inf.sp.framework.ClassAnalyzer;
|
|
import org.objectweb.asm.tree.ClassNode;
|
|
|
|
|
|
/**
|
|
* Build a class hierarchy (including methods).
|
|
*
|
|
* @author ?
|
|
* @author Matthias.Hauswirth@usi.ch
|
|
*/
|
|
public final class ClassHierarchyBuilder implements ClassAnalyzer {
|
|
|
|
private final ClassHierarchy classHierarchy;
|
|
|
|
|
|
public ClassHierarchyBuilder() {
|
|
this.classHierarchy = new ClassHierarchy();
|
|
}
|
|
|
|
public ClassHierarchy getClassHierarchy() {
|
|
return classHierarchy;
|
|
}
|
|
|
|
public void analyze(final String location, final ClassNode clazz) {
|
|
try {
|
|
final ClassType classType = classHierarchy.getOrCreateClass(clazz.name);
|
|
if (classType.isResolved()) {
|
|
System.err.println("WARNING: Class "+classType.getInternalName()+" defined multiple times");
|
|
return;
|
|
}
|
|
classType.setLocation(location);
|
|
|
|
|
|
// TODO extract modifiers, super class, interfaces, methods
|
|
|
|
|
|
|
|
classType.setResolved();
|
|
} catch (final TypeInconsistencyException ex) {
|
|
System.err.println(ex);
|
|
}
|
|
}
|
|
|
|
}
|