Example usage for org.eclipse.jdt.core.search IJavaSearchResultCollector getProgressMonitor

List of usage examples for org.eclipse.jdt.core.search IJavaSearchResultCollector getProgressMonitor

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.search IJavaSearchResultCollector getProgressMonitor.

Prototype

public IProgressMonitor getProgressMonitor();

Source Link

Document

Returns the progress monitor used to report progress.

Usage

From source file:org.eclipse.jdt.core.search.SearchEngine.java

License:Open Source License

/**
 * Searches for the Java element determined by the given signature. The signature
 * can be incomplete. For example, a call like
 * <code>search(ws, "run()", METHOD,REFERENCES, col)</code>
 * searches for all references to the method <code>run</code>.
 *
 * Note that by default the pattern will be case insensitive. For specifying case s
 * sensitive search, use <code>search(workspace, createSearchPattern(patternString, searchFor, limitTo, true), scope, resultCollector);</code>
 *
 * @param workspace the workspace//w  w w  .jav a  2  s.  c o m
 * @param patternString the pattern to be searched for
 * @param searchFor a hint what kind of Java element the string pattern represents.
 *  Look into {@link IJavaSearchConstants} for valid values
 * @param limitTo one of the following values:
 *   <ul>
 *     <li>{@link IJavaSearchConstants#DECLARATIONS}: search
 *        for declarations only </li>
 *     <li>{@link IJavaSearchConstants#REFERENCES}: search
 *        for all references </li>
 *     <li>{@link IJavaSearchConstants#ALL_OCCURRENCES}: search
 *        for both declarations and all references </li>
 *     <li>{@link IJavaSearchConstants#IMPLEMENTORS}: for types, will find all types
 *         which directly implement/extend a given interface.<br>
 *         Note that types may be only classes or only interfaces if respectively {@link IJavaSearchConstants#CLASS} or
 *         {@link IJavaSearchConstants#INTERFACE} is used for searchFor parameter instead of {@link IJavaSearchConstants#TYPE}.
 *     </li>
 * </ul>
 * @param scope the search result has to be limited to the given scope
 * @param resultCollector a callback object to which each match is reported
 * @exception JavaModelException if the search failed. Reasons include:
 *   <ul>
 *      <li>the classpath is incorrectly set</li>
 *   </ul>
 * @deprecated Use {@link  #search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)} instead.
 */
