Debian Codegraph @

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

raw
1 This test checks the behavior of the 'extract to a new file' code action.
2
3 -- flags --
4 -ignore_extra_diags
5
6 -- go.mod --
7 module golang.org/lsptests/extracttofile
8
9 go 1.18
10
11 -- a.go --
12 package main
13
14 // docs
15 func fn() {} //@codeaction("func", "refactor.extract.toNewFile", edit=function_declaration)
16
17 func fn2() {} //@codeaction("fn2", "refactor.extract.toNewFile", edit=only_select_func_name)
18
19 func fn3() {} //@codeaction(re`()fn3`, "refactor.extract.toNewFile", edit=zero_width_selection_on_func_name)
20
21 // docs
22 type T int //@codeaction("type", "refactor.extract.toNewFile", edit=type_declaration)
23
24 // docs
25 var V int //@codeaction("var", "refactor.extract.toNewFile", edit=var_declaration)
26
27 // docs
28 const K = "" //@codeaction("const", "refactor.extract.toNewFile", edit=const_declaration)
29
30 const ( //@codeaction("const", "refactor.extract.toNewFile", edit=const_declaration_multiple_specs)
31 P = iota
32 Q
33 R
34 )
35
36 func fnA () {} //@codeaction("func", "refactor.extract.toNewFile", end=mdEnd, result=multiple_declarations)
37
38 // unattached comment
39
40 func fnB () {} //@loc(mdEnd, "}")
41
42 -- @const_declaration_multiple_specs/p.go --
43 @@ -0,0 +1,7 @@
44 +package main
45 +
46 +const ( //@codeaction("const", "refactor.extract.toNewFile", edit=const_declaration_multiple_specs)
47 + P = iota
48 + Q
49 + R
50 +)
51 -- @multiple_declarations/fna.go --
52 package main
53
54 func fnA() {} //@codeaction("func", "refactor.extract.toNewFile", end=mdEnd, result=multiple_declarations)
55
56 // unattached comment
57
58 func fnB() {}
59 -- @multiple_declarations/a.go --
60 package main
61
62 // docs
63 func fn() {} //@codeaction("func", "refactor.extract.toNewFile", edit=function_declaration)
64
65 func fn2() {} //@codeaction("fn2", "refactor.extract.toNewFile", edit=only_select_func_name)
66
67 func fn3() {} //@codeaction(re`()fn3`, "refactor.extract.toNewFile", edit=zero_width_selection_on_func_name)
68
69 // docs
70 type T int //@codeaction("type", "refactor.extract.toNewFile", edit=type_declaration)
71
72 // docs
73 var V int //@codeaction("var", "refactor.extract.toNewFile", edit=var_declaration)
74
75 // docs
76 const K = "" //@codeaction("const", "refactor.extract.toNewFile", edit=const_declaration)
77
78 const ( //@codeaction("const", "refactor.extract.toNewFile", edit=const_declaration_multiple_specs)
79 P = iota
80 Q
81 R
82 )
83
84 //@loc(mdEnd, "}")
85
86 -- @const_declaration_multiple_specs/a.go --
87 @@ -19,6 +19 @@
88 -const ( //@codeaction("const", "refactor.extract.toNewFile", edit=const_declaration_multiple_specs)
89 - P = iota
90 - Q
91 - R
92 -)
93 -
94 -- existing.go --
95 -- existing2.go --
96 -- existing2.1.go --
97 -- b.go --
98 package main
99 func existing() {} //@codeaction("func", "refactor.extract.toNewFile", edit=file_name_conflict)
100 func existing2() {} //@codeaction("func", "refactor.extract.toNewFile", edit=file_name_conflict_again)
101
102 -- single_import.go --
103 package main
104 import "fmt"
105 func F() { //@codeaction("func", "refactor.extract.toNewFile", edit=single_import)
106 fmt.Println()
107 }
108
109 -- multiple_imports.go --
110 package main
111 import (
112 "fmt"
113 "log"
114 time1 "time"
115 )
116 func init(){
117 log.Println()
118 }
119 func F() { //@codeaction("func", "refactor.extract.toNewFile", edit=multiple_imports)
120 fmt.Println()
121 }
122 func g() string{ //@codeaction("func", "refactor.extract.toNewFile", edit=renamed_import)
123 return time1.Now().string()
124 }
125
126 -- blank_import.go --
127 package main
128 import _ "fmt"
129 func F() {} //@codeaction("func", "refactor.extract.toNewFile", edit=blank_import)
130
131
132
133 -- @blank_import/blank_import.go --
134 @@ -3 +3 @@
135 -func F() {} //@codeaction("func", "refactor.extract.toNewFile", edit=blank_import)
136 +//@codeaction("func", "refactor.extract.toNewFile", edit=blank_import)
137 -- @blank_import/f.go --
138 @@ -0,0 +1,3 @@
139 +package main
140 +
141 +func F() {}
142 -- @const_declaration/a.go --
143 @@ -16,2 +16 @@
144 -// docs
145 -const K = "" //@codeaction("const", "refactor.extract.toNewFile", edit=const_declaration)
146 +//@codeaction("const", "refactor.extract.toNewFile", edit=const_declaration)
147 -- @const_declaration/k.go --
148 @@ -0,0 +1,4 @@
149 +package main
150 +
151 +// docs
152 +const K = ""
153 -- @file_name_conflict/b.go --
154 @@ -2 +2 @@
155 -func existing() {} //@codeaction("func", "refactor.extract.toNewFile", edit=file_name_conflict)
156 +//@codeaction("func", "refactor.extract.toNewFile", edit=file_name_conflict)
157 -- @file_name_conflict/existing.1.go --
158 @@ -0,0 +1,3 @@
159 +package main
160 +
161 +func existing() {}
162 -- @file_name_conflict_again/b.go --
163 @@ -3 +3 @@
164 -func existing2() {} //@codeaction("func", "refactor.extract.toNewFile", edit=file_name_conflict_again)
165 +//@codeaction("func", "refactor.extract.toNewFile", edit=file_name_conflict_again)
166 -- @file_name_conflict_again/existing2.2.go --
167 @@ -0,0 +1,3 @@
168 +package main
169 +
170 +func existing2() {}
171 -- @function_declaration/a.go --
172 @@ -3,2 +3 @@
173 -// docs
174 -func fn() {} //@codeaction("func", "refactor.extract.toNewFile", edit=function_declaration)
175 +//@codeaction("func", "refactor.extract.toNewFile", edit=function_declaration)
176 -- @function_declaration/fn.go --
177 @@ -0,0 +1,4 @@
178 +package main
179 +
180 +// docs
181 +func fn() {}
182 -- @multiple_imports/f.go --
183 @@ -0,0 +1,9 @@
184 +package main
185 +
186 +import (
187 + "fmt"
188 +)
189 +
190 +func F() { //@codeaction("func", "refactor.extract.toNewFile", edit=multiple_imports)
191 + fmt.Println()
192 +}
193 -- @multiple_imports/multiple_imports.go --
194 @@ -3 +3 @@
195 - "fmt"
196 +
197 @@ -10,3 +10 @@
198 -func F() { //@codeaction("func", "refactor.extract.toNewFile", edit=multiple_imports)
199 - fmt.Println()
200 -}
201 -- @only_select_func_name/a.go --
202 @@ -6 +6 @@
203 -func fn2() {} //@codeaction("fn2", "refactor.extract.toNewFile", edit=only_select_func_name)
204 +//@codeaction("fn2", "refactor.extract.toNewFile", edit=only_select_func_name)
205 -- @only_select_func_name/fn2.go --
206 @@ -0,0 +1,3 @@
207 +package main
208 +
209 +func fn2() {}
210 -- @single_import/f.go --
211 @@ -0,0 +1,9 @@
212 +package main
213 +
214 +import (
215 + "fmt"
216 +)
217 +
218 +func F() { //@codeaction("func", "refactor.extract.toNewFile", edit=single_import)
219 + fmt.Println()
220 +}
221 -- @single_import/single_import.go --
222 @@ -2,4 +2 @@
223 -import "fmt"
224 -func F() { //@codeaction("func", "refactor.extract.toNewFile", edit=single_import)
225 - fmt.Println()
226 -}
227 -- @type_declaration/a.go --
228 @@ -10,2 +10 @@
229 -// docs
230 -type T int //@codeaction("type", "refactor.extract.toNewFile", edit=type_declaration)
231 +//@codeaction("type", "refactor.extract.toNewFile", edit=type_declaration)
232 -- @type_declaration/t.go --
233 @@ -0,0 +1,4 @@
234 +package main
235 +
236 +// docs
237 +type T int
238 -- @var_declaration/a.go --
239 @@ -13,2 +13 @@
240 -// docs
241 -var V int //@codeaction("var", "refactor.extract.toNewFile", edit=var_declaration)
242 +//@codeaction("var", "refactor.extract.toNewFile", edit=var_declaration)
243 -- @var_declaration/v.go --
244 @@ -0,0 +1,4 @@
245 +package main
246 +
247 +// docs
248 +var V int
249 -- @zero_width_selection_on_func_name/a.go --
250 @@ -8 +8 @@
251 -func fn3() {} //@codeaction(re`()fn3`, "refactor.extract.toNewFile", edit=zero_width_selection_on_func_name)
252 +//@codeaction(re`()fn3`, "refactor.extract.toNewFile", edit=zero_width_selection_on_func_name)
253 -- @zero_width_selection_on_func_name/fn3.go --
254 @@ -0,0 +1,3 @@
255 +package main
256 +
257 +func fn3() {}
258 -- @renamed_import/g.go --
259 @@ -0,0 +1,9 @@
260 +package main
261 +
262 +import (
263 + time1 "time"
264 +)
265 +
266 +func g() string { //@codeaction("func", "refactor.extract.toNewFile", edit=renamed_import)
267 + return time1.Now().string()
268 +}
269 -- @renamed_import/multiple_imports.go --
270 @@ -5 +5 @@
271 - time1 "time"
272 +
273 @@ -13,4 +13 @@
274 -func g() string{ //@codeaction("func", "refactor.extract.toNewFile", edit=renamed_import)
275 - return time1.Now().string()
276 -}
277 -
278 -- copyright.go --
279 // Copyright 2020 The Go Authors. All rights reserved.
280 // Use of this source code is governed by a BSD-style
281 // license that can be found in the LICENSE file.
282
283 package main
284
285 // docs
286 const C = "" //@codeaction("const", "refactor.extract.toNewFile", edit=copyright)
287
288 -- @copyright/c.go --
289 @@ -0,0 +1,8 @@
290 +// Copyright 2020 The Go Authors. All rights reserved.
291 +// Use of this source code is governed by a BSD-style
292 +// license that can be found in the LICENSE file.
293 +
294 +package main
295 +
296 +// docs
297 +const C = ""
298 -- @copyright/copyright.go --
299 @@ -7,2 +7 @@
300 -// docs
301 -const C = "" //@codeaction("const", "refactor.extract.toNewFile", edit=copyright)
302 +//@codeaction("const", "refactor.extract.toNewFile", edit=copyright)
303 -- buildconstraint.go --
304 //go:build go1.18
305
306 package main
307
308 // docs
309 const C = "" //@codeaction("const", "refactor.extract.toNewFile", edit=buildconstraint)
310
311 -- @buildconstraint/buildconstraint.go --
312 @@ -5,2 +5 @@
313 -// docs
314 -const C = "" //@codeaction("const", "refactor.extract.toNewFile", edit=buildconstraint)
315 +//@codeaction("const", "refactor.extract.toNewFile", edit=buildconstraint)
316 -- @buildconstraint/c.go --
317 @@ -0,0 +1,6 @@
318 +//go:build go1.18
319 +
320 +package main
321 +
322 +// docs
323 +const C = ""
324 -- copyrightandbuildconstraint.go --
325 // Copyright 2020 The Go Authors. All rights reserved.
326 // Use of this source code is governed by a BSD-style
327 // license that can be found in the LICENSE file.
328
329 //go:build go1.18
330
331 package main
332
333 // docs
334 const C = "" //@codeaction("const", "refactor.extract.toNewFile", edit=copyrightandbuildconstraint)
335 -- @copyrightandbuildconstraint/c.go --
336 @@ -0,0 +1,10 @@
337 +// Copyright 2020 The Go Authors. All rights reserved.
338 +// Use of this source code is governed by a BSD-style
339 +// license that can be found in the LICENSE file.
340 +
341 +//go:build go1.18
342 +
343 +package main
344 +
345 +// docs
346 +const C = ""
347 -- @copyrightandbuildconstraint/copyrightandbuildconstraint.go --
348 @@ -9,2 +9 @@
349 -// docs
350 -const C = "" //@codeaction("const", "refactor.extract.toNewFile", edit=copyrightandbuildconstraint)
351 +//@codeaction("const", "refactor.extract.toNewFile", edit=copyrightandbuildconstraint)