private static void iterateOverCarets(@NotNull final Project project,
                                 @NotNull final Editor hostEditor,
                                 @NotNull final MultiCaretCodeInsightActionHandler handler) {
    PsiFile hostFile = PsiDocumentManager.getInstance(project).getPsiFile(hostEditor.getDocument());

    hostEditor.getCaretModel().runForEachCaret(caret -> {
      Editor editor = hostEditor;
      if (hostFile != null) {
        Caret injectedCaret = InjectedLanguageUtil.getCaretForInjectedLanguageNoCommit(caret, hostFile);
        if (injectedCaret != null) {
          caret = injectedCaret;
          editor = caret.getEditor();
        }
      }
      final PsiFile file = PsiUtilBase.getPsiFileInEditor(caret, project);
      if (file != null) {
        handler.invoke(project, editor, caret, file);
      }
    });
  }
private static void iterateOverCarets(@NotNull final Project project,
                                 @NotNull final Editor hostEditor,
                                 @NotNull final MultiCaretCodeInsightActionHandler handler)