Bug 250454 - [search] Cannot find method references between projects
Summary: [search] Cannot find method references between projects
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows 2000
: P3 major with 3 votes (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 240790 264153 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-10-10 11:35 EDT by Steven Sinclair CLA
Modified: 2009-03-09 12:14 EDT (History)
6 users (show)

See Also:


Attachments
Proposed patch (15.10 KB, patch)
2009-02-11 09:04 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Sinclair CLA 2008-10-10 11:35:07 EDT
Build ID: 3.4.0

Steps To Reproduce:

1) define 3 projects: rootProject, subProject1, and subProject2.
2) set project build depedencies such that subProject1 and subProject2 depend on rootProject
3) Create interface in rootProject:
	public interface Shape { public void f(); }
4) Create implementing class in subProject1
	public class Square implements Shape { public void f() {} }
5) Create referencing class in subProject2
	public class ShapeUser { public void useShape(Shape p_shape)  { p_shape.f(); }


6) Search for references to Square.f() directly from it's declaration in Square.java.
	6a) EXPECT: one result: ShapeUser.useShape(Shape)
	6b) ACTUAL: no results

If ShapeUser is instead located in the direct derivable project dependency graph for subProject1, the results are ok.  For example, 
	1) If Square were defined in rootProject itself, the search succeeds.
	2) If Square were defined in subProject2, the search succeeds.  
	3) If subProject2 has a build dependency on subProject1, the search succeeds.

Additionally, searching for references to f() from the Shape declaration succeeds as defined above.  It appears the search does not go to all dependent projects of the project declaring the interface.



More information:
Also reproduced this bug on 3.3.1.1 (earliest version available to me)

This is related to Bug#: 178596, which is closed with Eclipse 3.3, but when this problem recurs when the project dependencies are as described above.
Comment 1 Frederic Fusier CLA 2009-02-05 04:44:27 EST
The problem comes from the fact that search engine first looks at projects concerned by the search to know which indexes should be activated... In this case the current algorithm in IndexSelector.initializeIndexLocations() does not consider that subProject2 can see the focus.

The problem is tricky at this stage, as the index selector knows nothing about the hierarchy of the declaring class of the searched method. 

Several ways may be envisaged to fix this issue but they would have all impact on performances:
1) look at resolved classpath of each project of the scope and keep it as soon as
   one entry is common with the focus project
2) look at focus declaration class super type hierarchy and either starts
   the search from the root type or walk through the whole hierarchy and
   keep indexes for all projects of it
3) include all indexes when the search is done on the workspace

I'll try to figure out what could be the performance impact for 2) and 3). Proposal 1) is currently a no go because either jars are not included and there would be still use case where the references wasn't find or the jars are included and then all projects would be added due to JRE and PDE containers...
Comment 2 Frederic Fusier CLA 2009-02-09 10:33:20 EST
*** Bug 264153 has been marked as a duplicate of this bug. ***
Comment 3 Frederic Fusier CLA 2009-02-11 09:04:15 EST
Created attachment 125382 [details]
Proposed patch
Comment 4 Frederic Fusier CLA 2009-02-11 09:08:45 EST
(In reply to comment #3)
> Created an attachment (id=125382) [details]
> Proposed patch
> 
I forgot to mention that I didn't notice any noticeable performance regression with this patch.
Comment 5 Frederic Fusier CLA 2009-02-12 11:55:50 EST
Released for 3.5M6 in HEAD stream.
Comment 6 Frederic Fusier CLA 2009-03-04 10:12:18 EST
*** Bug 240790 has been marked as a duplicate of this bug. ***
Comment 7 David Audel CLA 2009-03-09 12:14:49 EDT
Verified for 3.5M6 using I20090309-0100.