本文整理汇总了Java中org.checkerframework.javacutil.AnnotationUtils.containsSameIgnoringValues方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationUtils.containsSameIgnoringValues方法的具体用法?Java AnnotationUtils.containsSameIgnoringValues怎么用?Java AnnotationUtils.containsSameIgnoringValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.checkerframework.javacutil.AnnotationUtils
的用法示例。
在下文中一共展示了AnnotationUtils.containsSameIgnoringValues方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeFieldAccessType
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Determine the type of a field access (implicit or explicit) based on the
* receiver type and the declared annotations for the field
* (committed-only).
*
* @param type
* Type of the field access expression.
* @param declaredFieldAnnotations
* Annotations on the element.
* @param receiverType
* Inferred annotations of the receiver.
* @param fieldAnnotations
* @param element
*/
private void computeFieldAccessType(AnnotatedTypeMirror type,
Collection<? extends AnnotationMirror> declaredFieldAnnotations,
AnnotatedTypeMirror receiverType,
AnnotatedTypeMirror fieldAnnotations, Element element) {
// not necessary for primitive fields
if (TypesUtils.isPrimitive(type.getUnderlyingType())) {
return;
}
// not necessary if there is an explicit UnknownInitialization
// annotation on the field
if (AnnotationUtils.containsSameIgnoringValues(
fieldAnnotations.getAnnotations(), UNCLASSIFIED)) {
return;
}
if (isUnclassified(receiverType)
|| isFree(receiverType)) {
TypeMirror fieldDeclarationType = element.getEnclosingElement()
.asType();
boolean isInitializedForFrame = isInitializedForFrame(receiverType, fieldDeclarationType);
if (isInitializedForFrame) {
type.replaceAnnotation(qualHierarchy.getTopAnnotation(UNCLASSIFIED));
} else {
type.clearAnnotations();
type.addAnnotations(qualHierarchy.getTopAnnotations());
}
if (!AnnotationUtils.containsSame(declaredFieldAnnotations,
NOT_ONLY_COMMITTED) || !useFbc) {
// add root annotation for all other hierarchies, and
// Committed for the commitment hierarchy
type.replaceAnnotation(COMMITTED);
}
}
}
示例2: multiplication
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
public AnnotationMirror multiplication(AnnotatedTypeMirror p1, AnnotatedTypeMirror p2) {
// TODO: does this handle scaling correctly?
if (AnnotationUtils.containsSameIgnoringValues(p1.getAnnotations(), m) &&
AnnotationUtils.containsSameIgnoringValues(p2.getAnnotations(), m)) {
return m2;
}
if (AnnotationUtils.containsSameIgnoringValues(p1.getAnnotations(), km) &&
AnnotationUtils.containsSameIgnoringValues(p2.getAnnotations(), km)) {
return km2;
}
return null;
}
示例3: division
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
public AnnotationMirror division(AnnotatedTypeMirror p1, AnnotatedTypeMirror p2) {
if (AnnotationUtils.containsSameIgnoringValues(p1.getAnnotations(), m) &&
AnnotationUtils.containsSameIgnoringValues(p2.getAnnotations(), s)) {
return mPERs;
}
if (AnnotationUtils.containsSameIgnoringValues(p1.getAnnotations(), km) &&
AnnotationUtils.containsSameIgnoringValues(p2.getAnnotations(), h)) {
return kmPERh;
}
return null;
}
示例4: commonAssignmentCheck
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
protected void commonAssignmentCheck(Tree varTree, ExpressionTree valueExp,
/*@CompilerMessageKey*/ String errorKey) {
// field write of the form x.f = y
if (TreeUtils.isFieldAccess(varTree)) {
// cast is safe: a field access can only be an IdentifierTree or
// MemberSelectTree
ExpressionTree lhs = (ExpressionTree) varTree;
ExpressionTree y = valueExp;
Element el = TreeUtils.elementFromUse(lhs);
AnnotatedTypeMirror xType = atypeFactory.getReceiverType(lhs);
AnnotatedTypeMirror yType = atypeFactory.getAnnotatedType(y);
// the special FBC rules do not apply if there is an explicit
// UnknownInitialization annotation
Set<AnnotationMirror> fieldAnnotations =
atypeFactory.getAnnotatedType(TreeUtils.elementFromUse(lhs)).getAnnotations();
if (!AnnotationUtils.containsSameIgnoringValues(
fieldAnnotations, atypeFactory.UNCLASSIFIED)) {
if (!ElementUtils.isStatic(el)
&& !(atypeFactory.isCommitted(yType) || atypeFactory.isFree(xType) || atypeFactory.isFbcBottom(yType))) {
/*@CompilerMessageKey*/ String err;
if (atypeFactory.isCommitted(xType)) {
err = COMMITMENT_INVALID_FIELD_WRITE_COMMITTED;
} else {
err = COMMITMENT_INVALID_FIELD_WRITE_UNCLASSIFIED;
}
checker.report(Result.failure(err, varTree), varTree);
return; // prevent issuing another errow about subtyping
}
// for field access on the current object, make sure that we don't
// allow
// invalid assignments. that is, even though reading this.f in a
// constructor yields @Nullable (or similar for other typesystems),
// it
// is not allowed to write @Nullable to a @NonNull field.
// This is done by first getting the type as usual (var), and then
// again not using the postAsMember method (which takes care of
// transforming the type of o.f for a free receiver to @Nullable)
// (var2). Then, we take the child annotation from var2 and use it
// for var.
AnnotatedTypeMirror var = atypeFactory.getAnnotatedType(lhs);
boolean old = atypeFactory.HACK_DONT_CALL_POST_AS_MEMBER;
atypeFactory.HACK_DONT_CALL_POST_AS_MEMBER = true;
boolean old2 = atypeFactory.shouldReadCache;
atypeFactory.shouldReadCache = false;
AnnotatedTypeMirror var2 = atypeFactory.getAnnotatedType(lhs);
atypeFactory.HACK_DONT_CALL_POST_AS_MEMBER = old;
atypeFactory.shouldReadCache = old2;
final AnnotationMirror newAnno = var2.getAnnotationInHierarchy(
atypeFactory.getFieldInvariantAnnotation());
if (newAnno != null) {
var.replaceAnnotation(newAnno);
}
checkAssignability(var, varTree);
commonAssignmentCheck(var, valueExp, errorKey, false);
return;
}
}
super.commonAssignmentCheck(varTree, valueExp, errorKey);
}
示例5: isSupportedQualifier
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Determines whether the given annotation is a part of the type system
* under which this type factory operates.
* Null is never a supported qualifier; the parameter is nullable to
* allow the result of aliasedAnnotation to be passed in directly.
*
* @param a any annotation
* @return true if that annotation is part of the type system under which
* this type factory operates, false otherwise
*/
public boolean isSupportedQualifier(/*@Nullable*/ AnnotationMirror a) {
if (a == null) return false;
return AnnotationUtils.containsSameIgnoringValues(this.getQualifierHierarchy().getTypeQualifiers(), a);
}
示例6: hasEffectiveAnnotation
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* A version of hasAnnotation that considers annotations on the
* upper bound of wildcards and type variables.
*
* @see #hasAnnotation(Class)
*/
public boolean hasEffectiveAnnotation(Class<? extends Annotation> a) {
return AnnotationUtils.containsSameIgnoringValues(
getEffectiveAnnotations(),
AnnotationUtils.fromClass(atypeFactory.elements, a));
}
示例7: hasAnnotationRelaxed
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Determines whether this type contains an annotation with the same
* annotation type as a particular annotation. This method does not
* consider an annotation's values, that is,
* if the type is "@A("s") @B(3) Object" a call with
* "@A("t"), "@A", or "@B" will return true.
*
* @param a the annotation to check for
* @return true iff the type contains an annotation with the same type as
* the annotation given by {@code a}
*
* @see #hasAnnotation(AnnotationMirror)
*/
public boolean hasAnnotationRelaxed(AnnotationMirror a) {
return AnnotationUtils.containsSameIgnoringValues(getAnnotations(), a);
}
示例8: hasEffectiveAnnotationRelaxed
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* A version of hasAnnotationRelaxed that considers annotations on the
* upper bound of wildcards and type variables.
*
* @see #hasAnnotationRelaxed(AnnotationMirror)
*/
public boolean hasEffectiveAnnotationRelaxed(AnnotationMirror a) {
return AnnotationUtils.containsSameIgnoringValues(getEffectiveAnnotations(), a);
}
示例9: hasExplicitAnnotationRelaxed
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* A version of hasAnnotationRelaxed that only considers annotations that
* are explicitly written on the type.
*
* @see #hasAnnotationRelaxed(AnnotationMirror)
*/
public boolean hasExplicitAnnotationRelaxed(AnnotationMirror a) {
return AnnotationUtils.containsSameIgnoringValues(getExplicitAnnotations(), a);
}
示例10: hasExplicitAnnotation
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Determines whether this type contains an explictly written annotation
* with the same annotation type as a particular annotation. This method
* does not consider an annotation's values.
*
* @param a the class of annotation to check for
* @return true iff the type contains an explicitly written annotation
* with the same type as the annotation given by {@code a}
*/
public boolean hasExplicitAnnotation(Class<? extends Annotation> a) {
return AnnotationUtils.containsSameIgnoringValues(getExplicitAnnotations(), getAnnotation(a));
}