Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: show underlying type on hover over alias #71286

Open
jacobzim-stl opened this issue Jan 15, 2025 · 5 comments
Open

x/tools/gopls: show underlying type on hover over alias #71286

jacobzim-stl opened this issue Jan 15, 2025 · 5 comments
Assignees
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@jacobzim-stl
Copy link

jacobzim-stl commented Jan 15, 2025

gopls version

golang.org/x/tools/gopls v0.17.1

go env

n/a

What did you do?

Note: this is a feature request

Given

// This is a dog.
type Dog struct {
    Name string `json:"name"`
    Age int `json:"age"`
}

type Hound = Dog

// A Puppy is a Dog with an age less than 2.
type Puppy = Dog

I hovered over Hound and Puppy

What did you see happen?

The hover message reads

type Hound = Dog

and respectively

type Puppy = Dog

A puppy is a dog with an age less than 2.

What did you expect to see?

type Hound = Dog

This is a dog.

type Dog struct {
    Name string `json:"name"`
    Age int `json:"age"`
}

and respectively

type Puppy = Dog

A puppy is a dog with an age less than 2.

type Dog struct {
    Name string `json:"name"`
    Age int `json:"age"`
}

I like the semantic that docstrings are inherited if, and only if, the alias provides no docstring of its own.

Editor and settings

n/a

Logs

n/a

@jacobzim-stl jacobzim-stl added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Jan 15, 2025
@gopherbot gopherbot added this to the Unreleased milestone Jan 15, 2025
@findleyr findleyr added the FeatureRequest Issues asking for a new feature that does not need a proposal. label Jan 15, 2025
@findleyr
Copy link
Member

This sounds like a nice improvement. Thanks.

@adonovan
Copy link
Member

@jacobzim-stl, did you want to take a crack at implementing the necessary fix? (I heard a rumor from one of my coworkers.)

@jacobzim-stl
Copy link
Author

@adonovan I'd love to, unfortunately my bandwidth is a bit limited in the coming weeks. I'll give it an initial shot this weekend. If the implementation gets heavy I might not be able to implement it for a while.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/644495 mentions this issue: gopls/internal/hover: show underlying type on hover over alias

@xieyuschen
Copy link
Contributor

Hi @jacobzim-stl , I have put the real type definition after the original typeDecl, as the screenshot shows below. I hope it meets your expectations :)

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants