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

    if (!ActionUtil.isEditable(fEditor)) {
      instrumentation.metric("Problem", "Editor not editable");
      return;
    }

    CompilationUnit cu = SelectionConverter.getInputAsCompilationUnit(fEditor);
    instrumentation.record(cu);
    try {
      DartFunction function = DartModelUtil.findFunction(cu, selection.getOffset());
      instrumentation.data("function", function.getSource());

      boolean success =
          RefactoringExecutionStarter_OLD.startConvertGetterToMethodRefactoring(
              function, getShell());

      if (success) {
        return;
      }
      instrumentation.metric(
          "Problem", "RefactoringExecutionStarter.startConvertGetterToMethodRefactoring False");

    } catch (Throwable e) {
      instrumentation.record(e);
    }

    instrumentation.metric("Problem", "No valid selection, showing dialog");
    MessageDialog.openInformation(
        getShell(),
        RefactoringMessages.ConvertGetterToMethodAction_dialog_title,
        RefactoringMessages.ConvertGetterToMethodAction_select);
  }
  @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(IAction action) {
    if (selection != null) {
      UIInstrumentationBuilder instrumentation = UIInstrumentation.builder(getClass());

      Object obj = SelectionUtil.getSingleElement(selection);

      try {
        instrumentation.record(selection);

        if (obj instanceof IVariable) {
          IVariable variable = (IVariable) obj;

          obj = variable.getValue();
        }

        if (obj instanceof DartiumDebugValue) {
          DartiumDebugValue value = (DartiumDebugValue) obj;

          IValue classValue = value.getClassValue();

          if (classValue != null) {
            ObjectInspectorView.inspect(classValue, true);
          }
        } else if (obj instanceof ServerDebugValue) {
          ServerDebugValue value = (ServerDebugValue) obj;

          IValue classValue = value.getClassValue();

          if (classValue != null) {
            ObjectInspectorView.inspect(classValue, true);
          }
        }

        instrumentation.metric("Inspect", "Completed");
      } catch (DebugException e) {
        DartDebugUIPlugin.logError(e);
      } finally {
        instrumentation.log();
      }
    }
  }
  @Override
  public boolean performOk() {
    IPreferenceStore editorPreferences = EditorsPlugin.getDefault().getPreferenceStore();

    editorPreferences.setValue(
        AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER,
        lineNumbersCheck.getSelection());

    DartFormatter.setMaxLineLengthEnabled(printMarginCheck.getSelection());
    if (printMarginCheck.getSelection()) {
      DartFormatter.setMaxLineLength(printMarginText.getText());
    }

    IPreferenceStore toolsPreferenceStore = PreferenceConstants.getPreferenceStore();

    toolsPreferenceStore.setValue(
        PreferenceConstants.CODEASSIST_AUTOACTIVATION, enableAutoCompletion.getSelection());
    if (!DartCoreDebug.ENABLE_ANALYSIS_SERVER) {
      toolsPreferenceStore.setValue(
          PreferenceConstants.EDITOR_FOLDING_ENABLED, enableFolding.getSelection());
    }
    toolsPreferenceStore.setValue(
        PreferenceConstants.EDITOR_REMOVE_TRAILING_WS,
        removeTrailingWhitespaceCheck.getSelection());

    toolsPreferenceStore.setValue(
        PreferenceConstants.EDITOR_FORMAT_ON_SAVES, formatCheck.getSelection());

    handleSave(editorPreferences);
    handleSave(toolsPreferenceStore);

    IEclipsePreferences prefs = DartCore.getPlugin().getPrefs();
    if (prefs != null) {
      prefs.putBoolean(DartCore.PUB_AUTO_RUN_PREFERENCE, runPubAutoCheck.getSelection());
      try {
        DartCore.getPlugin().savePrefs();
      } catch (CoreException e) {
        DartToolsPlugin.log(e);
      }
      //
      // If the user has changed the preference to true,
      // then run pub on all pubspecs in the workspace
      //
      if (runPubChanged) {
        UIInstrumentationBuilder instrumentation = UIInstrumentation.builder(this.getClass());
        try {
          boolean autoRunPubEnabled = runPubAutoCheck.getSelection();
          instrumentation.metric("autoRunPubEnabled", autoRunPubEnabled);
          if (autoRunPubEnabled) {
            PlatformUI.getWorkbench()
                .getDisplay()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        runPubNow();
                      }
                    });
          }
        } catch (RuntimeException e) {
          instrumentation.record(e);
          throw e;
        } finally {
          instrumentation.log();
        }
      }
    }

    boolean serverChanged =
        setPrefBool(DartCoreDebug.ENABLE_ANALYSIS_SERVER_PREF, true, enableAnalysisServerButton);

    if (serverChanged) {
      MessageDialog.openInformation(
          getShell(),
          "Restart Required",
          "These changes will only take effect once the IDE has been restarted.");
    }

    return true;
  }