| 1 |
This test checks the behavior of removing a parameter with respect to various |
| 2 |
import scenarios. |
| 3 |
|
| 4 |
Wholly unused imports are expected to be removed by a subsequent |
| 5 |
"organize imports" step. |
| 6 |
|
| 7 |
-- go.mod -- |
| 8 |
module mod.test |
| 9 |
|
| 10 |
go 1.21 |
| 11 |
|
| 12 |
|
| 13 |
-- a/a1.go -- |
| 14 |
package a |
| 15 |
|
| 16 |
import "mod.test/b" |
| 17 |
|
| 18 |
func _() { |
| 19 |
b.B(<-b.Chan, <-b.Chan) |
| 20 |
} |
| 21 |
|
| 22 |
-- a/a2.go -- |
| 23 |
package a |
| 24 |
|
| 25 |
import "mod.test/b" |
| 26 |
|
| 27 |
func _() { |
| 28 |
b.B(<-b.Chan, <-b.Chan) |
| 29 |
b.B(<-b.Chan, <-b.Chan) |
| 30 |
} |
| 31 |
|
| 32 |
-- a/a3.go -- |
| 33 |
package a |
| 34 |
|
| 35 |
import "mod.test/b" |
| 36 |
|
| 37 |
func _() { |
| 38 |
b.B(<-b.Chan, <-b.Chan) |
| 39 |
} |
| 40 |
|
| 41 |
func _() { |
| 42 |
b.B(<-b.Chan, <-b.Chan) |
| 43 |
} |
| 44 |
|
| 45 |
-- a/a4.go -- |
| 46 |
package a |
| 47 |
|
| 48 |
// TODO(rfindley/adonovan): inlining here adds an additional import of |
| 49 |
// mod.test/b. Can we do better? |
| 50 |
import ( |
| 51 |
. "mod.test/b" |
| 52 |
) |
| 53 |
|
| 54 |
func _() { |
| 55 |
B(<-Chan, <-Chan) |
| 56 |
} |
| 57 |
|
| 58 |
-- b/b.go -- |
| 59 |
package b |
| 60 |
|
| 61 |
import "mod.test/c" |
| 62 |
|
| 63 |
var Chan chan c.C |
| 64 |
|
| 65 |
func B(x, y c.C) { //@codeaction("x", "refactor.rewrite.removeUnusedParam", result=b) |
| 66 |
} |
| 67 |
|
| 68 |
-- @b/a/a3.go -- |
| 69 |
package a |
| 70 |
|
| 71 |
import "mod.test/b" |
| 72 |
|
| 73 |
func _() { |
| 74 |
b.B(<-b.Chan) |
| 75 |
} |
| 76 |
|
| 77 |
func _() { |
| 78 |
b.B(<-b.Chan) |
| 79 |
} |
| 80 |
-- @b/a/a2.go -- |
| 81 |
package a |
| 82 |
|
| 83 |
import "mod.test/b" |
| 84 |
|
| 85 |
func _() { |
| 86 |
b.B(<-b.Chan) |
| 87 |
b.B(<-b.Chan) |
| 88 |
} |
| 89 |
-- @b/a/a1.go -- |
| 90 |
package a |
| 91 |
|
| 92 |
import "mod.test/b" |
| 93 |
|
| 94 |
func _() { |
| 95 |
b.B(<-b.Chan) |
| 96 |
} |
| 97 |
-- @b/a/a4.go -- |
| 98 |
package a |
| 99 |
|
| 100 |
// TODO(rfindley/adonovan): inlining here adds an additional import of |
| 101 |
// mod.test/b. Can we do better? |
| 102 |
import ( |
| 103 |
"mod.test/b" |
| 104 |
. "mod.test/b" |
| 105 |
) |
| 106 |
|
| 107 |
func _() { |
| 108 |
b.B(<-Chan) |
| 109 |
} |
| 110 |
-- @b/b/b.go -- |
| 111 |
package b |
| 112 |
|
| 113 |
import "mod.test/c" |
| 114 |
|
| 115 |
var Chan chan c.C |
| 116 |
|
| 117 |
func B(y c.C) { //@codeaction("x", "refactor.rewrite.removeUnusedParam", result=b) |
| 118 |
} |
| 119 |
-- c/c.go -- |
| 120 |
package c |
| 121 |
|
| 122 |
type C int |
| 123 |
|
| 124 |
-- d/d.go -- |
| 125 |
package d |
| 126 |
|
| 127 |
// Removing the parameter should remove this import. |
| 128 |
import "mod.test/c" |
| 129 |
|
| 130 |
func D(x c.C) { //@codeaction("x", "refactor.rewrite.removeUnusedParam", result=d) |
| 131 |
} |
| 132 |
|
| 133 |
func _() { |
| 134 |
D(1) |
| 135 |
} |
| 136 |
|
| 137 |
-- @d/d/d.go -- |
| 138 |
package d |
| 139 |
|
| 140 |
// Removing the parameter should remove this import. |
| 141 |
|
| 142 |
func D() { //@codeaction("x", "refactor.rewrite.removeUnusedParam", result=d) |
| 143 |
} |
| 144 |
|
| 145 |
func _() { |
| 146 |
D() |
| 147 |
} |