Rewriting your Java code with Copilot-based suggestions in VS Code

Published: 27 June 2024
on channel: Microsoft for Java Developers
887
10

We’re excited to announce an exciting update for Java developers on Visual Studio Code. In the Insider (Pre-release) version of our Extension Pack for Java, we’ve introduced a new feature: “Rewrite with new Java syntax” with Copilot! This feature integrates seamlessly with GitHub Copilot, so developers will need a GitHub Copilot license to access it.

Here’s how the feature works, on your Java class, a new CodeLens text will appear above the name of the class: “Rewrite with new Java syntax“. Once the user clicks on this, it will trigger an inspection on the current Java class. Once the inspection is complete, Visual Studio Code will show several improvement suggestions and point users to the location.

For each suggestion, additional CodeLens will appear and shows what the solution is (and what needs to be improved). The user can directly click on the CodeLens and this will bring up the GitHub Copilot inline chat dialog. The user can then see the code diff, and will be offered the choice of “Accept or “Discard”. If the user accepts the suggestion, then the workflow is over. Let’s see the first example where the for-loop can be refactored using IntStream.

This feature aims to leverage AI to offer helpful suggestions and seamless refactoring for Java developers for their code. We hope this can greatly boost developer’s productivity. If you have any feedback about this feature, please fill out our survey: https://aka.ms/ai-survey

To use this feature, developer needs to install both Insider (Pre-release) version Extension Pack for Java and GitHub Copilot extensions. (with a GitHub Copilot license).

Get started now with our sample: https://aka.ms/ai-sample


On this page of the site you can watch the video online Rewriting your Java code with Copilot-based suggestions in VS Code with a duration of hours minute second in good quality, which was uploaded by the user Microsoft for Java Developers 27 June 2024, share the link with friends and acquaintances, this video has already been watched 887 times on youtube and it was liked by 10 viewers. Enjoy your viewing!