mirror of
https://github.com/golang/go
synced 2024-11-18 17:14:45 -07:00
internal/lsp: find import errors for named imports
String matching is used to find diagnostics that could be fixed by organizing imports. Unused imports are of the form: "X imported but not used" "X imported but not used as Y" Check that "imported but not used" is contained in the message to include both named and unnamed imports. Change-Id: I478d1fb239962e706eb1adf305b858fcc875b7f0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/188158 Run-TryBot: Suzy Mueller <suzmue@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
ed3277de27
commit
a81e99d748
@ -123,7 +123,8 @@ func findImportErrors(diagnostics []protocol.Diagnostic) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// "X imported but not used" is an unused import.
|
// "X imported but not used" is an unused import.
|
||||||
if strings.HasSuffix(diagnostic.Message, " imported but not used") {
|
// "X imported but not used as Y" is an unused import.
|
||||||
|
if strings.Contains(diagnostic.Message, " imported but not used") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user