Java on Visual Studio Code Update – April 2020
Welcome back to the April update of Java on Visual Studio Code.
In this update, we will show you the effect of our latest performance improvements. You can also see new Java 14 support and semantic highlighting. We’d also like to show you how to easily create new Java class, perform rename refactoring from file explorer and preview the proposed changes before committing. On to the update.
If you’ve followed our update last month, we’ve enabled parallel dependency download to improve project loading performance as well as syntax mode. In this release, we’ve enabled syntax server for all project. You will be able to see the big difference on how fast you can do code navigation after opening a new project below.
The idea is since building and indexing the project takes a long time, it’s annoying for our developers to wait. With the help of syntax server, instead of waiting for all the dependencies to be downloaded, you can use the features listed below right away:
- Syntax Highlighting & Syntax Errors
- Code Navigation (Go to Definition, etc.)
- Documentation (Hover to See Javadoc)
- Code Structures (Outline, Folding Range, etc.)
Once the full language server is ready, the syntax server would be turned off automatically.
Java 14 Support
Java 14 is out and is supported by the language server now. To use the preview features, you may need to modify your project settings.
Maven – modify
sourceCompatibility = 14
options.compilerArgs += '--enable-preview'
jvmArgs += "--enable-preview"
Note: if you are modifying a project that was already opened in VS Code before, you may need to force clean the workspace and reload. To do so, run command
Java: Clean the Java language server workspace.
As you read and write code, syntax highlighting is a very important feature which allows you to read code more efficiently. However, since syntax highlighting colors the text based on lexical rules, it’s difficult to make it accurate for all scenarios. This month, VS Code Java brings semantic highlighting which enriches the syntax coloring based on symbol information from Java language service that has the full understanding of the project. Below is just one example, left is the behavior after enabling semantic highlighting and right is the one with only syntax highlighting.
You can also find more details of Java semantic highlighting here.
Create New Class from File Explorer
Here to mention a new way of creating a class. Now, when you create a
.java file in the File Explorer, the language server will automatically generate the class body, and fill the package info for you:
You can also create
record in the same way.
Rename Refactoring and Preview
Now you can do rename refactoring from file explorer. And for each refactoring, you now have the option to preview the changes before committing it to your code base.
We’re also working on other refactoring, such as move from the file explorer, please stay tuned.
The latest updates also brings a lot of other enhancements for Java experience in Visual Studio Code.
- Improved support for Gradle projects
- Improved organize import to resolve static imports and asterisk (*) wildcard character.
- New extension from Red Hat, Community Server Connectors brings better support for Apache Felix, Karaf and Tomcat.
- Skipped tests can be toggled out in the test report
- New documents are added to our official site.
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.
- Learn more about Java on Visual Studio Code.
- Explore our step by step Java Tutorials on Visual Studio Code.