Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple Eclipse formatter versions #52

Open
dougxc opened this issue Feb 22, 2016 · 3 comments
Open

Support multiple Eclipse formatter versions #52

dougxc opened this issue Feb 22, 2016 · 3 comments

Comments

@dougxc
Copy link
Member

dougxc commented Feb 22, 2016

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.

@markiewb
Copy link

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:https://eclipse-n-mati.blogspot.de/2015/06/eclipse-mars-how-to-switch-back-to.html

@dougxc
Copy link
Member Author

dougxc commented Feb 22, 2016

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 added a commit that referenced this issue Apr 29, 2016
…to master

* commit 'b3069a6c7217726f3b6c784c3dd8e5c0ac0c5f23':
  fixes regression in import statement parsing and defends against unexpected patterns
@pointhi
Copy link
Contributor

pointhi commented Jul 3, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants