Java on Visual Studio Code November Update

Xiaokai

November 15th, 2019

Welcome to the November update of Java on Visual Studio Code. Starting this month, we’re moving to a new home called Java at Microsoft, where you can find not only updates about Java on Visual Studio Code, but also other news and insights for Java development with other Microsoft tools, Azure services and OpenJDK. You can subscribe this blog by following @JavaAtMicrosoft.

In this update, we’d like to share some improvements we’ve made for code editing experience, more code actions, Java 13 support for Gradle projects and new features in Test Runner and Checkstyle extensions.

Code Editing

Provide better symbol details for the completion proposal

Originally, we only show javadoc for the auto completion proposal, with a simple header. To provide more detailed information and help you choose the right item, we’re now adding more detailed symbol info to the header, and hopefully helps you find the right choice faster.

Compare the previous and new information available for field

Method

Type

Package

Report unused code as unnecessary

We’ve added faded effect to unused code. So now it’s easier for you to spot them.

Code actions

Add ‘final’ modifier where possible

In Java, there is a practice of declaring every variable (local or class), parameter final if they really are. If you like to apply this to you code, you will find this code action useful.

Remove unnecessary cast

This code action will remove unnecessary cast in your code. (Note: the associated compiler warnings is not enabled by default. To enable this feature, you can manually append the compiler warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning to the file .settings/org.eclipse.jdt.core.prefs )

Other improvements

Support Java 13 for Gradle project. Gradle 6.x projects with Java 13 are now supported! We’ve also upgraded embedded maven version to 3.6.2 as well. Expose Invert Condition code action which automatically find the boolean expression around your caret so you don’t need to select the entire expression to trigger it. Add text selection support in code snippet so after inserting certain code snippet, VS Code will select/highlight certain code where you will likely to take action thereafter. Java Test Runner now supports module path for your modular Java project. It also added a new ‘CollapseAll’ button for you to easily collapse your test cases in test explorer. Checkstyle for Java added support for custom checkstyle modules. Now you can set any 3rd-party modules for checkstyle using its path. For example, after using the below configuration, you can add <module name="SingleBreakOrContinueCheck"/> or <module name="com.github.sevntu.checkstyle.checks.naming.SingleBreakOrContinueCheck"/> to checkstyle.xml to leverage those checks.

"java.checkstyle.modules": [ "${workspaceFolder}/src/main/resources/sevntu-checks-1.35.0.jar" ]

Sign up

If you’d like to follow the latest of Java on VS Code, please provide your email with us using the form below. We will send out updates and tips every couple weeks and invite you to test our unreleased feature and provide feedback early on.

Try it out

Please don’t hesitate to give it a try! Your feedback and suggestions are very important to us and will help shape our product in future.