Eclipse Source Code

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.2 (Eclipse Juno).

 

1. Eclipse Source Code

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

2. Import Plugins

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

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.

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 plug-in / data types / screen. This way you can get immediately access to the plug-in which is currently running.

Click on the active class or the contributing plug-in to get to the class or the source code of the class.

3.2. Plugin Spy for menus

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 plug-in "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. SeeSWT Toolsfor more information.

4. Include all plug-ins into the Eclipse search

By default the Eclipse Java tools only consider Java components, e.g. classes or interfaces, from the standard Java libraries and from the the projects and their dependencies in the workspace as relevant for search operations.

For example the Ctrl+Shift+T (Open Type) shortcut will not find theISources interface if it is not referred to in the current workspace.

You can add all classes from the current target platform, e.g. default is the Eclipse IDE, to be relevant for the Eclipse search via the following setting:WindowPreferencesPlug-in DevelopmentInclude all plug-ins from target into Java Search

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

5. Find plug-in for a certain class

Eclipse consists of out components called plug-ins.

You frequently have to find the plug-in which contains a certain class. After making theInclude all plug-ins from target into Java Search setting in the Eclipse preferences you can use theOpen Type dialog to find the plug-in for a class. Thejar 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 an Java class

6. Finding classes and plug-ins

6.1. Open Plugin Artifact

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 plug-in defines theorg.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 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".

6.3. Java Search

Use the tab "Java Search" to search for Java elements, e.g. methods.

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

7. Finding commands for keybindings

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" plug-in 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.

8. 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 / plug-in 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.

9. Eclipse source code via Git

Eclipse projects primarily use Git.The following section describes the usage of Git.

The usage and background of Git is not described in this tutorial. Please see EGit Tutorial for details on how to use the EGit plug-in for Eclipse or see Git Tutorial to learn how to use Git from the command line.

The main URL for Git access to the Eclipse source code is http://git.eclipse.org. You find links to all Eclipse Git repositories on this page.

To clone a project you check the webpage. For example if you want to clone the projectTycho you see on the webpage that the name istycho and the repository is called org.eclipse.tycho.git. You can clone this repo via the following command.

git clone git://git.eclipse.org/gitroot/tycho/org.eclipse.tycho.git 

The projects which are still using cvs are mirrored in http://dev.eclipse.org/git/ .

10. 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 replaces existing plug-ins. This would allow you to create update site for this feature and users can use your version of the modified code.

A feature project can get created via File NewOtherPlug-in DevelopmentFeature Patch.

In this dialog select the feature which you want to patch. Add every modified plug-in to your newFeature Patch Projects and export is as p2 update site.

Every feature can only be patched once.

11. 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.

Mylynis 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 theMylyn 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.

12. Thank you

Please help me to support this article:

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值