-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/lsp/source: fix comment update during rename for short varia…
…ble declarations *ast.AssignStmt doesn't have an associated comment group. So, we should try to find and return a comment just before the identifier. Fixes golang/go#42134 Change-Id: Ie40717a4973ccfdbd99c3df891c2cfffbb21742d GitHub-Last-Rev: da75fde GitHub-Pull-Request: #323 Reviewed-on: https://go-review.googlesource.com/c/tools/+/327229 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Trust: Rebecca Stambler <rstambler@golang.org> Trust: Robert Findley <rfindley@google.com> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org>
- Loading branch information
1 parent
a7dfe3d
commit ccff732
Showing
10 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package issue42134 | ||
|
||
func _() { | ||
// foo computes things. | ||
foo := func() {} | ||
|
||
foo() //@rename("foo", "bar") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- bar-rename -- | ||
package issue42134 | ||
|
||
func _() { | ||
// bar computes things. | ||
bar := func() {} | ||
|
||
bar() //@rename("foo", "bar") | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package issue42134 | ||
|
||
import "fmt" | ||
|
||
func _() { | ||
// minNumber is a min number. | ||
// Second line. | ||
minNumber := min(1, 2) | ||
fmt.Println(minNumber) //@rename("minNumber", "res") | ||
} | ||
|
||
func min(a, b int) int { return a } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- res-rename -- | ||
package issue42134 | ||
|
||
import "fmt" | ||
|
||
func _() { | ||
// res is a min number. | ||
// Second line. | ||
res := min(1, 2) | ||
fmt.Println(res) //@rename("minNumber", "res") | ||
} | ||
|
||
func min(a, b int) int { return a } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package issue42134 | ||
|
||
func _() { | ||
/* | ||
tests contains test cases | ||
*/ | ||
tests := []struct { //@rename("tests", "testCases") | ||
in, out string | ||
}{} | ||
_ = tests | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- testCases-rename -- | ||
package issue42134 | ||
|
||
func _() { | ||
/* | ||
testCases contains test cases | ||
*/ | ||
testCases := []struct { //@rename("tests", "testCases") | ||
in, out string | ||
}{} | ||
_ = testCases | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package issue42134 | ||
|
||
func _() { | ||
// a is equal to 5. Comment must stay the same | ||
|
||
a := 5 | ||
_ = a //@rename("a", "b") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- b-rename -- | ||
package issue42134 | ||
|
||
func _() { | ||
// a is equal to 5. Comment must stay the same | ||
|
||
b := 5 | ||
_ = b //@rename("a", "b") | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters