public static @NotNull FileType substituteFileType(@NotNull VirtualFile file, @NotNull FileType fileType, @Nullable Project project) {
    if (project == null) {
      return fileType;
    }
    if (fileType instanceof LanguageFileType) {
      Language substLang = LanguageUtil.getLanguageForPsi(project, file, fileType);
      LanguageFileType substFileType = substLang != null && substLang != ((LanguageFileType)fileType).getLanguage() ?
                                       substLang.getAssociatedFileType() : null;
      if (substFileType != null) {
        return new SubstitutedFileType(fileType, substFileType, substLang);
      }
    }

    return fileType;
  }
public static @NotNull FileType substituteFileType(@NotNull VirtualFile file, @NotNull FileType fileType, @Nullable Project project)