Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/gopls: extract variable suggests extracting an *ast.ImportSpec #40635
This is symptom of logic living in canExtractVariable. We check if it is an ast.Expr, but then leave the actual checking if its a valid ast.Expr type to extractVariable. This is why the lightbulb is on, but it won't actually do anything. Should we move this logic into canExtractVariable? We could just have a barebones switch statement in there that explicitly checks the type.
EDIT: This is actually an *ast.BasicLit, not an *ast.ImportSpec. This is why the lightbulb is showing up. It does not actually extract anything because extractVariable does not find a place to insert the extraction. In pathEnclosingInterval -> path is the basic lit and path is the import spec. Do we want to special case this to prevent the lightbulb?
Yes, please - let's do that.