Community
Participate
Working Groups
I am using build 0.137. I created a scope via SearchEngine.createJavaSearchScope() and provided an array of one project as the argument. I then performed a search for package declarations, and one of the matches was from within an external jar from another unrelated project's classpath. I traced through the code and the problem appears to be in JavaSearchScope.enclose(IJavaElement). It uses getUnderlyingResource() which for an external jar is null (there's even a comment to that affect), hence the method automatically returns true. In the case of external jars, shouldn't the method be trying to use getCorrespondingResource()? That would at least surface the fact that the jar is in a completely different project than the one for which I created the scope. NOTES:
getCorrespondingResource() will return null in the case of an external jar too. So I'm not sure what this would change. I think the problem is more that JavaSearchScope.enclose(IJavaElement) has been called with an IJavaElement coming from an unrelated jar. If you want to debug it, you should look at JavaSearchScope.enclosingProjectsAndJars(). I suspect that this returns the external jar that causes the problem.
PRODUCT VERSION: From Eclipse Corner
Stef, any news on this one? If not, I will close.
I am unable to find a failing scenario. My use of the search engine has changed quite a bit and I also use my own IJavaSearchScope implementation in certain cases. Next time I'll be sure to include a concrete set of steps for my own benefit as much as for the assignee. You may close this bug report.
Closing.