Bug 64319 - [type hierarchy] [search] should be able to find interface methods implemented by inheritance
Summary: [type hierarchy] [search] should be able to find interface methods implemente...
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 67012 112917 228541 268763 270231 328488 413285 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-05-27 09:20 EDT by Ilja Preuss CLA
Modified: 2013-11-27 01:35 EST (History)
12 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilja Preuss CLA 2004-05-27 09:20:55 EDT
consider the following classes:

public interface IBarable {
  public void bar();
}

public class Foo {
  public void bar() {}
}

public class SubFoo extends Foo implements IBarable {
}

When trying to find all implementations of IBarable#bar, Eclipse doesn't notice 
that SubFoo implements it by inheriting it from Foo.

I notice that this is somewhat questionable style anyway, but when working with 
legacy code, it can be fundamentally important to understand the code.

It would be nice, for example, if the type hierarchy (using ctrl-t on the 
method declaration in the interface) could show SubFoo implementing the method, 
somehow indicating that it does inherit it (perhaps by showing it in a 
different color, using the override indicator or something).
Comment 1 Ilja Preuss CLA 2004-05-27 09:28:13 EDT
Similarly, finding references doesn't work on the implementation in Foo:

public class Test {
  public void test() {
    IBarable barable = new SubFoo();
    barable.bar();
  }
}

Using ctrl-shift-g on Foo#bar doesn't find the reference in Test#test (which it 
does when foo directly implements IBarable).
Comment 2 Dirk Baeumer CLA 2004-05-27 10:41:04 EDT
Parts of this has to be provided by the search engine. CC JDT/Core.

Comment 3 Martin Aeschlimann CLA 2006-06-12 17:54:44 EDT
Implementing and inherting are two diffenert things. So, IMO, you can't say that SubFoo 'implements' bar.

The type hierarchy has the option to show all inherited members. 

The problem with the code example in comment 1 is that barable is of declared type IBarable. Searching for references of Foo:bar should match references to IBarable:bar. It should match for SubFoo:bar, but that's not the case here.

Maybe I misunderstood your request. Setting to remind as I don't know what we could improve here.
Comment 4 Ilja Preuss CLA 2006-06-13 02:06:24 EDT
(In reply to comment #3)
> Implementing and inherting are two diffenert things. So, IMO, you can't say
> that SubFoo 'implements' bar.

It's probably sloppy terminology, yes. I think you understood me nevertheless... ;)

> The type hierarchy has the option to show all inherited members. 

I don't see how that helps me with my problem.

Imagine that I want to change the method signature of IBarable.bar(). As far as I can tell, there is currently nothing in Eclipse that helps me find out that Foo.bar() might be affected, other than possibly a compile time error.
Comment 5 Frederic Fusier CLA 2006-06-13 04:35:07 EDT
(In reply to comment #4)
> > The type hierarchy has the option to show all inherited members. 
> 
> I don't see how that helps me with my problem.
> 
> Imagine that I want to change the method signature of IBarable.bar(). As far as
> I can tell, there is currently nothing in Eclipse that helps me find out that
> Foo.bar() might be affected, other than possibly a compile time error.
> 
That's wrong, with your example, if you rename bar() method from Foo class, then you are informed that this method implements an interface and you're asked if you want to perform the rename from the interface IBarable instead... Then 'barable.bar()' will be also renamed as it has been declared as an IBarable object...
Comment 6 Frederic Fusier CLA 2006-06-13 04:38:27 EDT
(In reply to comment #1)
> Similarly, finding references doesn't work on the implementation in Foo:
> 
> public class Test {
>   public void test() {
>     IBarable barable = new SubFoo();
>     barable.bar();
>   }
> }
> 
> Using ctrl-shift-g on Foo#bar doesn't find the reference in Test#test (which it 
> does when foo directly implements IBarable).


Unfortunately there's nothing Search Engine currently can do about this kind of search request. As said Martin, 'barable' is declared as 'IBarable' and so, as S.E. uses declarations while searching for fields/methods/types, it cannot get 'barable.bar()' as a reference match for 'Foo.bar()' pattern.

This is a similar problem than following test case:
class Foo {
  void foo(Object obj) {}
  void bar() {
    foo("hello");
  }
}
Although the call 'foo("hello")', Search Engine does not find any reference to 'foo(String)' method pattern. Even with a String parameter, method declaration is still 'foo(Object)' and it obviously does not match this pattern...

Comment 7 Denis Roy CLA 2009-08-30 02:08:30 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.
Comment 8 Markus Keller CLA 2010-10-22 14:36:50 EDT
*** Bug 328488 has been marked as a duplicate of this bug. ***
Comment 9 x y CLA 2010-10-24 09:20:23 EDT
This request is still valid for me, but I don't have permission to reopen it. Please reopen it.
Comment 10 Markus Keller CLA 2010-10-26 06:34:37 EDT
We have no plans to show inherited implementations from side branches in the type hierarchy. For one, they don't belong there technically, and secondly, this would be too expensive to compute in the general case (see also
bug 328488 comment 1). Setting this bug to WONTFIX.

As a remedy, we could add a Clean Up that adds explicit implementations of "joiner" methods where they are missing. For the example in comment 0, it would add this to SubFoo:

  public void bar() {
    super.bar();
  }

If you think that would be useful, please file a new enhancement request.
Comment 11 Markus Keller CLA 2010-10-26 14:45:30 EDT
(In reply to comment #10)
> If you think that would be useful, please file a new enhancement request.

I just hit such a case myself and filed bug 328760 to request this Clean Up. The problems I had there were actually not in the type hierarchy but in the search engine (comment 1).
Comment 12 Markus Keller CLA 2013-07-22 10:55:23 EDT
*** Bug 67012 has been marked as a duplicate of this bug. ***
Comment 13 Markus Keller CLA 2013-07-22 10:57:09 EDT
*** Bug 413285 has been marked as a duplicate of this bug. ***
Comment 14 Dani Megert CLA 2013-07-23 04:51:01 EDT
*** Bug 112917 has been marked as a duplicate of this bug. ***
Comment 15 Dani Megert CLA 2013-07-23 04:51:07 EDT
*** Bug 228541 has been marked as a duplicate of this bug. ***
Comment 16 Dani Megert CLA 2013-07-23 04:51:19 EDT
*** Bug 268763 has been marked as a duplicate of this bug. ***
Comment 17 Noopur Gupta CLA 2013-11-27 01:35:40 EST
*** Bug 270231 has been marked as a duplicate of this bug. ***