Version 3.3
Copyright © 2009, 2010, 2011, 2012 Lars Vogel
01.08.2012
| Revision History | |||
|---|---|---|---|
| Revision 0.1 - 0.6 | 23.05.2008 | Lars Vogel |
Created Article |
| Revision 0.7 - 3.3 | 18.02.2009 - 01.08.2012 | Lars Vogel |
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.
Especially if you develop Eclipse Plugins or Eclipse RCP application looking at the Eclipse Source code is useful.
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 plugins you would like to import and press "Finish".

You can you investigate the code of the imported plugins.
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 Eclipse Java tools only consider Java components, e.g. classes or interfaces, from the standard Java libraries and from the projects and their dependencies in the workspace as relevant for search operations.
For example the
Ctrl+Shift+T
(Open Type) shortcut will not
find the
ISources
interface if it is
not referred to in the current workspace.
You can add all classes from the current target platform, e.g. default is the Eclipse IDE, to be relevant for the Eclipse search via the following setting: → → →

Eclipse consists out of components called plug-ins.
You frequently
have to find the plug-in which contains a certain class.
After making
the
Include all plug-ins from target into Java Search
setting
in the Eclipse preferences you can use the
Open Type
dialog to find the plug-in for a class. The
jar
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
point.
Definition and usage of an extension point use different
icons.
For
example to see which plug-in defines the
org.eclipse.menu.ui
extension point,
enter it in the dialog and select the entry
with the
blue icon.

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 keybinding. 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.

Eclipse projects primarily use Git.The following section describes the usage of Git.
The usage and background of Git is not described in this tutorial. Please see EGit Tutorial for details on how to use the EGit plug-in for Eclipse or see Git Tutorial to learn how to use Git from the command line.
The main Git repository be accessed to the via the Eclipse source code repository. You find links to all Eclipse Git repositories on this page.
To clone a project you check the webpage. For example if you
want to
clone the project
Tycho
you see on the webpage that the name
is
tycho
and the repository is called
org.eclipse.tycho.git. You can
clone this repo via the following command.
git clone git://git.eclipse.org/gitroot/tycho/org.eclipse.tycho.git
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.
Before posting questions, please see the vogella FAQ. If you have questions or find an error in this article please use the www.vogella.com Google Group. I have created a short list how to create good questions which might also help you.
vogella Training Android and Eclipse Training from the vogella team
Android Tutorial Introduction to Android Programming
GWT Tutorial Program in Java and compile to JavaScript and HTML
Eclipse RCP Tutorial Create native applications in Java
JUnit Tutorial Test your application
Git Tutorial Put everything you have under distributed version control system