Tag Archives: open implementation

Eclipse Tips: Open Implementation

Eclipse Helios has another subtle enhancement to the JDT. It is called as Open Implementation. So what’s that? Before we play around with the feature, let’s create some classes.

interface IProcessor {
	void process();
}
public class Processor1 implements IProcessor {

	@Override
	public void process() {
		// TODO Auto-generated method stub
	}

}
public class Processor2 implements IProcessor {

	@Override
	public void process() {
	}

}
public class Main {

	public static void main(String[] args) {
		new Processor1().process();
	}

	public static void a(IProcessor p) {
		p.process();
	}
}

Before Open Implementation is implemented, we have only Open Declaration with F3 as default keybinding. Try this on Eclipse before Helios. Put your text cursor on method process on statement p.process(); in class Main. Click F3. You’ll be brought to the process method in IProcessor.

But what we need often is not the declaration, we need the implementation of the method. Before Helios, what I do is to go the declaration, click Ctrl+T and pick the implementation I want.

Helios shortens this. Put your text cursor again on the method and click menu Navigate → Open Implementation. Now if you have more than one implementation of the method, you will get choice to pick which implementation to open.

By defining a keybinding on Preferences → General → Keys you can even use the feature easier, but before you do that, see if this shortcut is fast enough for you.

Click Ctrl and hold it. Now move your mouse over the same method. Tadam… you will get choice.

If you pick Open Implementation you’ll get the same choice as before.

So that’s it. Hopefully this tips helps you a lot.