void (PsiElement element) { if (element instanceof PsiExpression && element.getParent() instanceof PsiExpressionStatement || (element.getParent() instanceof PsiDeclarationStatement && ((PsiDeclarationStatement)element.getParent()).getDeclaredElements().length == 1)) { element = element.getParent(); } else if (element.getParent() instanceof PsiJavaCodeReferenceElement) { PsiElement parent = element.getParent(); if (element instanceof PsiJavaCodeReferenceElement && ((PsiJavaCodeReferenceElement)parent).getQualifier() == element) { ASTNode dot = ((CompositeElement)parent).findChildByRole(ChildRole.DOT); if (dot != null) { PsiElement nextSibling = dot.getPsi().getNextSibling(); if (nextSibling != null && nextSibling.getTextLength() == 0) { nextSibling = PsiTreeUtil.skipWhitespacesAndCommentsForward(nextSibling); } while (nextSibling != null) { nextSibling = markUnchanged(nextSibling).getNextSibling(); } } } element = parent; } grabComments(element); }