/* (non-Javadoc)
   * Method declared on SelectionDispatchAction.
   */
  public void run(ITextSelection selection) {
    IModelElement input = SelectionConverter.getInput(fEditor);
    if (!ActionUtil.isProcessable(getShell(), input)) return;

    try {
      IModelElement[] elements = resolveModelElements();
      if (elements == null) return;
      List candidates = new ArrayList(elements.length);
      for (int i = 0; i < elements.length; i++) {
        IModelElement[] resolvedElements = CallHierarchyUI.getCandidates(elements[i]);
        if (resolvedElements != null) candidates.addAll(Arrays.asList(resolvedElements));
      }
      if (candidates.isEmpty()) {
        IModelElement enclosingMethod = getEnclosingMethod(input, selection);
        if (enclosingMethod != null) {
          candidates.add(enclosingMethod);
        }
      }
      run((IModelElement[]) candidates.toArray(new IModelElement[candidates.size()]));
    } catch (InvocationTargetException e) {
      ExceptionHandler.handle(
          e,
          getShell(),
          getErrorDialogTitle(),
          ActionMessages.SelectionConverter_codeResolve_failed);
    } catch (InterruptedException e) {
      // cancelled
    }
  }
 /** Note: This constructor is for internal use only. Clients should not call this constructor. */
 public OpenCallHierarchyAction(ScriptEditor editor) {
   this(editor.getEditorSite());
   fEditor = editor;
   setEnabled(SelectionConverter.canOperateOn(fEditor));
 }
 /**
  * This allows alternative editor implementations to override resolution
  *
  * @return
  * @throws InvocationTargetException
  * @throws InterruptedException
  */
 protected IModelElement[] resolveModelElements()
     throws InvocationTargetException, InterruptedException {
   return SelectionConverter.codeResolveOrInputForked(fEditor);
 }