Example usage for org.eclipse.jdt.core Signature getIntersectionTypeBounds

List of usage examples for org.eclipse.jdt.core Signature getIntersectionTypeBounds

Introduction

In this page you can find the example usage for org.eclipse.jdt.core Signature getIntersectionTypeBounds.

Prototype

public static String[] getIntersectionTypeBounds(String intersectionTypeSignature)
        throws IllegalArgumentException 

Source Link

Document

Extracts the type bounds' signatures from the given intersection type signature.

Usage

From source file:at.bestsolution.fxide.jdt.text.viewersupport.JavaElementLabelComposer.java

License:Open Source License

protected void appendTypeSignatureLabel(IJavaElement enclosingElement, String typeSig, long flags) {
    int sigKind = Signature.getTypeSignatureKind(typeSig);
    switch (sigKind) {
    case Signature.BASE_TYPE_SIGNATURE:
        fBuffer.append(Signature.toString(typeSig));
        break;/*from   w  w  w.  j av a  2s.c  o  m*/
    case Signature.ARRAY_TYPE_SIGNATURE:
        appendTypeSignatureLabel(enclosingElement, Signature.getElementType(typeSig), flags);
        for (int dim = Signature.getArrayCount(typeSig); dim > 0; dim--) {
            fBuffer.append('[').append(']');
        }
        break;
    case Signature.CLASS_TYPE_SIGNATURE:
        String baseType = getSimpleTypeName(enclosingElement, typeSig);
        fBuffer.append(baseType);

        String[] typeArguments = Signature.getTypeArguments(typeSig);
        appendTypeArgumentSignaturesLabel(enclosingElement, typeArguments, flags);
        break;
    case Signature.TYPE_VARIABLE_SIGNATURE:
        fBuffer.append(getSimpleTypeName(enclosingElement, typeSig));
        break;
    case Signature.WILDCARD_TYPE_SIGNATURE:
        char ch = typeSig.charAt(0);
        if (ch == Signature.C_STAR) { //workaround for bug 85713
            fBuffer.append('?');
        } else {
            if (ch == Signature.C_EXTENDS) {
                fBuffer.append("? extends "); //$NON-NLS-1$
                appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
            } else if (ch == Signature.C_SUPER) {
                fBuffer.append("? super "); //$NON-NLS-1$
                appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
            }
        }
        break;
    case Signature.CAPTURE_TYPE_SIGNATURE:
        appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags);
        break;
    case Signature.INTERSECTION_TYPE_SIGNATURE:
        String[] typeBounds = Signature.getIntersectionTypeBounds(typeSig);
        appendTypeBoundsSignaturesLabel(enclosingElement, typeBounds, flags);
        break;
    default:
        // unknown
    }
}

From source file:com.codenvy.ide.ext.java.server.SourcesFromBytecodeGenerator.java

License:Open Source License

protected void appendTypeSignatureLabel(IJavaElement enclosingElement, String typeSig, long flags,
        StringBuilder builder) {//  w  w  w . j a  v a 2s .c om
    int sigKind = Signature.getTypeSignatureKind(typeSig);
    switch (sigKind) {
    case Signature.BASE_TYPE_SIGNATURE:
        builder.append(Signature.toString(typeSig));
        break;
    case Signature.ARRAY_TYPE_SIGNATURE:
        appendTypeSignatureLabel(enclosingElement, Signature.getElementType(typeSig), flags, builder);
        for (int dim = Signature.getArrayCount(typeSig); dim > 0; dim--) {
            builder.append('[').append(']');
        }
        break;
    case Signature.CLASS_TYPE_SIGNATURE:
        String baseType = getSimpleTypeName(enclosingElement, typeSig);
        builder.append(baseType);

        String[] typeArguments = Signature.getTypeArguments(typeSig);
        appendTypeArgumentSignaturesLabel(enclosingElement, typeArguments, flags, builder);
        break;
    case Signature.TYPE_VARIABLE_SIGNATURE:
        builder.append(getSimpleTypeName(enclosingElement, typeSig));
        break;
    case Signature.WILDCARD_TYPE_SIGNATURE:
        char ch = typeSig.charAt(0);
        if (ch == Signature.C_STAR) { //workaround for bug 85713
            builder.append('?');
        } else {
            if (ch == Signature.C_EXTENDS) {
                builder.append("? extends "); //$NON-NLS-1$
                appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags, builder);
            } else if (ch == Signature.C_SUPER) {
                builder.append("? super "); //$NON-NLS-1$
                appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags, builder);
            }
        }
        break;
    case Signature.CAPTURE_TYPE_SIGNATURE:
        appendTypeSignatureLabel(enclosingElement, typeSig.substring(1), flags, builder);
        break;
    case Signature.INTERSECTION_TYPE_SIGNATURE:
        String[] typeBounds = Signature.getIntersectionTypeBounds(typeSig);
        appendTypeBoundsSignaturesLabel(enclosingElement, typeBounds, flags, builder);
        break;
    default:
        // unknown
    }
}