public interface ITypeHierarchy
A type hierarchy is static and can become stale. Although consistent when
created, it does not automatically track changes in the model.
As changes in the model potentially invalidate the hierarchy, change notifications
are sent to registered ITypeHierarchyChangedListener
s. Listeners should
use the exists
method to determine if the hierarchy has become completely
invalid (for example, when the type or project the hierarchy was created on
has been removed). To refresh a hierarchy, use the refresh
method.
The type hierarchy may contain cycles due to malformed supertype declarations.
Most type hierarchy queries are oblivious to cycles; the getAll*
methods are implemented such that they are unaffected by cycles.
This interface is not intended to be implemented by clients.
Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.Modifier and Type | Method and Description |
---|---|
void |
addTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener)
Adds the given listener for changes to this type hierarchy.
|
boolean |
contains(IType type)
Returns whether the given type is part of this hierarchy.
|
boolean |
exists()
Returns whether the type and project this hierarchy was created on exist.
|
IType[] |
getAllClasses()
Returns all classes in this type hierarchy's graph, in no particular
order.
|
IType[] |
getAllSubtypes(IType type)
Returns all resolved subtypes (direct and indirect) of the
given type, in no particular order, limited to the
types in this type hierarchy's graph.
|
IType[] |
getAllSuperclasses(IType type)
Returns all resolved superclasses of the
given class, in bottom-up order.
|
int |
getCachedFlags(IType type)
Return the flags associated with the given type (would be equivalent to
IMember.getFlags() ),
or -1 if this information wasn't cached on the hierarchy during its computation. |
IType[] |
getRootClasses()
Returns all classes in the graph which have no resolved superclass,
in no particular order.
|
IType[] |
getSubclasses(IType type)
Returns the direct resolved subclasses of the given class,
in no particular order, limited to the classes in this
type hierarchy's graph.
|
IType |
getSuperclass(IType type)
Returns the resolved superclass of the given class,
or
null if the given class has no superclass or
the superclass could not be resolved. |
IType |
getType()
Returns the type this hierarchy was computed for.
|
void |
refresh(IProgressMonitor monitor)
Re-computes the type hierarchy reporting progress.
|
void |
removeTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener)
Removes the given listener from this type hierarchy.
|
void |
store(java.io.OutputStream outputStream,
IProgressMonitor monitor)
Stores the type hierarchy in an output stream.
|
void addTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener)
listener
- the listenerboolean contains(IType type)
type
- the given typeboolean exists()
IType[] getAllClasses()
IType[] getAllSubtypes(IType type)
type
- the given typeIType[] getAllSuperclasses(IType type)
NOTE: once a type hierarchy has been created, it is more efficient to query the hierarchy for superclasses than to query a class recursively up the superclass chain. Querying an element performs a dynamic resolution, whereas the hierarchy returns a pre-computed result.
type
- the given typeint getCachedFlags(IType type)
IMember.getFlags()
),
or -1
if this information wasn't cached on the hierarchy during its computation.type
- the given typeFlags
IType[] getRootClasses()
IType[] getSubclasses(IType type)
type
- the given typeIType getSuperclass(IType type)
null
if the given class has no superclass or
the superclass could not be resolved.type
- the given typenull
if the given class has no superclass or
the superclass could not be resolved.IType getType()
null
if this hierarchy was computed for a region.void refresh(IProgressMonitor monitor) throws JavaScriptModelException
monitor
- the given progress monitorJavaScriptModelException
- if unable to refresh the hierarchyvoid removeTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener)
listener
- the listenervoid store(java.io.OutputStream outputStream, IProgressMonitor monitor) throws JavaScriptModelException
outputStream
- output stream where the hierarchy will be storedmonitor
- the given progress monitorJavaScriptModelException
- if unable to store the hierarchy in the ouput streamIType.loadTypeHierachy(java.io.InputStream, IProgressMonitor)
Copyright (c) IBM Corp. and others 2000, 2010. All Rights Reserved.