当前位置: 首页>>代码示例>>Java>>正文


Java AnnotatedDeclaredType.isAnnotatedInHierarchy方法代码示例

本文整理汇总了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;
  }
 
开发者ID:mcoblenz,项目名称:Glacier,代码行数:24,代码来源:GlacierAnnotatedTypeFactory.java

示例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);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:12,代码来源:OwnershipAnnotatedTypeFactory.java

示例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;
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:43,代码来源:KeyForVisitor.java

示例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;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:63,代码来源:TypeFromTree.java


注:本文中的org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType.isAnnotatedInHierarchy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。