Bug 9179 - DCR: Need IJavaSearchScope equals or encloses
Summary: DCR: Need IJavaSearchScope equals or encloses
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P4 normal (vote)
Target Milestone: 2.0 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-02-06 11:57 EST by Martin Aeschlimann CLA
Modified: 2002-04-05 05:50 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2002-02-06 11:57:18 EST
For the AllTypes dialog, search results are cached (scope is workspacescope). 
this cache is also used for other searches with other scopes.
to know if the cache is appropriate, scopes have to be compared

IJavaSearchScope.equals(IJavaSearchScope)
and
IJavaSearchScope.contains(IJavaSearchScope)

are needed.

The current solution is to compare the scope to be of type JavaWorkspaceScope
which is internal
Comment 1 Philipe Mulet CLA 2002-02-06 17:56:53 EST
Nice to have

Why don't you rather play rules on the elements you did put in these scopes 
instead ? 

Comment 2 Martin Aeschlimann CLA 2002-02-07 03:53:10 EST
what do you mean by 'play rules'?

The funtionallity offered is 
getTypes(IJavaSearchScope scope ...) and caching is done interally. Having an 
existing cache for the all types in the workspace can be used for reduced 
scopes as well.

equals should be simple to implement..?
Comment 3 Philipe Mulet CLA 2002-02-07 16:33:23 EST
Would you expect resource/element set equality or inclusion semantics ?
Comment 4 Martin Aeschlimann CLA 2002-02-08 03:16:49 EST
I can live with a simple element equality test.
Comment 5 Philipe Mulet CLA 2002-02-08 07:09:47 EST
Time permitting
Comment 6 Philipe Mulet CLA 2002-03-28 06:04:49 EST
Actually, we cannot add these without breaking 1.0 implementations.
Will not implement the change.

Closing
Comment 7 Martin Aeschlimann CLA 2002-03-28 06:20:46 EST
I'm currently using internal core API to find out if the scope is a workspace 
scope.
Please tell me how I can do this otherwise, if I can't compare scopes.

Comment 8 Jerome Lanneluc CLA 2002-03-28 06:58:45 EST
You should remember how you created the scope. One way to do this would be to 
have your own IJavaSearchScope that wraps the jdtcore search scope and that 
implements equals by comparing the elements that were used to create the scope.

As a side note, please stop re-opening this bug as it is really impossible for 
us to augment the API of IJavaSearchScope because this API is frozen since 1.0.
Comment 9 Martin Aeschlimann CLA 2002-03-28 08:02:56 EST
without reopening... sorry for being a pain

maybe the comment was missing that this class is not intended to be subclassed.
I suggest to add it

also, equals is not documented, but unspecified. specifying this is not 
breaking, more a bug fix in case you change the behaviour.

But, ok to wontfix. I'll add a workaround
Comment 10 Martin Aeschlimann CLA 2002-03-28 08:24:30 EST
Workaroiund is possible, but very expensive.

Let me describe the use case, to see my motivation to not giving up so fast:

AllTypesCache is essential for having a fast performance of the AllTypesDialog.
All request for a list of all types goes through the cache, which is flushed on 
any type changes.
The same cache is also used by other type queries, also with smaller scopes. 
However, a cache is only created for workspace-scopes. This is the reason why I 
have to compare scopes. In fact I only need to know if the passed in scope is a 
workspace scope.
The solution you suggested is problematic, as user dialogs created from our API 
classes JavaUI.createTypeDialog has IJavaSearchScope as parameter, and the 
clients also expect the best performance -> we should use the cache -> the 
cache must be able to work with original IJavaSearchScope.

I think this should be ok, 100% non-breaking
JavaWorkspaceScope.equals(Object obj):
  return obj != null && obj.getClass().equals(this.getClass())






Comment 11 Jerome Lanneluc CLA 2002-03-28 10:36:32 EST
1. IJavaSearchScope specifies that clients may choose to implement this 
interface.

2. Not sure why the workaround I suggested (i.e. you implement IJavaSearchScope 
and your implementation wraps the original search scope) would be expensive. 
You could even define equals on this implementation!
Comment 12 Martin Aeschlimann CLA 2002-03-28 11:13:39 EST
because of our unfortunate choice of API in JavaUI.
createTypeDialog (3 methods) & createMainTypeDialog (2 methods)
have JavaSearchScope in the signature.
I now also need the information if this is a workspace scope (add a boolean)
+ the old behaviour should be performant.

Please have a look at my suggestion to add equals to your internal class
WorkspaceSearchScope.

Comment 13 Martin Aeschlimann CLA 2002-03-28 11:19:38 EST
btw, another suggestion is to add a method

or SearchEngine.isWorkspaceScope(scope)
analog to SearchEngine.createWorkspaceSearchScope()
Comment 14 Jerome Lanneluc CLA 2002-04-05 05:48:56 EST
Re-opening.
Comment 15 Jerome Lanneluc CLA 2002-04-05 05:50:59 EST
Implemented equals on JavaWorkspaceScope.