The Visual Studio Code team released the Java optimization update for November, which brought new code editing features such as suffix completion and optimized organization imports. Also, the debugger got a nice update with support for a new feature called “Step Into Target”. In addition, some visual enhancements have been made to the Spring components.

According to official statistics, there are two million Java developers on Visual Studio Code.

Suffix completion

Suffix completion, which adds code snippets after the expression you just typed, is a popular feature in JetBrain products, and VSCODE also provides this feature by community request.

The currently supported suffix shortcuts are as follows:

hot key template content describe
cast ((SomeType) expr) Convert an expression to a new type
else if (!expr) Create a negative if statement
for for (T item : expr) Create a for statement
fori for (int i = 0; i < expr. length; i++) Create a for statement that iterates over the array
forr for (int i = expr.length-1; i >= 0; i–) Create a for statement to iterate through the array in reverse order
if if (expr) Create an if statement
Null if (expr != null) Create an if statement and check if the expression does not resolve to null
null if (expr == null) Create an if statement that checks if the expression resolves to null
sysout System.out.println(expr) Send the affected string to a System.out.println(..) call
throw throw expr throws the given exception
var T name = expr create a new variable
while while (expr) {} Create a while loop

Optimize for Organize/Clean Import

Organize Import is one of the most common operations for Java developers in the code editing process. This time, some optimizations have been made for this scenario.

  • Remove all unused imports in QuickFix

This option has been added to QuickFix (light bulb icon), so you can delete all unused imports at the same time.

  • QuickFix adds all missing imports

If there are unresolved classes, you can also use QuickFix to add all missing imports and select the class from the dropdown

  • Add all missing imports from the Source Action menu

Another way to add all missing imports is to right-click to bring up the menu and select “Source Action”, where you can find “Add all missing imports”.

Debug new functions – Step Into Target (directly step into the function)

Debugging statements containing many nested function calls can be cumbersome, and the November debug adapter protocol supports a “Step Into Target” feature that displays a UI for stepping directly into a specified function.

The latest Java plug-in has started to support this feature. When debugging stops on a statement, you can choose “Step Into Target” from the menu to step directly into the function or target of interest.

Diagram of Spring components

Added some visual enhancements to the editing area so that developers can better identify Spring components and interact with the Spring Boot Dashboard.

With the latest version of the Spring Boot plugin package, you’ll find green icons next to Spring beans and Endpoint mapping in the editor area. When hovering over these components, a tooltip will pop up with some details about this component and a link to open it in the Spring Boot Dashboard.

To use all the features above, download and install the Extension Pack for Java on Visual Studio Code.

Spring developers can download and install Spring Boot plugin packageget an exclusive development experience related to Spring Boot.

#VSCode #November #Java #optimization #functions #suffix #completion #Step #Target #Programmer #Sought

Leave a Comment

Your email address will not be published. Required fields are marked *