Skip to content

x/tools/gopls: provide actions when rename fails due to interface implementation breakage #62613

@hyangah

Description

@hyangah

gopls built on master.

When attempting to rename a method but that will make the struct no longer implement an interface and break the code, gopls tries to be helpful by showing the details like this.

Screenshot 2023-09-13 at 10 27 53 AM

That's an improvement (thanks!), however, since VS Code does not linkify source locations shown in the message and vscode by design discourages use of multi-line notification 1, this is a bit hard to deal with for VS Code users.

Some options to consider in this case

  • VS Code notification supports a subset of markdown syntax and one of them is [link](url) form. Utilize that when possible (check client info or markdown handling capability) so users can jump to the rename-able interface definition location by clicking the link.

  • Utilize 'actions' field and utilize 'ShowMessageRequestClientCapabilities.messageActionItem.additionalPropertiesSupport'. (e.g. "Rename this instead")

  • Or provide an option to force renaming - some users may attempt to recover by fixing the diagnostics following, or revert the action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions