This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 104311 - Navigation should allow going to implementation of interface rather then interface
Summary: Navigation should allow going to implementation of interface rather then inte...
Status: RESOLVED DUPLICATE of bug 142112
Alias: None
Product: java
Classification: Unclassified
Component: Navigation (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Jan Jancura
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-18 19:52 UTC by dmocek
Modified: 2010-08-20 15:11 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dmocek 2007-05-18 19:52:38 UTC
Let's say I have a class (class MyClass) which calls a method on a class (class
Doberman) which implements an interface (interface Dog), and the method is
defined in the interface (interface Dog).  If I go to the line in class MyClass
where I call myDog.bark() and I 'Go To Source | Declaration', I get taken to the
Dog interface's bark method.  There should be a way to go to the Doberman
implementation's bark method (e.g. Go To Implementation).  NB can figure out
that myDog is an implementation of Doberman and take me to the implementation's
bark method.  This is almost alway what I want to do...rather then go to the
interface's bark method.  The same can be said for classes that extend abstract
classes.

public class MyClass {
   public static void main(String[] args) {
      Dog myDog = new Doberman();
      myDog.bark();
   }
}

public interface Dog {
   public void bark();
}

public class Doberman implements Dog {
   public void bark() {
      System.out.println("ruff");
   }
}
Comment 1 Vitezslav Stejskal 2007-05-21 02:01:01 UTC
> NB can figure out that myDog is an implementation of Doberman ...

In general this is quite tricky to do. It may look simple in your example, but
how about code like this one:

Dog myDog = Lookup.getDefault().lookup(Dog.class);

There is no way how the IDE could guess what the lookup call would return. The
only thing you can do is to find all implementations of the Dog interface
visible in the scope of this statement and give a user chance to choose one.
Comment 2 malfunction84 2010-08-20 15:11:28 UTC
There are several "go to implementation" issues.  I'm trying to clean them up.

Listing all implementations when you Ctrl+click a method name is covered by bug 142112.

For reference purposes, if the Debugger is running and myDog is in the current scope, NetBeans *would* know that it was an implementation of Doberman and could navigate to the correct implementation when you Ctrl+click.

*** This bug has been marked as a duplicate of bug 142112 ***