Example usage for org.eclipse.jdt.internal.compiler.env IGenericType getModifiers

List of usage examples for org.eclipse.jdt.internal.compiler.env IGenericType getModifiers

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.env IGenericType getModifiers.

Prototype






int getModifiers();

Source Link

Document

Answer an int whose bits are set according the access constants defined by the VM spec.

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.//ww  w  .jav  a2  s.c o 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());
}