Completion in multi-catch

This commit is contained in:
Roman Shevchenko
2011-03-10 16:40:34 +01:00
parent 74f50e196a
commit 9593bfc3f1
12 changed files with 92 additions and 15 deletions

View File

@@ -9,6 +9,8 @@ import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.module.JavaModuleType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.TestDataPath;
@@ -70,7 +72,7 @@ public class ClassNameCompletionTest extends CompletionTestCase {
public void testInPlainTextFile() throws Exception {
configureByFile(BASE_PATH + getTestName(false) + ".txt");
checkResultByFile(BASE_PATH + getTestName(false) + "_after.txt");
checkResultByFile(BASE_PATH + getTestName(false) + "_after.txt");
}
public void testDoubleStringBuffer() throws Exception {
@@ -95,7 +97,7 @@ public class ClassNameCompletionTest extends CompletionTestCase {
private void doTest() throws Exception {
String path = BASE_PATH + "/java/";
configureByFile(path + getTestName(false) + ".java");
checkResultByFile(path + getTestName(false) + "_after.java");
checkResultByFile(path + getTestName(false) + "_after.java");
}
public void testNameCompletionJava() throws Exception {
@@ -108,14 +110,14 @@ public class ClassNameCompletionTest extends CompletionTestCase {
checkResultByFile(path + "/test2-result.java");
}
public void testImplementsFiltering1() throws Exception{
public void testImplementsFiltering1() throws Exception {
final String path = BASE_PATH + "/nameCompletion/java";
configureByFile(path + "/test4-source.java");
performAction();
checkResultByFile(path + "/test4-result.java");
}
public void testImplementsFiltering2() throws Exception{
public void testImplementsFiltering2() throws Exception {
final String path = BASE_PATH + "/nameCompletion/java";
configureByFile(path + "/test3-source.java");
performAction();
@@ -135,7 +137,7 @@ public class ClassNameCompletionTest extends CompletionTestCase {
return "testAnnotationFiltering".equals(getName());
}
public void testAnnotationFiltering() throws Exception{
public void testAnnotationFiltering() throws Exception {
final String path = BASE_PATH + "/nameCompletion/java";
configureByFile(path + "/test7-source.java");
performAction();
@@ -217,9 +219,23 @@ public class ClassNameCompletionTest extends CompletionTestCase {
checkResultByFile(BASE_PATH + "/nameCompletion/java/" + getTestName(false) + "-result.java");
}
public void testInCatchType1() throws Exception { doJavaTest(); }
public void testInCatchType2() throws Exception { doJavaTest(); }
public void testInMultiCatchType1() throws Exception {
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
doJavaTest();
}
public void testInMultiCatchType2() throws Exception {
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
doJavaTest();
}
private void doJavaTest() throws Exception {
final String path = BASE_PATH + "/nameCompletion/java";
configureByFile(path + "/" + getTestName(false) + "-source.java");
configureByFileNoCompletion(path + "/" + getTestName(false) + "-source.java");
performAction();
checkResultByFile(path + "/" + getTestName(false) + "-result.java");
}
@@ -237,10 +253,11 @@ public class ClassNameCompletionTest extends CompletionTestCase {
CodeCompletionHandlerBase handler = new CodeCompletionHandlerBase(CompletionType.CLASS_NAME);
handler.invokeCompletion(myProject, myEditor);
final LookupManager instance = LookupManager.getInstance(myProject);
if(instance instanceof LookupManagerImpl){
if (instance instanceof LookupManagerImpl) {
final LookupManagerImpl testLookupManager = ((LookupManagerImpl)instance);
if(testLookupManager.getActiveLookup() != null)
if (testLookupManager.getActiveLookup() != null) {
testLookupManager.forceSelection(Lookup.NORMAL_SELECT_CHAR, 0);
}
}
}
}