We currently store a separate Lucene index for each project, so this method is used to find all the relevant indices to search in. 

When you perform a "custom" search the user will have the ability to select the scope of the search, so this method is only used when finding occurrences of the the entity under the cursor.

I agree that we can generalize this and say we have an index for each classpath entry (no duplicates in the workspace). `IJavaProject` has a `getResolvedClasspath` method that might be useful. Currently we find the transitive closure of the project dependencies. I wonder if the classpath will take care of this.