Bug 73401 - [search] Unable to search just for references to overridden method
Summary: [search] Unable to search just for references to overridden method
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 enhancement with 2 votes (vote)
Target Milestone: 3.3 M2   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
: 85347 105768 108219 116208 116295 121016 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-07 15:50 EDT by Randy Hudson CLA
Modified: 2007-03-14 11:58 EDT (History)
11 users (show)

See Also:


Attachments
Proposed patch (25.72 KB, patch)
2006-09-14 13:10 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Hudson CLA 2004-09-07 15:50:55 EDT
I have a class Obstacles extends Rectangle, which overrides containsPoint(int, 
int). I would like to search to references to this method. When I search, I get 
all references to Rectangle#containsPoint(int, int) instead.

How can I make this search? Which method is the bytecode calling?
Comment 1 Philipe Mulet CLA 2004-09-08 03:45:17 EDT
We do a polymorphic search since there could be variables of type Rectangle 
actually valued to instances of Obstacles, e.g.:
  Rectangle r = new Obstacles(...);
  r.containsPoint(...)

However, this should not result in looking for senders of 
Rectangle.containsPoint, as it should eliminate matches to other subtypes of 
Rectangle (i.e. not in the branch of Obstacles).

Ok to close?


Comment 2 Randy Hudson CLA 2004-09-08 10:35:58 EDT
I don't want to close because I am unable to do what I need.  What is the 
generated bytecode for:

Obstacle o = new Obstacle(x, y, w, h);
o.containsPoint(point);

??

Is it a call to Obstacle#containsPoint(), or Rectangle#containsPoint(..)?  I 
want to search for all places where the compiled bytecode refers to 
Obstacle#containsPoint(..), and this isn't possible.

The polymorphism makes sense usually, but in my specific case Obstacle is never 
cast to or referred to as a Rectangle.  It is simply for convenience that it 
inherits some of the utility method on Rectangle.  BTW, is there a way to 
search for casting of a type to its supertype??
Comment 3 Frederic Fusier CLA 2004-10-28 07:42:15 EDT
I agree this polymorphic search is sometimes annoying when you're sure that you
do not want it!
I guess we can think about a new option in search to activate it or not, I'll
put this in my list...
About search for a cast, it's not possible for now, but bug 73205 addresses this
request.
Comment 4 Frederic Fusier CLA 2005-03-14 15:11:42 EST
Unfortunately, I'll not have enough time to add this option...
Defer post 3.1
Comment 5 Frederic Fusier CLA 2005-08-05 03:55:24 EDT
Reopen for 3.2
Comment 6 Frederic Fusier CLA 2005-08-05 03:56:24 EDT
*** Bug 85347 has been marked as a duplicate of this bug. ***
Comment 7 Frederic Fusier CLA 2005-08-05 03:56:49 EDT
*** Bug 105768 has been marked as a duplicate of this bug. ***
Comment 8 Dan Berindei CLA 2005-09-22 07:04:15 EDT
The polymorphic search is very annoying when searching with wildcards. 

For instance searching for references to SomeClass.get* will find all the
references to Object.getClass() - when all I want is references to the getters
defined in SomeClass.
Comment 9 Max Gilead CLA 2005-11-07 05:28:17 EST
Is there any change it'll get fixed soon? It's so very problematic when I want
to find references or declarations of a method which I know should be found in
three or four places in a project but instead get hundreds of hits from packages
like com.ibm.icu or com.sun.corba and all irrelevant places from all over the
project. :/
Comment 10 Frederic Fusier CLA 2005-11-14 06:07:28 EST
*** Bug 116208 has been marked as a duplicate of this bug. ***
Comment 11 Frederic Fusier CLA 2006-01-09 05:54:45 EST
*** Bug 121016 has been marked as a duplicate of this bug. ***
Comment 12 Frederic Fusier CLA 2006-03-31 05:56:26 EST
*** Bug 108219 has been marked as a duplicate of this bug. ***
Comment 13 Frederic Fusier CLA 2006-04-11 03:37:14 EDT
Unfortunately, this new option was missed for 3.2 and needs to be deferred again.
I've tagged it 3.3 + [API] to avoid doing this error twice.
Sorry for the delay...
Comment 14 Frederic Fusier CLA 2006-09-07 10:24:04 EDT
Reopen as the pressure get more and more important on this problem (see bug 156941 comment 2)...
Comment 15 Frederic Fusier CLA 2006-09-07 10:28:07 EDT
I'd rather prefer a new flavor on SearchMatch to allow user to filter polymorphic matches than a specific pattern. Having a specific pattern would not save too much time as the filter could only be applied while resolving possible matches (ie. just before creating SearchMatch to report it).
Comment 16 Markus Keller CLA 2006-09-07 12:45:46 EDT
A flag on SearchMatch sounds good. JDT/UI can then easily add a filter for polymorphic matches to the search result view. BWT: comment 14 meant bug 156491.

Will the 'polymorphic' flag be set for matches deeper down in the hierarchy as well? I.e. if I expand comment 0 and add a class MyObstacles that extends Obstacles and overrides containsPoint(int, int) again, will calls to myObstacle.containsPoint(..) be considered polymorphic or not? Or do we even need 2 flags here?
Comment 17 Frederic Fusier CLA 2006-09-13 11:37:27 EDT
(In reply to comment #16)
> A flag on SearchMatch sounds good. JDT/UI can then easily add a filter for
> polymorphic matches to the search result view. BWT: comment 14 meant bug
> 156491.
Ooops, thanks
> 
> Will the 'polymorphic' flag be set for matches deeper down in the hierarchy as
> well? I.e. if I expand comment 0 and add a class MyObstacles that extends
> Obstacles and overrides containsPoint(int, int) again, will calls to
> myObstacle.containsPoint(..) be considered polymorphic or not? Or do we even
> need 2 flags here?
> 
In patch I provided in bug 156491 comment 9, these kind of matches are not flagged as polymorphic. However, it's not a big deal to do it. The only remaining questions are: is it really necessary and f so, is it important to distinguish if the polymorphism comes from superclasses or subclasses...???

I can't see any use cases where it could be necessary but I'm sure you have something in mind, haven't you?
Comment 18 Frederic Fusier CLA 2006-09-14 13:10:36 EDT
Created attachment 50171 [details]
Proposed patch

This patch include also fix for bug 156491.
Note that JDT/UI needs to implements corresponding filter in Search View to have this issue completely fixed...
Comment 19 Frederic Fusier CLA 2006-09-14 13:11:51 EDT
JDT/Core patch released for 3.3 M2 in HEAD stream.
Wait for JDT/UI input to set this bug as fixed...
Comment 20 Markus Keller CLA 2006-09-14 13:53:31 EDT
I've released a filter for polymorphic matches to the Java search result page. The filter is enabled automatically in new workspace.

Re comment 17: Methods declared in subtypes as well as methods declared in supertypes are polymorphic matches now. Just 1 flag for all.
Comment 21 David Audel CLA 2006-09-18 09:28:28 EDT
Verified for 3.3 M2 using build I20060918-0010.
Comment 22 Dani Megert CLA 2006-11-01 10:11:20 EST
>The filter is enabled automatically in new workspace.
This is is no longer true. See bug 157814 for details.
Comment 23 Markus Keller CLA 2007-03-14 11:58:22 EDT
*** Bug 116295 has been marked as a duplicate of this bug. ***