mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
do not replace type with immediate type without necessity (IDEA-56926)
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
class A {
|
||||
class B {
|
||||
}
|
||||
|
||||
class C {
|
||||
void testHere() {
|
||||
B vari = new B();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class A {
|
||||
class B {
|
||||
}
|
||||
|
||||
class C {
|
||||
void testHere() {
|
||||
new <caret>B()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,15 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.refactoring.introduceVariable.InputValidator;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
|
||||
import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -207,6 +212,24 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
|
||||
doTest(new MockIntroduceVariableHandler("foo1", true, true, false, "Foo"));
|
||||
}
|
||||
|
||||
public void testSiblingInnerClassType() throws Exception {
|
||||
doTest(new MockIntroduceVariableHandler("vari", true, false, false, "A.B"){
|
||||
@Override
|
||||
protected IntroduceVariableSettings getSettings(Project project,
|
||||
Editor editor,
|
||||
PsiExpression expr,
|
||||
PsiElement[] occurrences,
|
||||
boolean anyAssignmentLHS,
|
||||
boolean declareFinalIfAll,
|
||||
PsiType type,
|
||||
TypeSelectorManagerImpl typeSelectorManager,
|
||||
InputValidator validator) {
|
||||
Assert.assertTrue(type.getPresentableText(), type.getPresentableText().equals("B"));
|
||||
return super.getSettings(project, editor, expr, occurrences, anyAssignmentLHS, declareFinalIfAll, type, typeSelectorManager, validator);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testNonExpressionPriorityFailure() throws Exception {
|
||||
doTest(new MockIntroduceVariableHandler("sum", true, true, false, "int"){
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user