NOW Hiring

Quick links

Eclipse Source Code - Tutorial

Lars Vogel

Version 3.6

12.02.2015

Eclipse source code tutorial

This tutorial explains how to work with the Eclipse source code. It assumes that you are already familiar with using the Eclipse IDE and is based on Eclipse 4.4 (Eclipse Luna).


Table of Contents

1. Accessing the Eclipse source code
2. Binary import of plug-ins
3. Identifying who contributes user interface components
3.1. Plug-in Spy for UI parts
3.2. Menu spy
3.3. SWT Spy
4. Enable access to plug-ins
4.1. Filtering by the Java tools
4.2. Include all plug-ins in Java search
5. Find the plug-in for a certain class
6. Finding classes and plug-ins
6.1. Open Plug-in artifact
6.2. Plug-in search
6.3. Plain text search
7. Example: tracing for key bindings
8. Example: tracing for key bindings
9. Patching existing Eclipse plug-ins with feature patches
9.1. Feature patch projects
9.2. Feature patch projects
10. About this website
11. Links and Literature
11.1. Eclipse Resources
11.2. vogella GmbH training and consulting support

1. Accessing the Eclipse source code

If you develop custom Eclipse plug-ins or Eclipse RCP applications, looking at the Eclipse source code is useful. This description helps you to access this source code.

2. Binary import of plug-ins

The following describes how you can import the source code of Eclipse plug-ins from your Eclipse installation to review the code. The Eclipse standard distribution contains the source code for the core Eclipse project. For other Eclipse projects you usually find an "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 FileImport. Select Plug-ins and Fragments.

Make the following settings. Select Binary project. There you can read the source code, but you cannot change it. It will also not be compiled. Therefore, this setting will save memory and performance.

Add all plug-ins you would like to import and press the Finish button.

You can you investigate the code of the imported plug-ins.

3. Identifying who contributes user interface components

3.1. Plug-in Spy for UI parts

You can activate the Plug-in Spy by pressing Alt+Shift+F1 in the Eclipse IDE. It gives you information about the currently selected user interface component. This way you can get immediate access to the plug-in which is currently running.

Click on any of the linked elements to obtain more information about that element. For example, if you click on the contributing plug-in the tool opens the manifest editor for this plug-in.

3.2. Menu spy

Press Alt+Shift+F2 and select a menu entry or click a toolbar entry to see information about this element.

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

4. Enable access to plug-ins

4.1. Filtering by the Java tools

The Eclipse Java tools limit the scope of search related activities based on your projects. By default, Eclipse includes elements from opened projects including their dependencies as well as elements from the standard Java library.

For example, the Open Type dialog (Ctrl+Shift+T) does not find the ISources interface, if it is not referred to by project in your workspace.

As plug-in developer you want to have access to all classes in your current target platform. The target platform is the set of plug-ins against you develop. By default, the plug-ins from the Eclipse IDE installation are used as target platform.

4.2. Include all plug-ins in Java search

You can include all classes from the current target platform to be relevant for the Eclipse Java tools via the following setting: WindowPreferencesPlug-in DevelopmentInclude all plug-ins from target in Java search.

How to add all Java classes from the Eclipse target platform to the Java search

5. Find the plug-in for a certain class

You frequently have to find the plug-in for a given class. The Eclipse IDE makes it easy to find the plug-in for a class. After enabling the Include all plug-ins from target into Java Search setting in the Eclipse IDE preferences you can use the Open Type dialog (Ctrl+Shift+T) 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.

Open Type Dialog

Plug-in for a Java class

6. Finding classes and plug-ins

6.1. Open Plug-in artifact

Use the Ctrl+Shift+A shortcut to search for an extension point. Definition and usage of an extension point have 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.

6.2. Plug-in search

Plug-in Search allows you to perform a detailed search for extension points. Select the SearchSearchPlug-in Search menu. You can specify what your are searching for as demonstrated in the following screenshot.

6.3. Plain text search

In case you have imported the source code of an Eclipse project into your workspace you can also use the plain text search. Select the SearchSearch menu entry and switch to the File Search tab.

As indicated in the following screenshot you can search for a text, use regular expressions and restrict which files to search by specifying a file name pattern. This is a very flexible way to search and allows you to find almost everything.

File Search

7. Example: tracing for key bindings

The tracing functionality of Eclipse allows to you trace which command is associated with a certain key binding. The following listing contains the trace options to enable that.

# turn on debugging for the org.eclipse.core.resources plugin.
org.eclipse.ui/debug=true
org.eclipse.ui/trace/keyBindings
org.eclipse.ui/trace/keyBindings.verbose 

8. Example: tracing for key bindings

The tracing functionality of Eclipse allows to you trace which command is associated with a certain key binding. The following listing contains the trace options to enable that.

# turn on debugging for the org.eclipse.core.resources plugin.
org.eclipse.ui/debug=true
org.eclipse.ui/trace/keyBindings
org.eclipse.ui/trace/keyBindings.verbose 

9. Patching existing Eclipse plug-ins with feature patches

9.1. Feature patch projects

If you want to modify standard Eclipse plug-ins, you can use Feature Patch Projects. A Feature Patch Project can contain plug-ins which replace existing plug-ins. This would allow you to create an update site for this feature and users can use your version of the modified code.

Each feature can only be patched once.

9.2. Feature patch projects

A feature patch project can get created via FileNewOther...Plug-in DevelopmentFeature Patch.

In this dialog select the feature which you want to patch. Add every modified plug-in to your new Feature Patch Project and export it as a p2 update site.

10. About this website

11. Links and Literature

11.1. Eclipse Resources

11.1.1. Eclipse Source Code

Setting up your ssh key for Eclipse.org

11.2. vogella GmbH training and consulting support

TRAINING SERVICE & SUPPORT
The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”. The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers.