@ApiStatus.Internal
  public void clearLineModificationFlags(@NotNull Document document) {
    if (document instanceof DocumentWindow) {
      document = ((DocumentWindow)document).getDelegate();
    }
    if (!(document instanceof DocumentImpl)) {
      return;
    }

    TrailingSpacesOptions options = getOptions(document);
    if (options == null) return;

    List<Editor> activeEditors = getActiveEditors(document);
    List<Caret> carets = new ArrayList<>();
    if (options.isChangedLinesOnly() && options.isStripTrailingSpaces()) {
      for (Editor activeEditor : activeEditors) {
        // when virtual space enabled, we can strip whitespace anywhere
        if (!activeEditor.getSettings().isVirtualSpace()) {
          carets.addAll(activeEditor.getCaretModel().getAllCarets());
        }
      }
    }

    int[] caretLines;
    if (!carets.isEmpty()) {
      caretLines = new int[carets.size()];
      for (int i = 0; i < carets.size(); i++) {
        Caret caret = carets.get(i);
        caretLines[i] = caret.getLogicalPosition().line;
      }
    }
    else {
      caretLines = ArrayUtilRt.EMPTY_INT_ARRAY;
    }
    ((DocumentImpl)document).clearLineModificationFlagsExcept(caretLines);
  }
@ApiStatus.Internal
  public void clearLineModificationFlags(@NotNull Document document)