Bug 197876 - Need a way to import eclipse code formatter.xml file
Need a way to import eclipse code formatter.xml file
Status: NEW
Product: editor
Classification: Unclassified
Component: Formatting & Indentation
-S1S-
All All
: P3 with 18 votes (vote)
: TBD
Assigned To: Dusan Balek
issues@editor
:
: 99495 188228 206053 206377 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-20 00:16 UTC by venkatramakkineni
Modified: 2016-01-05 19:53 UTC (History)
6 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description venkatramakkineni 2011-04-20 00:16:00 UTC
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
Comment 1 mdm42 2012-07-18 08:15:48 UTC
*** Bug 206053 has been marked as a duplicate of this bug. ***
Comment 2 markiewb 2013-01-12 13:56:26 UTC
*** Bug 206377 has been marked as a duplicate of this bug. ***
Comment 3 Meo 2013-04-20 11:13:38 UTC
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
Comment 4 tomzi 2013-04-22 07:22:54 UTC
Yeah - MUCH needed. Also with maven integration :)
Comment 6 williescholtz 2013-08-05 13:21:23 UTC
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
Comment 7 Meo 2013-08-05 16:04:29 UTC
(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...
Comment 8 tomzi 2013-08-06 06:22:28 UTC
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?
Comment 9 williescholtz 2013-08-06 06:32:06 UTC
(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
}
Comment 10 tomzi 2013-08-06 10:44:00 UTC
> 
> 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 :)
Comment 11 williescholtz 2013-08-06 10:47:13 UTC
(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 :)
Comment 12 markiewb 2013-08-06 21:16:19 UTC
(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)?!
Comment 13 tomzi 2013-08-07 06:52:41 UTC
@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....
Comment 14 Geertjan Wielenga 2013-08-25 12:28:29 UTC
Followed the instructions by williescholtz and the result can be tried out here:

https://blogs.oracle.com/geertjan/entry/eclipse_formatter_for_netbeans_ide
Comment 15 parthiNB73 2013-09-26 16:14:03 UTC
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.
Comment 16 markiewb 2013-09-26 19:22:03 UTC
(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...
Comment 17 parthiNB73 2013-10-07 16:18:36 UTC
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.
Comment 18 markiewb 2013-10-07 18:18:01 UTC
(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.
Comment 19 markiewb 2013-10-07 18:24:23 UTC
(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.
Comment 20 parthiNB73 2013-10-07 19:36:20 UTC
I created a new issue at this site 

https://github.com/markiewb/eclipsecodeformatter_for_netbeans/issues

Thanks,
Parthi
Comment 21 parthiNB73 2013-10-07 22:55:39 UTC
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.
Comment 22 puce 2013-10-25 11:28:51 UTC
+1 This feature ia also very imporant if not all team members use NetBeans as IDE.
Comment 23 markiewb 2015-04-06 19:58:32 UTC
*** Bug 188228 has been marked as a duplicate of this bug. ***
Comment 24 markiewb 2015-04-06 20:02:28 UTC
*** Bug 99495 has been marked as a duplicate of this bug. ***
Comment 25 nebrass 2016-01-05 15:32:49 UTC
+1 so important feature
Comment 26 markiewb 2016-01-05 19:53:32 UTC
(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


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo