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.6 (Eclipse Neon). This Tutorial describes how to extend the Eclipse IDE with custom plugins.

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

File ▸ Import

Select Plug-ins and Fragments.

import10

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.

import20

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

import30

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.

pluginspy10

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.

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

pluginspy20

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.

You can include all classes from the current target platform to be relevant for the Eclipse Java tools via the following setting: Window ▸ Preferences ▸ Plug-in Development ▸ Include 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.

openpluginartifact

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

pluginsearch10

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 Search ▸ Search 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. Eclipse Source Code Resources