Skip to content

Commit d4ccfb4

Browse files
committed
feat(internal/lsp): PublishDiagnosticTag 调用之前检测是否支持该功能
1 parent e6c2475 commit d4ccfb4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

internal/lsp/protocol/textdocument.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,23 @@ type TextDocumentClientCapabilities struct {
293293
PublishDiagnostics struct {
294294
// Whether the clients accepts diagnostics with related information.
295295
RelatedInformation bool `json:"relatedInformation,omitempty"`
296+
297+
// Client supports the tag property to provide meta data about a diagnostic.
298+
// Clients supporting tags have to handle unknown tags gracefully.
299+
//
300+
// @since 3.15.0
301+
TagSupport struct {
302+
// The tags supported by the client.
303+
ValueSet []DiagnosticTag `json:"valueSet,omitempty"`
304+
} `json:"tagSupport,omitempty"`
305+
306+
// Whether the client interprets the version property of the
307+
// `textDocument/publishDiagnostics` notification's parameter.
308+
//
309+
// @since 3.15.0
310+
VersionSupport bool `json:"versionSupport,omitempty"`
296311
} `json:"publishDiagnostics,omitempty"`
312+
297313
// Capabilities specific to `textDocument/foldingRange` requests.
298314
//
299315
// Since 3.10.0

internal/lsp/textdocument.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ func (f *folder) searchHover(uri core.URI, pos core.Position, hover *protocol.Ho
106106
//
107107
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_publishDiagnostics
108108
func (s *server) textDocumentPublishDiagnostics(uri core.URI, errs []*core.SyntaxError, warns []*core.SyntaxError) error {
109+
110+
if s.clientCapabilities.TextDocument.PublishDiagnostics.RelatedInformation == false {
111+
return nil
112+
}
113+
109114
p := &protocol.PublishDiagnosticsParams{
110115
URI: uri,
111116
Diagnostics: make([]protocol.Diagnostic, 0, len(errs)+len(warns)),

0 commit comments

Comments
 (0)