本文整理汇总了Java中org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType.isAnnotatedInHierarchy方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedDeclaredType.isAnnotatedInHierarchy方法的具体用法?Java AnnotatedDeclaredType.isAnnotatedInHierarchy怎么用?Java AnnotatedDeclaredType.isAnnotatedInHierarchy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType
的用法示例。
在下文中一共展示了AnnotatedDeclaredType.isAnnotatedInHierarchy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelfType
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
@Override
public AnnotatedDeclaredType getSelfType(Tree tree) {
AnnotatedDeclaredType selfType = super.getSelfType(tree);
TreePath path = getPath(tree);
ClassTree enclosingClass = TreeUtils.enclosingClass(path);
if (enclosingClass == null) {
// I hope this only happens when tree is a fake tree that
// we created, e.g. when desugaring enhanced-for-loops.
enclosingClass = getCurrentClassTree(tree);
}
AnnotatedDeclaredType enclosingClassType = getAnnotatedType(enclosingClass);
if (!selfType.isAnnotatedInHierarchy(READ_ONLY)) { // If there's already an annotation on selfType and it conflicts with MaybeMutable, that error will be found by the type validity check elsewhere.
if (enclosingClassType.isAnnotatedInHierarchy(READ_ONLY)) {
annotateInheritedFromClass(selfType, enclosingClassType.getAnnotations());
}
else {
selfType.addAnnotation(MAYBE_MUTABLE);
}
}
return selfType;
}
示例2: visitDeclared
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
@Override
public Void visitDeclared(AnnotatedDeclaredType type, Void p) {
if (type.isAnnotatedInHierarchy(BOTTOM_QUAL))
return super.visitDeclared(type, p);
/*if (elem != null &&
elem.getKind() == ElementKind.CLASS &&
TypesUtils.isObject(type.getUnderlyingType()))
type.addAnnotation(World.class);*/
return super.visitDeclared(type, p);
}
示例3: visitDeclared
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType; //导入方法依赖的package包/类
@Override
public Void visitDeclared(AnnotatedDeclaredType type, Tree p) {
AnnotationMirror kf = type.getAnnotation(KeyFor.class);
if (kf != null) {
List<String> maps = AnnotationUtils.getElementValueArray(kf, "value", String.class, false);
boolean inStatic = false;
if (p.getKind() == Kind.VARIABLE) {
ModifiersTree mt = ((VariableTree) p).getModifiers();
if (mt.getFlags().contains(Modifier.STATIC)) {
inStatic = true;
}
}
for (String map : maps) {
if (map.equals("this")) {
// this is not valid in static context
if (inStatic) {
checker.report(
Result.failure("keyfor.type.invalid",
type.getAnnotations(),
type.toString()), p);
}
} else if (map.matches("#(\\d+)")) {
// Accept parameter references
// TODO: look for total number of parameters and only
// allow the range 0 to n-1
} else {
// Only other option is local variable and field names?
// TODO: go through all possibilities.
}
}
}
// TODO: Should BaseTypeValidator be parametric in the ATF?
if (type.isAnnotatedInHierarchy(((KeyForAnnotatedTypeFactory)atypeFactory).KEYFOR)) {
return super.visitDeclared(type, p);
} else {
// TODO: Something went wrong...
return null;
}
}
示例4: 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;
}