本文整理汇总了Java中org.checkerframework.javacutil.AnnotationUtils.createAnnotationSet方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationUtils.createAnnotationSet方法的具体用法?Java AnnotationUtils.createAnnotationSet怎么用?Java AnnotationUtils.createAnnotationSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.checkerframework.javacutil.AnnotationUtils
的用法示例。
在下文中一共展示了AnnotationUtils.createAnnotationSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finish
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
protected void finish(QualifierHierarchy qualHierarchy,
Map<AnnotationMirror, Set<AnnotationMirror>> fullMap,
Map<AnnotationMirror, AnnotationMirror> polyQualifiers,
Set<AnnotationMirror> tops, Set<AnnotationMirror> bottoms,
Object... args) {
// Careful, when this method is called, a field this.bottom would not be set yet.
if (args != null && args[0] != null) {
AnnotationMirror thebottom = (AnnotationMirror) args[0];
// A special bottom qualifier was provided; go through the existing
// bottom qualifiers and tie them all to this bottom qualifier.
// Set<AnnotationMirror> bottoms = findBottoms(supertypes);
Set<AnnotationMirror> allQuals = AnnotationUtils.createAnnotationSet();
allQuals.addAll(fullMap.keySet());
allQuals.remove(thebottom);
AnnotationUtils.updateMappingToImmutableSet(fullMap, thebottom, allQuals);
// thebottom is initially a top qualifier
tops.remove(thebottom);
// thebottom is now the single bottom qualifier
bottoms.clear();
bottoms.add(thebottom);
}
}
示例2: bottomsOnly
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private static boolean bottomsOnly(Elements elements, AnnotatedTypeFactory atypeFactory,
Set<AnnotationMirror> annotations) {
Set<AnnotationMirror> bots = AnnotationUtils.createAnnotationSet();
bots.addAll(atypeFactory.getQualifierHierarchy().getBottomAnnotations());
// Return true if all the qualifiers that are present are
// bottom qualifiers. Allow fewer qualifiers to be present,
// which can happen for type variables and wildcards.
boolean allbot = true;
for (AnnotationMirror am : annotations) {
if (!bots.remove(am)) {
allbot = false;
}
}
return allbot;
}
示例3: findAllSupers
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Finds all the super qualifiers for a qualifier.
*
* @param anno
* @param supertypesMap
* @return
*/
private static Set<AnnotationMirror>
findAllSupers(AnnotationMirror anno,
Map<AnnotationMirror, Set<AnnotationMirror>> supertypes,
Map<AnnotationMirror, Set<AnnotationMirror>> allSupersSoFar) {
Set<AnnotationMirror> supers = AnnotationUtils.createAnnotationSet();
if (allSupersSoFar.containsKey(anno))
return Collections.unmodifiableSet(allSupersSoFar.get(anno));
// Updating the visited list before and after helps avoid
// infinite loops. TODO: cleaner way?
allSupersSoFar.put(anno, supers);
for (AnnotationMirror superAnno : supertypes.get(anno)) {
supers.add(superAnno);
supers.addAll(findAllSupers(superAnno, supertypes, allSupersSoFar));
}
allSupersSoFar.put(anno, Collections.unmodifiableSet(supers));
return supers;
}
示例4: addFromByteCode
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Adds @FromByteCode to methods and constructors declared in class files
* that are not already annotated with @FromStubFile
*
* @param elt
*/
private void addFromByteCode(Element elt) {
if (indexDeclAnnos == null){// || trees.getTree(elt) != null) {
// Parsing stub files, don't add @FromByteCode
return;
}
if (elt.getKind() == ElementKind.CONSTRUCTOR ||
elt.getKind() == ElementKind.METHOD) {
// Only add @FromByteCode to Methods and Constructors
if (ElementUtils.isElementFromByteCode(elt)) {
Set<AnnotationMirror> annos = indexDeclAnnos.get(ElementUtils
.getVerboseName(elt));
if (annos == null) {
annos = AnnotationUtils.createAnnotationSet();
indexDeclAnnos.put(ElementUtils.getVerboseName(elt), annos);
}
if (!annos.contains(AnnotationUtils.fromClass(elements,
FromStubFile.class))) {
annos.add(fromByteCode);
}
}
}
}
示例5: getExplicitAnnotations
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Returns the set of explicitly written annotations supported by this checker.
* This is useful to check the validity of annotations explicitly present on a type,
* as flow inference might add annotations that were not previously present.
*
* @return The set of explicitly written annotations supported by this checker.
*/
public Set<AnnotationMirror> getExplicitAnnotations() {
// TODO JSR 308: The explicit type annotations should be always present
Set<AnnotationMirror> explicitAnnotations = AnnotationUtils.createAnnotationSet();
List<? extends AnnotationMirror> typeAnnotations = this.getUnderlyingType().getAnnotationMirrors();
Set<? extends AnnotationMirror> validAnnotations = atypeFactory.getQualifierHierarchy().getTypeQualifiers();
for (AnnotationMirror explicitAnno : typeAnnotations) {
for (AnnotationMirror validAnno : validAnnotations) {
if (AnnotationUtils.areSameIgnoringValues(explicitAnno, validAnno)) {
explicitAnnotations.add(explicitAnno);
}
}
}
return explicitAnnotations;
}
示例6: leastUpperBoundsTypeVariable
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Returns the type qualifiers that are the least upper bound of
* the qualifiers in annos1 and annos2.
* <p>
*
* This is necessary for determining the type of a conditional
* expression (<tt>?:</tt>), where the type of the expression is the
* least upper bound of the true and false clauses.
*
* <p>
* This method works even if the underlying Java type is a type variable.
* In that case, a 'null' AnnnotationMirror and the empty set represent a meaningful
* value (namely, no annotation).
*
* @return the least upper bound of annos1 and annos2
*/
public Set<? extends AnnotationMirror>
leastUpperBoundsTypeVariable(Collection<? extends AnnotationMirror> annos1, Collection<? extends AnnotationMirror> annos2) {
Set<AnnotationMirror> result = AnnotationUtils.createAnnotationSet();
for (AnnotationMirror top : getTopAnnotations()) {
AnnotationMirror anno1ForTop = null;
for (AnnotationMirror anno1 : annos1) {
if (isSubtypeTypeVariable(anno1, top)) {
anno1ForTop = anno1;
}
}
AnnotationMirror anno2ForTop = null;
for (AnnotationMirror anno2 : annos2) {
if (isSubtypeTypeVariable(anno2, top)) {
anno2ForTop = anno2;
}
}
AnnotationMirror t = leastUpperBoundTypeVariable(anno1ForTop, anno2ForTop);
if (t != null) {
result.add(t);
}
}
return result;
}
示例7: greatestLowerBoundsTypeVariable
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Returns the type qualifiers that are the greatest lower bound of
* the qualifiers in annos1 and annos2.
*
* The two qualifiers have to be from the same qualifier hierarchy. Otherwise,
* null will be returned.
*
* <p>
* This method works even if the underlying Java type is a type variable.
* In that case, a 'null' AnnnotationMirror and the empty set represent a meaningful
* value (namely, no annotation).
*
* @param annos1 First collection of qualifiers
* @param annos2 Second collection of qualifiers
* @return Greatest lower bound of the two collections of qualifiers
*/
public Set<? extends AnnotationMirror>
greatestLowerBoundsTypeVariable(Collection<? extends AnnotationMirror> annos1, Collection<? extends AnnotationMirror> annos2) {
Set<AnnotationMirror> result = AnnotationUtils.createAnnotationSet();
for (AnnotationMirror top : getTopAnnotations()) {
AnnotationMirror anno1ForTop = null;
for (AnnotationMirror anno1 : annos1) {
if (isSubtypeTypeVariable(anno1, top)) {
anno1ForTop = anno1;
}
}
AnnotationMirror anno2ForTop = null;
for (AnnotationMirror anno2 : annos2) {
if (isSubtypeTypeVariable(anno2, top)) {
anno2ForTop = anno2;
}
}
AnnotationMirror t = greatestLowerBoundTypeVariable(anno1ForTop, anno2ForTop);
if (t != null) {
result.add(t);
}
}
return result;
}
示例8: updateMappingToMutableSet
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Update a mapping from some key to a set of AnnotationMirrors.
* If the key already exists in the mapping and the new qualifier
* is in the same qualifier hierarchy as any of the existing qualifiers,
* do nothing and return false.
* If the key already exists in the mapping and the new qualifier
* is not in the same qualifier hierarchy as any of the existing qualifiers,
* add the qualifier to the existing set and return true.
* If the key does not exist in the mapping, add the new qualifier as a
* singleton set and return true.
*
* @param map The mapping to modify.
* @param key The key to update.
* @param newQual The value to add.
* @return Whether there was a qualifier hierarchy collision.
*/
public <T> boolean updateMappingToMutableSet(
Map<T, Set<AnnotationMirror>> map,
T key, AnnotationMirror newQual) {
if (!map.containsKey(key)) {
Set<AnnotationMirror> set = AnnotationUtils.createAnnotationSet();
set.add(newQual);
map.put(key, set);
} else {
Set<AnnotationMirror> prevs = map.get(key);
for (AnnotationMirror p : prevs) {
if (AnnotationUtils.areSame(getTopAnnotation(p),
getTopAnnotation(newQual))) {
return false;
}
}
prevs.add(newQual);
map.put(key, prevs);
}
return true;
}
示例9: getSubSupertype
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
@Override
protected void getSubSupertype() {
Set<AnnotationMirror> topSet = AnnotationUtils.createAnnotationSet();
Set<AnnotationMirror> bottomSet = AnnotationUtils.createAnnotationSet();
topSet.add(top);
bottomSet.add(bottom);
this.typeToInt.put(top, 0);
this.typeToInt.put(bottom, 1);
this.intToType.put(0, top);
this.intToType.put(1, bottom);
subType.put(top, allTypes);
superType.put(top, topSet);
subType.put(bottom, bottomSet);
superType.put(bottom, allTypes);
}
示例10: reduce
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
public Map<AnnotationMirror, Set<? extends AnnotationMirror>> reduce(Map<AnnotationMirror, Set<? extends AnnotationMirror>> r1,
Map<AnnotationMirror, Set<? extends AnnotationMirror>> r2) {
if (r1 == null || r1.isEmpty())
return r2;
if (r2 == null || r2.isEmpty())
return r1;
Map<AnnotationMirror, Set<? extends AnnotationMirror>> res =
new HashMap<AnnotationMirror, Set<? extends AnnotationMirror>>(r1.size());
// Ensure that all qualifiers from r1 and r2 are visited.
Set<AnnotationMirror> r2remain = AnnotationUtils.createAnnotationSet();
r2remain.addAll(r2.keySet());
for (Map.Entry<AnnotationMirror, Set<? extends AnnotationMirror>> kv1 : r1.entrySet()) {
AnnotationMirror key1 = kv1.getKey();
Set<? extends AnnotationMirror> a1Annos = kv1.getValue();
Set<? extends AnnotationMirror> a2Annos = r2.get(key1);
if (a2Annos != null && !a2Annos.isEmpty()) {
r2remain.remove(key1);
Set<? extends AnnotationMirror> lubs = qualhierarchy.leastUpperBounds(a1Annos, a2Annos);
res.put(key1, lubs);
} else {
res.put(key1, a1Annos);
}
}
for (AnnotationMirror key2 : r2remain) {
res.put(key2, r2.get(key2));
}
return res;
}
示例11: findTops
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Infer the tops of the subtype hierarchy. Simple finds the qualifiers
* that have no supertypes.
*/
// Not static to allow adaptation in subclasses. Only parameters should be modified.
protected Set<AnnotationMirror>
findTops(Map<AnnotationMirror, Set<AnnotationMirror>> supertypes) {
Set<AnnotationMirror> possibleTops = AnnotationUtils.createAnnotationSet();
for (AnnotationMirror anno : supertypes.keySet()) {
if (supertypes.get(anno).isEmpty())
possibleTops.add(anno);
}
return possibleTops;
}
示例12: findBottoms
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Infer the bottoms of the subtype hierarchy. Simple finds the qualifiers
* that are not supertypes of other qualifiers.
*/
// Not static to allow adaptation in subclasses. Only parameters should be modified.
protected Set<AnnotationMirror>
findBottoms(Map<AnnotationMirror, Set<AnnotationMirror>> supertypes) {
Set<AnnotationMirror> possibleBottoms = AnnotationUtils.createAnnotationSet();
possibleBottoms.addAll(supertypes.keySet());
for (Set<AnnotationMirror> supers : supertypes.values()) {
possibleBottoms.removeAll(supers);
}
return possibleBottoms;
}
示例13: findSmallestTypes
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private Set<AnnotationMirror> findSmallestTypes(Set<AnnotationMirror> inset) {
Set<AnnotationMirror> outset = AnnotationUtils.createAnnotationSet();
outset.addAll(inset);
for( AnnotationMirror a1 : inset ) {
Iterator<AnnotationMirror> outit = outset.iterator();
while( outit.hasNext() ) {
AnnotationMirror a2 = outit.next();
if( a1 != a2 && isSubtype(a1, a2) ) {
outit.remove();
}
}
}
return outset;
}
示例14: findGreatestTypes
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
private Set<AnnotationMirror> findGreatestTypes(Set<AnnotationMirror> inset) {
Set<AnnotationMirror> outset = AnnotationUtils.createAnnotationSet();
outset.addAll(inset);
for( AnnotationMirror a1 : inset ) {
Iterator<AnnotationMirror> outit = outset.iterator();
while( outit.hasNext() ) {
AnnotationMirror a2 = outit.next();
if( a1 != a2 && isSubtype(a2, a1) ) {
outit.remove();
}
}
}
return outset;
}
示例15: addDeclAnnotations
import org.checkerframework.javacutil.AnnotationUtils; //导入方法依赖的package包/类
/**
* Adds a declAnnotation to every method in the stub file.
*
* @param declAnnos
* @param elt
*/
private void addDeclAnnotations(
Map<String, Set<AnnotationMirror>> declAnnos, ExecutableElement elt) {
if (fromStubFile != null) {
Set<AnnotationMirror> annos = declAnnos.get(ElementUtils
.getVerboseName(elt));
if (annos == null) {
annos = AnnotationUtils.createAnnotationSet();
putOrAddToMap(declAnnos, ElementUtils.getVerboseName(elt), annos);
}
annos.add(fromStubFile);
}
}