This test checks that extract variable permits:
- extraneous whitespace in the selection
- function literals
- pointer dereference expressions
- parenthesized expressions
-- a.go --
package a
func _(ptr *int) {
var _ = 1 + 2 + 3 //@codeaction("1 + 2 ", "refactor.extract.variable", edit=spaces)
var _ = func() {} //@codeaction("func() {}", "refactor.extract.variable", edit=funclit)
var _ = *ptr //@codeaction("*ptr", "refactor.extract.variable", edit=ptr)
var _ = (ptr) //@codeaction("(ptr)", "refactor.extract.variable", edit=paren)
}
-- @spaces/a.go --
@@ -4 +4,2 @@
- var _ = 1 + 2 + 3 //@codeaction("1 + 2 ", "refactor.extract.variable", edit=spaces)
+ x := 1 + 2
+ var _ = x+ 3 //@codeaction("1 + 2 ", "refactor.extract.variable", edit=spaces)
-- @funclit/a.go --
@@ -5 +5,2 @@
- var _ = func() {} //@codeaction("func() {}", "refactor.extract.variable", edit=funclit)
+ x := func() {}
+ var _ = x //@codeaction("func() {}", "refactor.extract.variable", edit=funclit)
-- @ptr/a.go --
@@ -6 +6,2 @@
- var _ = *ptr //@codeaction("*ptr", "refactor.extract.variable", edit=ptr)
+ x := *ptr
+ var _ = x //@codeaction("*ptr", "refactor.extract.variable", edit=ptr)
-- @paren/a.go --
@@ -7 +7,2 @@
- var _ = (ptr) //@codeaction("(ptr)", "refactor.extract.variable", edit=paren)
+ x := (ptr)
+ var _ = x //@codeaction("(ptr)", "refactor.extract.variable", edit=paren)