This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Hi I am looking for a way to import eclipse codeformatter.xml file into netbeans code formatting app. This will make importing eclipse projects into Netbeans even more easier. Since the functionality to import eclipse projects into Netbeans is already in place this feature will make the integration more complete. Also this feature should be accessible even if the project is not an eclipse project imported into netbeans. This feature is especially helpful if the project is a maven project. Venkat
*** Bug 206053 has been marked as a duplicate of this bug. ***
*** Bug 206377 has been marked as a duplicate of this bug. ***
Imho the best way would be using Eclipse's code formatter as a plugin, like it was done for IntelliJ http://plugins.jetbrains.com/plugin/?idea&pluginId=6546
Yeah - MUCH needed. Also with maven integration :)
FYI research links * http://www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/ * http://ssscripting.wordpress.com/2009/06/10/how-to-use-the-eclipse-code-formatter-from-your-code/ * http://blog.nigjo.de/netbeans/2011/08/der-eclipse-code-formatter-in-netbeans/ * https://github.com/benalexau/maven-java-formatter-plugin/#readme * http://code.google.com/p/maven-java-formatter-plugin/
I created a POC plugin for this using the eclipse formatter and all the research in above mentioned links, it is in no way perfect but shows it is possible, I wrote a short blog entry here: http://epochcoder.blogspot.com/2013/08/import-eclipse-formatter-into-netbeans.html
(In reply to comment #6) > I created a POC plugin for this using the eclipse formatter and all the > research in above mentioned links, it is in no way perfect but shows it is > possible, I wrote a short blog entry here: > > http://epochcoder.blogspot.com/2013/08/import-eclipse-formatter-into-netbeans.html You will also need to sort&group imports(if possible), for implementation look into IntelliJ plugin...
This is great - But one question, is there a way to reach the same goal by importing the formatter.xml and actually use the netbeans formatter?
(In reply to comment #8) > This is great - But one question, is there a way to reach the same goal by > importing the formatter.xml and actually use the netbeans formatter? No way at all, even if you manually adjust netbeans's formatting settings so it corresponds to eclipse's, there are still some discrepancies between the styles of formatting. for example, to the best of my knowledge netbeans cannot format an if statement like so: if (expr) { // statement } else // <------------------ problem here { // statement }
> > http://epochcoder.blogspot.com/2013/08/import-eclipse-formatter-into-netbeans.html So with this plugin, can I just select between the Netbeans and the Eclipse Formatter in the settings and use the same shortcuts/integration, like 'format on save'.... Can you upload the plugin to plugins.netbeans.org :)
(In reply to comment #10) > > > > http://epochcoder.blogspot.com/2013/08/import-eclipse-formatter-into-netbeans.html > > So with this plugin, can I just select between the Netbeans and the Eclipse > Formatter in the settings and use the same shortcuts/integration, like 'format > on save'.... > > Can you upload the plugin to plugins.netbeans.org :) Unfortunately not (disabling it is the only way to use the netbeans one). The formatter.xml file is also hard coded at the moment, that is why I wrote a blog entry on how to accomplish the same and build onto it, rather than publish an incomplete plugin that I cannot fully support :)
(In reply to comment #11) > (In reply to comment #10) > > > > > > http://epochcoder.blogspot.com/2013/08/import-eclipse-formatter-into-netbeans.html > > > > So with this plugin, can I just select between the Netbeans and the Eclipse > > Formatter in the settings and use the same shortcuts/integration, like 'format > > on save'.... > > > > Can you upload the plugin to plugins.netbeans.org :) > > Unfortunately not (disabling it is the only way to use the netbeans one). The > formatter.xml file is also hard coded at the moment, that is why I wrote a blog > entry on how to accomplish the same and build onto it, rather than publish an > incomplete plugin that I cannot fully support :) Can you please at least post the sourcecode (incl. libs) at github (or other hoster)?!
@Netbeans Devs: Is there a 'Formatter API' that I can switch to an external formatter? How can I integrate an external Formatter and at the same time use the same shortcuts....
Followed the instructions by williescholtz and the result can be tried out here: https://blogs.oracle.com/geertjan/entry/eclipse_formatter_for_netbeans_ide
I tried based on Geertjan Wielenga blog but still doesn't work for me. It goes back to default NB formatter. 1. I am using NB-7.4 RC1 2. JDK 1.7 Two things bothers me from NB5, 1. Code formatter 2. Font And still these issues are not fixed. I would appreciate if you make these issues are high priority.
(In reply to parthiNB73 from comment #15) > I tried based on Geertjan Wielenga blog but still doesn't work for me. It > goes back to default NB formatter. FYI: I forked Geertjan's plugin (in accordance with him), so you can file your issue at https://github.com/markiewb/eclipsecodeformatter_for_netbeans . I think next week I can release a fixed (but not fully bug-free) version. > Two things bothers me from NB5, > > 2. Font Please create a separate issue and provide details/system configuration/screenshots. One word is not enough...
Thanks for the update. I downloaded your plug-in and tried out on NB 7.4 RC1 and NB 7.3.1 1. When I use shortcut key (Ctrl-Shift-F) it works 2. But when I save the java file, it looses all the formats. Please provide me a solution.
(In reply to parthiNB73 from comment #17) > Thanks for the update. > > I downloaded your plug-in and tried out on NB 7.4 RC1 and NB 7.3.1 > > 1. When I use shortcut key (Ctrl-Shift-F) it works > > 2. But when I save the java file, it looses all the formats. > > Please provide me a solution. Please file an issue at https://github.com/markiewb/eclipsecodeformatter_for_netbeans and provide more details. I will take of.
(In reply to markiewb from comment #18) > Please file an issue at > https://github.com/markiewb/eclipsecodeformatter_for_netbeans and provide > more details. I will take of. Of course: I will take care of.
I created a new issue at this site https://github.com/markiewb/eclipsecodeformatter_for_netbeans/issues Thanks, Parthi
Thanks Everyone.. I got the source code from above site ( https://github.com/markiewb/eclipsecodeformatter_for_netbeans/issues ) and build it locally and tested against NB 7.4 RC2 ( which I downloaded today) and it worked.
+1 This feature ia also very imporant if not all team members use NetBeans as IDE.
*** Bug 188228 has been marked as a duplicate of this bug. ***
*** Bug 99495 has been marked as a duplicate of this bug. ***
+1 so important feature
(In reply to nebrass from comment #25) > +1 so important feature @Nebrass: Have you tried my plugin http://plugins.netbeans.org/plugin/50877/ which uses the eclipse formatter engine? IMHO that is more effective than trying to map all possible configurations of the eclipse formatter configuration to (perhaps not) existing NetBeans formatter options