Java on Visual Studio Code Update – January 2020
Happy New Year and welcome back to our first update of Java on Visual Studio Code in 2020.
In this update, we’re introducing the long-waited “Call Hierarchy” support along with some Visual Studio Code UI updates which will benefit Java developers a lot. At the same time, new features are also introduced to Debugger and Test Runner. We will also share some other improvements including performance in this post. On to the update.
A call hierarchy view shows all calls from or to a function and allows you to drill into callers of callers and call of calls. Just right-click on the functions and click
Peek -> Peek Call Hierarchy.
UI Improvements for Java
Compact folders in Explorer
In the File Explorer, we now render single child folders in a compact form. In such a form, single child folders will be compressed in a combined tree element. Useful for Java package structures, for example.
explorer.compactFolders controls this behavior. By default, this setting is turned on.
More predefined filters were added to the Problems panel. In addition to filtering by regular expression, you can now filter problems by type (errors, warnings, and information) and also see problems scoped to the current active file.
In addition, you can also show current problem in status bar to see the summary of the selected problem in the active file without any additional keyboard or mouse gestures.
Visual Studio Code Java now supports ‘Data Breakpoint’, so you can have the debugger break when a variable change its value. See the illustration below
We’ve also improved the run/debug experience. You can see the new
Debug buttons in the debug panel, and you can also easily press
F5 to start a debugging session.
By default, the run configuration (aka.
launch.json) won’t be persisted in your workspace. If you would like to save it, you can click the button “Create a
launch.json file” in the Debug viewlet.
If you have installed our Java Test Runner extension, you may notice that the new Test Explorer now shows the test status/results directly so you will go to the report only when more detailed information is needed.
More transparent build status
As you code in Visual Studio Code, the language server is building your workspace to provide you the necessary language features. Now you can see the detailed build task status and understand what’s happening behind the scene by simply clicking the language server status icon.
To make coding in Visual Studio Code more enjoyable, We’ve made 2 enhancements to reduce the latency between typing and completion suggestions
- Remove duplicate calls of time consuming APIs.
- Limit completion results via
java.completion.maxResultspreference. By default, it’s limited to 50 completion results. You can change it to 0 if you’d like to see the full results list which might negatively impact the performance. We’re also working on more updates to further improve the experience, such as keybinding to load the full list and context aware search scope.
The latest updates also brings a lot of other enhancements for Java experience in Visual Studio Code.
- Code actions
- Support jump to definition on break/continue
- Sort code action suggestions by relevance.
- quickfix to correct access to static elements.
- Support to “Collapse All” in Maven explorer.
- Support to specify the project for command “Maven: Add a dependency”.
java.maven.updateSnapshotspreference to update snapshots/releases for maven projects.
java.project.referencedLibrariespreference to add jars to classpath. Other extensions can also use this API to update classpath.
We’d also like to thank Ondrej Musil to contribute to extension API. In order for Visual Studio Code Java to support more features, it’s important for us to make sure the core language server is extensible.
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.
- Learn more about Java on Visual Studio Code.
- Explore our step by step Java Tutorials on Visual Studio Code.