From 9d6794d2394202c5b41747b4f82328ae4bb994a2 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 7 Mar 2019 12:40:22 +0300 Subject: [PATCH] tests: define equals & hashcode for the MockVirtualFile To be able to compare two MockVirtualFiles defined by the same path. --- .../src/com/intellij/mock/MockVirtualFile.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/platform/testFramework/src/com/intellij/mock/MockVirtualFile.java b/platform/testFramework/src/com/intellij/mock/MockVirtualFile.java index 96d37ff08796..71da2ee17a70 100644 --- a/platform/testFramework/src/com/intellij/mock/MockVirtualFile.java +++ b/platform/testFramework/src/com/intellij/mock/MockVirtualFile.java @@ -126,6 +126,20 @@ public class MockVirtualFile extends VirtualFile { return VfsUtilCore.toVirtualFileArray(myChildren); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + MockVirtualFile file = (MockVirtualFile)o; + return getPath().equals(file.getPath()); + } + + @Override + public int hashCode() { + return getPath().hashCode(); + } + @NotNull @Override public OutputStream getOutputStream(Object requestor, long newModificationStamp, long newTimeStamp) throws IOException {