Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326656

Summary: F3 (Open Declaration) should navigate to method declaration in the interface
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, markus.kell.r, remy.suen
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Deepak Azad CLA 2010-09-30 06:38:16 EDT
- Select A.foo() in the following snippet
- Press 'F3' (Open declaration) => nothing happens
Shouldn't the action navigate to the method declaration in the interface ?

package p;
interface IA {
	void foo();
}
class A implements IA{
	public void /*]*/foo/*[*/() {		
	}
}
Comment 1 Dani Megert CLA 2010-09-30 08:39:32 EDT
foo() is the closest declaration here. Of course one could also argue for the other approach but that's how it's done since 2.0. No plans to change that now.
Comment 2 Deepak Azad CLA 2010-09-30 09:13:41 EDT
(In reply to comment #1)
> foo() is the closest declaration here. 
I thought IA#foo() is the declaration and A#foo() is the implementation, no?

To be specific about what I am looking for...
- select 'foo' at '1' (or '2') > Press F3 => you reach 'X' (or 'Y'). 
I am ok with this behavior
- select 'foo' at 'X' (or 'Y') > Press F3 => I expect to reach the interface

package p;
interface IA {
    void foo();
}
class A implements IA{
    public void /*]*/foo/*[*/() {	//X      
    }    
    void bar() {
    	foo();	//1
    }
}

class B extends A{	
    public void /*]*/foo/*[*/() {	//Y   
    }    
    void bar() {
    	foo();	//2
    }
}

Or is there another *easy* way to navigate to the Interface?
Comment 3 Remy Suen CLA 2010-09-30 09:25:07 EDT
(In reply to comment #2)
> Or is there another *easy* way to navigate to the Interface?

I like to use Ctrl+T (or double Ctrl+T) myself, Deepak.
Comment 4 Dani Megert CLA 2010-09-30 09:28:18 EDT
Well, as soon as you write "public void foo()" then that is a method declaration ;-).

>Or is there another *easy* way to navigate to the Interface?
Click on the triangle on the left.

Also note that when you call foo() on a variable which is declared of type IA, then you will end up in the interface.
Comment 5 Deepak Azad CLA 2010-09-30 10:13:54 EDT
(In reply to comment #1)
> Of course one could also argue for the other approach 
hmm... I still think Open (F3) on a method declaration (public void foo) should navigate to the interface, instead of doing nothing.

(In reply to comment #4)
> Click on the triangle on the left.
The triangle just takes you one level up in the hierarchy, not directly to the interface.

(In reply to comment #3)
> I like to use Ctrl+T (or double Ctrl+T) myself, Deepak.
This is at least 4 keystrokes but I guess it is the best way right now.
Comment 6 Markus Keller CLA 2010-10-06 13:23:57 EDT
"declaration" in this context means the source location where the selected Java element is declared, not the declaration in terms of the Java language model (so I agree there's nothing to change here, since we shouldn't mix multiple meanings into one command).

In my workspaces, "Navigate > Open Super Implementation" is bound to Shift+F3.