int (Editor editor, LineRange range, boolean down) { int destLine = down ? range.endLine + 1 : range.startLine - 1; if (!(range.firstElement instanceof PsiStatement)) { return destLine; } PsiElement sibling = firstNonWhiteElement(down ? range.lastElement.getNextSibling() : range.firstElement.getPrevSibling(), down); if (sibling != null) { PsiClass aClass = PsiTreeUtil.findChildOfType(sibling, PsiClass.class, true, PsiStatement.class); if (aClass != null && PsiTreeUtil.getParentOfType(aClass, PsiStatement.class) == sibling) { destLine = editor.getDocument().getLineNumber(down ? sibling.getTextRange().getEndOffset() + 1 : sibling.getTextRange().getStartOffset()); } } return destLine; }