Debian Codegraph @

gopls/internal/test/marker/testdata/codeaction/extract_variable-70563.txt

raw
1 This test verifies the fix for golang/go#70563: refactor.extract.variable
2 inserts new statement before the scope of its free symbols.
3
4 -- flags --
5 -ignore_extra_diags
6
7 -- inside_else.go --
8 package extract
9
10 func _() {
11 if x := 1; true {
12
13 } else if y := x + 1; true { //@codeaction("x + 1", "refactor.extract.variable", err=re"else-if's init has free variable")
14
15 }
16 }
17 -- inside_case.go --
18 package extract
19
20 func _() {
21 switch x := 1; x {
22 case x + 1: //@codeaction("x + 1", "refactor.extract.variable-all", err=re"switch's init has free variable")
23 y := x + 1 //@codeaction("x + 1", "refactor.extract.variable-all", err=re"switch's init has free variable")
24 _ = y
25 case 3:
26 y := x + 1 //@codeaction("x + 1", "refactor.extract.variable-all", err=re"switch's init has free variable")
27 _ = y
28 }
29 }
30 -- parent_if.go --
31 package extract
32
33 func _() {
34 if x := 1; x > 0 {
35 y = x + 1 //@codeaction("x + 1", "refactor.extract.variable-all", err=re"if-statement's init has free variable")
36 } else {
37 y = x + 1 //@codeaction("x + 1", "refactor.extract.variable-all", err=re"if-statement's init has free variable")
38 }
39 }
40 -- parent_switch.go --
41 package extract
42
43 func _() {
44 switch x := 1; x {
45 case 1:
46 y = x + 1 //@codeaction("x + 1", "refactor.extract.variable-all", err=re"switch's init has free variable")
47 case 3:
48 y = x + 1 //@codeaction("x + 1", "refactor.extract.variable-all", err=re"switch's init has free variable")
49 }
50 }