private static @Nullable Editor getEditorFromContext(@NotNull DataContext dataContext, boolean allowSpeedSearch) {
    // try to get host editor in case of injections during action update in EDT
    boolean isEDT = EDT.isCurrentThreadEdt();
    Editor editor = isEDT && !SlowOperations.isInSection(SlowOperations.ACTION_PERFORM) ?
                    CommonDataKeys.HOST_EDITOR.getData(dataContext) : null;
    if (editor == null) {
      editor = CommonDataKeys.EDITOR.getData(dataContext);
    }
    if (editor != null) return editor;
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    Object data = PlatformCoreDataKeys.CONTEXT_COMPONENT.getData(dataContext);
    if (data instanceof EditorComponentImpl) {
      // can happen if editor is already disposed, or if it's in renderer mode
      return null;
    }
    if (data instanceof JTextComponent) {
      return new TextComponentEditorImpl(project, (JTextComponent)data);
    }
    if (allowSpeedSearch) {
      Object component = PlatformDataKeys.SPEED_SEARCH_COMPONENT.getData(dataContext);
      if (component instanceof JTextField) {
        return new TextComponentEditorImpl(project, (JTextField)component);
      }
    }
    return null;
  }
private static @Nullable Editor getEditorFromContext(@NotNull DataContext dataContext, boolean allowSpeedSearch)