From 86e17f0e6f5540f8680fb589dba0b7968cf950e9 Mon Sep 17 00:00:00 2001 From: Dmitriy Antonov Date: Fri, 10 May 2024 15:10:59 +0300 Subject: [PATCH 1/3] support textDocument/diagnostic method --- protocol_3_16/diagnostics.go | 223 ++++++++++++++++++++++++++++++ protocol_3_16/general-messages.go | 29 ++++ protocol_3_16/handler.go | 17 +++ 3 files changed, 269 insertions(+) diff --git a/protocol_3_16/diagnostics.go b/protocol_3_16/diagnostics.go index 08e6cc5..a0d12b6 100644 --- a/protocol_3_16/diagnostics.go +++ b/protocol_3_16/diagnostics.go @@ -1,5 +1,7 @@ package protocol +import "github.com/tliron/glsp" + // https://microsoft.github.io/language-server-protocol/specifications/specification-3-16#textDocument_publishDiagnostics type PublishDiagnosticsClientCapabilities struct { @@ -67,3 +69,224 @@ type PublishDiagnosticsParams struct { */ Diagnostics []Diagnostic `json:"diagnostics"` } + +/** + * Client capabilities specific to diagnostic pull requests. + * + * @since 3.17.0 + */ +type DiagnosticClientCapabilities struct { + /** + * Whether implementation supports dynamic registration. If this is set to + * `true` the client supports the new + * `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` + * return value for the corresponding server capability as well. + */ + DynamicRegistration bool `json:"dynamicRegistration"` + + /** + * Whether the clients supports related documents for document diagnostic + * pulls. + */ + RelatedDocumentSupport bool `json:"relatedDocumentSupport"` +} + +/** + * Diagnostic options. + * + * @since 3.17.0 + */ +type DiagnosticOptions struct { + WorkDoneProgressOptions + /** + * An optional identifier under which the diagnostics are + * managed by the client. + */ + Identifier *string `json:"identifier"` + + /** + * Whether the language has inter file dependencies meaning that + * editing code in one file can result in a different diagnostic + * set in another file. Inter file dependencies are common for + * most programming languages and typically uncommon for linters. + */ + InterFileDependencies bool `json:"interFileDependencies"` + + /** + * The server provides support for workspace diagnostics as well. + */ + WorkspaceDiagnostics bool `json:"workspaceDiagnostics"` +} + +/** + * Diagnostic registration options. + * + * @since 3.17.0 + */ +type DiagnosticRegistrationOptions struct { + TextDocumentRegistrationOptions + DiagnosticOptions + StaticRegistrationOptions +} + +const MethodTextDocumentDiagnostic = Method("textDocument/diagnostic") + +type TextDocumentDiagnosticFunc func(context *glsp.Context, params *DocumentDiagnosticParams) (any, error) + +/** + * Parameters of the document diagnostic request. + * + * @since 3.17.0 + */ +type DocumentDiagnosticParams struct { + WorkDoneProgressParams + PartialResultParams + + /** + * The text document. + */ + TextDocument TextDocumentIdentifier `json:"textDocument"` + + /** + * The additional identifier provided during registration. + */ + Identifier *string `json:"identifier,omitempty"` + + /** + * The result id of a previous response if provided. + */ + PreviousResultId *string `json:"previousResultId,omitempty"` +} + +/** + * The result of a document diagnostic pull request. A report can + * either be a full report containing all diagnostics for the + * requested document or a unchanged report indicating that nothing + * has changed in terms of diagnostics in comparison to the last + * pull request. + * + * @since 3.17.0 + */ +type DocumentDiagnosticReport any // RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport + +/** + * The document diagnostic report kinds. + * + * @since 3.17.0 + */ +type DocumentDiagnosticReportKind string + +const ( + /** + * A diagnostic report with a full + * set of problems. + */ + DocumentDiagnosticReportKindFull = DocumentDiagnosticReportKind("full") + /** + * A report indicating that the last + * returned report is still accurate. + */ + DocumentDiagnosticReportKindUnchanged = DocumentDiagnosticReportKind("unchanged") +) + +/** + * A diagnostic report with a full set of problems. + * + * @since 3.17.0 + */ +type FullDocumentDiagnosticReport struct { + /** + * A full document diagnostic report. + */ + Kind string `json:"kind"` + + /** + * An optional result id. If provided it will + * be sent on the next diagnostic request for the + * same document. + */ + ResultID *string `json:"resultId,omitempty"` + + /** + * The actual items. + */ + Items []Diagnostic `json:"items"` +} + +/** + * A diagnostic report indicating that the last returned + * report is still accurate. + * + * @since 3.17.0 + */ +type UnchangedDocumentDiagnosticReport struct { + /** + * A document diagnostic report indicating + * no changes to the last result. A server can + * only return `unchanged` if result ids are + * provided. + */ + Kind string `json:"kind"` + + /** + * A result id which will be sent on the next + * diagnostic request for the same document. + */ + ResultID string `json:"resultId"` +} + +/** + * A full diagnostic report with a set of related documents. + * + * @since 3.17.0 + */ +type RelatedFullDocumentDiagnosticReport struct { + FullDocumentDiagnosticReport + /** + * Diagnostics of related documents. This information is useful + * in programming languages where code in a file A can generate + * diagnostics in a file B which A depends on. An example of + * such a language is C/C++ where marco definitions in a file + * a.cpp and result in errors in a header file b.hpp. + * + * @since 3.17.0 + */ + RelatedDocuments map[DocumentUri]interface{} `json:"relatedDocuments,omitempty"` +} + +/** + * An unchanged diagnostic report with a set of related documents. + * + * @since 3.17.0 + */ +type RelatedUnchangedDocumentDiagnosticReport struct { + UnchangedDocumentDiagnosticReport + /** + * Diagnostics of related documents. This information is useful + * in programming languages where code in a file A can generate + * diagnostics in a file B which A depends on. An example of + * such a language is C/C++ where marco definitions in a file + * a.cpp and result in errors in a header file b.hpp. + * + * @since 3.17.0 + */ + RelatedDocuments map[DocumentUri]interface{} `json:"relatedDocuments,omitempty"` +} + +/** + * A partial result for a document diagnostic report. + * + * @since 3.17.0 + */ +type DocumentDiagnosticReportPartialResult struct { + RelatedDocuments map[DocumentUri]interface{} `json:"relatedDocuments"` +} + +/** + * Cancellation data returned from a diagnostic request. + * + * @since 3.17.0 + */ +type DiagnosticServerCancellationData struct { + RetriggerRequest bool `json:"retriggerRequest"` +} diff --git a/protocol_3_16/general-messages.go b/protocol_3_16/general-messages.go index 97f9629..083915c 100644 --- a/protocol_3_16/general-messages.go +++ b/protocol_3_16/general-messages.go @@ -248,6 +248,13 @@ type TextDocumentClientCapabilities struct { * @since 3.16.0 */ Moniker *MonikerClientCapabilities `json:"moniker,omitempty"` + + /** + * Capabilities specific to the diagnostic pull model. + * + * @since 3.17.0 + */ + Diagnostic *DiagnosticClientCapabilities `json:"diagnostic,omitempty"` } type ClientCapabilities struct { @@ -650,6 +657,13 @@ type ServerCapabilities struct { */ MonikerProvider any `json:"monikerProvider,omitempty"` // nil | bool | MonikerOptions | MonikerRegistrationOptions + /** + * The server has support for pull model diagnostics. + * + * @since 3.17.0 + */ + DiagnosticProvider any `json:"diagnosticProvider,omitempty"` // nil | DiagnosticOptions | DiagnosticRegistrationOptions + /** * The server provides workspace symbol support. */ @@ -750,6 +764,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { WorkspaceSymbolProvider json.RawMessage `json:"workspaceSymbolProvider,omitempty"` // nil | bool | WorkspaceSymbolOptions Workspace *ServerCapabilitiesWorkspace `json:"workspace,omitempty"` Experimental *any `json:"experimental,omitempty"` + DiagnosticProvider json.RawMessage `json:"diagnosticProvider,omitempty"` // nil | DiagnosticOptions | DiagnosticRegistrationOptions } if err := json.Unmarshal(data, &value); err == nil { @@ -1100,6 +1115,20 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { } } + if value.DiagnosticProvider != nil { + var value_ DiagnosticOptions + if err = json.Unmarshal(value.DiagnosticProvider, &value_); err == nil { + self.DiagnosticProvider = value_ + } else { + var value_ DiagnosticRegistrationOptions + if err = json.Unmarshal(value.DiagnosticProvider, &value_); err == nil { + self.DiagnosticProvider = value_ + } else { + return err + } + } + } + return nil } else { return err diff --git a/protocol_3_16/handler.go b/protocol_3_16/handler.go index 1fa0c2b..2bfc27e 100644 --- a/protocol_3_16/handler.go +++ b/protocol_3_16/handler.go @@ -81,6 +81,7 @@ type Handler struct { TextDocumentSemanticTokensRange TextDocumentSemanticTokensRangeFunc TextDocumentLinkedEditingRange TextDocumentLinkedEditingRangeFunc TextDocumentMoniker TextDocumentMonikerFunc + TextDocumentDiagnostic TextDocumentDiagnosticFunc initialized bool lock sync.Mutex @@ -709,6 +710,15 @@ func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, val r, err = self.TextDocumentMoniker(context, ¶ms) } } + case MethodTextDocumentDiagnostic: + if self.TextDocumentDiagnostic != nil { + validMethod = true + var params DocumentDiagnosticParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentDiagnostic(context, ¶ms) + } + } } return @@ -961,5 +971,12 @@ func (self *Handler) CreateServerCapabilities() ServerCapabilities { } } + if self.TextDocumentDiagnostic != nil { + capabilities.DiagnosticProvider = DiagnosticOptions{ + InterFileDependencies: true, + WorkspaceDiagnostics: false, + } + } + return capabilities } From 647a6e12c6063ff7a442d643156b54ba5a6ab7e6 Mon Sep 17 00:00:00 2001 From: Dmitriy Antonov Date: Sat, 11 May 2024 16:36:34 +0300 Subject: [PATCH 2/3] move 3.17 protocol to separate directory --- protocol_3_16/diagnostics.go | 223 -------- protocol_3_16/general-messages.go | 29 - protocol_3_16/handler.go | 17 - protocol_3_17/diagnostics.go | 227 ++++++++ protocol_3_17/general-messages.go | 471 +++++++++++++++ protocol_3_17/handler.go | 912 ++++++++++++++++++++++++++++++ 6 files changed, 1610 insertions(+), 269 deletions(-) create mode 100644 protocol_3_17/diagnostics.go create mode 100644 protocol_3_17/general-messages.go create mode 100644 protocol_3_17/handler.go diff --git a/protocol_3_16/diagnostics.go b/protocol_3_16/diagnostics.go index a0d12b6..08e6cc5 100644 --- a/protocol_3_16/diagnostics.go +++ b/protocol_3_16/diagnostics.go @@ -1,7 +1,5 @@ package protocol -import "github.com/tliron/glsp" - // https://microsoft.github.io/language-server-protocol/specifications/specification-3-16#textDocument_publishDiagnostics type PublishDiagnosticsClientCapabilities struct { @@ -69,224 +67,3 @@ type PublishDiagnosticsParams struct { */ Diagnostics []Diagnostic `json:"diagnostics"` } - -/** - * Client capabilities specific to diagnostic pull requests. - * - * @since 3.17.0 - */ -type DiagnosticClientCapabilities struct { - /** - * Whether implementation supports dynamic registration. If this is set to - * `true` the client supports the new - * `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` - * return value for the corresponding server capability as well. - */ - DynamicRegistration bool `json:"dynamicRegistration"` - - /** - * Whether the clients supports related documents for document diagnostic - * pulls. - */ - RelatedDocumentSupport bool `json:"relatedDocumentSupport"` -} - -/** - * Diagnostic options. - * - * @since 3.17.0 - */ -type DiagnosticOptions struct { - WorkDoneProgressOptions - /** - * An optional identifier under which the diagnostics are - * managed by the client. - */ - Identifier *string `json:"identifier"` - - /** - * Whether the language has inter file dependencies meaning that - * editing code in one file can result in a different diagnostic - * set in another file. Inter file dependencies are common for - * most programming languages and typically uncommon for linters. - */ - InterFileDependencies bool `json:"interFileDependencies"` - - /** - * The server provides support for workspace diagnostics as well. - */ - WorkspaceDiagnostics bool `json:"workspaceDiagnostics"` -} - -/** - * Diagnostic registration options. - * - * @since 3.17.0 - */ -type DiagnosticRegistrationOptions struct { - TextDocumentRegistrationOptions - DiagnosticOptions - StaticRegistrationOptions -} - -const MethodTextDocumentDiagnostic = Method("textDocument/diagnostic") - -type TextDocumentDiagnosticFunc func(context *glsp.Context, params *DocumentDiagnosticParams) (any, error) - -/** - * Parameters of the document diagnostic request. - * - * @since 3.17.0 - */ -type DocumentDiagnosticParams struct { - WorkDoneProgressParams - PartialResultParams - - /** - * The text document. - */ - TextDocument TextDocumentIdentifier `json:"textDocument"` - - /** - * The additional identifier provided during registration. - */ - Identifier *string `json:"identifier,omitempty"` - - /** - * The result id of a previous response if provided. - */ - PreviousResultId *string `json:"previousResultId,omitempty"` -} - -/** - * The result of a document diagnostic pull request. A report can - * either be a full report containing all diagnostics for the - * requested document or a unchanged report indicating that nothing - * has changed in terms of diagnostics in comparison to the last - * pull request. - * - * @since 3.17.0 - */ -type DocumentDiagnosticReport any // RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport - -/** - * The document diagnostic report kinds. - * - * @since 3.17.0 - */ -type DocumentDiagnosticReportKind string - -const ( - /** - * A diagnostic report with a full - * set of problems. - */ - DocumentDiagnosticReportKindFull = DocumentDiagnosticReportKind("full") - /** - * A report indicating that the last - * returned report is still accurate. - */ - DocumentDiagnosticReportKindUnchanged = DocumentDiagnosticReportKind("unchanged") -) - -/** - * A diagnostic report with a full set of problems. - * - * @since 3.17.0 - */ -type FullDocumentDiagnosticReport struct { - /** - * A full document diagnostic report. - */ - Kind string `json:"kind"` - - /** - * An optional result id. If provided it will - * be sent on the next diagnostic request for the - * same document. - */ - ResultID *string `json:"resultId,omitempty"` - - /** - * The actual items. - */ - Items []Diagnostic `json:"items"` -} - -/** - * A diagnostic report indicating that the last returned - * report is still accurate. - * - * @since 3.17.0 - */ -type UnchangedDocumentDiagnosticReport struct { - /** - * A document diagnostic report indicating - * no changes to the last result. A server can - * only return `unchanged` if result ids are - * provided. - */ - Kind string `json:"kind"` - - /** - * A result id which will be sent on the next - * diagnostic request for the same document. - */ - ResultID string `json:"resultId"` -} - -/** - * A full diagnostic report with a set of related documents. - * - * @since 3.17.0 - */ -type RelatedFullDocumentDiagnosticReport struct { - FullDocumentDiagnosticReport - /** - * Diagnostics of related documents. This information is useful - * in programming languages where code in a file A can generate - * diagnostics in a file B which A depends on. An example of - * such a language is C/C++ where marco definitions in a file - * a.cpp and result in errors in a header file b.hpp. - * - * @since 3.17.0 - */ - RelatedDocuments map[DocumentUri]interface{} `json:"relatedDocuments,omitempty"` -} - -/** - * An unchanged diagnostic report with a set of related documents. - * - * @since 3.17.0 - */ -type RelatedUnchangedDocumentDiagnosticReport struct { - UnchangedDocumentDiagnosticReport - /** - * Diagnostics of related documents. This information is useful - * in programming languages where code in a file A can generate - * diagnostics in a file B which A depends on. An example of - * such a language is C/C++ where marco definitions in a file - * a.cpp and result in errors in a header file b.hpp. - * - * @since 3.17.0 - */ - RelatedDocuments map[DocumentUri]interface{} `json:"relatedDocuments,omitempty"` -} - -/** - * A partial result for a document diagnostic report. - * - * @since 3.17.0 - */ -type DocumentDiagnosticReportPartialResult struct { - RelatedDocuments map[DocumentUri]interface{} `json:"relatedDocuments"` -} - -/** - * Cancellation data returned from a diagnostic request. - * - * @since 3.17.0 - */ -type DiagnosticServerCancellationData struct { - RetriggerRequest bool `json:"retriggerRequest"` -} diff --git a/protocol_3_16/general-messages.go b/protocol_3_16/general-messages.go index 083915c..97f9629 100644 --- a/protocol_3_16/general-messages.go +++ b/protocol_3_16/general-messages.go @@ -248,13 +248,6 @@ type TextDocumentClientCapabilities struct { * @since 3.16.0 */ Moniker *MonikerClientCapabilities `json:"moniker,omitempty"` - - /** - * Capabilities specific to the diagnostic pull model. - * - * @since 3.17.0 - */ - Diagnostic *DiagnosticClientCapabilities `json:"diagnostic,omitempty"` } type ClientCapabilities struct { @@ -657,13 +650,6 @@ type ServerCapabilities struct { */ MonikerProvider any `json:"monikerProvider,omitempty"` // nil | bool | MonikerOptions | MonikerRegistrationOptions - /** - * The server has support for pull model diagnostics. - * - * @since 3.17.0 - */ - DiagnosticProvider any `json:"diagnosticProvider,omitempty"` // nil | DiagnosticOptions | DiagnosticRegistrationOptions - /** * The server provides workspace symbol support. */ @@ -764,7 +750,6 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { WorkspaceSymbolProvider json.RawMessage `json:"workspaceSymbolProvider,omitempty"` // nil | bool | WorkspaceSymbolOptions Workspace *ServerCapabilitiesWorkspace `json:"workspace,omitempty"` Experimental *any `json:"experimental,omitempty"` - DiagnosticProvider json.RawMessage `json:"diagnosticProvider,omitempty"` // nil | DiagnosticOptions | DiagnosticRegistrationOptions } if err := json.Unmarshal(data, &value); err == nil { @@ -1115,20 +1100,6 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { } } - if value.DiagnosticProvider != nil { - var value_ DiagnosticOptions - if err = json.Unmarshal(value.DiagnosticProvider, &value_); err == nil { - self.DiagnosticProvider = value_ - } else { - var value_ DiagnosticRegistrationOptions - if err = json.Unmarshal(value.DiagnosticProvider, &value_); err == nil { - self.DiagnosticProvider = value_ - } else { - return err - } - } - } - return nil } else { return err diff --git a/protocol_3_16/handler.go b/protocol_3_16/handler.go index 2bfc27e..1fa0c2b 100644 --- a/protocol_3_16/handler.go +++ b/protocol_3_16/handler.go @@ -81,7 +81,6 @@ type Handler struct { TextDocumentSemanticTokensRange TextDocumentSemanticTokensRangeFunc TextDocumentLinkedEditingRange TextDocumentLinkedEditingRangeFunc TextDocumentMoniker TextDocumentMonikerFunc - TextDocumentDiagnostic TextDocumentDiagnosticFunc initialized bool lock sync.Mutex @@ -710,15 +709,6 @@ func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, val r, err = self.TextDocumentMoniker(context, ¶ms) } } - case MethodTextDocumentDiagnostic: - if self.TextDocumentDiagnostic != nil { - validMethod = true - var params DocumentDiagnosticParams - if err = json.Unmarshal(context.Params, ¶ms); err == nil { - validParams = true - r, err = self.TextDocumentDiagnostic(context, ¶ms) - } - } } return @@ -971,12 +961,5 @@ func (self *Handler) CreateServerCapabilities() ServerCapabilities { } } - if self.TextDocumentDiagnostic != nil { - capabilities.DiagnosticProvider = DiagnosticOptions{ - InterFileDependencies: true, - WorkspaceDiagnostics: false, - } - } - return capabilities } diff --git a/protocol_3_17/diagnostics.go b/protocol_3_17/diagnostics.go new file mode 100644 index 0000000..36f51aa --- /dev/null +++ b/protocol_3_17/diagnostics.go @@ -0,0 +1,227 @@ +package protocol317 + +import ( + "github.com/tliron/glsp" + protocol "github.com/tliron/glsp/protocol_3_16" +) + +/** + * Client capabilities specific to diagnostic pull requests. + * + * @since 3.17.0 + */ +type DiagnosticClientCapabilities struct { + /** + * Whether implementation supports dynamic registration. If this is set to + * `true` the client supports the new + * `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` + * return value for the corresponding server capability as well. + */ + DynamicRegistration bool `json:"dynamicRegistration"` + + /** + * Whether the clients supports related documents for document diagnostic + * pulls. + */ + RelatedDocumentSupport bool `json:"relatedDocumentSupport"` +} + +/** + * Diagnostic options. + * + * @since 3.17.0 + */ +type DiagnosticOptions struct { + protocol.WorkDoneProgressOptions + /** + * An optional identifier under which the diagnostics are + * managed by the client. + */ + Identifier *string `json:"identifier"` + + /** + * Whether the language has inter file dependencies meaning that + * editing code in one file can result in a different diagnostic + * set in another file. Inter file dependencies are common for + * most programming languages and typically uncommon for linters. + */ + InterFileDependencies bool `json:"interFileDependencies"` + + /** + * The server provides support for workspace diagnostics as well. + */ + WorkspaceDiagnostics bool `json:"workspaceDiagnostics"` +} + +/** + * Diagnostic registration options. + * + * @since 3.17.0 + */ +type DiagnosticRegistrationOptions struct { + protocol.TextDocumentRegistrationOptions + DiagnosticOptions + protocol.StaticRegistrationOptions +} + +const MethodTextDocumentDiagnostic = protocol.Method("textDocument/diagnostic") + +type TextDocumentDiagnosticFunc func(context *glsp.Context, params *DocumentDiagnosticParams) (any, error) + +/** + * Parameters of the document diagnostic request. + * + * @since 3.17.0 + */ +type DocumentDiagnosticParams struct { + protocol.WorkDoneProgressParams + protocol.PartialResultParams + + /** + * The text document. + */ + TextDocument protocol.TextDocumentIdentifier `json:"textDocument"` + + /** + * The additional identifier provided during registration. + */ + Identifier *string `json:"identifier,omitempty"` + + /** + * The result id of a previous response if provided. + */ + PreviousResultId *string `json:"previousResultId,omitempty"` +} + +/** + * The result of a document diagnostic pull request. A report can + * either be a full report containing all diagnostics for the + * requested document or a unchanged report indicating that nothing + * has changed in terms of diagnostics in comparison to the last + * pull request. + * + * @since 3.17.0 + */ +type DocumentDiagnosticReport any // RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport + +/** + * The document diagnostic report kinds. + * + * @since 3.17.0 + */ +type DocumentDiagnosticReportKind string + +const ( + /** + * A diagnostic report with a full + * set of problems. + */ + DocumentDiagnosticReportKindFull = DocumentDiagnosticReportKind("full") + /** + * A report indicating that the last + * returned report is still accurate. + */ + DocumentDiagnosticReportKindUnchanged = DocumentDiagnosticReportKind("unchanged") +) + +/** + * A diagnostic report with a full set of problems. + * + * @since 3.17.0 + */ +type FullDocumentDiagnosticReport struct { + /** + * A full document diagnostic report. + */ + Kind string `json:"kind"` + + /** + * An optional result id. If provided it will + * be sent on the next diagnostic request for the + * same document. + */ + ResultID *string `json:"resultId,omitempty"` + + /** + * The actual items. + */ + Items []protocol.Diagnostic `json:"items"` +} + +/** + * A diagnostic report indicating that the last returned + * report is still accurate. + * + * @since 3.17.0 + */ +type UnchangedDocumentDiagnosticReport struct { + /** + * A document diagnostic report indicating + * no changes to the last result. A server can + * only return `unchanged` if result ids are + * provided. + */ + Kind string `json:"kind"` + + /** + * A result id which will be sent on the next + * diagnostic request for the same document. + */ + ResultID string `json:"resultId"` +} + +/** + * A full diagnostic report with a set of related documents. + * + * @since 3.17.0 + */ +type RelatedFullDocumentDiagnosticReport struct { + FullDocumentDiagnosticReport + /** + * Diagnostics of related documents. This information is useful + * in programming languages where code in a file A can generate + * diagnostics in a file B which A depends on. An example of + * such a language is C/C++ where marco definitions in a file + * a.cpp and result in errors in a header file b.hpp. + * + * @since 3.17.0 + */ + RelatedDocuments map[protocol.DocumentUri]interface{} `json:"relatedDocuments,omitempty"` +} + +/** + * An unchanged diagnostic report with a set of related documents. + * + * @since 3.17.0 + */ +type RelatedUnchangedDocumentDiagnosticReport struct { + UnchangedDocumentDiagnosticReport + /** + * Diagnostics of related documents. This information is useful + * in programming languages where code in a file A can generate + * diagnostics in a file B which A depends on. An example of + * such a language is C/C++ where marco definitions in a file + * a.cpp and result in errors in a header file b.hpp. + * + * @since 3.17.0 + */ + RelatedDocuments map[protocol.DocumentUri]interface{} `json:"relatedDocuments,omitempty"` +} + +/** + * A partial result for a document diagnostic report. + * + * @since 3.17.0 + */ +type DocumentDiagnosticReportPartialResult struct { + RelatedDocuments map[protocol.DocumentUri]interface{} `json:"relatedDocuments"` +} + +/** + * Cancellation data returned from a diagnostic request. + * + * @since 3.17.0 + */ +type DiagnosticServerCancellationData struct { + RetriggerRequest bool `json:"retriggerRequest"` +} diff --git a/protocol_3_17/general-messages.go b/protocol_3_17/general-messages.go new file mode 100644 index 0000000..0443c03 --- /dev/null +++ b/protocol_3_17/general-messages.go @@ -0,0 +1,471 @@ +package protocol317 + +import ( + "encoding/json" + + "github.com/tliron/glsp" + protocol "github.com/tliron/glsp/protocol_3_16" +) + +// https://microsoft.github.io/language-server-protocol/specifications/specification-3-16#initialize + +const MethodInitialize = protocol.Method("initialize") + +// Returns: InitializeResult | InitializeError +type InitializeFunc func(context *glsp.Context, params *InitializeParams) (any, error) + +type InitializeParams struct { + protocol.InitializeParams + + /** + * The capabilities provided by the client (editor or tool) + */ + Capabilities ClientCapabilities `json:"capabilities"` +} + +type ClientCapabilities struct { + protocol.ClientCapabilities + + TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"` +} + +/** + * Text document specific client capabilities. + */ +type TextDocumentClientCapabilities struct { + protocol.TextDocumentClientCapabilities + + /** + * Capabilities specific to the diagnostic pull model. + * + * @since 3.17.0 + */ + Diagnostic *DiagnosticClientCapabilities `json:"diagnostic,omitempty"` +} + +type ServerCapabilities struct { + protocol.ServerCapabilities + + /** + * The server has support for pull model diagnostics. + * + * @since 3.17.0 + */ + DiagnosticProvider any `json:"diagnosticProvider,omitempty"` // nil | DiagnosticOptions | DiagnosticRegistrationOptions +} + +func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { + var value struct { + TextDocumentSync json.RawMessage `json:"textDocumentSync,omitempty"` // nil | TextDocumentSyncOptions | TextDocumentSyncKind + CompletionProvider *protocol.CompletionOptions `json:"completionProvider,omitempty"` + HoverProvider json.RawMessage `json:"hoverProvider,omitempty"` // nil | bool | HoverOptions + SignatureHelpProvider *protocol.SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` + DeclarationProvider json.RawMessage `json:"declarationProvider,omitempty"` // nil | bool | DeclarationOptions | DeclarationRegistrationOptions + DefinitionProvider json.RawMessage `json:"definitionProvider,omitempty"` // nil | bool | DefinitionOptions + TypeDefinitionProvider json.RawMessage `json:"typeDefinitionProvider,omitempty"` // nil | bool | TypeDefinitionOption | TypeDefinitionRegistrationOptions + ImplementationProvider json.RawMessage `json:"implementationProvider,omitempty"` // nil | bool | ImplementationOptions | ImplementationRegistrationOptions + ReferencesProvider json.RawMessage `json:"referencesProvider,omitempty"` // nil | bool | ReferenceOptions + DocumentHighlightProvider json.RawMessage `json:"documentHighlightProvider,omitempty"` // nil | bool | DocumentHighlightOptions + DocumentSymbolProvider json.RawMessage `json:"documentSymbolProvider,omitempty"` // nil | bool | DocumentSymbolOptions + CodeActionProvider json.RawMessage `json:"codeActionProvider,omitempty"` // nil | bool | CodeActionOptions + CodeLensProvider *protocol.CodeLensOptions `json:"codeLensProvider,omitempty"` + DocumentLinkProvider *protocol.DocumentLinkOptions `json:"documentLinkProvider,omitempty"` + ColorProvider json.RawMessage `json:"colorProvider,omitempty"` // nil | bool | DocumentColorOptions | DocumentColorRegistrationOptions + DocumentFormattingProvider json.RawMessage `json:"documentFormattingProvider,omitempty"` // nil | bool | DocumentFormattingOptions + DocumentRangeFormattingProvider json.RawMessage `json:"documentRangeFormattingProvider,omitempty"` // nil | bool | DocumentRangeFormattingOptions + DocumentOnTypeFormattingProvider *protocol.DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"` + RenameProvider json.RawMessage `json:"renameProvider,omitempty"` // nil | bool | RenameOptions + FoldingRangeProvider json.RawMessage `json:"foldingRangeProvider,omitempty"` // nil | bool | FoldingRangeOptions | FoldingRangeRegistrationOptions + ExecuteCommandProvider *protocol.ExecuteCommandOptions `json:"executeCommandProvider,omitempty"` + SelectionRangeProvider json.RawMessage `json:"selectionRangeProvider,omitempty"` // nil | bool | SelectionRangeOptions | SelectionRangeRegistrationOptions + LinkedEditingRangeProvider json.RawMessage `json:"linkedEditingRangeProvider,omitempty"` // nil | bool | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions + CallHierarchyProvider json.RawMessage `json:"callHierarchyProvider,omitempty"` // nil | bool | CallHierarchyOptions | CallHierarchyRegistrationOptions + SemanticTokensProvider json.RawMessage `json:"semanticTokensProvider,omitempty"` // nil | SemanticTokensOptions | SemanticTokensRegistrationOptions + MonikerProvider json.RawMessage `json:"monikerProvider,omitempty"` // nil | bool | MonikerOptions | MonikerRegistrationOptions + WorkspaceSymbolProvider json.RawMessage `json:"workspaceSymbolProvider,omitempty"` // nil | bool | WorkspaceSymbolOptions + Workspace *protocol.ServerCapabilitiesWorkspace `json:"workspace,omitempty"` + Experimental *any `json:"experimental,omitempty"` + DiagnosticProvider json.RawMessage `json:"diagnosticProvider,omitempty"` // nil | DiagnosticOptions | DiagnosticRegistrationOptions + } + + if err := json.Unmarshal(data, &value); err == nil { + self.CompletionProvider = value.CompletionProvider + self.SignatureHelpProvider = value.SignatureHelpProvider + self.CodeLensProvider = value.CodeLensProvider + self.DocumentLinkProvider = value.DocumentLinkProvider + self.DocumentOnTypeFormattingProvider = value.DocumentOnTypeFormattingProvider + self.ExecuteCommandProvider = value.ExecuteCommandProvider + self.Workspace = value.Workspace + + if value.TextDocumentSync != nil { + var value_ protocol.TextDocumentSyncOptions + if err = json.Unmarshal(value.TextDocumentSync, &value_); err == nil { + self.TextDocumentSync = value_ + } else { + var value_ protocol.TextDocumentSyncKind + if err = json.Unmarshal(value.TextDocumentSync, &value_); err == nil { + self.TextDocumentSync = value_ + } else { + return err + } + } + } + + if value.HoverProvider != nil { + var value_ bool + if err = json.Unmarshal(value.HoverProvider, &value_); err == nil { + self.HoverProvider = value_ + } else { + var value_ protocol.HoverOptions + if err = json.Unmarshal(value.HoverProvider, &value_); err == nil { + self.HoverProvider = value_ + } else { + return err + } + } + } + + if value.DeclarationProvider != nil { + var value_ bool + if err = json.Unmarshal(value.DeclarationProvider, &value_); err == nil { + self.DeclarationProvider = value_ + } else { + var value_ protocol.DeclarationOptions + if err = json.Unmarshal(value.DeclarationProvider, &value_); err == nil { + self.DeclarationProvider = value_ + } else { + var value_ protocol.DeclarationRegistrationOptions + if err = json.Unmarshal(value.DeclarationProvider, &value_); err == nil { + self.DeclarationProvider = value_ + } else { + return err + } + } + } + } + + if value.DefinitionProvider != nil { + var value_ bool + if err = json.Unmarshal(value.DefinitionProvider, &value_); err == nil { + self.DefinitionProvider = value_ + } else { + var value_ protocol.DefinitionOptions + if err = json.Unmarshal(value.DefinitionProvider, &value_); err == nil { + self.DefinitionProvider = value_ + } else { + return err + } + } + } + + if value.TypeDefinitionProvider != nil { + var value_ bool + if err = json.Unmarshal(value.TypeDefinitionProvider, &value_); err == nil { + self.TypeDefinitionProvider = value_ + } else { + var value_ protocol.TypeDefinitionOptions + if err = json.Unmarshal(value.TypeDefinitionProvider, &value_); err == nil { + self.TypeDefinitionProvider = value_ + } else { + var value_ protocol.TypeDefinitionRegistrationOptions + if err = json.Unmarshal(value.TypeDefinitionProvider, &value_); err == nil { + self.TypeDefinitionProvider = value_ + } else { + return err + } + } + } + } + + if value.ImplementationProvider != nil { + var value_ bool + if err = json.Unmarshal(value.ImplementationProvider, &value_); err == nil { + self.ImplementationProvider = value_ + } else { + var value_ protocol.ImplementationOptions + if err = json.Unmarshal(value.ImplementationProvider, &value_); err == nil { + self.ImplementationProvider = value_ + } else { + var value_ protocol.ImplementationRegistrationOptions + if err = json.Unmarshal(value.ImplementationProvider, &value_); err == nil { + self.ImplementationProvider = value_ + } else { + return err + } + } + } + } + + if value.ReferencesProvider != nil { + var value_ bool + if err = json.Unmarshal(value.ReferencesProvider, &value_); err == nil { + self.ReferencesProvider = value_ + } else { + var value_ protocol.ReferenceOptions + if err = json.Unmarshal(value.ReferencesProvider, &value_); err == nil { + self.ReferencesProvider = value_ + } else { + return err + } + } + } + + if value.DocumentHighlightProvider != nil { + var value_ bool + if err = json.Unmarshal(value.DocumentHighlightProvider, &value_); err == nil { + self.DocumentHighlightProvider = value_ + } else { + var value_ protocol.DocumentHighlightOptions + if err = json.Unmarshal(value.DocumentHighlightProvider, &value_); err == nil { + self.DocumentHighlightProvider = value_ + } else { + return err + } + } + } + + if value.DocumentSymbolProvider != nil { + var value_ bool + if err = json.Unmarshal(value.DocumentSymbolProvider, &value_); err == nil { + self.DocumentSymbolProvider = value_ + } else { + var value_ protocol.DocumentSymbolOptions + if err = json.Unmarshal(value.DocumentSymbolProvider, &value_); err == nil { + self.DocumentSymbolProvider = value_ + } else { + return err + } + } + } + + if value.CodeActionProvider != nil { + var value_ bool + if err = json.Unmarshal(value.CodeActionProvider, &value_); err == nil { + self.CodeActionProvider = value_ + } else { + var value_ protocol.CodeActionOptions + if err = json.Unmarshal(value.CodeActionProvider, &value_); err == nil { + self.CodeActionProvider = value_ + } else { + return err + } + } + } + + if value.ColorProvider != nil { + var value_ bool + if err = json.Unmarshal(value.ColorProvider, &value_); err == nil { + self.ColorProvider = value_ + } else { + var value_ protocol.DocumentColorOptions + if err = json.Unmarshal(value.ColorProvider, &value_); err == nil { + self.ColorProvider = value_ + } else { + var value_ protocol.DocumentColorRegistrationOptions + if err = json.Unmarshal(value.ColorProvider, &value_); err == nil { + self.ColorProvider = value_ + } else { + return err + } + } + } + } + + if value.DocumentFormattingProvider != nil { + var value_ bool + if err = json.Unmarshal(value.DocumentFormattingProvider, &value_); err == nil { + self.DocumentFormattingProvider = value_ + } else { + var value_ protocol.DocumentFormattingOptions + if err = json.Unmarshal(value.DocumentFormattingProvider, &value_); err == nil { + self.DocumentFormattingProvider = value_ + } else { + return err + } + } + } + + if value.DocumentRangeFormattingProvider != nil { + var value_ bool + if err = json.Unmarshal(value.DocumentRangeFormattingProvider, &value_); err == nil { + self.DocumentRangeFormattingProvider = value_ + } else { + var value_ protocol.DocumentRangeFormattingOptions + if err = json.Unmarshal(value.DocumentRangeFormattingProvider, &value_); err == nil { + self.DocumentRangeFormattingProvider = value_ + } else { + return err + } + } + } + + if value.RenameProvider != nil { + var value_ bool + if err = json.Unmarshal(value.RenameProvider, &value_); err == nil { + self.RenameProvider = value_ + } else { + var value_ protocol.RenameOptions + if err = json.Unmarshal(value.RenameProvider, &value_); err == nil { + self.RenameProvider = value_ + } else { + return err + } + } + } + + if value.FoldingRangeProvider != nil { + var value_ bool + if err = json.Unmarshal(value.FoldingRangeProvider, &value_); err == nil { + self.FoldingRangeProvider = value_ + } else { + var value_ protocol.FoldingRangeOptions + if err = json.Unmarshal(value.FoldingRangeProvider, &value_); err == nil { + self.FoldingRangeProvider = value_ + } else { + var value_ protocol.FoldingRangeRegistrationOptions + if err = json.Unmarshal(value.FoldingRangeProvider, &value_); err == nil { + self.FoldingRangeProvider = value_ + } else { + return err + } + } + } + } + + if value.SelectionRangeProvider != nil { + var value_ bool + if err = json.Unmarshal(value.SelectionRangeProvider, &value_); err == nil { + self.SelectionRangeProvider = value_ + } else { + var value_ protocol.SelectionRangeOptions + if err = json.Unmarshal(value.SelectionRangeProvider, &value_); err == nil { + self.SelectionRangeProvider = value_ + } else { + var value_ protocol.SelectionRangeRegistrationOptions + if err = json.Unmarshal(value.SelectionRangeProvider, &value_); err == nil { + self.SelectionRangeProvider = value_ + } else { + return err + } + } + } + } + + if value.LinkedEditingRangeProvider != nil { + var value_ bool + if err = json.Unmarshal(value.LinkedEditingRangeProvider, &value_); err == nil { + self.LinkedEditingRangeProvider = value_ + } else { + var value_ protocol.LinkedEditingRangeOptions + if err = json.Unmarshal(value.LinkedEditingRangeProvider, &value_); err == nil { + self.LinkedEditingRangeProvider = value_ + } else { + var value_ protocol.LinkedEditingRangeRegistrationOptions + if err = json.Unmarshal(value.LinkedEditingRangeProvider, &value_); err == nil { + self.LinkedEditingRangeProvider = value_ + } else { + return err + } + } + } + } + + if value.CallHierarchyProvider != nil { + var value_ bool + if err = json.Unmarshal(value.CallHierarchyProvider, &value_); err == nil { + self.CallHierarchyProvider = value_ + } else { + var value_ protocol.CallHierarchyOptions + if err = json.Unmarshal(value.CallHierarchyProvider, &value_); err == nil { + self.CallHierarchyProvider = value_ + } else { + var value_ protocol.CallHierarchyRegistrationOptions + if err = json.Unmarshal(value.CallHierarchyProvider, &value_); err == nil { + self.CallHierarchyProvider = value_ + } else { + return err + } + } + } + } + + if value.SemanticTokensProvider != nil { + var value_ protocol.SemanticTokensOptions + if err = json.Unmarshal(value.SemanticTokensProvider, &value_); err == nil { + self.SemanticTokensProvider = value_ + } else { + var value_ protocol.SemanticTokensRegistrationOptions + if err = json.Unmarshal(value.SemanticTokensProvider, &value_); err == nil { + self.SemanticTokensProvider = value_ + } else { + return err + } + } + } + + if value.MonikerProvider != nil { + var value_ bool + if err = json.Unmarshal(value.MonikerProvider, &value_); err == nil { + self.MonikerProvider = value_ + } else { + var value_ protocol.MonikerOptions + if err = json.Unmarshal(value.MonikerProvider, &value_); err == nil { + self.MonikerProvider = value_ + } else { + var value_ protocol.MonikerRegistrationOptions + if err = json.Unmarshal(value.MonikerProvider, &value_); err == nil { + self.MonikerProvider = value_ + } else { + return err + } + } + } + } + + if value.WorkspaceSymbolProvider != nil { + var value_ bool + if err = json.Unmarshal(value.WorkspaceSymbolProvider, &value_); err == nil { + self.WorkspaceSymbolProvider = value_ + } else { + var value_ protocol.WorkspaceSymbolOptions + if err = json.Unmarshal(value.WorkspaceSymbolProvider, &value_); err == nil { + self.WorkspaceSymbolProvider = value_ + } else { + return err + } + } + } + + if value.DiagnosticProvider != nil { + var value_ DiagnosticOptions + if err = json.Unmarshal(value.DiagnosticProvider, &value_); err == nil { + self.DiagnosticProvider = value_ + } else { + var value_ DiagnosticRegistrationOptions + if err = json.Unmarshal(value.DiagnosticProvider, &value_); err == nil { + self.DiagnosticProvider = value_ + } else { + return err + } + } + } + + return nil + } else { + return err + } +} + +type InitializeResult struct { + /** + * The capabilities the language server provides. + */ + Capabilities ServerCapabilities `json:"capabilities"` + + /** + * Information about the server. + * + * @since 3.15.0 + */ + ServerInfo *protocol.InitializeResultServerInfo `json:"serverInfo,omitempty"` +} diff --git a/protocol_3_17/handler.go b/protocol_3_17/handler.go new file mode 100644 index 0000000..35229cd --- /dev/null +++ b/protocol_3_17/handler.go @@ -0,0 +1,912 @@ +package protocol317 + +import ( + "encoding/json" + "errors" + "sync" + + "github.com/tliron/glsp" + protocol "github.com/tliron/glsp/protocol_3_16" +) + +type Handler struct { + protocol.Handler + + Initialize InitializeFunc + TextDocumentDiagnostic TextDocumentDiagnosticFunc + + initialized bool + lock sync.Mutex +} + +func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, validParams bool, err error) { + if !self.IsInitialized() && (context.Method != protocol.MethodInitialize) { + return nil, true, true, errors.New("server not initialized") + } + + switch context.Method { + case protocol.MethodCancelRequest: + if self.CancelRequest != nil { + validMethod = true + var params protocol.CancelParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.CancelRequest(context, ¶ms) + } + } + + case protocol.MethodProgress: + if self.Progress != nil { + validMethod = true + var params protocol.ProgressParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.Progress(context, ¶ms) + } + } + + // General Messages + + case MethodInitialize: + if self.Initialize != nil { + validMethod = true + var params InitializeParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + if r, err = self.Initialize(context, ¶ms); err == nil { + self.SetInitialized(true) + } + } + } + + case protocol.MethodInitialized: + if self.Initialized != nil { + validMethod = true + var params protocol.InitializedParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.Initialized(context, ¶ms) + } + } + + case protocol.MethodShutdown: + self.SetInitialized(false) + if self.Shutdown != nil { + validMethod = true + validParams = true + err = self.Shutdown(context) + } + + case protocol.MethodExit: + // Note that the server will close the connection after we handle it here + if self.Exit != nil { + validMethod = true + validParams = true + err = self.Exit(context) + } + + case protocol.MethodLogTrace: + if self.LogTrace != nil { + validMethod = true + var params protocol.LogTraceParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.LogTrace(context, ¶ms) + } + } + + case protocol.MethodSetTrace: + if self.SetTrace != nil { + validMethod = true + var params protocol.SetTraceParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.SetTrace(context, ¶ms) + } + } + + // Window + + case protocol.MethodWindowWorkDoneProgressCancel: + if self.WindowWorkDoneProgressCancel != nil { + validMethod = true + var params protocol.WorkDoneProgressCancelParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.WindowWorkDoneProgressCancel(context, ¶ms) + } + } + + // Workspace + + case protocol.MethodWorkspaceDidChangeWorkspaceFolders: + if self.WorkspaceDidChangeWorkspaceFolders != nil { + validMethod = true + var params protocol.DidChangeWorkspaceFoldersParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.WorkspaceDidChangeWorkspaceFolders(context, ¶ms) + } + } + + case protocol.MethodWorkspaceDidChangeConfiguration: + if self.WorkspaceDidChangeConfiguration != nil { + validMethod = true + var params protocol.DidChangeConfigurationParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.WorkspaceDidChangeConfiguration(context, ¶ms) + } + } + + case protocol.MethodWorkspaceDidChangeWatchedFiles: + if self.WorkspaceDidChangeWatchedFiles != nil { + validMethod = true + var params protocol.DidChangeWatchedFilesParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.WorkspaceDidChangeWatchedFiles(context, ¶ms) + } + } + + case protocol.MethodWorkspaceSymbol: + if self.WorkspaceSymbol != nil { + validMethod = true + var params protocol.WorkspaceSymbolParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.WorkspaceSymbol(context, ¶ms) + } + } + + case protocol.MethodWorkspaceExecuteCommand: + if self.WorkspaceExecuteCommand != nil { + validMethod = true + var params protocol.ExecuteCommandParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.WorkspaceExecuteCommand(context, ¶ms) + } + } + + case protocol.MethodWorkspaceWillCreateFiles: + if self.WorkspaceWillCreateFiles != nil { + validMethod = true + var params protocol.CreateFilesParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.WorkspaceWillCreateFiles(context, ¶ms) + } + } + + case protocol.MethodWorkspaceDidCreateFiles: + if self.WorkspaceDidCreateFiles != nil { + validMethod = true + var params protocol.CreateFilesParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.WorkspaceDidCreateFiles(context, ¶ms) + } + } + + case protocol.MethodWorkspaceWillRenameFiles: + if self.WorkspaceWillRenameFiles != nil { + validMethod = true + var params protocol.RenameFilesParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.WorkspaceWillRenameFiles(context, ¶ms) + } + } + + case protocol.MethodWorkspaceDidRenameFiles: + if self.WorkspaceDidRenameFiles != nil { + validMethod = true + var params protocol.RenameFilesParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.WorkspaceDidRenameFiles(context, ¶ms) + } + } + + case protocol.MethodWorkspaceWillDeleteFiles: + if self.WorkspaceWillDeleteFiles != nil { + validMethod = true + var params protocol.DeleteFilesParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.WorkspaceWillDeleteFiles(context, ¶ms) + } + } + + case protocol.MethodWorkspaceDidDeleteFiles: + if self.WorkspaceDidDeleteFiles != nil { + validMethod = true + var params protocol.DeleteFilesParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.WorkspaceDidDeleteFiles(context, ¶ms) + } + } + + // Text Document Synchronization + + case protocol.MethodTextDocumentDidOpen: + if self.TextDocumentDidOpen != nil { + validMethod = true + var params protocol.DidOpenTextDocumentParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.TextDocumentDidOpen(context, ¶ms) + } + } + + case protocol.MethodTextDocumentDidChange: + if self.TextDocumentDidChange != nil { + validMethod = true + var params protocol.DidChangeTextDocumentParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.TextDocumentDidChange(context, ¶ms) + } + } + + case protocol.MethodTextDocumentWillSave: + if self.TextDocumentWillSave != nil { + validMethod = true + var params protocol.WillSaveTextDocumentParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.TextDocumentWillSave(context, ¶ms) + } + } + + case protocol.MethodTextDocumentWillSaveWaitUntil: + if self.TextDocumentWillSaveWaitUntil != nil { + validMethod = true + var params protocol.WillSaveTextDocumentParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentWillSaveWaitUntil(context, ¶ms) + } + } + + case protocol.MethodTextDocumentDidSave: + if self.TextDocumentDidSave != nil { + validMethod = true + var params protocol.DidSaveTextDocumentParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.TextDocumentDidSave(context, ¶ms) + } + } + + case protocol.MethodTextDocumentDidClose: + if self.TextDocumentDidClose != nil { + validMethod = true + var params protocol.DidCloseTextDocumentParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + err = self.TextDocumentDidClose(context, ¶ms) + } + } + + // Language Features + + case protocol.MethodTextDocumentCompletion: + if self.TextDocumentCompletion != nil { + validMethod = true + var params protocol.CompletionParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentCompletion(context, ¶ms) + } + } + + case protocol.MethodCompletionItemResolve: + if self.CompletionItemResolve != nil { + validMethod = true + var params protocol.CompletionItem + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.CompletionItemResolve(context, ¶ms) + } + } + + case protocol.MethodTextDocumentHover: + if self.TextDocumentHover != nil { + validMethod = true + var params protocol.HoverParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentHover(context, ¶ms) + } + } + + case protocol.MethodTextDocumentSignatureHelp: + if self.TextDocumentSignatureHelp != nil { + validMethod = true + var params protocol.SignatureHelpParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentSignatureHelp(context, ¶ms) + } + } + + case protocol.MethodTextDocumentDeclaration: + if self.TextDocumentDeclaration != nil { + validMethod = true + var params protocol.DeclarationParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentDeclaration(context, ¶ms) + } + } + + case protocol.MethodTextDocumentDefinition: + if self.TextDocumentDefinition != nil { + validMethod = true + var params protocol.DefinitionParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentDefinition(context, ¶ms) + } + } + + case protocol.MethodTextDocumentTypeDefinition: + if self.TextDocumentTypeDefinition != nil { + validMethod = true + var params protocol.TypeDefinitionParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentTypeDefinition(context, ¶ms) + } + } + + case protocol.MethodTextDocumentImplementation: + if self.TextDocumentImplementation != nil { + validMethod = true + var params protocol.ImplementationParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentImplementation(context, ¶ms) + } + } + + case protocol.MethodTextDocumentReferences: + if self.TextDocumentReferences != nil { + validMethod = true + var params protocol.ReferenceParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentReferences(context, ¶ms) + } + } + + case protocol.MethodTextDocumentDocumentHighlight: + if self.TextDocumentDocumentHighlight != nil { + validMethod = true + var params protocol.DocumentHighlightParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentDocumentHighlight(context, ¶ms) + } + } + + case protocol.MethodTextDocumentDocumentSymbol: + if self.TextDocumentDocumentSymbol != nil { + validMethod = true + var params protocol.DocumentSymbolParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentDocumentSymbol(context, ¶ms) + } + } + + case protocol.MethodTextDocumentCodeAction: + if self.TextDocumentCodeAction != nil { + validMethod = true + var params protocol.CodeActionParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentCodeAction(context, ¶ms) + } + } + + case protocol.MethodCodeActionResolve: + if self.CodeActionResolve != nil { + validMethod = true + var params protocol.CodeAction + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.CodeActionResolve(context, ¶ms) + } + } + + case protocol.MethodTextDocumentCodeLens: + if self.TextDocumentCodeLens != nil { + validMethod = true + var params protocol.CodeLensParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentCodeLens(context, ¶ms) + } + } + + case protocol.MethodCodeLensResolve: + if self.TextDocumentDidClose != nil { + validMethod = true + var params protocol.CodeLens + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.CodeLensResolve(context, ¶ms) + } + } + + case protocol.MethodTextDocumentDocumentLink: + if self.TextDocumentDocumentLink != nil { + validMethod = true + var params protocol.DocumentLinkParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentDocumentLink(context, ¶ms) + } + } + + case protocol.MethodDocumentLinkResolve: + if self.DocumentLinkResolve != nil { + validMethod = true + var params protocol.DocumentLink + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.DocumentLinkResolve(context, ¶ms) + } + } + + case protocol.MethodTextDocumentColor: + if self.TextDocumentColor != nil { + validMethod = true + var params protocol.DocumentColorParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentColor(context, ¶ms) + } + } + + case protocol.MethodTextDocumentColorPresentation: + if self.TextDocumentColorPresentation != nil { + validMethod = true + var params protocol.ColorPresentationParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentColorPresentation(context, ¶ms) + } + } + + case protocol.MethodTextDocumentFormatting: + if self.TextDocumentFormatting != nil { + validMethod = true + var params protocol.DocumentFormattingParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentFormatting(context, ¶ms) + } + } + + case protocol.MethodTextDocumentRangeFormatting: + if self.TextDocumentRangeFormatting != nil { + validMethod = true + var params protocol.DocumentRangeFormattingParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentRangeFormatting(context, ¶ms) + } + } + + case protocol.MethodTextDocumentOnTypeFormatting: + if self.TextDocumentOnTypeFormatting != nil { + validMethod = true + var params protocol.DocumentOnTypeFormattingParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentOnTypeFormatting(context, ¶ms) + } + } + + case protocol.MethodTextDocumentRename: + if self.TextDocumentRename != nil { + validMethod = true + var params protocol.RenameParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentRename(context, ¶ms) + } + } + + case protocol.MethodTextDocumentPrepareRename: + if self.TextDocumentPrepareRename != nil { + validMethod = true + var params protocol.PrepareRenameParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentPrepareRename(context, ¶ms) + } + } + + case protocol.MethodTextDocumentFoldingRange: + if self.TextDocumentFoldingRange != nil { + validMethod = true + var params protocol.FoldingRangeParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentFoldingRange(context, ¶ms) + } + } + + case protocol.MethodTextDocumentSelectionRange: + if self.TextDocumentSelectionRange != nil { + validMethod = true + var params protocol.SelectionRangeParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentSelectionRange(context, ¶ms) + } + } + + case protocol.MethodTextDocumentPrepareCallHierarchy: + if self.TextDocumentPrepareCallHierarchy != nil { + validMethod = true + var params protocol.CallHierarchyPrepareParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentPrepareCallHierarchy(context, ¶ms) + } + } + + case protocol.MethodCallHierarchyIncomingCalls: + if self.CallHierarchyIncomingCalls != nil { + validMethod = true + var params protocol.CallHierarchyIncomingCallsParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.CallHierarchyIncomingCalls(context, ¶ms) + } + } + + case protocol.MethodCallHierarchyOutgoingCalls: + if self.CallHierarchyOutgoingCalls != nil { + validMethod = true + var params protocol.CallHierarchyOutgoingCallsParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.CallHierarchyOutgoingCalls(context, ¶ms) + } + } + + case protocol.MethodTextDocumentSemanticTokensFull: + if self.TextDocumentSemanticTokensFull != nil { + validMethod = true + var params protocol.SemanticTokensParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentSemanticTokensFull(context, ¶ms) + } + } + + case protocol.MethodTextDocumentSemanticTokensFullDelta: + if self.TextDocumentSemanticTokensFullDelta != nil { + validMethod = true + var params protocol.SemanticTokensDeltaParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentSemanticTokensFullDelta(context, ¶ms) + } + } + + case protocol.MethodTextDocumentSemanticTokensRange: + if self.TextDocumentSemanticTokensRange != nil { + validMethod = true + var params protocol.SemanticTokensRangeParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentSemanticTokensRange(context, ¶ms) + } + } + + case protocol.MethodWorkspaceSemanticTokensRefresh: + if self.WorkspaceSemanticTokensRefresh != nil { + validMethod = true + validParams = true + err = self.WorkspaceSemanticTokensRefresh(context) + } + + case protocol.MethodTextDocumentLinkedEditingRange: + if self.TextDocumentLinkedEditingRange != nil { + validMethod = true + var params protocol.LinkedEditingRangeParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentLinkedEditingRange(context, ¶ms) + } + } + + case protocol.MethodTextDocumentMoniker: + if self.TextDocumentMoniker != nil { + validMethod = true + var params protocol.MonikerParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentMoniker(context, ¶ms) + } + } + case MethodTextDocumentDiagnostic: + if self.TextDocumentDiagnostic != nil { + validMethod = true + var params DocumentDiagnosticParams + if err = json.Unmarshal(context.Params, ¶ms); err == nil { + validParams = true + r, err = self.TextDocumentDiagnostic(context, ¶ms) + } + } + } + + return + +} + +func (self *Handler) IsInitialized() bool { + self.lock.Lock() + defer self.lock.Unlock() + return self.initialized +} + +func (self *Handler) SetInitialized(initialized bool) { + self.lock.Lock() + defer self.lock.Unlock() + self.initialized = initialized +} + +func (self *Handler) CreateServerCapabilities() ServerCapabilities { + var capabilities ServerCapabilities + + if (self.TextDocumentDidOpen != nil) || (self.TextDocumentDidClose != nil) { + if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + } + capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).OpenClose = &protocol.True + } + + if self.TextDocumentDidChange != nil { + if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + } + // This can be overriden to TextDocumentSyncKindFull + value := protocol.TextDocumentSyncKindIncremental + capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).Change = &value + } + + if self.TextDocumentWillSave != nil { + if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + } + capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).WillSave = &protocol.True + } + + if self.TextDocumentWillSaveWaitUntil != nil { + if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + } + capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).WillSaveWaitUntil = &protocol.True + } + + if self.TextDocumentDidSave != nil { + if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + } + capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).Save = &protocol.True + } + + if self.TextDocumentCompletion != nil { + capabilities.CompletionProvider = &protocol.CompletionOptions{} + } + + if self.TextDocumentHover != nil { + capabilities.HoverProvider = true + } + + if self.TextDocumentSignatureHelp != nil { + capabilities.SignatureHelpProvider = &protocol.SignatureHelpOptions{} + } + + if self.TextDocumentDeclaration != nil { + capabilities.DeclarationProvider = true + } + + if self.TextDocumentDefinition != nil { + capabilities.DefinitionProvider = true + } + + if self.TextDocumentTypeDefinition != nil { + capabilities.TypeDefinitionProvider = true + } + + if self.TextDocumentImplementation != nil { + capabilities.ImplementationProvider = true + } + + if self.TextDocumentReferences != nil { + capabilities.ReferencesProvider = true + } + + if self.TextDocumentDocumentHighlight != nil { + capabilities.DocumentHighlightProvider = true + } + + if self.TextDocumentDocumentSymbol != nil { + capabilities.DocumentSymbolProvider = true + } + + if self.TextDocumentCodeAction != nil { + capabilities.CodeActionProvider = true + } + + if self.TextDocumentCodeLens != nil { + capabilities.CodeLensProvider = &protocol.CodeLensOptions{} + } + + if self.TextDocumentDocumentLink != nil { + capabilities.DocumentLinkProvider = &protocol.DocumentLinkOptions{} + } + + if self.TextDocumentColor != nil { + capabilities.ColorProvider = true + } + + if self.TextDocumentFormatting != nil { + capabilities.DocumentFormattingProvider = true + } + + if self.TextDocumentRangeFormatting != nil { + capabilities.DocumentRangeFormattingProvider = true + } + + if self.TextDocumentOnTypeFormatting != nil { + capabilities.DocumentOnTypeFormattingProvider = &protocol.DocumentOnTypeFormattingOptions{} + } + + if self.TextDocumentRename != nil { + capabilities.RenameProvider = true + } + + if self.TextDocumentFoldingRange != nil { + capabilities.FoldingRangeProvider = true + } + + if self.WorkspaceExecuteCommand != nil { + capabilities.ExecuteCommandProvider = &protocol.ExecuteCommandOptions{} + } + + if self.TextDocumentSelectionRange != nil { + capabilities.SelectionRangeProvider = true + } + + if self.TextDocumentLinkedEditingRange != nil { + capabilities.LinkedEditingRangeProvider = true + } + + if self.TextDocumentPrepareCallHierarchy != nil { + capabilities.CallHierarchyProvider = true + } + + if self.TextDocumentSemanticTokensFull != nil { + if _, ok := capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions); !ok { + capabilities.SemanticTokensProvider = &protocol.SemanticTokensOptions{} + } + if self.TextDocumentSemanticTokensFullDelta != nil { + capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions).Full = &protocol.SemanticDelta{} + capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions).Full.(*protocol.SemanticDelta).Delta = &protocol.True + } else { + capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions).Full = true + } + } + + if self.TextDocumentSemanticTokensRange != nil { + if _, ok := capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions); !ok { + capabilities.SemanticTokensProvider = &protocol.SemanticTokensOptions{} + } + capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions).Range = true + } + + // TODO: self.TextDocumentSemanticTokensRefresh? + + if self.TextDocumentMoniker != nil { + capabilities.MonikerProvider = true + } + + if self.WorkspaceSymbol != nil { + capabilities.WorkspaceSymbolProvider = true + } + + if self.WorkspaceDidCreateFiles != nil { + if capabilities.Workspace == nil { + capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + } + if capabilities.Workspace.FileOperations == nil { + capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + } + capabilities.Workspace.FileOperations.DidCreate = &protocol.FileOperationRegistrationOptions{ + Filters: []protocol.FileOperationFilter{}, + } + } + + if self.WorkspaceWillCreateFiles != nil { + if capabilities.Workspace == nil { + capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + } + if capabilities.Workspace.FileOperations == nil { + capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + } + capabilities.Workspace.FileOperations.WillCreate = &protocol.FileOperationRegistrationOptions{ + Filters: []protocol.FileOperationFilter{}, + } + } + + if self.WorkspaceDidRenameFiles != nil { + capabilities.RenameProvider = true + if capabilities.Workspace == nil { + capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + } + if capabilities.Workspace.FileOperations == nil { + capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + } + capabilities.Workspace.FileOperations.DidRename = &protocol.FileOperationRegistrationOptions{ + Filters: []protocol.FileOperationFilter{}, + } + } + + if self.WorkspaceWillRenameFiles != nil { + capabilities.RenameProvider = true + if capabilities.Workspace == nil { + capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + } + if capabilities.Workspace.FileOperations == nil { + capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + } + capabilities.Workspace.FileOperations.WillRename = &protocol.FileOperationRegistrationOptions{ + Filters: []protocol.FileOperationFilter{}, + } + } + + if self.WorkspaceDidDeleteFiles != nil { + if capabilities.Workspace == nil { + capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + } + if capabilities.Workspace.FileOperations == nil { + capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + } + capabilities.Workspace.FileOperations.DidDelete = &protocol.FileOperationRegistrationOptions{ + Filters: []protocol.FileOperationFilter{}, + } + } + + if self.WorkspaceWillDeleteFiles != nil { + if capabilities.Workspace == nil { + capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + } + if capabilities.Workspace.FileOperations == nil { + capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + } + capabilities.Workspace.FileOperations.WillDelete = &protocol.FileOperationRegistrationOptions{ + Filters: []protocol.FileOperationFilter{}, + } + } + + if self.TextDocumentDiagnostic != nil { + capabilities.DiagnosticProvider = DiagnosticOptions{ + InterFileDependencies: true, + WorkspaceDiagnostics: false, + } + } + + return capabilities +} From 48292b37eac29c65fd699158b154c8bb2c8ac35a Mon Sep 17 00:00:00 2001 From: Dmitriy Antonov Date: Sat, 11 May 2024 23:24:22 +0300 Subject: [PATCH 3/3] the same package name for protocol versions --- protocol_3_17/diagnostics.go | 26 +-- protocol_3_17/general-messages.go | 140 ++++++------ protocol_3_17/handler.go | 350 +++++++++++++++--------------- 3 files changed, 258 insertions(+), 258 deletions(-) diff --git a/protocol_3_17/diagnostics.go b/protocol_3_17/diagnostics.go index 36f51aa..24c0069 100644 --- a/protocol_3_17/diagnostics.go +++ b/protocol_3_17/diagnostics.go @@ -1,8 +1,8 @@ -package protocol317 +package protocol import ( "github.com/tliron/glsp" - protocol "github.com/tliron/glsp/protocol_3_16" + protocol316 "github.com/tliron/glsp/protocol_3_16" ) /** @@ -32,7 +32,7 @@ type DiagnosticClientCapabilities struct { * @since 3.17.0 */ type DiagnosticOptions struct { - protocol.WorkDoneProgressOptions + protocol316.WorkDoneProgressOptions /** * An optional identifier under which the diagnostics are * managed by the client. @@ -59,12 +59,12 @@ type DiagnosticOptions struct { * @since 3.17.0 */ type DiagnosticRegistrationOptions struct { - protocol.TextDocumentRegistrationOptions + protocol316.TextDocumentRegistrationOptions DiagnosticOptions - protocol.StaticRegistrationOptions + protocol316.StaticRegistrationOptions } -const MethodTextDocumentDiagnostic = protocol.Method("textDocument/diagnostic") +const MethodTextDocumentDiagnostic = protocol316.Method("textDocument/diagnostic") type TextDocumentDiagnosticFunc func(context *glsp.Context, params *DocumentDiagnosticParams) (any, error) @@ -74,13 +74,13 @@ type TextDocumentDiagnosticFunc func(context *glsp.Context, params *DocumentDiag * @since 3.17.0 */ type DocumentDiagnosticParams struct { - protocol.WorkDoneProgressParams - protocol.PartialResultParams + protocol316.WorkDoneProgressParams + protocol316.PartialResultParams /** * The text document. */ - TextDocument protocol.TextDocumentIdentifier `json:"textDocument"` + TextDocument protocol316.TextDocumentIdentifier `json:"textDocument"` /** * The additional identifier provided during registration. @@ -145,7 +145,7 @@ type FullDocumentDiagnosticReport struct { /** * The actual items. */ - Items []protocol.Diagnostic `json:"items"` + Items []protocol316.Diagnostic `json:"items"` } /** @@ -186,7 +186,7 @@ type RelatedFullDocumentDiagnosticReport struct { * * @since 3.17.0 */ - RelatedDocuments map[protocol.DocumentUri]interface{} `json:"relatedDocuments,omitempty"` + RelatedDocuments map[protocol316.DocumentUri]interface{} `json:"relatedDocuments,omitempty"` } /** @@ -205,7 +205,7 @@ type RelatedUnchangedDocumentDiagnosticReport struct { * * @since 3.17.0 */ - RelatedDocuments map[protocol.DocumentUri]interface{} `json:"relatedDocuments,omitempty"` + RelatedDocuments map[protocol316.DocumentUri]interface{} `json:"relatedDocuments,omitempty"` } /** @@ -214,7 +214,7 @@ type RelatedUnchangedDocumentDiagnosticReport struct { * @since 3.17.0 */ type DocumentDiagnosticReportPartialResult struct { - RelatedDocuments map[protocol.DocumentUri]interface{} `json:"relatedDocuments"` + RelatedDocuments map[protocol316.DocumentUri]interface{} `json:"relatedDocuments"` } /** diff --git a/protocol_3_17/general-messages.go b/protocol_3_17/general-messages.go index 0443c03..8cd5970 100644 --- a/protocol_3_17/general-messages.go +++ b/protocol_3_17/general-messages.go @@ -1,21 +1,21 @@ -package protocol317 +package protocol import ( "encoding/json" "github.com/tliron/glsp" - protocol "github.com/tliron/glsp/protocol_3_16" + protocol316 "github.com/tliron/glsp/protocol_3_16" ) // https://microsoft.github.io/language-server-protocol/specifications/specification-3-16#initialize -const MethodInitialize = protocol.Method("initialize") +const MethodInitialize = protocol316.Method("initialize") // Returns: InitializeResult | InitializeError type InitializeFunc func(context *glsp.Context, params *InitializeParams) (any, error) type InitializeParams struct { - protocol.InitializeParams + protocol316.InitializeParams /** * The capabilities provided by the client (editor or tool) @@ -24,7 +24,7 @@ type InitializeParams struct { } type ClientCapabilities struct { - protocol.ClientCapabilities + protocol316.ClientCapabilities TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"` } @@ -33,7 +33,7 @@ type ClientCapabilities struct { * Text document specific client capabilities. */ type TextDocumentClientCapabilities struct { - protocol.TextDocumentClientCapabilities + protocol316.TextDocumentClientCapabilities /** * Capabilities specific to the diagnostic pull model. @@ -44,7 +44,7 @@ type TextDocumentClientCapabilities struct { } type ServerCapabilities struct { - protocol.ServerCapabilities + protocol316.ServerCapabilities /** * The server has support for pull model diagnostics. @@ -56,36 +56,36 @@ type ServerCapabilities struct { func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { var value struct { - TextDocumentSync json.RawMessage `json:"textDocumentSync,omitempty"` // nil | TextDocumentSyncOptions | TextDocumentSyncKind - CompletionProvider *protocol.CompletionOptions `json:"completionProvider,omitempty"` - HoverProvider json.RawMessage `json:"hoverProvider,omitempty"` // nil | bool | HoverOptions - SignatureHelpProvider *protocol.SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` - DeclarationProvider json.RawMessage `json:"declarationProvider,omitempty"` // nil | bool | DeclarationOptions | DeclarationRegistrationOptions - DefinitionProvider json.RawMessage `json:"definitionProvider,omitempty"` // nil | bool | DefinitionOptions - TypeDefinitionProvider json.RawMessage `json:"typeDefinitionProvider,omitempty"` // nil | bool | TypeDefinitionOption | TypeDefinitionRegistrationOptions - ImplementationProvider json.RawMessage `json:"implementationProvider,omitempty"` // nil | bool | ImplementationOptions | ImplementationRegistrationOptions - ReferencesProvider json.RawMessage `json:"referencesProvider,omitempty"` // nil | bool | ReferenceOptions - DocumentHighlightProvider json.RawMessage `json:"documentHighlightProvider,omitempty"` // nil | bool | DocumentHighlightOptions - DocumentSymbolProvider json.RawMessage `json:"documentSymbolProvider,omitempty"` // nil | bool | DocumentSymbolOptions - CodeActionProvider json.RawMessage `json:"codeActionProvider,omitempty"` // nil | bool | CodeActionOptions - CodeLensProvider *protocol.CodeLensOptions `json:"codeLensProvider,omitempty"` - DocumentLinkProvider *protocol.DocumentLinkOptions `json:"documentLinkProvider,omitempty"` - ColorProvider json.RawMessage `json:"colorProvider,omitempty"` // nil | bool | DocumentColorOptions | DocumentColorRegistrationOptions - DocumentFormattingProvider json.RawMessage `json:"documentFormattingProvider,omitempty"` // nil | bool | DocumentFormattingOptions - DocumentRangeFormattingProvider json.RawMessage `json:"documentRangeFormattingProvider,omitempty"` // nil | bool | DocumentRangeFormattingOptions - DocumentOnTypeFormattingProvider *protocol.DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"` - RenameProvider json.RawMessage `json:"renameProvider,omitempty"` // nil | bool | RenameOptions - FoldingRangeProvider json.RawMessage `json:"foldingRangeProvider,omitempty"` // nil | bool | FoldingRangeOptions | FoldingRangeRegistrationOptions - ExecuteCommandProvider *protocol.ExecuteCommandOptions `json:"executeCommandProvider,omitempty"` - SelectionRangeProvider json.RawMessage `json:"selectionRangeProvider,omitempty"` // nil | bool | SelectionRangeOptions | SelectionRangeRegistrationOptions - LinkedEditingRangeProvider json.RawMessage `json:"linkedEditingRangeProvider,omitempty"` // nil | bool | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions - CallHierarchyProvider json.RawMessage `json:"callHierarchyProvider,omitempty"` // nil | bool | CallHierarchyOptions | CallHierarchyRegistrationOptions - SemanticTokensProvider json.RawMessage `json:"semanticTokensProvider,omitempty"` // nil | SemanticTokensOptions | SemanticTokensRegistrationOptions - MonikerProvider json.RawMessage `json:"monikerProvider,omitempty"` // nil | bool | MonikerOptions | MonikerRegistrationOptions - WorkspaceSymbolProvider json.RawMessage `json:"workspaceSymbolProvider,omitempty"` // nil | bool | WorkspaceSymbolOptions - Workspace *protocol.ServerCapabilitiesWorkspace `json:"workspace,omitempty"` - Experimental *any `json:"experimental,omitempty"` - DiagnosticProvider json.RawMessage `json:"diagnosticProvider,omitempty"` // nil | DiagnosticOptions | DiagnosticRegistrationOptions + TextDocumentSync json.RawMessage `json:"textDocumentSync,omitempty"` // nil | TextDocumentSyncOptions | TextDocumentSyncKind + CompletionProvider *protocol316.CompletionOptions `json:"completionProvider,omitempty"` + HoverProvider json.RawMessage `json:"hoverProvider,omitempty"` // nil | bool | HoverOptions + SignatureHelpProvider *protocol316.SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` + DeclarationProvider json.RawMessage `json:"declarationProvider,omitempty"` // nil | bool | DeclarationOptions | DeclarationRegistrationOptions + DefinitionProvider json.RawMessage `json:"definitionProvider,omitempty"` // nil | bool | DefinitionOptions + TypeDefinitionProvider json.RawMessage `json:"typeDefinitionProvider,omitempty"` // nil | bool | TypeDefinitionOption | TypeDefinitionRegistrationOptions + ImplementationProvider json.RawMessage `json:"implementationProvider,omitempty"` // nil | bool | ImplementationOptions | ImplementationRegistrationOptions + ReferencesProvider json.RawMessage `json:"referencesProvider,omitempty"` // nil | bool | ReferenceOptions + DocumentHighlightProvider json.RawMessage `json:"documentHighlightProvider,omitempty"` // nil | bool | DocumentHighlightOptions + DocumentSymbolProvider json.RawMessage `json:"documentSymbolProvider,omitempty"` // nil | bool | DocumentSymbolOptions + CodeActionProvider json.RawMessage `json:"codeActionProvider,omitempty"` // nil | bool | CodeActionOptions + CodeLensProvider *protocol316.CodeLensOptions `json:"codeLensProvider,omitempty"` + DocumentLinkProvider *protocol316.DocumentLinkOptions `json:"documentLinkProvider,omitempty"` + ColorProvider json.RawMessage `json:"colorProvider,omitempty"` // nil | bool | DocumentColorOptions | DocumentColorRegistrationOptions + DocumentFormattingProvider json.RawMessage `json:"documentFormattingProvider,omitempty"` // nil | bool | DocumentFormattingOptions + DocumentRangeFormattingProvider json.RawMessage `json:"documentRangeFormattingProvider,omitempty"` // nil | bool | DocumentRangeFormattingOptions + DocumentOnTypeFormattingProvider *protocol316.DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"` + RenameProvider json.RawMessage `json:"renameProvider,omitempty"` // nil | bool | RenameOptions + FoldingRangeProvider json.RawMessage `json:"foldingRangeProvider,omitempty"` // nil | bool | FoldingRangeOptions | FoldingRangeRegistrationOptions + ExecuteCommandProvider *protocol316.ExecuteCommandOptions `json:"executeCommandProvider,omitempty"` + SelectionRangeProvider json.RawMessage `json:"selectionRangeProvider,omitempty"` // nil | bool | SelectionRangeOptions | SelectionRangeRegistrationOptions + LinkedEditingRangeProvider json.RawMessage `json:"linkedEditingRangeProvider,omitempty"` // nil | bool | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions + CallHierarchyProvider json.RawMessage `json:"callHierarchyProvider,omitempty"` // nil | bool | CallHierarchyOptions | CallHierarchyRegistrationOptions + SemanticTokensProvider json.RawMessage `json:"semanticTokensProvider,omitempty"` // nil | SemanticTokensOptions | SemanticTokensRegistrationOptions + MonikerProvider json.RawMessage `json:"monikerProvider,omitempty"` // nil | bool | MonikerOptions | MonikerRegistrationOptions + WorkspaceSymbolProvider json.RawMessage `json:"workspaceSymbolProvider,omitempty"` // nil | bool | WorkspaceSymbolOptions + Workspace *protocol316.ServerCapabilitiesWorkspace `json:"workspace,omitempty"` + Experimental *any `json:"experimental,omitempty"` + DiagnosticProvider json.RawMessage `json:"diagnosticProvider,omitempty"` // nil | DiagnosticOptions | DiagnosticRegistrationOptions } if err := json.Unmarshal(data, &value); err == nil { @@ -98,11 +98,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { self.Workspace = value.Workspace if value.TextDocumentSync != nil { - var value_ protocol.TextDocumentSyncOptions + var value_ protocol316.TextDocumentSyncOptions if err = json.Unmarshal(value.TextDocumentSync, &value_); err == nil { self.TextDocumentSync = value_ } else { - var value_ protocol.TextDocumentSyncKind + var value_ protocol316.TextDocumentSyncKind if err = json.Unmarshal(value.TextDocumentSync, &value_); err == nil { self.TextDocumentSync = value_ } else { @@ -116,7 +116,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.HoverProvider, &value_); err == nil { self.HoverProvider = value_ } else { - var value_ protocol.HoverOptions + var value_ protocol316.HoverOptions if err = json.Unmarshal(value.HoverProvider, &value_); err == nil { self.HoverProvider = value_ } else { @@ -130,11 +130,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.DeclarationProvider, &value_); err == nil { self.DeclarationProvider = value_ } else { - var value_ protocol.DeclarationOptions + var value_ protocol316.DeclarationOptions if err = json.Unmarshal(value.DeclarationProvider, &value_); err == nil { self.DeclarationProvider = value_ } else { - var value_ protocol.DeclarationRegistrationOptions + var value_ protocol316.DeclarationRegistrationOptions if err = json.Unmarshal(value.DeclarationProvider, &value_); err == nil { self.DeclarationProvider = value_ } else { @@ -149,7 +149,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.DefinitionProvider, &value_); err == nil { self.DefinitionProvider = value_ } else { - var value_ protocol.DefinitionOptions + var value_ protocol316.DefinitionOptions if err = json.Unmarshal(value.DefinitionProvider, &value_); err == nil { self.DefinitionProvider = value_ } else { @@ -163,11 +163,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.TypeDefinitionProvider, &value_); err == nil { self.TypeDefinitionProvider = value_ } else { - var value_ protocol.TypeDefinitionOptions + var value_ protocol316.TypeDefinitionOptions if err = json.Unmarshal(value.TypeDefinitionProvider, &value_); err == nil { self.TypeDefinitionProvider = value_ } else { - var value_ protocol.TypeDefinitionRegistrationOptions + var value_ protocol316.TypeDefinitionRegistrationOptions if err = json.Unmarshal(value.TypeDefinitionProvider, &value_); err == nil { self.TypeDefinitionProvider = value_ } else { @@ -182,11 +182,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.ImplementationProvider, &value_); err == nil { self.ImplementationProvider = value_ } else { - var value_ protocol.ImplementationOptions + var value_ protocol316.ImplementationOptions if err = json.Unmarshal(value.ImplementationProvider, &value_); err == nil { self.ImplementationProvider = value_ } else { - var value_ protocol.ImplementationRegistrationOptions + var value_ protocol316.ImplementationRegistrationOptions if err = json.Unmarshal(value.ImplementationProvider, &value_); err == nil { self.ImplementationProvider = value_ } else { @@ -201,7 +201,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.ReferencesProvider, &value_); err == nil { self.ReferencesProvider = value_ } else { - var value_ protocol.ReferenceOptions + var value_ protocol316.ReferenceOptions if err = json.Unmarshal(value.ReferencesProvider, &value_); err == nil { self.ReferencesProvider = value_ } else { @@ -215,7 +215,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.DocumentHighlightProvider, &value_); err == nil { self.DocumentHighlightProvider = value_ } else { - var value_ protocol.DocumentHighlightOptions + var value_ protocol316.DocumentHighlightOptions if err = json.Unmarshal(value.DocumentHighlightProvider, &value_); err == nil { self.DocumentHighlightProvider = value_ } else { @@ -229,7 +229,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.DocumentSymbolProvider, &value_); err == nil { self.DocumentSymbolProvider = value_ } else { - var value_ protocol.DocumentSymbolOptions + var value_ protocol316.DocumentSymbolOptions if err = json.Unmarshal(value.DocumentSymbolProvider, &value_); err == nil { self.DocumentSymbolProvider = value_ } else { @@ -243,7 +243,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.CodeActionProvider, &value_); err == nil { self.CodeActionProvider = value_ } else { - var value_ protocol.CodeActionOptions + var value_ protocol316.CodeActionOptions if err = json.Unmarshal(value.CodeActionProvider, &value_); err == nil { self.CodeActionProvider = value_ } else { @@ -257,11 +257,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.ColorProvider, &value_); err == nil { self.ColorProvider = value_ } else { - var value_ protocol.DocumentColorOptions + var value_ protocol316.DocumentColorOptions if err = json.Unmarshal(value.ColorProvider, &value_); err == nil { self.ColorProvider = value_ } else { - var value_ protocol.DocumentColorRegistrationOptions + var value_ protocol316.DocumentColorRegistrationOptions if err = json.Unmarshal(value.ColorProvider, &value_); err == nil { self.ColorProvider = value_ } else { @@ -276,7 +276,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.DocumentFormattingProvider, &value_); err == nil { self.DocumentFormattingProvider = value_ } else { - var value_ protocol.DocumentFormattingOptions + var value_ protocol316.DocumentFormattingOptions if err = json.Unmarshal(value.DocumentFormattingProvider, &value_); err == nil { self.DocumentFormattingProvider = value_ } else { @@ -290,7 +290,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.DocumentRangeFormattingProvider, &value_); err == nil { self.DocumentRangeFormattingProvider = value_ } else { - var value_ protocol.DocumentRangeFormattingOptions + var value_ protocol316.DocumentRangeFormattingOptions if err = json.Unmarshal(value.DocumentRangeFormattingProvider, &value_); err == nil { self.DocumentRangeFormattingProvider = value_ } else { @@ -304,7 +304,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.RenameProvider, &value_); err == nil { self.RenameProvider = value_ } else { - var value_ protocol.RenameOptions + var value_ protocol316.RenameOptions if err = json.Unmarshal(value.RenameProvider, &value_); err == nil { self.RenameProvider = value_ } else { @@ -318,11 +318,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.FoldingRangeProvider, &value_); err == nil { self.FoldingRangeProvider = value_ } else { - var value_ protocol.FoldingRangeOptions + var value_ protocol316.FoldingRangeOptions if err = json.Unmarshal(value.FoldingRangeProvider, &value_); err == nil { self.FoldingRangeProvider = value_ } else { - var value_ protocol.FoldingRangeRegistrationOptions + var value_ protocol316.FoldingRangeRegistrationOptions if err = json.Unmarshal(value.FoldingRangeProvider, &value_); err == nil { self.FoldingRangeProvider = value_ } else { @@ -337,11 +337,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.SelectionRangeProvider, &value_); err == nil { self.SelectionRangeProvider = value_ } else { - var value_ protocol.SelectionRangeOptions + var value_ protocol316.SelectionRangeOptions if err = json.Unmarshal(value.SelectionRangeProvider, &value_); err == nil { self.SelectionRangeProvider = value_ } else { - var value_ protocol.SelectionRangeRegistrationOptions + var value_ protocol316.SelectionRangeRegistrationOptions if err = json.Unmarshal(value.SelectionRangeProvider, &value_); err == nil { self.SelectionRangeProvider = value_ } else { @@ -356,11 +356,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.LinkedEditingRangeProvider, &value_); err == nil { self.LinkedEditingRangeProvider = value_ } else { - var value_ protocol.LinkedEditingRangeOptions + var value_ protocol316.LinkedEditingRangeOptions if err = json.Unmarshal(value.LinkedEditingRangeProvider, &value_); err == nil { self.LinkedEditingRangeProvider = value_ } else { - var value_ protocol.LinkedEditingRangeRegistrationOptions + var value_ protocol316.LinkedEditingRangeRegistrationOptions if err = json.Unmarshal(value.LinkedEditingRangeProvider, &value_); err == nil { self.LinkedEditingRangeProvider = value_ } else { @@ -375,11 +375,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.CallHierarchyProvider, &value_); err == nil { self.CallHierarchyProvider = value_ } else { - var value_ protocol.CallHierarchyOptions + var value_ protocol316.CallHierarchyOptions if err = json.Unmarshal(value.CallHierarchyProvider, &value_); err == nil { self.CallHierarchyProvider = value_ } else { - var value_ protocol.CallHierarchyRegistrationOptions + var value_ protocol316.CallHierarchyRegistrationOptions if err = json.Unmarshal(value.CallHierarchyProvider, &value_); err == nil { self.CallHierarchyProvider = value_ } else { @@ -390,11 +390,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { } if value.SemanticTokensProvider != nil { - var value_ protocol.SemanticTokensOptions + var value_ protocol316.SemanticTokensOptions if err = json.Unmarshal(value.SemanticTokensProvider, &value_); err == nil { self.SemanticTokensProvider = value_ } else { - var value_ protocol.SemanticTokensRegistrationOptions + var value_ protocol316.SemanticTokensRegistrationOptions if err = json.Unmarshal(value.SemanticTokensProvider, &value_); err == nil { self.SemanticTokensProvider = value_ } else { @@ -408,11 +408,11 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.MonikerProvider, &value_); err == nil { self.MonikerProvider = value_ } else { - var value_ protocol.MonikerOptions + var value_ protocol316.MonikerOptions if err = json.Unmarshal(value.MonikerProvider, &value_); err == nil { self.MonikerProvider = value_ } else { - var value_ protocol.MonikerRegistrationOptions + var value_ protocol316.MonikerRegistrationOptions if err = json.Unmarshal(value.MonikerProvider, &value_); err == nil { self.MonikerProvider = value_ } else { @@ -427,7 +427,7 @@ func (self *ServerCapabilities) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(value.WorkspaceSymbolProvider, &value_); err == nil { self.WorkspaceSymbolProvider = value_ } else { - var value_ protocol.WorkspaceSymbolOptions + var value_ protocol316.WorkspaceSymbolOptions if err = json.Unmarshal(value.WorkspaceSymbolProvider, &value_); err == nil { self.WorkspaceSymbolProvider = value_ } else { @@ -467,5 +467,5 @@ type InitializeResult struct { * * @since 3.15.0 */ - ServerInfo *protocol.InitializeResultServerInfo `json:"serverInfo,omitempty"` + ServerInfo *protocol316.InitializeResultServerInfo `json:"serverInfo,omitempty"` } diff --git a/protocol_3_17/handler.go b/protocol_3_17/handler.go index 35229cd..5026a09 100644 --- a/protocol_3_17/handler.go +++ b/protocol_3_17/handler.go @@ -1,4 +1,4 @@ -package protocol317 +package protocol import ( "encoding/json" @@ -6,11 +6,11 @@ import ( "sync" "github.com/tliron/glsp" - protocol "github.com/tliron/glsp/protocol_3_16" + protocol316 "github.com/tliron/glsp/protocol_3_16" ) type Handler struct { - protocol.Handler + protocol316.Handler Initialize InitializeFunc TextDocumentDiagnostic TextDocumentDiagnosticFunc @@ -20,25 +20,25 @@ type Handler struct { } func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, validParams bool, err error) { - if !self.IsInitialized() && (context.Method != protocol.MethodInitialize) { + if !self.IsInitialized() && (context.Method != protocol316.MethodInitialize) { return nil, true, true, errors.New("server not initialized") } switch context.Method { - case protocol.MethodCancelRequest: + case protocol316.MethodCancelRequest: if self.CancelRequest != nil { validMethod = true - var params protocol.CancelParams + var params protocol316.CancelParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.CancelRequest(context, ¶ms) } } - case protocol.MethodProgress: + case protocol316.MethodProgress: if self.Progress != nil { validMethod = true - var params protocol.ProgressParams + var params protocol316.ProgressParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.Progress(context, ¶ms) @@ -59,17 +59,17 @@ func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, val } } - case protocol.MethodInitialized: + case protocol316.MethodInitialized: if self.Initialized != nil { validMethod = true - var params protocol.InitializedParams + var params protocol316.InitializedParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.Initialized(context, ¶ms) } } - case protocol.MethodShutdown: + case protocol316.MethodShutdown: self.SetInitialized(false) if self.Shutdown != nil { validMethod = true @@ -77,7 +77,7 @@ func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, val err = self.Shutdown(context) } - case protocol.MethodExit: + case protocol316.MethodExit: // Note that the server will close the connection after we handle it here if self.Exit != nil { validMethod = true @@ -85,20 +85,20 @@ func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, val err = self.Exit(context) } - case protocol.MethodLogTrace: + case protocol316.MethodLogTrace: if self.LogTrace != nil { validMethod = true - var params protocol.LogTraceParams + var params protocol316.LogTraceParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.LogTrace(context, ¶ms) } } - case protocol.MethodSetTrace: + case protocol316.MethodSetTrace: if self.SetTrace != nil { validMethod = true - var params protocol.SetTraceParams + var params protocol316.SetTraceParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.SetTrace(context, ¶ms) @@ -107,10 +107,10 @@ func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, val // Window - case protocol.MethodWindowWorkDoneProgressCancel: + case protocol316.MethodWindowWorkDoneProgressCancel: if self.WindowWorkDoneProgressCancel != nil { validMethod = true - var params protocol.WorkDoneProgressCancelParams + var params protocol316.WorkDoneProgressCancelParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.WindowWorkDoneProgressCancel(context, ¶ms) @@ -119,110 +119,110 @@ func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, val // Workspace - case protocol.MethodWorkspaceDidChangeWorkspaceFolders: + case protocol316.MethodWorkspaceDidChangeWorkspaceFolders: if self.WorkspaceDidChangeWorkspaceFolders != nil { validMethod = true - var params protocol.DidChangeWorkspaceFoldersParams + var params protocol316.DidChangeWorkspaceFoldersParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.WorkspaceDidChangeWorkspaceFolders(context, ¶ms) } } - case protocol.MethodWorkspaceDidChangeConfiguration: + case protocol316.MethodWorkspaceDidChangeConfiguration: if self.WorkspaceDidChangeConfiguration != nil { validMethod = true - var params protocol.DidChangeConfigurationParams + var params protocol316.DidChangeConfigurationParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.WorkspaceDidChangeConfiguration(context, ¶ms) } } - case protocol.MethodWorkspaceDidChangeWatchedFiles: + case protocol316.MethodWorkspaceDidChangeWatchedFiles: if self.WorkspaceDidChangeWatchedFiles != nil { validMethod = true - var params protocol.DidChangeWatchedFilesParams + var params protocol316.DidChangeWatchedFilesParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.WorkspaceDidChangeWatchedFiles(context, ¶ms) } } - case protocol.MethodWorkspaceSymbol: + case protocol316.MethodWorkspaceSymbol: if self.WorkspaceSymbol != nil { validMethod = true - var params protocol.WorkspaceSymbolParams + var params protocol316.WorkspaceSymbolParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.WorkspaceSymbol(context, ¶ms) } } - case protocol.MethodWorkspaceExecuteCommand: + case protocol316.MethodWorkspaceExecuteCommand: if self.WorkspaceExecuteCommand != nil { validMethod = true - var params protocol.ExecuteCommandParams + var params protocol316.ExecuteCommandParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.WorkspaceExecuteCommand(context, ¶ms) } } - case protocol.MethodWorkspaceWillCreateFiles: + case protocol316.MethodWorkspaceWillCreateFiles: if self.WorkspaceWillCreateFiles != nil { validMethod = true - var params protocol.CreateFilesParams + var params protocol316.CreateFilesParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.WorkspaceWillCreateFiles(context, ¶ms) } } - case protocol.MethodWorkspaceDidCreateFiles: + case protocol316.MethodWorkspaceDidCreateFiles: if self.WorkspaceDidCreateFiles != nil { validMethod = true - var params protocol.CreateFilesParams + var params protocol316.CreateFilesParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.WorkspaceDidCreateFiles(context, ¶ms) } } - case protocol.MethodWorkspaceWillRenameFiles: + case protocol316.MethodWorkspaceWillRenameFiles: if self.WorkspaceWillRenameFiles != nil { validMethod = true - var params protocol.RenameFilesParams + var params protocol316.RenameFilesParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.WorkspaceWillRenameFiles(context, ¶ms) } } - case protocol.MethodWorkspaceDidRenameFiles: + case protocol316.MethodWorkspaceDidRenameFiles: if self.WorkspaceDidRenameFiles != nil { validMethod = true - var params protocol.RenameFilesParams + var params protocol316.RenameFilesParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.WorkspaceDidRenameFiles(context, ¶ms) } } - case protocol.MethodWorkspaceWillDeleteFiles: + case protocol316.MethodWorkspaceWillDeleteFiles: if self.WorkspaceWillDeleteFiles != nil { validMethod = true - var params protocol.DeleteFilesParams + var params protocol316.DeleteFilesParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.WorkspaceWillDeleteFiles(context, ¶ms) } } - case protocol.MethodWorkspaceDidDeleteFiles: + case protocol316.MethodWorkspaceDidDeleteFiles: if self.WorkspaceDidDeleteFiles != nil { validMethod = true - var params protocol.DeleteFilesParams + var params protocol316.DeleteFilesParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.WorkspaceDidDeleteFiles(context, ¶ms) @@ -231,60 +231,60 @@ func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, val // Text Document Synchronization - case protocol.MethodTextDocumentDidOpen: + case protocol316.MethodTextDocumentDidOpen: if self.TextDocumentDidOpen != nil { validMethod = true - var params protocol.DidOpenTextDocumentParams + var params protocol316.DidOpenTextDocumentParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.TextDocumentDidOpen(context, ¶ms) } } - case protocol.MethodTextDocumentDidChange: + case protocol316.MethodTextDocumentDidChange: if self.TextDocumentDidChange != nil { validMethod = true - var params protocol.DidChangeTextDocumentParams + var params protocol316.DidChangeTextDocumentParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.TextDocumentDidChange(context, ¶ms) } } - case protocol.MethodTextDocumentWillSave: + case protocol316.MethodTextDocumentWillSave: if self.TextDocumentWillSave != nil { validMethod = true - var params protocol.WillSaveTextDocumentParams + var params protocol316.WillSaveTextDocumentParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.TextDocumentWillSave(context, ¶ms) } } - case protocol.MethodTextDocumentWillSaveWaitUntil: + case protocol316.MethodTextDocumentWillSaveWaitUntil: if self.TextDocumentWillSaveWaitUntil != nil { validMethod = true - var params protocol.WillSaveTextDocumentParams + var params protocol316.WillSaveTextDocumentParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentWillSaveWaitUntil(context, ¶ms) } } - case protocol.MethodTextDocumentDidSave: + case protocol316.MethodTextDocumentDidSave: if self.TextDocumentDidSave != nil { validMethod = true - var params protocol.DidSaveTextDocumentParams + var params protocol316.DidSaveTextDocumentParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.TextDocumentDidSave(context, ¶ms) } } - case protocol.MethodTextDocumentDidClose: + case protocol316.MethodTextDocumentDidClose: if self.TextDocumentDidClose != nil { validMethod = true - var params protocol.DidCloseTextDocumentParams + var params protocol316.DidCloseTextDocumentParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true err = self.TextDocumentDidClose(context, ¶ms) @@ -293,347 +293,347 @@ func (self *Handler) Handle(context *glsp.Context) (r any, validMethod bool, val // Language Features - case protocol.MethodTextDocumentCompletion: + case protocol316.MethodTextDocumentCompletion: if self.TextDocumentCompletion != nil { validMethod = true - var params protocol.CompletionParams + var params protocol316.CompletionParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentCompletion(context, ¶ms) } } - case protocol.MethodCompletionItemResolve: + case protocol316.MethodCompletionItemResolve: if self.CompletionItemResolve != nil { validMethod = true - var params protocol.CompletionItem + var params protocol316.CompletionItem if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.CompletionItemResolve(context, ¶ms) } } - case protocol.MethodTextDocumentHover: + case protocol316.MethodTextDocumentHover: if self.TextDocumentHover != nil { validMethod = true - var params protocol.HoverParams + var params protocol316.HoverParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentHover(context, ¶ms) } } - case protocol.MethodTextDocumentSignatureHelp: + case protocol316.MethodTextDocumentSignatureHelp: if self.TextDocumentSignatureHelp != nil { validMethod = true - var params protocol.SignatureHelpParams + var params protocol316.SignatureHelpParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentSignatureHelp(context, ¶ms) } } - case protocol.MethodTextDocumentDeclaration: + case protocol316.MethodTextDocumentDeclaration: if self.TextDocumentDeclaration != nil { validMethod = true - var params protocol.DeclarationParams + var params protocol316.DeclarationParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentDeclaration(context, ¶ms) } } - case protocol.MethodTextDocumentDefinition: + case protocol316.MethodTextDocumentDefinition: if self.TextDocumentDefinition != nil { validMethod = true - var params protocol.DefinitionParams + var params protocol316.DefinitionParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentDefinition(context, ¶ms) } } - case protocol.MethodTextDocumentTypeDefinition: + case protocol316.MethodTextDocumentTypeDefinition: if self.TextDocumentTypeDefinition != nil { validMethod = true - var params protocol.TypeDefinitionParams + var params protocol316.TypeDefinitionParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentTypeDefinition(context, ¶ms) } } - case protocol.MethodTextDocumentImplementation: + case protocol316.MethodTextDocumentImplementation: if self.TextDocumentImplementation != nil { validMethod = true - var params protocol.ImplementationParams + var params protocol316.ImplementationParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentImplementation(context, ¶ms) } } - case protocol.MethodTextDocumentReferences: + case protocol316.MethodTextDocumentReferences: if self.TextDocumentReferences != nil { validMethod = true - var params protocol.ReferenceParams + var params protocol316.ReferenceParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentReferences(context, ¶ms) } } - case protocol.MethodTextDocumentDocumentHighlight: + case protocol316.MethodTextDocumentDocumentHighlight: if self.TextDocumentDocumentHighlight != nil { validMethod = true - var params protocol.DocumentHighlightParams + var params protocol316.DocumentHighlightParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentDocumentHighlight(context, ¶ms) } } - case protocol.MethodTextDocumentDocumentSymbol: + case protocol316.MethodTextDocumentDocumentSymbol: if self.TextDocumentDocumentSymbol != nil { validMethod = true - var params protocol.DocumentSymbolParams + var params protocol316.DocumentSymbolParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentDocumentSymbol(context, ¶ms) } } - case protocol.MethodTextDocumentCodeAction: + case protocol316.MethodTextDocumentCodeAction: if self.TextDocumentCodeAction != nil { validMethod = true - var params protocol.CodeActionParams + var params protocol316.CodeActionParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentCodeAction(context, ¶ms) } } - case protocol.MethodCodeActionResolve: + case protocol316.MethodCodeActionResolve: if self.CodeActionResolve != nil { validMethod = true - var params protocol.CodeAction + var params protocol316.CodeAction if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.CodeActionResolve(context, ¶ms) } } - case protocol.MethodTextDocumentCodeLens: + case protocol316.MethodTextDocumentCodeLens: if self.TextDocumentCodeLens != nil { validMethod = true - var params protocol.CodeLensParams + var params protocol316.CodeLensParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentCodeLens(context, ¶ms) } } - case protocol.MethodCodeLensResolve: + case protocol316.MethodCodeLensResolve: if self.TextDocumentDidClose != nil { validMethod = true - var params protocol.CodeLens + var params protocol316.CodeLens if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.CodeLensResolve(context, ¶ms) } } - case protocol.MethodTextDocumentDocumentLink: + case protocol316.MethodTextDocumentDocumentLink: if self.TextDocumentDocumentLink != nil { validMethod = true - var params protocol.DocumentLinkParams + var params protocol316.DocumentLinkParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentDocumentLink(context, ¶ms) } } - case protocol.MethodDocumentLinkResolve: + case protocol316.MethodDocumentLinkResolve: if self.DocumentLinkResolve != nil { validMethod = true - var params protocol.DocumentLink + var params protocol316.DocumentLink if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.DocumentLinkResolve(context, ¶ms) } } - case protocol.MethodTextDocumentColor: + case protocol316.MethodTextDocumentColor: if self.TextDocumentColor != nil { validMethod = true - var params protocol.DocumentColorParams + var params protocol316.DocumentColorParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentColor(context, ¶ms) } } - case protocol.MethodTextDocumentColorPresentation: + case protocol316.MethodTextDocumentColorPresentation: if self.TextDocumentColorPresentation != nil { validMethod = true - var params protocol.ColorPresentationParams + var params protocol316.ColorPresentationParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentColorPresentation(context, ¶ms) } } - case protocol.MethodTextDocumentFormatting: + case protocol316.MethodTextDocumentFormatting: if self.TextDocumentFormatting != nil { validMethod = true - var params protocol.DocumentFormattingParams + var params protocol316.DocumentFormattingParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentFormatting(context, ¶ms) } } - case protocol.MethodTextDocumentRangeFormatting: + case protocol316.MethodTextDocumentRangeFormatting: if self.TextDocumentRangeFormatting != nil { validMethod = true - var params protocol.DocumentRangeFormattingParams + var params protocol316.DocumentRangeFormattingParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentRangeFormatting(context, ¶ms) } } - case protocol.MethodTextDocumentOnTypeFormatting: + case protocol316.MethodTextDocumentOnTypeFormatting: if self.TextDocumentOnTypeFormatting != nil { validMethod = true - var params protocol.DocumentOnTypeFormattingParams + var params protocol316.DocumentOnTypeFormattingParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentOnTypeFormatting(context, ¶ms) } } - case protocol.MethodTextDocumentRename: + case protocol316.MethodTextDocumentRename: if self.TextDocumentRename != nil { validMethod = true - var params protocol.RenameParams + var params protocol316.RenameParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentRename(context, ¶ms) } } - case protocol.MethodTextDocumentPrepareRename: + case protocol316.MethodTextDocumentPrepareRename: if self.TextDocumentPrepareRename != nil { validMethod = true - var params protocol.PrepareRenameParams + var params protocol316.PrepareRenameParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentPrepareRename(context, ¶ms) } } - case protocol.MethodTextDocumentFoldingRange: + case protocol316.MethodTextDocumentFoldingRange: if self.TextDocumentFoldingRange != nil { validMethod = true - var params protocol.FoldingRangeParams + var params protocol316.FoldingRangeParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentFoldingRange(context, ¶ms) } } - case protocol.MethodTextDocumentSelectionRange: + case protocol316.MethodTextDocumentSelectionRange: if self.TextDocumentSelectionRange != nil { validMethod = true - var params protocol.SelectionRangeParams + var params protocol316.SelectionRangeParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentSelectionRange(context, ¶ms) } } - case protocol.MethodTextDocumentPrepareCallHierarchy: + case protocol316.MethodTextDocumentPrepareCallHierarchy: if self.TextDocumentPrepareCallHierarchy != nil { validMethod = true - var params protocol.CallHierarchyPrepareParams + var params protocol316.CallHierarchyPrepareParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentPrepareCallHierarchy(context, ¶ms) } } - case protocol.MethodCallHierarchyIncomingCalls: + case protocol316.MethodCallHierarchyIncomingCalls: if self.CallHierarchyIncomingCalls != nil { validMethod = true - var params protocol.CallHierarchyIncomingCallsParams + var params protocol316.CallHierarchyIncomingCallsParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.CallHierarchyIncomingCalls(context, ¶ms) } } - case protocol.MethodCallHierarchyOutgoingCalls: + case protocol316.MethodCallHierarchyOutgoingCalls: if self.CallHierarchyOutgoingCalls != nil { validMethod = true - var params protocol.CallHierarchyOutgoingCallsParams + var params protocol316.CallHierarchyOutgoingCallsParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.CallHierarchyOutgoingCalls(context, ¶ms) } } - case protocol.MethodTextDocumentSemanticTokensFull: + case protocol316.MethodTextDocumentSemanticTokensFull: if self.TextDocumentSemanticTokensFull != nil { validMethod = true - var params protocol.SemanticTokensParams + var params protocol316.SemanticTokensParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentSemanticTokensFull(context, ¶ms) } } - case protocol.MethodTextDocumentSemanticTokensFullDelta: + case protocol316.MethodTextDocumentSemanticTokensFullDelta: if self.TextDocumentSemanticTokensFullDelta != nil { validMethod = true - var params protocol.SemanticTokensDeltaParams + var params protocol316.SemanticTokensDeltaParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentSemanticTokensFullDelta(context, ¶ms) } } - case protocol.MethodTextDocumentSemanticTokensRange: + case protocol316.MethodTextDocumentSemanticTokensRange: if self.TextDocumentSemanticTokensRange != nil { validMethod = true - var params protocol.SemanticTokensRangeParams + var params protocol316.SemanticTokensRangeParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentSemanticTokensRange(context, ¶ms) } } - case protocol.MethodWorkspaceSemanticTokensRefresh: + case protocol316.MethodWorkspaceSemanticTokensRefresh: if self.WorkspaceSemanticTokensRefresh != nil { validMethod = true validParams = true err = self.WorkspaceSemanticTokensRefresh(context) } - case protocol.MethodTextDocumentLinkedEditingRange: + case protocol316.MethodTextDocumentLinkedEditingRange: if self.TextDocumentLinkedEditingRange != nil { validMethod = true - var params protocol.LinkedEditingRangeParams + var params protocol316.LinkedEditingRangeParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentLinkedEditingRange(context, ¶ms) } } - case protocol.MethodTextDocumentMoniker: + case protocol316.MethodTextDocumentMoniker: if self.TextDocumentMoniker != nil { validMethod = true - var params protocol.MonikerParams + var params protocol316.MonikerParams if err = json.Unmarshal(context.Params, ¶ms); err == nil { validParams = true r, err = self.TextDocumentMoniker(context, ¶ms) @@ -670,44 +670,44 @@ func (self *Handler) CreateServerCapabilities() ServerCapabilities { var capabilities ServerCapabilities if (self.TextDocumentDidOpen != nil) || (self.TextDocumentDidClose != nil) { - if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { - capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + if _, ok := capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol316.TextDocumentSyncOptions{} } - capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).OpenClose = &protocol.True + capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions).OpenClose = &protocol316.True } if self.TextDocumentDidChange != nil { - if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { - capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + if _, ok := capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol316.TextDocumentSyncOptions{} } // This can be overriden to TextDocumentSyncKindFull - value := protocol.TextDocumentSyncKindIncremental - capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).Change = &value + value := protocol316.TextDocumentSyncKindIncremental + capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions).Change = &value } if self.TextDocumentWillSave != nil { - if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { - capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + if _, ok := capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol316.TextDocumentSyncOptions{} } - capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).WillSave = &protocol.True + capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions).WillSave = &protocol316.True } if self.TextDocumentWillSaveWaitUntil != nil { - if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { - capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + if _, ok := capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol316.TextDocumentSyncOptions{} } - capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).WillSaveWaitUntil = &protocol.True + capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions).WillSaveWaitUntil = &protocol316.True } if self.TextDocumentDidSave != nil { - if _, ok := capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions); !ok { - capabilities.TextDocumentSync = &protocol.TextDocumentSyncOptions{} + if _, ok := capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions); !ok { + capabilities.TextDocumentSync = &protocol316.TextDocumentSyncOptions{} } - capabilities.TextDocumentSync.(*protocol.TextDocumentSyncOptions).Save = &protocol.True + capabilities.TextDocumentSync.(*protocol316.TextDocumentSyncOptions).Save = &protocol316.True } if self.TextDocumentCompletion != nil { - capabilities.CompletionProvider = &protocol.CompletionOptions{} + capabilities.CompletionProvider = &protocol316.CompletionOptions{} } if self.TextDocumentHover != nil { @@ -715,7 +715,7 @@ func (self *Handler) CreateServerCapabilities() ServerCapabilities { } if self.TextDocumentSignatureHelp != nil { - capabilities.SignatureHelpProvider = &protocol.SignatureHelpOptions{} + capabilities.SignatureHelpProvider = &protocol316.SignatureHelpOptions{} } if self.TextDocumentDeclaration != nil { @@ -751,11 +751,11 @@ func (self *Handler) CreateServerCapabilities() ServerCapabilities { } if self.TextDocumentCodeLens != nil { - capabilities.CodeLensProvider = &protocol.CodeLensOptions{} + capabilities.CodeLensProvider = &protocol316.CodeLensOptions{} } if self.TextDocumentDocumentLink != nil { - capabilities.DocumentLinkProvider = &protocol.DocumentLinkOptions{} + capabilities.DocumentLinkProvider = &protocol316.DocumentLinkOptions{} } if self.TextDocumentColor != nil { @@ -771,7 +771,7 @@ func (self *Handler) CreateServerCapabilities() ServerCapabilities { } if self.TextDocumentOnTypeFormatting != nil { - capabilities.DocumentOnTypeFormattingProvider = &protocol.DocumentOnTypeFormattingOptions{} + capabilities.DocumentOnTypeFormattingProvider = &protocol316.DocumentOnTypeFormattingOptions{} } if self.TextDocumentRename != nil { @@ -783,7 +783,7 @@ func (self *Handler) CreateServerCapabilities() ServerCapabilities { } if self.WorkspaceExecuteCommand != nil { - capabilities.ExecuteCommandProvider = &protocol.ExecuteCommandOptions{} + capabilities.ExecuteCommandProvider = &protocol316.ExecuteCommandOptions{} } if self.TextDocumentSelectionRange != nil { @@ -799,22 +799,22 @@ func (self *Handler) CreateServerCapabilities() ServerCapabilities { } if self.TextDocumentSemanticTokensFull != nil { - if _, ok := capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions); !ok { - capabilities.SemanticTokensProvider = &protocol.SemanticTokensOptions{} + if _, ok := capabilities.SemanticTokensProvider.(*protocol316.SemanticTokensOptions); !ok { + capabilities.SemanticTokensProvider = &protocol316.SemanticTokensOptions{} } if self.TextDocumentSemanticTokensFullDelta != nil { - capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions).Full = &protocol.SemanticDelta{} - capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions).Full.(*protocol.SemanticDelta).Delta = &protocol.True + capabilities.SemanticTokensProvider.(*protocol316.SemanticTokensOptions).Full = &protocol316.SemanticDelta{} + capabilities.SemanticTokensProvider.(*protocol316.SemanticTokensOptions).Full.(*protocol316.SemanticDelta).Delta = &protocol316.True } else { - capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions).Full = true + capabilities.SemanticTokensProvider.(*protocol316.SemanticTokensOptions).Full = true } } if self.TextDocumentSemanticTokensRange != nil { - if _, ok := capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions); !ok { - capabilities.SemanticTokensProvider = &protocol.SemanticTokensOptions{} + if _, ok := capabilities.SemanticTokensProvider.(*protocol316.SemanticTokensOptions); !ok { + capabilities.SemanticTokensProvider = &protocol316.SemanticTokensOptions{} } - capabilities.SemanticTokensProvider.(*protocol.SemanticTokensOptions).Range = true + capabilities.SemanticTokensProvider.(*protocol316.SemanticTokensOptions).Range = true } // TODO: self.TextDocumentSemanticTokensRefresh? @@ -829,75 +829,75 @@ func (self *Handler) CreateServerCapabilities() ServerCapabilities { if self.WorkspaceDidCreateFiles != nil { if capabilities.Workspace == nil { - capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + capabilities.Workspace = &protocol316.ServerCapabilitiesWorkspace{} } if capabilities.Workspace.FileOperations == nil { - capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + capabilities.Workspace.FileOperations = &protocol316.ServerCapabilitiesWorkspaceFileOperations{} } - capabilities.Workspace.FileOperations.DidCreate = &protocol.FileOperationRegistrationOptions{ - Filters: []protocol.FileOperationFilter{}, + capabilities.Workspace.FileOperations.DidCreate = &protocol316.FileOperationRegistrationOptions{ + Filters: []protocol316.FileOperationFilter{}, } } if self.WorkspaceWillCreateFiles != nil { if capabilities.Workspace == nil { - capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + capabilities.Workspace = &protocol316.ServerCapabilitiesWorkspace{} } if capabilities.Workspace.FileOperations == nil { - capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + capabilities.Workspace.FileOperations = &protocol316.ServerCapabilitiesWorkspaceFileOperations{} } - capabilities.Workspace.FileOperations.WillCreate = &protocol.FileOperationRegistrationOptions{ - Filters: []protocol.FileOperationFilter{}, + capabilities.Workspace.FileOperations.WillCreate = &protocol316.FileOperationRegistrationOptions{ + Filters: []protocol316.FileOperationFilter{}, } } if self.WorkspaceDidRenameFiles != nil { capabilities.RenameProvider = true if capabilities.Workspace == nil { - capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + capabilities.Workspace = &protocol316.ServerCapabilitiesWorkspace{} } if capabilities.Workspace.FileOperations == nil { - capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + capabilities.Workspace.FileOperations = &protocol316.ServerCapabilitiesWorkspaceFileOperations{} } - capabilities.Workspace.FileOperations.DidRename = &protocol.FileOperationRegistrationOptions{ - Filters: []protocol.FileOperationFilter{}, + capabilities.Workspace.FileOperations.DidRename = &protocol316.FileOperationRegistrationOptions{ + Filters: []protocol316.FileOperationFilter{}, } } if self.WorkspaceWillRenameFiles != nil { capabilities.RenameProvider = true if capabilities.Workspace == nil { - capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + capabilities.Workspace = &protocol316.ServerCapabilitiesWorkspace{} } if capabilities.Workspace.FileOperations == nil { - capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + capabilities.Workspace.FileOperations = &protocol316.ServerCapabilitiesWorkspaceFileOperations{} } - capabilities.Workspace.FileOperations.WillRename = &protocol.FileOperationRegistrationOptions{ - Filters: []protocol.FileOperationFilter{}, + capabilities.Workspace.FileOperations.WillRename = &protocol316.FileOperationRegistrationOptions{ + Filters: []protocol316.FileOperationFilter{}, } } if self.WorkspaceDidDeleteFiles != nil { if capabilities.Workspace == nil { - capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + capabilities.Workspace = &protocol316.ServerCapabilitiesWorkspace{} } if capabilities.Workspace.FileOperations == nil { - capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + capabilities.Workspace.FileOperations = &protocol316.ServerCapabilitiesWorkspaceFileOperations{} } - capabilities.Workspace.FileOperations.DidDelete = &protocol.FileOperationRegistrationOptions{ - Filters: []protocol.FileOperationFilter{}, + capabilities.Workspace.FileOperations.DidDelete = &protocol316.FileOperationRegistrationOptions{ + Filters: []protocol316.FileOperationFilter{}, } } if self.WorkspaceWillDeleteFiles != nil { if capabilities.Workspace == nil { - capabilities.Workspace = &protocol.ServerCapabilitiesWorkspace{} + capabilities.Workspace = &protocol316.ServerCapabilitiesWorkspace{} } if capabilities.Workspace.FileOperations == nil { - capabilities.Workspace.FileOperations = &protocol.ServerCapabilitiesWorkspaceFileOperations{} + capabilities.Workspace.FileOperations = &protocol316.ServerCapabilitiesWorkspaceFileOperations{} } - capabilities.Workspace.FileOperations.WillDelete = &protocol.FileOperationRegistrationOptions{ - Filters: []protocol.FileOperationFilter{}, + capabilities.Workspace.FileOperations.WillDelete = &protocol316.FileOperationRegistrationOptions{ + Filters: []protocol316.FileOperationFilter{}, } }