CppStyle
CppStyle copied to clipboard
Java formatting
Are there any plans to support Java formatting? According to https://clang.llvm.org/docs/ClangFormat.html, this is supported by clang-format.
Presumably this would mostly be UI work, and clang-format could be called the same way?
That‘s very cool. Would you like to contribute to this feature?
I actually got it working in a fork - the functionality itself was simple, the big issue is the CDT dependency. Not sure if you can have optional dependencies in Eclipse plugins? I ended up just removing all CDT references to make it work. Either way, having CDT installed should obviously not be a requirement for formatting Java code.
Nice and very useful tool!
Would it be possible to merge @Gama11's proposed commit https://github.com/wangzw/CppStyle/commit/6edf38b7b3694e07b59592f24a2bf56deba4833f be and eventually release this? The commit seems to be fairly small... I'd use it even with the CDT dependency as we are also using C/C++ in addition to Java.
Many thanks in advance and thanks again for your good work!
I actually got it working in a fork - the functionality itself was simple, the big issue is the CDT dependency. Not sure if you can have optional dependencies in Eclipse plugins? I ended up just removing all CDT references to make it work. Either way, having CDT installed should obviously not be a requirement for formatting Java code.
Hi Gama11, your Java-Fork seems to be failing, when you also have active SaveActions (Preferences -> Java -> Editor -> Save Actions).
Steps to reproduce:
- Remove an @Override annotation and also change some formatting which the formatter should handle.
- The Formatter formats the code
- The SaveActions restore the @Override Annotation and fails, because of the previous actions of the formatter. -- Save action: Add missing '@Override' annotations
I didn't understand yet, why the SaveAction fails in combination with the formatter. Do you have any idea?
Also I saw that you didn't add the ClangFormatFormatter as a JavaFormatter via the extension point
I got a version which works fine for Java in my fork: ClangFormat4J
I have tried both CppStyle and ClangFormat4J and the functionality seemed identical in the latest Eclipse (Version: 2023-03 (4.27.0)) configured to format on save. I am using clang-format 16.0.4. Maybe I am not set up correctly and am seeing the default Eclipse format because when I compare the clang-format with IntelliJ it responds quite different (more as I would expect clang-format) My goal is to get identical formatting across IDE so we do not have differences introduced based on editor.