Formatting rules

(Joan Pujol) #1

I’ve done a little PR and I’ve been asked to apply formatting rules.
The problem is that I haven’t been able to find any definition of formatting rules and I use IntelliJ and without a definition file I can’t use the Eclipse formatting plugin.
Any help? Someone that is not using Eclipse?

(David Graeff) #2

The style has not yet been recreated for IntelliJ unfortunately.
It seems to be a straight forward process however (if you for install Eclipse for a short moment, at least):

We can then import that style into the repository for everyone to use.

(Joan Pujol) #3

No, I’ve no problem is using eclipse formatting rules.
There is a plugin named Eclipse Formatter that does exactly the same formatting as internally uses eclipse code.
I’ve used it in successfully in several projects, but the problem is that I haven’t found where are the formatting rules that the project uses (the eclipse ones)
About the default importer in my experience is not a good solution, because it’s not 100% perfect and produces some differences.

(David Graeff) #4

They are setup by eclipse oomph and embedded in the .setup file as far as I know :confused:

(Joan Pujol) #5

It will be nice to have them clearly exported as an xml file that can be imported in IntelliJ or used in a maven plugin

(Scott Rushworth) #6

openHAB2.setup is xml, so maybe you can doing something with it?

(David Graeff) #7

openHAB core was just recently moved over back from Eclipse. And Eclipse never had any intention to support IntelliJ (naturally). That might change only now. That’s why I said, export the style from Eclipse, import it into IntelliJ and provide us with the style file. We would then add it to the repo.

(Hilbrand Bouwkamp) #8

Here you go :smile: openHAB_formatter.xml (33.4 KB)

(Or if you would have an openHAB eclipse installation you can export the formatter rules).

(Joan Pujol) #9

Thanks hilbrand.
It worked well, I double checked installing eclipse. Only there are some differences in imports when ussing eclipse formatting plugin.

I think that will be nice to have that file in the repository as it is very convenient for not eclipse users.
Also in a future is desired formatting could be enforced in maven build using a plugin