I am developing a search plugin where i am using IPackageFragment to specify the package in which the search is to be carried out . I am not able to use the IPackageFragment to create IJavaSearchScope . Please help me by providing an explanation with suitable example .
Thanks
You have a fine example in this article Find unused methods:
The
IPackageFragmentis used to get any Java element you want (like methods)And the
IJavaSearchScopeis created from theSearchEngine, and used with elements found through theIPackageFragmentelements.private static int performIMethodSearch(IMethod method) throws CoreException { SearchPattern pattern = SearchPattern.createPattern(method, IJavaSearchConstants.REFERENCES); IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); MySearchRequestor requestor = new MySearchRequestor(); SearchEngine searchEngine = new SearchEngine(); searchEngine.search( pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope, requestor, null); return requestor.getNumberOfCalls(); }