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


Java AnnotatedDeclaredType.replaceAnnotation方法代码示例

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


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

示例1: getImplicitReceiverType

import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
@Override
protected AnnotatedDeclaredType getImplicitReceiverType(ExpressionTree tree) {
    AnnotatedDeclaredType receiver = super.getImplicitReceiverType(tree);
    if (receiver != null && !isMostEnclosingThisDeref(tree)) {
        receiver.replaceAnnotation(READONLY);
    }
    return receiver;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:9,代码来源:ImmutabilityAnnotatedTypeFactory.java

示例2: visitDeclared

import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
@Override
public Void visitDeclared(AnnotatedDeclaredType type,
        Map<String, AnnotationMirror> p) {
    if (type.hasAnnotationRelaxed(I)) {
        String immutableString =
            AnnotationUtils.getElementValue(getImmutabilityAnnotation(type),
                    IMMUTABILITY_KEY, String.class, true);
        if (p.containsKey(immutableString)) {
            type.replaceAnnotation(p.get(immutableString));
        }
    }

    return super.visitDeclared(type, p);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:15,代码来源:ImmutabilityAnnotatedTypeFactory.java

示例3: setSelfTypeInInitializationCode

import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
protected void setSelfTypeInInitializationCode(Tree tree,
        AnnotatedDeclaredType selfType, TreePath path) {
    ClassTree enclosingClass = TreeUtils.enclosingClass(path);
    Type classType = ((JCTree) enclosingClass).type;
    AnnotationMirror annotation = null;

    // If all fields are committed-only, and they are all initialized,
    // then it is save to switch to @UnderInitialization(CurrentClass).
    if (areAllFieldsCommittedOnly(enclosingClass)) {
        Store store = getStoreBefore(tree);
        if (store != null) {
            List<AnnotationMirror> annos = Collections.emptyList();
            if (getUninitializedInvariantFields(store, path, false,
                    annos).size() == 0) {
                if (useFbc) {
                    annotation = createFreeAnnotation(classType);
                } else {
                    annotation = createUnclassifiedAnnotation(classType);
                }
            }
        }
    }

    if (annotation == null) {
        annotation = getFreeOrRawAnnotationOfSuperType(classType);
    }
    selfType.replaceAnnotation(annotation);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:29,代码来源:InitializationAnnotatedTypeFactory.java

示例4: visitExecutable

import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
@Override
public Void visitExecutable(AnnotatedExecutableType t, Void p) {
    Void result = super.visitExecutable(t, p);
    Element elem = t.getElement();
    if (elem.getKind() == ElementKind.CONSTRUCTOR) {
        AnnotatedDeclaredType returnType = (AnnotatedDeclaredType) t.getReturnType();
        DeclaredType underlyingType = returnType.getUnderlyingType();
        returnType.replaceAnnotation(getFreeOrRawAnnotationOfSuperType(underlyingType));
    }
    return result;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:12,代码来源:InitializationAnnotatedTypeFactory.java

示例5: visitNewClass

import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
@Override
public AnnotatedTypeMirror visitNewClass(NewClassTree node,
        AnnotatedTypeFactory f) {
    // constructorFromUse obviously has Void as return type.
    // Therefore, use the overall type to return.
    AnnotatedDeclaredType type = f.fromNewClass(node);
    // Enum constructors lead to trouble.
    // TODO: is there more to check? Can one annotate them?
    if (isNewEnum(type)) {
        return type;
    }
    // Add annotations that are on the constructor declaration.
    // constructorFromUse gives us resolution of polymorphic qualifiers.
    // However, it also applies defaulting, so we might apply too many qualifiers.
    // Therefore, ensure to only add the qualifiers that are explicitly on
    // the constructor, but then take the possibly substituted qualifier.
    AnnotatedExecutableType ex = f.constructorFromUse(node).first;

    ExecutableElement ctor = TreeUtils.elementFromUse(node);
    // TODO: There will be a nicer way to access this in 308 soon.
    List<TypeCompound> decall = ((com.sun.tools.javac.code.Symbol)ctor).getRawTypeAttributes();
    Set<AnnotationMirror> decret = AnnotationUtils.createAnnotationSet();
    for (TypeCompound da : decall) {
        if (da.position.type == com.sun.tools.javac.code.TargetType.METHOD_RETURN) {
            decret.add(da);
        }
    }

    // Collect all polymorphic qualifiers; we should substitute them.
    Set<AnnotationMirror> polys = AnnotationUtils.createAnnotationSet();
    for (AnnotationMirror anno : type.getAnnotations()) {
        if (QualifierPolymorphism.isPolymorphicQualified(anno)) {
            polys.add(anno);
        }
    }

    for (AnnotationMirror cta : ex.getReturnType().getAnnotations()) {
        AnnotationMirror ctatop = f.getQualifierHierarchy().getTopAnnotation(cta);
        if (f.isSupportedQualifier(cta) &&
                !type.isAnnotatedInHierarchy(cta)) {
            for (AnnotationMirror fromDecl : decret) {
                if (f.isSupportedQualifier(fromDecl) &&
                        AnnotationUtils.areSame(ctatop,
                                f.getQualifierHierarchy().getTopAnnotation(fromDecl))) {
                    type.addAnnotation(cta);
                    break;
                }
            }
        }

        // Go through the polymorphic qualifiers and see whether
        // there is anything left to replace.
        for (AnnotationMirror pa : polys) {
            if (AnnotationUtils.areSame(ctatop,
                    f.getQualifierHierarchy().getTopAnnotation(pa))) {
                type.replaceAnnotation(cta);
                break;
            }
        }
    }
    return type;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:63,代码来源:TypeFromTree.java


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