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
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
- Enable search artifact by groupId and/or artifactId when auto completing dependency.
- 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
- 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.
- 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.
- Add
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.
- Learn more about Java on Visual Studio Code.
- Explore our step by step Java Tutorials on Visual Studio Code.
0 comments