Java Code Examples for com.sun.tools.javac.code.Type#isAnnotated()

The following examples show how to use com.sun.tools.javac.code.Type#isAnnotated() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeMaker.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string representation of a type use.  Bounds of type
 * variables are not included; bounds of wildcard types are.
 * Class names are qualified if "full" is true.
 */
static String getTypeString(DocEnv env, Type t, boolean full) {
    // TODO: should annotations be included here?
    if (t.isAnnotated()) {
        t = t.unannotatedType();
    }
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = env.types.elemtype(t);
        }
        s.insert(0, getTypeString(env, t, full));
        return s.toString();
    case CLASS:
        return ParameterizedTypeImpl.
                    parameterizedTypeToString(env, (ClassType)t, full);
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return WildcardTypeImpl.wildcardTypeToString(env, a, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example 2
Source File: TypeMaker.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string representation of a type use.  Bounds of type
 * variables are not included; bounds of wildcard types are.
 * Class names are qualified if "full" is true.
 */
static String getTypeString(DocEnv env, Type t, boolean full) {
    // TODO: should annotations be included here?
    if (t.isAnnotated()) {
        t = t.unannotatedType();
    }
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = env.types.elemtype(t);
        }
        s.insert(0, getTypeString(env, t, full));
        return s.toString();
    case CLASS:
        return ParameterizedTypeImpl.
                    parameterizedTypeToString(env, (ClassType)t, full);
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return WildcardTypeImpl.wildcardTypeToString(env, a, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example 3
Source File: TypeMaker.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string representation of a type use.  Bounds of type
 * variables are not included; bounds of wildcard types are.
 * Class names are qualified if "full" is true.
 */
static String getTypeString(DocEnv env, Type t, boolean full) {
    // TODO: should annotations be included here?
    if (t.isAnnotated()) {
        t = t.unannotatedType();
    }
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = env.types.elemtype(t);
        }
        s.insert(0, getTypeString(env, t, full));
        return s.toString();
    case CLASS:
        return ParameterizedTypeImpl.
                    parameterizedTypeToString(env, (ClassType)t, full);
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return WildcardTypeImpl.wildcardTypeToString(env, a, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example 4
Source File: TypeMaker.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string representation of a type use.  Bounds of type
 * variables are not included; bounds of wildcard types are.
 * Class names are qualified if "full" is true.
 */
static String getTypeString(DocEnv env, Type t, boolean full) {
    // TODO: should annotations be included here?
    if (t.isAnnotated()) {
        t = t.unannotatedType();
    }
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = env.types.elemtype(t);
        }
        s.insert(0, getTypeString(env, t, full));
        return s.toString();
    case CLASS:
        return ParameterizedTypeImpl.
                    parameterizedTypeToString(env, (ClassType)t, full);
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return WildcardTypeImpl.wildcardTypeToString(env, a, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example 5
Source File: TypeMaker.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string representation of a type use.  Bounds of type
 * variables are not included; bounds of wildcard types are.
 * Class names are qualified if "full" is true.
 */
static String getTypeString(DocEnv env, Type t, boolean full) {
    // TODO: should annotations be included here?
    if (t.isAnnotated()) {
        t = t.unannotatedType();
    }
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = env.types.elemtype(t);
        }
        s.insert(0, getTypeString(env, t, full));
        return s.toString();
    case CLASS:
        return ParameterizedTypeImpl.
                    parameterizedTypeToString(env, (ClassType)t, full);
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return WildcardTypeImpl.wildcardTypeToString(env, a, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example 6
Source File: TypeMaker.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string representation of a type use.  Bounds of type
 * variables are not included; bounds of wildcard types are.
 * Class names are qualified if "full" is true.
 */
static String getTypeString(DocEnv env, Type t, boolean full) {
    // TODO: should annotations be included here?
    if (t.isAnnotated()) {
        t = t.unannotatedType();
    }
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = env.types.elemtype(t);
        }
        s.insert(0, getTypeString(env, t, full));
        return s.toString();
    case CLASS:
        return ParameterizedTypeImpl.
                    parameterizedTypeToString(env, (ClassType)t, full);
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return WildcardTypeImpl.wildcardTypeToString(env, a, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example 7
Source File: TypeMaker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the string representation of a type use.  Bounds of type
 * variables are not included; bounds of wildcard types are.
 * Class names are qualified if "full" is true.
 */
static String getTypeString(DocEnv env, Type t, boolean full) {
    // TODO: should annotations be included here?
    if (t.isAnnotated()) {
        t = t.unannotatedType();
    }
    switch (t.getTag()) {
    case ARRAY:
        StringBuilder s = new StringBuilder();
        while (t.hasTag(ARRAY)) {
            s.append("[]");
            t = env.types.elemtype(t);
        }
        s.insert(0, getTypeString(env, t, full));
        return s.toString();
    case CLASS:
        return ParameterizedTypeImpl.
                    parameterizedTypeToString(env, (ClassType)t, full);
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return WildcardTypeImpl.wildcardTypeToString(env, a, full);
    default:
        return t.tsym.getQualifiedName().toString();
    }
}
 
Example 8
Source File: TypeMaker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("fallthrough")
private static com.sun.javadoc.Type getTypeImpl(DocEnv env, Type t,
        boolean errToClassDoc, boolean considerAnnotations) {
    if (env.legacyDoclet) {
        t = env.types.erasure(t);
    }

    if (considerAnnotations && t.isAnnotated()) {
        return new AnnotatedTypeImpl(env, t);
    }

    switch (t.getTag()) {
    case CLASS:
        if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) {
            return env.getParameterizedType((ClassType)t);
        } else {
            return env.getClassDoc((ClassSymbol)t.tsym);
        }
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return new WildcardTypeImpl(env, a);
    case TYPEVAR: return new TypeVariableImpl(env, (TypeVar)t);
    case ARRAY: return new ArrayTypeImpl(env, t);
    case BYTE: return PrimitiveType.byteType;
    case CHAR: return PrimitiveType.charType;
    case SHORT: return PrimitiveType.shortType;
    case INT: return PrimitiveType.intType;
    case LONG: return PrimitiveType.longType;
    case FLOAT: return PrimitiveType.floatType;
    case DOUBLE: return PrimitiveType.doubleType;
    case BOOLEAN: return PrimitiveType.booleanType;
    case VOID: return PrimitiveType.voidType;
    case ERROR:
        if (errToClassDoc)
            return env.getClassDoc((ClassSymbol)t.tsym);
        // FALLTHRU
    default:
        return new PrimitiveType(t.tsym.getQualifiedName().toString());
    }
}
 
Example 9
Source File: TypeMaker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("fallthrough")
public static com.sun.javadoc.Type getType(DocEnv env, Type t,
        boolean errToClassDoc, boolean considerAnnotations) {
    if (env.legacyDoclet) {
        t = env.types.erasure(t);
    }

    if (considerAnnotations && t.isAnnotated()) {
        return new AnnotatedTypeImpl(env, t);
    }

    switch (t.getTag()) {
    case CLASS:
        if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) {
            return env.getParameterizedType((ClassType)t);
        } else {
            return env.getClassDoc((ClassSymbol)t.tsym);
        }
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return new WildcardTypeImpl(env, a);
    case TYPEVAR: return new TypeVariableImpl(env, (TypeVar)t);
    case ARRAY: return new ArrayTypeImpl(env, t);
    case BYTE: return PrimitiveType.byteType;
    case CHAR: return PrimitiveType.charType;
    case SHORT: return PrimitiveType.shortType;
    case INT: return PrimitiveType.intType;
    case LONG: return PrimitiveType.longType;
    case FLOAT: return PrimitiveType.floatType;
    case DOUBLE: return PrimitiveType.doubleType;
    case BOOLEAN: return PrimitiveType.booleanType;
    case VOID: return PrimitiveType.voidType;
    case ERROR:
        if (errToClassDoc)
            return env.getClassDoc((ClassSymbol)t.tsym);
        // FALLTHRU
    default:
        return new PrimitiveType(t.tsym.getQualifiedName().toString());
    }
}
 
Example 10
Source File: TypeVariableImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the bounds of a type variable as listed in the "extends" clause.
 */
private static List<Type> getBounds(TypeVar v, DocEnv env) {
    final Type upperBound = v.getUpperBound();
    Name boundname = upperBound.tsym.getQualifiedName();
    if (boundname == boundname.table.names.java_lang_Object
        && !upperBound.isAnnotated()) {
        return List.nil();
    } else {
        return env.types.getBounds(v);
    }
}
 
Example 11
Source File: TypeMaker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("fallthrough")
private static com.sun.javadoc.Type getTypeImpl(DocEnv env, Type t,
        boolean errToClassDoc, boolean considerAnnotations) {
    if (env.legacyDoclet) {
        t = env.types.erasure(t);
    }

    if (considerAnnotations && t.isAnnotated()) {
        return new AnnotatedTypeImpl(env, t);
    }

    switch (t.getTag()) {
    case CLASS:
        if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) {
            return env.getParameterizedType((ClassType)t);
        } else {
            return env.getClassDoc((ClassSymbol)t.tsym);
        }
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return new WildcardTypeImpl(env, a);
    case TYPEVAR: return new TypeVariableImpl(env, (TypeVar)t);
    case ARRAY: return new ArrayTypeImpl(env, t);
    case BYTE: return PrimitiveType.byteType;
    case CHAR: return PrimitiveType.charType;
    case SHORT: return PrimitiveType.shortType;
    case INT: return PrimitiveType.intType;
    case LONG: return PrimitiveType.longType;
    case FLOAT: return PrimitiveType.floatType;
    case DOUBLE: return PrimitiveType.doubleType;
    case BOOLEAN: return PrimitiveType.booleanType;
    case VOID: return PrimitiveType.voidType;
    case ERROR:
        if (errToClassDoc)
            return env.getClassDoc((ClassSymbol)t.tsym);
        // FALLTHRU
    default:
        return new PrimitiveType(t.tsym.getQualifiedName().toString());
    }
}
 
Example 12
Source File: TypeVariableImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the bounds of a type variable as listed in the "extends" clause.
 */
private static List<Type> getBounds(TypeVar v, DocEnv env) {
    final Type upperBound = v.getUpperBound();
    Name boundname = upperBound.tsym.getQualifiedName();
    if (boundname == boundname.table.names.java_lang_Object
        && !upperBound.isAnnotated()) {
        return List.nil();
    } else {
        return env.types.getBounds(v);
    }
}
 
Example 13
Source File: TypeVariableImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the bounds of a type variable as listed in the "extends" clause.
 */
private static List<Type> getBounds(TypeVar v, DocEnv env) {
    final Type upperBound = v.getUpperBound();
    Name boundname = upperBound.tsym.getQualifiedName();
    if (boundname == boundname.table.names.java_lang_Object
        && !upperBound.isAnnotated()) {
        return List.nil();
    } else {
        return env.types.getBounds(v);
    }
}
 
Example 14
Source File: TypeVariableImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the bounds of a type variable as listed in the "extends" clause.
 */
private static List<Type> getBounds(TypeVar v, DocEnv env) {
    final Type upperBound = v.getUpperBound();
    Name boundname = upperBound.tsym.getQualifiedName();
    if (boundname == boundname.table.names.java_lang_Object
        && !upperBound.isAnnotated()) {
        return List.nil();
    } else {
        return env.types.getBounds(v);
    }
}
 
Example 15
Source File: TypeVariableImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the bounds of a type variable as listed in the "extends" clause.
 */
private static List<Type> getBounds(TypeVar v, DocEnv env) {
    final Type upperBound = v.getUpperBound();
    Name boundname = upperBound.tsym.getQualifiedName();
    if (boundname == boundname.table.names.java_lang_Object
        && !upperBound.isAnnotated()) {
        return List.nil();
    } else {
        return env.types.getBounds(v);
    }
}
 
Example 16
Source File: TypeMaker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("fallthrough")
private static com.sun.javadoc.Type getTypeImpl(DocEnv env, Type t,
        boolean errToClassDoc, boolean considerAnnotations) {
    if (env.legacyDoclet) {
        t = env.types.erasure(t);
    }

    if (considerAnnotations && t.isAnnotated()) {
        return new AnnotatedTypeImpl(env, t);
    }

    switch (t.getTag()) {
    case CLASS:
        if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) {
            return env.getParameterizedType((ClassType)t);
        } else {
            return env.getClassDoc((ClassSymbol)t.tsym);
        }
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return new WildcardTypeImpl(env, a);
    case TYPEVAR: return new TypeVariableImpl(env, (TypeVar)t);
    case ARRAY: return new ArrayTypeImpl(env, t);
    case BYTE: return PrimitiveType.byteType;
    case CHAR: return PrimitiveType.charType;
    case SHORT: return PrimitiveType.shortType;
    case INT: return PrimitiveType.intType;
    case LONG: return PrimitiveType.longType;
    case FLOAT: return PrimitiveType.floatType;
    case DOUBLE: return PrimitiveType.doubleType;
    case BOOLEAN: return PrimitiveType.booleanType;
    case VOID: return PrimitiveType.voidType;
    case ERROR:
        if (errToClassDoc)
            return env.getClassDoc((ClassSymbol)t.tsym);
        // FALLTHRU
    default:
        return new PrimitiveType(t.tsym.getQualifiedName().toString());
    }
}
 
Example 17
Source File: TypeMaker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("fallthrough")
public static com.sun.javadoc.Type getType(DocEnv env, Type t,
        boolean errToClassDoc, boolean considerAnnotations) {
    if (env.legacyDoclet) {
        t = env.types.erasure(t);
    }

    if (considerAnnotations && t.isAnnotated()) {
        return new AnnotatedTypeImpl(env, t);
    }

    switch (t.getTag()) {
    case CLASS:
        if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) {
            return env.getParameterizedType((ClassType)t);
        } else {
            return env.getClassDoc((ClassSymbol)t.tsym);
        }
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return new WildcardTypeImpl(env, a);
    case TYPEVAR: return new TypeVariableImpl(env, (TypeVar)t);
    case ARRAY: return new ArrayTypeImpl(env, t);
    case BYTE: return PrimitiveType.byteType;
    case CHAR: return PrimitiveType.charType;
    case SHORT: return PrimitiveType.shortType;
    case INT: return PrimitiveType.intType;
    case LONG: return PrimitiveType.longType;
    case FLOAT: return PrimitiveType.floatType;
    case DOUBLE: return PrimitiveType.doubleType;
    case BOOLEAN: return PrimitiveType.booleanType;
    case VOID: return PrimitiveType.voidType;
    case ERROR:
        if (errToClassDoc)
            return env.getClassDoc((ClassSymbol)t.tsym);
        // FALLTHRU
    default:
        return new PrimitiveType(t.tsym.getQualifiedName().toString());
    }
}
 
Example 18
Source File: TypeMaker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("fallthrough")
public static com.sun.javadoc.Type getType(DocEnv env, Type t,
        boolean errToClassDoc, boolean considerAnnotations) {
    if (env.legacyDoclet) {
        t = env.types.erasure(t);
    }

    if (considerAnnotations && t.isAnnotated()) {
        return new AnnotatedTypeImpl(env, t);
    }

    switch (t.getTag()) {
    case CLASS:
        if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) {
            return env.getParameterizedType((ClassType)t);
        } else {
            return env.getClassDoc((ClassSymbol)t.tsym);
        }
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return new WildcardTypeImpl(env, a);
    case TYPEVAR: return new TypeVariableImpl(env, (TypeVar)t);
    case ARRAY: return new ArrayTypeImpl(env, t);
    case BYTE: return PrimitiveType.byteType;
    case CHAR: return PrimitiveType.charType;
    case SHORT: return PrimitiveType.shortType;
    case INT: return PrimitiveType.intType;
    case LONG: return PrimitiveType.longType;
    case FLOAT: return PrimitiveType.floatType;
    case DOUBLE: return PrimitiveType.doubleType;
    case BOOLEAN: return PrimitiveType.booleanType;
    case VOID: return PrimitiveType.voidType;
    case ERROR:
        if (errToClassDoc)
            return env.getClassDoc((ClassSymbol)t.tsym);
        // FALLTHRU
    default:
        return new PrimitiveType(t.tsym.getQualifiedName().toString());
    }
}
 
