mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
smart completion tests -> community
This commit is contained in:
+88
@@ -0,0 +1,88 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
@SuppressWarnings({"ALL"})
|
||||
public class HeavySmartTypeCompletion15Test extends CompletionTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/smartType";
|
||||
|
||||
public HeavySmartTypeCompletion15Test() {
|
||||
setType(CompletionType.SMART);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
|
||||
public void testGetInstance() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/foo/" + getTestName(false) + ".java", BASE_PATH);
|
||||
performAction();
|
||||
selectItem(myItems[0]);
|
||||
checkResultByFile(BASE_PATH + "/foo/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testProtectedAnonymousConstructor() throws Throwable {
|
||||
createClass("package pkg;" +
|
||||
"public class Foo {" +
|
||||
" protected Foo(int a) {}" +
|
||||
"}");
|
||||
createClass("package pkg;" +
|
||||
"public class Bar<T> {" +
|
||||
" protected Bar(java.util.List<T> list) {}" +
|
||||
"}");
|
||||
|
||||
configureByFile(BASE_PATH + "/ProtectedAnonymousConstructor.java");
|
||||
checkResultByFile(BASE_PATH + "/ProtectedAnonymousConstructor-out.java");
|
||||
|
||||
configureByFile(BASE_PATH + "/ProtectedAnonymousConstructor2.java");
|
||||
checkResultByFile(BASE_PATH + "/ProtectedAnonymousConstructor2-out.java");
|
||||
}
|
||||
|
||||
public void testUnlockDocument() throws Throwable {
|
||||
createClass("package pkg; public class Bar {}");
|
||||
createClass("package pkg; public class Foo {" +
|
||||
" public static void foo(java.util.List<pkg.Bar> list) {}" +
|
||||
"}");
|
||||
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testClassLiteralShouldInsertImport() throws Throwable {
|
||||
createClass("package bar; public class Intf {}");
|
||||
createClass("package foo; public class Bar extends bar.Intf {}");
|
||||
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
selectItem(myItems[0]);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
private void performAction() {
|
||||
complete();
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LookupManager.getInstance(myProject).hideActiveLookup();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected Sdk getTestProjectJdk() {
|
||||
return JavaSdkImpl.getMockJdk15("java 1.5");
|
||||
}
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementDecorator;
|
||||
import com.intellij.codeInsight.lookup.LookupItem;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@SuppressWarnings({"ALL"})
|
||||
public class SecondSmartTypeCompletionTest extends LightCompletionTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/smartType/second";
|
||||
|
||||
public SecondSmartTypeCompletionTest() {
|
||||
setType(CompletionType.SMART);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void testMethodAsQualifier() throws Throwable { doTest(); }
|
||||
public void testFieldAsQualifier() throws Throwable { doTest(); }
|
||||
public void testMethodWithParams() throws Throwable { doTest(); }
|
||||
public void testMergeMethods() throws Throwable { doTest(); }
|
||||
|
||||
public void testMethodDelegation() throws Throwable { doTest(); }
|
||||
|
||||
public void testGenerics() throws Throwable { doTest(); }
|
||||
public void testQualifierMatters() throws Throwable { doTest(); }
|
||||
|
||||
public void testDifferentQualifiers() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("b.getGoo", "getBar().getGoo");
|
||||
}
|
||||
|
||||
public void testSuggestArraysAsList() throws Throwable { doTest(); }
|
||||
public void testSuggestArraysAsListWildcard() throws Throwable { doTest(); }
|
||||
|
||||
public void testSuggestToArrayWithNewEmptyArray() throws Throwable { doTest(); }
|
||||
public void testSuggestToArrayWithNewNonEmptyArray() throws Throwable { doTest(); }
|
||||
|
||||
public void testSuggestToArrayWithExistingEmptyArray() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("foos().toArray(EMPTY_ARRAY)", "foos().toArray(EMPTY_ARRAY2)");
|
||||
selectItem(myItems[0]);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testToArrayGenericArrayCreation() throws Throwable { doTest(); }
|
||||
|
||||
public void testToArrayFieldsQualifier() throws Throwable { doTest(); }
|
||||
public void testToArrayMethodQualifier() throws Throwable { doTest(); }
|
||||
|
||||
public void testToListWithQualifier() throws Throwable { doTest(); }
|
||||
|
||||
public void testSuggestToArrayWithExistingEmptyArrayFromAnotherClass() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("foos().toArray(Bar.EMPTY_ARRAY)", "foos().toArray(Bar.EMPTY_ARRAY2)");
|
||||
selectItem(myItems[0]);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testIgnoreToString() throws Throwable { doTest(); }
|
||||
public void testDontIgnoreToStringInsideIt() throws Throwable { doTest(); }
|
||||
public void testDontIgnoreToStringInStringBuilders() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("bar.substring", "bar.substring", "bar.toString");
|
||||
}
|
||||
|
||||
public void testNoObjectMethodsAsFirstPart() throws Throwable { doTest(); }
|
||||
public void testGetClassLoader() throws Throwable { doTest(); }
|
||||
|
||||
public void testChainingPerformance() throws Throwable {
|
||||
long time = System.currentTimeMillis();
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
IdeaTestUtil.assertTiming("", 3000, System.currentTimeMillis() - time);
|
||||
assertNotNull(myItems);
|
||||
}
|
||||
|
||||
public void testArrayMemberAccess() throws Throwable { doTest(); }
|
||||
public void testVarargMemberAccess() throws Throwable { doTest(); }
|
||||
public void testQualifiedArrayMemberAccess() throws Throwable { doTest(); }
|
||||
|
||||
public void testNoArraysAsListCommonPrefix() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("bar()", "foo()");
|
||||
assertEquals("Arrays.asList(f.bar())", ((LookupItem)((LookupElementDecorator)myItems[0]).getDelegate()).getPresentableText());
|
||||
assertEquals("Arrays.asList(f.foo())", ((LookupItem)((LookupElementDecorator)myItems[1]).getDelegate()).getPresentableText());
|
||||
selectItem(myItems[1]);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testRestoreInitialPrefix() throws Throwable {
|
||||
configureByFileNoComplete(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
complete(1);
|
||||
assertStringItems("MyEnum.Bar", "MyEnum.Foo");
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
complete(1);
|
||||
assertStringItems("MyEnum.Bar", "MyEnum.Foo", "my.getEnum");
|
||||
}
|
||||
|
||||
public void testDontChainStringMethodsOnString() throws Throwable { doTest(); }
|
||||
|
||||
public void testDontSuggestTooGenericMethods() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertEquals("f.barAny", myItems[0].getLookupString());
|
||||
assertEquals("f.zipAny", myItems[1].getLookupString());
|
||||
}
|
||||
|
||||
public void testNoUnqualifiedCastsInQualifiedContext() throws Throwable { doAntiTest(); }
|
||||
|
||||
private void doAntiTest() throws Exception {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertNull(myItems);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testCastInstanceofedQualifier() throws Throwable { doTest(); }
|
||||
|
||||
public void testNoLeftRecursion() throws Throwable {
|
||||
final boolean old = CodeInsightSettings.getInstance().SHOW_STATIC_AFTER_INSTANCE;
|
||||
CodeInsightSettings.getInstance().SHOW_STATIC_AFTER_INSTANCE = true;
|
||||
try {
|
||||
doAntiTest();
|
||||
}
|
||||
finally {
|
||||
CodeInsightSettings.getInstance().SHOW_STATIC_AFTER_INSTANCE = old;
|
||||
}
|
||||
}
|
||||
|
||||
public void testNoRedundantCasts() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("o.gggg", "false", "true");
|
||||
}
|
||||
|
||||
public void testEmptyListInMethodCall() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
selectItem(myItems[0]);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testSingletonMap() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
selectItem(myItems[0]);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
protected void checkResultByFile(@NonNls final String filePath) throws Exception {
|
||||
if (myItems != null) {
|
||||
System.out.println("items = " + Arrays.asList(myItems));
|
||||
}
|
||||
super.checkResultByFile(filePath);
|
||||
}
|
||||
|
||||
|
||||
private void doTest() throws Exception {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void complete() {
|
||||
complete(2);
|
||||
LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
|
||||
myItems = lookup == null ? null : lookup.getItems().toArray(LookupElement.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk15("java 1.5");
|
||||
}
|
||||
}
|
||||
+300
@@ -0,0 +1,300 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class SmartTypeCompletion15Test extends LightCompletionTestCase {
|
||||
@NonNls private static final String BASE_PATH = "/codeInsight/completion/smartType";
|
||||
private LanguageLevel myOldLanguageLevel;
|
||||
|
||||
public SmartTypeCompletion15Test() {
|
||||
setType(CompletionType.SMART);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void testAfterNewWithGenerics() throws Exception {
|
||||
doActionTest();
|
||||
}
|
||||
|
||||
public void testClassLiteral() throws Exception {
|
||||
doActionTest();
|
||||
assertStringItems("String.class");
|
||||
}
|
||||
public void testNoClassLiteral() throws Exception {
|
||||
doActionTest();
|
||||
assertStringItems("Object.class", "getClass", "Class.forName", "Class.forName");
|
||||
}
|
||||
|
||||
public void testClassLiteralInAnno2() throws Throwable {
|
||||
doActionItemTest();
|
||||
}
|
||||
|
||||
public void testClassLiteralInheritors() throws Throwable {
|
||||
doActionItemTest();
|
||||
}
|
||||
|
||||
public void testAfterNew15() throws Exception {
|
||||
doActionItemTest();
|
||||
}
|
||||
|
||||
public void testInsertOverride() throws Exception {
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
styleSettings.INSERT_OVERRIDE_ANNOTATION = true;
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_6);
|
||||
doActionItemTest();
|
||||
}
|
||||
|
||||
public void testForeach() throws Exception {
|
||||
doActionTest();
|
||||
}
|
||||
|
||||
public void testIDEADEV2626() throws Exception {
|
||||
doActionTest();
|
||||
}
|
||||
|
||||
public void testCastWith2TypeParameters() throws Throwable { doTest(); }
|
||||
|
||||
public void testAnnotation() throws Exception {
|
||||
doTest();
|
||||
testByCount(8, "ElementType.ANNOTATION_TYPE", "ElementType.CONSTRUCTOR", "ElementType.FIELD", "ElementType.LOCAL_VARIABLE",
|
||||
"ElementType.METHOD", "ElementType.PACKAGE", "ElementType.PARAMETER", "ElementType.TYPE");
|
||||
}
|
||||
|
||||
protected void checkResultByFile(@NonNls final String filePath) throws Exception {
|
||||
if (myItems != null) {
|
||||
//System.out.println("items = " + Arrays.asList(myItems));
|
||||
}
|
||||
super.checkResultByFile(filePath);
|
||||
}
|
||||
|
||||
public void testAnnotation2() throws Exception {
|
||||
doTest();
|
||||
testByCount(3, "RetentionPolicy.CLASS", "RetentionPolicy.SOURCE", "RetentionPolicy.RUNTIME");
|
||||
}
|
||||
public void testAnnotation2_2() throws Exception {
|
||||
doTest();
|
||||
testByCount(3, "RetentionPolicy.CLASS", "RetentionPolicy.SOURCE", "RetentionPolicy.RUNTIME");
|
||||
}
|
||||
|
||||
public void testAnnotation3() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAnnotation3_2() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAnnotation4() throws Exception {
|
||||
doTest();
|
||||
|
||||
testByCount(2, "true","false");
|
||||
}
|
||||
|
||||
public void testAnnotation5() throws Exception {
|
||||
doTest();
|
||||
|
||||
testByCount(2, "CONNECTION","NO_CONNECTION");
|
||||
}
|
||||
|
||||
public void testAnnotation6() throws Exception {
|
||||
doTest();
|
||||
|
||||
testByCount(8, "ElementType.ANNOTATION_TYPE", "ElementType.CONSTRUCTOR", "ElementType.FIELD", "ElementType.LOCAL_VARIABLE",
|
||||
"ElementType.METHOD", "ElementType.PACKAGE", "ElementType.PARAMETER", "ElementType.TYPE");
|
||||
}
|
||||
|
||||
public void testArrayClone() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEADEV5150() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEADEV7835() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeArgs1() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeArgs2() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEADEV2668() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExcessiveTail() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExtendsInTypeCast() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEADEV13148() throws Exception {
|
||||
configureByFile(BASE_PATH + "/IDEADEV13148.java");
|
||||
testByCount(0);
|
||||
}
|
||||
|
||||
public void testOverloadedMethods() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEnumField() throws Throwable {
|
||||
doItemTest();
|
||||
}
|
||||
|
||||
public void testEnumField1() throws Exception {
|
||||
doTest();
|
||||
assertEquals(4, myItems.length);
|
||||
}
|
||||
|
||||
public void testInsertTypeParametersOnImporting() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEmptyListInReturn() throws Throwable {
|
||||
doItemTest();
|
||||
}
|
||||
|
||||
public void testEmptyListInReturn2() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEmptyListInReturnTernary() throws Throwable {
|
||||
doItemTest();
|
||||
}
|
||||
|
||||
public void testEmptyListBeforeSemicolon() throws Throwable {
|
||||
doItemTest();
|
||||
}
|
||||
|
||||
public void testStaticallyImportedMagicMethod() throws Throwable {
|
||||
doItemTest();
|
||||
}
|
||||
|
||||
public void _testCallVarargArgument() throws Throwable { doTest(); }
|
||||
|
||||
public void testTabToReplaceClassKeyword() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
selectItem(myItems[0], Lookup.REPLACE_SELECT_CHAR);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testNoTypeParametersForToArray() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInferFromCall() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInferFromCall1() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCastToParameterizedType() throws Throwable { doActionTest(); }
|
||||
|
||||
public void testInnerEnumInMethod() throws Throwable {
|
||||
doActionItemTest();
|
||||
}
|
||||
|
||||
public void testEnumAsDefaultAnnotationParam() throws Throwable { doTest(); }
|
||||
|
||||
public void testFilterPrivateConstructors() throws Throwable { doTest(); }
|
||||
|
||||
public void testExplicitMethodTypeParametersQualify() throws Throwable { doTest(); }
|
||||
|
||||
public void testWildcardedInstanceof() throws Throwable { doTest(); }
|
||||
public void testWildcardedInstanceof2() throws Throwable { doTest(); }
|
||||
public void testWildcardedInstanceof3() throws Throwable { doTest(); }
|
||||
|
||||
public void testTypeVariableInstanceOf() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
performAction();
|
||||
assertStringItems("Bar", "Goo");
|
||||
}
|
||||
|
||||
public void testCommonPrefixWithSelection() throws Throwable {
|
||||
doItemTest();
|
||||
}
|
||||
|
||||
public void testInsideGenericClassLiteral() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
testByCount(3, "String.class", "StringBuffer.class", "StringBuilder.class");
|
||||
}
|
||||
|
||||
public void testArrayAnnoParameter() throws Throwable {
|
||||
doActionTest();
|
||||
}
|
||||
|
||||
public void testCastWithGenerics() throws Throwable {
|
||||
doActionTest();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void doTest(boolean performAction, boolean selectItem) throws Exception {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
if (performAction) {
|
||||
performAction();
|
||||
}
|
||||
if (selectItem) {
|
||||
selectItem(myItems[0]);
|
||||
}
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
private void doTest() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
private void doActionTest() throws Exception {
|
||||
doTest(true, false);
|
||||
}
|
||||
private void doItemTest() throws Exception {
|
||||
doTest(false, true);
|
||||
}
|
||||
private void doActionItemTest() throws Exception {
|
||||
doTest(true, true);
|
||||
}
|
||||
|
||||
private void performAction() {
|
||||
complete();
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone();
|
||||
styleSettings.INSERT_OVERRIDE_ANNOTATION = false;
|
||||
CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(styleSettings);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(myOldLanguageLevel);
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk15("java 1.5");
|
||||
}
|
||||
}
|
||||
+807
@@ -0,0 +1,807 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.codeInsight.lookup.impl.TestLookupManager;
|
||||
import com.intellij.codeInsight.template.SmartCompletionContextType;
|
||||
import com.intellij.codeInsight.template.Template;
|
||||
import com.intellij.codeInsight.template.TemplateContextType;
|
||||
import com.intellij.codeInsight.template.TemplateManager;
|
||||
import com.intellij.codeInsight.template.impl.TemplateImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateSettings;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SmartTypeCompletionTest extends LightCompletionTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/smartType";
|
||||
private LanguageLevel myPrevLanguageLevel;
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void testParenAfterCast1() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCast";
|
||||
|
||||
configureByFile(path + "/before1.java");
|
||||
checkResultByFile(path + "/after1.java");
|
||||
}
|
||||
|
||||
public void testParenAfterCast2() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCast";
|
||||
|
||||
configureByFile(path + "/before2.java");
|
||||
checkResultByFile(path + "/after2.java");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testParenAfterCast3() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCast";
|
||||
|
||||
configureByFile(path + "/before3.java");
|
||||
checkResultByFile(path + "/after3.java");
|
||||
}
|
||||
|
||||
public void testParenAfterCall1() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCall";
|
||||
|
||||
configureByFile(path + "/before1.java");
|
||||
checkResultByFile(path + "/after1.java");
|
||||
}
|
||||
|
||||
public void testParenAfterCall2() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCall";
|
||||
|
||||
configureByFile(path + "/before2.java");
|
||||
checkResultByFile(path + "/after2.java");
|
||||
}
|
||||
|
||||
public void testParenAfterCall3() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCall";
|
||||
|
||||
configureByFile(path + "/before3.java");
|
||||
checkResultByFile(path + "/after3.java");
|
||||
}
|
||||
|
||||
public void testParenAfterCall4() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCall";
|
||||
|
||||
configureByFile(path + "/before4.java");
|
||||
checkResultByFile(path + "/after4.java");
|
||||
}
|
||||
|
||||
public void testParenAfterCall5() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCall";
|
||||
|
||||
configureByFile(path + "/before5.java");
|
||||
checkResultByFile(path + "/after5.java");
|
||||
}
|
||||
|
||||
public void testParenAfterCall6() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCall";
|
||||
|
||||
configureByFile(path + "/before6.java");
|
||||
checkResultByFile(path + "/after6.java");
|
||||
}
|
||||
|
||||
public void testParenAfterCall1_SpaceWithinMethodCallParens() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterCall";
|
||||
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
configureByFileNoComplete(path + "/before1.java");
|
||||
styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
try{
|
||||
complete();
|
||||
}
|
||||
finally{
|
||||
styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = false;
|
||||
}
|
||||
checkResultByFile(path + "/after1_space.java");
|
||||
}
|
||||
|
||||
public void testParenAfterIf1() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterIf";
|
||||
|
||||
configureByFile(path + "/before1.java");
|
||||
checkResultByFile(path + "/after1.java");
|
||||
}
|
||||
|
||||
public void testParenAfterIf2() throws Exception {
|
||||
String path = BASE_PATH + "/parenAfterIf";
|
||||
|
||||
configureByFile(path + "/before2.java");
|
||||
checkResultByFile(path + "/after2.java");
|
||||
}
|
||||
|
||||
public void testForceLookupForAbstractClasses() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before9.java");
|
||||
checkResultByFile(path + "/after9.java");
|
||||
}
|
||||
|
||||
public void testAfterNew1() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before1.java");
|
||||
select();
|
||||
checkResultByFile(path + "/after1.java");
|
||||
}
|
||||
|
||||
public void testAfterNew2() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before2.java");
|
||||
select();
|
||||
checkResultByFile(path + "/after2.java");
|
||||
}
|
||||
|
||||
public void testAfterNew3() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before3.java");
|
||||
select();
|
||||
checkResultByFile(path + "/after3.java");
|
||||
}
|
||||
|
||||
public void testAfterNew4() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before4.java");
|
||||
select();
|
||||
checkResultByFile(path + "/after4.java");
|
||||
}
|
||||
|
||||
public void testAfterNew5() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before5.java");
|
||||
select();
|
||||
checkResultByFile(path + "/after5.java");
|
||||
}
|
||||
|
||||
public void testAfterNew6() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before6.java");
|
||||
select();
|
||||
checkResultByFile(path + "/after6.java");
|
||||
}
|
||||
|
||||
public void testAfterNew7() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before7.java");
|
||||
select();
|
||||
checkResultByFile(path + "/after7.java");
|
||||
}
|
||||
|
||||
public void testAfterNew8() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before8.java");
|
||||
select();
|
||||
checkResultByFile(path + "/after8.java");
|
||||
}
|
||||
|
||||
public void testAfterNew9() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before10.java");
|
||||
select();
|
||||
checkResultByFile(path + "/after10.java");
|
||||
}
|
||||
|
||||
public void testAfterNew10() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before12.java");
|
||||
//select();
|
||||
checkResultByFile(path + "/after12.java");
|
||||
}
|
||||
|
||||
public void testAfterNew11() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before13.java");
|
||||
//select();
|
||||
checkResultByFile(path + "/after13.java");
|
||||
}
|
||||
|
||||
public void testAfterThrowNew1() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before14.java");
|
||||
//select();
|
||||
checkResultByFile(path + "/after14.java");
|
||||
}
|
||||
|
||||
public void testAfterThrowNew2() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before15.java");
|
||||
//select();
|
||||
checkResultByFile(path + "/after15.java");
|
||||
}
|
||||
|
||||
public void testAfterThrowNew3() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/before16.java");
|
||||
//select();
|
||||
checkResultByFile(path + "/after16.java");
|
||||
}
|
||||
|
||||
public void testAfterThrow1() throws Exception {
|
||||
String path = BASE_PATH;
|
||||
|
||||
configureByFile(path + "/CastInThrow.java");
|
||||
//select();
|
||||
checkResultByFile(path + "/CastInThrow-out.java");
|
||||
}
|
||||
|
||||
public void testParenAfterNewWithinInnerExpr() throws Exception {
|
||||
String path = BASE_PATH + "/afterNew";
|
||||
|
||||
configureByFile(path + "/LastArgInInnerNewBefore.java");
|
||||
checkResultByFile(path + "/LastArgInInnerNewAfter.java");
|
||||
|
||||
//configureByFile(path + "/LastArgInInnerNewBefore2.java");
|
||||
//performAction();
|
||||
//checkResultByFile(path + "/LastArgInInnerNewAfter2.java");
|
||||
|
||||
configureByFile(path + "/LastArgInInnerNewBefore3.java");
|
||||
checkResultByFile(path + "/LastArgInInnerNewAfter3.java");
|
||||
|
||||
configureByFile(path + "/LastArgInInnerNewBefore4.java");
|
||||
checkResultByFile(path + "/LastArgInInnerNewAfter4.java");
|
||||
}
|
||||
|
||||
public void testReturn1() throws Exception{
|
||||
String path = BASE_PATH + "/return";
|
||||
configureByFile(path + "/before1.java");
|
||||
checkResultByFile(path + "/after1.java");
|
||||
}
|
||||
|
||||
public void testReturn2() throws Exception{
|
||||
String path = BASE_PATH + "/return";
|
||||
|
||||
configureByFile(path + "/before2.java");
|
||||
checkResultByFile(path + "/after2.java");
|
||||
}
|
||||
|
||||
public void testReturn3() throws Exception{
|
||||
String path = BASE_PATH + "/return";
|
||||
|
||||
configureByFile(path + "/before3.java");
|
||||
checkResultByFile(path + "/after3.java");
|
||||
}
|
||||
|
||||
public void testGenerics1() throws Exception {
|
||||
String path = BASE_PATH + "/generics";
|
||||
|
||||
configureByFile(path + "/before1.java");
|
||||
checkResultByFile(path + "/after1.java");
|
||||
}
|
||||
|
||||
public void testGenerics2() throws Exception {
|
||||
String path = BASE_PATH + "/generics";
|
||||
|
||||
configureByFile(path + "/before2.java");
|
||||
checkResultByFile(path + "/after2.java");
|
||||
}
|
||||
|
||||
public void testGenerics3() throws Exception {
|
||||
String path = BASE_PATH + "/generics";
|
||||
|
||||
configureByFile(path + "/before3.java");
|
||||
checkResultByFile(path + "/after3.java");
|
||||
}
|
||||
|
||||
public void testGenerics4() throws Exception {
|
||||
String path = BASE_PATH + "/generics";
|
||||
|
||||
configureByFile(path + "/before4.java");
|
||||
checkResultByFile(path + "/after4.java");
|
||||
}
|
||||
|
||||
public void testGenerics5() throws Exception {
|
||||
String path = BASE_PATH + "/generics";
|
||||
|
||||
configureByFile(path + "/before5.java");
|
||||
checkResultByFile(path + "/after5.java");
|
||||
}
|
||||
|
||||
public void testAfterInstanceOf1() throws Exception {
|
||||
String path = BASE_PATH + "/afterInstanceOf";
|
||||
|
||||
configureByFile(path + "/before1.java");
|
||||
checkResultByFile(path + "/after1.java");
|
||||
}
|
||||
|
||||
public void testAfterInstanceOf2() throws Exception {
|
||||
String path = BASE_PATH + "/afterInstanceOf";
|
||||
|
||||
configureByFile(path + "/before2.java");
|
||||
checkResultByFile(path + "/after2.java");
|
||||
}
|
||||
|
||||
public void testInsideCatch() throws Exception {
|
||||
String path = BASE_PATH;
|
||||
|
||||
configureByFile(path + "/InsideCatch.java");
|
||||
checkResultByFile(path + "/InsideCatch-out.java");
|
||||
}
|
||||
|
||||
|
||||
public void testGenerics6() throws Exception {
|
||||
String path = BASE_PATH + "/generics";
|
||||
|
||||
configureByFile(path + "/before6.java");
|
||||
checkResultByFile(path + "/after6.java");
|
||||
}
|
||||
|
||||
public void testWildcardNew1() throws Exception {
|
||||
String path = BASE_PATH + "/generics";
|
||||
|
||||
configureByFile(path + "/before7.java");
|
||||
checkResultByFile(path + "/after7.java");
|
||||
}
|
||||
|
||||
public void testWildcardNew2() throws Exception {
|
||||
String path = BASE_PATH + "/generics";
|
||||
|
||||
configureByFile(path + "/before8.java");
|
||||
checkResultByFile(path + "/after8.java");
|
||||
}
|
||||
|
||||
public void testWildcardEliminated() throws Exception {
|
||||
String path = BASE_PATH + "/generics";
|
||||
|
||||
configureByFile(path + "/before9.java");
|
||||
checkResultByFile(path + "/after9.java");
|
||||
}
|
||||
|
||||
public void testBug1() throws Exception { doTest(); }
|
||||
|
||||
public void testQualifiedThis() throws Exception { doTest(); }
|
||||
|
||||
public void testBug2() throws Exception {
|
||||
configureByFile(BASE_PATH + "/Bug2.java");
|
||||
}
|
||||
|
||||
|
||||
public void testSillyAssignment1() throws Exception {
|
||||
configureByFile(BASE_PATH + "/Silly1.java");
|
||||
checkResultByFile(BASE_PATH + "/Silly1.java");
|
||||
}
|
||||
|
||||
public void testVarargs1() throws Exception { doTest(); }
|
||||
|
||||
public void testEnumConstInSwitch() throws Exception { doTest(); }
|
||||
|
||||
public void testEnumConstInSwitchOutside() throws Exception { doTest(); }
|
||||
|
||||
public void testIntConstInSwitch() throws Exception { doTest(); }
|
||||
|
||||
public void testMethodCallInScriplet() throws Exception {
|
||||
configureByFile(BASE_PATH + "/"+getTestName(false)+".jsp");
|
||||
checkResultByFile(BASE_PATH + "/"+getTestName(false) + "-out.jsp");
|
||||
}
|
||||
|
||||
public void testDoubleEmptyArray() throws Exception {
|
||||
configureByFile(BASE_PATH + "/"+getTestName(false)+".java");
|
||||
checkResultByFile(BASE_PATH + "/"+getTestName(false) + ".java");
|
||||
assertEquals(2, myItems.length);
|
||||
}
|
||||
|
||||
public void testCollectionsEmptySetInMethodCall() throws Throwable { doTest(); }
|
||||
|
||||
public void testCollectionsEmptySetInTernary() throws Throwable { doTest(); }
|
||||
|
||||
public void testStringConstantInAnno() throws Throwable { doTest(); }
|
||||
|
||||
public void testCollectionsEmptySetInTernary2() throws Throwable { doTest(); }
|
||||
|
||||
public void testConstructorOnSeparateLineInMethodCall() throws Throwable { doTest(); }
|
||||
|
||||
public void testConstructorWithExistingParens() throws Throwable { doTest(); }
|
||||
|
||||
public void testMethodAnnotationNamedParameter() throws Throwable { doTest(); }
|
||||
|
||||
public void testInheritedClass() throws Throwable { doTest(); }
|
||||
|
||||
public void testClassLiteralInAnno1() throws Throwable { doTest(); }
|
||||
|
||||
public void testExplicitWildcardParam() throws Throwable { doTest(); }
|
||||
|
||||
public void testExplicitWildcardArrayParam() throws Throwable { doTest(); }
|
||||
|
||||
public void testCatchInAnonymous() throws Throwable { doTest(); }
|
||||
|
||||
public void testThrowRuntimeException() throws Throwable { doTest(); }
|
||||
|
||||
public void testParameterizedConstructor() throws Throwable { doTest(); }
|
||||
|
||||
public void testNewInnerOfParameterizedClass() throws Throwable { doTest(); }
|
||||
|
||||
public void testQualifiedThisInAnonymousConstructor() throws Throwable { doTest(); }
|
||||
|
||||
public void testExceptionTwice() throws Throwable { doTest(); }
|
||||
|
||||
public void testExceptionTwice2() throws Throwable { doTest(); }
|
||||
|
||||
public void testNewInnerRunnable() throws Throwable { doTest(); }
|
||||
|
||||
public void testArrayAccessIndex() throws Throwable { doTest(); }
|
||||
|
||||
public void testThrowExceptionConstructor() throws Throwable { doTest(); }
|
||||
|
||||
public void testJavadocThrows() throws Throwable { doTest(); }
|
||||
|
||||
public void testDoNotExcludeAssignedVariable() throws Throwable { doTest(); }
|
||||
|
||||
public void testArrayIndexTailType() throws Throwable { doTest(); }
|
||||
|
||||
public void testHonorSelection() throws Throwable { doTest(); }
|
||||
|
||||
public void testTypeParametersInheritors() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("Foo", "Bar", "Goo");
|
||||
select();
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testVoidExpectedType() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("notify", "notifyAll", "wait", "wait", "wait", "equals", "getClass", "hashCode", "toString");
|
||||
type('e');
|
||||
select();
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testDoubleSemicolonPenetration() throws Throwable { doTest(); }
|
||||
|
||||
public void testTypeParametersInheritorsComma() throws Throwable { doTest(); }
|
||||
|
||||
public void testTypeParametersInheritorsInExpression() throws Throwable { doTest(); }
|
||||
|
||||
//do we need to see all Object inheritors at all?
|
||||
public void _testTypeParametersObjectInheritors() throws Throwable { doTest(); }
|
||||
|
||||
public void testDoubleThis() throws Throwable {
|
||||
doTest();
|
||||
assertNull(myItems);
|
||||
}
|
||||
|
||||
public void testSmartFinish() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
select(Lookup.COMPLETE_STATEMENT_SELECT_CHAR);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testSillyAssignmentInTernary() throws Throwable { doTest(); }
|
||||
|
||||
public void testSameFieldInAnotherObject() throws Throwable { doTest(); }
|
||||
|
||||
public void testUnqualifiedConstantInSwitch() throws Throwable { doTest(); }
|
||||
|
||||
public void testAmbiguousConstant() throws Throwable { doTest(); }
|
||||
|
||||
public void testSameNamedFieldAndLocal() throws Throwable { doTest(); }
|
||||
|
||||
public void testAbstractClassTwice() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
final int offset = myEditor.getCaretModel().getOffset();
|
||||
select();
|
||||
myEditor.getCaretModel().moveToOffset(offset);
|
||||
assertOneElement(myItems);
|
||||
}
|
||||
|
||||
public void testConstantTwice() throws Throwable { doTest(); }
|
||||
|
||||
public void testConstantTwice2() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertEquals(2, myItems.length);
|
||||
}
|
||||
|
||||
public void testNoKeyConstant() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertEquals(2, myItems.length);
|
||||
assertEquals("A_KEY", myItems[0].getLookupString());
|
||||
assertEquals("Key.create", myItems[1].getLookupString());
|
||||
}
|
||||
|
||||
public void testUserDataListAddAll() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStaticSubclass() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethodCallDot() throws Throwable { doTest(); }
|
||||
public void testNegateVariable() throws Throwable { doTest(); }
|
||||
|
||||
public void testExclamationMethodFinish() throws Throwable { doTest('!'); }
|
||||
public void testExclamationVariableFinish() throws Throwable { doTest('!'); }
|
||||
public void testExclamationStaticFieldFinish() throws Throwable { doTest('!'); }
|
||||
public void testExclamationFinishNonBoolean() throws Throwable { doTest('!'); }
|
||||
|
||||
public void testExcludeDeclaredConstant() throws Throwable { doTest(); }
|
||||
|
||||
public void testTabMethodInBinaryExpression() throws Throwable { doTest('\t'); }
|
||||
|
||||
public void testIfConditionBinaryExpression() throws Throwable { doTest(); }
|
||||
|
||||
public void testDelegationToParent() throws Throwable { doTest(); }
|
||||
|
||||
public void testBeforeBinaryExpressionInMethodCall() throws Throwable { doTest(); }
|
||||
|
||||
public void testAssignableToAfterCast() throws Throwable { doTest(); }
|
||||
|
||||
public void testInstanceMethodParametersFromStaticContext() throws Throwable { doTest(); }
|
||||
|
||||
public void testInstanceMethodParametersFromStaticContext2() throws Throwable { doTest(); }
|
||||
|
||||
public void testBeforeCastToArray() throws Throwable { doTest(); }
|
||||
|
||||
public void testHidingFields() throws Throwable { doTest(); }
|
||||
|
||||
public void testVoidCast() throws Throwable { doAntiTest(); }
|
||||
|
||||
public void testIntPlusLongNotDouble() throws Throwable { doTest(); }
|
||||
|
||||
public void testNestedAssignments() throws Throwable { doTest(); }
|
||||
|
||||
public void testAfterNewInTernary() throws Throwable { doTest(); }
|
||||
|
||||
public void testSuggestAnythingWhenWildcardExpected() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("X<java.lang.Object>", "Y", "Z<java.lang.Object>");
|
||||
}
|
||||
|
||||
public void testNewVararg() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("Foo", "Foo");
|
||||
assertEquals(0, myItems[0].as(PsiTypeLookupItem.class).getBracketsCount());
|
||||
assertEquals(1, myItems[1].as(PsiTypeLookupItem.class).getBracketsCount());
|
||||
}
|
||||
|
||||
public void testInsideStringLiteral() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertNull(myItems);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
|
||||
}
|
||||
|
||||
public void testDefaultAnnoParam() throws Throwable { doTest(); }
|
||||
|
||||
public void testCastGenericQualifier() throws Throwable { doTest(); }
|
||||
|
||||
public void testEverythingDoubles() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertStringItems("hashCode", "indexOf", "lastIndexOf", "size");
|
||||
}
|
||||
|
||||
public void testNonStaticInnerClass() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertNull(myItems);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
//todo 2nd completion
|
||||
public void _testDefaultAnnoParam2() throws Throwable { doTest(); }
|
||||
|
||||
public void testLiveTemplate() throws Throwable {
|
||||
final Template template = TemplateManager.getInstance(getProject()).createTemplate("foo", "zzz");
|
||||
template.addTextSegment("FooFactory.createFoo()");
|
||||
final SmartCompletionContextType completionContextType =
|
||||
ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), SmartCompletionContextType.class);
|
||||
((TemplateImpl)template).getTemplateContext().setEnabled(completionContextType, true);
|
||||
TemplateSettings.getInstance().addTemplate(template);
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
TemplateSettings.getInstance().removeTemplate(template);
|
||||
}
|
||||
}
|
||||
|
||||
public void testInThisExpression() throws Throwable { doTest(); }
|
||||
|
||||
public void testSuggestNull() throws Throwable { doTest(); }
|
||||
|
||||
public void testNoNullAfterDot() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertNull(myItems);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testDefaultAnnoMethodValue() throws Throwable { doTest(); }
|
||||
|
||||
public void testUseIntConstantsFromTargetClass() throws Throwable { doTest(); }
|
||||
public void testUseIntConstantsFromTargetClassReturnValue() throws Throwable { doTest(); }
|
||||
public void testUseIntConstantsFromConstructedClass() throws Throwable { doTest(); }
|
||||
|
||||
public void testExtraSemicolonAfterMethodParam() throws Throwable {
|
||||
CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
try{
|
||||
doTest();
|
||||
}
|
||||
finally{
|
||||
styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void testAssignFromTheSameFieldOfAnotherObject() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTailAfterInstanceOf() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSuggestInstanceofedValue() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSuggestInstanceofedValueInTernary() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSuggestInstanceofedValueInComplexIf() throws Throwable { doTest(); }
|
||||
|
||||
public void testSuggestInstanceofedValueInElseNegated() throws Throwable { doTest(); }
|
||||
|
||||
public void testSuggestInstanceofedValueAfterReturn() throws Throwable { doTest(); }
|
||||
|
||||
public void testNoInstanceofedValueWhenBasicSuits() throws Throwable { doTest(); }
|
||||
|
||||
public void testSuggestCastedValueAfterCast() throws Throwable { doTest(); }
|
||||
|
||||
public void testNoInstanceofedValueInElse() throws Throwable { doAntiTest(); }
|
||||
|
||||
public void testNoInstanceofedValueInThenNegated() throws Throwable { doAntiTest(); }
|
||||
|
||||
public void testNoInstanceofedValueInElseWithComplexIf() throws Throwable { doAntiTest(); }
|
||||
|
||||
public void testReplaceWholeReferenceChain() throws Throwable { doTest(Lookup.REPLACE_SELECT_CHAR); }
|
||||
|
||||
public void testInstanceofedInsideAnonymous() throws Throwable { doTest(Lookup.REPLACE_SELECT_CHAR); }
|
||||
|
||||
public void testDoubleTrueInOverloadedMethodCall() throws Throwable { doTest(Lookup.REPLACE_SELECT_CHAR); }
|
||||
|
||||
public void testOneElementArray() throws Throwable { doTest(); }
|
||||
|
||||
public void testCastToArray() throws Throwable { doTest(); }
|
||||
|
||||
public void testDontAutoCastWhenAlreadyCasted() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertEquals("s", myItems[0].getLookupString());
|
||||
assertEquals("String.copyValueOf", myItems[1].getLookupString());
|
||||
select();
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testAutoCastWhenAlreadyCasted() throws Throwable { doTest(); }
|
||||
|
||||
public void testCommaDoublePenetration() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
select(',');
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testSuperMethodArguments() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
getLookup().setCurrentItem(getLookup().getItems().get(1));
|
||||
select();
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testDelegateMethodArguments() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
getLookup().setCurrentItem(getLookup().getItems().get(1));
|
||||
select();
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testSuperConstructorArguments() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
getLookup().setCurrentItem(getLookup().getItems().get(2));
|
||||
select();
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
private void doAntiTest() throws Exception {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertNull(myItems);
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(Lookup.NORMAL_SELECT_CHAR);
|
||||
}
|
||||
|
||||
private void doTest(final char c) throws Exception {
|
||||
boolean old = CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION;
|
||||
if (c != Lookup.NORMAL_SELECT_CHAR) {
|
||||
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = false;
|
||||
}
|
||||
|
||||
try {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
if (myItems != null && myItems.length == 1) {
|
||||
select(c);
|
||||
}
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
finally {
|
||||
if (c != Lookup.NORMAL_SELECT_CHAR) {
|
||||
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = old;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void checkResultByFile(@NonNls final String filePath) throws Exception {
|
||||
if (myItems != null) {
|
||||
System.out.println("items = " + Arrays.asList(myItems));
|
||||
}
|
||||
super.checkResultByFile(filePath);
|
||||
}
|
||||
|
||||
public void testInnerEnum() throws Exception {
|
||||
configureByFile(BASE_PATH + "/"+getTestName(false)+".java");
|
||||
|
||||
LookupManager.getActiveLookup(myEditor).setCurrentItem(ContainerUtil.find(myItems, new Condition<LookupElement>() {
|
||||
public boolean value(final LookupElement lookupItem) {
|
||||
return "Fubar.Bar".equals(lookupItem.getLookupString());
|
||||
}
|
||||
}));
|
||||
select('\n');
|
||||
checkResultByFile(BASE_PATH + "/"+getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myPrevLanguageLevel = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
setType(CompletionType.SMART);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(myPrevLanguageLevel);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
private void select() {
|
||||
select(Lookup.NORMAL_SELECT_CHAR);
|
||||
}
|
||||
|
||||
private void select(final char c) {
|
||||
if (c != '\n' && c != '\t' && c != Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
|
||||
type(c);
|
||||
return;
|
||||
}
|
||||
|
||||
final TestLookupManager manager = (TestLookupManager) LookupManager.getInstance(getProject());
|
||||
final Lookup lookup = manager.getActiveLookup();
|
||||
if(lookup != null) {
|
||||
manager.forceSelection(c, lookup.getCurrentItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user