Community
Participate
Working Groups
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
Nice to have Why don't you rather play rules on the elements you did put in these scopes instead ?
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..?
Would you expect resource/element set equality or inclusion semantics ?
I can live with a simple element equality test.
Time permitting
Actually, we cannot add these without breaking 1.0 implementations. Will not implement the change. Closing
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.
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.
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
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())
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!
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.
btw, another suggestion is to add a method or SearchEngine.isWorkspaceScope(scope) analog to SearchEngine.createWorkspaceSearchScope()
Re-opening.
Implemented equals on JavaWorkspaceScope.