コード例 #1
0
 private static void deleteMemberWithDocComment(GrDocCommentOwner docCommentOwner) {
   GrDocComment oldDoc = docCommentOwner.getDocComment();
   if (oldDoc != null) {
     oldDoc.delete();
   }
   docCommentOwner.delete();
 }
コード例 #2
0
  public static GrDocComment setDocComment(
      @NotNull GrDocCommentOwner owner, @Nullable GrDocComment comment) {
    GrDocComment docComment = owner.getDocComment();

    if (docComment != null) {
      if (comment == null) {
        docComment.delete();
        return null;
      } else {
        PsiElement added = docComment.replace(comment);
        assert added instanceof GrDocComment;
        return (GrDocComment) added;
      }
    } else {
      if (comment == null) return null;

      PsiElement parent = owner.getParent();

      ASTNode node = owner.getNode();
      parent.getNode().addLeaf(GroovyTokenTypes.mNLS, "\n ", node);

      PsiElement added = parent.addBefore(comment, owner);
      assert added instanceof GrDocComment;

      return (GrDocComment) added;
    }
  }
 public PsiComment findExistingDocComment(PsiComment contextElement) {
   if (contextElement instanceof GrDocComment) {
     final GrDocCommentOwner owner = GrDocCommentUtil.findDocOwner((GrDocComment) contextElement);
     if (owner != null) {
       return owner.getDocComment();
     }
   }
   return null;
 }