}
public static Collection/*<MethodUnitPair>*/ findDeclarations(IProgressMonitor progressMonitor, String methodName, IJavaProject project, boolean isConstructor) {
try {
SearchRequestor searchRequestor = new MethodSearchRequestor.MethodDeclarationsSearchRequestor();
SearchEngine searchEngine = new SearchEngine();
IProgressMonitor monitor = new SubProgressMonitor(
progressMonitor, 5, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
monitor.beginTask("Searching for calls to " +
methodName + (project != null ? " in " + project.getProject().getName() : ""), 100);
IJavaSearchScope searchScope = getSearchScope(project);
// This is kind of hacky: we need to make up a string name for the search to work right
log("Looking for " + methodName);
int matchType = !isConstructor ? IJavaSearchConstants.METHOD : IJavaSearchConstants.CONSTRUCTOR;
SearchPattern pattern = SearchPattern.createPattern(
methodName,
matchType,
IJavaSearchConstants.DECLARATIONS,
SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE );
searchEngine.search(
pattern,
new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
searchScope,
searchRequestor,
monitor