Search in sources :

Example 76 with Type

use of com.sun.tools.javac.code.Type in project ceylon-compiler by ceylon.

the class ExecutableMemberDocImpl method thrownExceptions.

/**
     * Return exceptions this method or constructor throws.
     *
     * @return an array of ClassDoc[] representing the exceptions
     * thrown by this method.
     */
public ClassDoc[] thrownExceptions() {
    ListBuffer<ClassDocImpl> l = new ListBuffer<ClassDocImpl>();
    for (Type ex : sym.type.getThrownTypes()) {
        ex = env.types.erasure(ex);
        //### Will these casts succeed in the face of static semantic
        //### errors in the documented code?
        ClassDocImpl cdi = env.getClassDoc((ClassSymbol) ex.tsym);
        if (cdi != null)
            l.append(cdi);
    }
    return l.toArray(new ClassDocImpl[l.length()]);
}
Also used : Type(com.sun.tools.javac.code.Type) ListBuffer(com.sun.tools.javac.util.ListBuffer)

Example 77 with Type

use of com.sun.tools.javac.code.Type in project ceylon-compiler by ceylon.

the class ExecutableMemberDocImpl method makeSignature.

private String makeSignature(boolean full) {
    StringBuilder result = new StringBuilder();
    result.append("(");
    for (List<Type> types = sym.type.getParameterTypes(); types.nonEmpty(); ) {
        Type t = types.head;
        result.append(TypeMaker.getTypeString(env, t, full));
        types = types.tail;
        if (types.nonEmpty()) {
            result.append(", ");
        }
    }
    if (isVarArgs()) {
        int len = result.length();
        result.replace(len - 2, len, "...");
    }
    result.append(")");
    return result.toString();
}
Also used : Type(com.sun.tools.javac.code.Type)

Example 78 with Type

use of com.sun.tools.javac.code.Type in project ceylon-compiler by ceylon.

the class TypeVariableImpl method typeVarToString.

/**
     * Return the string form of a type variable along with any
     * "extends" clause.  Class names are qualified if "full" is true.
     */
static String typeVarToString(DocEnv env, TypeVar v, boolean full) {
    StringBuilder s = new StringBuilder(v.toString());
    List<Type> bounds = getBounds(v, env);
    if (bounds.nonEmpty()) {
        boolean first = true;
        for (Type b : bounds) {
            s.append(first ? " extends " : " & ");
            s.append(TypeMaker.getTypeString(env, b, full));
            first = false;
        }
    }
    return s.toString();
}
Also used : Type(com.sun.tools.javac.code.Type)

Example 79 with Type

use of com.sun.tools.javac.code.Type in project ceylon-compiler by ceylon.

the class WildcardTypeImpl method wildcardTypeToString.

/**
     * Return the string form of a wildcard type ("?") along with any
     * "extends" or "super" clause.  Delimiting brackets are not
     * included.  Class names are qualified if "full" is true.
     */
static String wildcardTypeToString(DocEnv env, Type.WildcardType wildThing, boolean full) {
    if (env.legacyDoclet) {
        return TypeMaker.getTypeName(env.types.erasure(wildThing), full);
    }
    StringBuilder s = new StringBuilder("?");
    List<Type> bounds = getExtendsBounds(wildThing);
    if (bounds.nonEmpty()) {
        s.append(" extends ");
    } else {
        bounds = getSuperBounds(wildThing);
        if (bounds.nonEmpty()) {
            s.append(" super ");
        }
    }
    // currently only one bound is allowed
    boolean first = true;
    for (Type b : bounds) {
        if (!first) {
            s.append(" & ");
        }
        s.append(TypeMaker.getTypeString(env, b, full));
        first = false;
    }
    return s.toString();
}
Also used : Type(com.sun.tools.javac.code.Type)

Example 80 with Type

use of com.sun.tools.javac.code.Type in project ceylon-compiler by ceylon.

the class TypeMaker method typeParametersString.

/**
     * Return the formal type parameters of a class or method as an
     * angle-bracketed string.  Each parameter is a type variable with
     * optional bounds.  Class names are qualified if "full" is true.
     * Return "" if there are no type parameters or we're hiding generics.
     */
static String typeParametersString(DocEnv env, Symbol sym, boolean full) {
    if (env.legacyDoclet || sym.type.getTypeArguments().isEmpty()) {
        return "";
    }
    StringBuilder s = new StringBuilder();
    for (Type t : sym.type.getTypeArguments()) {
        s.append(s.length() == 0 ? "<" : ", ");
        s.append(TypeVariableImpl.typeVarToString(env, (TypeVar) t, full));
    }
    s.append(">");
    return s.toString();
}
Also used : ClassType(com.sun.tools.javac.code.Type.ClassType) ArrayType(com.sun.tools.javac.code.Type.ArrayType) Type(com.sun.tools.javac.code.Type) TypeVar(com.sun.tools.javac.code.Type.TypeVar)

Aggregations

Type (com.sun.tools.javac.code.Type)254 Symbol (com.sun.tools.javac.code.Symbol)64 ClassType (com.sun.tools.javac.code.Type.ClassType)55 ArrayType (com.sun.tools.javac.code.Type.ArrayType)47 MethodType (com.sun.tools.javac.code.Type.MethodType)42 WildcardType (com.sun.tools.javac.code.Type.WildcardType)42 MethodSymbol (com.sun.tools.javac.code.Symbol.MethodSymbol)36 UnionClassType (com.sun.tools.javac.code.Type.UnionClassType)33 ClassSymbol (com.sun.tools.javac.code.Symbol.ClassSymbol)32 JCTree (com.sun.tools.javac.tree.JCTree)27 TypeSymbol (com.sun.tools.javac.code.Symbol.TypeSymbol)24 VarSymbol (com.sun.tools.javac.code.Symbol.VarSymbol)23 Types (com.sun.tools.javac.code.Types)22 ExpressionTree (com.sun.source.tree.ExpressionTree)21 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)17 ArrayList (java.util.ArrayList)17 PackageSymbol (com.sun.tools.javac.code.Symbol.PackageSymbol)16 Tree (com.sun.source.tree.Tree)14 Name (com.sun.tools.javac.util.Name)14 DynamicMethodSymbol (com.sun.tools.javac.code.Symbol.DynamicMethodSymbol)13