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 for Converge360.

comments powered by Disqus

Featured

Subscribe on YouTube