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

The following examples show how to use com.sun.tools.javac.code.Type.ClassType#getEnclosingType() . 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: ParameterizedTypeImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static String parameterizedTypeToString(DocEnv env, ClassType cl,
                                        boolean full) {
    if (env.legacyDoclet) {
        return TypeMaker.getTypeName(cl, full);
    }
    StringBuilder s = new StringBuilder();
    if (!(cl.getEnclosingType().hasTag(CLASS))) {               // if not an inner class...
        s.append(TypeMaker.getTypeName(cl, full));
    } else {
        ClassType encl = (ClassType)cl.getEnclosingType();
        s.append(parameterizedTypeToString(env, encl, full))
         .append('.')
         .append(cl.tsym.name.toString());
    }
    s.append(TypeMaker.typeArgumentsString(env, cl, full));
    return s.toString();
}
 
Example 2
Source File: ParameterizedTypeImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static String parameterizedTypeToString(DocEnv env, ClassType cl,
                                        boolean full) {
    if (env.legacyDoclet) {
        return TypeMaker.getTypeName(cl, full);
    }
    StringBuilder s = new StringBuilder();
    if (!(cl.getEnclosingType().hasTag(CLASS))) {               // if not an inner class...
        s.append(TypeMaker.getTypeName(cl, full));
    } else {
        ClassType encl = (ClassType)cl.getEnclosingType();
        s.append(parameterizedTypeToString(env, encl, full))
         .append('.')
         .append(cl.tsym.name.toString());
    }
    s.append(TypeMaker.typeArgumentsString(env, cl, full));
    return s.toString();
}
 
Example 3
Source File: Printer.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
@Override
public String visitClassType(ClassType t, Locale locale) {
    StringBuffer buf = new StringBuffer();
    if (t.getEnclosingType().tag == CLASS && t.tsym.owner.kind == Kinds.TYP) {
        buf.append(visit(t.getEnclosingType(), locale));
        buf.append(".");
        buf.append(className(t, false, locale));
    } else {
        buf.append(className(t, true, locale));
    }
    if (t.getTypeArguments().nonEmpty()) {
        buf.append('<');
        buf.append(visitTypes(t.getTypeArguments(), locale));
        buf.append(">");
    }
    return buf.toString();
}
 
Example 4
Source File: ParameterizedTypeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static String parameterizedTypeToString(DocEnv env, ClassType cl,
                                        boolean full) {
    if (env.legacyDoclet) {
        return TypeMaker.getTypeName(cl, full);
    }
    StringBuilder s = new StringBuilder();
    if (!(cl.getEnclosingType().hasTag(CLASS))) {               // if not an inner class...
        s.append(TypeMaker.getTypeName(cl, full));
    } else {
        ClassType encl = (ClassType)cl.getEnclosingType();
        s.append(parameterizedTypeToString(env, encl, full))
         .append('.')
         .append(cl.tsym.name.toString());
    }
    s.append(TypeMaker.typeArgumentsString(env, cl, full));
    return s.toString();
}
 
Example 5
Source File: ParameterizedTypeImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static String parameterizedTypeToString(DocEnv env, ClassType cl,
                                        boolean full) {
    if (env.legacyDoclet) {
        return TypeMaker.getTypeName(cl, full);
    }
    StringBuilder s = new StringBuilder();
    if (!(cl.getEnclosingType().hasTag(CLASS))) {               // if not an inner class...
        s.append(TypeMaker.getTypeName(cl, full));
    } else {
        ClassType encl = (ClassType)cl.getEnclosingType();
        s.append(parameterizedTypeToString(env, encl, full))
         .append('.')
         .append(cl.tsym.name.toString());
    }
    s.append(TypeMaker.typeArgumentsString(env, cl, full));
    return s.toString();
}
 
Example 6
Source File: Printer.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
public String visitClassType(ClassType t, Locale locale) {
    StringBuffer buf = new StringBuffer();
    if (t.getEnclosingType().tag == CLASS && t.tsym.owner.kind == Kinds.TYP) {
        buf.append(visit(t.getEnclosingType(), locale));
        buf.append(".");
        buf.append(className(t, false, locale));
    } else {
        buf.append(className(t, true, locale));
    }
    if (t.getTypeArguments().nonEmpty()) {
        buf.append('<');
        buf.append(visitTypes(t.getTypeArguments(), locale));
        buf.append(">");
    }
    return buf.toString();
}
 
