mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
test 2nd basic instead of class name completion: java global member name
This commit is contained in:
+3
-2
@@ -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
|
||||
|
||||
+10
-5
@@ -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<caret> }}"
|
||||
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()<caret> }}"""
|
||||
""")
|
||||
|
||||
myFixture.configureByText("a.java", "class Bar {{ abcm<caret> }}")
|
||||
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
|
||||
}
|
||||
|
||||
+2
-2
@@ -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') }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user