How does "Open Declaration" work? [message #1017987] |
Tue, 12 March 2013 19:02  |
Eclipse User |
|
|
|
So I'm interested in learning more about how the "Open Declaration" and Declaration View work.
I've tried searching the eclipse git repository but I didn't manage to find the source for either of these tools.
Does anyone know where I would find the source? A high-level overview of their implementation would also be useful.
Thanks!
|
|
|
Re: How does "Open Declaration" work? [message #1018792 is a reply to message #1017987] |
Thu, 14 March 2013 09:31  |
Eclipse User |
|
|
|
Hi,
You can find the source code of the Java Development Tools for Eclipse on github:
* https://github.com/eclipse/eclipse.jdt.core
* https://github.com/eclipse/eclipse.jdt.ui
* https://github.com/eclipse/jdt
* https://github.com/eclipse/eclipse.jdt
* https://github.com/eclipse/eclipse.jdt.debug
What you are looking for is the class OpenAction. By the way, if you want to known how something is done in Eclipse, go in the Window -> Preferences menu select Plug-in Development and include all plug-ins from target in Java search. After that use Alt+Shift+F1 to see the Java class responsible for the currently selected view, editor or wizard and Alt+Shift+F2 (and then click on a button or anything else) to see which Java class is responsible for the clicked element.
How is it working? To make it short, the JDT is storing the structure of all your Java source code in the metadata of your workspace. Each time you are changing something, this index is updated. When you are asking for a reference (search references, call hierarchy, open declaration, refactoring, etc...) this index is used. This is why the JDT is so quick. You can have a look at the builder of the JDT to see how this index is done.
Regards,
Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Google+: +stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com | Eclipse Java Development Tools Tips and Tricks
|
|
|
Powered by
FUDForum. Page generated in 0.02528 seconds