I would like to get a list of all subclasses of a given class with their fully qualified names. I wanted to copy it from Eclipse and paste into a text file like this:
<
The method in the Hierarchy view which does build the hierarchy tree is in the org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyLifeCycle:
private ITypeHierarchy createTypeHierarchy(IJavaElement element, IProgressMonitor pm) throws JavaModelException {
if (element.getElementType() == IJavaElement.TYPE) {
IType type= (IType) element;
if (fIsSuperTypesOnly) {
return type.newSupertypeHierarchy(pm);
} else {
return type.newTypeHierarchy(pm);
}
} else {
Which uses org.eclipse.jdt.internal.core.SourceType class
/**
* @see IType
*/
public ITypeHierarchy newTypeHierarchy(IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
return newTypeHierarchy(project, DefaultWorkingCopyOwner.PRIMARY, monitor);
}
So if you can get a IJavaElement, you can check those classes to emulate the same result.
It uses a org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation