From c66c509cbdf301d1ac3d0a1fae1b3d7ec598932b Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 27 Jan 2015 17:08:01 +0100 Subject: [PATCH] IDEA-99510 (Move statement up/down behaves unexpectedly when used on class level annotation) --- .../codeInsight/editorActions/moveUpDown/DeclarationMover.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/DeclarationMover.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/DeclarationMover.java index e81bf716a7d1..da89cbd495ec 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/DeclarationMover.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/moveUpDown/DeclarationMover.java @@ -101,7 +101,6 @@ class DeclarationMover extends LineMover { Document document = editor.getDocument(); PsiElement sibling = down ? range.lastElement.getNextSibling() : range.firstElement.getPrevSibling(); - if (sibling == null) return false; sibling = firstNonWhiteElement(sibling, down); final boolean areWeMovingClass = range.firstElement instanceof PsiClass; info.toMove = range; @@ -179,7 +178,7 @@ class DeclarationMover extends LineMover { // throws IllegalMoveException when corresponding movement has no sense @Nullable private LineRange moveInsideOutsideClassPosition(Editor editor, PsiElement sibling, final boolean isDown, boolean areWeMovingClass) throws IllegalMoveException{ - if (sibling == null) throw new IllegalMoveException(); + if (sibling == null || sibling instanceof PsiImportList) throw new IllegalMoveException(); if (sibling instanceof PsiJavaToken && ((PsiJavaToken)sibling).getTokenType() == (isDown ? JavaTokenType.RBRACE : JavaTokenType.LBRACE) && sibling.getParent() instanceof PsiClass) {