[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.jdt] Re: Searching for implementers of multiple interfaces

Gerry Kessler wrote:
Thanks for the response Frederic.

Yes, I want to use the createAndPattern method. I stupidly said union when I should have said intersection.

Before I enter a bug, do you see anything wrong with the code snippet below? I have verified in the debugger that the list of elems contains valid interface ITypes and that the constructed SearchPatterns are not null.


JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
IJavaSearchScope scope= factory.createJavaSearchScope(new IJavaElement[]{myJavaProject}, false);
SearchPattern patternA = SearchPattern.createPattern((IJavaElement)elems.get(0), IJavaSearchConstants.IMPLEMENTORS, 0);
SearchPattern patternB = SearchPattern.createPattern((IJavaElement)elems.get(1), IJavaSearchConstants.IMPLEMENTORS, 0);
SearchPattern andedPattern = SearchPattern.createAndPattern(patternA, patternB);
SearchRequestor requestor = new Searcher();
SearchEngine engine = new SearchEngine();
try {
engine.search(andedPattern, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, scope, requestor, null);
} catch (CoreException e) {
...
}
...
This results in a NullPointerException in MatchLocator when I call engine.search:


java.lang.NullPointerException
at org.eclipse.jdt.internal.core.search.matching.MatchLocator.<init>(MatchLocator.java:351)


at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:85)

at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:212)

at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:503)

at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:538)
...
The problem seems to stem from the static method PatternLocator.patternLocator(SearchPattern pattern) returning null. Regards,
Gerry Kessler
WTP JSF Tools Team



Your snippet is perfectly correct, this implementation for AndPattern which is not... :-(
Please open the bug and I'll have a look at it ASAP.
Thanks