vscode-java-pack v0.7.0发布,vscode写java又方便了一个台阶

What's new in Visual Studio Code Java?

April 2019

Welcome to the April 2019 release of Java Extension Pack. This document aims to recap the features, bug fixes around Java language support in between releases. Here are some of the key highlights:

The release notes are arranged in the following sections related to VS Code Java focus areas. Here are some further updates:

Code Editing

Java 12 Supported

Java 12 is supported now. To use the experimental language features like the new switch statement, add the following settings to pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>12</source>
                <compilerArgs>--enable-preview</compilerArgs>
            </configuration>
        </plugin>
    </plugins>
</build>

Better Performance

With the latest release of Language Server for Java by Red Hat, the performance of dealing with larger amount of source files is improved. When you have many open files in your editor, the language server is more responsive.

More Source Actions

Resolve Ambiguous Imports

To deal with ambiguous imports, you now have a dropdown list to pick the right one. The code line with the unresolved type is also presented to you to help you decide.

Resolve Ambiguous Imports

Override/Implement Methods

With the new source action, all the candidates are presented to you with a checklist. Then you can decide what to override or implement.

Override/Implement Methods

Generate hashCode() & equals()

Now hashCode() & equals() can be generated with default implementations. All the non-static member variables are listed, and you can customize the generated code using the check list.

There are two options for you to customize the generated code:

  • If you use Java 7+, you can set java.codeGeneration.hashCodeEquals.useJava7Objects to true to generate shorter code which calls Objects.hash and Objects.equals.
  • You can also set java.codeGeneration.hashCodeEquals.useInstanceof to true to use instanceOf operator to check the object types instead of calling Object.getClass().

Generate hashCode() & equals()

Generate toString()

toString() can also be generated with the new source action. Customization is also possible with the check list of all the member variables.

Generate toString()

Convert to Static Imports

Last but not least, you can now convert static functions calls to static imports.

Convert to Static Imports

Folding Range

Folding range allows you to fold or unfold code snippet to better view the source code.

Folding Range

Debugging

Display Logical Structure of Collections

The debugger is now showing the logical structure of lists and maps, instead of the physical layout of the collections.

If you prefer the physical layout view, you can go back by setting java.debug.settings.showLogicalStructure to false.

Logical Structure of Collections

Highlight Exceptions in Editor

Exceptions are now highlighted with extra info in the editor window. Before that, you need to hover on the exception to see details. Now the most important info is presented to you right at where it occurs.

Highlight Excpetions in Editor

Go to Definition by Clicking Stack Trace in Debug Console

When there's an exception, you can click on the stack trace to see the definition of the function calls.

Go to Definition by Clicking Stack Trace in Debug Console

Maven

Maven extensions released some interesting features and improvements to improve the productivity.

Debug Maven Goals

To debug Maven goals, just right click on a goal and start debugging. The Maven extension will call the Java debugger with the right parameters. This is handy and super time-saving.

Debug Maven Goals

New Command to Add a Dependency

Maven extension released a new command Maven: Add a Dependency (or maven.project.addDependency) to help add a new dependency to pom.xml. The process is interactive.

Maven Add Dependency

Troubleshooting

JDK Acquisition Guide

If you are experiencing the problem of setting up the JDK, we've got you covered. The JDK Acquisition Guide follows the same logic used by the Java language server to check for a JDK installation on your machine. When the check fails, the guide will automatically show and recommend a JDK distribution that is compatible with your OS and CPU architecture.

JDK Acquisition Guide

Thank You

Here are more changes and bug fixes. Kudos to all the contributors!

Happy Coding!

Visual Studio Code Java有哪些新功能?
2019年4月

欢迎阅读2019年4月发布的Java Extension Pack。本文档旨在概述各版本之间的Java语言支持的功能和错误修复。以下是一些主要亮点:

Java 12支持
更多源操作添加到Java语言服务器
调试器显示的集合的逻辑结构
调试Maven目标变得简单
JDK Acquisition Guide指导您下载和安装Java Development Kit
发行说明在以下与VS Code Java焦点区域相关的部分中进行了安排。以下是一些进一步的更新:

