ABAP with Github Copilot – version 2

Treatment in progress…
You're done! You are in the list.

In that article, we saw how to use Github Copilot. However, we were using an unofficial extension, since no official one existed. Github now offers us its official extension.

This article is a quick update on how to configure Github Copilot with ADT using the official extension.

Installing and configuring the extension

  • Access the Eclipse Marketplace and install GitHub Copilot
  • Login to your Github account

2. Using the extension

  • Autocompletion

Github Copilot’s first feature is code autocompletion, which works like a peer programmer, offering you code on the fly according to what you’re developing.

Here, for example, it suggests code according to the comment being written:

By pressing “tab”, the code is accepted.

  • Github Copilot Chat

You can choose the model you want to work with (here, GPT-4o):

Then, Github Copilot provides its Chat containing various functionalities:

*Create a unit test class

*Correct problems in the code

*Simplify the code

*Explain the code

*Document it

Basically, these actions are performed on the class/program we’re on (here on the image, z_test_copilottestclasses), but it’s entirely possible to add additional references:

So, if the code to be analyzed calls methods from other classes, you can add the latter so that Github Copilot can also take them into account.

Let’s now use these features in the code we wrote earlier:

1/ Fix

In our case, we can see that the code previously proposed contains errors (method divide_number doesn’t exist, syntax errors, etc.). We therefore ask Copilot to correct it:

By copying and pasting the code proposal (and adjusting certain parts of the code manually), the class is now functional.

2/ tests

We’re going to ask Github Copilot to create a test class

With a few corrections, the test class is functional

Conclusion

This example shows how to use the official Github Copilot extension in Eclipse with ABAP.

Even if manual actions are still necessary to correct the proposed code, the quality of the code increases day by day, and saves a lot of time, for example when writing unit tests.