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: consider moving methods inside its type in outline view #40931

Open
emil14 opened this issue Aug 18, 2020 · 5 comments
Open

x/tools/gopls: consider moving methods inside its type in outline view #40931

emil14 opened this issue Aug 18, 2020 · 5 comments

Comments

@emil14
Copy link

@emil14 emil14 commented Aug 18, 2020

It would be nice if we could look at some type in outline view and see all of the methods declared on that type in one place.

At the moment type and its methods separated

Screenshot from 2020-08-18 10-26-29

@hyangah
Copy link
Contributor

@hyangah hyangah commented Aug 18, 2020

@emil14 Are you using the language server? ("go.useLanguageServer": true).

I am asking because the extension computes the outline info in two different ways, so I need to know it to direct this FR to the right place.

@heschik
Copy link
Contributor

@heschik heschik commented Aug 18, 2020

This is conceptually difficult: in Go, a method can be defined in a different file than the declaration. In that case, there is no struct node to put it under. In gopls, we decided to leave methods at the top level.

@emil14
Copy link
Author

@emil14 emil14 commented Aug 20, 2020

@hyangah yes, useLanguageServer set to true :)

@hyangah
Copy link
Contributor

@hyangah hyangah commented Aug 20, 2020

@emil14 Thanks! Yeah, I observed that when not using the language server, the outline view grouped methods under its struct type. As @heschik said, Go's code structure is different from other languages, so the document-based symbol hierarchy (DocumentSymbolProvider and its corresponding LSP method) doesn't fit perfectly.

I will transfer this to gopls issue tracker so we can discuss there how to improve this.

@hyangah hyangah changed the title Feature request: Move methods inside its types in outline view x/tools/gopls: consider moving methods inside its types in outline view (DocumentSymbolRequest) Aug 20, 2020
@hyangah hyangah transferred this issue from golang/vscode-go Aug 20, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 20, 2020
@hyangah hyangah removed the Documentation label Aug 20, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v.0.5.0 Aug 25, 2020
@stamblerre stamblerre changed the title x/tools/gopls: consider moving methods inside its types in outline view (DocumentSymbolRequest) x/tools/gopls: consider moving methods inside its types in outline view Aug 25, 2020
@stamblerre stamblerre removed this from the gopls/v.0.5.0 milestone Aug 25, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Aug 25, 2020

Thanks for the feature request, @emil14. For now, our approach to the outline view has been to show symbols in the order that they appear in the file. This would require us to change that behavior. Before moving forward with this, I'd like to hear from other users if they think this would be a net improvement. Notably, we can't show the methods nested within the type declaration because that breaks VS Code's breadcrumbs feature.

@stamblerre stamblerre added the Thinking label Aug 28, 2020
@stamblerre stamblerre changed the title x/tools/gopls: consider moving methods inside its types in outline view x/tools/gopls: consider moving methods inside its struct type in outline view Aug 28, 2020
@stamblerre stamblerre changed the title x/tools/gopls: consider moving methods inside its struct type in outline view x/tools/gopls: consider moving methods inside its type in outline view Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.