private static boolean shouldKeepTrailingSpacesOnEmptyLines(@NotNull Project project, @NotNull Document document) {
    PsiFile file;
    try (AccessToken ignore = SlowOperations.knownIssue("IDEA-341942, IDEA-307607, EA-765259")) {
      file = PsiDocumentManager.getInstance(project).getCachedPsiFile(document);
    }
    if (file != null) {
      CommonCodeStyleSettings settings = CodeStyle.getLanguageSettings(file);
      CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions();
      return indentOptions != null && indentOptions.KEEP_INDENTS_ON_EMPTY_LINES;
    }
    return false;
  }
private static boolean shouldKeepTrailingSpacesOnEmptyLines(@NotNull Project project, @NotNull Document document)