mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
show only imported classes in the first completion
This commit is contained in:
-2
@@ -1,5 +1,3 @@
|
||||
import foo.ABCDEFFFFF;
|
||||
|
||||
class Xxx {
|
||||
{
|
||||
if (ABCDEFFFFF<caret>aaa.bbb()) {
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
import foo.Foo;
|
||||
import bar.*;
|
||||
|
||||
class Bar {
|
||||
{
|
||||
|
||||
+6
-2
@@ -40,12 +40,16 @@ public abstract class CompletionSortingTestCase extends LightFixtureCompletionTe
|
||||
}
|
||||
|
||||
protected LookupImpl invokeCompletion(final String path) {
|
||||
myFixture.configureFromExistingVirtualFile(
|
||||
myFixture.copyFileToProject(path, com.intellij.openapi.util.text.StringUtil.getShortName(path, '/')));
|
||||
configureNoCompletion(path);
|
||||
myFixture.complete(myType);
|
||||
return getLookup();
|
||||
}
|
||||
|
||||
protected void configureNoCompletion(String path) {
|
||||
myFixture.configureFromExistingVirtualFile(
|
||||
myFixture.copyFileToProject(path, com.intellij.openapi.util.text.StringUtil.getShortName(path, '/')));
|
||||
}
|
||||
|
||||
protected static void incUseCount(final LookupImpl lookup, final int index) {
|
||||
imitateItemSelection(lookup, index);
|
||||
refreshSorting(lookup);
|
||||
|
||||
-7
@@ -42,13 +42,6 @@ public class HeavyNormalCompletionTest extends CompletionTestCase{
|
||||
assertTrue(JavaPsiFacade.getInstance(myProject).findPackage("foo.bar.goo").isValid());
|
||||
}
|
||||
|
||||
public void testAllClassesWhenNothingIsFound() throws Throwable {
|
||||
createClass("package foo.bar; public class AxBxCxDxEx {}");
|
||||
|
||||
configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
|
||||
checkResultByFile("/codeInsight/completion/normal/" + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
public void testAllClassesOnSecondBasicCompletion() throws Throwable {
|
||||
createClass("package foo.bar; public class AxBxCxDxEx {}");
|
||||
|
||||
|
||||
+12
-10
@@ -224,11 +224,11 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
public void testFocusInJavadoc() {
|
||||
myFixture.configureByText("a.java", """
|
||||
/**
|
||||
* {@link ArrLi<caret>}
|
||||
* {@link AIO<caret>}
|
||||
*/
|
||||
class Foo {}
|
||||
""")
|
||||
type 's'
|
||||
type 'O'
|
||||
assert lookup.focused
|
||||
|
||||
}
|
||||
@@ -236,6 +236,8 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
public void testPrefixLengthDependentSorting() {
|
||||
myFixture.addClass("package foo; public class PsiJavaCodeReferenceElement {}")
|
||||
myFixture.configureByText("a.java", """
|
||||
import foo.PsiJavaCodeReferenceElement;
|
||||
|
||||
class PsiJavaCodeReferenceElementImpl {
|
||||
{ <caret> }
|
||||
}
|
||||
@@ -373,8 +375,8 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
{ <caret> }
|
||||
}
|
||||
""")
|
||||
type 'FilInpStr.'
|
||||
assert myFixture.file.text.contains("FileInputStream.")
|
||||
type 'AIOO.'
|
||||
assert myFixture.file.text.contains("ArrayIndexOutOfBoundsException.")
|
||||
assert lookup
|
||||
}
|
||||
|
||||
@@ -384,8 +386,8 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
void foo(<caret>) {}
|
||||
}
|
||||
""")
|
||||
type 'FilInpStr...'
|
||||
assert myFixture.editor.document.text.contains("FileInputStream...")
|
||||
type 'AIOO...'
|
||||
assert myFixture.editor.document.text.contains("ArrayIndexOutOfBoundsException...")
|
||||
assert !lookup
|
||||
}
|
||||
|
||||
@@ -660,8 +662,8 @@ class Foo {
|
||||
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE
|
||||
try {
|
||||
myFixture.configureByText("a.java", """ class Foo { { new <caret> } } """)
|
||||
type 'fil('
|
||||
assert myFixture.editor.document.text.contains('new File()')
|
||||
type 'aioo('
|
||||
assert myFixture.editor.document.text.contains('new ArrayIndexOutOfBoundsException()')
|
||||
}
|
||||
finally {
|
||||
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER
|
||||
@@ -796,7 +798,7 @@ public class UTest {
|
||||
|
||||
public void testSamePrefixIgnoreCase() {
|
||||
myFixture.addClass("package xxxxx; public class SYSTEM_EXCEPTION {}")
|
||||
myFixture.configureByText "a.java", "class Foo { S<caret> }"
|
||||
myFixture.configureByText "a.java", "import xxxxx.*; class Foo { S<caret> }"
|
||||
type 'Ystem'
|
||||
assert 'java.lang.System' == ((JavaPsiClassReferenceElement) myFixture.lookupElements[0]).qualifiedName
|
||||
assert 'xxxxx.SYSTEM_EXCEPTION' == ((JavaPsiClassReferenceElement) myFixture.lookupElements[1]).qualifiedName
|
||||
@@ -805,7 +807,7 @@ public class UTest {
|
||||
public void testSamePrefixIgnoreCase2() {
|
||||
myFixture.addClass("package xxxxx; public class SYSTEM_EXCEPTION {}")
|
||||
myFixture.addClass("package xxxxx; public class SYstem {}")
|
||||
myFixture.configureByText "a.java", "class Foo { S<caret> }"
|
||||
myFixture.configureByText "a.java", "import xxxxx.*; class Foo { S<caret> }"
|
||||
type 'Ystem'
|
||||
assert 'xxxxx.SYstem' == ((JavaPsiClassReferenceElement) myFixture.lookupElements[0]).qualifiedName
|
||||
assert 'java.lang.System' == ((JavaPsiClassReferenceElement) myFixture.lookupElements[1]).qualifiedName
|
||||
|
||||
+20
-7
@@ -100,7 +100,8 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
|
||||
public void testDispreferImpls() throws Throwable {
|
||||
myFixture.addClass("package foo; public class Xxx {}");
|
||||
checkPreferredItems(0, "Xxx", "XxxEx", "XxxImpl", "Xxy");
|
||||
configureSecondCompletion();
|
||||
assertPreferredItems(0, "Xxx", "XxxEx", "XxxImpl", "Xxy");
|
||||
}
|
||||
|
||||
public void testPreferOwnInnerClasses() throws Throwable {
|
||||
@@ -108,18 +109,26 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
}
|
||||
|
||||
public void testPreferTopLevelClasses() throws Throwable {
|
||||
checkPreferredItems(0, "XxxYyy", "XxzYyy");
|
||||
configureSecondCompletion();
|
||||
assertPreferredItems(0, "XxxYyy", "XxzYyy");
|
||||
}
|
||||
|
||||
private void configureSecondCompletion() {
|
||||
configureNoCompletion(getTestName(false) + ".java");
|
||||
myFixture.complete(CompletionType.BASIC, 2);
|
||||
}
|
||||
|
||||
public void testDontDispreferImplsAfterNew() throws Throwable {
|
||||
myFixture.addClass("package foo; public interface Xxx {}");
|
||||
checkPreferredItems(0, "Xxx", "XxxImpl");
|
||||
configureSecondCompletion();
|
||||
assertPreferredItems(0, "Xxx", "XxxImpl");
|
||||
}
|
||||
|
||||
public void testPreferLessHumps() throws Throwable {
|
||||
myFixture.addClass("package foo; public interface XaYa {}");
|
||||
myFixture.addClass("package foo; public interface XyYa {}");
|
||||
checkPreferredItems(0, "XaYa", "XaYaEx", "XaYaImpl", "XyYa", "XyYaXa");
|
||||
configureSecondCompletion();
|
||||
assertPreferredItems(0, "XaYa", "XaYaEx", "XaYaImpl", "XyYa", "XyYaXa");
|
||||
}
|
||||
|
||||
public void testPreferLessParameters() throws Throwable {
|
||||
@@ -133,7 +142,8 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
myFixture.addClass("package foo; public interface FooBar {}");
|
||||
myFixture.addClass("package foo; public interface FooBee {}");
|
||||
|
||||
checkPreferredItems(0, "FooBar", "FooBee");
|
||||
invokeCompletion(getTestName(false) + ".java");
|
||||
configureSecondCompletion();
|
||||
incUseCount(getLookup(), 1);
|
||||
assertPreferredItems(0, "FooBee", "FooBar");
|
||||
}
|
||||
@@ -175,7 +185,9 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
myFixture.addClass("public interface Baaaaaaar {}");
|
||||
myFixture.addClass("package zoo; public interface Baaaaaaar {}");
|
||||
|
||||
final LookupImpl lookup = invokeCompletion(getTestName(false) + ".java");
|
||||
configureSecondCompletion();
|
||||
|
||||
final LookupImpl lookup = getLookup();
|
||||
assertEquals("Baaaaaaar", ((JavaPsiClassReferenceElement) lookup.getItems().get(0)).getQualifiedName());
|
||||
assertEquals("zoo.Baaaaaaar", ((JavaPsiClassReferenceElement) lookup.getItems().get(1)).getQualifiedName());
|
||||
incUseCount(lookup, 1);
|
||||
@@ -216,6 +228,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
public void testPreselectMostRelevantInTheMiddle() {
|
||||
myFixture.addClass("package foo; public class Elaaaaaaaaaaaaaaaaaaaa {}");
|
||||
invokeCompletion(getTestName(false) + ".java");
|
||||
myFixture.completeBasic();
|
||||
LookupImpl lookup = getLookup();
|
||||
assertPreferredItems(lookup.getList().getSelectedIndex());
|
||||
assertEquals("Elaaaaaaaaaaaaaaaaaaaa", lookup.getItems().get(0).getLookupString());
|
||||
@@ -242,7 +255,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
myFixture.addClass("package bar; public class Bar {}");
|
||||
final String path = getTestName(false) + ".java";
|
||||
myFixture.configureByFile(getTestName(false) + ".java");
|
||||
myFixture.complete(CompletionType.BASIC);
|
||||
myFixture.complete(CompletionType.BASIC, 2);
|
||||
assertPreferredItems(0, "Bar", "Bar");
|
||||
List<LookupElement> items = getLookup().getItems();
|
||||
assertEquals(((JavaPsiClassReferenceElement)items.get(0)).getQualifiedName(), "Bar");
|
||||
|
||||
+16
-6
@@ -708,7 +708,11 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testReturningTypeVariable() throws Throwable { doTest(); }
|
||||
public void testReturningTypeVariable2() throws Throwable { doTest(); }
|
||||
public void testReturningTypeVariable3() throws Throwable { doTest(); }
|
||||
public void testImportInGenericType() throws Throwable { doTest(); }
|
||||
public void testImportInGenericType() throws Throwable {
|
||||
configure()
|
||||
myFixture.complete(CompletionType.BASIC, 2)
|
||||
checkResult();
|
||||
}
|
||||
|
||||
public void testCaseTailType() throws Throwable { doTest(); }
|
||||
|
||||
@@ -866,7 +870,7 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testClassNameInIfBeforeIdentifier() throws Throwable {
|
||||
myFixture.addClass("package foo; public class ABCDEFFFFF {}")
|
||||
myFixture.addClass("public class ABCDEFFFFF {}")
|
||||
doTest('\n')
|
||||
}
|
||||
|
||||
@@ -929,13 +933,19 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testClassNameInsideIdentifierInIf() throws Throwable {
|
||||
doTest '\n'
|
||||
configure()
|
||||
myFixture.complete(CompletionType.BASIC, 2)
|
||||
type '\n'
|
||||
checkResult()
|
||||
}
|
||||
|
||||
public void testImportStringValue() throws Throwable {
|
||||
myFixture.addClass("package foo; public class StringValue {}")
|
||||
myFixture.addClass("package java.lang; class StringValue {}")
|
||||
doTest ' '
|
||||
configure()
|
||||
myFixture.complete(CompletionType.BASIC, 2)
|
||||
type ' '
|
||||
checkResult()
|
||||
}
|
||||
|
||||
public void testPrimitiveArrayWithRBrace() throws Throwable { doTest '[' }
|
||||
@@ -978,8 +988,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testStaticInnerExtendingOuter() throws Exception { doTest() }
|
||||
|
||||
public void testSaxParserCommonPrefix() throws Exception {
|
||||
myFixture.addClass("package foo.bar; public class SAXParser {}")
|
||||
myFixture.addClass("package foo.bar.goo; public class SAXParseException {}")
|
||||
myFixture.addClass("public class SAXParser {}")
|
||||
myFixture.addClass("public class SAXParseException {}")
|
||||
doTest()
|
||||
}
|
||||
|
||||
|
||||
@@ -140,5 +140,5 @@ dir.diff.default.trg.folder=
|
||||
show.live.templates.in.completion=false
|
||||
documentation.component.editor.font=false
|
||||
ide.mac.useNativeClipboard=true
|
||||
show.all.classes.on.first.completion=true
|
||||
show.all.classes.on.first.completion=false
|
||||
ide.enable.toolwindow.stack=false
|
||||
|
||||
+3
-3
@@ -98,7 +98,7 @@ public class GroovyClassNameCompletionTest extends LightCodeInsightFixtureTestCa
|
||||
public void testDelegateBasicToClassName() throws Exception{
|
||||
addClassToProject("a", "FooBarGooDoo");
|
||||
myFixture.configureByText("a.groovy", "FBGD<caret>a")
|
||||
myFixture.completeBasic()
|
||||
myFixture.complete(CompletionType.BASIC, 2)
|
||||
myFixture.type '.'.charAt(0)
|
||||
myFixture.checkResult "a.FooBarGooDoo.<caret>a"
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class GroovyClassNameCompletionTest extends LightCodeInsightFixtureTestCa
|
||||
public void testDelegateBasicToClassNameAutoinsert() throws Exception{
|
||||
addClassToProject("a", "FooBarGooDoo");
|
||||
myFixture.configureByText("a.groovy", "FBGD<caret>")
|
||||
myFixture.completeBasic()
|
||||
myFixture.complete(CompletionType.BASIC, 2)
|
||||
myFixture.checkResult "a.FooBarGooDoo<caret>"
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ abcMethod()<caret>"""
|
||||
public void testNewClassName() {
|
||||
addClassToProject("foo", "Fxoo")
|
||||
myFixture.configureByText("a.groovy", "new Fxo<caret>\n")
|
||||
myFixture.completeBasic()
|
||||
myFixture.complete(CompletionType.BASIC, 2)
|
||||
myFixture.checkResult """import foo.Fxoo
|
||||
|
||||
new Fxoo()<caret>\n"""
|
||||
|
||||
Reference in New Issue
Block a user