revelc / formatter-maven-plugin

Formatter Maven Plugin
https://code.revelc.net/formatter-maven-plugin
Apache License 2.0
291 stars 91 forks source link

Support C/C++ formating from Eclipse CDT #265

Open wmarkow opened 6 years ago

wmarkow commented 6 years ago

It would be good to format C/C++ code as well. Eclipse CDT can be used as a C/C++ development IDE. It has already a formatter that seems to work in a similar way like for standard Java development.

I think it could use the CodeFormatter class from org.eclipse.cdt.core jar. At the beginning it could format the following files:

With this solution it would be possible to format a large C/C++ project pretty fast. Let me know what you think.

ctubbsii commented 6 years ago

I think this would be useful, but it would probably have to run outside of a Maven project, since most C/C++ projects don't use Maven to build. Running outside of a Maven project is being discussed as problematic on #261 , but it may be possible to create a separate mojo for formatting C/C++ code outside of a project.

wmarkow commented 6 years ago

I did some job on embedding Eclipse CDT into fromatter-maven-plgin. Some commits are available in my cdt_#265 branch.

There are some issues with Eclipse CDT formatter:

I have prepared unit tests to cover some specific cases. I didn't create a separate mojo for C/C++ formatting, I just added this to a FormatterMojo. I have checked this and it works with my C/C++ code. I know that most C/C++ projects doesn't use Maven to build. Maybe it could be used together with nar-maven-plugin.

ctubbsii commented 6 years ago

@wmarkow It sounds like you've made some good progress. I think before this would be ready for a pull request, I'd want to see the relevant CDT jars for formatting be published to Maven Central, and for it to better support formatting outside of an Eclipse CDT project.