@Nullable public static GrDocComment findDocComment(GrDocCommentOwner owner) { PsiElement element = owner.getPrevSibling(); while (true) { if (element == null) return null; final ASTNode node = element.getNode(); if (node == null) return null; if (GroovyElementTypes.GROOVY_DOC_COMMENT.equals(node.getElementType()) || !GroovyElementTypes.WHITE_SPACES_OR_COMMENTS.contains(node.getElementType())) { break; } element = element.getPrevSibling(); } if (element instanceof GrDocComment) return (GrDocComment) element; return null; }
@Nullable public static GrDocCommentOwner findDocOwner(GroovyDocPsiElement docElement) { PsiElement element = docElement; while (element != null && element.getParent() instanceof GroovyDocPsiElement) element = element.getParent(); if (element == null) return null; while (true) { element = element.getNextSibling(); if (element == null) return null; final ASTNode node = element.getNode(); if (node == null) return null; if (GroovyElementTypes.GROOVY_DOC_COMMENT.equals(node.getElementType()) || !GroovyElementTypes.WHITE_SPACES_OR_COMMENTS.contains(node.getElementType())) { break; } } if (element instanceof GrDocCommentOwner) return (GrDocCommentOwner) element; return null; }