Java on Visual Studio Code Update – May 2020

Yaojin Yang

Yaojin

Welcome back to the May update of Java on Visual Studio Code.

Your satisfaction continuously motivates us delivering the best product for you. Therefore, whatever it is a new feature or an enhancement, we hope you like it. In this update, we will show enhancements on Java side that make the product more friendly and also answer a frequently asked question. On to the update.

Display Java language level on status bar

As Java evolves, developers need deal with language level. Today, VS Code applies language level for your project based on project setting. As an enhancement, now VS Code’s status bar displays the language level directly, so no need open your project file to look for it anymore. When you click the language level on status bar, it will take you to “java.configuration.runtimes” setting, where you can configure your JDK settings. To get the benefit of this enhancement, you need the latest version of Language Support for Java extension and set active editor tab to a “.java” file.

Image language level

Refactor package name

Renaming a folder in the explorer view now triggers package refactoring. At the 1st time, you’ll be prompted to select either always automatically apply or always preview before apply:

Image Refactorying package

The behavior is controlled by “java.refactor.renameFromFileExplorer” in your preference setting with below options:

  • never: Don’t enable refactoring for rename operations on File Explorer.
  • autoApply: Always automatically update the imports and package declarations.
  • preview: Always preview the changes before applying.
  • prompt: Ask user to confirm whether to bypass refactor preview.

Attach debugger by process ID

Debugger extension now supports Attach by Process ID. To work with this new capability, you need the latest version of debugger extension, and add a debugger configuration with “java: Attach to Process” option. When run debugger, you will be promoted to pick a debugging process to attach.

Image attach to process

Other enhancements

  1. Command “Create Java Project” now allows you to select creating a Java project with Maven support (as long as the Maven extension is installed) or a project without any build tools.
  2. A new argument of “sourcePaths” supports specifying source path as part of your customer configuration for running your tests. You can find the argument under “java.test.config” in your preference setting.
  3. A new command of “Import Java projects in workspace” allows you to add a module into an opened project without restarting window.

FAQ: generate getters & setters in bulk

Many users have asked us how to generate getters & setters in bulk. Actually, you can easily find the option of bulk generation under “Source Action” by right-clicking your .Java file.

Image getter setter

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.

0 comments

Comments are closed. Login to edit/delete your existing comments