Example 7
Source File: ParameterizedTypeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static String parameterizedTypeToString(DocEnv env, ClassType cl,
                                        boolean full) {
    if (env.legacyDoclet) {
        return TypeMaker.getTypeName(cl, full);
    }
    StringBuilder s = new StringBuilder();
    if (!(cl.getEnclosingType().hasTag(CLASS))) {               // if not an inner class...
        s.append(TypeMaker.getTypeName(cl, full));
    } else {
        ClassType encl = (ClassType)cl.getEnclosingType();
        s.append(parameterizedTypeToString(env, encl, full))
         .append('.')
         .append(cl.tsym.name.toString());
    }
    s.append(TypeMaker.typeArgumentsString(env, cl, full));
    return s.toString();
}
 
Example 8
Source File: ParameterizedTypeImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static String parameterizedTypeToString(DocEnv env, ClassType cl,
                                        boolean full) {
    if (env.legacyDoclet) {
        return TypeMaker.getTypeName(cl, full);
    }
    StringBuilder s = new StringBuilder();
    if (!(cl.getEnclosingType().hasTag(CLASS))) {               // if not an inner class...
        s.append(TypeMaker.getTypeName(cl, full));
    } else {
        ClassType encl = (ClassType)cl.getEnclosingType();
        s.append(parameterizedTypeToString(env, encl, full))
         .append('.')
         .append(cl.tsym.name.toString());
    }
    s.append(TypeMaker.typeArgumentsString(env, cl, full));
    return s.toString();
}
 
Example 9
Source File: ParameterizedTypeImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static String parameterizedTypeToString(DocEnv env, ClassType cl,
                                        boolean full) {
    if (env.legacyDoclet) {
        return TypeMaker.getTypeName(cl, full);
    }
    StringBuilder s = new StringBuilder();
    if (!(cl.getEnclosingType().hasTag(CLASS))) {               // if not an inner class...
        s.append(TypeMaker.getTypeName(cl, full));
    } else {
        ClassType encl = (ClassType)cl.getEnclosingType();
        s.append(parameterizedTypeToString(env, encl, full))
         .append('.')
         .append(cl.tsym.name.toString());
    }
    s.append(TypeMaker.typeArgumentsString(env, cl, full));
    return s.toString();
}
 
Example 10
Source File: ParameterizedTypeImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static String parameterizedTypeToString(DocEnv env, ClassType cl,
                                        boolean full) {
    if (env.legacyDoclet) {
        return TypeMaker.getTypeName(cl, full);
    }
    StringBuilder s = new StringBuilder();
    if (!(cl.getEnclosingType().hasTag(CLASS))) {               // if not an inner class...
        s.append(TypeMaker.getTypeName(cl, full));
    } else {
        ClassType encl = (ClassType)cl.getEnclosingType();
        s.append(parameterizedTypeToString(env, encl, full))
         .append('.')
         .append(cl.tsym.name.toString());
    }
    s.append(TypeMaker.typeArgumentsString(env, cl, full));
    return s.toString();
}
 
Example 11
Source File: VarTypePrinter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Type visitClassType(ClassType t, Boolean upward) {
    if (upward && !t.isCompound() && t.tsym.name.isEmpty()) {
        //lift anonymous class type to first supertype (class or interface)
        return types.directSupertypes(t).last();
    } else if (t.isCompound()) {
        List<Type> components = types.directSupertypes(t);
        List<Type> components1 = components.map(c -> c.map(this, upward));
        if (components == components1) return t;
        else return types.makeIntersectionType(components1);
    } else {
        Type outer = t.getEnclosingType();
        Type outer1 = visit(outer, upward);
        List<Type> typarams = t.getTypeArguments();
        List<Type> typarams1 = typarams.map(ta -> mapTypeArgument(ta, upward));
        if (typarams1.stream().anyMatch(ta -> ta.hasTag(BOT))) {
            //not defined
            return syms.botType;
        }
        if (outer1 == outer && typarams1 == typarams) return t;
        else return new ClassType(outer1, typarams1, t.tsym, t.getMetadata()) {
            @Override
            protected boolean needsStripping() {
                return true;
            }
        };
    }
}