private static @NotNull Transferable getSelectionAction(@NotNull Editor editor, @NotNull Project project, @NotNull PsiFile file,
                                                          @NotNull CopyPasteOptions options) {
    SelectionModel selectionModel = editor.getSelectionModel();
    final int[] startOffsets = selectionModel.getBlockSelectionStarts();
    final int[] endOffsets = selectionModel.getBlockSelectionEnds();

    final List<TextBlockTransferableData> transferableDataList = new ArrayList<>();

    DumbService.getInstance(project).withAlternativeResolveEnabled(() -> {
      for (CopyPastePostProcessor<? extends TextBlockTransferableData> processor : CopyPastePostProcessor.EP_NAME.getExtensionList()) {
        try {
          transferableDataList.addAll(processor.collectTransferableData(file, editor, startOffsets, endOffsets));
        }
        catch (ProcessCanceledException ex) {
          throw ex;
        }
        catch (IndexNotReadyException e) {
          LOG.debug(e);
        }
        catch (Throwable e) {
          LOG.error(e);
        }
      }
    });

    String text = editor.getCaretModel().supportsMultipleCarets()
                  ? EditorCopyPasteHelperImpl.getSelectedTextForClipboard(editor, options, transferableDataList)
                  : selectionModel.getSelectedText();
    String rawText = TextBlockTransferable.convertLineSeparators(text, "\n", transferableDataList);
    String escapedText = null;
    for (CopyPastePreProcessor processor : CopyPastePreProcessor.EP_NAME.getExtensionList()) {
      try {
        escapedText = processor.preprocessOnCopy(file, startOffsets, endOffsets, rawText);
      }
      catch (ProcessCanceledException ex) {
        throw ex;
      }
      catch (Throwable e) {
        LOG.error(e);
      }
      if (escapedText != null) {
        break;
      }
    }
    return new TextBlockTransferable(escapedText != null ? escapedText : rawText,
                                     transferableDataList,
                                     escapedText != null ? new RawText(rawText) : null);
  }
private static @NotNull Transferable getSelectionAction(@NotNull Editor editor, @NotNull Project project, @NotNull PsiFile file,
                                                          @NotNull CopyPasteOptions options)