blob: c10b8185c9b069d60fdff923aac14eedd38194c0 [file] [log] [blame]
This test checks the behavior of the 'extract variable' code action.
-- flags --
-ignore_extra_diags
-- basic_lit.go --
package extract
func _() {
var _ = 1 + 2 //@codeactionedit("1", "refactor.extract", basic_lit1)
var _ = 3 + 4 //@codeactionedit("3 + 4", "refactor.extract", basic_lit2)
}
-- @basic_lit1/basic_lit.go --
@@ -4 +4,2 @@
- var _ = 1 + 2 //@codeactionedit("1", "refactor.extract", basic_lit1)
+ x := 1
+ var _ = x + 2 //@codeactionedit("1", "refactor.extract", basic_lit1)
-- @basic_lit2/basic_lit.go --
@@ -5 +5,2 @@
- var _ = 3 + 4 //@codeactionedit("3 + 4", "refactor.extract", basic_lit2)
+ x := 3 + 4
+ var _ = x //@codeactionedit("3 + 4", "refactor.extract", basic_lit2)
-- func_call.go --
package extract
import "strconv"
func _() {
x0 := append([]int{}, 1) //@codeactionedit("append([]int{}, 1)", "refactor.extract", func_call1)
str := "1"
b, err := strconv.Atoi(str) //@codeactionedit("strconv.Atoi(str)", "refactor.extract", func_call2)
}
-- @func_call1/func_call.go --
@@ -6 +6,2 @@
- x0 := append([]int{}, 1) //@codeactionedit("append([]int{}, 1)", "refactor.extract", func_call1)
+ x := append([]int{}, 1)
+ x0 := x //@codeactionedit("append([]int{}, 1)", "refactor.extract", func_call1)
-- @func_call2/func_call.go --
@@ -8 +8,2 @@
- b, err := strconv.Atoi(str) //@codeactionedit("strconv.Atoi(str)", "refactor.extract", func_call2)
+ x, x1 := strconv.Atoi(str)
+ b, err := x, x1 //@codeactionedit("strconv.Atoi(str)", "refactor.extract", func_call2)
-- scope.go --
package extract
import "go/ast"
func _() {
x0 := 0
if true {
y := ast.CompositeLit{} //@codeactionedit("ast.CompositeLit{}", "refactor.extract", scope1)
}
if true {
x1 := !false //@codeactionedit("!false", "refactor.extract", scope2)
}
}
-- @scope1/scope.go --
@@ -8 +8,2 @@
- y := ast.CompositeLit{} //@codeactionedit("ast.CompositeLit{}", "refactor.extract", scope1)
+ x := ast.CompositeLit{}
+ y := x //@codeactionedit("ast.CompositeLit{}", "refactor.extract", scope1)
-- @scope2/scope.go --
@@ -11 +11,2 @@
- x1 := !false //@codeactionedit("!false", "refactor.extract", scope2)
+ x := !false
+ x1 := x //@codeactionedit("!false", "refactor.extract", scope2)