boolean (@NotNull VirtualFile file, @NotNull FileType requestedFileType) { FileType temporarilyFixedFileType = getTemporarilyFixedFileType(file); if (temporarilyFixedFileType != null) return temporarilyFixedFileType.equals(requestedFileType); FileType overriddenFileType = FileTypeOverrider.EP_NAME.computeSafeIfAny(overrider -> overrider.getOverriddenFileType(file)); if (overriddenFileType != null) { return overriddenFileType.equals(requestedFileType); } if (file instanceof VirtualFileWithAssignedFileType) { FileType fileType = ((VirtualFileWithAssignedFileType)file).getAssignedFileType(); if (fileType != null) { return fileType.equals(requestedFileType); } } if (requestedFileType instanceof FileTypeIdentifiableByVirtualFile && ((FileTypeIdentifiableByVirtualFile)requestedFileType).isMyFileType(file)) { return true; } // otherwise, we can skip all the mySpecialFileTypes because it's certain this file type is not one of them FileType fileType = getFileTypeByFileName(file.getNameSequence()); if (fileType == UnknownFileType.INSTANCE) { fileType = null; } if (fileType == null && file instanceof FakeVirtualFile && ScratchUtil.isScratch(file.getParent())) { return PlainTextFileType.INSTANCE.equals(requestedFileType); } if (fileType == null || fileType == DetectedByContentFileType.INSTANCE) { FileType detected = myDetectionService.getOrDetectFromContent(file, null, fileType); if (detected == UnknownFileType.INSTANCE && fileType == DetectedByContentFileType.INSTANCE) { return DetectedByContentFileType.INSTANCE.equals(requestedFileType); } return requestedFileType.equals(detected); } return requestedFileType.equals(ObjectUtils.notNull(fileType, UnknownFileType.INSTANCE)); }