Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor
intellij-code-format
intellij-code-format
Java Code Format

In order for IntelliJ to format the code you need to import the OpenMRSFormatter.xml

Open the IntelliJ preferences and enter the search term "code style" which should show Code Style -> Java under the results in the left pane like shown here

Image Removed

Click on the "Manage..." button next to the "Scheme" drop-down at the top and select "Import..." in the pop-up window

Image Removed

Since the OpenMRSFormatter.xml is created using Eclipse select "Eclipse XML Profile"

Image Removed

Navigate to and select the tools/src/main/resources/eclipse/OpenMRSFormatter.xml and click "Open".

Import the formatter then in an own IntelliJ scheme and call it for example "OpenMRS Formatter"

Image Removed

Ensure the scheme you just created is selected in the "Scheme" dropdown

...


  1.  Install Eclipse Code Formatter plugin in intelliJ | Go to Files -> Settings -> Plugins | Select Marketplace and search for Eclipse Code Formatter, then install it and restart your IntelliJImage Added
     
  2. Get OpenMRS Formatter XML file
  3. Go to Files -> Settings -> Other Settings -> Eclipse Code Formatter |  The configuration must look like this                                                                                                                      Image Added
  • Turn on the Eclipse Code Formatter
  • Import the previously downloaded XML file
  • Turn off the option for Optimizing Imports

Keep everything else to default.


4. Apply the changes 


From now on you can let IntelliJ format any java class for you. Read IntelliJ - Reformatting Source Code on ways to do that.

...