Bug 295894 - [search] Search shows focus type implementation for nested types even though the scope is restricted to subtypes.
Summary: [search] Search shows focus type implementation for nested types even though ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M5   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 295897
  Show dependency tree
 
Reported: 2009-11-23 11:28 EST by Raksha Vasisht CLA
Modified: 2010-03-12 19:29 EST (History)
6 users (show)

See Also:


Attachments
Tests showing the problem (5.00 KB, patch)
2009-11-24 04:43 EST, Frederic Fusier CLA
no flags Details | Diff
API simplification (37.52 KB, patch)
2009-11-24 08:46 EST, Stephan Herrmann CLA
no flags Details | Diff
Patch to fix encoding issue (284.89 KB, patch)
2009-11-25 07:26 EST, Frederic Fusier CLA
no flags Details | Diff
combined changes (21.02 KB, patch)
2009-12-05 13:01 EST, Stephan Herrmann CLA
no flags Details | Diff
updated patch: new method name (23.46 KB, patch)
2009-12-07 12:08 EST, Stephan Herrmann CLA
no flags Details | Diff
patch v4 (26.29 KB, patch)
2010-01-13 10:56 EST, Stephan Herrmann CLA
frederic_fusier: iplog+
frederic_fusier: review+
Details | Diff
Same patch with copyright updates (28.48 KB, patch)
2010-01-13 12:14 EST, Olivier Thomann CLA
no flags Details | Diff
additional test (1.78 KB, patch)
2010-01-14 04:49 EST, Stephan Herrmann CLA
no flags Details | Diff
Additional test highlighting the problem described by Dani (3.63 KB, patch)
2010-01-14 06:58 EST, Frederic Fusier CLA
no flags Details | Diff
Additional test highlighting the problem described by Dani (3.63 KB, patch)
2010-01-14 07:37 EST, Frederic Fusier CLA
no flags Details | Diff
proposed fix re comment 54 (5.17 KB, patch)
2010-01-14 08:28 EST, Stephan Herrmann CLA
no flags Details | Diff
same patch - one more test (6.15 KB, patch)
2010-01-14 09:12 EST, Stephan Herrmann CLA
frederic_fusier: iplog+
frederic_fusier: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Raksha Vasisht CLA 2009-11-23 11:28:15 EST
build : HEAD (Pls remove the temp workaround in line 213 with this bug id as comment :
" && !links.contains(methodFound)" to reproduce)

The code in org.eclipse.jdt.internal.ui.javaeditor.JavaElementImplementationHyperlink.openImplementations(...) 
searches for implementations in sub types of a focus type and creates the hierarchy scope using API :

org.eclipse.jdt.core.search.SearchEngine.createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean noMemberTypes, WorkingCopyOwner owner) 

with the 'onlySubtypes' flag set to true. But with nested types, the search  also shows the implementation in focus type when the subtype has a declaration of the method. For ex:

public class sup {
    void test() {
        sup a = new sup();
        a.toString();        
    }    

    
    public String toString() {
        return "";
    }

    public abstract class sub extends sup{        
        public abstract String toString() ;
    }
}

Expected : When you open implementation on a.toString(), the search results must return only sub.toString(). 

Current Behaviour: shows sup.toString(), sub.toString(). Which is wrong according to the API documentation. 

