externalcodeformatter_for_netbeans
externalcodeformatter_for_netbeans copied to clipboard
Support for Intellij code formatter
Hi, I am trying to import code formatter from Intellij but unfortunately without success. Is there a way to use Intellij code formatter with this plugin or is still not supported ?
Hello @moxit0,
I think the libraries of the IntelliJ code formatter are not public. At least I could not find any of them in Maven Central or on the JetBrains website. If you know a place where to get them, please let me know, I'm more than happy to integrate their formatter into the plugin.
I am not aware if Intellij has shared any library, currently they support Code stye format as XML, If this is somehow helpful. In general often developers are trying to migrate from Intellij to some other IDE but due to rest of their teammates are still using Intellij migration is not possible because of different code formatter.
I'm totally aware of that issue, as I faced the same problem with Eclipse and NetBeans. It would make sense to have a common formatter for all IDEs or even IDE independent which is available afaik, but not really used. Anyways, I downloaded the current IntelliJ CE and it looks like I could use the libraries from within that package, but it's not really decoupled and definitely not meant to be used from outside the IntelliJ IDE. I'll have a closer look soon, but that won't be easy and I'm afraid that I will have to include so many JARs from IntelliJ that in the end I will package the whole IntelliJ IDE into my plugin, which makes obviously no sense. But as said, I'll try my best even if it doesn't look promising.
I understand, is it possible some solution like parsing of their exported xml file and then mapping to Eclipse or Netbeans code formatter properties ?
I need to check their XML output, but I'm pretty sure I would have to write my own custom mapper, which could be quite difficult as there might be a lot of options and some of them might not match the options of the Eclipse or NetBeans formatter and then I would need to add some logic into the mapper which could change anytime either on IntelliJ side or on Eclipse or NetBeans side. I'm not sure if I would like to maintain such a thing 😉
For what it's worth. You can probably use Eclipse as a common formatter. There is an IntelliJ-plugin for this.
Some news on this:
I found the Maven repository for the JetBrains Maven artifacts: https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html And I think I found the artifacts of the IntelliJ Java formatter, but I did not yet understand how that code works and how or if I can call it to format a NetBeans Editor Document, but I'm on it and hopefully I'll find out how it could be used.
Cheers, Fabi
Hi. What is the outcome? Did you stop working on Idea formatting?
Hi @zuzzz,
yes and no, I tried a lot but it seems the formatter of IntelliJ is not very loosely coupled. Their formatter expects a special IntelliJ document which can be only created by another piece of IntelliJ code which then expects other IntelliJ objects and at some point in the code it expects an initialized IntelliJ IDE, as far as I remember. But still this feature would be a great plus to the plugin, so I'm not willing to give up on this, yet. But at the moment it seems not very promising that it will be done soon or even be possible.
If someone has an idea or a hint on how to implement that, please let me know.
Cheers, Fabian