当前位置: 首页>>代码示例>>Java>>正文


Java Type.WildcardType方法代码示例

本文整理汇总了Java中com.sun.tools.javac.code.Type.WildcardType方法的典型用法代码示例。如果您正苦于以下问题:Java Type.WildcardType方法的具体用法?Java Type.WildcardType怎么用?Java Type.WildcardType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.code.Type的用法示例。


在下文中一共展示了Type.WildcardType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTypeString

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:TypeMaker.java

示例2: wildcardTypeToString

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
/**
 * 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 ");
        }
    }
    boolean first = true;   // currently only one bound is allowed
    for (Type b : bounds) {
        if (!first) {
            s.append(" & ");
        }
        s.append(TypeMaker.getTypeString(env, b, full));
        first = false;
    }
    return s.toString();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:WildcardTypeImpl.java

示例3: getTypeString

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
/**
 * 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?
    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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TypeMaker.java

示例4: visitWildcardType

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
@Override
public Void visitWildcardType(Type.WildcardType t, Void s) {
    if (t.type instanceof PlaceholderType)
        t.type = ((PlaceholderType)t.type).delegate;
    else if (t.type != null)
        t.type.accept(this, s);
    if (t.bound != null)
        t.bound.accept(this, s);
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:TypeMirrorHandle.java

示例5: getType

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
@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());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:TypeMaker.java

示例6: getTypeImpl

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
@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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:TypeMaker.java

示例7: visitIdent

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
/**
 * Erase all structural interface type literals to Object
 */
@Override
public void visitIdent( JCTree.JCIdent tree )
{
  super.visitIdent( tree );

  if( _tp.isGenerate() && !shouldProcessForGeneration() )
  {
    // Don't process tree during GENERATE, unless the tree was generated e.g., a bridge method
    return;
  }

  if( tree.sym != null && TypeUtil.isStructuralInterface( _tp, tree.sym ) && !isReceiver( tree ) )
  {
    Symbol.ClassSymbol objectSym = getObjectClass();
    Tree parent = _tp.getParent( tree );
    JCTree.JCIdent objIdent = _tp.getTreeMaker().Ident( objectSym );
    if( parent instanceof JCTree.JCVariableDecl )
    {
      ((JCTree.JCVariableDecl)parent).type = objectSym.type;

      long parameterModifier = 8589934592L; // Flag.Flag.PARAMETER.value
      if( (((JCTree.JCVariableDecl)parent).mods.flags & parameterModifier) != 0 )
      {
        objIdent.type = objectSym.type;
        ((JCTree.JCVariableDecl)parent).sym.type = objectSym.type;
        ((JCTree.JCVariableDecl)parent).vartype = objIdent;
      }
    }
    else if( parent instanceof JCTree.JCWildcard )
    {
      JCTree.JCWildcard wildcard = (JCTree.JCWildcard)parent;
      wildcard.type = new Type.WildcardType( objectSym.type, wildcard.kind.kind, wildcard.type.tsym );
    }
    tree = objIdent;
    tree.type = objectSym.type;
  }
  result = tree;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:42,代码来源:ExtensionTransformer.java

示例8: visitSelect

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
/**
 * Erase all structural interface type literals to Object
 */
@Override
public void visitSelect( JCTree.JCFieldAccess tree )
{
  super.visitSelect( tree );

  if( _tp.isGenerate() && !shouldProcessForGeneration() )
  {
    // Don't process tree during GENERATE, unless the tree was generated e.g., a bridge method
    return;
  }

  if( TypeUtil.isStructuralInterface( _tp, tree.sym ) && !isReceiver( tree ) )
  {
    Symbol.ClassSymbol objectSym = getObjectClass();
    JCTree.JCIdent objIdent = _tp.getTreeMaker().Ident( objectSym );
    Tree parent = _tp.getParent( tree );
    if( parent instanceof JCTree.JCVariableDecl )
    {
      ((JCTree.JCVariableDecl)parent).type = objectSym.type;
      long parameterModifier = 8589934592L; // Flag.Flag.PARAMETER.value
      if( (((JCTree.JCVariableDecl)parent).mods.flags & parameterModifier) != 0 )
      {
        objIdent.type = objectSym.type;
        ((JCTree.JCVariableDecl)parent).sym.type = objectSym.type;
        ((JCTree.JCVariableDecl)parent).vartype = objIdent;
      }
    }
    else if( parent instanceof JCTree.JCWildcard )
    {
      JCTree.JCWildcard wildcard = (JCTree.JCWildcard)parent;
      wildcard.type = new Type.WildcardType( objectSym.type, wildcard.kind.kind, wildcard.type.tsym );
    }
    result = objIdent;
  }
  else
  {
    result = tree;
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:43,代码来源:ExtensionTransformer.java

示例9: visitWildcardType

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
@Override
public Type visitWildcardType( Type.WildcardType t, Void s )
{
  Type bound = eraseBound( t, t.type );
  if( bound == t.type )
  {
    return t;
  }
  return new Type.WildcardType( bound, t.kind, t.tsym );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:11,代码来源:StructuralTypeEraser.java

示例10: getBound

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
public static TypeMirror getBound(WildcardType wildcardType) {
    Type.TypeVar bound = ((Type.WildcardType)wildcardType).bound;
    return bound != null ? bound.bound : null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:SourceUtils.java

示例11: WildcardTypeImpl

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
WildcardTypeImpl(DocEnv env, Type.WildcardType type) {
    super(env, type);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:WildcardTypeImpl.java

示例12: getExtendsBounds

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
private static List<Type> getExtendsBounds(Type.WildcardType wild) {
    return wild.isSuperBound()
            ? List.<Type>nil()
            : List.of(wild.type);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:WildcardTypeImpl.java

示例13: getSuperBounds

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
private static List<Type> getSuperBounds(Type.WildcardType wild) {
    return wild.isExtendsBound()
            ? List.<Type>nil()
            : List.of(wild.type);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:WildcardTypeImpl.java

示例14: visitWildcardType

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
@Override
public R visitWildcardType(Type.WildcardType t, P p) {
    return defaultAction(t, p);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:JNIWriter.java

示例15: getExtendsBounds

import com.sun.tools.javac.code.Type; //导入方法依赖的package包/类
private static List<Type> getExtendsBounds(Type.WildcardType wild) {
    return wild.isSuperBound()
            ? List.nil()
            : List.of(wild.type);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:WildcardTypeImpl.java


注:本文中的com.sun.tools.javac.code.Type.WildcardType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。