Testing JetBrains AI Assistant

Elena Guidi
SEAT CODE
Published in
5 min readJul 4, 2024

In Seat Code, every developer has now access to JetBrains AI assistant plugin. I’ve never used it before, but I am familiar with Chat GPT.
So, let’s see it in action!

Disclaimer: I’m going to test it with Kotlin.

Table of contents:

Getting started

There are two different ways to interact with the AI: the chat and the code actions.

THE CHAT

Starting with a quite simple chat question about the project: What does the plugin know about a specific project I chose?

The answer is correct and focused in technologies, and when asking specifical aspects about the domain, it was able to give a very general information (private information, no screenshot provided 🫢​).

THE CODE ACTIONS

To activate the AI from a code file: right click -> AI actions (although there are other options to access it).

Generate code

Probably one of the most interesting parts is the ability to generate new code. In my opinion, it would be interesting to know if it’s able to take into account already existing models.

Prompt: “Create a function that accept a boolean “enabled” value and return a list of GameEnums with this value”

Result: It’s good, but we have to consider it was a quite simple request.

In the prompt line you can accept the change, specify more about your request or regenerate the result.

Explain Code

We can ask to explain the function that it has created using the explain code action

Result: It opens the chat to explain the function. It provides a very detailed explanation starting with the enum class we are using.

It continues explain the functions we are calling, values(), filter { } and its condition.

Write Documentation

As the description is very well done, I do expect good results with the javadoc automatic generation. Also in this case we are going to use the AI actions.

Result: clean and clear. For me, it’s a 10/10!

Create unit tests

In this case, we do not have an action to do it directly, but we can use the write code action or the chat to do it. I’m going with the first option.

Prompt: “create unit tests for all cases”

Result: — not exactly as expected — it has created the code without taking into account the existing code in the file. The Merge feature from the AI could be improved as it is not adding the imports at the beginning of the code.

Anyway, in this case I’m going to move the code manually.

I’ve moved the fun to a companion object:

And the tests in the new class:

I like the tests: it has taken into account the not null, the size and the elements. Val names are clear and, last but not least, tests are working correctly:

Refactor Suggestions

In this case we also have two options:

  1. when we are renaming something, we will also automatically see the AI suggestion

2. Using the specific action: this option will open the chat for the code explanation. In this case, there is a “see diff and apply” button to move automatically the change to the file

Fun fact: the IA wrote the function and now it’s saying to itself that it is improvable 😂​

Commit Message Suggestions

A pain for most of programmers: commit messages. IA is going to help us by generating suggestions.
We can use with the logo button in the commit tab

The suggestion is a bit long in my opinion, but surely clear.

But it is possible to modify the prompt to adapt itto our necesities (for example to follow some standard). I’m going to test different prompts to find the best solution for me.

Conclusion

I’ve been exploring this AI for several days now, and I still find it challenging to achieve exactly what I need.

The main benefits:

  • the integration with the IDE that allows you to use it without switching to an external browser or application (this helps not loosing the focus)
  • the compliance with company confidenciality rules
  • improves speed in certain tasks as documentation, commit and test writing or in onboarding in a new project as code explanation is very good

Given its integration with the IDE, I was hoping for a more straightforward way to utilise other parts of the code as existing functions and models in refactors.
If you have any tips or tricks for using this AI more effectively, please share them in the comments. I’d love to give them a try!

If you want to learn more, here there is the official documentation: https://www.jetbrains.com/help/idea/ai-assistant.html

--

--

Elena Guidi
SEAT CODE

Hi! Italian and software developer at @seat_code 💕​🐈​ Content you can find here: Kotlin backend, infra, React code, green computing