@Override
  public void doRun(
      IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) {

    try {
      Object element = selection.getFirstElement();
      if (element instanceof DartFunction) {
        DartFunction function = (DartFunction) element;
        instrumentation.data("function", function.getSource());

        if (!RefactoringAvailabilityTester.isConvertGetterToMethodAvailable(function)) {
          instrumentation.metric("Problem", "RefactoringAvailabilityTester Returned false");
        }

        boolean success =
            RefactoringExecutionStarter_OLD.startConvertGetterToMethodRefactoring(
                function, getShell());
        if (success) {
          return;
        }

        instrumentation.metric(
            "Problem",
            "RefactoringExecutionStarter.startConvertGetterToMethodRefactoring returned False");
      }
    } catch (DartModelException e) {
      ExceptionHandler.handle(
          e,
          getShell(),
          RefactoringMessages.ConvertGetterToMethodAction_dialog_title,
          RefactoringMessages.InlineMethodAction_unexpected_exception);
    }
  }
  @Override
  protected void doRun(
      ITextSelection selection, Event event, UIInstrumentationBuilder instrumentation) {
    CompilationUnit input = SelectionConverter.getInputAsCompilationUnit(editor);
    instrumentation.record(input);

    if (!ActionUtil.isProcessable(getShell(), input)) {
      instrumentation.metric("Problem", "input cu is not processable");
      return;
    }

    try {
      DartElement[] elements = SelectionConverter.codeResolveOrInputForked(editor);
      if (elements == null) {
        instrumentation.metric("Problem", "elements was null");
        return;
      }
      ActionInstrumentationUtilities.record(elements, "Selections", instrumentation);

      List<DartElement> candidates = new ArrayList<DartElement>(elements.length);
      for (int i = 0; i < elements.length; i++) {
        DartElement element = elements[i];
        if (CallHierarchy.isPossibleInputElement(element)) {
          candidates.add(element);
        }
      }

      if (candidates.isEmpty()) {
        DartElement enclosingMethod = getEnclosingMethod(input, selection);
        if (enclosingMethod != null) {
          candidates.add(enclosingMethod);
        }
      }
      ActionInstrumentationUtilities.record(candidates, "Candidates", instrumentation);

      CallHierarchyUI.openSelectionDialog(
          candidates.toArray(new DartElement[candidates.size()]), getSite().getWorkbenchWindow());

    } catch (InvocationTargetException e) {
      ExceptionHandler.handle(
          e,
          getShell(),
          CallHierarchyMessages.OpenCallHierarchyAction_dialog_title,
          ActionMessages.SelectionConverter_codeResolve_failed);
    } catch (InterruptedException e) {
      // cancelled
      instrumentation.metric("Problem", "User cancelled");
    }
  }
  @Override
  public void run(ITextSelection selection) {
    CompilationUnit input = SelectionConverter.getInputAsCompilationUnit(editor);
    if (!ActionUtil.isProcessable(getShell(), input)) {
      return;
    }

    try {
      DartElement[] elements = SelectionConverter.codeResolveOrInputForked(editor);
      if (elements == null) {
        return;
      }
      List<DartElement> candidates = new ArrayList<DartElement>(elements.length);
      for (int i = 0; i < elements.length; i++) {
        DartElement element = elements[i];
        if (CallHierarchy.isPossibleInputElement(element)) {
          candidates.add(element);
        }
      }
      if (candidates.isEmpty()) {
        DartElement enclosingMethod = getEnclosingMethod(input, selection);
        if (enclosingMethod != null) {
          candidates.add(enclosingMethod);
        }
      }
      CallHierarchyUI.openSelectionDialog(
          candidates.toArray(new DartElement[candidates.size()]), getSite().getWorkbenchWindow());

    } catch (InvocationTargetException e) {
      ExceptionHandler.handle(
          e,
          getShell(),
          CallHierarchyMessages.OpenCallHierarchyAction_dialog_title,
          ActionMessages.SelectionConverter_codeResolve_failed);
    } catch (InterruptedException e) {
      // cancelled
    }
  }
  /**
   * Opens a type selection dialog. If the user selects a type (and does not cancel), an editor is
   * opened on the selected type.
   *
   * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
   */
  @Override
  public void runWithEvent(Event e) {
    Shell parent = DartToolsPlugin.getActiveWorkbenchShell();
    if (!doCreateProjectFirstOnEmptyWorkspace(parent)) {
      return;
    }

    SelectionDialog dialog =
        new OpenTypeSelectionDialog(
            parent,
            true,
            PlatformUI.getWorkbench().getProgressService(),
            null,
            SEARCH_ELEMENT_KINDS);
    dialog.setTitle(DartUIMessages.OpenTypeAction_dialogTitle);
    dialog.setMessage(DartUIMessages.OpenTypeAction_dialogMessage);

    int result = dialog.open();
    if (result != IDialogConstants.OK_ID) {
      return;
    }

    Object[] types = dialog.getResult();
    if (types == null || types.length == 0) {
      return;
    }

    if (types.length == 1) {
      try {
        DartUI.openInEditor((Element) types[0], true, true);
      } catch (CoreException x) {
        ExceptionHandler.handle(
            x,
            DartUIMessages.OpenTypeAction_errorTitle,
            DartUIMessages.OpenTypeAction_errorMessage);
      }
      return;
    }

    final IWorkbenchPage workbenchPage = DartToolsPlugin.getActivePage();
    if (workbenchPage == null) {
      IStatus status =
          new Status(
              IStatus.ERROR,
              DartToolsPlugin.getPluginId(),
              DartUIMessages.OpenTypeAction_no_active_WorkbenchPage);
      ExceptionHandler.handle(
          status,
          DartUIMessages.OpenTypeAction_errorTitle,
          DartUIMessages.OpenTypeAction_errorMessage);
      return;
    }

    MultiStatus multiStatus =
        new MultiStatus(
            DartToolsPlugin.getPluginId(),
            DartStatusConstants.INTERNAL_ERROR,
            DartUIMessages.OpenTypeAction_multiStatusMessage,
            null);

    for (int i = 0; i < types.length; i++) {
      Type type = (Type) types[i];
      try {
        DartUI.openInEditor(type, true, true);
      } catch (CoreException x) {
        multiStatus.merge(x.getStatus());
      }
    }

    if (!multiStatus.isOK()) {
      ExceptionHandler.handle(
          multiStatus,
          DartUIMessages.OpenTypeAction_errorTitle,
          DartUIMessages.OpenTypeAction_errorMessage);
    }
  }