completion-robust LightFieldBuilder.isEquivalentTo (https://devnet.jetbrains.com...
[idea/community.git] / java / java-psi-impl / src / com / intellij / psi / impl / light / LightFieldBuilder.java
index 72256079a0fd11fa722c474c57a0b43bd97dff9e..87df5dcb049d7920d2208660c8cc19b5da3172df 100644 (file)
@@ -83,4 +83,14 @@ public class LightFieldBuilder extends LightVariableBuilder<LightFieldBuilder> i
   public PsiClass getContainingClass() {
     return myContainingClass;
   }
   public PsiClass getContainingClass() {
     return myContainingClass;
   }
+
+  @Override
+  public boolean isEquivalentTo(PsiElement another) {
+    if (!(another instanceof PsiField)) return false;
+    if (!((PsiField)another).getName().equals(getName())) return false;
+    if (hasModifierProperty(PsiModifier.STATIC) != ((PsiField)another).hasModifierProperty(PsiModifier.STATIC)) return false;
+    final PsiClass containingClass = getContainingClass();
+    final PsiClass anotherClass = ((PsiField)another).getContainingClass();
+    return containingClass == null && anotherClass == null || getManager().areElementsEquivalent(containingClass, anotherClass);
+  }
 }
 }