enable introduce before void statement but with non-void qualifier (IDEA-76726 )

This commit is contained in:
anna
2011-11-13 18:58:27 +01:00
parent 412259f73d
commit 6156f780a6
4 changed files with 21 additions and 3 deletions
@@ -96,8 +96,8 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
//try line selection
if (statementsInRange.length == 1 && (PsiUtilCore.hasErrorElementChild(statementsInRange[0]) ||
!PsiUtil.isStatement(statementsInRange[0]) ||
statementsInRange[0].getTextRange().getStartOffset() >= offset ||
statementsInRange[0].getTextRange().getEndOffset() <= offset ||
statementsInRange[0].getTextRange().getStartOffset() > offset ||
statementsInRange[0].getTextRange().getEndOffset() < offset ||
isPreferStatements())) {
selectionModel.selectLineAtCaret();
final PsiExpression expressionInRange =
@@ -0,0 +1,8 @@
class Test {
void foo() {
Object c = getObject();
c.notify();
}
Object getObject() {return null;}
}
@@ -0,0 +1,7 @@
class Test {
void foo() {
<caret>getObject().notify();
}
Object getObject() {return null;}
}
@@ -16,7 +16,6 @@ import com.intellij.util.containers.MultiMap;
import junit.framework.Assert;
import org.jetbrains.annotations.NonNls;
import java.util.ArrayList;
import java.util.Collection;
/**
@@ -298,6 +297,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest(new MockIntroduceVariableHandler("b", true, true, false, "java.lang.Exception", true));
}
public void testBeforeVoidStatement() throws Exception {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "java.lang.Object"));
}
private void doTest(IntroduceVariableBase testMe) throws Exception {
@NonNls String baseName = "/refactoring/introduceVariable/" + getTestName(false);
configureByFile(baseName + ".java");