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

Summary: Navigation should allow going to implementation of interface rather then interface
Product: java Reporter: dmocek <dmocek>
Component: NavigationAssignee: Jan Jancura <jjancura>
Status: RESOLVED DUPLICATE    
Severity: blocker    
Priority: P3    
Version: 3.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

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 ***