-
Notifications
You must be signed in to change notification settings - Fork 780
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
tools: merge gomodifytags
functionality into gopls
and use gopls
#2002
Comments
This PR moves the `gomodifytags` tool into its own package so it can be imported by other applications (i.e: `gopls`). It's currently delibaretly put under `internal`, as I want to make sure it meets the needs of others. related: golang/vscode-go#2002
This PR moves the `gomodifytags` tool into its package to be imported by other applications (i.e.: `gopls`). It's currently deliberately put under `internal`, as I want to make sure it meets the needs of others. related: golang/vscode-go#2002
@hyangah Hi 👋🏼 When I created It's currently inside an Let me know what you think and how you think we should proceed. For example, do we want to make |
Hi! Thanks a lot @fatih! cc @findleyr for API & gopls integration advice: Skimming through your PR, the new API will be like
Currently Gopls does the custom command integration within the x/tools/internal/lsp/command framework. Gopls manages the snapshot of the parsed file including the overlay treatment, and the framework allows the integrated tool to access data available in So, I think it would allow us more efficient integration if the API simply lets the caller handle read/parse/output part, takes For example, I think it's better to keep it under |
Thank you @fatih! I also only skimmed the PR, but have a couple thoughts:
|
@fatih we're looking at this now, as gomodifytags is one of our final remaining third-party tool dependency in VS Code (and we'd like to expose its functionality to all gopls-backed editors). Are you still interested in landing that PR? If not, we can fork the gomodifytags codebase inside gopls. |
Hi @findleyr, Unfortunately I don't have the bandwidth to work on this. Feel free to fork or take the relevant functions from the project. |
@fatih we totally understand. Thanks for the quick response. |
@madelinekalil the current gomodifytags integration is documented here: https://github.com/golang/vscode-go/blob/master/docs/features.md#add-or-remove-struct-tags And configuration is here: https://github.com/golang/vscode-go/blob/master/docs/settings.md#goaddtags Since we are not exposing all of the gomodifytags command line in VS Code settings, I think this will be perhaps easier than first thought. To migrate gomodifytags to gopls, we need to:
(EDIT: whoops, fixed link to gomodifytags feature documentation) |
@fatih we're encountering some friction with different ways of vendoring in or depending upon a fork of gomodifytags (e.g. doing so can cause more work for linux package managers that bundle gopls). Would you be amenable to us contributing a refactoring that allows gomodifytags to be called as a library? This would be similar to your CL above, but we'd handle the rebasing and would do the first pass at review ourselves, just needing your final sign-off. Alternatively, we can rewrite most of the functionality without reference to the original source, which would avoid some of the hassle, but I'd prefer not to operate in such gray areas. CC @adonovan @stapelberg with whom I'd discussed various options. |
Yeap that sounds perfect. I'm more than happy to make it easy for you folks to include it. If the library doesn't work out, you can always rewrite and I would be OK with it. I believe the license I chose is the same we use for Go, so they are compatible. If you open a PR, I can easily merge it after you review it, just let me know once that is done. |
What do you think about us adding another entrypoint, so in addition to: |
@madelinekalil the refactored |
@findleyr Another idea is to use this output type specified by gomodifytags:
and then gopls can transform this into We could also mutate the file in place and do the formatting separately as you suggest. I think this option would involve the least number of changes to gomodifytags, but I'm not sure how important that is |
@madelinekalil I think having an API that mutates the AST could be most useful, as it allows the operation to be easily composable with other mutations. How about
This is very similar to the existing |
Config.Apply seems like the right existing seam to expose, but I will note that we still don't really have a good way to compose two operations that mutate syntax trees. If they are purely syntactic operations (as Config.Apply is), there's no problem, but if the second operation needs type information, there is no way to obtain type information for the mutated tree resulting from the first operation short of running the type checker again, which is expensive and may require careful coordination with the rest of the application. Also, analyzers using the go/analysis framework and gopls code actions merely borrow the syntax tree that belongs to the framework, so they must not mutate it; instead they must clone the tree and return a mutated copy. However, type information is unavailable for the mutated copy, so the analysis must do its computation on the original. In summary, most analyses must be lent the original, typed syntax tree, must not mutate it, and must express transformations by returning a mutated copy (or a textual diff). |
… by other applications (i.e.: `gopls`). A new entrypoint into `gomodifytags` is provided via config.Apply(), which uses the specified start and end positions to apply struct tag modifications to the node without returning the new content. related: golang/vscode-go#2002
This PR moves the `gomodifytags` tool into its package to be imported by other applications (i.e.: `gopls`). A new entrypoint into `gomodifytags` is provided via config.Apply(), which uses the specified start and end positions to apply struct tag modifications to the node without returning the new content. related: golang/vscode-go#2002
This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). A new entrypoint into gomodifytags is provided via config.Apply(), which uses the specified start and end positions to apply struct tag modifications to the node without returning the new content. related: golang/vscode-go#2002
This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). A new entrypoint into gomodifytags is provided via config.Apply(), which uses the specified start and end positions to apply struct tag modifications to the node without returning the new content. related: golang/vscode-go#2002
This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). A new entrypoint into gomodifytags is provided via config.Apply(), which uses the specified start and end positions to apply struct tag modifications to the node without returning the new content. related: golang/vscode-go#2002
This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). A new entrypoint into gomodifytags is provided via config.Apply(), which uses the specified start and end positions to apply struct tag modifications to the node without returning the new content. related: golang/vscode-go#2002
This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). A new entrypoint into gomodifytags is provided via config.Apply(), which uses the specified start and end lines to apply struct tag modifications to the node without returning the new content. related: golang/vscode-go#2002
This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). A new entrypoint into gomodifytags is provided via config.Apply(), which uses the specified start and end lines to apply struct tag modifications to the node without returning the new content. Also updates staticcheck version related: golang/vscode-go#2002
This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). A new entrypoint into gomodifytags is provided via config.Apply(), which uses the specified start and end lines to apply struct tag modifications to the node without returning the new content. Also updates staticcheck version related: golang/vscode-go#2002
This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). A new entrypoint into gomodifytags is provided via Modification.Apply(), which uses the specified start and end positions to apply struct tag modifications to the file without returning the new content. Also updates staticcheck version related: golang/vscode-go#2002
This PR moves the gomodifytags tool into its package to be imported by other applications (i.e.: gopls). A new entrypoint into gomodifytags is provided via Modification.Apply(), which uses the specified start and end positions to apply struct tag modifications to the file without returning the new content. Also updates staticcheck version related: golang/vscode-go#2002
From #1652
Function: modify tags on structs (go.add.tags, go.remove.tags commands)
Proposal:
gomodifytags
.gomodifytags
and reuse it from gopls? (cc @fatih)The text was updated successfully, but these errors were encountered: