Bug 90160 - [search] SearchEngine.createJavaSearchScope swallows problems
Summary: [search] SearchEngine.createJavaSearchScope swallows problems
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-04 10:14 EDT by Martin Aeschlimann CLA
Modified: 2005-05-12 06:21 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2005-04-04 10:14:23 EDT
20050404

- Use the search dialog and create a Java working set that contains a new Java
project.
- Search
- No result or only half of the results
(see bug 82505)

Probelm is BasicSearchEngine.createJavaSearchScope: It starts collecting the
elements for the scope but with a problem just silently leaves the loop (line 145)

I see the following solutions:
- be more tollerant with Non- Java projects (make a IJavaProject.exists test
before accessing getResolvedClasspath in JavaSearchScope.add(..)
- only skip the problematic element, but collect elements for the rest
- forward the exception to the client (new API)
Comment 1 Martin Aeschlimann CLA 2005-04-04 10:22:12 EDT
It would be good if a IJavaSearchScope could deal with a non-Java project.
We use the created IJavaSearchScope later as input for search UI participants. 
They might want to contribute results from non-Java project.
Comment 2 Frederic Fusier CLA 2005-04-04 11:13:25 EDT
Of course new API will not be done for 3.1 as API is now frozen...
Comment 3 Frederic Fusier CLA 2005-04-26 12:39:31 EDT
I do not understand the first solution: how can we be tolerant with Non-Java
project although they cannot contain element which would be on the classpath and
so will never be found by indexer...
IMO, it's a Java search, user has to use textual search to find any other piece
of information than Java ones... but perhaps I missed something?

So, the only valid solution I see at this late stage (frozen APIs) is to skip
the problematic element by catching the exception inside the loop instead of
outside. That will allow search engine to collect elements for non problematic ones.
Comment 4 Frederic Fusier CLA 2005-04-26 14:49:57 EDT
Fixed and released in HEAD.

Even if first solution was valid, it would have been too risky to implement it
at this late stage in 3.1 dvpt. So, Marting, if you're definitely convinced that
Non-Java project should be added to JavaSearchScope, then open a new bug for
this requirement to open discussion on this specific topic.

So, fix consists in catching exception for non-java project to allow search
engine continue normally on java ones...

[jdt-core-internal]
Changes done in BasicSearchEngine.createJavaSearchScope(IJavaElement[],int)

No specific test case added as fix was really trivial...
Note that all JDT/UI tests pass with this fix
Comment 5 Martin Aeschlimann CLA 2005-04-27 02:49:08 EDT
With tolerating I meant the same as skipping.

Do I have to skip the file now to avaid a log entry?
Comment 6 Frederic Fusier CLA 2005-04-27 05:06:02 EDT
No, you do not. As execption is now catched for each project, all non-java
projects are skipped and not added to JavaSearchScope. All others (ie. Java
project) are added in JavaSearchScope and search is performed on them...
Comment 7 Maxime Daniel CLA 2005-05-12 06:14:17 EDT
Verified for 3.1 M7 using build I20050509-2010 + jdt.core HEAD.