mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
prefer inner classes from the same file
This commit is contained in:
@@ -27,17 +27,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class StaticMembersWeigher extends CompletionWeigher {
|
||||
public Comparable weigh(@NotNull LookupElement element, @NotNull CompletionLocation loc) {
|
||||
if (loc == null) {
|
||||
return null;
|
||||
}
|
||||
if (loc.getCompletionType() != CompletionType.BASIC) return 0;
|
||||
|
||||
final PsiElement position = loc.getCompletionParameters().getPosition();
|
||||
|
||||
// cheap weigher applicability goes first
|
||||
final Object o = element.getObject();
|
||||
if (!(o instanceof PsiMember)) return 0;
|
||||
|
||||
|
||||
final PsiElement position = loc.getCompletionParameters().getPosition();
|
||||
if (PsiTreeUtil.getParentOfType(position, PsiDocComment.class) != null) return 0;
|
||||
if (position.getParent() instanceof PsiReferenceExpression) {
|
||||
final PsiReferenceExpression refExpr = (PsiReferenceExpression)position.getParent();
|
||||
@@ -55,8 +51,9 @@ public class StaticMembersWeigher extends CompletionWeigher {
|
||||
if (o instanceof PsiField) return 4;
|
||||
}
|
||||
|
||||
if (o instanceof PsiClass && ((PsiClass) o).getContainingClass() != null) {
|
||||
return 3;
|
||||
if (o instanceof PsiClass) {
|
||||
if (((PsiClass) o).getContainingClass() != null) return 3;
|
||||
return 2;
|
||||
}
|
||||
|
||||
//instance method or field
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
final Yy<caret>
|
||||
|
||||
private static class YyyXxx {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class YyyZzz {}
|
||||
@@ -112,6 +112,10 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
checkPreferredItems(0, "Xxy", "Xxx", "XxxEx", "XxxImpl");
|
||||
}
|
||||
|
||||
public void testPreferOwnInnerClasses() throws Throwable {
|
||||
checkPreferredItems(0, "YyyXxx", "YyyZzz");
|
||||
}
|
||||
|
||||
public void testDontDispreferImplsAfterNew() throws Throwable {
|
||||
VfsUtil.saveText(getSourceRoot().createChildDirectory(this, "foo").createChildData(this, "Xxx.java"), "package foo; public interface Xxx {}");
|
||||
checkPreferredItems(0, "Xxx", "XxxImpl");
|
||||
|
||||
Reference in New Issue
Block a user