public static @Nullable FileType getFileType(@Nullable String contentType) {
    if (contentType == null) return null;

    int end = contentType.indexOf(';');
    String mimeType = end == -1 ? contentType : contentType.substring(0, end);
    if (mimeType.isEmpty()) {
      return null;
    }

    for (Language language : Language.getRegisteredLanguages()) {
      String[] types = language.getMimeTypes();
      for (String type : types) {
        if (type.equalsIgnoreCase(mimeType)) {
          FileType fileType = language.getAssociatedFileType();
          if (fileType != null) {
            return fileType;
          }
        }
      }
    }
    return null;
  }
public static @Nullable FileType getFileType(@Nullable String contentType)