redhat-developer / redhat-developer/vscode-java

Include Return Type Annotations in Method Hover Tooltip

未关闭
#4,407 1 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement
主要语言
TypeScript
星标
2.3k
派生
546
平均合并
20 小时 1 分钟
30 天内合并 PR
11

描述

Description
When hovering over a method in the editor, the tooltip currently shows the method signature and Javadoc (if available). However, annotations applied to the method’s return type are not displayed.

This feature request proposes enhancing the hover tooltip to include annotations declared on the return type.

Example

public @Nullable String getName() {
    return name;
}

or with type-use annotations:

public List<@NonNull String> getNames() {
    return names;
}

Current Behavior:
Hover tooltip shows:

String getName()

Expected Behavior:
Hover tooltip shows:

@Nullable String getName()

and for generics:

List<@NonNull String> getNames()

Motivation / Use Case
Return type annotations (e.g., nullability annotations like @Nullable, @NonNull, or custom type-use annotations) are critical for understanding API contracts, static analysis, and preventing runtime errors.

Not displaying them in hover:

  • Hides important semantic information
  • Forces developers to navigate to the declaration
  • Reduces the usefulness of hover as a quick inspection tool

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先定位 VS Code 扩展中的 Java hover-tooltip 实现,并跟踪方法签名的渲染方式。使用 @Nullable 和 List<@NonNull String> 示例作为预期情况;当声明返回注解和类型使用返回注解都出现在 hover 输出中,并且相应的测试已添加或更新时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, typescript, vscode
领域
developer-experience, tooling
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。