diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index 83fa8dc423bf..5998c7e432a8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -206,7 +206,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent VirtualFile file = event instanceof VFileCreateEvent ? /* avoid expensive find child here */ null : event.getFile(); VirtualFile filtered = file != null && wasAutoDetectedBefore(file) && isDetectable(file) ? file : null; if (toLog()) { - log("F: handled " + event + "; filtered file: " + filtered + "(file: "+file+"; wasAutoDetectedBefore(file): "+(file == null ? null : wasAutoDetectedBefore(file))+"; isDetectable(file): "+(file == null ? null : isDetectable(file))+"; file.getLength(): "+(file == null ? null : file.getLength())+"; file.isValid(): "+(file == null ? null : file.isValid())+"; file.is(VFileProperty.SPECIAL): "+(file == null ? null : file.is(VFileProperty.SPECIAL))+"; packedFlags.get(id): "+(!(file instanceof VirtualFileWithId) ? null : packedFlags.get(((VirtualFileWithId)file).getId()))+"; file.getFileSystem():"+(file == null ? null : file.getFileSystem())+")"); + log("F: handled " + event + "; filtered file: " + filtered + " (file: "+file+"; wasAutoDetectedBefore(file): "+(file == null ? null : wasAutoDetectedBefore(file))+"; isDetectable(file): "+(file == null ? null : isDetectable(file))+"; file.getLength(): "+(file == null ? null : file.getLength())+"; file.isValid(): "+(file == null ? null : file.isValid())+"; file.is(VFileProperty.SPECIAL): "+(file == null ? null : file.is(VFileProperty.SPECIAL))+"; packedFlags.get(id): "+(!(file instanceof VirtualFileWithId) ? null : packedFlags.get(((VirtualFileWithId)file).getId()))+"; file.getFileSystem():"+(file == null ? null : file.getFileSystem())+")"); } return filtered; } @@ -349,7 +349,11 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent int id = file instanceof VirtualFileWithId ? ((VirtualFileWithId)file).getId() : -1; FileType before = getAutoDetectedType(file, id); - packedFlags.set(id, ATTRIBUTES_WERE_LOADED_MASK); + int flags = ATTRIBUTES_WERE_LOADED_MASK; + packedFlags.set(id, flags); + if (toLog()) { + log("F: reDetect("+file.getName()+") prepare to redetect. flags: "+flags); + } file.putUserData(DETECTED_FROM_CONTENT_FILE_TYPE_KEY, null); FileType after = getFileTypeByFile(file); // may be back to standard file type @@ -481,13 +485,16 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent if (autoDetectWasRun) { FileType type = getAutoDetectedType(file, id); if (toLog()) { - log("F: autodetected getFileType("+file.getName()+") = "+type.getName()); + log("F: autodetected getFileType("+file.getName()+") = "+type.getName()+"; packedFlags.get(id):"+flags); } return type; } if ((flags & ATTRIBUTES_WERE_LOADED_MASK) == 0) { flags = readFlagsFromCache(file); packedFlags.set(id, flags); + if (toLog()) { + log("F: readFlagsFromCache("+file.getName()+") = "+flags); + } } boolean wasDetectedAsText = BitUtil.isSet(flags, AUTO_DETECTED_AS_TEXT_MASK); boolean wasDetectedAsBinary = BitUtil.isSet(flags, AUTO_DETECTED_AS_BINARY_MASK); @@ -553,6 +560,9 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent autoDetectedAttribute = autoDetectedAttribute.newVersion(count); PropertiesComponent.getInstance().setValue("fileTypeChangedCounter", Integer.toString(count)); packedFlags.clear(); + if (toLog()) { + log("F: clearCaches"); + } } @NotNull @@ -583,6 +593,9 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent flags = BitUtil.set(flags, AUTO_DETECTED_AS_TEXT_MASK, wasAutodetectedAsText); flags = BitUtil.set(flags, AUTO_DETECTED_AS_BINARY_MASK, wasAutodetectedAsBinary); packedFlags.set(id, flags); + if (toLog()) { + log("F: cacheAutoDetectedFileType("+file.getName()+") = "+flags); + } if (wasAutodetectedAsText || wasAutodetectedAsBinary) { file.putUserData(DETECTED_FROM_CONTENT_FILE_TYPE_KEY, null);