File: fill_switch.txt

package info (click to toggle)
golang-golang-x-tools 1%3A0.25.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,724 kB
  • sloc: javascript: 2,027; asm: 1,645; sh: 166; yacc: 155; makefile: 49; ansic: 8
file content (105 lines) | stat: -rw-r--r-- 1,916 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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))