Version 3.2
Copyright © 2009, 2010, 2011, 2012 Lars Vogel
17.01.2012
| Revision History | ||
|---|---|---|
| Revision 0.1 - 0.6 | 23.05.2008 | Lars Vogel |
| Created Article | ||
| Revision 0.7 - 3.2 | 18.02.2009 - 17.01.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 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 side 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 plugin / data types / screen. This way you can get immediately access to the plugin which is currently running.

Click on the active class or the contributing plugin 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.
Per default the Java search in Eclipse will only search classes from the projects and their dependencies in the workspace. You can add all classes from the current target platfrom to the Java search via the following setting: → → → → →

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 plugin defines the
org.eclipse.menu.ui
extension point
enter it in the dialog and select the entry
with the
blue icon.

Plugin 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".

Use the tab "Java Search" to search for Java elements, e.g. methods. To include all plugins from your target platform into the Java Search select the option "Include all plug-ins from target into Java Search" under the menu entry Windows-> Preferences ->"Plug-in Development".


The search show all references. You can double-click on a search entry to navigate to the coding.

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" plugin 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 / plugin 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 can mainly use Git. Some projects still use cvs or svn. The following will describe cvs and Git access.
The Eclipse project is currently moving all projects to Git, the majority has already migrated. The main URL for Git access is http://git.eclipse.org
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 "org.eclipse.tycho.git". You can clone this repo via. You can alway to add the prefix "gitroot".
git clone git://git.eclipse.org/gitroot/tycho/org.eclipse.tycho.git
Please see EGit Tutorial for details on how to use the EGit plugin for Eclipse or see Git Tutorial to learn how to use Git from the command line.
The projects which are still using cvs are mirrored in http://dev.eclipse.org/git/
.
To access the Eclipse CVS repositories open the "CVS
Repositories"
View
via
→ → → →
Create a new entry in the
View
by right clicking and selecting
→

Copy the following string and paste it into the CVS view to create a new repository. You can validate the properties via right-mouse click on the repository entry and select "Properties".
:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse

Now can you browse the structure and check out code. Check out will create a local copy of the selected path into your workspace.

All known Eclipse bugs and feature requests are stored in a Bugzilla database Eclipse Bugs
The following explains how you could use Mylyn to work on Bugs and store your content in the bugreport.
Mylyn is a task management system and allows to store the context (source files) in a task. This way you can work on a certain task, switch to another tasks and return to the same tasks and all the files you worked on are re-opened. See the Mylyn Tutorial for installation and basic usage.
Mylyn has build in support for the Eclipse bug database. Just right click in the "Task List" view and select New -> Query

Select "Eclipse" and press Next. Select "Create query" and if you know the bug already "Create query using form".

Lets assume you want to see all bugs for Eclipse 3.6 in PDE - UI then you could maintain the following query.

If you now activate a task you can use Mylyn to work on Eclipse bugs.

Before posting questions, please see the vogella FAQ. If you have questions or find an error in this article please use the www.vogella.de Google Group. I have created a short list how to create good questions which might also help you.
Eclipse RCP Training (German) Eclipse RCP Training with Lars Vogel
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