Javadoc 在 VSCode 中悬停时不显示

发布于 2025-01-13 00:46:41 字数 582 浏览 2 评论 0原文

我目前正在使用 VSCode 开发一个 java 项目,当我将鼠标悬停在对象、类型或方法名称上时,文档不再显示。我不知道为什么或者我做了什么来改变这一点。

在下图中,我将鼠标悬停在第一次出现的 ByteBuyUtils 上,正如我们所看到的,没有显示任何内容。

第一个悬停示例

这是在谷歌图片上找到的一张图片,显示了我悬停在某些东西上时想要得到的结果:

悬停代码时我想要的示例

我正在使用 1.65.1 版本VSCode,在 Ubuntu 21.10 上。我使用的是 openjdk 版本“18-ea”2022-03-15。

我的 VSCode 上安装了以下扩展:

  • Java 对 Java(TM) 的语言支持
  • Red Hat Debugger for Java
  • Test Runner for

I'm currently working on a java project using VSCode and when I hover an object, type or method name, documentation isn't showing anymore. I do not know why or what I did to change that.

In the following picture, I am hovering the first occurence of ByteBuyUtils, and as we can see, nothing is shown.

first hovering example

Here is a picture found on google pictures showing what I want to get when hovering something :

example of what I want when hovering code

I'm using 1.65.1 version of VSCode, on Ubuntu 21.10. I am using openjdk version "18-ea" 2022-03-15.

The following extensions are installed on my VSCode :

  • Language Support for Java(TM) by Red Hat
  • Debugger for Java
  • Test Runner for Java

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

十秒萌定你 2025-01-20 00:46:41

您可以尝试几件事。

maven

如果您使用ma​​ven,则需要显式下载项目中包的javadoc和源代码。

  • 下载源代码: mvn dependency:sources
  • 下载 javadoc: mvn dependency:resolve -Dclassifier=javadoc

java home 属性

在 vscode 中,您需要设置 java home 属性。

  • Ctrl+Shift+p 打开命令面板
  • 搜索用户设置 json
  • 应打开 settings.json
  • 添加一个字段 java.lang. jdt.ls.java.home 并将值设置为 openjdk 包的根文件夹。

对我来说,它是 /usr/lib/jvm/java-17-openjdk-amd64。因此,我将其添加

"java.jdt.ls.java.home": "/usr/lib/jvm/java-17-openjdk-amd64"

settings.json 中。

要找到您的,请尝试

$ which java
/usr/bin/java
$ ls -l /usr/bin/java
......  /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
......  /etc/alternatives/java -> /usr/lib/jvm/java-17-openjdk-amd64/bin/java

使用 ls -l 一直跟踪。 /bin/java 部分之前的最后一个路径是您的 JAVA_HOME

安装 openjdk javadoc

您可以通过以下方式下载您的 openjdk 版本的 doc: Ubuntu 上的 apt 。

$ sudo apt update
$ apt list | grep openjdk-17-

您应该会看到 openjdk-17-docopenjdk-17-source 可用。将 17 更改为您选择的版本(例如 18)。然后

$ sudo apt install openjdk-17-doc openjdk-17-source

最后

重启vscode

You may try a couple of things.

maven

If you are using maven, you need to explicitly download javadoc and source of the packages in your project.

  • To download source code: mvn dependency:sources
  • To download javadoc: mvn dependency:resolve -Dclassifier=javadoc

java home property

In vscode, you need to set java home property.

  • Ctrl+Shift+p to open command palette
  • search for user settings json
  • the settings.json should be opened
  • add a field java.jdt.ls.java.home and set the value to the root folder of your openjdk package.

For me, it's /usr/lib/jvm/java-17-openjdk-amd64. So I add

"java.jdt.ls.java.home": "/usr/lib/jvm/java-17-openjdk-amd64"

to the settings.json.

To find yours, try

$ which java
/usr/bin/java
$ ls -l /usr/bin/java
......  /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
......  /etc/alternatives/java -> /usr/lib/jvm/java-17-openjdk-amd64/bin/java

Trace all the way down with ls -l. The last path before the /bin/java part is your JAVA_HOME.

install openjdk javadoc

You can download the doc of your openjdk version via. apt on Ubuntu.

$ sudo apt update
$ apt list | grep openjdk-17-

You should see openjdk-17-doc and openjdk-17-source available. Change 17 to your version of choice (18 for example). Then

$ sudo apt install openjdk-17-doc openjdk-17-source

Finally

Restart vscode

野侃 2025-01-20 00:46:41

我遇到了这个问题,并尝试了每个人的建议,将这个或那个编辑添加到设置中,但没有一个有任何效果。原来我需要安装openjdk源码包。对于 Ubuntu 上的 java 17,您可以在终端中运行以下命令:

sudo apt install openjdk-17-source

I was having this problem, and tried everyone's suggestions of adding this or that edit to the settings and none of them had any effect. It turns out I needed to install the openjdk source package. For java 17 on Ubuntu, you'd run this in a terminal:

sudo apt install openjdk-17-source
泪意 2025-01-20 00:46:41

也许这就是您需要的扩展:Visual Studio IntelliCode
您还可以阅读这篇文章来了解Java需要的一些扩展:
https://code.visualstudio.com/docs/java/java-tutorial

Maybe this is the extension you need:Visual Studio IntelliCode
You can also read this article to see some of the extensions that Java needs:
https://code.visualstudio.com/docs/java/java-tutorial

榆西 2025-01-20 00:46:41

按理说你下载的扩展有这个功能说明...为什么不安装一个智能提示扩展比如这个来尝试一下吗?或者请检查一下您是否关闭了设置:editor.hover.enabled(右下角搜索hover)?

It stands to reason that the extension you downloaded has this function to show that... why don't you install an intelligent prompt extension such as this oneto have a try? Or please check it out if you have turned off the setting:editor.hover.enabled(in the lower right corner and search for hover)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文