Java, Eclipse and Web programming Tutorials
Follow me on twitter About Lars Vogel

Source Code Guide of Eclipse 3.5 (Galileo)

Lars Vogel

Version 2.3

01.03.2010

Revision History
Revision 0.1 - 0.623.05.2008Lars Vogel
Created Article
Revision 0.718.02.2009Lars Vogel
Added CVS access
Revision 0.803.05.2009Lars Vogel
Plugin Spy for menus (Eclipse 3.5)
Revision 0.929.05.2009Lars Vogel
Updated to Eclipse 3.5
Revision 1.001.06.2009Lars Vogel
Added cvs details in table
Revision 1.106.07.2009Lars Vogel
Added cvs details in table
Revision 1.209.07.2009Lars Vogel
How to get commandsId for keybindings
Revision 1.317.07.2009Lars Vogel
Improved cvs section, adding how to access Eclipse PDE cvs repository
Revision 1.426.07.2009Lars Vogel
plugin search, new introduction
Revision 1.529.07.2009Lars Vogel
How to use Mylyn to connect to Bugzilla
Revision 1.609.08.2009Lars Vogel
Improved cvs description
Revision 1.710.11.2009Lars Vogel
Added Project Set Files for cvs access
Revision 1.817.11.2009Lars Vogel
Removed redundant plugin search capter, general rework of the Article.
Revision 1.903.01.2009Lars Vogel
Added WTP cvs repository
Revision 2.004.01.2010Lars Vogel
get the source code via git
Revision 2.106.01.2010Lars Vogel
added SWT spy
Revision 2.213.01.2010Lars Vogel
Added CVS web respository
Revision 2.301.03.2010Lars Vogel
Simplified CVS chapter

Eclipse Source Code Guide

This article describes how to access the Eclipse source code, search for plugins or code, demonstrates the usage of the "Plugin Spy" and how to debug the Eclipse IDE.

This article assumes that you are already familiar with using the Eclipse IDE and is based on Eclipse 3.5 (Eclipse Galileo).


Table of Contents

1. Overview
2. Import Plugins
3. Plugin Spy
3.1. Plugin Spy for UI parts
3.2. Plugin Spy for menus
3.3. SWT spy
4. Using Search
4.1. Plugin Search
4.2. Java Search
5. Finding commands for keybindings
6. Debugging Eclipse
7. Version control
7.1. CVS
7.2. svn
7.3. git
8. Bugzilla and Mylyn
9. Thank you
10. Questions and Discussion
11. Links and Literature
11.1. Source Code
11.2. Other Resources

1. Overview

Often you need to change or extend Eclipse functionality. This guide try to help getting into the Eclipse source code.

In additional to this developers are frequently advised to read existing high-quality code. Having easy access to the Eclipse sources can be extremely helpful in familiarizing yourself with the coding patterns inherent in Eclipse

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. So you can learn a lot from the Eclipse code base.

The Eclipse code base can be imported directly from your installed Eclipse version or can be access via the cvs or svn version control system. The article describes both approaches.

2. Import Plugins

The following describes how you can import Eclipse plugins from your Eclipse installation to review the code.

Tip

If you import a lot of plugins you may want to create a new workspace for this.

Select File -> Import. Select "Plug-ins and Fragments".

Make the following settings.

Tip

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". In my example I import only "org.eclipse.ui.intro".

You can you investigate the code of the imported plugins.

Tip

The Eclipse distribution contains the source code for the core Eclipse projects, e.g. JDT. For other Eclipse projects you usually find a "SDK" bundle on the project update side which contains the source code.

3. Plugin Spy

3.1. Plugin Spy for UI parts

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.

3.2. Plugin Spy for menus

Eclipse 3.5 introduced the possibility to check which plugin contributed a menu. Press "Alt + Shift + F2" and select a menu to see who is contributing this menu.

Tip

To use the Eclipse Plugin Spy in your Eclipse RCP application include the plugin "org.eclipse.pde.runtime" into your application.

3.3. SWT spy

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 here for more information SWT Tools .

4. Using Search

4.1. Plugin Search

Plugin Search allow you to search for extension points declaration and usage.

Select from the menu Search -> Search and then the tab "Plug-in Search". For example the following will search for all declaration (defining an extension) to the extension point "org.eclipse.debug.core.launchConfigurationTypes".

4.2. Java Search

You can also search for Java elements, e.g. methods. In the search menu select the tab "Java Search"

For example you can search for method createInitialLayout

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

5. Finding commands for keybindings

Tip

The following is based on the following blog entry Tracing Keybindings in Eclipse RCP from Elias Volanakis

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 this create a runtime configuration which contains the Eclipse plugins you are interested in, e.g. include "org.eclipse.ui" and press add required plugins.

In the "Run Configuration" switch to the "Tracing" tab and set "Enable Tracing". Select the "org.eclipse.ui" plugin. 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 then everytime 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.

6. Debugging Eclipse

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.

7. Version control

Eclipse projects can use cvs and svn as version control system. The majority of the project still uses cvs. Downloading the source code from a version control system is called "checkout".

7.1. CVS

To access the Eclipse CVS repositories open the "CVS Repositories" view via Window -> Show View -> Other -> CVS -> CVS Repositories

Create a repository by right clicking in the view and selecting "New" -> "Repository Location".

Copy the following string and paste it into the CVS view to create a new repository.

				
:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse
			

You can check the created properties via right-mouse click on the entry -> Properties

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

Not all Eclipse projects are in the same path. For example here are some connection strings.

Table 1. Access to some

ProjectDescription
Eclipse Main:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse
Eclipse PDE CVS repository:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse then find the folder pde
Eclipse Equinox CVS repository:pserver:anonymous@dev.eclipse.org:/cvsroot/rt

More information about cvs access can be found Eclipse cvs access

Tip

You can browse the CVS source code in the CVS online repository

Tip

Eclipse projects often provide "Project Set Files" (.psf) which allow to checkout a logical connected set of plugins directly from cvs. Via these files you can easily get a consistent working copy of a set of plugins. See Eclipse PSF Wiki for details and see Eclipse PDE contributor Guide for an example.

7.2. svn

The access of Eclipse code via svn is described in Eclipse svn access . For using svn with Eclipse you need the Eclipse subversive plugin. The installation of this plugin is described in Eclipse Subversive

.

7.3. git

Eclipse mirrors the cvs repositories into Git.

The Eclipse code is currently mainly maintained in cvs but this source code is mirrored into Git repositories.

Tip

You find the Git url for all projects at http://dev.eclipse.org/git/

Tip

Please note that the checkout via HTTP uses a different URL. You can switch to the HTTP urls on the webpage.

Please see Git with Eclipse EGit - Tutorial for details on how to use the EGit plugin.

8. Bugzilla and Mylyn

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.

9. Thank you

Thank you for practicing with this tutorial.

Please note that I maintain this website in my private time. If you like the information I'm providing please help me by donating.

10. Questions and Discussion

For questions and discussion around this article please use the www.vogella.de Google Group. Also if you note an error in this article please post the error and if possible the correction to the Group.

I believe the following is a very good guideline for asking questions in general and also for the Google group How To Ask Questions The Smart Way.

11. Links and Literature

11.1. Source Code

http://www.vogella.de/code/codeeclipse.html Source Code of Examples