Skip to content

x/tools/gopls: dynamic questions support for interactive refactoring #79935

Description

@h9jiang

While reviewing CL 787541 and reviewing previous CL regarding tags removal code action, we found this missing feature from interactive refactoring.

gopls version

v0.22.1

go env

N/A

What did you do?

Trigger code action "gopls.implement_interface", this code action stub methods to the type to satisfy an interface.

What did you see happen?

However, if the interface is a generic (contains free type parameters), the code action will fail.

What did you expect to see?

Instead, gopls should dynamically ask follow up questions,

Questions: []{
  {id: "interface"}
}

Answers: []{
  {id: "interface", value: "foo.GenericInterface"}
}

Questions: []{
  {id: "interface"}
  {id: "type0"}
  {id: "type1"}
}

Answers: []{
  {id: "interface", value: "foo.GenericInterface"}
  {id: "type0", value: "foo.Type0"}
  {id: "type1", value: "foo.Type1"}
}

Then gopls can generate the proper methods stub for the user.

The scenario above is dynamically generating new question based on the previous answers, and the tags removal code action is dynamically generating questions based on the current context (like the position of the file).

Metadata

Metadata

Assignees

Labels

ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Fields

No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions