Work started on Apache Camel Intellij IDEA plugin

Just because its Christmas does not mean the Camel stands still.

On the even of the 23rd I took the evening to do a bit of research and start hack on a little prototype for an Apache Camel plugin for IDEA. Its something that has been on my radar for a longer time. 

The reason is that Apache Camel provides a catalog with has a ton of great information for tooling. The catalog includes every little detail about every Camel component, EIPs, data formats, languages, and much more.

I have long wanted to have a little plugin for IDEA (and also Eclipse if possible) for code assistance to setup Camel endpoints - in other words, having ctrl + space to show a list of Camel options you can use on any given Camel endpoint.

Sidestory begins ...
So in the darkness of the night I found myself back in Intellij IDEA plugin land. It was a long long time since last time I hacked on a IDEA plugin. It was so many years ago I cannot remember exactly, but it was around 2002. I created a little plugin called Generate toString which would generate nice toString methods for your POJO classes, like you can generte equals/hashCode etc. Over the years that followed I maintained the plugin and upgraded it for newer IDEA versions which would often break the plugin, or they have moved/changed their APIs. Back then the plugin API was hardly documented, and there was no source code of the editor itself, so it was no fun to try to figure out how to get it to work again, or how to use some of  the existing IDEA dialogs etc. But in the end it was possible, and for a few dialogs I actually had to build it myself using Java Swing etc. The plugin later found a new home at Jetbrains where they took over and provides the plugin out of the box in IDEA. Thanks Jetbrains. You make the best editor on the planet. 
You can read more about this story in the following blog posts: Fast forward to 2016 and I was back in somewhat familiar waters, the AST model is still named PsiSomething.
... sidestory ends.

However doing a plugin that hooks into the Java language of IDEA took a while to find out, because I was walking down the wrong path, trying to find an extension-point about smart completion. 

So instead I looked at some of the out of the box plugins as you can find their source code, and eventually found a plugin that hook into the Java language which took me down the right path.

So after a while I got something working, which was marvelous to see that the smart completion suggestion list included the Camel endpoint options for the given component.

On christmas morning I hacked some more, and posted a tweet with the first screenshot

Today on the 25th December I do have a bit more time as well to polish up the code and to publish it on github. 

I have created a new project on github where we can hack on the code to make the plugin awesome and great. The intention is that the code eventually will be donated to Apache Camel. But for now we can keep it separated so its easier because there is only the plugin code, and not all the other Camel source as well.

You can find more details on the github page, where there is instructions how to try / run and build the plugin. There is also a issue tracker with tickets for stuff we need to work on.

Anyone is welcome to help with the plugin.

Sadly I don't have so much time currently to justify spending days hacking on the plugin, even thought it would be really fun. I have to focus on completing the Camel in Action 2nd edition book. I am 85% complete with the microservices chapter, and then have another chapter to complete as soon as possible in the start of 2017. However I am also a human whom want to have a bit fun hacking so I will hack a bit from time to time on the plugin.

A shameless plug for the book, there is a 40% discount code during the holidays.

The discount code is camiach(40% off Camel in Action, Second Edition, all formats, expiration: January 7, 2017)

To finish this blog post here are the latest screenshot of the Camel IDEA plugin in action:
Smart completion to present possible Camel options

The plugin also supports smart completion for the values, for example an enum based option shows which choices there are (and which one is the default if there is a default value)

Smart completion for enum values


Scratsh said...

That's great to provide specific Camel tooling on a larger set of IDEs.
I just want to share that Fuse Tooling and Forge Tooling are already providing a larger support and leverage the Camel catalog.
There is no auto-completion in editor because the focus was to provide a more advanced UI integration. All catalog informations are displayed in forms in properties view or wizards. They also provide validation on the fly.
I hope that we will be able to leverage this initiative of providing code-completion in editor by using language Server Protocol, which will allow an even larger set of IDEs providing Camel specific tooling.

Claus Ibsen said...

Yeah I hope Jetbrains will support LSP as well

I logged a ticket

This little kind of tooling with smart completion is something that benefit all IDEs whether its Eclipse, Netbeans, IDEA, and also web based such as Eclipse Che.

And LSP is a way of archiving this.

But that said, I think Fuse Tooling should start adding similar smart completion like we are doing for IDEA. We can later try to refactor some of the touch points we do with IDAE to some SPI api which we can then add implementations for IDEA and Eclipse separately so we can potentially reuse this shared logic in both editors.

But for now we move on and have some fun hacking on the little IDEA plugin.