mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
[java-completion] Deduplicate chained items with different class qualifier
They are basically the same Improvement for IDEA-334398 GitOrigin-RevId: 1d29fed1c229ed3d41c89902dfe578ab1610f989
This commit is contained in:
committed by
intellij-monorepo-bot
parent
679de5d46d
commit
093ca478fd
@@ -17,6 +17,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class JavaChainLookupElement extends LookupElementDecorator<LookupElement> implements TypedLookupItem {
|
||||
@@ -159,10 +160,12 @@ public class JavaChainLookupElement extends LookupElementDecorator<LookupElement
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
private LookupElement getComparableQualifier() {
|
||||
final CastingLookupElementDecorator casting = myQualifier.as(CastingLookupElementDecorator.CLASS_CONDITION_KEY);
|
||||
return casting == null ? myQualifier : casting.getDelegate();
|
||||
LookupElement qualifier = casting == null ? myQualifier : casting.getDelegate();
|
||||
if (qualifier.getObject() instanceof PsiClass) return null;
|
||||
return qualifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,13 +173,13 @@ public class JavaChainLookupElement extends LookupElementDecorator<LookupElement
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
return getComparableQualifier().equals(((JavaChainLookupElement)o).getComparableQualifier());
|
||||
if (!mySeparator.equals(((JavaChainLookupElement)o).mySeparator)) return false;
|
||||
return Objects.equals(getComparableQualifier(), ((JavaChainLookupElement)o).getComparableQualifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * super.hashCode() + getComparableQualifier().hashCode();
|
||||
return 31 * super.hashCode() + Objects.hashCode(getComparableQualifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
sealed interface AddUserError {
|
||||
|
||||
non-sealed class NameIsEmpty implements AddUserError {
|
||||
final static class T4 extends NameIsTooLong.T3 {}
|
||||
}
|
||||
|
||||
non-sealed class NameIsTooLong implements AddUserError {
|
||||
static class T extends NameIsEmpty{}
|
||||
static class T3 extends T{}
|
||||
}
|
||||
}
|
||||
class Test {
|
||||
|
||||
public static AddUserError TryAddUser() {
|
||||
return new AUE.<caret>
|
||||
}
|
||||
}
|
||||
@@ -43,4 +43,12 @@ public class NormalSealedCompletionTest extends NormalCompletionTestCase {
|
||||
myFixture.completeBasic();
|
||||
myFixture.assertPreferredCompletionItems(0, "AddUserError.NameIsEmpty", "AddUserError.NameIsTooLong");
|
||||
}
|
||||
|
||||
@NeedsIndex.Full
|
||||
public void testNestedClassCompletion2() {
|
||||
configure();
|
||||
myFixture.completeBasic();
|
||||
myFixture.assertPreferredCompletionItems(0, "AddUserError.NameIsEmpty", "AddUserError.NameIsTooLong.T",
|
||||
"AddUserError.NameIsEmpty.T4", "AddUserError.NameIsTooLong", "AddUserError.NameIsTooLong.T3");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user