-
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: use exact match in import highlighting
Previously, hovering on a package name such as http.XYZ would highlight its import path ("net/http"), but also any other one that contained it as a substring, such as "net/http/httptest". (This behavior was there from the outset in CL 215258, but wasn't remarked upon during the review.) This change uses exact matching based on type-checker objects, not strings,, adds a test of same, and clarifies the logic. Fixes golang/go#60435 Change-Id: I9cc07dbcdaf54707d17be2a162bfcb0a22aa440a Reviewed-on: https://go-review.googlesource.com/c/tools/+/498268 Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
- Loading branch information
Showing
7 changed files
with
76 additions
and
77 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
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
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 @@ | ||
package highlights | ||
|
||
import ( | ||
"net/http" //@mark(httpImp, `"net/http"`) | ||
"net/http/httptest" //@mark(httptestImp, `"net/http/httptest"`) | ||
) | ||
|
||
// This is a regression test for issue 60435: | ||
// Highlighting "net/http" shouldn't have any effect | ||
// on an import path that contains it as a substring, | ||
// such as httptest. | ||
|
||
var _ = httptest.NewRequest | ||
var _ = http.NewRequest //@mark(here, "http"), highlight(here, here, httpImp) |
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
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