Copyright © 2009, 2010, 2011, 2012, 2013 Lars Vogel
|Revision 0.1 - 0.6||23.05.2008||Lars
|Revision 0.7 - 3.4||18.02.2009 - 15.07.2013||Lars
|bugfixes and enhancements|
Table of Contents
Developers are frequently advised to read high-quality code. Eclipse is a powerful, extensible IDE for building general purpose applications. Some of the key player in creating Eclipse are also well known for their software architecture skills. By reading the Eclipse source code you can learn a lot. It also helps to understand the Eclipse source code to address certain problems.
The following describes how you can import Eclipse plugins from your Eclipse installation to review the code. The Eclipse standard distribution contains the source code for the core Eclipse projects, e.g. Eclipse JDT. For other Eclipse projects you usually find a "SDK" bundle on the project update site which contains the source code.
To avoid "pollution" of your existing workspace, switch to a new workspace and select File -> Import. Select "Plug-ins and Fragments".
Make the following settings. Select "Binary projects". In Binary project you can read the source code but you cannot change it. They will also not be compiled therefore this setting will save memory and performance.
Add all plug-ins you would like to import and press "Finish".
You can you investigate the code of the imported plug-ins.
The Plugin Spy gives you easily information about the running UI. Press Alt+Shift+F1 to get information about the current running Eclipse plug-in / data types / screen. This way you can get immediately access to the plug-in which is currently running.
Click on the active class or the contributing plug-in to get to the class or the source code of the class.
Press "Alt + Shift + F2" and select a menu to see who is contributing this menu.
SWT spy for Eclipse is a tool that prints out information about the widget under the cursor. Currently, this includes style, layout and parent information. See SWT Tools for more information.
By default the Java tools of the Eclipse IDE consider only Java components, e.g. classes or interfaces, from the standard Java libraries and from projects and their dependencies in the workspace as relevant for search operations.
For example, the
(Open Type) shortcut will not
interface if it is
not referred to in the current workspace. As
developer you want to have access to all classes in your
The target platform is the set of plug-ins against which you develop. The default is the Eclipse IDE installation.
have to find the plug-in / bundle for a given class. The
IDE makes it easy to find the plug-in for a class.
Include all plug-ins from target into Java Search
in the Eclipse IDE preferences you can use the
dialog (Ctrl+Shift+T) to find the plug-in for a class. The
file is shown in this dialog and the prefix of the JAR file is
typically the plug-in which contains this class.
Use the shortcut "Ctrl+Shift+A" to search for an extension
Definition and usage of an extension point use different
example to see which plug-in defines the
enter it in the dialog and select the entry
Plug-in Search allows you to perform a detailed search for extension points. Select the menu "Search" -> "Search" and the tab "Plug-in Search". The following will search for all declaration (defining an extension) to the extension point "org.eclipse.debug.core.launchConfigurationTypes".
Eclipse allows to trace a running Eclipse and to write information to the console. This can be used to identify which command is associated with a certain key binding. To use tracing modify your runtime configuration on the "Tracing" tab and set "Enable Tracing". For trace for example the keybindings of "org.eclipse.ui" plug-in select it and flag "debug".
Scroll down and select "trace/keybindings" and "trace/keybindings.verbose".
Make sure you have the -consoleLog flag maintained as an argument.
If you start now the Eclipse IDE and you use a shortcut the calling Eclipse will display a trace which contains the commandId.
In your calling Eclipse you can now use Search (text) to find the handler / action which implements this command.
You can also debug the Eclipse IDE if you want to see how certain things are done. Use for example the Plugin Spy to find the class / plug-in which you would like to invest. Put a breakpoint into the coding, for example in the constructor of the class or if the class shows UI elements "createPartControl". Create a Run Configuration which includes all Eclipse IDE plugins and run it.
If you now select Run -> Debug for your runtime configuration you can start debugging the interesting point.
If you want to modify standard Eclipse plug-ins you can use Feature Patch Projects. A Feature Patch Project can contain plug-ins which replaces existing plug-ins. This would allow you to create update site for this feature and users can use your version of the modified code.
A feature project can get created via→ → → → .
In this dialog select the feature which you want to patch. Add every modified plug-in to your new Feature Patch Projects and export is as p2 update site.
Every feature can only be patched once.
Maintaining high quality free online tutorials is a lot of work. Please support free tutorials by donating or by reporting typos and factual errors.
If you find errors in this tutorial, please notify me (see the top of the page). Please note that due to the high volume of feedback I receive, I cannot answer questions to your implementation. Ensure you have read the vogella FAQ as I don't respond to questions already answered there.
vogella Training Android and Eclipse Training from the vogella team
Android Tutorial Introduction to Android Programming
Eclipse RCP Tutorial Create native applications in Java
JUnit Tutorial Test your application
Git Tutorial Put all your files in a distributed version control system