introduce parameter on non-expressive line ( IDEA-26367 )
authoranna <anna.kozlova@jetbrains.com>
Fri, 23 Apr 2010 16:39:03 +0000 (20:39 +0400)
committeranna <anna.kozlova@jetbrains.com>
Mon, 26 Apr 2010 13:56:48 +0000 (17:56 +0400)
java/java-impl/src/com/intellij/refactoring/introduceField/ElementToWorkOn.java

index 26f2a212b2047197fc73a54bf46558b44341286f..128fd029fc89de17f2f62d6132f5db1e4cb1b921 100644 (file)
@@ -79,9 +79,16 @@ public class ElementToWorkOn {
 
         final int offset = editor.getCaretModel().getOffset();
         final PsiElement[] statementsInRange = IntroduceVariableBase.findStatementsAtOffset(editor, file, offset);
+
         if (statementsInRange.length == 1 && PsiUtil.hasErrorElementChild(statementsInRange[0])) {
           editor.getSelectionModel().selectLineAtCaret();
-        } else {
+          final ElementToWorkOn elementToWorkOn = getElementToWorkOn(editor, file, refactoringName, helpId, project, localVar, expr);
+          if (elementToWorkOn == null || elementToWorkOn.getLocalVariable() == null && elementToWorkOn.getExpression() == null) {
+            editor.getSelectionModel().removeSelection();
+          }
+        }
+
+        if (!editor.getSelectionModel().hasSelection()){
           final List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(file, editor, offset, statementsInRange);
           if (expressions.isEmpty()) {
             editor.getSelectionModel().selectLineAtCaret();