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