PS: Same behaviour is seen even when sub has a concrete implementation of toString() rather than abstract.
Comment 1 Markus Keller CLA 2009-11-23 13:23:06 EST
Raksha, your code in HEAD calls SearchEngine.createHierarchyScope(..) with noMemberTypes == false. Doesn't it work as you expect when you set it to true?
Comment 2 Raksha Vasisht CLA 2009-11-24 01:37:01 EST
(In reply to comment #1)
> Raksha, your code in HEAD calls SearchEngine.createHierarchyScope(..) with
> noMemberTypes == false. Doesn't it work as you expect when you set it to true?

Ahh yes! The boolean noMemberTypes also filters enclosing types which could be used in this case. It works as expected with that flag set to true. Thanks Markus!
Comment 3 Dani Megert CLA 2009-11-24 02:57:47 EST
>Doesn't it work as you expect when you set it to true?
That's not the point of this bug. The bug is about returning results for the focus type. According to the Javadoc it should not return results for the focus type:

 * This method, however, allows to restrict the hierarchy to true subtypes,
 * neither including supertypes nor the focus type itself.

Now, the flag you mention can be set to hide results for member types but that shouldn't override the general spec to not return results for the focus type and especially not when the focus type is the top-level class.

Reopening to fix.
Comment 4 Dani Megert CLA 2009-11-24 03:35:13 EST
And there seems to be wrong interpretation of noMemberTypes too.
Comment 5 Frederic Fusier CLA 2009-11-24 04:42:16 EST
My first analysis is that there are two issues here:
a) comment 0: when the onlySubtypes param is set to true, the SearchEngine should never return the focus type
b) comment 3: we missed the peculiar case where a sub-type is an inner class and onlySubtypes==true and noMemberTypes==true. Which parameter should be taken
into account first...!? I agree with Dani that changing the noMemberTypes value should not change the behavior of the onlySubtypes flag. But I'd add that it should also take the precedence on that flag: e.g. with the peculiar case I described earlier, no match at all should be returned...
Comment 6 Frederic Fusier CLA 2009-11-24 04:43:47 EST
Created attachment 152929 [details]
Tests showing the problem

Here are some additional tests to show and reproduce the problem easily...
Comment 7 Markus Keller CLA 2009-11-24 06:54:57 EST
Do we have a use case for noMemberTypes == false? I think not. This was just a bug in the old methods, but we couldn't fix them because the bug was also in the specification.

I would just remove that parameter (always set it to true). That would also simplify the documentation. It could e.g. say:

Unlike the other <code>createHierarchyScope</code> methods, this method creates scopes that only contain types that actually span the hierarchy of the focus type, but do not include additional enclosing or member types.
Comment 8 Dani Megert CLA 2009-11-24 07:03:05 EST
+1 for comment 7.
Comment 9 Stephan Herrmann CLA 2009-11-24 07:15:01 EST
Has anybody started working on a patch or should I have a look,
since this is a follow up of bug 215139?

(In reply to comment #5)
> b) comment 3: we missed the peculiar case where a sub-type is an inner class
> and onlySubtypes==true and noMemberTypes==true. Which parameter should be taken
> into account first...!? I agree with Dani that changing the noMemberTypes value
> should not change the behavior of the onlySubtypes flag. But I'd add that it
> should also take the precedence on that flag: e.g. with the peculiar case I
> described earlier, no match at all should be returned...

According to the original intention I'd say that noMemberTypes should
never exclude an actual subtype.

