mx icon indicating copy to clipboard operation
mx copied to clipboard

Support multiple Eclipse formatter versions

Open dougxc opened this issue 8 years ago • 3 comments

The current release of Eclipse is 4.5.1 and a number of people have expressed they are now using it. One problem though is that the formatter in 4.5 is not 100% backwards compatible with the one in 4.4 and so everyone has to keep a copy of 4.4 around to check that mx eclipseformat will pass integration gates that use Eclipse 4.4 for formatting checks.

To support per-project opt-in adoption of Eclipse 4.5, we need mx to support multiple Eclipse formatter versions. The plan is to add support for a suite level eclipse.formatter.version attribute. Suites missing this attribute or whose mxversion attribute value is lower than the mx version introducing eclipse.formatter.version will use Eclipse 4.4 for formatting. Otherwise, the eclipse.formatter.version value is used to find a compatible Eclipse. The search for a compatible version will use the -e/--eclipse-exe argument of the mx eclipseformat command which will now be interpreted as a search path (like a class path). The version of an Eclipse found on the path is the version property in the .eclipseproduct file. Given that the Eclipse formatter doesn’t ensure backwards compatibility, mx will require an exact match for the major and minor version numbers.

Note that this issue only addresses mx based Eclipse formatting. As far as I know the Eclipse IDE only supports one formatter at a time and so sources should only be edited from within the Eclipse IDE if the associated eclipse.formatter.version value is compatible with the IDE version.

dougxc avatar Feb 22 '16 14:02 dougxc

As far as I know the Eclipse IDE only supports one formatter at a time

It's pluggable [1], that's why the 4.4-formatter can be used in 4.5 too [2] .

[1] https://www.eclipse.org/eclipse/news/4.5/jdt.php#JavaFormatter [2] http://eclipse-n-mati.blogspot.de/2015/06/eclipse-mars-how-to-switch-back-to.html

markiewb avatar Feb 22 '16 17:02 markiewb

Thanks for the info @markiewb ! However, as far as I can tell, still only one formatter implementation can be active at any given time in Eclipse. So you're still going to have to touch source code in Eclipse that is "compatible" with the active formatter implementation.

dougxc avatar Feb 22 '16 21:02 dougxc

With the new Eclipse 4.7 release, there was a little change of the formatting of block comments. Which means lines which are formatted on my computer doesn't validate on the ci-system with mx eclipseformat vice versa.

It seems the option Count width from comment's starting position was enabled.

pointhi avatar Jul 03 '17 07:07 pointhi