The current Bndtools 7.1.0-SNAPSHOT Eclipse Plugin has recently received a number of new quick fixes. Before we finalize them, it would be nice to get some feedback how they work in practice.
Without further ado, let’s dive into them.
Binary, Hex, Separators
Maybe it is me, but in the embedded world hex and binary are often used. So you an now you can easily convert decimal to hex and binary and hex and binary to decimal.
Versions
Originally I added a version bump in a special refactoring for the package-info.java
file. However, then I realized this could also be useful in other source files.
Strings & Text Blocks
Make string upper case or lower case; convert strings to text blocks and text blocks to strings
Constructor Assignment
Methods and constructors get a quick fix to assign a parameter to a field. However, this parameter is private
. Personally I do not think class private is very useful (package private suffices for me and it makes testing easier). Then again, I am going out of my way nowadays to make fields final. So I added a fix to assign a parameter to a final
field.
Turning Private into final
As stated, I really don’t like final. I know it helps to find unused fields but that is just a limitation of the compiler, you could also provide this information on package level. Less is more and private takes real estate and imho provides no value. Therefore a quick fix to change private
field to final
!
Export a package
If you have a package-info.java
file, you can now export it.
If you do not have a package-info.java
file, you can now create it with File/New
.
Declarative Services
You can now add all the Declarative Services/Component annotations with quick fixes.
Gogo Commands
In a recent version Gogo added an annotation @GogoCommand that simplifies making a component that can provide Gogo commands. The quick fixes for the Gogo Command assume that methods with the @Descriptor annotation are commands. It will assemble the hard to maintain function
annotation field for you.
It can also add a @Parameter annotation all filed in:
Oh, yeah. It can also clean up:
Selection
You can now expand the selection to the type the cursor is in. If the cursor is on a method declaration, it will select the whole method. If it is on a class declaration it will select the class. This makes it simpler to copy a part of the source code without having to chase the proper closing bracket.
Open AI
Unless you’ve been living under a rock you are aware that AI is going to revolutionize the software world. I already had been dabbling in. As an experiment, I’ve added an AI dialog to the quick fixes. It will copy the current node to a OpenAI dialog and then allows you to tell it to change the code.
The OpenAI quick fix is only available if you set an OpenAI API key. This can be done with the following bnd
command:
bnd settings openai.apikey=sk-...hqyl
Concluding
This is preliminary code. Quick fixes are good when you need them but unnecessary quick fixes become annoying when they are in your face. For this reason, I need feedback how they work in practice.
The OpenAI stuff is highly experimental. I am aware there is another AI assistant available for Eclipse now but I think it is worth to expand the usage of AI to bndtools. The current implementation is very much generic Java but I think AI could really help with debugging the resolving and doing things in the bnd file.
Again, feedback on this is needed. I am open to spend some significant time to make this a really cool tool if I get some engagement.
Last point. I’ve spent significant effort to make the refactoring a lot easier. If you’re interested in quickfix/refactoring support for your company annotations, let me know. I am looking for some new customers