ScopeOrQualifierAnnotationRetention.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:error-prone 作者:
@Override
public final Description matchClass(ClassTree classTree, VisitorState state) {
  if (SCOPE_OR_QUALIFIER_ANNOTATION_MATCHER.matches(classTree, state)) {
    ClassSymbol classSymbol = ASTHelpers.getSymbol(classTree);
    if (hasSourceRetention(classSymbol)) {
      return describe(classTree, state, ASTHelpers.getAnnotation(classSymbol, Retention.class));
    }

    // TODO(glorioso): This is a poor hack to exclude android apps that are more likely to not
    // have reflective DI than normal java. JSR spec still says the annotations should be
    // runtime-retained, but this reduces the instances that are flagged.
    if (!state.isAndroidCompatible() && doesNotHaveRuntimeRetention(classSymbol)) {
      // Is this in a dagger component?
      ClassTree outer = ASTHelpers.findEnclosingNode(state.getPath(), ClassTree.class);
      if (outer != null && InjectMatchers.IS_DAGGER_COMPONENT_OR_MODULE.matches(outer, state)) {
        return Description.NO_MATCH;
      }
      return describe(classTree, state, ASTHelpers.getAnnotation(classSymbol, Retention.class));
    }
  }
  return Description.NO_MATCH;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号