golang.org/x/tools/gopls@v0.15.3/internal/test/marker/testdata/codeaction/removeparam_resolve.txt (about) 1 This test exercises the refactoring to remove unused parameters, with resolve support. 2 See removeparam.txt for same test without resolve support. 3 4 -- capabilities.json -- 5 { 6 "textDocument": { 7 "codeAction": { 8 "dataSupport": true, 9 "resolveSupport": { 10 "properties": ["edit"] 11 } 12 } 13 } 14 } 15 -- go.mod -- 16 module unused.mod 17 18 go 1.18 19 20 -- a/a.go -- 21 package a 22 23 func A(x, unused int) int { //@codeaction("unused", "unused", "refactor.rewrite", a) 24 return x 25 } 26 27 -- @a/a/a.go -- 28 package a 29 30 func A(x int) int { //@codeaction("unused", "unused", "refactor.rewrite", a) 31 return x 32 } 33 34 -- a/a2.go -- 35 package a 36 37 func _() { 38 A(1, 2) 39 } 40 41 -- a/a_test.go -- 42 package a 43 44 func _() { 45 A(1, 2) 46 } 47 48 -- a/a_x_test.go -- 49 package a_test 50 51 import "unused.mod/a" 52 53 func _() { 54 a.A(1, 2) 55 } 56 57 -- b/b.go -- 58 package b 59 60 import "unused.mod/a" 61 62 func f() int { 63 return 1 64 } 65 66 func g() int { 67 return 2 68 } 69 70 func _() { 71 a.A(f(), 1) 72 } 73 74 -- @a/a/a2.go -- 75 package a 76 77 func _() { 78 A(1) 79 } 80 -- @a/a/a_test.go -- 81 package a 82 83 func _() { 84 A(1) 85 } 86 -- @a/a/a_x_test.go -- 87 package a_test 88 89 import "unused.mod/a" 90 91 func _() { 92 a.A(1) 93 } 94 -- @a/b/b.go -- 95 package b 96 97 import "unused.mod/a" 98 99 func f() int { 100 return 1 101 } 102 103 func g() int { 104 return 2 105 } 106 107 func _() { 108 a.A(f()) 109 } 110 -- field/field.go -- 111 package field 112 113 func Field(x int, field int) { //@codeaction("int", "int", "refactor.rewrite", field) 114 } 115 116 func _() { 117 Field(1, 2) 118 } 119 -- @field/field/field.go -- 120 package field 121 122 func Field(field int) { //@codeaction("int", "int", "refactor.rewrite", field) 123 } 124 125 func _() { 126 Field(2) 127 } 128 -- ellipsis/ellipsis.go -- 129 package ellipsis 130 131 func Ellipsis(...any) { //@codeaction("any", "any", "refactor.rewrite", ellipsis) 132 } 133 134 func _() { 135 // TODO(rfindley): investigate the broken formatting resulting from these inlinings. 136 Ellipsis() 137 Ellipsis(1) 138 Ellipsis(1, 2) 139 Ellipsis(1, f(), g()) 140 Ellipsis(h()) 141 Ellipsis(i()...) 142 } 143 144 func f() int 145 func g() int 146 func h() (int, int) 147 func i() []any 148 149 -- @ellipsis/ellipsis/ellipsis.go -- 150 package ellipsis 151 152 func Ellipsis() { //@codeaction("any", "any", "refactor.rewrite", ellipsis) 153 } 154 155 func _() { 156 // TODO(rfindley): investigate the broken formatting resulting from these inlinings. 157 Ellipsis() 158 Ellipsis() 159 Ellipsis() 160 var _ []any = []any{1, f(), g()} 161 Ellipsis() 162 func(_ ...any) { 163 Ellipsis() 164 }(h()) 165 var _ []any = i() 166 Ellipsis() 167 } 168 169 func f() int 170 func g() int 171 func h() (int, int) 172 func i() []any 173 -- ellipsis2/ellipsis2.go -- 174 package ellipsis2 175 176 func Ellipsis2(_, _ int, rest ...int) { //@codeaction("_", "_", "refactor.rewrite", ellipsis2) 177 } 178 179 func _() { 180 Ellipsis2(1,2,3) 181 Ellipsis2(h()) 182 Ellipsis2(1,2, []int{3, 4}...) 183 } 184 185 func h() (int, int) 186 187 -- @ellipsis2/ellipsis2/ellipsis2.go -- 188 package ellipsis2 189 190 func Ellipsis2(_ int, rest ...int) { //@codeaction("_", "_", "refactor.rewrite", ellipsis2) 191 } 192 193 func _() { 194 Ellipsis2(2, []int{3}...) 195 func(_, blank0 int, rest ...int) { 196 Ellipsis2(blank0, rest...) 197 }(h()) 198 Ellipsis2(2, []int{3, 4}...) 199 } 200 201 func h() (int, int) 202 -- overlapping/overlapping.go -- 203 package overlapping 204 205 func Overlapping(i int) int { //@codeactionerr(re"(i) int", re"(i) int", "refactor.rewrite", re"overlapping") 206 return 0 207 } 208 209 func _() { 210 x := Overlapping(Overlapping(0)) 211 _ = x 212 } 213 214 -- effects/effects.go -- 215 package effects 216 217 func effects(x, y int) int { //@codeaction("y", "y", "refactor.rewrite", effects), diag("y", re"unused") 218 return x 219 } 220 221 func f() int 222 func g() int 223 224 func _() { 225 effects(f(), g()) 226 effects(f(), g()) 227 } 228 -- @effects/effects/effects.go -- 229 package effects 230 231 func effects(x int) int { //@codeaction("y", "y", "refactor.rewrite", effects), diag("y", re"unused") 232 return x 233 } 234 235 func f() int 236 func g() int 237 238 func _() { 239 var x, _ int = f(), g() 240 effects(x) 241 { 242 var x, _ int = f(), g() 243 effects(x) 244 } 245 } 246 -- recursive/recursive.go -- 247 package recursive 248 249 func Recursive(x int) int { //@codeaction("x", "x", "refactor.rewrite", recursive) 250 return Recursive(1) 251 } 252 253 -- @recursive/recursive/recursive.go -- 254 package recursive 255 256 func Recursive() int { //@codeaction("x", "x", "refactor.rewrite", recursive) 257 return Recursive() 258 }