October 18th, 2019

Java on Visual Studio Code October Update

Xiaokai He
Senior Program Manager

Welcome to the October update of Java on Visual Studio Code! This month, we’re bringing some new features for code navigation, code actions and refactoring, code snippet along with Java 13 support. There’re also improvements in debugger, maven, checkstyle and Test Runner. Please checkout and let us know what you think!

Code Navigation

Go to super implementation
You can now keep track of class implementations and overriding methods by clicking the Go to Super Implementation link when hover.

See the code navigation in action.

Code Actions

A couple new code actions have been added to VS Code for Java recently.

Create non existing package

Now when your package name doesn’t match the folder name, you have the options to either change the package name in your code, or move the folder in file system (even when the destination folder doesn’t exist yet).

Add quick fix for non accessible references

This quick fix helps you resolve non accessible reference

Automatically trigger auto-import on paste

If you paste blocks of code that contain references to classes or static methods and fields that are not yet imported, VS Code now can automatically add missing imports. The new feature is enabled via the java.actionsOnPaste.organizeImports preference in VS Code preferences. If true (the default value), triggers “Organize imports” when Java code is pasted into an empty file.

Refactoring

Inline refactoring

The Inline refactoring lets you reverse the refactoring for a local variable, method, and constant.

Convert for-loop to for-each loop

The enhanced for-loop is a popular feature. Its simple structure allows you to simplify code by presenting for-loops that visit each element of an array/collection without explicitly expressing how one goes from element to element.

Convert anonymous class to nested class

This refactoring allows you to convert an anonymous class into a named inner class.

Deprecation tags for symbols and completions

Java extension now shows source code that references deprecated types or members with a strike-through line.

Code Snippets

Now VS Code Java supports server side code snippets, which means it will provide more code snippets options in a context aware way. You can also also see more detailed information during the preview of code snippets during selection.

Java 13 support

Java 13 is out and VS Code is ready for it. It supports Java 13 through latest Java Extension. For developers use Java 12 with preview features, you will need to upgrade to JDK 13 to keep working with them.

Debugger

Show Run/Debug when hover

In case you don’t like the Run/Debug button on the Code Lens of your main method, but still want easy access to the functionality, you can now configure to disable the Code Lens but still accessible by hover.

In this release, we’ve also made a lot of improvements in error handling and message to help user resolve issues during debugging. One example is to add fix suggestions when a build failure occurs when launching the program.

By clicking Fix... a list of suggestions would be provided.

A more detailed troubleshooting guide is also provided.

Maven Support

Resolve unknown type

Maven extension now supports searching Maven Central to resolve unknown type in your code. You can achieve this easily by clicking the link in hover.

Other improvements in Maven extension includes

  1. Enable search artifact by groupId and/or artifactId when auto completing dependency.
  2. Add inline action buttons in Maven explorer. Add icons for Maven explorer items.

Checkstyle

Enhanced setting configuration command

Checkstyle: Set the Checkstyle Configuration command will now detect potential Checkstyle configuration files and list them. You can also provide a configuration file by directly writing a URL in the input box now.

Setting checkstyle version support

A new command Checkstyle: Set the Checkstyle Version is added to the extension. It supports:

  • List the latest Checkstyle version from main repo.
  • List all the download versions.
  • List all the supported versions.
  • Mark the currently used version with a check symbol.

When the version is too high (with breaking changes) for a user defined checkstyle configuration.

And when the version is too low (with new features) for google_check.xml fetched from checkstyle master branch.

Other improvements

  1. Provide more granularity of progress of loading project. We’re working on making the language server more transparent with what it’s working on behind the scene.
  2. Test Runner updates
    • Add java.test.saveAllBeforeLaunchTest setting to specify whether to automatically save the files before launching the tests.
    • Add java.test.forceBuildBeforeLaunchTest setting to specify whether to automatically build the workspace before launching the tests.

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.

Author

Xiaokai He
Senior Program Manager

Xiaokai is the program manager working on Java developer tools and services at Microsoft. He’s currently focusing on making Visual Studio Code great for Java developers, as well as supporting Java in various of cloud services in Azure.

0 comments

Discussion are closed.