| 1 |
This test verifies the fix for golang/go#44813: extraction failure when there |
| 2 |
are blank identifiers. |
| 3 |
|
| 4 |
-- go.mod -- |
| 5 |
module mod.test/extract |
| 6 |
|
| 7 |
go 1.18 |
| 8 |
|
| 9 |
-- p.go -- |
| 10 |
package extract |
| 11 |
|
| 12 |
import "fmt" |
| 13 |
|
| 14 |
func main() { |
| 15 |
x := []rune{} //@codeaction("x", "refactor.extract.function", end=end, result=ext) |
| 16 |
s := "HELLO" |
| 17 |
for _, c := range s { |
| 18 |
x = append(x, c) |
| 19 |
} //@loc(end, "}") |
| 20 |
fmt.Printf("%x\n", x) |
| 21 |
} |
| 22 |
|
| 23 |
-- @ext/p.go -- |
| 24 |
package extract |
| 25 |
|
| 26 |
import "fmt" |
| 27 |
|
| 28 |
func main() { |
| 29 |
x := newFunction() //@loc(end, "}") |
| 30 |
fmt.Printf("%x\n", x) |
| 31 |
} |
| 32 |
|
| 33 |
func newFunction() []rune { |
| 34 |
x := []rune{} //@codeaction("x", "refactor.extract.function", end=end, result=ext) |
| 35 |
s := "HELLO" |
| 36 |
for _, c := range s { |
| 37 |
x = append(x, c) |
| 38 |
} |
| 39 |
return x |
| 40 |
} |
| 41 |
|