コード例 #1
0
 public void run(IModelElement[] elements) {
   if (elements.length == 0) {
     getShell().getDisplay().beep();
     return;
   }
   CallHierarchyUI.open(elements, getSite().getWorkbenchWindow(), getCallHierarchyID());
 }
コード例 #2
0
  /* (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
    }
  }
コード例 #3
0
ファイル: OpenLocationAction.java プロジェクト: aptana/rdt
 /* (non-Javadoc)
  * Method declared on SelectionDispatchAction.
  */
 public void run(IStructuredSelection selection) {
   if (!checkEnabled(selection)) {
     return;
   }
   for (Iterator iter = selection.iterator(); iter.hasNext(); ) {
     boolean noError = CallHierarchyUI.openInEditor(iter.next(), getShell(), getDialogTitle());
     if (!noError) return;
   }
 }
コード例 #4
0
ファイル: OpenCallHierarchyAction.java プロジェクト: SjB/Dart
  @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());
  }
コード例 #5
0
  @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");
    }
  }
コード例 #6
0
  @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());
  }
コード例 #7
0
ファイル: OpenCallHierarchyAction.java プロジェクト: SjB/Dart
  @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
    }
  }
コード例 #8
0
 private boolean shouldStopTraversion(MethodWrapper methodWrapper) {
   return (methodWrapper.getLevel() > CallHierarchyUI.getDefault().getMaxCallDepth())
       || methodWrapper.isRecursive();
 }