public class ClassHierarchy
extends java.lang.Object
ClassInfoLoader| Modifier and Type | Class and Description |
|---|---|
class |
ClassHierarchy.ResolvesToWith
Represents a method and a set of Types.
|
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
static Type |
POS_BYTE |
static Type |
POS_SHORT |
static boolean |
RELAX |
| Constructor and Description |
|---|
ClassHierarchy(EditorContext context,
java.util.Collection initial,
boolean closure)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addClassNamed(java.lang.String name)
Adds a class of a given name to the ClassHierarchy.
|
java.util.Collection |
classes()
Returns (the Types of) all of the classes and interfaces in
the hierarchy.
|
boolean |
closure()
Returns true if class closure has been computed
|
java.util.Collection |
implementors(Type type)
Returns the classes (Types) that implement a given interface
as a Collection of Types.
|
java.util.Collection |
interfaces(Type type)
Returns the interfaces that a given Type implements as a
Collection of Types
|
Type |
intersectType(Type a,
Type b)
Returns the intersection of two types.
|
MemberRef |
methodInvoked(Type receiver,
NameAndType method)
Returns the MemberRef of the method that would be invoked if a
given method of a given type was invoked.
|
boolean |
methodIsOverridden(Type classType,
NameAndType nat)
Determines whether or not a class's method is overriden by any of its
subclasses.
|
void |
printClasses(java.io.PrintWriter out,
int indent)
Prints the class hierarchy (i.e.
|
void |
printImplements(java.io.PrintWriter out,
int indent)
Prints the implements hierarchy to a PrintWriter.
|
java.util.Set |
resolvesToWith(MemberRef method)
Returns a set of ResolvesToWith that represent all subclass
methods that override a given method and the subclasses that when used as
receivers resolve to that method.
|
static Type |
setToType(java.util.BitSet v)
Given a set of bits representing the range of values some type has,
determines what that Type is.
|
java.util.Collection |
subclasses(Type type)
Returns the immediate subclasses of a given Type as a
Collection of Types.
|
boolean |
subclassOf(Type a,
Type b)
Returns whether or not a is a subclass of b.
|
Type |
superclass(Type type)
Returns the superclass of a given Type.
|
static java.util.BitSet |
typeToSet(Type type)
Returns a BitSet representing the possible values of a given integral
type.
|
Type |
unionType(Type a,
Type b)
Returns the union of two types.
|
Type |
unionTypes(java.util.Collection types)
Returns the most refined common supertype for a bunch of Types.
|
public static final Type POS_SHORT
public static final Type POS_BYTE
public static boolean DEBUG
public static boolean RELAX
public ClassHierarchy(EditorContext context, java.util.Collection initial, boolean closure)
context - The context in which to access an Editor and other
such things.initial - The names of the classes that initially constitue the
hierarchy.closure - Do we get the maximum amount of class information?public void addClassNamed(java.lang.String name)
public java.util.Collection subclasses(Type type)
The subclass relationship at the classfile level is a little screwy with respect to interfaces. An interface that extends another interface is compiled into an interface that extends java.lang.Object and implements the superinterface. As a result, the interface-subinterface is not captured in subclasses as one may expect. Instead, you have to look at implementors and filter out the classes.
public Type superclass(Type type)
public java.util.Collection interfaces(Type type)
public java.util.Collection implementors(Type type)
See note in subclasses for information about the interface hierarchy.
public java.util.Collection classes()
public boolean closure()
public Type intersectType(Type a, Type b)
public Type unionTypes(java.util.Collection types)
public Type unionType(Type a, Type b)
public void printClasses(java.io.PrintWriter out,
int indent)
public void printImplements(java.io.PrintWriter out,
int indent)
public boolean methodIsOverridden(Type classType, NameAndType nat)
public MemberRef methodInvoked(Type receiver, NameAndType method)
public static Type setToType(java.util.BitSet v)
public static java.util.BitSet typeToSet(Type type)
public java.util.Set resolvesToWith(MemberRef method)
ClassHierarchy.ResolvesToWith