A first look at Copilot in Eclipse

Microsoft announced the public review of Copilot for Eclipse.

I immediately tried that in one of my Java projects.

Use the “Market Place” to install Copilot in Eclipse:

Once you click install, you must “trust” the contents to be installed:

Once installed and restarted Eclipse, you must authenticate with your GitHub Copilot account by clicking on the Copilot icon in the bottom right:

This will open a dialog with a code you must insert in the opened web page. Note the button to automatically copy the code in the clipboard and open the browser:

In the browser, you’ll have to authenticate in your GitHub account and paste that code (which should be in the clipboard). If everything goes fine, the webpage will tell you that everything is in place to start using Copilot in Eclipse, and Eclipse should show the corresponding success dialog:

I started to do some experiments.

I have this test code where Eclipse shows a warning on the “FileOutputStream” because the resource is not closed. Of course, I know how to solve that: use a try-with-resource block. But let’s ask Copilot.

I opened the file and the Copilot chat (still using the button in the bottom right toolbar):

Here’s what I asked:

I experienced a possible UX design problem here: I didn’t see any answer. I had to enlarge the view to see where Copilot wrote the answer (note in the same part where I wrote the question):

The answer is wrong: that is not the cause of the warning, and that is not the solution.

I tried to be more explicit in the question, detailing the message of the warning:

OK, this time, the answer is correct!

I tried to use the toolbar button to insert the solution in the editor:

However, instead of replacing the interested part, it just inserted that code starting from the editor’s cursor: a disaster of course 😉

Instead of manually copying and pasting the solution, I experimented with Copilot code completion. As I said, I know that I must use a try-with-resource. I converted the lambda expression into a block and typed “try (“. The grey code is suggested by Copilot:

I don’t know whether this is due to the selected solution in the chat or to my previous question, but the proposed code is correct! Press TAB to accept that. Then, I manually removed the duplicate original line. Maybe the original line has been used to propose the correct completion.

For the other part in the same file with the same warning, the completion was done in two steps: I started typing as before, accepted the initial partial condition, went on typing some more, and got the rest of the correct completion:

I also tried asking how to move the Maven project to Java 21 by opening the POM and using the chat:

The answer is correct, but honestly, the question was relatively trivial 😉

Unfortunately, Copilot code completion in the POM file does not work well: it tends to interfere with the default content assist in the POM; I haven’t found a way to use that properly.

Other valid key bindings:

  • Ctrl + Alt + / to manually trigger Copilot’s code completion;
  • Ctrl + Right to accept the next word in a suggestion.

Let’s see for future updates 🙂

In the meantime, I’ll try to experiment with that further.

5 thoughts on “A first look at Copilot in Eclipse

  1. Alexis Drogoul

    Hi, I tried it too, and I must say that I have been quite impressed by the quality of the code produced. Not everything is perfect (and there are sometimes “hallucinations” happening, e.g. proposal of non-existing classes, etc.) but so far so good. The only downside is that the number of “free” completions is quite low — and I havent been able to understand how to activate the “academic” scheme for registration.

    Reply
  2. Sheng Chen

    Hi Lorenzo,

    Could you give more details about ‘Unfortunately, Copilot code completion in the POM file does not work well: it tends to interfere with the default content assist in the POM’? What kind of conflict are you facing?

    Reply
    1. Lorenzo Bettini Post author

      Dear Sheng, the problem in the POM editor is that as soon as you start typing in most contexts, the default code completion kicks in, hiding what Copilot would suggest. Moreover, even when the default code completion kicks in, something in the editor removes the suggestion provided by Copilot, unless you’re not fast enough to look at it and accept it.

      Reply
      1. Sheng Chen

        I see, yes I can reproduce the issue. When the content suggestion widget appear, the inline completion from copilot plugin disappear.

        Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.