Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 19 Current »

On This Page

 

A code formatter for the Eclipse IDE that can be used across all DDF projects will allow developers to format code similarly and minimize merge issues in the future.

DDF uses an updated version of the Apache ServiceMix Code Formatter (http://servicemix.apache.org/developers/building.html) for code formatting. 

Load the Code Formatter Into the Eclipse IDE

DOWNLOAD THIS FILEddf-eclipse-code-formatter.xml (NOTE: Right-Click the link and Select Save Link As if the browser opens the file in another window).

  1. In Eclipse, select Window → Preferences. The Preferences window opens.

  2. Select Java → Code Style → Formatter.

  3. Select the Edit... button and load the attached ddf-eclipse-code-formatter.xml.

  4. Select the OK button.

Load the Code Formatter Into IntelliJ IDEA

DOWNLOAD THIS FILEddf-intellij-code-formatter.jar (NOTE: Right-Click the link and Select Save Link As if the browser opens the file in another window).

Previously, in IntelliJ, we would just import the Eclipse settings. However, now there is a IntelliJ settings jar that will import the code styles.

  1. Open IntelliJ IDEA.
  2. Select File → Import Settings. The file selection window opens.
  3. Choose ddf-intellij-code-formatter.jar.
  4. Select OK. NOTE: this will restart IntelliJ.

Format Your Source Code Using Eclipse 

A developer may write code and format it before saving.

  1. Before the file is saved, highlight all of the source code in the IDE editor window.
  2. Right-click on the highlighted code.
  3. Select Source → Format. The code formatter is applied to the source code and the file can be saved. 

Set Up Save Actions in Eclipse

A developer can also set up Save Actions to format the source code automatically.

  1. Open Eclipse.
  2. Select Window → Preferences (Eclipse → Preferences on Mac). The Preferences window opens.

  3. Select Java → Editor → Save Actions.

  4. Select Perform the selected actions on save.

  5. Select Format source code.
  6. Select Format all lines or Format edited lines, as necessary. 
  7. Optionally, select Organize imports (recommended).
  8. Select the Apply button.
  9. Select the OK button.

Format Source Code Using IntelliJ

In the toolbar, select Code → Reformat Code or use the keyboard shortcut Ctrl-Alt-L.

 

  • No labels