Search in sources :

Example 1 with GroovyDocPsiElement

use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement in project intellij-community by JetBrains.

the class GrDocCommentUtil method findDocOwner.

@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;
    element = skipWhiteSpacesAndStopOnDoc(element, true);
    if (element instanceof GrDocCommentOwner)
        return (GrDocCommentOwner) element;
    if (element instanceof GrMembersDeclaration) {
        GrMember[] members = ((GrMembersDeclaration) element).getMembers();
        if (members.length > 0 && members[0] instanceof GrDocCommentOwner) {
            return (GrDocCommentOwner) members[0];
        }
    }
    return null;
}
Also used : GroovyDocPsiElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement) GrMember(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember) GrMembersDeclaration(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration) GrDocCommentOwner(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner) PsiElement(com.intellij.psi.PsiElement) GroovyDocPsiElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 Nullable (org.jetbrains.annotations.Nullable)1 GrDocCommentOwner (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner)1 GroovyDocPsiElement (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GroovyDocPsiElement)1 GrMember (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember)1 GrMembersDeclaration (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration)1