From 8e189439ca9aa63555f5dd20ebe161c79aa9cfe5 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 16 Apr 2013 14:56:05 +0200 Subject: [PATCH] test for IDEA-105455 --- .../introduceVariable/IntroduceVariableBase.java | 6 +++++- .../ReturnNonExportedArray.after.java | 8 ++++++++ .../introduceVariable/ReturnNonExportedArray.java | 6 ++++++ .../intellij/refactoring/IntroduceVariableTest.java | 12 ++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/refactoring/introduceVariable/ReturnNonExportedArray.after.java create mode 100644 java/java-tests/testData/refactoring/introduceVariable/ReturnNonExportedArray.java diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java index b2aa15916b26..3e18ae1af275 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java @@ -560,7 +560,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase { supportProvider != null && editor.getSettings().isVariableInplaceRenameEnabled() && supportProvider.isInplaceIntroduceAvailable(expr, nameSuggestionContext) && - !ApplicationManager.getApplication().isUnitTestMode() && + (!ApplicationManager.getApplication().isUnitTestMode() || isInplaceAvailableInTestMode()) && !isInJspHolderMethod(expr); if (isInplaceAvailableOnDataContext) { @@ -653,6 +653,10 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase { return wasSucceed[0]; } + protected boolean isInplaceAvailableInTestMode() { + return false; + } + private static ExpressionOccurrenceManager createOccurrenceManager(PsiExpression expr, PsiElement tempContainer) { boolean skipForStatement = true; final PsiForStatement forStatement = PsiTreeUtil.getParentOfType(expr, PsiForStatement.class); diff --git a/java/java-tests/testData/refactoring/introduceVariable/ReturnNonExportedArray.after.java b/java/java-tests/testData/refactoring/introduceVariable/ReturnNonExportedArray.after.java new file mode 100644 index 000000000000..ebd5a17ad231 --- /dev/null +++ b/java/java-tests/testData/refactoring/introduceVariable/ReturnNonExportedArray.after.java @@ -0,0 +1,8 @@ +import java.io.File; + +class Test { + java.io.File[] get() {return null;} + { + File[] files = get(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/introduceVariable/ReturnNonExportedArray.java b/java/java-tests/testData/refactoring/introduceVariable/ReturnNonExportedArray.java new file mode 100644 index 000000000000..4d6455a8aede --- /dev/null +++ b/java/java-tests/testData/refactoring/introduceVariable/ReturnNonExportedArray.java @@ -0,0 +1,6 @@ +class Test { + java.io.File[] get() {return null;} + { + get() + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java index eff899fb422d..0ac07353cb60 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java @@ -1,6 +1,7 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; +import com.intellij.idea.Bombed; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.CommonClassNames; @@ -18,6 +19,7 @@ import junit.framework.Assert; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import java.util.Calendar; import java.util.Collection; /** @@ -396,6 +398,16 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase { doTest(new MockIntroduceVariableHandler("m", false, false, false, "Foo.I")); } + @Bombed(month = Calendar.APRIL, day = 22, user = "Roman") + public void testReturnNonExportedArray() throws Exception { + doTest(new MockIntroduceVariableHandler("i", false, false, false, "java.io.File[]") { + @Override + protected boolean isInplaceAvailableInTestMode() { + return true; + } + }); + } + private void doTest(IntroduceVariableBase testMe) throws Exception { @NonNls String baseName = "/refactoring/introduceVariable/" + getTestName(false); configureByFile(baseName + ".java");