Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Intellij code formatter #176

Open
moxit0 opened this issue Jan 1, 2022 · 9 comments
Open

Support for Intellij code formatter #176

moxit0 opened this issue Jan 1, 2022 · 9 comments

Comments

@moxit0
Copy link

moxit0 commented Jan 1, 2022

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 ?

@funfried
Copy link
Owner

funfried commented Jan 2, 2022

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.

@moxit0
Copy link
Author

moxit0 commented Jan 2, 2022

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.

@funfried
Copy link
Owner

funfried commented Jan 2, 2022

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.

@moxit0
Copy link
Author

moxit0 commented Jan 2, 2022

I understand, is it possible some solution like parsing of their exported xml file and then mapping to Eclipse or Netbeans code formatter properties ?

@funfried
Copy link
Owner

funfried commented Jan 2, 2022

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 😉

@sviperll
Copy link

For what it's worth. You can probably use Eclipse as a common formatter. There is an IntelliJ-plugin for this.

@funfried funfried added this to the 1.15.0 milestone Jan 22, 2022
@funfried funfried modified the milestones: 1.15.0, 1.15.1, 1.15.2 May 18, 2022
@funfried
Copy link
Owner

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

@funfried funfried modified the milestones: 1.15.2, 1.16.0 Jul 21, 2022
@zuzzz
Copy link

zuzzz commented Mar 5, 2024

Hi. What is the outcome? Did you stop working on Idea formatting?

@funfried
Copy link
Owner

funfried commented Mar 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants