Example usage for org.eclipse.jdt.internal.core.hierarchy TypeHierarchy NO_TYPE

List of usage examples for org.eclipse.jdt.internal.core.hierarchy TypeHierarchy NO_TYPE

Introduction

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

Prototype

IType[] NO_TYPE

To view the source code for org.eclipse.jdt.internal.core.hierarchy TypeHierarchy NO_TYPE.

Click Source Link

Usage

From source file:org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.java

License:Open Source License

/**
 * Connect the supplied type to its superclass & superinterfaces.
 * The superclass & superinterfaces are the identical binary or source types as
 * supplied by the name environment./*from  w  w  w.  ja v a  2s . co m*/
 */
public void connect(IGenericType type, IType typeHandle, IType superclassHandle,
        IType[] superinterfaceHandles) {

    /*
     * Temporary workaround for 1G2O5WK: ITPJCORE:WINNT - NullPointerException when selecting "Show in Type Hierarchy" for a inner class
     */
    if (typeHandle == null)
        return;
    if (TypeHierarchy.DEBUG) {
        System.out.println("Connecting: " + ((JavaElement) typeHandle).toStringWithAncestors()); //$NON-NLS-1$
        System.out.println("  to superclass: " //$NON-NLS-1$
                + (superclassHandle == null ? "<None>" //$NON-NLS-1$
                        : ((JavaElement) superclassHandle).toStringWithAncestors()));
        System.out.print("  and superinterfaces:"); //$NON-NLS-1$
        if (superinterfaceHandles == null || superinterfaceHandles.length == 0) {
            System.out.println(" <None>"); //$NON-NLS-1$
        } else {
            System.out.println();
            for (int i = 0, length = superinterfaceHandles.length; i < length; i++) {
                if (superinterfaceHandles[i] == null)
                    continue;
                System.out.println("    " + ((JavaElement) superinterfaceHandles[i]).toStringWithAncestors()); //$NON-NLS-1$
            }
        }
    }
    // now do the caching
    switch (TypeDeclaration.kind(type.getModifiers())) {
    case TypeDeclaration.CLASS_DECL:
    case TypeDeclaration.ENUM_DECL:
        if (superclassHandle == null) {
            this.hierarchy.addRootClass(typeHandle);
        } else {
            this.hierarchy.cacheSuperclass(typeHandle, superclassHandle);
        }
        break;
    case TypeDeclaration.INTERFACE_DECL:
    case TypeDeclaration.ANNOTATION_TYPE_DECL:
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=329663
        if (this.hierarchy.typeToSuperInterfaces.get(typeHandle) == null)
            this.hierarchy.addInterface(typeHandle);
        break;
    }
    if (superinterfaceHandles == null) {
        superinterfaceHandles = TypeHierarchy.NO_TYPE;
    }
    this.hierarchy.cacheSuperInterfaces(typeHandle, superinterfaceHandles);

    // record flags
    this.hierarchy.cacheFlags(typeHandle, type.getModifiers());
}