| This test checks the behavior of the 'fill switch' code action. |
| See fill_switch_resolve.txt for same test with resolve support. |
| |
| -- flags -- |
| -ignore_extra_diags |
| |
| -- go.mod -- |
| module golang.org/lsptests/fillswitch |
| |
| go 1.18 |
| |
| -- data/data.go -- |
| package data |
| |
| type TypeB int |
| |
| const ( |
| TypeBOne TypeB = iota |
| TypeBTwo |
| TypeBThree |
| ) |
| |
| -- a.go -- |
| package fillswitch |
| |
| import ( |
| "golang.org/lsptests/fillswitch/data" |
| ) |
| |
| type typeA int |
| |
| const ( |
| typeAOne typeA = iota |
| typeATwo |
| typeAThree |
| ) |
| |
| type notification interface { |
| isNotification() |
| } |
| |
| type notificationOne struct{} |
| |
| func (notificationOne) isNotification() {} |
| |
| type notificationTwo struct{} |
| |
| func (notificationTwo) isNotification() {} |
| |
| func doSwitch() { |
| var b data.TypeB |
| switch b { |
| case data.TypeBOne: //@codeactionedit(":", "refactor.rewrite", a1) |
| } |
| |
| var a typeA |
| switch a { |
| case typeAThree: //@codeactionedit(":", "refactor.rewrite", a2) |
| } |
| |
| var n notification |
| switch n.(type) { //@codeactionedit("{", "refactor.rewrite", a3) |
| } |
| |
| switch nt := n.(type) { //@codeactionedit("{", "refactor.rewrite", a4) |
| } |
| |
| var s struct { |
| a typeA |
| } |
| |
| switch s.a { |
| case typeAThree: //@codeactionedit(":", "refactor.rewrite", a5) |
| } |
| } |
| -- @a1/a.go -- |
| @@ -31 +31,4 @@ |
| + case data.TypeBThree: |
| + case data.TypeBTwo: |
| + default: |
| + panic(fmt.Sprintf("unexpected data.TypeB: %#v", b)) |
| -- @a2/a.go -- |
| @@ -36 +36,4 @@ |
| + case typeAOne: |
| + case typeATwo: |
| + default: |
| + panic(fmt.Sprintf("unexpected fillswitch.typeA: %#v", a)) |
| -- @a3/a.go -- |
| @@ -40 +40,4 @@ |
| + case notificationOne: |
| + case notificationTwo: |
| + default: |
| + panic(fmt.Sprintf("unexpected fillswitch.notification: %#v", n)) |
| -- @a4/a.go -- |
| @@ -43 +43,4 @@ |
| + case notificationOne: |
| + case notificationTwo: |
| + default: |
| + panic(fmt.Sprintf("unexpected fillswitch.notification: %#v", nt)) |
| -- @a5/a.go -- |
| @@ -51 +51,4 @@ |
| + case typeAOne: |
| + case typeATwo: |
| + default: |
| + panic(fmt.Sprintf("unexpected fillswitch.typeA: %#v", s.a)) |