Eclipse Setup for iObserve

Reiner Jung edited this page Mar 7, 2018 · 21 revisions

The iObserve project comprises several different repositories used for various artifacts used to realize the iObserve approach. To improve inter interoperability, between different research groups, we defined the following setup instructions for your Eclipse environment.

The present configuration is tested with Eclipse Oxygen, but should also work with Mars.

Prerequisites

Coding Conventions

We know people have different coding conventions in their projects which might differ from our setup. However, we need a common setup for our iObserve. This tutorial instructs how to setup the code formatter and the editor for the iObserve project. The illustration follows the setup in Eclipse. In case you use other development environments, e.g., Emacs, VisualStudio or InelliJ, you must mimic the coding style in your specific IDE. As all settings are also enforced with checkstyle, findbugs and pmd, you can also follow the respective quality tools.

If you want these coding styles to be present in all projects you have to deviate from the given instructions or reproduce the setup for every project.

As iObserve comprises multiple Eclipse projects, it is preferable to use a workspace wide configuration. Therefore, we encourage you to create a separate workspace for iObserve and follow these instructions.

Please note that we use Xtend and Java to implement parts of iObserve. Therefore, several preferences must be configured for both languages.

To start the configuration: Start Eclipse and open the Preferences page (Windows > Preferences)

Setup the Clean Up

Unfold the Java Code Style option and then Clean Up. This will open the clean up form in the dialog.

Clean Up
  • Now click on the Import...-button under Active - Profile. This brings up a file dialog.
  • Select in the file dialog the ide-configuration/eclipse/cleanup-rules.xml relative to the iobserve directory.
  • Ensure that the iObserve cleanup Rules are displayed as active entry in the selector below.
  • Finally click on Apply to apply the clean up settings.

Setup the Formatter

Unfold the Java Code Style option and then Formatter. This will open the formatter form in the dialog.

Formatter
  • Now click on the Import...-button under Active - Profile. This brings up a file dialog.
  • Select in the file dialog the ide-configuration/eclipse/code-formatter.xml relative to the iobserve directory.
  • Ensure that the iObserve Code Format is displayed as active entry in the selector below.
  • Finally click on Apply to apply the formatter settings.

Setup the Save Actions

Save actions are applied to the content while saving the file. the are setup in the project properties dialog.

Unfold the Java Editor option and select Save Actions.

Save Actions
  • Check Perform the selection actions on save
  • Check Format source code
  • Check Organize imports
  • Check Additional Actions

The result should look like in the image above.

  • Click on the Configure...*-button right of the list of additional actions. This brings up the save action configuration.
Code Organizing
  • Select the tab Code Organizing
  • Select the options as displayed in the picture (above).
Code Style
  • Select the tab Code Style
  • Select the options as displayed in the picture.

Note that we force the setting of final modifiers everywhere. This has two advantages. First, it indicates to the reader that this property, parameter and variable is not modified, i.e., no new object is assigned to it. This increases code readability. Second, it hinders programmers to modify properties accidentally or in case they should be modifiable, shows that there is some mix up somewhere else in the code. You may also consulte the checkstyle manual on this property.

Member Access
  • Select the tab Member Access
  • Select the options as displayed in the picture.
Missing Code
  • Select the tab Missing Code
  • Select the options as displayed in the picture.
Unnecessary Code
  • Select the tab Unnecessary Code

  • Select the options as displayed in the picture.

  • Now click on Ok to accept the setup.

  • In the Save Actions tab, press Apply to apply these settings.

Setup Templates

The iObserve templates have been extended by a template for the standard file header. It can be applied to the header by moving the cursor to the top left and pressing CTRL-Space for context help. By selecting the header template from the list, the editor adds the header template include the correct year for the code revision.

Unfold the Editor option and select Templates.

  • Select the Import...-button on the right. This brings up a file dialog.
  • Select in the file dialog the ide-configuration/eclipse/java-templates.xml relative to the iobserve directory.
  • In the Templates, press Apply to apply these settings.

Setup the Header for new Files

You can also add code templates to automatically insert the license header when a new Java file is created.

In the Java option under Code Style click on the settings for Code Templates. Java Code Templates

  • Click on Import

  • Select in the file dialog the ide-configuration/eclipse/java-codetemplates.xml relative to the iobserve directory

  • Click Ok and then Apply

Character Encoding

To avoid encoding issues (which can also be handled by git) you may want to set the correct encoding in Eclipse. This task is optional, as it can also be performed by git. In case you want to use you OS native settings, please configure git to manage encoding and line end conversion.

Workspace Encoding
  • Unfold General option and select Workspace

  • Check if Text file encoding is set to UTF-8

  • Check if New text file line delimeter is set to Unix

  • Press the Ok-button.

Add Checkstyle Configuration

In the Workspace preferences search for Checkstyle.

Workspace Encoding
  • Click on New...

  • Choose for Type the Project Relative Configuration

  • Name it iObserve

  • Click on the *Browse... button and look in iobserve-analysis/ide-configuration/eclipse/ for checkstyle-rules.xml

  • Click Ok and leave the preference dialog

  • Go to each project and open the properties dialog

  • Select the Checkstyle option

  • Select iObserve as Simple configuration

  • Check Checkstyle active for this project

  • Click Ok

You may perform this task only for those projects you are working on.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.