示例#1
0
  @Override
  public void run() {
    ISearchQuery searchJob = null;

    ISelection selection = getSelection();
    if (selection instanceof IStructuredSelection) {
      Object object = ((IStructuredSelection) selection).getFirstElement();
      if (object instanceof ISourceReference) searchJob = createQuery((ISourceReference) object);
    } else if (selection instanceof ITextSelection) {
      ITextSelection selNode = (ITextSelection) selection;
      ICElement element = fEditor.getInputCElement();
      while (element != null && !(element instanceof ITranslationUnit))
        element = element.getParent();
      if (element != null) {
        if (selNode.getLength() == 0) {
          IDocument document = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
          IRegion reg = CWordFinder.findWord(document, selNode.getOffset());
          selNode = new TextSelection(document, reg.getOffset(), reg.getLength());
        }
        searchJob = createQuery(element, selNode);
      }
    }

    if (searchJob == null) {
      showStatusLineMessage(CSearchMessages.CSearchOperation_operationUnavailable_message);
      return;
    }

    clearStatusLine();
    NewSearchUI.activateSearchResultView();
    NewSearchUI.runQueryInBackground(searchJob);
  }
 private String getMethodName(IMethod method) {
   StringBuffer name = new StringBuffer();
   String methodName = method.getElementName();
   ICElement parent = method.getParent();
   while (parent != null
       && (parent.getElementType() == ICElement.C_NAMESPACE
           || parent.getElementType() == ICElement.C_CLASS
           || parent.getElementType() == ICElement.C_STRUCT
           || parent.getElementType() == ICElement.C_UNION)) {
     name.append(parent.getElementName()).append("::"); // $NON-NLS-1$
     parent = parent.getParent();
   }
   name.append(methodName);
   appendParameters(name, method);
   return name.toString();
 }