mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
more on *Impl sorting in completion
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class A{
|
||||
{
|
||||
String str;
|
||||
str.toCharArray();
|
||||
str.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
class A{
|
||||
{
|
||||
final String path = BASE_PATH;
|
||||
path.toCharArray()<caret>;
|
||||
path.toString()<caret>;
|
||||
sdkfjsdkhjfh();
|
||||
}
|
||||
}
|
||||
@@ -229,4 +229,16 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
|
||||
}
|
||||
|
||||
public void testPrefixLengthDependentSorting() {
|
||||
myFixture.addClass("package foo; public class PsiJavaCodeReferenceElement {}")
|
||||
myFixture.configureByText("a.java", """
|
||||
class PsiJavaCodeReferenceElementImpl {
|
||||
{ <caret> }
|
||||
}
|
||||
""")
|
||||
type 'PJCR'
|
||||
assertOrderedEquals myFixture.lookupElementStrings, 'PsiJavaCodeReferenceElement', 'PsiJavaCodeReferenceElementImpl'
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-2
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.testFramework.fixtures.impl;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.ProjectScope;
|
||||
@@ -49,12 +51,17 @@ public class JavaCodeInsightTestFixtureImpl extends CodeInsightTestFixtureImpl i
|
||||
return psiClass;
|
||||
}
|
||||
|
||||
private PsiClass addClass(@NonNls String rootPath, @NotNull @NonNls final String classText) throws IOException {
|
||||
private PsiClass addClass(@NonNls final String rootPath, @NotNull @NonNls final String classText) throws IOException {
|
||||
final PsiClass aClass = ((PsiJavaFile)PsiFileFactory.getInstance(getProject()).createFileFromText("a.java", classText)).getClasses()[0];
|
||||
final String qName = aClass.getQualifiedName();
|
||||
assert qName != null;
|
||||
|
||||
final PsiFile psiFile = addFileToProject(rootPath, qName.replace('.', '/') + ".java", classText);
|
||||
final PsiFile psiFile = new WriteCommandAction<PsiFile>(getProject()) {
|
||||
@Override
|
||||
protected void run(Result<PsiFile> result) throws Throwable {
|
||||
result.setResult(addFileToProject(rootPath, qName.replace('.', '/') + ".java", classText));
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
return ((PsiJavaFile)psiFile).getClasses()[0];
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -35,8 +35,7 @@ public class PrefixMatchingWeigher extends CompletionWeigher {
|
||||
final String prefixHumps = StringUtil.capitalsOnly(prefix);
|
||||
final String itemHumps = StringUtil.capitalsOnly(lookupString);
|
||||
|
||||
if (itemHumps.equals(prefixHumps)) return 20;
|
||||
if (itemHumps.startsWith(prefixHumps)) return 10;
|
||||
if (itemHumps.startsWith(prefixHumps)) return 100 - itemHumps.length();
|
||||
|
||||
if (lookupString.startsWith(prefix)) return 5;
|
||||
if (StringUtil.startsWithIgnoreCase(lookupString, prefix)) return 1;
|
||||
|
||||
Reference in New Issue
Block a user