News

Java Devs in VS Code Can Now Ask Copilot for Syntax Rewrites

Count among the many emerging abilities of GitHub Copilot new functionality for rewriting your Java syntax in Visual Studio Code.

The AI-powered code-completion tool, unveiled years ago as an "AI pair programmer," can now rewrite your Java code in Microsoft's open-source-based, cross-platform code editor, thanks to an update of the Extension Pack for Java in the VS Code marketplace, a bundle of six different tools now nearing 27.5 million installs.

Extension Pack for Java
[Click on image for larger view.] Extension Pack for Java (source: Microsoft).

The Insider (Pre-release) version of the pack introduces a new feature, "Rewrite with new Java syntax," which leverages GitHub Copilot, for which a license is needed to use the new functionality.

"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," the dev team explained in a blog post today (June 3) announcing the May 2024 update.

Along with each suggestion, the tool will create an additional CodeLens that shows what the solution is and what needs to be improved. Devs can directly click on the CodeLens to 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," the team said

Several updates were also made for Spring development, which comes in the Spring Boot Extension Pack extension (2.4 million installs), including:

  • JPQL syntax highlighting: The Spring pack's Spring Boot Tools extension now supports JPQL syntax highlighting, improving the readability of JPQL query strings in both @Query annotations and named query property files.
    JPQL Syntax Highlighting
    [Click on image for larger view.] JPQL Syntax Highlighting (source: Microsoft).
  • Add Starters directly from within "pom.xml" files: The team added a clickable hint in the dependency section of pom.xml files, making it easier to add Spring Boot starter modules directly from within the file.
  • Dashboard shows active profiles: The Spring Boot Dashboard in the pre-release version now displays the active profiles of a running Spring Boot application alongside the port it is running on.
  • Automatically convert application properties to YAML and back: New actions automatically convert "application.properties" files to YAML format and vice versa, simplifying the switch to a developer's preferred format.
  • Performance and footprint improvements: Improved indexing infrastructure increases the capacity to index Java source files from 6.5k to 60k within the same memory constraints, doubling the performance of Java source file reconciliation for Spring-specific validations.

Other new functionality highlighted by the team in the May 2024 update is improved testing coverage.

"In April, we released the Testing Coverage feature for our Test Runner extension in Stable version on Visual Studio Code," the post said. "After release, we have received lots of positive feedback. However, we also received questions on how to use the feature. One popular question was around how coverage data can be reset for every execution."

In response to that feedback, the extension's JaCoCo coverage tool will now append the coverage data by default. Tweaking a setting will reset the coverage data before every coverage execution.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube