mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
preselect available type, leave inacessible in combo
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
void foo() {
|
||||
class C {}
|
||||
C c<caret>c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
class C {}
|
||||
|
||||
void foo() {
|
||||
C c<caret>c;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.intellij.refactoring;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiJavaFile;
|
||||
import com.intellij.psi.PsiLocalVariable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
@@ -87,6 +88,37 @@ public class IntroduceConstantTest extends LightCodeInsightTestCase {
|
||||
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
public void testResultedType() throws Exception {
|
||||
checkDefaultType("java.lang.Object");
|
||||
}
|
||||
|
||||
public void testResultedTypeWhenNonLocal() throws Exception {
|
||||
checkDefaultType("Test.C");
|
||||
}
|
||||
|
||||
private void checkDefaultType(final String expectedType) throws Exception {
|
||||
configureByFile(BASE_PATH + getTestName(false) + ".java");
|
||||
new MockIntroduceConstantHandler(null){
|
||||
@Override
|
||||
protected Settings showRefactoringDialog(Project project,
|
||||
Editor editor,
|
||||
PsiClass parentClass,
|
||||
PsiExpression expr,
|
||||
PsiType type,
|
||||
PsiExpression[] occurences,
|
||||
PsiElement anchorElement,
|
||||
PsiElement anchorElementIfAll) {
|
||||
final TypeSelectorManagerImpl selectorManager =
|
||||
new TypeSelectorManagerImpl(project, type, PsiTreeUtil.getParentOfType(anchorElement, PsiMethod.class), expr, occurences);
|
||||
final PsiType psiType = selectorManager.getDefaultType();
|
||||
Assert.assertEquals(psiType.getCanonicalText(), expectedType);
|
||||
return new Settings("xxx", true, true, true,
|
||||
InitializationPlace.IN_FIELD_DECLARATION, getVisibility(), null, psiType, false,
|
||||
parentClass, false, false);
|
||||
}
|
||||
}.invoke(getProject(), getEditor(), getFile(), null);
|
||||
}
|
||||
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk17("java 1.5");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user