Example 19
Source File: TypeVariableImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the bounds of a type variable as listed in the "extends" clause.
 */
private static List<Type> getBounds(TypeVar v, DocEnv env) {
    final Type upperBound = v.getUpperBound();
    Name boundname = upperBound.tsym.getQualifiedName();
    if (boundname == boundname.table.names.java_lang_Object
        && !upperBound.isAnnotated()) {
        return List.nil();
    } else {
        return env.types.getBounds(v);
    }
}
 
Example 20
Source File: TypeMaker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("fallthrough")
private static com.sun.javadoc.Type getTypeImpl(DocEnv env, Type t,
        boolean errToClassDoc, boolean considerAnnotations) {
    if (env.legacyDoclet) {
        t = env.types.erasure(t);
    }

    if (considerAnnotations && t.isAnnotated()) {
        return new AnnotatedTypeImpl(env, t);
    }

    switch (t.getTag()) {
    case CLASS:
        if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) {
            return env.getParameterizedType((ClassType)t);
        } else {
            return env.getClassDoc((ClassSymbol)t.tsym);
        }
    case WILDCARD:
        Type.WildcardType a = (Type.WildcardType)t;
        return new WildcardTypeImpl(env, a);
    case TYPEVAR: return new TypeVariableImpl(env, (TypeVar)t);
    case ARRAY: return new ArrayTypeImpl(env, t);
    case BYTE: return PrimitiveType.byteType;
    case CHAR: return PrimitiveType.charType;
    case SHORT: return PrimitiveType.shortType;
    case INT: return PrimitiveType.intType;
    case LONG: return PrimitiveType.longType;
    case FLOAT: return PrimitiveType.floatType;
    case DOUBLE: return PrimitiveType.doubleType;
    case BOOLEAN: return PrimitiveType.booleanType;
    case VOID: return PrimitiveType.voidType;
    case ERROR:
        if (errToClassDoc)
            return env.getClassDoc((ClassSymbol)t.tsym);
        // FALLTHRU
    default:
        return new PrimitiveType(t.tsym.getQualifiedName().toString());
    }
}