-
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.
gopls/internal/lsp/source: highlight returns correctly
Rewrite the control flow highlighting logic to be more understandable, and to fix a bug where multi-name result parameters were not properly counted. Fixes golang/go#60589 Change-Id: Id12ada78852be0a8376fbd482326322fc1b87fcf Reviewed-on: https://go-review.googlesource.com/c/tools/+/503439 Auto-Submit: Robert Findley <[email protected]> Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
- Loading branch information
Showing
2 changed files
with
171 additions
and
87 deletions.
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
30 changes: 30 additions & 0 deletions
30
gopls/internal/test/marker/testdata/highlight/issue60589.txt
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,30 @@ | ||
This test verifies that control flow lighlighting correctly accounts for | ||
multi-name result parameters. In golang/go#60589, it did not. | ||
|
||
-- go.mod -- | ||
module mod.com | ||
|
||
go 1.18 | ||
|
||
-- p.go -- | ||
package p | ||
|
||
func _() (foo int, bar, baz string) { //@ loc(func, "func"), loc(foo, "foo"), loc(fooint, "foo int"), loc(int, "int"), loc(bar, "bar"), loc(beforebaz, " baz"), loc(baz, "baz"), loc(barbazstring, "bar, baz string"), loc(beforestring, re`() string`), loc(string, "string") | ||
return 0, "1", "2" //@ loc(return, `return 0, "1", "2"`), loc(l0, "0"), loc(l1, `"1"`), loc(l2, `"2"`) | ||
} | ||
|
||
// Assertions, expressed here to avoid clutter above. | ||
// Note that when the cursor is over the field type, there is some | ||
// (likely harmless) redundancy. | ||
|
||
//@ highlight(func, func, return) | ||
//@ highlight(foo, foo, l0) | ||
//@ highlight(int, fooint, int, l0) | ||
//@ highlight(bar, bar, l1) | ||
//@ highlight(beforebaz) | ||
//@ highlight(baz, baz, l2) | ||
//@ highlight(beforestring, baz, l2) | ||
//@ highlight(string, barbazstring, string, l1, l2) | ||
//@ highlight(l0, foo, l0) | ||
//@ highlight(l1, bar, l1) | ||
//@ highlight(l2, baz, l2) |