代码编辑
调试
Maven的
故障排除
代码编辑
Java 12支持
现在支持Java 12。要使用新的switch语句之类的实验语言功能,请将以下设置添加到pom.xml:

<建立>
    <插件>
        <插件>
            <的groupId> org.apache.maven.plugins </的groupId>
            <artifactId的>行家编译-插件</ artifactId的>
            <版本> 3.8.0 </版本>
            <结构>
                <源> 12 </源>
                <compilerArgs>  - 使能预览</ compilerArgs>
            </配置>
        </插件>
    </插件>
</建造>
更好的性能
借助Red Hat最新发布的Language Server for Java,可以提高处理大量源文件的性能。如果编辑器中有许多打开的文件,语言服务器的响应速度会更快。

更多来源行动
解决模棱两可的进口问题

要处理不明确的导入,您现在有一个下拉列表来选择正确的导入。还会向您显示具有未解析类型的代码行,以帮助您做出决定。

覆盖/实施方法

通过新的源操作,所有候选人都会向您提供一份清单。然后,您可以决定要覆盖或实施的内容。

生成的hashCode()和equals()方法

现在可以使用默认实现生成hashCode()和equals()。列出了所有非静态成员变量,您可以使用检查列表自定义生成的代码。

您可以通过两种方式自定义生成的代码:

如果使用Java 7+,则可以将java.codeGeneration.hashCodeEquals.useJava7Objects设置为true以生成调用Objects.hash和Objects.equals的更短代码。
您还可以将java.codeGeneration.hashCodeEquals.useInstanceof设置为true,以使用instanceOf运算符来检查对象类型,而不是调用Object.getClass()。


生成的toString()

也可以使用新的源操作生成toString()。使用所有成员变量的检查列表也可以进行自定义。

转换为静态导入

最后但并非最不重要的是,您现在可以将静态函数调用转换为静态导入。

折叠范围
折叠范围允许您折叠或展开代码段以更好地查看源代码。

调试
显示集合的逻辑结构
调试器现在显示列表和映射的逻辑结构,而不是集合的物理布局。

如果您更喜欢物理布局视图,可以通过将java.debug.settings.showLogicalStructure设置为false来返回。

突出显示编辑器中的异常
现在,在编辑器窗口中使用额外信息突出显示异常。在此之前,您需要将鼠标悬停在异常上以查看详细信息。现在,最重要的信息会立即呈现给您。

通过在调试控制台中单击堆栈跟踪转到定义
当出现异常时,可以单击堆栈跟踪以查看函数调用的定义。

Maven的
Maven扩展发布了一些有趣的功能和改进,以提高生产力。

调试Maven目标
要调试Maven目标,只需右键单击目标并开始调试。 Maven扩展将使用正确的参数调用Java调试器。这样既方便又省时。

添加依赖关系的新命令
Maven扩展发布了一个新命令Maven:添加一个Dependency(或maven.project.addDependency)来帮助向pom.xml添加一个新的依赖项。这个过程是互动的。

故障排除
JDK收购指南
如果您遇到设置JDK的问题,我们已经为您提供帮助。 JDK Acquisition Guide遵循Java语言服务器用于检查计算机上JDK安装的相同逻辑。检查失败时,指南将自动显示并推荐与您的操作系统和CPU体系结构兼容的JDK发行版。

谢谢
以下是更多更改和错误修复。感谢所有贡献者!

@snjeza
[Langauge Server]下载java源码lazyily eclipse / eclipse.jdt.ls#979
[Langauge Server]优化编译单元计算eclipse / eclipse.jdt.ls#980
[Langauge Server]优化服务器初始化eclipse / eclipse.jdt.ls#981
@testforstephen
[。调试器]当.class文件打开时,调试控制台不自动完成Microsoft / vscode-java-debug#535
[Debugger]自动缩短命令行“CreateProcess error = 206,文件名或扩展名太长”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值