Debian Codegraph @

gopls/internal/test/marker/testdata/codeaction/fill_switch_resolve.txt

raw
1 This test checks the behavior of the 'fill switch' code action, with resolve support.
2 See fill_switch.txt for same test without resolve support.
3
4 -- flags --
5 -ignore_extra_diags
6
7 -- go.mod --
8 module golang.org/lsptests/fillswitch
9
10 go 1.18
11
12 -- data/data.go --
13 package data
14
15 type TypeB int
16
17 const (
18 TypeBOne TypeB = iota
19 TypeBTwo
20 TypeBThree
21 )
22
23 -- a.go --
24 package fillswitch
25
26 import (
27 "golang.org/lsptests/fillswitch/data"
28 )
29
30 type typeA int
31
32 const (
33 typeAOne typeA = iota
34 typeATwo
35 typeAThree
36 )
37
38 type notification interface {
39 isNotification()
40 }
41
42 type notificationOne struct{}
43
44 func (notificationOne) isNotification() {}
45
46 type notificationTwo struct{}
47
48 func (notificationTwo) isNotification() {}
49
50 func doSwitch() {
51 var b data.TypeB
52 switch b {
53 case data.TypeBOne: //@codeaction(":", "refactor.rewrite.fillSwitch", edit=a1)
54 }
55
56 var a typeA
57 switch a {
58 case typeAThree: //@codeaction(":", "refactor.rewrite.fillSwitch", edit=a2)
59 }
60
61 var n notification
62 switch n.(type) { //@codeaction("{", "refactor.rewrite.fillSwitch", edit=a3)
63 }
64
65 switch nt := n.(type) { //@codeaction("{", "refactor.rewrite.fillSwitch", edit=a4)
66 }
67
68 var s struct {
69 a typeA
70 }
71
72 switch s.a {
73 case typeAThree: //@codeaction(":", "refactor.rewrite.fillSwitch", edit=a5)
74 }
75 }
76 -- @a1/a.go --
77 @@ -31 +31,4 @@
78 + case data.TypeBThree:
79 + case data.TypeBTwo:
80 + default:
81 + panic(fmt.Sprintf("unexpected data.TypeB: %#v", b))
82 -- @a2/a.go --
83 @@ -36 +36,4 @@
84 + case typeAOne:
85 + case typeATwo:
86 + default:
87 + panic(fmt.Sprintf("unexpected fillswitch.typeA: %#v", a))
88 -- @a3/a.go --
89 @@ -40 +40,4 @@
90 + case notificationOne:
91 + case notificationTwo:
92 + default:
93 + panic(fmt.Sprintf("unexpected fillswitch.notification: %#v", n))
94 -- @a4/a.go --
95 @@ -43 +43,4 @@
96 + case notificationOne:
97 + case notificationTwo:
98 + default:
99 + panic(fmt.Sprintf("unexpected fillswitch.notification: %#v", nt))
100 -- @a5/a.go --
101 @@ -51 +51,4 @@
102 + case typeAOne:
103 + case typeATwo:
104 + default:
105 + panic(fmt.Sprintf("unexpected fillswitch.typeA: %#v", s.a))