Esempio n. 1
0
  @Override
  public void run(IStructuredSelection selection) {
    List<?> elements = selection.toList();
    if (!CallHierarchy.arePossibleInputElements(elements)) {
      elements = Collections.EMPTY_LIST;
    }

    TypeMember[] members = elements.toArray(new TypeMember[elements.size()]);
    if (!ActionUtil.areProcessable(getShell(), members)) {
      return;
    }

    CallHierarchyUI.openView(members, getSite().getWorkbenchWindow());
  }
  @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
  protected void doRun(
      IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) {

    List<?> elements = selection.toList();
    instrumentation.metric("Elements-Length", elements.size());

    if (!CallHierarchy.arePossibleInputElements(elements)) {
      elements = Collections.EMPTY_LIST;
    }

    TypeMember[] members = elements.toArray(new TypeMember[elements.size()]);
    ActionInstrumentationUtilities.record(members, "SelectedMembers", instrumentation);
    if (!ActionUtil.areProcessable(getShell(), members)) {
      instrumentation.metric("Problem", "areProcessable returned false");
      return;
    }

    CallHierarchyUI.openView(members, getSite().getWorkbenchWindow());
  }
Esempio n. 4
0
  @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
    }
  }
Esempio n. 5
0
 @Override
 public void selectionChanged(IStructuredSelection selection) {
   setEnabled(CallHierarchy.arePossibleInputElements(selection.toList()));
 }