InjectScopeOrQualifierAnnotationRetention.java 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号