ensure Value parameter of an index has proper equals and hashcode

This commit is contained in:
Maxim.Mossienko
2016-04-06 17:59:58 +02:00
parent d62b650231
commit a4392c9fc9
3 changed files with 44 additions and 2 deletions
@@ -75,4 +75,24 @@ public class PsiJavaFileStubImpl extends PsiFileStubImpl<PsiJavaFile> implements
public String toString() {
return "PsiJavaFileStub [" + myPackageName + "]";
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PsiJavaFileStubImpl stub = (PsiJavaFileStubImpl)o;
if (myCompiled != stub.myCompiled) return false;
if (myPackageName != null ? !myPackageName.equals(stub.myPackageName) : stub.myPackageName != null) return false;
return true;
}
@Override
public int hashCode() {
int result = myPackageName != null ? myPackageName.hashCode() : 0;
result = 31 * result + (myCompiled ? 1 : 0);
return result;
}
}
@@ -105,7 +105,7 @@ public class GroovyTraitFieldsFileIndex
@Override
public int getVersion() {
return 3;
return 4;
}
private static Collection<TraitFieldDescriptor> index(FileContent inputData) {
@@ -212,5 +212,27 @@ public class GroovyTraitFieldsFileIndex
this.typeString = typeString;
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TraitFieldDescriptor that = (TraitFieldDescriptor)o;
if (flags != that.flags) return false;
if (!typeString.equals(that.typeString)) return false;
if (!name.equals(that.name)) return false;
return true;
}
@Override
public int hashCode() {
int result = (int)flags;
result = 31 * result + typeString.hashCode();
result = 31 * result + name.hashCode();
return result;
}
}
}
@@ -76,7 +76,7 @@ public class GroovyTraitMethodsFileIndex extends SingleEntryFileBasedIndexExtens
@Override
public int getVersion() {
return ClassFileStubBuilder.STUB_VERSION;
return ClassFileStubBuilder.STUB_VERSION + 1;
}
@NotNull