ScopeOrQualifierAnnotationRetention.java 文件源码

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

项目:error-prone 作者:
private Description describe(
    ClassTree classTree, VisitorState state, @Nullable Retention retention) {
  if (retention == null) {
    return describeMatch(
        classTree,
        SuggestedFix.builder()
            .addImport("java.lang.annotation.Retention")
            .addStaticImport("java.lang.annotation.RetentionPolicy.RUNTIME")
            .prefixWith(classTree, "@Retention(RUNTIME)\n")
            .build());
  }
  AnnotationTree retentionNode = null;
  for (AnnotationTree annotation : classTree.getModifiers().getAnnotations()) {
    if (ASTHelpers.getSymbol(annotation)
        .equals(state.getSymbolFromString(RETENTION_ANNOTATION))) {
      retentionNode = annotation;
    }
  }
  return describeMatch(
      retentionNode,
      SuggestedFix.builder()
          .addImport("java.lang.annotation.Retention")
          .addStaticImport("java.lang.annotation.RetentionPolicy.RUNTIME")
          .replace(retentionNode, "@Retention(RUNTIME)")
          .build());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号