diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaGlobalMemberNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaGlobalMemberNameCompletionContributor.java index 036cf0d7a155..968199205071 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaGlobalMemberNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaGlobalMemberNameCompletionContributor.java @@ -1,5 +1,6 @@ package com.intellij.codeInsight.completion; +import com.intellij.codeInsight.lookup.AutoCompletionPolicy; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.VariableLookupItem; import com.intellij.psi.*; @@ -46,9 +47,9 @@ public class JavaGlobalMemberNameCompletionContributor extends CompletionContrib shouldImport |= originalPosition != null && PsiTreeUtil.isAncestor(containingClass, originalPosition, false); if (member instanceof PsiMethod) { - return new JavaMethodCallElement((PsiMethod)member, shouldImport, false); + return AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(new JavaMethodCallElement((PsiMethod)member, shouldImport, false)); } - return new VariableLookupItem((PsiField)member, shouldImport); + return AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(new VariableLookupItem((PsiField)member, shouldImport)); } @Override diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy index 4a4c202b8c1c..412f5c61c8b6 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/GlobalMemberNameCompletionTest.groovy @@ -3,7 +3,8 @@ package com.intellij.codeInsight.completion; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import com.intellij.codeInsight.CodeInsightSettings import com.intellij.util.ArrayUtil -import com.intellij.codeInsight.lookup.LookupElementPresentation; +import com.intellij.codeInsight.lookup.LookupElementPresentation +import com.intellij.codeInsight.lookup.LookupElement; /** * @author peter @@ -65,7 +66,7 @@ public class Foo { } """) myFixture.configureByText "a.java", "class Bar {{ abcf }}" - def element = myFixture.complete(CompletionType.CLASS_NAME)[0] + def element = complete()[0] def presentation = new LookupElementPresentation() element.renderElement(presentation) assert 'Foo.abcfield' == presentation.itemText @@ -73,6 +74,10 @@ public class Foo { assert 'int' == presentation.typeText } + private LookupElement[] complete() { + myFixture.complete(CompletionType.BASIC, 2) + } + public void testQualifiedMethodName() throws Exception { myFixture.addClass(""" package foo; @@ -157,7 +162,7 @@ class Bar {{ abcmethod1() }}""" """) myFixture.configureByText("a.java", "class Bar {{ abcm }}") - myFixture.complete(CompletionType.CLASS_NAME) + complete() assertOrderedEquals myFixture.lookupElementStrings, "abcmethod", "abcmethod1" } @@ -171,7 +176,7 @@ class A { } } """) - def element = myFixture.complete(CompletionType.CLASS_NAME)[0] + def element = complete()[0] def presentation = new LookupElementPresentation() element.renderElement(presentation) assert 'foo' == presentation.itemText @@ -190,7 +195,7 @@ class A { private void doTest(String input, boolean importStatic, String output) { myFixture.configureByText("a.java", input) - def item = assertOneElement(myFixture.complete(CompletionType.CLASS_NAME)) + def item = assertOneElement(complete()) if (importStatic) { item.'as'(StaticallyImportable).shouldBeImported = true } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index cc56df142398..9ae24972daa2 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -1110,7 +1110,7 @@ public class ListUtils { public static void bar() {} } """) - doTest() + doTest('\n') } public void testSuggestMembersOfStaticallyImportedClassesUnqualifiedOnly() throws Exception { @@ -1338,7 +1338,7 @@ public class ListUtils { public void testListArrayListCast() { doTest('\n') } public void testInterfaceImplementationNoCast() { doTest() } - public void testStaticallyImportedMethodsBeforeExpression() { doTest() } + public void testStaticallyImportedMethodsBeforeExpression() { doTest('\n') } public void testInnerChainedReturnType() { doTest() } public void testOverwriteGenericsAfterNew() { doTest('\n') }