diff options
Diffstat (limited to 'platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java')
-rw-r--r-- | platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java b/platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java index d20d01dc4e03..34f80dae5cc9 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java @@ -21,6 +21,7 @@ import com.intellij.openapi.vfs.newvfs.persistent.ContentHashesUtil; import com.intellij.openapi.vfs.newvfs.persistent.FlushingDaemon; import com.intellij.util.io.IOUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; @@ -63,19 +64,19 @@ class ContentHashesSupport { } static void flushContentHashes() { - if (ourHashesWithFileType.isDirty()) ourHashesWithFileType.force(); + if (ourHashesWithFileType != null && ourHashesWithFileType.isDirty()) ourHashesWithFileType.force(); } - static int calcContentHashIdWithFileType(@NotNull byte[] bytes, @NotNull FileType fileType) throws IOException { - return enumerateHash(calcContentHashWithFileType(bytes, fileType)); + static int calcContentHashIdWithFileType(@NotNull byte[] bytes, @Nullable Charset charset, @NotNull FileType fileType) throws IOException { + return enumerateHash(calcContentHashWithFileType(bytes, charset, fileType)); } static int enumerateHash(@NotNull byte[] digest) throws IOException { return ourHashesWithFileType.enumerate(digest); } - static byte[] calcContentHashWithFileType(@NotNull byte[] bytes, @NotNull FileType fileType) throws IOException { + static byte[] calcContentHashWithFileType(@NotNull byte[] bytes, @Nullable Charset charset, @NotNull FileType fileType) throws IOException { MessageDigest messageDigest = ContentHashesUtil.HASHER_CACHE.getValue(); Charset defaultCharset = Charset.defaultCharset(); @@ -83,6 +84,8 @@ class ContentHashesSupport { messageDigest.update((byte)0); messageDigest.update(String.valueOf(bytes.length).getBytes(defaultCharset)); messageDigest.update((byte)0); + messageDigest.update((charset != null ? charset.displayName():"null_charset").getBytes(defaultCharset)); + messageDigest.update((byte)0); messageDigest.update(bytes, 0, bytes.length); return messageDigest.digest(); |