mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't suggest two same-named fields from super classes when one overrides the other
This commit is contained in:
+11
-27
@@ -16,7 +16,7 @@
|
||||
package com.intellij.codeInsight.completion.scope;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -26,16 +26,12 @@ import com.intellij.psi.util.PsiUtilCore;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class CompletionElement{
|
||||
private final PsiType myQualifier;
|
||||
private final PsiClass myQualifierClass;
|
||||
private final Object myElement;
|
||||
private final PsiSubstitutor mySubstitutor;
|
||||
|
||||
public CompletionElement(PsiType qualifier, Object element, PsiSubstitutor substitutor, final PsiClass qualifierClass){
|
||||
public CompletionElement(Object element, PsiSubstitutor substitutor) {
|
||||
myElement = element;
|
||||
myQualifier = qualifier;
|
||||
mySubstitutor = substitutor;
|
||||
myQualifierClass = qualifierClass;
|
||||
}
|
||||
|
||||
public PsiSubstitutor getSubstitutor(){
|
||||
@@ -46,34 +42,22 @@ public class CompletionElement{
|
||||
return myElement;
|
||||
}
|
||||
|
||||
public Object getUniqueId(){
|
||||
final String name;
|
||||
@Nullable
|
||||
Object getUniqueId(){
|
||||
if(myElement instanceof PsiClass){
|
||||
name = ((PsiClass)myElement).getQualifiedName();
|
||||
return ((PsiClass)myElement).getQualifiedName();
|
||||
}
|
||||
else if(myElement instanceof PsiPackage){
|
||||
name = ((PsiPackage)myElement).getQualifiedName();
|
||||
if(myElement instanceof PsiPackage){
|
||||
return ((PsiPackage)myElement).getQualifiedName();
|
||||
}
|
||||
else if(myElement instanceof PsiMethod){
|
||||
if(myElement instanceof PsiMethod){
|
||||
return ((PsiMethod)myElement).getSignature(mySubstitutor);
|
||||
}
|
||||
else if (myElement instanceof PsiField) {
|
||||
final PsiField field = (PsiField)myElement;
|
||||
final String s = field.getName();
|
||||
if (myQualifierClass != null || !field.hasModifierProperty(PsiModifier.STATIC)) return "#" + s;
|
||||
return field.getContainingClass().getQualifiedName() + "#" + s;
|
||||
}
|
||||
else if(myElement instanceof PsiElement){
|
||||
name = PsiUtilCore.getName((PsiElement)myElement);
|
||||
}
|
||||
else{
|
||||
name = "";
|
||||
if (myElement instanceof PsiVariable) {
|
||||
return "#" + ((PsiVariable)myElement).getName();
|
||||
}
|
||||
|
||||
return name;
|
||||
return null;
|
||||
}
|
||||
|
||||
public PsiType getQualifier(){
|
||||
return myQualifier;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -224,7 +224,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme
|
||||
}
|
||||
|
||||
if (satisfies(element, state) && isAccessible(element)) {
|
||||
CompletionElement element1 = new CompletionElement(myQualifierType, element, state.get(PsiSubstitutor.KEY), myQualifierClass);
|
||||
CompletionElement element1 = new CompletionElement((PsiNamedElement)element, state.get(PsiSubstitutor.KEY));
|
||||
if (myResultNames.add(element1.getUniqueId())) {
|
||||
myResults.add(element1);
|
||||
}
|
||||
@@ -257,7 +257,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme
|
||||
|
||||
public void setCompletionElements(@NotNull Object[] elements) {
|
||||
for (Object element: elements) {
|
||||
myResults.add(new CompletionElement(null, element, PsiSubstitutor.EMPTY, myQualifierClass));
|
||||
myResults.add(new CompletionElement(element, PsiSubstitutor.EMPTY));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
interface Intf { Intf FOO = null; }
|
||||
interface Intf2 extends Intf { Intf2 FOO = null; }
|
||||
|
||||
public class Bar implements Intf2 {
|
||||
public static void fpp() {
|
||||
F<caret>
|
||||
}
|
||||
}
|
||||
+5
@@ -494,6 +494,11 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
assertStringItems("boolean", "byte")
|
||||
}
|
||||
|
||||
public void testDoubleConstant() throws Throwable {
|
||||
configure()
|
||||
assertStringItems("FOO", "Float")
|
||||
}
|
||||
|
||||
public void testNotOnlyKeywordsInsideSwitch() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user