Example usage for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding isHierarchyConnected

List of usage examples for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding isHierarchyConnected

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding isHierarchyConnected.

Prototype

public boolean isHierarchyConnected() 

Source Link

Document

Returns true if the type hierarchy is connected

Usage

From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java

License:Open Source License

public boolean isPossibleSubtypeOfRawType(TypeBinding paramType) {
    TypeBinding t = paramType.leafComponentType();
    if (t.isBaseType())
        return false;

    ReferenceBinding currentType = (ReferenceBinding) t;
    ReferenceBinding[] interfacesToVisit = null;
    int nextPosition = 0;
    do {/* w ww  . j  a va  2  s  .  c o m*/
        if (currentType.isRawType())
            return true;
        if (!currentType.isHierarchyConnected())
            return true; // do not fault in super types right now, so assume one is a raw type

        ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
        if (itsInterfaces != null && itsInterfaces != Binding.NO_SUPERINTERFACES) {
            if (interfacesToVisit == null) {
                interfacesToVisit = itsInterfaces;
                nextPosition = interfacesToVisit.length;
            } else {
                int itsLength = itsInterfaces.length;
                if (nextPosition + itsLength >= interfacesToVisit.length)
                    System.arraycopy(interfacesToVisit, 0,
                            interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0,
                            nextPosition);
                nextInterface: for (int a = 0; a < itsLength; a++) {
                    ReferenceBinding next = itsInterfaces[a];
                    for (int b = 0; b < nextPosition; b++)
                        if (next == interfacesToVisit[b])
                            continue nextInterface;
                    interfacesToVisit[nextPosition++] = next;
                }
            }
        }
    } while ((currentType = currentType.superclass()) != null);

    for (int i = 0; i < nextPosition; i++) {
        currentType = interfacesToVisit[i];
        if (currentType.isRawType())
            return true;

        ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
        if (itsInterfaces != null && itsInterfaces != Binding.NO_SUPERINTERFACES) {
            int itsLength = itsInterfaces.length;
            if (nextPosition + itsLength >= interfacesToVisit.length)
                System.arraycopy(interfacesToVisit, 0,
                        interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0,
                        nextPosition);
            nextInterface: for (int a = 0; a < itsLength; a++) {
                ReferenceBinding next = itsInterfaces[a];
                for (int b = 0; b < nextPosition; b++)
                    if (next == interfacesToVisit[b])
                        continue nextInterface;
                interfacesToVisit[nextPosition++] = next;
            }
        }
    }
    return false;
}