Skip to content

Include Return Type Annotations in Method Hover Tooltip #4407

Open

Description

@mamilic

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

Activity

  1. MikeJCusack commented on May 1, 2026

    @MikeJCusack

    This would be greatly appreciated for use with JSpecify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions