Example usage for org.eclipse.jdt.internal.core.search.matching DeclarationOfReferencedTypesPattern DeclarationOfReferencedTypesPattern

List of usage examples for org.eclipse.jdt.internal.core.search.matching DeclarationOfReferencedTypesPattern DeclarationOfReferencedTypesPattern

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.search.matching DeclarationOfReferencedTypesPattern DeclarationOfReferencedTypesPattern.

Prototype

public DeclarationOfReferencedTypesPattern(IJavaElement enclosingElement) 

Source Link

Usage

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>//from ww w.j  a  v  a  2s.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());
}