List of usage examples for org.eclipse.jdt.internal.core.search.matching DeclarationOfReferencedMethodsPattern DeclarationOfReferencedMethodsPattern
public DeclarationOfReferencedMethodsPattern(IJavaElement enclosingElement)
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>/*from www .j ava2 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()); }