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
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:
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.
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 themenu. 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 themenu 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.
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. About this website
9. Eclipse Source Code Resources
9.1. 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.
Appendix A: Copyright and License
Copyright © 2012-2016 vogella GmbH. Free use of the software examples is granted under the terms of the EPL License. This tutorial is published under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Germany license.