Debian Codegraph @

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

raw
1 This test checks the behavior of the 'fill struct' code action, with resolve support.
2 See fill_struct.txt for same test without resolve support.
3
4 -- flags --
5 -ignore_extra_diags
6
7 -- go.mod --
8 module golang.org/lsptests/fillstruct
9
10 go 1.18
11
12 -- data/data.go --
13 package data
14
15 type B struct {
16 ExportedInt int
17 unexportedInt int
18 }
19
20 -- a.go --
21 package fillstruct
22
23 import (
24 "golang.org/lsptests/fillstruct/data"
25 )
26
27 type basicStruct struct {
28 foo int
29 }
30
31 var _ = basicStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a1)
32
33 type twoArgStruct struct {
34 foo int
35 bar string
36 }
37
38 var _ = twoArgStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a2)
39
40 type nestedStruct struct {
41 bar string
42 basic basicStruct
43 }
44
45 var _ = nestedStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a3)
46
47 var _ = data.B{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a4)
48 -- @a1/a.go --
49 @@ -11 +11,3 @@
50 -var _ = basicStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a1)
51 +var _ = basicStruct{
52 + foo: 0,
53 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a1)
54 -- @a2/a.go --
55 @@ -18 +18,4 @@
56 -var _ = twoArgStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a2)
57 +var _ = twoArgStruct{
58 + foo: 0,
59 + bar: "",
60 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a2)
61 -- @a3/a.go --
62 @@ -25 +25,4 @@
63 -var _ = nestedStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a3)
64 +var _ = nestedStruct{
65 + bar: "",
66 + basic: basicStruct{},
67 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a3)
68 -- @a4/a.go --
69 @@ -27 +27,3 @@
70 -var _ = data.B{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a4)
71 +var _ = data.B{
72 + ExportedInt: 0,
73 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a4)
74 -- a2.go --
75 package fillstruct
76
77 type typedStruct struct {
78 m map[string]int
79 s []int
80 c chan int
81 c1 <-chan int
82 a [2]string
83 }
84
85 var _ = typedStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a21)
86
87 type funStruct struct {
88 fn func(i int) int
89 }
90
91 var _ = funStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a22)
92
93 type funStructComplex struct {
94 fn func(i int, s string) (string, int)
95 }
96
97 var _ = funStructComplex{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a23)
98
99 type funStructEmpty struct {
100 fn func()
101 }
102
103 var _ = funStructEmpty{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a24)
104
105 -- @a21/a2.go --
106 @@ -11 +11,7 @@
107 -var _ = typedStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a21)
108 +var _ = typedStruct{
109 + m: map[string]int{},
110 + s: []int{},
111 + c: make(chan int),
112 + c1: make(<-chan int),
113 + a: [2]string{},
114 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a21)
115 -- @a22/a2.go --
116 @@ -17 +17,5 @@
117 -var _ = funStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a22)
118 +var _ = funStruct{
119 + fn: func(i int) int {
120 + panic("TODO")
121 + },
122 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a22)
123 -- @a23/a2.go --
124 @@ -23 +23,5 @@
125 -var _ = funStructComplex{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a23)
126 +var _ = funStructComplex{
127 + fn: func(i int, s string) (string, int) {
128 + panic("TODO")
129 + },
130 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a23)
131 -- @a24/a2.go --
132 @@ -29 +29,5 @@
133 -var _ = funStructEmpty{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a24)
134 +var _ = funStructEmpty{
135 + fn: func() {
136 + panic("TODO")
137 + },
138 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a24)
139 -- a3.go --
140 package fillstruct
141
142 import (
143 "go/ast"
144 "go/token"
145 )
146
147 type Foo struct {
148 A int
149 }
150
151 type Bar struct {
152 X *Foo
153 Y *Foo
154 }
155
156 var _ = Bar{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a31)
157
158 type importedStruct struct {
159 m map[*ast.CompositeLit]ast.Field
160 s []ast.BadExpr
161 a [3]token.Token
162 c chan ast.EmptyStmt
163 fn func(ast_decl ast.DeclStmt) ast.Ellipsis
164 st ast.CompositeLit
165 }
166
167 var _ = importedStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a32)
168
169 type pointerBuiltinStruct struct {
170 b *bool
171 s *string
172 i *int
173 }
174
175 var _ = pointerBuiltinStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a33)
176
177 var _ = []ast.UnaryExpr{
178 {}, //@codeaction("}", "refactor.rewrite.fillStruct", edit=a34)
179 }
180
181 var _ = []ast.UnaryExpr{{}} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a35)
182 -- @a31/a3.go --
183 @@ -17 +17,4 @@
184 -var _ = Bar{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a31)
185 +var _ = Bar{
186 + X: &Foo{},
187 + Y: &Foo{},
188 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a31)
189 -- @a32/a3.go --
190 @@ -28 +28,10 @@
191 -var _ = importedStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a32)
192 +var _ = importedStruct{
193 + m: map[*ast.CompositeLit]ast.Field{},
194 + s: []ast.BadExpr{},
195 + a: [3]token.Token{},
196 + c: make(chan ast.EmptyStmt),
197 + fn: func(ast_decl ast.DeclStmt) ast.Ellipsis {
198 + panic("TODO")
199 + },
200 + st: ast.CompositeLit{},
201 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a32)
202 -- @a33/a3.go --
203 @@ -36 +36,5 @@
204 -var _ = pointerBuiltinStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a33)
205 +var _ = pointerBuiltinStruct{
206 + b: new(bool),
207 + s: new(string),
208 + i: new(int),
209 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a33)
210 -- @a34/a3.go --
211 @@ -39 +39,5 @@
212 - {}, //@codeaction("}", "refactor.rewrite.fillStruct", edit=a34)
213 + {
214 + OpPos: 0,
215 + Op: 0,
216 + X: nil,
217 + }, //@codeaction("}", "refactor.rewrite.fillStruct", edit=a34)
218 -- @a35/a3.go --
219 @@ -42 +42,5 @@
220 -var _ = []ast.UnaryExpr{{}} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a35)
221 +var _ = []ast.UnaryExpr{{
222 + OpPos: 0,
223 + Op: 0,
224 + X: nil,
225 +}} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a35)
226 -- a4.go --
227 package fillstruct
228
229 import "go/ast"
230
231 type iStruct struct {
232 X int
233 }
234
235 type sStruct struct {
236 str string
237 }
238
239 type multiFill struct {
240 num int
241 strin string
242 arr []int
243 }
244
245 type assignStruct struct {
246 n ast.Node
247 }
248
249 func fill() {
250 var x int
251 var _ = iStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a41)
252
253 var s string
254 var _ = sStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a42)
255
256 var n int
257 _ = []int{}
258 if true {
259 arr := []int{1, 2}
260 }
261 var _ = multiFill{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a43)
262
263 var node *ast.CompositeLit
264 var _ = assignStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a45)
265 }
266
267 -- @a41/a4.go --
268 @@ -25 +25,3 @@
269 - var _ = iStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a41)
270 + var _ = iStruct{
271 + X: x,
272 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=a41)
273 -- @a42/a4.go --
274 @@ -28 +28,3 @@
275 - var _ = sStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a42)
276 + var _ = sStruct{
277 + str: s,
278 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=a42)
279 -- @a43/a4.go --
280 @@ -35 +35,5 @@
281 - var _ = multiFill{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a43)
282 + var _ = multiFill{
283 + num: n,
284 + strin: s,
285 + arr: []int{},
286 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=a43)
287 -- @a45/a4.go --
288 @@ -38 +38,3 @@
289 - var _ = assignStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=a45)
290 + var _ = assignStruct{
291 + n: node,
292 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=a45)
293 -- fillStruct.go --
294 package fillstruct
295
296 type StructA struct {
297 unexportedIntField int
298 ExportedIntField int
299 MapA map[int]string
300 Array []int
301 StructB
302 }
303
304 type StructA2 struct {
305 B *StructB
306 }
307
308 type StructA3 struct {
309 B StructB
310 }
311
312 func fill() {
313 a := StructA{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct1)
314 b := StructA2{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct2)
315 c := StructA3{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct3)
316 if true {
317 _ = StructA3{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct4)
318 }
319 }
320
321 -- @fillStruct1/fillStruct.go --
322 @@ -20 +20,7 @@
323 - a := StructA{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct1)
324 + a := StructA{
325 + unexportedIntField: 0,
326 + ExportedIntField: 0,
327 + MapA: map[int]string{},
328 + Array: []int{},
329 + StructB: StructB{},
330 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct1)
331 -- @fillStruct2/fillStruct.go --
332 @@ -21 +21,3 @@
333 - b := StructA2{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct2)
334 + b := StructA2{
335 + B: &StructB{},
336 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct2)
337 -- @fillStruct3/fillStruct.go --
338 @@ -22 +22,3 @@
339 - c := StructA3{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct3)
340 + c := StructA3{
341 + B: StructB{},
342 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct3)
343 -- @fillStruct4/fillStruct.go --
344 @@ -24 +24,3 @@
345 - _ = StructA3{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct4)
346 + _ = StructA3{
347 + B: StructB{},
348 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct4)
349 -- fillStruct_anon.go --
350 package fillstruct
351
352 type StructAnon struct {
353 a struct{}
354 b map[string]any
355 c map[string]struct {
356 d int
357 e bool
358 }
359 }
360
361 func fill() {
362 _ := StructAnon{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_anon)
363 }
364 -- @fillStruct_anon/fillStruct_anon.go --
365 @@ -13 +13,8 @@
366 - _ := StructAnon{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_anon)
367 + _ := StructAnon{
368 + a: struct{}{},
369 + b: map[string]any{},
370 + c: map[string]struct {
371 + d int
372 + e bool
373 + }{},
374 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_anon)
375 -- fillStruct_nested.go --
376 package fillstruct
377
378 type StructB struct {
379 StructC
380 }
381
382 type StructC struct {
383 unexportedInt int
384 }
385
386 func nested() {
387 c := StructB{
388 StructC: StructC{}, //@codeaction("}", "refactor.rewrite.fillStruct", edit=fill_nested)
389 }
390 }
391
392 -- @fill_nested/fillStruct_nested.go --
393 @@ -13 +13,3 @@
394 - StructC: StructC{}, //@codeaction("}", "refactor.rewrite.fillStruct", edit=fill_nested)
395 + StructC: StructC{
396 + unexportedInt: 0,
397 + }, //@codeaction("}", "refactor.rewrite.fillStruct", edit=fill_nested)
398 -- fillStruct_package.go --
399 package fillstruct
400
401 import (
402 h2 "net/http"
403
404 "golang.org/lsptests/fillstruct/data"
405 )
406
407 func unexported() {
408 a := data.B{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_package1)
409 _ = h2.Client{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_package2)
410 }
411 -- @fillStruct_package1/fillStruct_package.go --
412 @@ -10 +10,3 @@
413 - a := data.B{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_package1)
414 + a := data.B{
415 + ExportedInt: 0,
416 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_package1)
417 -- @fillStruct_package2/fillStruct_package.go --
418 @@ -11 +11,8 @@
419 - _ = h2.Client{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_package2)
420 + _ = h2.Client{
421 + Transport: nil,
422 + CheckRedirect: func(req *h2.Request, via []*h2.Request) error {
423 + panic("TODO")
424 + },
425 + Jar: nil,
426 + Timeout: 0,
427 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_package2)
428 -- fillStruct_partial.go --
429 package fillstruct
430
431 type StructPartialA struct {
432 PrefilledInt int
433 UnfilledInt int
434 StructPartialB
435 }
436
437 type StructPartialB struct {
438 PrefilledInt int
439 UnfilledInt int
440 }
441
442 func fill() {
443 a := StructPartialA{
444 PrefilledInt: 5,
445 } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_partial1)
446 b := StructPartialB{
447 /* this comment should be preserved */
448 PrefilledInt: 7, // This comment should be preserved.
449 /* As should
450 this one */
451 } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_partial2)
452 }
453
454 -- @fillStruct_partial1/fillStruct_partial.go --
455 @@ -16 +16,3 @@
456 - PrefilledInt: 5,
457 + PrefilledInt: 5,
458 + UnfilledInt: 0,
459 + StructPartialB: StructPartialB{},
460 -- @fillStruct_partial2/fillStruct_partial.go --
461 @@ -23 +23 @@
462 + UnfilledInt: 0,
463 -- fillStruct_spaces.go --
464 package fillstruct
465
466 type StructD struct {
467 ExportedIntField int
468 }
469
470 func spaces() {
471 d := StructD{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_spaces)
472 }
473
474 -- @fillStruct_spaces/fillStruct_spaces.go --
475 @@ -8 +8,3 @@
476 - d := StructD{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_spaces)
477 + d := StructD{
478 + ExportedIntField: 0,
479 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_spaces)
480 -- fillStruct_unsafe.go --
481 package fillstruct
482
483 import "unsafe"
484
485 type unsafeStruct struct {
486 x int
487 p unsafe.Pointer
488 }
489
490 func fill() {
491 _ := unsafeStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_unsafe)
492 }
493
494 -- @fillStruct_unsafe/fillStruct_unsafe.go --
495 @@ -11 +11,4 @@
496 - _ := unsafeStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_unsafe)
497 + _ := unsafeStruct{
498 + x: 0,
499 + p: nil,
500 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=fillStruct_unsafe)
501 -- typeparams.go --
502 package fillstruct
503
504 type emptyStructWithTypeParams[A any] struct{}
505
506 var _ = emptyStructWithTypeParams[int]{} // no suggested fix
507
508 type basicStructWithTypeParams[T any] struct {
509 foo T
510 }
511
512 var _ = basicStructWithTypeParams[int]{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams1)
513
514 type twoArgStructWithTypeParams[F, B any] struct {
515 foo F
516 bar B
517 }
518
519 var _ = twoArgStructWithTypeParams[string, int]{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams2)
520
521 var _ = twoArgStructWithTypeParams[int, string]{
522 bar: "bar",
523 } //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams3)
524
525 type nestedStructWithTypeParams struct {
526 bar string
527 basic basicStructWithTypeParams[int]
528 }
529
530 var _ = nestedStructWithTypeParams{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams4)
531
532 func _[T any]() {
533 type S struct{ t T }
534 _ = S{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams5)
535
536 type P struct{ t *T }
537 _ = P{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams6)
538
539 type Alias[u any] = struct {
540 x u
541 y *T
542 }
543 _ = Alias[string]{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams7)
544
545 type Named[u any] struct {
546 x u
547 y T
548 }
549 _ = Named[int]{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams8)
550 }
551 -- @typeparams1/typeparams.go --
552 @@ -11 +11,3 @@
553 -var _ = basicStructWithTypeParams[int]{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams1)
554 +var _ = basicStructWithTypeParams[int]{
555 + foo: 0,
556 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams1)
557 -- @typeparams2/typeparams.go --
558 @@ -18 +18,4 @@
559 -var _ = twoArgStructWithTypeParams[string, int]{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams2)
560 +var _ = twoArgStructWithTypeParams[string, int]{
561 + foo: "",
562 + bar: 0,
563 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams2)
564 -- @typeparams3/typeparams.go --
565 @@ -22 +22 @@
566 + foo: 0,
567 -- @typeparams4/typeparams.go --
568 @@ -29 +29,4 @@
569 -var _ = nestedStructWithTypeParams{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams4)
570 +var _ = nestedStructWithTypeParams{
571 + bar: "",
572 + basic: basicStructWithTypeParams[int]{},
573 +} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams4)
574 -- @typeparams5/typeparams.go --
575 @@ -33 +33,3 @@
576 - _ = S{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams5)
577 + _ = S{
578 + t: *new(T),
579 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams5)
580 -- @typeparams6/typeparams.go --
581 @@ -36 +36,3 @@
582 - _ = P{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams6)
583 + _ = P{
584 + t: new(T),
585 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams6)
586 -- @typeparams7/typeparams.go --
587 @@ -42 +42,4 @@
588 - _ = Alias[string]{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams7)
589 + _ = Alias[string]{
590 + x: "",
591 + y: new(T),
592 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams7)
593 -- @typeparams8/typeparams.go --
594 @@ -48 +48,4 @@
595 - _ = Named[int]{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams8)
596 + _ = Named[int]{
597 + x: 0,
598 + y: *new(T),
599 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=typeparams8)
600 -- issue63921.go --
601 package fillstruct
602
603 // Test for golang/go#63921: fillstruct panicked with invalid fields.
604 type invalidStruct struct {
605 F int
606 Undefined
607 }
608
609 func _() {
610 // Note: fillstruct now skips invalid/unresolvable fields (like Undefined)
611 // rather than aborting completely, it successfully fills the valid field F.
612 invalidStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=issue63921)
613 }
614 -- @issue63921/issue63921.go --
615 @@ -12 +12,3 @@
616 - invalidStruct{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=issue63921)
617 + invalidStruct{
618 + F: 0,
619 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=issue63921)
620 -- named/named.go --
621 package named
622
623 type foo struct {}
624 type aliasFoo = foo
625
626 func _() {
627 type namedInt int
628 type namedString string
629 type namedBool bool
630 type namedPointer *foo
631 type namedSlice []foo
632 type namedInterface interface{ Error() string }
633 type namedChan chan int
634 type namedMap map[string]foo
635 type namedSignature func(string) string
636 type namedStruct struct{}
637 type namedArray [3]foo
638 type namedAlias aliasFoo
639
640 type bar struct {
641 namedInt namedInt
642 namedString namedString
643 namedBool namedBool
644 namedPointer namedPointer
645 namedSlice namedSlice
646 namedInterface namedInterface
647 namedChan namedChan
648 namedMap namedMap
649 namedSignature namedSignature
650 namedStruct namedStruct
651 namedArray namedArray
652 namedAlias namedAlias
653 }
654
655 bar{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=named)
656 }
657 -- @named/named/named.go --
658 @@ -35 +35,14 @@
659 - bar{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=named)
660 + bar{
661 + namedInt: 0,
662 + namedString: "",
663 + namedBool: false,
664 + namedPointer: nil,
665 + namedSlice: namedSlice{},
666 + namedInterface: nil,
667 + namedChan: nil,
668 + namedMap: namedMap{},
669 + namedSignature: nil,
670 + namedStruct: namedStruct{},
671 + namedArray: namedArray{},
672 + namedAlias: namedAlias{},
673 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=named)
674 -- alias/alias.go --
675 package alias
676
677 type foo struct {}
678 type aliasFoo = foo
679
680 func _() {
681 type aliasInt = int
682 type aliasString = string
683 type aliasBool = bool
684 type aliasPointer = *foo
685 type aliasSlice = []foo
686 type aliasInterface = interface{ Error() string }
687 type aliasChan = chan int
688 type aliasMap = map[string]foo
689 type aliasSignature = func(string) string
690 type aliasStruct = struct{ bar string }
691 type aliasArray = [3]foo
692 type aliasNamed = foo
693
694 type bar struct {
695 aliasInt aliasInt
696 aliasString aliasString
697 aliasBool aliasBool
698 aliasPointer aliasPointer
699 aliasSlice aliasSlice
700 aliasInterface aliasInterface
701 aliasChan aliasChan
702 aliasMap aliasMap
703 aliasSignature aliasSignature
704 aliasStruct aliasStruct
705 aliasArray aliasArray
706 aliasNamed aliasNamed
707 }
708
709 bar{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=alias)
710 }
711 -- @alias/alias/alias.go --
712 @@ -35 +35,14 @@
713 - bar{} //@codeaction("}", "refactor.rewrite.fillStruct", edit=alias)
714 + bar{
715 + aliasInt: 0,
716 + aliasString: "",
717 + aliasBool: false,
718 + aliasPointer: nil,
719 + aliasSlice: aliasSlice{},
720 + aliasInterface: nil,
721 + aliasChan: nil,
722 + aliasMap: aliasMap{},
723 + aliasSignature: nil,
724 + aliasStruct: aliasStruct{},
725 + aliasArray: aliasArray{},
726 + aliasNamed: aliasNamed{},
727 + } //@codeaction("}", "refactor.rewrite.fillStruct", edit=alias)