private static boolean canBeFormatted(@NotNull PsiFile file) {
    if (!file.isValid()) return false;
    FormattingService formattingService = FormattingServiceUtil.findService(file, true, true);
    if (formattingService instanceof CoreFormattingService && LanguageFormatting.INSTANCE.forContext(file) == null) {
      return false;
    }
    VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile == null) return true;

    if (ProjectUtil.isProjectOrWorkspaceFile(virtualFile)) return false;

    return !GeneratedSourcesFilter.isGeneratedSourceByAnyFilter(virtualFile, file.getProject());
  }
private static boolean canBeFormatted(@NotNull PsiFile file)