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


Java AnnotatedDeclaredType.wasRaw方法代码示例

本文整理汇总了Java中org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType.wasRaw方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedDeclaredType.wasRaw方法的具体用法?Java AnnotatedDeclaredType.wasRaw怎么用?Java AnnotatedDeclaredType.wasRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType的用法示例。


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

示例1: fromTypeTree

import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
/**
 * Determines the annotated type from a type in tree form.  This method
 * does not add implicit annotations.
 *
 * @param tree the type tree
 * @return the annotated type of the type in the AST
 */
public AnnotatedTypeMirror fromTypeTree(Tree tree) {
    if (fromTreeCache.containsKey(tree) && shouldReadCache) {
        return AnnotatedTypes.deepCopy(fromTreeCache.get(tree));
    }

    AnnotatedTypeMirror result = fromTreeWithVisitor(
            TypeFromTree.TypeFromTypeTreeINSTANCE, tree);

    // treat Raw as generic!
    // TODO: This doesn't handle recursive type parameter
    // e.g. class Pair<Y extends List<Y>> { ... }
    if (result.getKind() == TypeKind.DECLARED) {
        AnnotatedDeclaredType dt = (AnnotatedDeclaredType)result;
        if (dt.wasRaw()) {
            List<AnnotatedTypeMirror> typeArgs;
            Pair<Tree, AnnotatedTypeMirror> ctx = this.visitorState.getAssignmentContext();
            if (ctx != null) {
                if (ctx.second.getKind() == TypeKind.DECLARED &&
                        types.isSameType(types.erasure(ctx.second.actualType), types.erasure(dt.actualType))) {
                    typeArgs = ((AnnotatedDeclaredType) ctx.second).getTypeArguments();
                } else {
                    // TODO: we want a way to go from the raw type to an instantiation of the raw type
                    // that is compatible with the context.
                    typeArgs = null;
                }
            } else {
                // TODO: the context is null, use uninstantiated wildcards instead.
                typeArgs = new ArrayList<AnnotatedTypeMirror>();
                AnnotatedDeclaredType declaration = fromElement((TypeElement)dt.getUnderlyingType().asElement());
                for (AnnotatedTypeMirror typeParam : declaration.getTypeArguments()) {
                    AnnotatedWildcardType wct = getUninferredWildcardType((AnnotatedTypeVariable) typeParam);
                    typeArgs.add(wct);
                }
            }
            dt.setTypeArguments(typeArgs);
        }
    }
    annotateInheritedFromClass(result);
    if (shouldCache)
        fromTreeCache.put(tree, AnnotatedTypes.deepCopy(result));
    return result;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:50,代码来源:AnnotatedTypeFactory.java

示例2: ignoreRawTypeArguments

import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
protected boolean ignoreRawTypeArguments(AnnotatedDeclaredType rhs, AnnotatedDeclaredType lhs) {
    return checker.hasOption("ignoreRawTypeArguments") &&
            (rhs.wasRaw() || lhs.wasRaw());
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:5,代码来源:TypeHierarchy.java


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