Skip to content

Commit

Permalink
Consider navigable element in equality - seems to fix psi outdated (#860
Browse files Browse the repository at this point in the history
)

* Consider navigation element in PSI equality checks

This seems to solve issues related to psi becoming outdated.
Extension of comment by ajchun:
mplushnikov/lombok-intellij-plugin#840 (comment)

Covers issues: #821, #827, #829, #840, #842, #844, #846, #850, #853, #854, #855, #857

* Remove debug logging related to equality of PsiElements

GitOrigin-RevId: e9ad9801b15dc91b872b14add012a9261033fbc7
  • Loading branch information
GingerGeek authored and intellij-monorepo-bot committed Aug 13, 2020
1 parent 22f98fc commit cd39da2
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 1 deletion.
Expand Up @@ -187,6 +187,10 @@ public boolean equals(Object o) {

LombokLightClassBuilder that = (LombokLightClassBuilder) o;

if(getNavigationElement() != this && !getNavigationElement().equals(that.getNavigationElement())) {
return false;
}

return myQualifiedName.equals(that.myQualifiedName);
}

Expand Down
Expand Up @@ -138,6 +138,10 @@ public boolean isEquivalentTo(PsiElement another) {
(null != containingClass && containingClass.isEquivalentTo(anotherContainingClass));
}

if(getNavigationElement() != this && !getNavigationElement().equals(anotherLightField.getNavigationElement())) {
stillEquivalent = false;
}

return stillEquivalent;
} else {
return super.isEquivalentTo(another);
Expand Down
Expand Up @@ -5,6 +5,8 @@
import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.light.LightIdentifier;

import java.util.Objects;

/**
* Date: 12.10.13 Time: 23:27
*/
Expand Down Expand Up @@ -47,7 +49,11 @@ public boolean equals(Object o) {

LombokLightIdentifier that = (LombokLightIdentifier) o;

return !(myText != null ? !myText.equals(that.myText) : that.myText != null);
if(getNavigationElement() != this && !getNavigationElement().equals(that.getNavigationElement())) {
return false;
}

return Objects.equals(myText, that.myText);

}

Expand Down
Expand Up @@ -287,6 +287,11 @@ public boolean equals(Object o) {
if (!getParameterList().equals(that.getParameterList())) {
return false;
}

if(getNavigationElement() != this && !getNavigationElement().equals(that.getNavigationElement())) {
return false;
}

return Objects.equals(myReturnTypeAsText, that.myReturnTypeAsText);
}

Expand Down
Expand Up @@ -115,6 +115,10 @@ public boolean equals(Object o) {

LombokLightModifierList that = (LombokLightModifierList) o;

if (getNavigationElement() != this && !getNavigationElement().equals(that.getNavigationElement())) {
return false;
}

return myAnnotations.equals(that.myAnnotations);
}

Expand Down
Expand Up @@ -77,6 +77,10 @@ public boolean equals(Object o) {
return false;
}

if(getNavigationElement() != this && !getNavigationElement().equals(that.getNavigationElement())) {
return false;
}

return thisType.getCanonicalText().equals(thatType.getCanonicalText());
}

Expand Down
Expand Up @@ -7,6 +7,7 @@
import java.util.Arrays;

public class LombokLightParameterListBuilder extends LightParameterListBuilder {

public LombokLightParameterListBuilder(PsiManager manager, Language language) {
super(manager, language);
}
Expand All @@ -26,6 +27,10 @@ public boolean equals(Object o) {
return false;
}

if(getNavigationElement() != this && !getNavigationElement().equals(that.getNavigationElement())) {
return false;
}

return Arrays.equals(getParameters(), that.getParameters());
}

Expand Down

0 comments on commit cd39da2

Please sign in to comment.