Using SearchEngine to find a method declaration [message #233580] |
Mon, 31 July 2006 22:18 |
Eclipse User |
|
|
|
Originally posted by: jdobros.umd.edu
I'm in the process of creating a plugin, and my current obstacle is when I
try to implement a feature which opens a .java file at the specified
method declaration. In short, given two strings, fileName and methodName,
I want the end product to be an IMarker to the method declaration of
methodName in the file fileName. However, the only method I've found
which seems to address this issue doesn't work. My current implementation
is as follows, where method is the String variable holding the method name:
SearchPattern pattern = SearchPattern.createPattern(method,
IJavaSearchConstants.METHOD,
IJavaSearchConstants.ALL_OCCURRENCES,
SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE);
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
SearchRequestor requestor = new SearchRequestor(){
public void acceptSearchMatch(SearchMatch match){
System.out.println("match found");
}
};
SearchEngine searchEngine = new SearchEngine();
try{
searchEngine.search(pattern,
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
scope, requestor, null);
}catch(CoreException e){
System.out.println("Error searching: "+e.toString());
}
My problem is that while I get no errors, I also get no matches. Can
anyone help me figure out where I'm going wrong? Or, does anyone have any
better ideas of how to open a .java file to a method declaration, when all
you have is the strings describing the filename and method.
Thanks,
John
|
|
|
Powered by
FUDForum. Page generated in 0.04629 seconds