private boolean isFileTypeOk(@NotNull VirtualFile file) {
    if (file.isDirectory()) {
      PatchApplier.showError(myProject, VcsBundle.message("patch.apply.file.type.directory.error", file.getPresentableName()));
      return false;
    }
    FileType fileType = file.getFileType();
    if (fileType == FileTypes.UNKNOWN) {
      if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
        ApplicationManager.getApplication().runWriteAction(
          () -> FileTypeManagerEx.getInstanceEx().associate(FileTypes.PLAIN_TEXT, new ExactFileNameMatcher(file.getName()))
        );
        return true;
      }
      else {
        fileType = FileTypeChooser.associateFileType(file.getName());
        if (fileType == null) {
          PatchApplier
            .showError(myProject, VcsBundle.message("patch.apply.file.type.undefined.error", file.getPresentableName()));
          return false;
        }
      }
    }
    if (fileType.isBinary()) {
      PatchApplier.showError(myProject, VcsBundle.message("patch.apply.file.type.binary.error", file.getPresentableName()));
      return false;
    }
    return true;
  }
private boolean isFileTypeOk(@NotNull VirtualFile file)