mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-155716 Statically imported method should be higher in the completion list
This commit is contained in:
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.ProximityLocation;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.NullableFunction;
|
||||
@@ -58,9 +59,11 @@ public class ExplicitlyImportedWeigher extends ProximityWeigher {
|
||||
if (importList == null) return Collections.emptyList();
|
||||
|
||||
List<String> importedNames = ContainerUtil.newArrayList();
|
||||
for (final PsiImportStatement importStatement : importList.getImportStatements()) {
|
||||
ContainerUtil.addIfNotNull(importedNames, importStatement.getQualifiedName());
|
||||
for (PsiImportStatementBase statement : importList.getAllImportStatements()) {
|
||||
PsiJavaCodeReferenceElement reference = statement.getImportReference();
|
||||
ContainerUtil.addIfNotNull(importedNames, reference == null ? null : reference.getQualifiedName());
|
||||
}
|
||||
|
||||
return importedNames;
|
||||
}
|
||||
});
|
||||
@@ -126,6 +129,11 @@ public class ExplicitlyImportedWeigher extends ProximityWeigher {
|
||||
|
||||
}
|
||||
if (element instanceof PsiMember) {
|
||||
String qname = PsiUtil.getMemberQualifiedName((PsiMember)element);
|
||||
if (qname != null && PLACE_IMPORTED_NAMES.getValue(location).contains(qname)) {
|
||||
return 400;
|
||||
}
|
||||
|
||||
final PsiPackage placePackage = PLACE_PACKAGE.getValue(location);
|
||||
if (placePackage != null) {
|
||||
Module elementModule = ModuleUtilCore.findModuleForPsiElement(element);
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import static ContainerUtil.newHashSet;
|
||||
|
||||
public class TestClass {
|
||||
public static void main(String[] args) {
|
||||
newHashSet();
|
||||
newHashSet<caret>
|
||||
}
|
||||
}
|
||||
+15
@@ -758,4 +758,19 @@ interface TxANotAnno {}
|
||||
checkPreferredItems 0, 'false', 'factory'
|
||||
}
|
||||
|
||||
public void testPreferExplicitlyImportedStaticMembers() {
|
||||
myFixture.addClass("""
|
||||
class ContainerUtilRt {
|
||||
static void newHashSet();
|
||||
static void newHashSet2();
|
||||
}
|
||||
class ContainerUtil extends ContainerUtilRt {
|
||||
static void newHashSet();
|
||||
static void newHashSet3();
|
||||
}
|
||||
""")
|
||||
checkPreferredItems 0, 'newHashSet', 'newHashSet', 'newHashSet3', 'newHashSet2'
|
||||
assert (myFixture.lookupElements[0].psiElement as PsiMethod).containingClass.name == 'ContainerUtil'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user