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

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

Introduction

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

Prototype

public DeclarationOfAccessedFieldsPattern(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 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>/*ww  w. j a  va 2s  .  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());
}