(In reply to comment #7)
> Do we have a use case for noMemberTypes == false? I think not. This was just a
> bug in the old methods, but we couldn't fix them because the bug was also in
> the specification.
>
> I would just remove that parameter (always set it to true). That would also
> simplify the documentation. It could e.g. say:
>
> Unlike the other <code>createHierarchyScope</code> methods, this method creates
> scopes that only contain types that actually span the hierarchy of the focus
> type, but do not include additional enclosing or member types.

I fully agree.
Comment 10 Frederic Fusier CLA 2009-11-24 07:30:32 EST
(In reply to comment #9)
> Has anybody started working on a patch or should I have a look,
> since this is a follow up of bug 215139?
> 
I just wrote the tests, so if you have time to have a look on it, I will sincerely be happy :-)

> (In reply to comment #5)
> According to the original intention I'd say that noMemberTypes should
> never exclude an actual subtype.
> 
> (In reply to comment #7)
> > Do we have a use case for noMemberTypes == false? I think not. This was just a
> > bug in the old methods, but we couldn't fix them because the bug was also in
> > the specification.
> >
> > I would just remove that parameter (always set it to true). That would also
> > simplify the documentation. It could e.g. say:
> >
> > Unlike the other <code>createHierarchyScope</code> methods, this method creates
> > scopes that only contain types that actually span the hierarchy of the focus
> > type, but do not include additional enclosing or member types.
> 
> I fully agree.

So, if there's no real use case for the false value and it was not included in the initial intention, then I also agree to remove this parameter...
Comment 11 Stephan Herrmann CLA 2009-11-24 08:10:05 EST
At a closer look the implementation is correct wrt the specification:
With these options:
  onlySubtypes=true
  noMemberTypes=false
type sup from comment 0 is correctly found because it is the enclosing
type of a true sub type (note that noMemberTypes covers both direction
of containment - probably a misnomer to begin with ...)

Following comment 7, however, this is a non-issue since the combination
(onlySubtypes=true,noMemberTypes=false) seems to be useless.

The main improvement in this bug will thus be simplification by
removing a difficult-to-explain parameter.
Comment 12 Stephan Herrmann CLA 2009-11-24 08:46:27 EST
Created attachment 152945 [details]
API simplification

This patch contains the API simplification suggested in comment 7,
but DO NOT BLINDLY APPLY THIS PATCH (see below).

I've tried to update the tests, too. 

Firstly, my patch is not usable for the tests since I'm still affected
by bug 214085 comment 4!! Perhaps some more votes could help here?

Secondly, with the simplified API some tests no longer apply.
Should some of those tests from bug 215139 be removed or be
disabled and kept for documentation?
Comment 13 Dani Megert CLA 2009-11-24 09:10:21 EST
>Firstly, my patch is not usable for the tests since I'm still affected
>by bug 214085 comment 4!! Perhaps some more votes could help here?
Bug 214085 is valid BUT the main issue here is with the test project itself: if it uses special characters encoded in ISO-8859-1 (because most JDT Core developers use Windows XP) then it must explicitly set the project specific encoding to ISO-8859-1 otherwise there is not way for the editor or patch wizard to guess this.

Frédéric, please fix all JDT Core projects that have such special chars.
Comment 14 Dani Megert CLA 2009-11-25 03:14:53 EST
>With these options:
>  onlySubtypes=true
>  noMemberTypes=false
>type sup from comment 0 is correctly found because it is the enclosing
>type of a true sub type (note that noMemberTypes covers both direction
>of containment - probably a misnomer to begin with ...)
Such a behavior would be misleading and I would consider it broken but as we agreed this parameter will go away anyway ;-)


It's also wrong to exclude the focus type: the 80% case is to search an element in a hierarchy of T and of course a result in T itself is naturally expected to appear. With the existing API the client is forced to manually do the test himself. Yes, it's easy to do, but it is additional useless work that the search engine should do for me. This is also better aligned with the other createHierarchyScope(*) methods which include the focus type. So, the correct fix for this is to have parameter that tells whether to include the focus type or not.
Comment 15 Stephan Herrmann CLA 2009-11-25 06:34:20 EST
(In reply to comment #14)
> >With these options:
> >  onlySubtypes=true
> >  noMemberTypes=false
> >type sup from comment 0 is correctly found because it is the enclosing
> >type of a true sub type (note that noMemberTypes covers both direction
> >of containment - probably a misnomer to begin with ...)
> Such a behavior would be misleading and I would consider it broken but as we
> agreed this parameter will go away anyway ;-)

The catch is: pre bug 215139 the hierarchy scope ALWAYS contained
all enclosing types of types in the hierarchy. And since reasons exist
to maintain that behavior, HierarchyScope.encloses() MUST still be able
to compute that set as well.

In that light the patch in bug 215139 was designed in terms of additional
parameters that incrementally change the behavior of a HierarchyScope,
not a full re-design ;-)

If one of the factory methods in SearchEngine starts to produce behavioral
differences that are not controlled by an explicit parameter, this might
actually be confusing, too.

> So, the correct fix for this is to have parameter that tells whether to 
> include the focus type or not.

If there's sufficient demand for that parameter that should be easy to add.

Also note, that the new API is already consumed by PDE/UI. Any changes will
have to be propagated.
Comment 16 Dani Megert CLA 2009-11-25 06:58:06 EST
>And since reasons exist
>to maintain that behavior, HierarchyScope.encloses() MUST still be able
>to compute that set as well
Which ones? When adding a new API there's no need to take over anything unless there are good reasons/demands.

>If there's sufficient demand for that parameter that should be easy to add.
Yes, PDE needs it and there is no API that would allow them to remove the focus type from the IJavaSearchScope, hence we have to add the parameter.

>Also note, that the new API is already consumed by PDE/UI. Any changes will
>have to be propagated.
I know and it's also used by JDT Text. Once we have a patch we agree on, we can coordinate the changes, that's no problem.
Comment 17 Dani Megert CLA 2009-11-25 06:59:41 EST
NOTE: Given the method is in M3, we should leave it in for M4 but deprecate it with a comment that it will be removed for 3.6 (M5).
Comment 18 Frederic Fusier CLA 2009-11-25 07:24:37 EST
(In reply to comment #13)
> >Firstly, my patch is not usable for the tests since I'm still affected
> >by bug 214085 comment 4!! Perhaps some more votes could help here?
> Bug 214085 is valid BUT the main issue here is with the test project itself: if
> it uses special characters encoded in ISO-8859-1 (because most JDT Core
> developers use Windows XP) then it must explicitly set the project specific
> encoding to ISO-8859-1 otherwise there is not way for the editor or patch
> wizard to guess this.
> 
> Frédéric, please fix all JDT Core projects that have such special chars.
>
JDT/Core usually didn't have such characters, but I introduced the '§' char when working on Java Search tests and it seems it was definitely not a good idea... So, I change to use an ASCII character ('!') instead and avoid this kind of limitation in our projects.

I also set specific 'UTF-8' encoding for a file containing specific UTF-8 characters used by the EncodingTests test suite...

The changes have been released in HEAD, hence it should be OK to create the patch even if the bug 214085 is still not fixed.
Comment 19 Frederic Fusier CLA 2009-11-25 07:26:15 EST
Created attachment 153058 [details]
Patch to fix encoding issue

Patch corresponding to the change described in comment 18 and which has been released in HEAD...
Comment 20 Stephan Herrmann CLA 2009-11-25 08:15:39 EST
(In reply to comment #16)
> >And since reasons exist
> >to maintain that behavior, HierarchyScope.encloses() MUST still be able
> >to compute that set as well
> Which ones? When adding a new API there's no need to take over anything unless
> there are good reasons/demands.

Hierarchy scopes created through the old API must contain members and
enclosings for performance sake (document based search). 
HierarchyScope.encloses() is used on all hierarchy scopes, not matter
through which API they are created.
According to bug 215196 there were differences between cached results
and actual search results, because encloses() did not fully comply 
with the spec. This is fixed.
All this is about the implementation in HierarchyScope.

Of course the new API is free to provide whatever functionality is
desired, but then documentation must be very clear about any difference
that is hidden/not represented by a parameter.
Comment 21 Stephan Herrmann CLA 2009-11-30 12:35:33 EST
(In reply to comment #15)
> > So, the correct fix for this is to have parameter that tells whether to 
> > include the focus type or not.
> 
> If there's sufficient demand for that parameter that should be easy to add.

Any votes from JDT/Core on this parameter?
Comment 22 Dani Megert CLA 2009-12-01 02:13:45 EST
>Any votes from JDT/Core on this parameter?
The parameter is needed unless you can explain a simple way how PDE can build their scope as they currently do.
Comment 23 Stephan Herrmann CLA 2009-12-04 17:34:03 EST
(In reply to comment #22)
> >Any votes from JDT/Core on this parameter?
> The parameter is needed unless you can explain a simple way how PDE can build
> their scope as they currently do.

Still: without a GO from a JDT/Core committer I can do nothing.
Comment 24 Olivier Thomann CLA 2009-12-04 18:10:05 EST
+1 for adding a parameter.
Comment 25 Dani Megert CLA 2009-12-05 04:30:54 EST
>Still: without a GO from a JDT/Core committer I can do nothing.
Stephan, I'm the overall JDT lead, so whatever I say counts ;-)
Comment 26 Stephan Herrmann CLA 2009-12-05 13:01:51 EST
Created attachment 153865 [details]
combined changes

This patch combines the removal of parameter 'noMemberTypes' with the
addition of a parameter 'includeFocusType'.

After adding and removing a boolean argument, we end up with the same
signature as before. 
I assume that consumers of this API currently call it with
'noMemberTypes=true', is that right?
When linking against the new API, 
where this 'true' now goes into the 'includeFocusType' parameter, 
this would mean that the behavior regarding the focus type will change. 
According to comment 14 this should be the desired behavior for the 80% case.
=> Is this semantic change acceptable at this point?
Otherwise a new method name might be necessary.
For bug 61185 (PDE/UI) I think excluding the focus type is more natural,
but that's a minor change.

(behavior regarding member types will not change in the above situation).

Thanks to the avoidance of non-ascii chars I could produce a sound
patch including the tests ;-)

I slightly adjusted Frederics 3 tests in JavaSearchBugsTest.
Also for 2 tests in JavaSearchTests I created a variant challenging
the new parameter, plus adjusted existing tests.
3 Tests became obsolete be removing 'noMemberTypes'. I only disabled those
(by '_' prefix), but you may want to remove those as well.
Comment 27 Stephan Herrmann CLA 2009-12-07 07:56:58 EST
(In reply to comment #26)
> [...]
> Otherwise a new method name might be necessary.

Given the different semantics of those factory methods, I'd actually
suggest to name the new API something like:
   createStrictHierarchyScope
where "strict" refers to the exclusion of members/enclosings.
Then we can also cleanly mark the previous version as deprecated etc.

Should I update the patch in this way?
Comment 28 Markus Keller CLA 2009-12-07 09:07:17 EST
(In reply to comment #27)
> suggest to name the new API something like:
>    createStrictHierarchyScope

That's a very good idea. I also felt uneasy about having overloaded versions of createHierarchyScope and just one of them has a slightly different behavior.

+1 from my side (but I'm not a JDT/Core committer).
Comment 29 Olivier Thomann CLA 2009-12-07 09:56:16 EST
+1 for me and I am a JDT Core committer :-)
Comment 30 Stephan Herrmann CLA 2009-12-07 12:08:10 EST
Created attachment 153938 [details]
updated patch: new method name

Voila!

* retain previous API and mark it as @deprecated
  - retain also some tests that can only be expressed with the previous API
* create new API as createStrictHierarchyScope
  - update tests to using the new API where appropriate
* map both APIs to one extended ctor in HierarchyScope
* slightly clarify the now internal flags regarding members & enclosings

And: thanks, I guess by now I know who's who in JDT ;-)
Comment 31 Dani Megert CLA 2009-12-10 05:31:02 EST
+1. I like that we use a new name.

>  - retain also some tests that can only be expressed with the previous API
They should be removed as we will remove the deprecated API that was introduced during 3.6.
Comment 32 Stephan Herrmann CLA 2010-01-12 16:12:22 EST
Anything keeping us from committing the patch (comment 30) and closing the bug?
Comment 33 Frederic Fusier CLA 2010-01-12 18:19:06 EST
(In reply to comment #32)
> Anything keeping us from committing the patch (comment 30) and closing the bug?

Just remove the API added in 3.6 instead of set as deprecated as Dani requested in comment 31. Also remove the static TESTS_PREFIX in JavaSearchBugTest (my fault as I let it in my initial patch...) and repost the patch, then I'll release it.

Many thanks for the good job Stephan (as usual) and for your patience! :-)
Comment 34 Stephan Herrmann CLA 2010-01-13 06:05:27 EST
(In reply to comment #33)
> Just remove the API added in 3.6 instead of set as deprecated as Dani requested
> in comment 31. 

I had understood that the old API should stay as deprecated for the
duration of one milestone to give clients sufficient time to adjust
(see comment 16 & comment 17).

If this understanding is wrong I will post an updated patch later today.
Comment 35 Dani Megert CLA 2010-01-13 06:23:21 EST
>I had understood that the old API should stay as deprecated for the
>duration of one milestone to give clients sufficient time to adjust
>(see comment 16 & comment 17).
Correct. In comment 31 I only asked to remove the tests that still reference that method. I would write in the deprecation comment that the method will get removed shortly before M5 and also send a note to the mailing list.
Comment 36 Stephan Herrmann CLA 2010-01-13 08:32:43 EST
(In reply to comment #35)
> I would write in the deprecation comment that the method will get
> removed shortly before M5

Really before M5? So, the deprecation mark will be visible for
less than 2 weeks, is that sufficient time?

> and also send a note to the mailing list.

No problem, which one do you mean? jdt-core-dev?
Comment 37 Dani Megert CLA 2010-01-13 08:58:27 EST
>Really before M5? So, the deprecation mark will be visible for
>less than 2 weeks, is that sufficient time?
I doubt that there's anyone using it outside the SDK. I would fix it in HEAD today and announce on the lists that this will be gone in the next I-build (and hence also M5). After all adopting the new method is quickly done.

>No problem, which one do you mean? jdt-core-dev?
No, that list is for jdt-core developers which aren't affected by the change. I would send it to eclipse-dev and cross-project-issues-dev.

I would start the message like this:

If you don't call JDT Core's SearchEngine.createHierarchyScope(...) method  you can disregard this message.
...

and mention that the remove method has been introduces during 3.6 and also tell how to replace the call.
Comment 38 Stephan Herrmann CLA 2010-01-13 10:56:53 EST
Created attachment 155994 [details]
patch v4

This patch removes tests that used the now deprecated method.

Removed the static TEST_PREFIX.

Also a comment was added mentioning that the deprecated method
will be removed shortly before M5.

While cleaning the tests I noticed other tests that also call
deprecated API, but did not touch those..

Mail will be sent shortly.
Comment 39 Frederic Fusier CLA 2010-01-13 12:04:58 EST
Comment on attachment 155994 [details]
patch v4

Patch looks good to me. It was not really necessary to depreciate the method in BasicSearchEngine as it is internal, but that's not a problem, we'll remove it at the same time than for SearchEngine...
Comment 40 Stephan Herrmann CLA 2010-01-13 12:10:48 EST
(In reply to comment #39)
> (From update of attachment 155994 [details])
> Patch looks good to me. It was not really necessary to depreciate the method in
> BasicSearchEngine as it is internal, but that's not a problem, we'll remove it
> at the same time than for SearchEngine...

Yes, and by marking it as deprecated it's easier to remember removing it ;-)

FYI: Mail has been sent to both lists as suggested by Dani.
Comment 41 Olivier Thomann CLA 2010-01-13 12:14:02 EST
Created attachment 156008 [details]
Same patch with copyright updates
Comment 42 Olivier Thomann CLA 2010-01-13 12:44:09 EST
Released for 3.6M5 on the behalf of Frédéric.
Comment 43 Dani Megert CLA 2010-01-14 03:40:14 EST
The new method does not work as expected and hence I cannot use it. The problem is that it does not find matches if I include the focus type but that type has no subtype:

public class A {
     void test() {
         A a= new A();
         a.toString();
     }
     @Override
     public String toString(){
         return "";
     }
 }

If I create a hierarchy scope for A including the focus type and subtypes only then it won't find A.toString() which is wrong. However, if I simply add
  class B extends A {}
to the example then it finds A.toString().

Please fix ASAP since we asked clients to adopt this new method.
Comment 44 Frederic Fusier CLA 2010-01-14 04:40:56 EST
(In reply to comment #40)
> (In reply to comment #39)
> > (From update of attachment 155994 [details] [details])
> > Patch looks good to me. It was not really necessary to depreciate the method in
> > BasicSearchEngine as it is internal, but that's not a problem, we'll remove it
> > at the same time than for SearchEngine...
> 
> Yes, and by marking it as deprecated it's easier to remember removing it ;-)
> 

My remark wasn't clear enough. I wanted to say that the BasicSearchEngine method could have been removed instead of being depreciated. Because it is in a internal class, no client is supposed to used it. Hence we do not have to give time to migrate on the correct method as we have to do for API method...
Comment 45 Stephan Herrmann CLA 2010-01-14 04:49:06 EST
Created attachment 156074 [details]
additional test

(In reply to comment #43)
> The new method does not work as expected and hence I cannot use it. The problem
> is that it does not find matches if I include the focus type but that type has
> no subtype:
> 
> public class A {
>      void test() {
>          A a= new A();
>          a.toString();
>      }
>      @Override
>      public String toString(){
>          return "";
>      }
>  }
> 
> If I create a hierarchy scope for A including the focus type and subtypes only
> then it won't find A.toString() which is wrong. However, if I simply add
>   class B extends A {}
> to the example then it finds A.toString().
> 
> Please fix ASAP since we asked clients to adopt this new method.

I cannot reproduce. The patch adds your example to the tests
and in my workspace it passes.
Comment 46 Stephan Herrmann CLA 2010-01-14 04:51:19 EST
(In reply to comment #44)
> My remark wasn't clear enough. I wanted to say that the BasicSearchEngine
> method could have been removed instead of being depreciated. Because it is in a
> internal class, no client is supposed to used it. Hence we do not have to give
> time to migrate on the correct method as we have to do for API method...

But the deprecated method in SearchEngine still uses the deprecated
method in BasicSearchEngine. I cannot remove the internal one
before removing the deprecated API. Am I missing something?
Comment 47 Dani Megert CLA 2010-01-14 04:56:59 EST
>I cannot reproduce. The patch adds your example to the tests
>and in my workspace it passes.
Maybe you do a different search. I can give you more details if your on Sametime.
Comment 48 Stephan Herrmann CLA 2010-01-14 05:02:20 EST
(In reply to comment #47)
> >I cannot reproduce. The patch adds your example to the tests
> >and in my workspace it passes.
> Maybe you do a different search. I can give you more details if your on
> Sametime.

If Sametime is some kind of platform, no. Never heard of.
How about email? ;-)

Have you looked at the test? What's different?
Comment 49 Frederic Fusier CLA 2010-01-14 05:05:18 EST
(In reply to comment #46)
> 
> But the deprecated method in SearchEngine still uses the deprecated
> method in BasicSearchEngine. I cannot remove the internal one
> before removing the deprecated API. Am I missing something?

The deprecated API can call the new BasicSearchEngine method and then you can remove the deprecated method on BasicSearchEngine. It should not heart anyone...
Comment 50 Dani Megert CLA 2010-01-14 05:10:15 EST
>If Sametime is some kind of platform, no. Never heard of.
>How about email? ;-)
My response was for Frédéric, who knows what Sametime is ;-)
FYI: it's a chat client.

I didn't look at the test but I suspect we perform the search a bit differently. Frédéric is looking at it.
Comment 51 Stephan Herrmann CLA 2010-01-14 05:16:28 EST
(In reply to comment #49)
> (In reply to comment #46)
> > 
> > But the deprecated method in SearchEngine still uses the deprecated
> > method in BasicSearchEngine. I cannot remove the internal one
> > before removing the deprecated API. Am I missing something?
> 
> The deprecated API can call the new BasicSearchEngine method and then you can
> remove the deprecated method on BasicSearchEngine. It should not heart
> anyone...

No ;-)
The deprecated API needs to passe the parameter noMemberTypes, which is 
not exposed by the new method in BasicSearchEngine.

Alternatively, the deprecated API could create the HierarchyScope
directly without using BasicSearchEngine, but why the hassle?
It'll all go by M5, right?
Comment 52 Frederic Fusier CLA 2010-01-14 06:27:10 EST
(In reply to comment #51)
> (In reply to comment #49)
> > (In reply to comment #46)
> > > 
> > > But the deprecated method in SearchEngine still uses the deprecated
> > > method in BasicSearchEngine. I cannot remove the internal one
> > > before removing the deprecated API. Am I missing something?
> > 
> > The deprecated API can call the new BasicSearchEngine method and then you can
> > remove the deprecated method on BasicSearchEngine. It should not heart
> > anyone...
> 
> No ;-)
> The deprecated API needs to passe the parameter noMemberTypes, which is 
> not exposed by the new method in BasicSearchEngine.
> 
That's right, I was puzzled with the boolean which does not have the same meaning for the two methods...

> Alternatively, the deprecated API could create the HierarchyScope
> directly without using BasicSearchEngine, but why the hassle?
> It'll all go by M5, right?

Sure... :-)
Comment 53 Frederic Fusier CLA 2010-01-14 06:28:25 EST
(In reply to comment #50)
> >If Sametime is some kind of platform, no. Never heard of.
> >How about email? ;-)
> My response was for Frédéric, who knows what Sametime is ;-)
> FYI: it's a chat client.
> 
> I didn't look at the test but I suspect we perform the search a bit
> differently. Frédéric is looking at it.

Yes, I'm reproducing the Dani's problem. So, I'm currently trying to writing a test to highlight it...
Comment 54 Frederic Fusier CLA 2010-01-14 06:58:02 EST
Created attachment 156084 [details]
Additional test highlighting the problem described by Dani

The difference is when using compilation unit instead of working copy. The hierarchy scope encloses(String) method does not return true for the A.java file, hence the index returns no match and the search request fails...

It sounds to be a problem in the HierarchyScope.buildResourceVector method which does not add any elements if there is no subtypes.

Perhaps the test this.subTypes == null should also test whether the array is empty or the focus type should be explicitely added to the elements when the flag includeFocusType is true...
Comment 55 Frederic Fusier CLA 2010-01-14 07:37:53 EST
Created attachment 156088 [details]
Additional test highlighting the problem described by Dani

New patch fixing the expected search results...
Comment 56 Stephan Herrmann CLA 2010-01-14 08:28:52 EST
Created attachment 156091 [details]
proposed fix re comment 54

(In reply to comment #54)
> Created an attachment (id=156084) [details]
> Additional test highlighting the problem described by Dani

I see.
 
> The difference is when using compilation unit instead of working copy. The
> hierarchy scope encloses(String) method does not return true for the A.java
> file, hence the index returns no match and the search request fails...
> 
> It sounds to be a problem in the HierarchyScope.buildResourceVector method
> which does not add any elements if there is no subtypes.
> 
> Perhaps the test this.subTypes == null should also test whether the array is
> empty or the focus type should be explicitely added to the elements when the
> flag includeFocusType is true...

Sounds like it. I propose this patch which adds the focus type right after
calling this.hierarchy.getAllSubtypes(this.focusType), which reflects the
asymmetry between getAllSubTypes() and getAllTypes(): the latter includes
the focus type, the former excludes it.

I also added a test similar to yours but using the old API.
Comment 57 Stephan Herrmann CLA 2010-01-14 09:12:05 EST
Created attachment 156098 [details]
same patch - one more test

I added one more test as a variation of testBug295894c3():
By placing A and B in different files the test fails (without the patch
in HierarchyScope) even though A has a subtype.

I must admit that the includeFocusType flag wasn't evaluated when
searching for resources (using the path) rather than types. 
The proposed patch fixes this. (Same patch as before).
Comment 58 Frederic Fusier CLA 2010-01-14 09:22:23 EST
Comment on attachment 156098 [details]
same patch - one more test

Looks good. I also verified that with this fix, the JDT/UI test case works well :-)
Comment 59 Frederic Fusier CLA 2010-01-14 09:24:31 EST
(In reply to comment #57)
> Created an attachment (id=156098) [details]
> same patch - one more test
> 
Released for 3.6M5 in HEAD stream.
Comment 60 Dani Megert CLA 2010-01-15 03:14:08 EST
Thanks Stephan and Frédéric, works now.
Comment 61 Satyam Kandula CLA 2010-01-25 04:43:47 EST
Verified for 3.6M5 using Build id: I20100122-0800
Comment 62 Srikanth Sankaran CLA 2010-01-25 05:23:53 EST
Verified.
Comment 63 Stephan Herrmann CLA 2010-03-12 18:01:08 EST
(In reply to comment #37)
> I doubt that there's anyone using it outside the SDK. I would fix it in HEAD
> today and announce on the lists that this will be gone in the next I-build (and
> hence also M5). After all adopting the new method is quickly done.

Did we just miss the last train home (due to API freeze)?
Or can we still remove the deprecated method for Helios?

Note, that the PDE/UI usage of the deprecated method has been fixed
in bug 304157 (builds > 20100303).
Comment 64 Olivier Thomann CLA 2010-03-12 18:04:48 EST
(In reply to comment #63)
> Did we just miss the last train home (due to API freeze)?
> Or can we still remove the deprecated method for Helios?
With PMC approval, it is always possible to have API change post API freeze. This is why the API freeze check has an exclusion list to remove "approved" API changes post API freeze.
Comment 65 Olivier Thomann CLA 2010-03-12 18:08:39 EST
I completely forgot this case.
Comment 66 Stephan Herrmann CLA 2010-03-12 18:22:08 EST
(In reply to comment #65)
> I completely forgot this case.

Me too, until I read Chris' blog post on API freeze today.
Comment 67 Olivier Thomann CLA 2010-03-12 19:29:26 EST
(In reply to comment #66)
> (In reply to comment #65)
> > I completely forgot this case.
> 
> Me too, until I read Chris' blog post on API freeze today.
I opened bug 305755 to take care of this.