本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}