public void search(IWorkspace workspace, String patternString, int searchFor, int limitTo,
        IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException {
    try {
        int matchMode = patternString.indexOf('*') != -1 || patternString.indexOf('?') != -1
                ? SearchPattern.R_PATTERN_MATCH
                : SearchPattern.R_EXACT_MATCH;
        search(SearchPattern.createPattern(patternString, searchFor, limitTo,
                matchMode | SearchPattern.R_CASE_SENSITIVE),
                new SearchParticipant[] { getDefaultSearchParticipant() }, scope,
                new ResultCollectorAdapter(resultCollector), resultCollector.getProgressMonitor());
    } catch (CoreException e) {
        if (e instanceof JavaModelException)
            throw (JavaModelException) e;
        throw new JavaModelException(e);
    }
}

From source file:org.eclipse.jdt.core.search.SearchEngine.java

License:Open Source License

/**
 * Searches for matches of a given search pattern. Search patterns can be created using helper
 * methods (from a String pattern or a Java element) and encapsulate the description of what is
 * being searched (for example, search method declarations in a case sensitive way).
 *
 * @param workspace the workspace/*from  w  w  w .  j av  a 2s . co m*/
 * @param searchPattern the pattern to be searched for
 * @param scope the search result has to be limited to the given scope
 * @param resultCollector a callback object to which each match is reported
 * @exception JavaModelException if the search failed. Reasons include:
 *   <ul>
 *      <li>the classpath is incorrectly set</li>
 *   </ul>
 * @deprecated Use {@link  #search(SearchPattern, SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)} instead.
 */
public void search(IWorkspace workspace, ISearchPattern searchPattern, IJavaSearchScope scope,
        IJavaSearchResultCollector resultCollector) throws JavaModelException {
    try {
        search(((SearchPatternAdapter) searchPattern).pattern,
                new SearchParticipant[] { getDefaultSearchParticipant() }, scope,
                new ResultCollectorAdapter(resultCollector), resultCollector.getProgressMonitor());
    } catch (CoreException e) {
        if (e instanceof JavaModelException)
            throw (JavaModelException) e;
        throw new JavaModelException(e);
    }
}

From source file:org.eclipse.jdt.core.search.SearchEngine.java

License:Open Source License

/**
 * Searches for all declarations of the fields accessed in the given element.
 * The element can be a compilation unit, a source type, or a source method.
 * Reports the field declarations using the given collector.
 * <p>/* w w  w .j av  a2 s .c o  m*/
 * Consider the following code:
 * <code>
 * <pre>
 *      class A {
 *         int field1;
 *      }
 *      class B extends A {
 *         String value;
 *      }
 *      class X {
 *         void test() {
 *            B b = new B();
 *            System.out.println(b.value + b.field1);
 *         };
 *      }
 * </pre>
 * </code>
 * then searching for declarations of accessed fields in method
 * <code>X.test()</code> would collect the fields
 * <code>B.value</code> and <code>A.field1</code>.
 * </p>
 *
 * @param workspace the workspace
 * @param enclosingElement the method, type, or compilation unit to be searched in
 * @param resultCollector a callback object to which each match is reported
 * @exception JavaModelException if the search failed. Reasons include:
 *   <ul>
 *      <li>the element doesn't exist</li>
 *      <li>the classpath is incorrectly set</li>
 *   </ul>
 * @deprecated Use {@link  #searchDeclarationsOfAccessedFields(IJavaElement, SearchRequestor, IProgressMonitor)} instead.
 */
public void searchDeclarationsOfAccessedFields(IWorkspace workspace, IJavaElement enclosingElement,
        IJavaSearchResultCollector resultCollector) throws JavaModelException {
    SearchPattern pattern = new DeclarationOfAccessedFieldsPattern(enclosingElement);
    this.basicEngine.searchDeclarations(enclosingElement, new ResultCollectorAdapter(resultCollector), pattern,
            resultCollector.getProgressMonitor());
}

From source file:org.eclipse.jdt.core.search.SearchEngine.java

License:Open Source License

/**
 * Searches for all declarations of the types referenced in the given element.
 * The element can be a compilation unit, a source type, or a source method.
 * Reports the type declarations using the given collector.
 * <p>//www.j a  va  2  s . c o m
 * Consider the following code:
 * <code>
 * <pre>
 *      class A {
 *      }
 *      class B extends A {
 *      }
 *      interface I {
 *        int VALUE = 0;
 *      }
 *      class X {
 *         void test() {
 *            B b = new B();
 *            this.foo(b, I.VALUE);
 *         };
 *      }
 * </pre>
 * </code>
 * then searching for declarations of referenced types in method <code>X.test()</code>
 * would collect the class <code>B</code> and the interface <code>I</code>.
 * </p>
 *
 * @param workspace the workspace
 * @param enclosingElement the method, type, or compilation unit to be searched in
 * @param resultCollector a callback object to which each match is reported
 * @exception JavaModelException if the search failed. Reasons include:
 *   <ul>
 *      <li>the element doesn't exist</li>
 *      <li>the classpath is incorrectly set</li>
 *   </ul>
 * @deprecated Use {@link #searchDeclarationsOfReferencedTypes(IJavaElement, SearchRequestor, IProgressMonitor)} instead.
 */
public void searchDeclarationsOfReferencedTypes(IWorkspace workspace, IJavaElement enclosingElement,
        IJavaSearchResultCollector resultCollector) throws JavaModelException {
    SearchPattern pattern = new DeclarationOfReferencedTypesPattern(enclosingElement);
    this.basicEngine.searchDeclarations(enclosingElement, new ResultCollectorAdapter(resultCollector), pattern,
            resultCollector.getProgressMonitor());
}

From source file:org.eclipse.jdt.core.search.SearchEngine.java

License:Open Source License

/**
 * Searches for all declarations of the methods invoked in the given element.
 * The element can be a compilation unit, a source type, or a source method.
 * Reports the method declarations using the given collector.
 * <p>/* w  w w . j a v  a  2  s .  c  o m*/
 * Consider the following code:
 * <code>
 * <pre>
 *      class A {
 *         void foo() {};
 *         void bar() {};
 *      }
 *      class B extends A {
 *         void foo() {};
 *      }
 *      class X {
 *         void test() {
 *            A a = new B();
 *            a.foo();
 *            B b = (B)a;
 *            b.bar();
 *         };
 *      }
 * </pre>
 * </code>
 * then searching for declarations of sent messages in method
 * <code>X.test()</code> would collect the methods
 * <code>A.foo()</code>, <code>B.foo()</code>, and <code>A.bar()</code>.
 * </p>
 *
 * @param workspace the workspace
 * @param enclosingElement the method, type, or compilation unit to be searched in
 * @param resultCollector a callback object to which each match is reported
 * @exception JavaModelException if the search failed. Reasons include:
 *   <ul>
 *      <li>the element doesn't exist</li>
 *      <li>the classpath is incorrectly set</li>
 *   </ul>
 * @deprecated Use {@link #searchDeclarationsOfSentMessages(IJavaElement, SearchRequestor, IProgressMonitor)} instead.
 */
public void searchDeclarationsOfSentMessages(IWorkspace workspace, IJavaElement enclosingElement,
        IJavaSearchResultCollector resultCollector) throws JavaModelException {
    SearchPattern pattern = new DeclarationOfReferencedMethodsPattern(enclosingElement);
    this.basicEngine.searchDeclarations(enclosingElement, new ResultCollectorAdapter(resultCollector), pattern,
            resultCollector.getProgressMonitor());
}