[groovy] tweak isEquivalentTo() in accessors and light variables

This commit is contained in:
Daniil Ovchinnikov
2016-10-31 18:31:30 +03:00
parent 1389731a1c
commit cc1ff82436
2 changed files with 13 additions and 2 deletions
@@ -33,6 +33,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAc
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import org.jetbrains.plugins.groovy.lang.psi.util.GrTraitUtil;
import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils.GET_PREFIX;
/**
* @author ven
*/
@@ -127,8 +129,14 @@ public class GrAccessorMethodImpl extends LightMethodBuilder implements GrAccess
if (another == this) return true;
if (!(another instanceof GrAccessorMethod)) return false;
if (!((GrAccessorMethod)another).getName().equals(getName())) return false;
return getManager().areElementsEquivalent(myProperty, ((GrAccessorMethod)another).getProperty());
GrAccessorMethod anotherAccessor = (GrAccessorMethod)another;
if (isSetter()) {
if (!anotherAccessor.isSetter()) return false;
}
else {
if (!getName().startsWith(GET_PREFIX) == anotherAccessor.getName().startsWith(GET_PREFIX)) return false;
}
return getManager().areElementsEquivalent(myProperty, anotherAccessor.getProperty());
}
@NotNull
@@ -111,6 +111,9 @@ public class GrLightVariable extends GrImplicitVariableImpl implements Navigatab
@Override
public boolean isEquivalentTo(PsiElement another) {
if (another instanceof GrLightVariable) {
return myDeclarations.equals(((GrLightVariable)another).getDeclarations());
}
return myDeclarations.contains(another) || super.isEquivalentTo(another);
}