public static void selectSearchResultsInEditor(@NotNull Editor editor,
                                                 @NotNull Iterator<? extends FindResult> resultIterator,
                                                 int caretShiftFromSelectionStart) {
    ArrayList<CaretState> caretStates = new ArrayList<>();
    while (resultIterator.hasNext()) {
      FindResult findResult = resultIterator.next();
      int caretOffset = getCaretPosition(findResult, caretShiftFromSelectionStart);
      int selectionStartOffset = findResult.getStartOffset();
      int selectionEndOffset = findResult.getEndOffset();
      EditorActionUtil.makePositionVisible(editor, caretOffset);
      EditorActionUtil.makePositionVisible(editor, selectionStartOffset);
      EditorActionUtil.makePositionVisible(editor, selectionEndOffset);
      caretStates.add(new CaretState(editor.offsetToLogicalPosition(caretOffset),
                                     editor.offsetToLogicalPosition(selectionStartOffset),
                                     editor.offsetToLogicalPosition(selectionEndOffset)));
    }
    if (caretStates.size() > editor.getCaretModel().getMaxCaretCount()) {
      EditorUtil.notifyMaxCarets(editor);
    }
    else if (!caretStates.isEmpty()){
      editor.getCaretModel().setCaretsAndSelections(caretStates);
    }
  }
public static void selectSearchResultsInEditor(@NotNull Editor editor,
                                                 @NotNull Iterator<? extends FindResult> resultIterator,
                                                 int caretShiftFromSelectionStart)