Example usage for org.eclipse.jdt.internal.core CreateTypeHierarchyOperation CreateTypeHierarchyOperation

List of usage examples for org.eclipse.jdt.internal.core CreateTypeHierarchyOperation CreateTypeHierarchyOperation

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core CreateTypeHierarchyOperation CreateTypeHierarchyOperation.

Prototype

public CreateTypeHierarchyOperation(IType element, ICompilationUnit[] workingCopies, IJavaProject project,
        boolean computeSubtypes) 

Source Link

Document

Constructs an operation to create a type hierarchy for the given type and working copies.

Usage

From source file:org.eclipse.jdt.internal.core.JavaProject.java

License:Open Source License

/**
 * @see IJavaProject//ww w  . ja va2s  .c o m
 */
public ITypeHierarchy newTypeHierarchy(IRegion region, WorkingCopyOwner owner, IProgressMonitor monitor)
        throws JavaModelException {

    if (region == null) {
        throw new IllegalArgumentException(Messages.hierarchy_nullRegion);
    }
    ICompilationUnit[] workingCopies = JavaModelManager.getJavaModelManager().getWorkingCopies(owner,
            true/*add primary working copies*/);
    CreateTypeHierarchyOperation op = new CreateTypeHierarchyOperation(region, workingCopies, null, true);
    op.runOperation(monitor);
    return op.getResult();
}

From source file:org.eclipse.jdt.internal.core.JavaProject.java

License:Open Source License

/**
 * @see IJavaProject//from   w ww. j  a  v a 2s.com
 */
public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, WorkingCopyOwner owner,
        IProgressMonitor monitor) throws JavaModelException {

    if (type == null) {
        throw new IllegalArgumentException(Messages.hierarchy_nullFocusType);
    }
    if (region == null) {
        throw new IllegalArgumentException(Messages.hierarchy_nullRegion);
    }
    ICompilationUnit[] workingCopies = JavaModelManager.getJavaModelManager().getWorkingCopies(owner,
            true/*add primary working copies*/);
    CreateTypeHierarchyOperation op = new CreateTypeHierarchyOperation(region, workingCopies, type,
            true/*compute subtypes*/);
    op.runOperation(monitor);
    return op.getResult();
}

From source file:org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils.java

License:Open Source License

/**
 * Returns the hierarchy for the given type, or null if it could not be
 * 'computed'.//ww w  . j  a va 2 s.  c  om
 * 
 * @param baseType
 *            the base type for the hierarchy
 * @param includeLibraries
 *            should the hierarchy include type from libraries
 * @param progressMonitor
 *            a progress monitor (or null)
 * @return the SourceType Hierarchy for the base type
 * @throws CoreException
 *             the underlying CoreException thrown by the manipulated JDT
 *             APIs
 */
public static ITypeHierarchy resolveTypeHierarchy(final IType baseType, final IJavaElement scope,
        final boolean includeLibraries, final IProgressMonitor progressMonitor) throws CoreException {
    // create type hierarchy
    // FIXME : restrict operation scope to sources only, exclude application
    // libraries.
    int appLibs = 0;
    if (includeLibraries) {
        appLibs = IJavaSearchScope.APPLICATION_LIBRARIES;
    }
    IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope },
            IJavaSearchScope.SOURCES | appLibs | IJavaSearchScope.REFERENCED_PROJECTS);
    CreateTypeHierarchyOperation operation = new CreateTypeHierarchyOperation(baseType, null, searchScope,
            true);
    ITypeHierarchy hierarchy = operation.getResult();
    if (hierarchy != null && hierarchy.exists()) {
        hierarchy.refresh(progressMonitor);
        return hierarchy;
    }
    Logger.warn("No type hierarchy found for " + baseType.getFullyQualifiedName());
    return null;
}