本文整理汇总了Java中org.checkerframework.javacutil.AnnotationUtils.areSameByClass方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationUtils.areSameByClass方法的具体用法?Java AnnotationUtils.areSameByClass怎么用?Java AnnotationUtils.areSameByClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.checkerframework.javacutil.AnnotationUtils
的用法示例。
在下文中一共展示了AnnotationUtils.areSameByClass方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitVariable
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
public Void visitVariable(VariableTree node, Void p) {
// is this a field (and not a local variable)?
if (TreeUtils.elementFromDeclaration(node).getKind().isField()) {
Set<AnnotationMirror> annotationMirrors = atypeFactory.getAnnotatedType(
node).getExplicitAnnotations();
// Fields cannot have commitment annotations.
for (Class<? extends Annotation> c : atypeFactory.getInitializationAnnotations()) {
for (AnnotationMirror a : annotationMirrors) {
if (atypeFactory.isUnclassified(a)) continue; // unclassified is allowed
if (AnnotationUtils.areSameByClass(a, c)) {
checker.report(Result.failure(
COMMITMENT_INVALID_FIELD_ANNOTATION, node),
node);
break;
}
}
}
}
return super.visitVariable(node, p);
}
示例2: visitMethod
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
public Void visitMethod(MethodTree node, Void p) {
if (TreeUtils.isConstructor(node)) {
Collection<? extends AnnotationMirror> returnTypeAnnotations = getExplicitReturnTypeAnnotations(node);
// check for invalid constructor return type
for (Class<? extends Annotation> c : atypeFactory.getInvalidConstructorReturnTypeAnnotations()) {
for (AnnotationMirror a : returnTypeAnnotations) {
if (AnnotationUtils.areSameByClass(a, c)) {
checker.report(Result.failure(
COMMITMENT_INVALID_CONSTRUCTOR_RETURN_TYPE,
node), node);
break;
}
}
}
// Check that all fields have been initialized at the end of the
// constructor.
boolean isStatic = false;
Store store = atypeFactory.getRegularExitStore(node);
List<? extends AnnotationMirror> receiverAnnotations = getAllReceiverAnnotations(node);
checkFieldsInitialized(node, isStatic, store, receiverAnnotations);
}
return super.visitMethod(node, p);
}
示例3: annoIsPresented
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private boolean annoIsPresented(AnnotationMirror anno) {
if (AnnotationUtils.areSameByClass(anno, DataFlowTop.class)) {
return true;
}
String[] datatypes;
if (this.isRoot) {
datatypes = DataflowUtils.getTypeNameRoots(anno);
} else {
datatypes = DataflowUtils.getTypeNames(anno);
}
return Arrays.asList(datatypes).contains(datatype);
}
示例4: annoIsPresented
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private boolean annoIsPresented(AnnotationMirror anno) {
if (AnnotationUtils.areSameByClass(anno, DataFlowTop.class)) {
return true;
}
String[] datatypes = DataflowUtils.getTypeNames(anno);
String[] datatype = DataflowUtils.getTypeNames(this.lattice.top);
return Arrays.asList(datatypes).contains(datatype[0]);
}
示例5: containsSameIgnoringValues
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private boolean containsSameIgnoringValues(
Set<Class<? extends Annotation>> quals, AnnotationMirror anno) {
for (Class<? extends Annotation> q : quals) {
if (AnnotationUtils.areSameByClass(anno, q)) {
return true;
}
}
return false;
}
示例6: getDeclAnnotationWithMetaAnnotation
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Returns a list of all declaration annotations used to annotate this element,
* which have a meta-annotation (i.e., an annotation on that annotation)
* with class {@code metaAnnotation}.
*
* @param element
* The element for which to determine annotations.
* @param metaAnnotation
* The meta annotation that needs to be present.
* @return A list of pairs {@code (anno, metaAnno)} where {@code anno} is
* the annotation mirror at {@code element}, and {@code metaAnno} is
* the annotation mirror used to annotate {@code anno}.
*/
public List<Pair<AnnotationMirror, AnnotationMirror>> getDeclAnnotationWithMetaAnnotation(
Element element, Class<? extends Annotation> metaAnnotation) {
List<Pair<AnnotationMirror, AnnotationMirror>> result = new ArrayList<>();
List<AnnotationMirror> annotationMirrors = new ArrayList<>();
// Consider real annotations.
annotationMirrors.addAll(element.getAnnotationMirrors());
// Consider stub annotations.
String eltName = ElementUtils.getVerboseName(element);
Set<AnnotationMirror> stubAnnos = indexDeclAnnos.get(eltName);
if (stubAnnos != null) {
annotationMirrors.addAll(stubAnnos);
}
// Go through all annotations found.
for (AnnotationMirror annotation : annotationMirrors) {
List<? extends AnnotationMirror> annotationsOnAnnotation;
try {
annotationsOnAnnotation = annotation.getAnnotationType().asElement().getAnnotationMirrors();
} catch (com.sun.tools.javac.code.Symbol.CompletionFailure cf) {
// Fix for Issue 309: If a CompletionFailure occurs, issue a warning.
// I didn't find a nicer alternative to check whether the Symbol can be completed.
// The completer field of a Symbol might be non-null also in successful cases.
// Issue a warning (exception only happens once) and continue.
checker.message(Kind.WARNING, annotation.getAnnotationType().asElement(),
"annotation.not.completed", ElementUtils.getVerboseName(element), annotation);
continue;
}
// First call copier, if exception, continue normal modula laws.
for (AnnotationMirror a : annotationsOnAnnotation) {
if (AnnotationUtils.areSameByClass(a, metaAnnotation)) {
result.add(Pair.of(annotation, a));
}
}
}
return result;
}
示例7: getAnnotationWithMetaAnnotation
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Returns a list of all annotations used to annotate this element,
* which have a meta-annotation (i.e., an annotation on that annotation)
* with class {@code metaAnnotation}.
*
* @param element
* The element at which to look for annotations.
* @param metaAnnotation
* The meta annotation that needs to be present.
* @return A list of pairs {@code (anno, metaAnno)} where {@code anno} is
* the annotation mirror at {@code element}, and {@code metaAnno} is
* the annotation mirror used to annotate {@code anno}.
*/
public List<Pair<AnnotationMirror, AnnotationMirror>> getAnnotationWithMetaAnnotation(
Element element, Class<? extends Annotation> metaAnnotation) {
List<Pair<AnnotationMirror, AnnotationMirror>> result = new ArrayList<>();
List<AnnotationMirror> annotationMirrors = new ArrayList<>();
// Consider real annotations.
annotationMirrors.addAll(getAnnotatedType(element).getAnnotations());
// Consider stub annotations.
String eltName = ElementUtils.getVerboseName(element);
Set<AnnotationMirror> stubAnnos = indexDeclAnnos.get(eltName);
if (stubAnnos != null) {
annotationMirrors.addAll(stubAnnos);
}
// Go through all annotations found.
for (AnnotationMirror annotation : annotationMirrors) {
List<? extends AnnotationMirror> annotationsOnAnnotation = annotation
.getAnnotationType().asElement().getAnnotationMirrors();
for (AnnotationMirror a : annotationsOnAnnotation) {
if (AnnotationUtils.areSameByClass(a, metaAnnotation)) {
result.add(Pair.of(annotation, a));
}
}
}
return result;
}
示例8: getAnnotation
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Returns the actual annotation mirror used to annotate this type,
* whose name equals the passed annotationName if one exists, null otherwise.
*
* @param annoClass annotation class
* @return the annotation mirror for anno
*/
public AnnotationMirror getAnnotation(Class<? extends Annotation> annoClass) {
for (AnnotationMirror annoMirror : getAnnotations()) {
if (AnnotationUtils.areSameByClass(annoMirror, annoClass)) {
return annoMirror;
}
}
return null;
}
示例9: isUnclassified
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Is {@code anno} the {@link UnknownInitialization} annotation (with any type
* frame)? If {@code useFbc} is false, then {@link Raw} is used in the
* comparison.
*/
public boolean isUnclassified(AnnotationMirror anno) {
Class<? extends Annotation> clazz = useFbc ? UnknownInitialization.class
: Raw.class;
return AnnotationUtils.areSameByClass(anno, clazz);
}
示例10: noUnits
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private boolean noUnits(AnnotatedTypeMirror t) {
Set<AnnotationMirror> annos = t.getAnnotations();
return annos.isEmpty() ||
(annos.size() == 1 &&
AnnotationUtils.areSameByClass(annos.iterator().next(), UnknownUnits.class));
}
示例11: isPolyAll
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public static boolean isPolyAll(AnnotationMirror qual) {
return AnnotationUtils.areSameByClass(qual, PolyAll.class);
}
示例12: isFree
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Is {@code anno} the {@link UnderInitialization} annotation (with any type frame)? Always
* returns false if {@code useFbc} is false.
*/
public boolean isFree(AnnotationMirror anno) {
return useFbc && AnnotationUtils.areSameByClass(anno, UnderInitialization.class);
}