LineRange (@NotNull PsiElement member, Editor editor, LineRange lineRange) { final TextRange textRange = member.getTextRange(); if (editor.getDocument().getTextLength() < textRange.getEndOffset()) return null; int startLine = editor.offsetToLogicalPosition(textRange.getStartOffset()).line; int endLine = editor.offsetToLogicalPosition(textRange.getEndOffset()).line+1; // if member includes a comment (non-javadoc) and it wasn't selected by user, don't move it with member Couple<LineRange> splitRanges = extractCommentRange(member); if (lineRange.startLine >= splitRanges.first.endLine) startLine = splitRanges.second.startLine; else if (lineRange.endLine < splitRanges.second.startLine) endLine = splitRanges.first.endLine; if (!isInsideDeclaration(member, startLine, endLine, lineRange, editor)) return null; return new LineRange(startLine, endLine); }