void (@NotNull VirtualFile file, @Nullable FileType cachedFileType, @NotNull Runnable runnable) { FileType fileType = null; if (!file.isDirectory()) { fileType = cachedFileType != null ? cachedFileType : file.getFileType(); } Pair<VirtualFile, FileType> old = FILE_TYPE_FIXED_TEMPORARILY.get(); FILE_TYPE_FIXED_TEMPORARILY.set(new Pair<>(file, fileType)); if (toLog()) { log("F: freezeFileTypeTemporarilyIn(" + file.getName() + ") to " + fileType +" in "+Thread.currentThread()); } try { runnable.run(); } finally { if (old == null) { FILE_TYPE_FIXED_TEMPORARILY.remove(); } else { FILE_TYPE_FIXED_TEMPORARILY.set(old); } if (toLog()) { log("F: unfreezeFileType(" + file.getName() + ") in "+Thread.currentThread()); } } }