コード例 #1
0
 @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;
 }
コード例 #2
0
  @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;
  }