completion-robust LightFieldBuilder.isEquivalentTo (https://devnet.jetbrains.com...
authorpeter <peter@jetbrains.com>
Fri, 20 Feb 2015 16:20:59 +0000 (17:20 +0100)
committerpeter <peter@jetbrains.com>
Fri, 20 Feb 2015 16:41:45 +0000 (17:41 +0100)
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;
   }
+
+  @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);
+  }
 }