aboutsummaryrefslogtreecommitdiff
path: root/internal/lsp
diff options
context:
space:
mode:
authorSuzy Mueller <suzmue@golang.org>2022-06-30 17:09:03 -0400
committerSuzy Mueller <suzmue@golang.org>2022-08-11 16:19:14 +0000
commit37a81b68a061ab2fad895d022a5a665d87c44e40 (patch)
treeed313918ed97d7461ef8d853cb9261679bce0226 /internal/lsp
parent38074195235bdd653de752af11c4a3ca1b77aec3 (diff)
downloadgolang-x-tools-37a81b68a061ab2fad895d022a5a665d87c44e40.tar.gz
internal/lsp: add unnecessary tags for unused vars and imports
Diagnostic Tags add another hint for the client for how to display diagnostics. The Unnecessary tags allows clients to fade out the diagnostic instead of adding a squiggle. This adds this tag to unused import errors as well as unused vars. For golang/vscode-go#2285 Change-Id: I0c93b28a6a2ef4eed314dcf30a37c27dd65940ac Reviewed-on: https://go-review.googlesource.com/c/tools/+/415499 Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'internal/lsp')
-rw-r--r--internal/lsp/cache/errors.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/internal/lsp/cache/errors.go b/internal/lsp/cache/errors.go
index a1aecb35c..80ae5451c 100644
--- a/internal/lsp/cache/errors.go
+++ b/internal/lsp/cache/errors.go
@@ -123,6 +123,10 @@ func typeErrorDiagnostics(snapshot *snapshot, pkg *pkg, e extendedError) ([]*sou
diag.Code = code.String()
diag.CodeHref = typesCodeHref(snapshot, code)
}
+ switch code {
+ case typesinternal.UnusedVar, typesinternal.UnusedImport:
+ diag.Tags = append(diag.Tags, protocol.Unnecessary)
+ }
for _, secondary := range e.secondaries {
_, secondarySpan, err := typeErrorData(snapshot.FileSet(), pkg, secondary)