Bug 3450

Summary: Bug in JavaSearchScope (1GLE1GC)
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P4 CC: svandijk
Version: 2.0   
Target Milestone: 2.0 M2   
Hardware: All   
OS: Windows 2000   
Whiteboard:

Description Olivier Thomann CLA 2001-10-10 22:55:19 EDT
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:
Comment 1 Jerome Lanneluc CLA 2001-10-12 10:17:37 EDT
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.
Comment 2 DJ Houghton CLA 2001-10-29 17:15:09 EST
PRODUCT VERSION:
	From Eclipse Corner

Comment 3 Jerome Lanneluc CLA 2001-12-18 12:12:23 EST
Stef, any news on this one? If not, I will close.
Comment 4 Stef van Dijk CLA 2001-12-18 21:00:33 EST
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.
Comment 5 Jerome Lanneluc CLA 2001-12-19 04:48:49 EST
Closing.