From 900487d73e3aba4706bef4c87cd7acdeddd17eb0 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 5 May 2024 23:37:34 +0900 Subject: [PATCH 01/19] WIP Signed-off-by: Koichi Shiraishi --- tools/protocol-gen/generator/client_server.go | 461 ++++++++++++ tools/protocol-gen/generator/enumeration.go | 122 ++++ tools/protocol-gen/generator/generator.go | 324 +++++++++ .../protocol-gen/generator/generics_types.go | 267 +++++++ tools/protocol-gen/generator/structure.go | 659 ++++++++++++++++++ tools/protocol-gen/generator/typealiases.go | 212 ++++++ tools/protocol-gen/go.mod | 9 + tools/protocol-gen/go.sum | 20 + tools/protocol-gen/main.go | 154 ++++ tools/protocol-gen/protocol/enum.go | 54 ++ tools/protocol-gen/protocol/message_dir.go | 13 + tools/protocol-gen/protocol/notification.go | 35 + tools/protocol-gen/protocol/property.go | 31 + tools/protocol-gen/protocol/protocol.go | 48 ++ tools/protocol-gen/protocol/request.go | 43 ++ tools/protocol-gen/protocol/structure.go | 42 ++ .../protocol/structure_literal.go | 22 + tools/protocol-gen/protocol/type.go | 258 +++++++ tools/protocol-gen/protocol/type_alias.go | 28 + tools/protocol-gen/protocol/type_decl.go | 9 + tools/protocol-gen/resolver/resolver.go | 474 +++++++++++++ tools/protocol-gen/schema/metaModel.go | 485 +++++++++++++ 22 files changed, 3770 insertions(+) create mode 100644 tools/protocol-gen/generator/client_server.go create mode 100644 tools/protocol-gen/generator/enumeration.go create mode 100644 tools/protocol-gen/generator/generator.go create mode 100644 tools/protocol-gen/generator/generics_types.go create mode 100644 tools/protocol-gen/generator/structure.go create mode 100644 tools/protocol-gen/generator/typealiases.go create mode 100644 tools/protocol-gen/go.mod create mode 100644 tools/protocol-gen/go.sum create mode 100644 tools/protocol-gen/main.go create mode 100644 tools/protocol-gen/protocol/enum.go create mode 100644 tools/protocol-gen/protocol/message_dir.go create mode 100644 tools/protocol-gen/protocol/notification.go create mode 100644 tools/protocol-gen/protocol/property.go create mode 100644 tools/protocol-gen/protocol/protocol.go create mode 100644 tools/protocol-gen/protocol/request.go create mode 100644 tools/protocol-gen/protocol/structure.go create mode 100644 tools/protocol-gen/protocol/structure_literal.go create mode 100644 tools/protocol-gen/protocol/type.go create mode 100644 tools/protocol-gen/protocol/type_alias.go create mode 100644 tools/protocol-gen/protocol/type_decl.go create mode 100644 tools/protocol-gen/resolver/resolver.go create mode 100644 tools/protocol-gen/schema/metaModel.go diff --git a/tools/protocol-gen/generator/client_server.go b/tools/protocol-gen/generator/client_server.go new file mode 100644 index 00000000..40a1b7d9 --- /dev/null +++ b/tools/protocol-gen/generator/client_server.go @@ -0,0 +1,461 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package generator + +import ( + "cmp" + "fmt" + "slices" + "strconv" + "strings" + + "go.lsp.dev/protocol/tools/protocol-gen/protocol" +) + +func (gen *Generator) ClientToServer(clientNotifications, bidiNotifications []*protocol.Notification, clientRequests, bidiRequests []*protocol.Request) error { + g := NewPrinter("client_interface") + gen.client = append(gen.client, g) + + g.PP(`const (`) + if len(bidiNotifications) > 0 { + slices.SortFunc(bidiNotifications, func(a, b *protocol.Notification) int { + if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { + return cmp.Compare(a.Method, b.Method) + } + return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) + }) + for _, meth := range bidiNotifications { + g.PP(` `, `MethodClient`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect client notification`) + } + } + slices.SortFunc(clientNotifications, func(a, b *protocol.Notification) int { + if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { + return cmp.Compare(a.Method, b.Method) + } + return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) + }) + for _, meth := range clientNotifications { + g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // client notification`) + } + if len(bidiRequests) > 0 { + slices.SortFunc(bidiRequests, func(a, b *protocol.Request) int { + if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { + return cmp.Compare(a.Method, b.Method) + } + return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) + }) + for _, meth := range bidiRequests { + g.PP(` `, `MethodClient`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect client request`) + } + } + slices.SortFunc(clientRequests, func(a, b *protocol.Request) int { + if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { + return cmp.Compare(a.Method, b.Method) + } + return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) + }) + for _, meth := range clientRequests { + g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // client request`) + } + g.PP(`)`) + + g.PP(`type Client interface {`) + + notifications := append(bidiNotifications, clientNotifications...) + reqests := append(bidiRequests, clientRequests...) + + for i, notify := range notifications { + meth := normalizeMethodName(notify.Method) + // write Documentation + if notify.Documentation != "" { + g.PP(`// `, meth, normalizeDocumentation(notify.Documentation)) + } + if notify.Since != "" { + if notify.Documentation != "" { + g.PP(`//`) + } + g.P(`// @since `, strings.ReplaceAll(notify.Since, "\n", " ")) + if notify.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + if err := gen.notification(g, meth, notify); err != nil { + return err + } + g.P("\n") + // add newline per clientNotifications and bidiNotifications + if i < len(notifications)-1 { + g.P("\n") + } + } + for i, req := range reqests { + meth := normalizeMethodName(req.Method) + // write Documentation + if req.Documentation != "" { + g.PP(`// `, meth, normalizeDocumentation(req.Documentation)) + } + if req.Since != "" { + if req.Documentation != "" { + g.PP(`//`) + } + g.P(`// @since `, strings.ReplaceAll(req.Since, "\n", " ")) + if req.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + if _, err := gen.request(g, meth, req); err != nil { + return err + } + g.P("\n") + // add newline per clientRequests and bidiRequests + if i < len(reqests)-1 { + g.P("\n") + } + } + g.PP(`}`) + g.P("\n") + + g.PP(`// UnimplementedClient should be embedded to have forward compatible implementations.`) + g.PP(`type UnimplementedClient struct {}`) + g.P("\n") + for i, notify := range notifications { + meth := normalizeMethodName(notify.Method) + g.P(`func (UnimplementedClient) `) + if err := gen.notification(g, meth, notify); err != nil { + return err + } + g.PP(` {`) + g.PP(` return jsonrpc2.ErrInternal`) + g.PP(`}`) + // add newline per clientNotifications and bidiNotifications + if i < len(notifications)-1 { + g.P("\n") + } + } + for i, req := range reqests { + meth := normalizeMethodName(req.Method) + if meth == "" { + continue + } + g.P(`func (UnimplementedClient) `) + n, err := gen.request(g, meth, req) + if err != nil { + return err + } + g.PP(` {`) + g.P(` return `) + if n > 0 { + g.P(` nil, `) + } + g.PP(`jsonrpc2.ErrInternal`) + g.PP(`}`) + // add newline per clientRequests and bidiRequests + if i < len(reqests)-1 { + g.P("\n") + } + } + + if err := g.WriteTo(); err != nil { + return err + } + + return nil +} + +func (gen *Generator) ServerToClient(serverNotifications, bidiNotifications []*protocol.Notification, serverNequests, bidiRequests []*protocol.Request) error { + g := NewPrinter("server_interface") + gen.server = append(gen.server, g) + + g.PP(`const (`) + if len(bidiNotifications) > 0 { + slices.SortFunc(bidiNotifications, func(a, b *protocol.Notification) int { + if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { + return cmp.Compare(a.Method, b.Method) + } + return cmp.Compare(a.Method, b.Method) + }) + for _, meth := range bidiNotifications { + g.PP(` `, `MethodServer`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect server notification`) + } + } + slices.SortFunc(serverNotifications, func(a, b *protocol.Notification) int { + if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { + return cmp.Compare(a.Method, b.Method) + } + return cmp.Compare(a.Method, b.Method) + }) + for _, meth := range serverNotifications { + g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // server notification`) + } + if len(bidiRequests) > 0 { + slices.SortFunc(bidiRequests, func(a, b *protocol.Request) int { + if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { + return cmp.Compare(a.Method, b.Method) + } + return cmp.Compare(a.Method, b.Method) + }) + for _, meth := range bidiRequests { + g.PP(` `, `MethodServer`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect server request`) + } + } + slices.SortFunc(serverNequests, func(a, b *protocol.Request) int { + if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { + return cmp.Compare(a.Method, b.Method) + } + return cmp.Compare(a.Method, b.Method) + }) + for _, meth := range serverNequests { + g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // server request`) + } + g.PP(`)`) + + g.PP(`type Server interface {`) + + notifications := append(slices.Clip(bidiNotifications), slices.Clip(serverNotifications)...) + reqests := slices.Clip(serverNequests) + + for i, notify := range notifications { + meth := normalizeMethodName(notify.Method) + // write Documentation + if notify.Documentation != "" { + g.PP(`// `, meth, normalizeDocumentation(notify.Documentation)) + } + if notify.Since != "" { + if notify.Documentation != "" { + g.PP(`//`) + } + g.P(`// @since `, strings.ReplaceAll(notify.Since, "\n", " ")) + if notify.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + if err := gen.notification(g, meth, notify); err != nil { + return err + } + g.P("\n") + // add newline per serverNotifications and bidiNotifications + if i < len(notifications)-1 { + g.P("\n") + } + } + for i, req := range reqests { + meth := normalizeMethodName(req.Method) + // write Documentation + if req.Documentation != "" { + g.PP(`// `, meth, normalizeDocumentation(req.Documentation)) + } + if req.Since != "" { + if req.Documentation != "" { + g.PP(`//`) + } + g.P(`// @since `, strings.ReplaceAll(req.Since, "\n", " ")) + if req.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + if _, err := gen.request(g, meth, req); err != nil { + return err + } + g.P("\n") + // add newline per serverNequests and bidiRequests + if i < len(reqests)-1 { + g.P("\n") + } + } + g.P("\n") + g.PP(`Request(ctx context.Context, method string, params any) (any, error)`) + g.PP(`}`) + g.P("\n") + + g.PP(`// UnimplementedServer should be embedded to have forward compatible implementations.`) + g.PP(`type UnimplementedServer struct {}`) + g.P("\n") + for i, notify := range notifications { + meth := normalizeMethodName(notify.Method) + g.P(`func (UnimplementedServer) `) + if err := gen.notification(g, meth, notify); err != nil { + return err + } + g.PP(` {`) + g.PP(` return jsonrpc2.ErrInternal`) + g.PP(`}`) + // add newline per clientNotifications and bidiNotifications + if i < len(notifications)-1 { + g.P("\n") + } + } + for i, req := range reqests { + meth := normalizeMethodName(req.Method) + g.P(`func (UnimplementedServer) `) + n, err := gen.request(g, meth, req) + if err != nil { + return err + } + g.PP(` {`) + g.P(` return `) + if n > 0 { + g.P(` nil, `) + } + g.PP(`jsonrpc2.ErrInternal`) + g.PP(`}`) + // add newline per clientRequests and bidiRequests + if i < len(reqests)-1 { + g.P("\n") + } + } + + if err := g.WriteTo(); err != nil { + return err + } + + return nil +} + +// notification generates notification Go type from the metaModel schema definition. +func (gen *Generator) notification(g Printer, meth string, notify *protocol.Notification) error { + g.P(` `, meth, `(ctx context.Context, `) + + if len(notify.Params) == 0 { + g.P(`) error`) + return nil + } + for _, param := range notify.Params { + switch p := param.(type) { + case *protocol.ReferenceType: + g.P(`params `) + pt, ok := normalizeHasLSPTypes(p.String()) + if !ok { + g.P(`*`) + } + g.P(pt) + + default: + panic(fmt.Sprintf("notification: %#v\n", p)) + } + } + + g.P(`) error`) + + return nil +} + +// request generates request Go type from the metaModel schema definition. +func (gen *Generator) request(g Printer, meth string, req *protocol.Request) (nResult int, err error) { + g.P(` `, meth, `(ctx context.Context, `) + + for _, param := range req.Params { + switch p := param.(type) { + case *protocol.ReferenceType: + g.P(`params *`, normalizeLSPTypes(p.String())) + + default: + panic(fmt.Sprintf("requests: %#v\n", p)) + } + } + + g.P(`) (`) + + switch r := req.Result.(type) { + case *protocol.NullType: + // nothing to do + + case *protocol.ReferenceType: + nResult++ + g.P(`*`) + g.P(normalizeLSPTypes(r.String())) + g.P(`, `) + + case *protocol.ArrayType: + nResult++ + gen.renderRequestsArrayType(g, req, r) + g.P(`, `) + + case *protocol.OrType: + nResult++ + switch { + case len(r.Items) == 2 && (isNull(r.Items[0], r.Items[1])): + gen.renderRequestssOrTypeNull(g, req, r) + g.P(`, `) + default: + genericsType := genericsType{ + Name: meth + "Result", + Documentation: req.Documentation, + Since: req.Since, + Proposed: req.Proposed, + } + gen.renderRequestssOrType(g, r, genericsType) + g.P(`, `) + } + + default: + panic(fmt.Sprintf("requests: %#v\n", r)) + } + + g.P(`error)`) + + return nResult, nil +} + +func (gen *Generator) renderRequestsArrayType(g Printer, req *protocol.Request, array *protocol.ArrayType) { + elem := array.Element + switch elem := elem.(type) { + case *protocol.ReferenceType: + g.P(`[]`) + pt, ok := normalizeHasLSPTypes(elem.String()) + if !ok { + g.P(`*`) + } + g.P(pt) + + case *protocol.OrType: + switch { + case len(elem.Items) == 2 && (isNull(elem.Items[0], elem.Items[1])): + g.P(`[]*`) + gen.renderRequestssOrTypeNull(g, req, elem) + default: + genericsType := genericsType{ + Name: normalizeMethodName(req.Method) + "Result", + Documentation: req.Documentation, + Since: req.Since, + Proposed: req.Proposed, + } + gen.renderRequestssOrType(g, elem, genericsType) + } + + default: + panic(fmt.Sprintf("request.Array: %#v\n", elem)) + } +} + +func (gen *Generator) renderRequestssOrTypeNull(g Printer, req *protocol.Request, or *protocol.OrType) { + for _, item := range or.Items { + if isNull(item) { + continue + } + + switch item := item.(type) { + case *protocol.ReferenceType: + pt, ok := normalizeHasLSPTypes(item.String()) + if !ok { + g.P(`*`) + } + g.P(pt) + + case *protocol.ArrayType: + gen.renderRequestsArrayType(g, req, item) + + default: + panic(fmt.Sprintf("request.OrType: %[1]T = %#[1]v\n", item)) + } + } +} + +func (gen *Generator) renderRequestssOrType(g Printer, or *protocol.OrType, genericsType genericsType) { + g.P(` *`, genericsType.Name) + gen.genericsTypes[genericsType] = or.Items +} diff --git a/tools/protocol-gen/generator/enumeration.go b/tools/protocol-gen/generator/enumeration.go new file mode 100644 index 00000000..96818ec0 --- /dev/null +++ b/tools/protocol-gen/generator/enumeration.go @@ -0,0 +1,122 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package generator + +import ( + "fmt" + + "github.com/gobuffalo/flect" + + "go.lsp.dev/protocol/tools/protocol-gen/protocol" +) + +var enumerationNames = map[string]string{ + "SemanticTokenTypes": "language", + "SemanticTokenModifiers": "language", + "DocumentDiagnosticReportKind": "language", + "ErrorCodes": "base", + "LSPErrorCodes": "base", + "FoldingRangeKind": "language", + "SymbolKind": "language", + "SymbolTag": "language", + "UniquenessLevel": "language", + "MonikerKind": "language", + "InlayHintKind": "language", + "MessageType": "window", + "TextDocumentSyncKind": "lifecycle", + "TextDocumentSaveReason": "document", + "CompletionItemKind": "language", + "CompletionItemTag": "language", + "InsertTextFormat": "language", + "InsertTextMode": "language", + "DocumentHighlightKind": "language", + "CodeActionKind": "language", + "TraceValue": "basic", + "MarkupKind": "basic", + "LanguageKind": "basic", + "InlineCompletionTriggerKind": "language", + "PositionEncodingKind": "basic", + "FileChangeType": "workspace", + "WatchKind": "workspace", + "DiagnosticSeverity": "basic", + "DiagnosticTag": "basic", + "CompletionTriggerKind": "language", + "SignatureHelpTriggerKind": "language", + "CodeActionTriggerKind": "language", + "FileOperationPatternKind": "workspace", + "NotebookCellKind": "document", + "ResourceOperationKind": "basic", + "FailureHandlingKind": "basic", + "PrepareSupportDefaultBehavior": "language", + "TokenFormat": "language", +} + +// Enumerations generates Enumerations Go type from the metaModel schema definition. +func (gen *Generator) Enumerations(enumerations []*protocol.Enumeration) error { + for _, enum := range enumerations { + enumName := flect.Pascalize(enum.Name) + filename, ok := enumerationNames[enumName] + if !ok { + panic(fmt.Sprintf("not found %s enumerations file", enumName)) + } + + // Init filename printers + g := NewPrinter(filename) + gen.enumerations = append(gen.enumerations, g) + + // write Documentation + if enum.Documentation != "" { + g.PP(`// `, enumName, normalizeDocumentation(enum.Documentation)) + } + if enum.Since != "" { + if enum.Documentation != "" { + g.PP(`//`) + } + g.P(`// @since `, enum.Since) + if enum.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + + g.P(`type `, enumName) + switch e := enum.Type.(type) { + case protocol.BaseType: + g.P(` `, e.String()) + default: + panic(fmt.Sprintf("enumerations: %#v\n", e)) + } + g.PP("\n") + + g.PP(`const (`) + for i, val := range enum.Values { + // write Documentation + if val.Documentation != "" { + g.PP(` // `, flect.Pascalize(val.Name), enumName, normalizeDocumentation(val.Documentation)) + } + if val.Since != "" { + if val.Documentation != "" { + g.PP(` //`) + } + g.P(` // @since `, val.Since) + if val.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + + g.P(` `, flect.Pascalize(val.Name), enumName) + g.P(` `, enumName, ` = `, val.Value) + g.P("\n") + + // Add newline per fields + if i < len(enum.Values)-1 { + g.P("\n") + } + } + g.PP(`)`, "\n") + } + + return nil +} diff --git a/tools/protocol-gen/generator/generator.go b/tools/protocol-gen/generator/generator.go new file mode 100644 index 00000000..b5d05182 --- /dev/null +++ b/tools/protocol-gen/generator/generator.go @@ -0,0 +1,324 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package generator + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "io" + "os" + "path/filepath" + "strconv" + "strings" + + "github.com/davecgh/go-spew/spew" + "github.com/gobuffalo/flect" + + "go.lsp.dev/protocol/tools/protocol-gen/protocol" +) + +var acronyms = [...]string{ + "LSP", +} + +func init() { + spew.Config = spew.ConfigState{ + Indent: " ", + ContinueOnMethod: true, + SortKeys: true, + } + + var buf bytes.Buffer + buf.WriteByte('[') + for i, acronym := range acronyms { + buf.WriteString(strconv.Quote(acronym)) + if i < len(acronyms)-1 { + buf.WriteByte(',') + } + } + buf.WriteByte(']') + if err := flect.LoadAcronyms(&buf); err != nil { + panic(err) + } +} + +const ( + pkgContext = `"context"` + pkgURI = `"go.lsp.dev/uri"` + pkgJSONRPC = `"go.lsp.dev/jsonrpc2"` +) + +type genericsType struct { + Name string + Documentation string + Since string + Proposed bool +} + +type Generator struct { + enumerations []Printer + typeAliases []Printer + structures []Printer + client []Printer + server []Printer + generics map[string]bool + genericsTypes map[genericsType][]protocol.Type + files map[string]*os.File +} + +func (gen *Generator) Init() { + gen.generics = make(map[string]bool) + gen.genericsTypes = make(map[genericsType][]protocol.Type) + gen.files = make(map[string]*os.File) +} + +func (gen *Generator) writeTo(pp []Printer) (err error) { + for _, p := range pp { + filename := p.Filename() + + f, ok := gen.files[filename] + if !ok { + // creates file for writing target + cwd, err := os.Getwd() + if err != nil { + return err + } + root := filepath.Join(filepath.Dir(filepath.Dir(cwd)), ".protocol") + f, err = os.Create(filepath.Join(root, filename)) + if err != nil { + return fmt.Errorf("unable to open %s file: %w", filename, err) + } + gen.files[filename] = f + + // Writes header content to the file at first + f.WriteString(`// Copyright 2024 The Go Language Server Authors` + "\n") + f.WriteString(`// SPDX-License-Identifier: BSD-3-Clause` + "\n") + f.WriteString("\n") + f.WriteString(`package protocol` + "\n") + f.WriteString("\n") + f.WriteString(`import (` + "\n") + f.WriteString(` ` + pkgContext + "\n\n") + f.WriteString(` ` + pkgURI + "\n") + f.WriteString(` ` + pkgJSONRPC + "\n") + f.WriteString(`)` + "\n\n") + } + + f.Write(p.Bytes()) + } + + return nil +} + +func (gen *Generator) WriteTo() (err error) { + if err := gen.writeTo(gen.enumerations); err != nil { + return err + } + if err := gen.writeTo(gen.structures); err != nil { + return err + } + + for _, f := range gen.files { + if err := f.Close(); err != nil { + return err + } + } + + return nil +} + +type Printer interface { + P(a ...any) + PP(a ...any) + Filename() string + Bytes() []byte + WriteTo() error +} + +type printer struct { + filename string + buf bytes.Buffer +} + +func NewPrinter(filename string) Printer { + return &printer{ + filename: filename + ".go", + } +} + +func (p *printer) p(w io.Writer, a ...any) { + fmt.Fprint(w, a...) +} + +// P prints a line to the generated output. +// +// It converts each parameter to a string following the same rules as [fmt.Print]. +// It never inserts spaces between parameters. +func (p *printer) P(a ...any) { + p.p(&p.buf, a...) +} + +// PP prints a line to the generated output with newline. +// +// It converts each parameter to a string following the same rules as [fmt.Print]. +// It never inserts spaces between parameters. +func (p *printer) PP(a ...any) { + p.p(&p.buf, a...) + p.p(&p.buf, "\n") +} + +func (p *printer) Filename() string { + return p.filename +} + +func (p *printer) Bytes() []byte { + return p.buf.Bytes() +} + +// WriteTo creates a p.filename file and writes the generated code. +func (p *printer) WriteTo() (err error) { + // Creates file for writing target + cwd, err := os.Getwd() + if err != nil { + return err + } + root := filepath.Join(filepath.Dir(filepath.Dir(cwd)), ".protocol") + f, err := os.Create(filepath.Join(root, p.filename)) + if err != nil { + return fmt.Errorf("unable to open %s file: %w", p.filename, err) + } + defer func() { + err = errors.Join(err, f.Close()) + }() + + // Writes header content to the file at first + p.p(f, `// Copyright 2024 The Go Language Server Authors`+"\n") + p.p(f, `// SPDX-License-Identifier: BSD-3-Clause`+"\n") + p.p(f, "\n") + p.p(f, `package protocol`+"\n") + p.p(f, "\n") + p.p(f, `import (`+"\n") + p.p(f, ` `+pkgContext+"\n\n") + p.p(f, ` `+pkgURI+"\n\n") + p.p(f, ` `+pkgJSONRPC+"\n\n") + p.p(f, `)`+"\n\n") + + if _, err := f.Write(p.buf.Bytes()); err != nil { + return fmt.Errorf("unable to write to %s file: %w", p.filename, err) + } + + return nil +} + +func normalizeMethodName(methName string) (methIdent string) { + pairs := strings.Split(methName, "/") + for _, s := range pairs { + methIdent += flect.Pascalize(s) + } + + return methIdent +} + +func normalizeDocumentation(s string) string { + if s == "." { + return "." + } + + if strings.HasPrefix(s, "@since") { + return "." + } + + s = strings.ReplaceAll(s, "\n", "\n// ") + s = strings.ReplaceAll(s, "@since", "") + s = strings.TrimRight(s, "1234567890.") + + if s[len(s)-1] != '.' { + s = s + "." + } + s = strings.ReplaceAll(s, " .", "") + + s = strings.ToLower(string(s[0])) + s[1:] + + if len(s) > 100 { + var sb strings.Builder + sc := bufio.NewScanner(strings.NewReader(s)) + sc.Split(bufio.ScanWords) + for sc.Scan() { + s := sc.Text() + " " + if s != ". " && (sb.Len()%100 == 1 || sb.Len()%200 == 1 || sb.Len()%300 == 1) { + s = "\n // " + s + } + sb.WriteString(s) + } + s = sb.String() + } + + // s = strings.ReplaceAll(s, " . ", ". ") + // s = strings.ReplaceAll(s, " , ", ", ") + // s = strings.ReplaceAll(s, " '", "'") + // s = strings.ReplaceAll(s, "' ", "'") + // s = strings.ReplaceAll(s, " - ", "-") + // s = strings.ReplaceAll(s, " x", "x") + // s = strings.ReplaceAll(s, "( ", "(") + // s = strings.ReplaceAll(s, " )", ")") + // s = strings.ReplaceAll(s, "e. g", "e.g") + + return " " + s +} + +func writeDocumentation(g Printer, typeName, docs, since string, proposed bool) { + if docs != "" { + g.PP(`// `, typeName, normalizeDocumentation(docs)) + } + if since != "" && !strings.Contains(docs, "since") { + if docs != "" { + g.PP(`//`) + } + g.P(`// @since `, docs) + if proposed { + g.P(` proposed`) + } + g.P("\n") + } +} + +func normalizeLSPTypes(name string) string { + switch name { + case "LSPAny": + name = "any" + case "LSPObject": + name = "map[string]any" + case "LSPArray": + name = "[]any" + default: + name = flect.Pascalize(name) + } + return name +} + +func normalizeHasLSPTypes(name string) (string, bool) { + isLSPType := false + switch name { + case "LSPAny": + name = "any" + isLSPType = true + case "LSPObject": + name = "map[string]any" + isLSPType = true + case "LSPArray": + name = "[]any" + isLSPType = true + } + return name, isLSPType +} + +func isNull(tt ...protocol.Type) bool { + for _, t := range tt { + if _, ok := t.(*protocol.NullType); ok { + return true + } + } + return false +} diff --git a/tools/protocol-gen/generator/generics_types.go b/tools/protocol-gen/generator/generics_types.go new file mode 100644 index 00000000..9fdcdfdc --- /dev/null +++ b/tools/protocol-gen/generator/generics_types.go @@ -0,0 +1,267 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package generator + +import ( + "cmp" + "fmt" + "slices" + "strings" + + "go.lsp.dev/protocol/tools/protocol-gen/protocol" +) + +// GenericsTypes generates Generics Go type from the metaModel schema definition. +func (gen *Generator) GenericsTypes() error { + g := NewPrinter("types_generics") + + sorted := make([]genericsType, len(gen.genericsTypes)) + i := 0 + for generics := range gen.genericsTypes { + sorted[i] = generics + i++ + } + slices.SortFunc(sorted, func(a, b genericsType) int { + return cmp.Compare(a.Name, b.Name) + }) + + for _, generics := range sorted { + types := gen.genericsTypes[generics] + + // write Documentation + if generics.Documentation != "" { + g.PP(`// `, generics.Name, normalizeDocumentation(generics.Documentation)) + } + if generics.Since != "" { + if generics.Documentation != "" { + g.PP(`//`) + } + g.P(`// @since `, strings.ReplaceAll(generics.Since, "\n", " ")) + if generics.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + + g.PP(`type `, generics.Name, ` struct {`) + g.PP(` Value any `, "`json:\"value\"`") + g.PP(`}`) + + g.P("\n") + + g.P(`func New`, generics.Name) + g.P(`[T `) + var typs []string + seem := map[string]bool{} + for i, gt := range types { + switch gt := gt.(type) { + case protocol.BaseType: + t := gt.String() + if !seem[t] { + seem[t] = true + typs = append(typs, t) + g.P(t) + } + + case *protocol.NullType: + // nothing to do + + case *protocol.ReferenceType: + t := normalizeLSPTypes(strings.ReplaceAll(gt.String(), "Uri", "URI")) + if !seem[t] { + seem[t] = true + typs = append(typs, t) + g.P(t) + } + + case *protocol.ArrayType: + elem := gt.Element + switch elem := elem.(type) { + case protocol.BaseType: + t := `[]` + elem.String() + if !seem[t] { + seem[t] = true + typs = append(typs, t) + g.P(t) + } + case *protocol.ReferenceType: + t := `[]` + normalizeLSPTypes(elem.String()) + if !seem[t] { + seem[t] = true + typs = append(typs, t) + g.P(t) + } + default: + panic(fmt.Sprintf("GenericsTypes.Array: %#v\n", elem)) + } + + case *protocol.TupleType: + for _, item := range gt.Items { + switch item := item.(type) { + case protocol.BaseType: + name := item.String() + if !seem[name] { + seem[name] = true + t := name + typs = append(typs, t) + g.P(t) + } + default: + panic(fmt.Sprintf("GenericsTypes.TupleType: %[1]T = %#[1]v\n", item)) + } + } + + default: + panic(fmt.Sprintf("GenericsTypes: %[1]T = %#[1]v\n", gt)) + } + + if i < len(types)-1 && !isNull(types[i+1]) { + g.P(` | `) + } + } + g.PP(`](x T) `, generics.Name, ` {`) + g.PP(` return `, generics.Name, `{`) + g.PP(` Value: x,`) + g.PP(` }`) + g.PP(`}`, "\n") + + g.PP(`func (t `, generics.Name, `) MarshalJSON() ([]byte, error) {`) + g.PP(` switch x := t.Value.(type) {`) + for _, gt := range types { + switch gt := gt.(type) { + case protocol.BaseType: + g.PP(` case `, gt.String(), `:`) + g.PP(` return marshal(x)`) + + case *protocol.NullType: + // nothing to do + + case *protocol.ReferenceType: + g.PP(` case `, normalizeLSPTypes(strings.ReplaceAll(gt.String(), "Uri", "URI")), `:`) + g.PP(` return marshal(x)`) + + case *protocol.ArrayType: + elem := gt.Element + switch elem := elem.(type) { + case protocol.BaseType: + g.PP(` case `, `[]`+elem.String(), `:`) + case *protocol.ReferenceType: + g.PP(` case `, `[]`+normalizeLSPTypes(elem.String()), `:`) + default: + panic(fmt.Sprintf("GenericsTypes.Array: %#v\n", elem)) + } + g.PP(` return marshal(x)`) + + case *protocol.TupleType: + seem := map[string]bool{} + for i, item := range gt.Items { + switch item := item.(type) { + case protocol.BaseType: + name := item.String() + if !seem[name] { + g.PP(` case `, name, `:`) + seem[name] = true + continue + } + default: + panic(fmt.Sprintf("GenericsTypes.TupleType: %[1]T = %#[1]v\n", item)) + } + if i < len(gt.Items) { + g.PP(` return marshal(x)`) + } + } + + default: + panic(fmt.Sprintf("GenericsTypes: %[1]T = %#[1]v\n", gt)) + } + } + g.PP(` case nil:`) + g.PP(` return []byte("null"), nil`) + g.PP(` }`) + g.PP(` return nil, fmt.Errorf("unknown type: %T", t)`) + g.PP(`}`) + + g.PP(`func (t *`, generics.Name, `) UnmarshalJSON(x []byte) error {`) + g.PP(`if string(x) == "null" {`) + g.PP(` t.Value = nil`) + g.PP(` return nil`) + g.PP(`}`) + + for i, gt := range types { + switch gt := gt.(type) { + case protocol.BaseType: + g.PP(`var h`, i, ` `, gt.String()) + g.PP(`if err := unmarshal(x, &h`, i, `); err == nil {`) + g.PP(` t.Value = h`, i) + g.PP(` return nil`) + g.PP(`}`) + + case *protocol.NullType: + // nothing to do + + case *protocol.ReferenceType: + g.PP(`var h`, i, ` `, normalizeLSPTypes(strings.ReplaceAll(gt.String(), "Uri", "URI"))) + g.PP(`if err := unmarshal(x, &h`, i, `); err == nil {`) + g.PP(` t.Value = h`, i) + g.PP(` return nil`) + g.PP(`}`) + + case *protocol.ArrayType: + g.P(`var h`, i, ` `) + elem := gt.Element + switch elem := elem.(type) { + case protocol.BaseType: + g.PP(`[]` + elem.String()) + case *protocol.ReferenceType: + g.PP(`[]` + normalizeLSPTypes(elem.String())) + default: + panic(fmt.Sprintf("GenericsTypes.Array: %#v\n", elem)) + } + g.PP(`if err := unmarshal(x, &h`, i, `); err == nil {`) + g.PP(` t.Value = h`, i) + g.PP(` return nil`) + g.PP(`}`) + + case *protocol.TupleType: + seem := map[string]bool{} + for j, item := range gt.Items { + switch item := item.(type) { + case protocol.BaseType: + name := item.String() + if !seem[name] { + g.PP(`var h`, i+j, ` `, name) + seem[name] = true + } + default: + panic(fmt.Sprintf("GenericsTypes.TupleType: %[1]T = %#[1]v\n", item)) + } + if j < len(gt.Items)-1 { + g.PP(`if err := unmarshal(x, &h`, i+j, `); err == nil {`) + g.PP(` t.Value = h`, i+j) + g.PP(` return nil`) + g.PP(`}`) + } + } + + default: + panic(fmt.Sprintf("GenericsTypes: %[1]T = %#[1]v\n", gt)) + } + } + g.P(` return &UnmarshalError{"unmarshal failed to match one of [`) + for i, t := range typs { + g.P(t) + if i < len(typs)-1 { + g.P(` `) + } + } + g.PP(`]"}`) + g.PP(`}`) + } + + if err := g.WriteTo(); err != nil { + return err + } + + return nil +} diff --git a/tools/protocol-gen/generator/structure.go b/tools/protocol-gen/generator/structure.go new file mode 100644 index 00000000..ee9d4f87 --- /dev/null +++ b/tools/protocol-gen/generator/structure.go @@ -0,0 +1,659 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package generator + +import ( + "fmt" + "strings" + + "github.com/gobuffalo/flect" + + "go.lsp.dev/protocol/tools/protocol-gen/protocol" +) + +var structureNames = map[string]string{ + "TextDocumentIdentifier": "basic", + "Position": "basic", + "TextDocumentPositionParams": "basic", + "ImplementationParams": "language", + "Range": "basic", + "Location": "basic", + "TextDocumentRegistrationOptions": "lifecycle", + "ImplementationOptions": "language", + "ImplementationRegistrationOptions": "language", + "TypeDefinitionParams": "language", + "TypeDefinitionOptions": "language", + "TypeDefinitionRegistrationOptions": "language", + "WorkspaceFolder": "workspace", + "WorkspaceFoldersChangeEvent": "workspace", + "DidChangeWorkspaceFoldersParams": "workspace", + "ConfigurationItem": "workspace", + "ConfigurationParams": "workspace", + "DocumentColorParams": "language", + "Color": "language", + "ColorInformation": "language", + "DocumentColorOptions": "language", + "DocumentColorRegistrationOptions": "language", + "ColorPresentationParams": "language", + "TextEdit": "basic", + "ColorPresentation": "language", + "WorkDoneProgressOptions": "basic", + "FoldingRangeParams": "language", + "FoldingRange": "language", + "FoldingRangeOptions": "language", + "FoldingRangeRegistrationOptions": "language", + "DeclarationParams": "language", + "DeclarationOptions": "language", + "DeclarationRegistrationOptions": "language", + "SelectionRangeParams": "language", + "SelectionRange": "language", + "SelectionRangeOptions": "language", + "SelectionRangeRegistrationOptions": "language", + "WorkDoneProgressCreateParams": "window", + "WorkDoneProgressCancelParams": "window", + "CallHierarchyPrepareParams": "language", + "CallHierarchyItem": "language", + "CallHierarchyOptions": "language", + "CallHierarchyRegistrationOptions": "language", + "CallHierarchyIncomingCallsParams": "language", + "CallHierarchyIncomingCall": "language", + "CallHierarchyOutgoingCallsParams": "language", + "CallHierarchyOutgoingCall": "language", + "SemanticTokensParams": "language", + "SemanticTokens": "language", + "SemanticTokensPartialResult": "language", + "SemanticTokensLegend": "language", + "SemanticTokensFullDelta": "language", + "SemanticTokensOptions": "language", + "SemanticTokensRegistrationOptions": "language", + "SemanticTokensDeltaParams": "language", + "SemanticTokensEdit": "language", + "SemanticTokensDelta": "language", + "SemanticTokensDeltaPartialResult": "language", + "SemanticTokensRangeParams": "language", + "ShowDocumentParams": "window", + "ShowDocumentResult": "window", + "LinkedEditingRangeParams": "language", + "LinkedEditingRanges": "language", + "LinkedEditingRangeOptions": "language", + "LinkedEditingRangeRegistrationOptions": "language", + "FileCreate": "workspace", + "CreateFilesParams": "workspace", + "ResourceOperation": "workspace", + "DeleteFileOptions": "workspace", + "DeleteFile": "workspace", + "RenameFileOptions": "workspace", + "RenameFile": "workspace", + "CreateFileOptions": "workspace", + "CreateFile": "workspace", + "OptionalVersionedTextDocumentIdentifier": "basic", + "AnnotatedTextEdit": "basic", + "TextDocumentEdit": "basic", + "ChangeAnnotation": "basic", + "WorkspaceEdit": "basic", + "FileOperationPatternOptions": "workspace", + "FileOperationPattern": "workspace", + "FileOperationFilter": "workspace", + "FileOperationRegistrationOptions": "workspace", + "FileRename": "workspace", + "RenameFilesParams": "workspace", + "FileDelete": "workspace", + "DeleteFilesParams": "workspace", + "MonikerParams": "language", + "Moniker": "language", + "MonikerOptions": "language", + "MonikerRegistrationOptions": "language", + "TypeHierarchyPrepareParams": "language", + "TypeHierarchyItem": "language", + "TypeHierarchyOptions": "language", + "TypeHierarchyRegistrationOptions": "language", + "TypeHierarchySupertypesParams": "language", + "TypeHierarchySubtypesParams": "language", + "InlineValueContext": "language", + "InlineValueParams": "language", + "InlineValueOptions": "language", + "InlineValueRegistrationOptions": "language", + "InlayHintParams": "language", + "MarkupContent": "basic", + "Command": "basic", + "InlayHintLabelPart": "language", + "InlayHint": "language", + "InlayHintOptions": "language", + "InlayHintRegistrationOptions": "language", + "DocumentDiagnosticParams": "language", + "UnchangedDocumentDiagnosticReport": "language", + "CodeDescription": "basic", + "DiagnosticRelatedInformation": "basic", + "Diagnostic": "basic", + "FullDocumentDiagnosticReport": "language", + "DocumentDiagnosticReportPartialResult": "language", + "DiagnosticServerCancellationData": "language", + "DiagnosticOptions": "language", + "DiagnosticRegistrationOptions": "language", + "PreviousResultID": "language", + "WorkspaceDiagnosticParams": "language", + "WorkspaceDiagnosticReport": "language", + "WorkspaceDiagnosticReportPartialResult": "language", + "ExecutionSummary": "document", + "NotebookCell": "document", + "NotebookDocument": "document", + "TextDocumentItem": "basic", + "DidOpenNotebookDocumentParams": "document", + "NotebookCellLanguage": "document", + "NotebookDocumentFilterWithCells": "document", + "NotebookDocumentFilterWithNotebook": "document", + "NotebookDocumentSyncOptions": "document", + "NotebookDocumentSyncRegistrationOptions": "document", + "VersionedNotebookDocumentIdentifier": "document", + "NotebookCellArrayChange": "document", + "NotebookDocumentCellChangeStructure": "document", + "VersionedTextDocumentIdentifier": "basic", + "NotebookDocumentCellContentChanges": "document", + "NotebookDocumentCellChanges": "document", + "NotebookDocumentChangeEvent": "document", + "DidChangeNotebookDocumentParams": "document", + "NotebookDocumentIdentifier": "document", + "DidSaveNotebookDocumentParams": "document", + "DidCloseNotebookDocumentParams": "document", + "SelectedCompletionInfo": "language", + "InlineCompletionContext": "language", + "InlineCompletionParams": "language", + "StringValue": "basic", + "InlineCompletionItem": "language", + "InlineCompletionList": "language", + "InlineCompletionOptions": "language", + "InlineCompletionRegistrationOptions": "language", + "Registration": "lifecycle", + "RegistrationParams": "lifecycle", + "Unregistration": "lifecycle", + "UnregistrationParams": "lifecycle", + "ClientInfo": "lifecycle", + "ChangeAnnotationsSupportOptions": "basic", + "WorkspaceEditClientCapabilities": "basic", + "DidChangeConfigurationClientCapabilities": "workspace", + "DidChangeWatchedFilesClientCapabilities": "workspace", + "ClientSymbolKindOptions": "workspace", + "ClientSymbolTagOptions": "workspace", + "ClientSymbolResolveOptions": "workspace", + "WorkspaceSymbolClientCapabilities": "workspace", + "ExecuteCommandClientCapabilities": "workspace", + "SemanticTokensWorkspaceClientCapabilities": "lifecycle", + "CodeLensWorkspaceClientCapabilities": "lifecycle", + "FileOperationClientCapabilities": "lifecycle", + "InlineValueWorkspaceClientCapabilities": "lifecycle", + "InlayHintWorkspaceClientCapabilities": "lifecycle", + "DiagnosticWorkspaceClientCapabilities": "lifecycle", + "FoldingRangeWorkspaceClientCapabilities": "lifecycle", + "WorkspaceClientCapabilities": "lifecycle", + "TextDocumentSyncClientCapabilities": "lifecycle", + "CompletionItemTagOptions": "lifecycle", + "ClientCompletionItemResolveOptions": "lifecycle", + "ClientCompletionItemInsertTextModeOptions": "lifecycle", + "ClientCompletionItemOptions": "lifecycle", + "ClientCompletionItemOptionsKind": "lifecycle", + "CompletionListCapabilities": "lifecycle", + "CompletionClientCapabilities": "lifecycle", + "HoverClientCapabilities": "lifecycle", + "ClientSignatureParameterInformationOptions": "lifecycle", + "ClientSignatureInformationOptions": "lifecycle", + "SignatureHelpClientCapabilities": "lifecycle", + "DeclarationClientCapabilities": "lifecycle", + "DefinitionClientCapabilities": "lifecycle", + "TypeDefinitionClientCapabilities": "lifecycle", + "ImplementationClientCapabilities": "lifecycle", + "ReferenceClientCapabilities": "lifecycle", + "DocumentHighlightClientCapabilities": "lifecycle", + "DocumentSymbolClientCapabilities": "lifecycle", + "ClientCodeActionKindOptions": "lifecycle", + "ClientCodeActionLiteralOptions": "lifecycle", + "ClientCodeActionResolveOptions": "lifecycle", + "CodeActionClientCapabilities": "lifecycle", + "CodeLensClientCapabilities": "lifecycle", + "DocumentLinkClientCapabilities": "lifecycle", + "DocumentColorClientCapabilities": "lifecycle", + "DocumentFormattingClientCapabilities": "lifecycle", + "DocumentRangeFormattingClientCapabilities": "lifecycle", + "DocumentOnTypeFormattingClientCapabilities": "lifecycle", + "RenameClientCapabilities": "lifecycle", + "ClientFoldingRangeKindOptions": "lifecycle", + "ClientFoldingRangeOptions": "lifecycle", + "FoldingRangeClientCapabilities": "lifecycle", + "SelectionRangeClientCapabilities": "lifecycle", + "ClientDiagnosticsTagOptions": "lifecycle", + "PublishDiagnosticsClientCapabilities": "lifecycle", + "CallHierarchyClientCapabilities": "lifecycle", + "ClientSemanticTokensRequestFullDelta": "lifecycle", + "ClientSemanticTokensRequestOptions": "lifecycle", + "SemanticTokensClientCapabilities": "lifecycle", + "LinkedEditingRangeClientCapabilities": "lifecycle", + "MonikerClientCapabilities": "lifecycle", + "TypeHierarchyClientCapabilities": "lifecycle", + "InlineValueClientCapabilities": "lifecycle", + "ClientInlayHintResolveOptions": "lifecycle", + "InlayHintClientCapabilities": "lifecycle", + "DiagnosticClientCapabilities": "lifecycle", + "InlineCompletionClientCapabilities": "lifecycle", + "TextDocumentClientCapabilities": "lifecycle", + "NotebookDocumentSyncClientCapabilities": "lifecycle", + "NotebookDocumentClientCapabilities": "lifecycle", + "ClientShowMessageActionItemOptions": "lifecycle", + "ShowMessageRequestClientCapabilities": "lifecycle", + "ShowDocumentClientCapabilities": "lifecycle", + "WindowClientCapabilities": "lifecycle", + "StaleRequestSupportOptions": "lifecycle", + "RegularExpressionsClientCapabilities": "lifecycle", + "MarkdownClientCapabilities": "lifecycle", + "GeneralClientCapabilities": "lifecycle", + "ClientCapabilities": "lifecycle", + "InitializeParamsBase": "lifecycle", + "WorkspaceFoldersInitializeParams": "lifecycle", + "InitializeParams": "lifecycle", + "SaveOptions": "document", + "TextDocumentSyncOptions": "document", + "ServerCompletionItemOptions": "language", + "CompletionOptions": "language", + "HoverOptions": "language", + "SignatureHelpOptions": "language", + "DefinitionOptions": "language", + "ReferenceOptions": "language", + "DocumentHighlightOptions": "language", + "DocumentSymbolOptions": "language", + "CodeActionKindDocumentation": "language", + "CodeActionOptions": "language", + "CodeLensOptions": "language", + "DocumentLinkOptions": "language", + "WorkspaceSymbolOptions": "language", + "DocumentFormattingOptions": "language", + "DocumentRangeFormattingOptions": "language", + "DocumentOnTypeFormattingOptions": "language", + "RenameOptions": "language", + "ExecuteCommandOptions": "language", + "WorkspaceFoldersServerCapabilities": "workspace", + "FileOperationOptions": "lifecycle", + "WorkspaceOptions": "lifecycle", + "ServerCapabilities": "lifecycle", + "ServerInfo": "lifecycle", + "InitializeResult": "lifecycle", + "InitializeError": "lifecycle", + "InitializedParams": "lifecycle", + "DidChangeConfigurationParams": "workspace", + "DidChangeConfigurationRegistrationOptions": "workspace", + "ShowMessageParams": "window", + "MessageActionItem": "window", + "ShowMessageRequestParams": "window", + "LogMessageParams": "window", + "DidOpenTextDocumentParams": "document", + "DidChangeTextDocumentParams": "document", + "TextDocumentChangeRegistrationOptions": "document", + "DidCloseTextDocumentParams": "document", + "DidSaveTextDocumentParams": "document", + "TextDocumentSaveRegistrationOptions": "document", + "WillSaveTextDocumentParams": "document", + "FileEvent": "workspace", + "DidChangeWatchedFilesParams": "workspace", + "FileSystemWatcher": "workspace", + "DidChangeWatchedFilesRegistrationOptions": "workspace", + "PublishDiagnosticsParams": "language", + "CompletionContext": "language", + "CompletionParams": "language", + "CompletionItemLabelDetails": "language", + "InsertReplaceEdit": "language", + "CompletionItem": "language", + "EditRangeWithInsertReplace": "language", + "CompletionItemDefaults": "language", + "CompletionList": "language", + "CompletionRegistrationOptions": "language", + "HoverParams": "language", + "Hover": "language", + "HoverRegistrationOptions": "language", + "ParameterInformation": "language", + "SignatureInformation": "language", + "SignatureHelp": "language", + "SignatureHelpContext": "language", + "SignatureHelpParams": "language", + "SignatureHelpRegistrationOptions": "language", + "DefinitionParams": "language", + "DefinitionRegistrationOptions": "language", + "ReferenceContext": "language", + "ReferenceParams": "language", + "ReferenceRegistrationOptions": "language", + "DocumentHighlightParams": "language", + "DocumentHighlight": "language", + "DocumentHighlightRegistrationOptions": "language", + "DocumentSymbolParams": "language", + "BaseSymbolInformation": "language", + "SymbolInformation": "language", + "DocumentSymbol": "language", + "DocumentSymbolRegistrationOptions": "language", + "CodeActionContext": "language", + "CodeActionParams": "language", + "CodeActionDisabled": "language", + "CodeAction": "language", + "CodeActionRegistrationOptions": "language", + "WorkspaceSymbolParams": "workspace", + "LocationURIOnly": "language", + "WorkspaceSymbol": "workspace", + "WorkspaceSymbolRegistrationOptions": "workspace", + "CodeLensParams": "language", + "CodeLens": "language", + "CodeLensRegistrationOptions": "language", + "DocumentLinkParams": "language", + "DocumentLink": "language", + "DocumentLinkRegistrationOptions": "language", + "FormattingOptions": "language", + "DocumentFormattingParams": "language", + "DocumentFormattingRegistrationOptions": "language", + "DocumentRangeFormattingParams": "language", + "DocumentRangeFormattingRegistrationOptions": "language", + "DocumentRangesFormattingParams": "language", + "DocumentOnTypeFormattingParams": "language", + "DocumentOnTypeFormattingRegistrationOptions": "language", + "RenameParams": "language", + "RenameRegistrationOptions": "language", + "PrepareRenameParams": "language", + "ExecuteCommandParams": "language", + "ExecuteCommandRegistrationOptions": "language", + "ApplyWorkspaceEditParams": "workspace", + "ApplyWorkspaceEditResult": "workspace", + "WorkDoneProgressBegin": "basic", + "WorkDoneProgressReport": "basic", + "WorkDoneProgressEnd": "basic", + "SetTraceParams": "lifecycle", + "LogTraceParams": "lifecycle", + "CancelParams": "base", + "ProgressParams": "base", + "WorkDoneProgressParams": "basic", + "PartialResultParams": "basic", + "LocationLink": "basic", + "StaticRegistrationOptions": "lifecycle", + "InlineValueText": "language", + "InlineValueVariableLookup": "language", + "InlineValueEvaluatableExpression": "language", + "RelatedFullDocumentDiagnosticReport": "language", + "RelatedUnchangedDocumentDiagnosticReport": "language", + "PrepareRenamePlaceholder": "language", + "PrepareRenameDefaultBehavior": "language", + "WorkspaceFullDocumentDiagnosticReport": "language", + "WorkspaceUnchangedDocumentDiagnosticReport": "language", + "TextDocumentContentChangePartial": "language", + "TextDocumentContentChangeWholeDocument": "language", + "MarkedStringWithLanguage": "language", + "NotebookCellTextDocumentFilter": "language", + "RelativePattern": "workspace", + "TextDocumentFilterLanguage": "language", + "TextDocumentFilterScheme": "language", + "TextDocumentFilterPattern": "language", + "NotebookDocumentFilterNotebookType": "document", + "NotebookDocumentFilterScheme": "document", + "NotebookDocumentFilterPattern": "document", +} + +// Structures generates Structure Go type from the metaModel schema definition. +func (gen *Generator) Structures(structures []*protocol.Structure) error { + for _, structure := range structures { + structuresName := flect.Pascalize(structure.Name) + + filename, ok := structureNames[structuresName] + if !ok { + panic(fmt.Sprintf("not found %s enumerations file", structuresName)) + } + + // Init structures printers + g := NewPrinter(filename) + gen.structures = append(gen.structures, g) + + if structure.Documentation != "" { + g.PP(`// `, structuresName, normalizeDocumentation(structure.Documentation)) + } + if structure.Since != "" { + if structure.Documentation != "" { + g.PP(`//`) + } + g.P(`// @since `, structure.Since) + if structure.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + + g.PP(`type `, structuresName, ` struct {`) + + var needNewline bool + if len(structure.Extends) > 0 { + g.PP(` // extends`) + for i, extend := range structure.Extends { + switch extend := extend.(type) { + case *protocol.ReferenceType: + g.PP(` `, normalizeLSPTypes(extend.Name)) + default: + fmt.Printf("mixin[%d]: %#[2]v %[2]T\n", i, extend) + } + if ns := extend.SubTypes(); ns != nil { + for i, n := range ns { + switch n := n.(type) { + default: + fmt.Printf("extend[%d]: %#[2]v %[2]T\n", i, n) + } + g.PP(` `, n) + } + } + } + needNewline = true + } + + if len(structure.Mixins) > 0 { + g.PP(` // mixins`) + for i, mixin := range structure.Mixins { + switch mixin := mixin.(type) { + case *protocol.ReferenceType: + g.PP(` `, normalizeLSPTypes(mixin.Name)) + default: + fmt.Printf("mixin[%d]: %#[2]v %[2]T\n", i, mixin) + } + if ns := mixin.SubTypes(); ns != nil { + for i, n := range ns { + switch n := n.(type) { + default: + fmt.Printf("mixin.SubTypes[%d]: %#[2]v %[2]T\n", i, n) + } + g.PP(` `, n) + } + } + } + needNewline = true + } + + if len(structure.Properties) > 0 { + if needNewline { + g.P("\n") + } + + for i, prop := range structure.Properties { + propName := flect.Pascalize(prop.Name) + + // write Documentation + if prop.Documentation != "" { + g.PP(` // `, propName, normalizeDocumentation(prop.Documentation)) + } + if structure.Since != "" { + if prop.Documentation != "" && !strings.Contains(prop.Documentation, "since") { + g.PP(` //`) + } + g.P(` // @since `, structure.Since) + if structure.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + + g.P(` `, propName) + + propType := prop.Type + switch node := propType.(type) { + case protocol.BaseType: + g.P(` `, node.String()) + + case *protocol.ReferenceType: + g.P(` `) + gen.renderStructuresReferenceType(g, prop, node) + + case *protocol.ArrayType: + genericsType := genericsType{ + Name: structuresName + propName, + Documentation: prop.Documentation, + Since: structure.Since, + Proposed: structure.Proposed, + } + g.P(` `) + gen.renderStructuresArrayTypeGeneric(g, node, genericsType) + + case *protocol.MapType: + genericsType := genericsType{ + Name: structuresName + propName, + Documentation: prop.Documentation, + Since: structure.Since, + Proposed: structure.Proposed, + } + gen.renderStructuresMapType(g, node, genericsType) + + case *protocol.OrType: + switch { + case len(node.Items) == 2 && (isNull(node.Items[0], node.Items[1])): + prop.Optional = true + for _, item := range node.Items { + if !isNull(item) { + switch item := item.(type) { + case protocol.BaseType: + g.P(` `, item.String()) + case *protocol.ReferenceType: + g.P(` `) + gen.renderStructuresReferenceType(g, prop, item) + case *protocol.ArrayType: + g.P(` `) + gen.renderStructuresArrayType(g, item) + default: + panic(fmt.Sprintf("structures.OrType: %#v\n", item)) + } + } + } + default: + if isNull(node.Items...) { + prop.Optional = true + } + genericsType := genericsType{ + Name: structuresName + propName, + Documentation: prop.Documentation, + Since: structure.Since, + Proposed: structure.Proposed, + } + gen.renderStructuresOrType(g, node, genericsType) + } + + default: + // *protocol.AndType and *protocol.TupleType are nothing to do in structures + panic(fmt.Sprintf("structures: %#v\n", node)) + } + + g.P(" `json:\"", prop.JSONName) + if prop.Optional { + g.P(`,omitempty`) + } + g.PP("\"`") + + // Add newline per fields + if i < len(structure.Properties)-1 { + g.P("\n") + } + } + } + g.PP(`}`) + g.P("\n") + } + + return nil +} + +func (gen *Generator) renderStructuresReferenceType(g Printer, prop *protocol.Property, ref *protocol.ReferenceType) { + name := ref.String() + + // don't use normalizeLSPTypes for the avoid pointer to `map[string]any` and `[]any` + switch name { + case `LSPAny`: + name = `any` + case `LSPObject`: + name = `map[string]any` + case `LSPArray`: + name = `[]any` + default: + if _, ok := enumerationNames[ref.Name]; !ok && prop.Optional { + g.P(`*`) + } + } + + g.P(name) +} + +func (gen *Generator) renderStructuresArrayType(g Printer, array *protocol.ArrayType) { + elem := array.Element + switch elem := elem.(type) { + case *protocol.ReferenceType: + g.P(`[]` + normalizeLSPTypes(elem.String())) + + default: + panic(fmt.Sprintf("structures.ArrayKind: %#v\n", elem)) + } +} + +func (gen *Generator) renderStructuresArrayTypeGeneric(g Printer, array *protocol.ArrayType, genericsType genericsType) { + elem := array.Element + switch elem := elem.(type) { + case protocol.BaseType: + g.P(`[]` + elem.String()) + + case *protocol.ReferenceType: + g.P(`[]` + normalizeLSPTypes(elem.String())) + + case *protocol.OrType: + gen.renderStructuresOrType(g, elem, genericsType) + + default: + panic(fmt.Sprintf("structures.ArrayKind: %#v\n", elem)) + } +} + +func (gen *Generator) renderStructuresMapType(g Printer, m *protocol.MapType, genericsType genericsType) { + g.P(` map`) + + // write map key + switch key := m.Key.(type) { + case *protocol.DocumentUriType: + g.P(`[`, key.String(), `]`) + + case *protocol.ReferenceType: + g.P(`[`, normalizeLSPTypes(key.String()), `]`) + + default: + panic(fmt.Sprintf("structures.MapType.Key: %[1]T = %#[1]v\n", m.Key)) + } + + // write map value + switch val := m.Value.(type) { + case *protocol.ReferenceType: + g.P(normalizeLSPTypes(val.String())) + + case *protocol.ArrayType: + gen.renderStructuresArrayTypeGeneric(g, val, genericsType) + + case *protocol.OrType: + gen.renderStructuresOrType(g, val, genericsType) + + default: + panic(fmt.Sprintf("structures.MapType.Value: %[1]T = %#[1]v\n", m.Value)) + } +} + +func (gen *Generator) renderStructuresOrType(g Printer, or *protocol.OrType, genericsType genericsType) { + g.P(` `, genericsType.Name) + gen.genericsTypes[genericsType] = or.Items +} diff --git a/tools/protocol-gen/generator/typealiases.go b/tools/protocol-gen/generator/typealiases.go new file mode 100644 index 00000000..e087ae65 --- /dev/null +++ b/tools/protocol-gen/generator/typealiases.go @@ -0,0 +1,212 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package generator + +import ( + "fmt" + + "github.com/gobuffalo/flect" + + "go.lsp.dev/protocol/tools/protocol-gen/protocol" +) + +var typeAliasNames = [...]string{ + "typealias", +} + +// TypeAliases generates TypeAliases Go type from the metaModel schema definition. +func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { + // Init typeAliases printers + g := NewPrinter("typealias") + gen.typeAliases = append(gen.typeAliases, g) + + for _, alias := range typeAliases { + switch alias.Name { + case "LSPAny", "LSPObject", "LSPArray": + continue + } + + aliasName := flect.Pascalize(alias.Name) + gen.generics[aliasName] = true + + // write documentation + if alias.Documentation != "" { + g.PP(`// `, aliasName, normalizeDocumentation(alias.Documentation)) + } + if alias.Since != "" { + if alias.Documentation != "" { + g.PP(`//`) + } + g.P(`// @since `, alias.Since) + if alias.Proposed { + g.P(` proposed`) + } + g.P("\n") + } + + switch a := alias.Type.(type) { + case protocol.BaseType: + g.PP(`type `, aliasName, ` `, a.String()) + + case *protocol.ReferenceType: + g.PP(`type `, aliasName, ` `, normalizeLSPTypes(a.Name)) + + case *protocol.ArrayType: + g.P(`type `, aliasName, ` `) + elem := a.Element + switch elem := elem.(type) { + case *protocol.ReferenceType: + g.PP(`[]` + normalizeLSPTypes(elem.String())) + default: + panic(fmt.Sprintf("typealias: %T\n", elem)) + } + + case *protocol.MapType: + g.P(`type `, aliasName, ` `, `map`) + switch key := a.Key.(type) { + case protocol.BaseType: + g.P(`[`, key.String(), `]`) + default: + panic(fmt.Sprintf("structures.MapType.Key: %[1]T = %#[1]v\n", a.Key)) + } + switch a.Value.(type) { + case *protocol.OrType: + g.PP(aliasName) + default: + panic(fmt.Sprintf("typealias.MapType.Value: %[1]T = %#[1]v\n", a.Value)) + } + + case *protocol.OrType: + g.PP(`type `, aliasName, ` struct {`) + g.PP(` Value any `, "`json:\"value\"`") + g.PP(`}`) + } + + g.P("\n") + + seem := map[string]bool{} + switch a := alias.Type.(type) { + case *protocol.OrType: + g.P(`func New`, aliasName) + g.P(`[T `) + for i, item := range a.Items { + switch item := item.(type) { + case protocol.BaseType: + t := item.String() + if !seem[t] { + seem[t] = true + g.P(t) + } + case *protocol.ReferenceType: + t := normalizeLSPTypes(item.String()) + if !seem[t] { + seem[t] = true + g.P(t) + } + case *protocol.ArrayType: + elem := item.Element + switch elem := elem.(type) { + case protocol.BaseType: + t := `[]` + elem.String() + if !seem[t] { + seem[t] = true + g.P(t) + } + case *protocol.ReferenceType: + t := `[]` + normalizeLSPTypes(elem.String()) + if !seem[t] { + seem[t] = true + g.P(t) + } + default: + panic(fmt.Sprintf("GenericsTypes.Array: %#v\n", elem)) + } + default: + panic(fmt.Sprintf("typealias.OrType: %#v\n", item)) + } + + if i < len(a.Items)-1 { + g.P(` | `) + } + } + g.PP(`](x T) `, aliasName, ` {`) + g.PP(` return `, aliasName, `{`) + g.PP(` Value: x,`) + g.PP(` }`) + g.PP(`}`, "\n") + } + + switch a := alias.Type.(type) { + case *protocol.OrType: + g.PP(`func (t `, aliasName, `) MarshalJSON() ([]byte, error) {`) + g.PP(` switch x := t.Value.(type) {`) + for i, item := range a.Items { + switch item := item.(type) { + case protocol.BaseType: + g.PP(` case `, item.String(), `:`) + case *protocol.ArrayType: + elem := item.Element + switch elem := elem.(type) { + case *protocol.ReferenceType: + g.PP(` case `, `[]`+normalizeLSPTypes(elem.String()), `:`) + default: + panic(fmt.Sprintf("GenericsTypes.Array: %#v\n", elem)) + } + case *protocol.ReferenceType: + g.PP(` case `, normalizeLSPTypes(item.String()), `:`) + default: + panic(fmt.Sprintf("typealias.OrType: %#v\n", item)) + } + if i <= len(a.Items)-1 { + g.PP(` return marshal(x)`) + } + } + g.PP(` case nil:`) + g.PP(` return []byte("null"), nil`) + g.PP(` }`) + g.PP(` return nil, fmt.Errorf("unkonwn type: %T", t)`) + g.PP(`}`) + } + + switch a := alias.Type.(type) { + case *protocol.OrType: + g.PP(`func (t *`, aliasName, `) UnmarshalJSON(x []byte) error {`) + g.PP(`if string(x) == "null" {`) + g.PP(` t.Value = nil`) + g.PP(` return nil`) + g.PP(`}`) + for i, item := range a.Items { + g.P(`var h`, i, ` `) + switch item := item.(type) { + case protocol.BaseType: + g.PP(item.String()) + case *protocol.ArrayType: + elem := item.Element + switch elem := elem.(type) { + case *protocol.ReferenceType: + g.PP(`[]` + normalizeLSPTypes(elem.String())) + default: + panic(fmt.Sprintf("GenericsTypes.Array: %#v\n", elem)) + } + case *protocol.ReferenceType: + g.PP(normalizeLSPTypes(item.String())) + default: + panic(fmt.Sprintf("typealias.OrType: %#v\n", item)) + } + g.PP(`if err := unmarshal(x, &h`, i, `); err == nil {`) + g.PP(` t.Value = h`, i) + g.PP(` return nil`) + g.PP(`}`) + } + g.PP(` return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)}`) + g.PP(`}`) + } + } + + if err := g.WriteTo(); err != nil { + return err + } + + return nil +} diff --git a/tools/protocol-gen/go.mod b/tools/protocol-gen/go.mod new file mode 100644 index 00000000..1832413f --- /dev/null +++ b/tools/protocol-gen/go.mod @@ -0,0 +1,9 @@ +module go.lsp.dev/protocol/tools/protocol-gen + +go 1.22.2 + +require ( + github.com/davecgh/go-spew v1.1.1 + github.com/gobuffalo/flect v1.0.2 + golang.org/x/text v0.14.0 +) diff --git a/tools/protocol-gen/go.sum b/tools/protocol-gen/go.sum new file mode 100644 index 00000000..a855e77a --- /dev/null +++ b/tools/protocol-gen/go.sum @@ -0,0 +1,20 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= +github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tools/protocol-gen/main.go b/tools/protocol-gen/main.go new file mode 100644 index 00000000..5f81b18e --- /dev/null +++ b/tools/protocol-gen/main.go @@ -0,0 +1,154 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package main + +import ( + "bytes" + "context" + "errors" + "fmt" + "io" + "net/http" + "os" + "strings" + + "github.com/davecgh/go-spew/spew" + + "go.lsp.dev/protocol/tools/protocol-gen/generator" + "go.lsp.dev/protocol/tools/protocol-gen/resolver" + "go.lsp.dev/protocol/tools/protocol-gen/schema" +) + +const ( + lspVersion = "3.17" + LSPSchemaURI = "https://github.com/microsoft/lsprotocol/raw/%s/generator/lsp.json" + schemaVersion = "2024.0.0a1" +) + +func init() { + spew.Config = spew.ConfigState{ + Indent: " ", + ContinueOnMethod: true, + SortKeys: true, + } +} + +func main() { + if err := run(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} + +func run() error { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + data, err := fetchLSPSchema(ctx) + if err != nil { + return err + } + + model, err := schema.Decode(bytes.NewReader(data)) + if err != nil { + return err + } + + protocol, err := resolver.Resolve(model) + if err != nil { + return err + } + + g := &generator.Generator{} + g.Init() + if err := g.TypeAliases(protocol.TypeAliases); err != nil { + return fmt.Errorf("unable to generate type aliases: %w", err) + } + if err := g.Enumerations(protocol.Enumerations); err != nil { + return fmt.Errorf("unable to generate enumerations: %w", err) + } + if err := g.Structures(protocol.Structures); err != nil { + return fmt.Errorf("unable to generate structures: %w", err) + } + if err := g.ClientToServer(protocol.ServerToClientNotifications, protocol.BidirectionalNotifications, protocol.ServerToClientRequests, protocol.BidirectionalRequests); err != nil { + return fmt.Errorf("unable to generate ClientToServer: %w", err) + } + if err := g.ServerToClient(protocol.ClientToServerNotifications, protocol.BidirectionalNotifications, protocol.ClientToServerRequests, protocol.BidirectionalRequests); err != nil { + return fmt.Errorf("unable to generate ServerToClient: %w", err) + } + if err := g.GenericsTypes(); err != nil { + return fmt.Errorf("unable to generate GenericsTypes: %w", err) + } + + if err := g.WriteTo(); err != nil { + return err + } + + return nil +} + +func fetchLSPSchema(ctx context.Context) ([]byte, error) { + uri := fmt.Sprintf(LSPSchemaURI, schemaVersion) + // uri := "https://raw.githubusercontent.com/microsoft/language-server-protocol/gh-pages/_specifications/lsp/3.18/metaModel/metaModel.json" + req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, http.NoBody) + if err != nil { + return nil, fmt.Errorf("failed to create http request: %w", err) + } + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, fmt.Errorf("failed to get lsp.json http request: %w", err) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + if err != nil { + if errors.Is(err, io.EOF) { + return nil, fmt.Errorf("response body is empty: %w", err) + } + return nil, fmt.Errorf("failed to get lsp.json http request: %w", err) + } + + return b, nil +} + +func debug(model schema.MetaModel) { + sb := struct { + MetaData strings.Builder + Requests strings.Builder + Notifications strings.Builder + Structures strings.Builder + Enumerations strings.Builder + TypeAliases strings.Builder + }{} + + fmt.Fprintf(&sb.MetaData, "model.MetaData: %s\n", model.MetaData) + for i, request := range model.Requests { + fmt.Fprintf(&sb.Requests, "model.Requests[%d]: %#v\n", i, request) + } + for i, notification := range model.Notifications { + fmt.Fprintf(&sb.Notifications, "model.Notifications[%d]: %#v\n", i, notification) + } + for i, structure := range model.Structures { + fmt.Fprintf(&sb.Structures, "model.Structures[%d]: %#v\n", i, structure) + } + for i, enumeration := range model.Enumerations { + fmt.Fprintf(&sb.Enumerations, "model.Enumerations[%d]: %#v\n", i, enumeration) + } + for i, typeAliase := range model.TypeAliases { + fmt.Fprintf(&sb.TypeAliases, "model.TypeAliases[%d]: %#v\n", i, typeAliase) + } + + os.Stdout.WriteString("MetaData:\n") + os.Stdout.WriteString(sb.MetaData.String()) + os.Stdout.WriteString("\nRequests:\n") + os.Stdout.WriteString(sb.Requests.String()) + os.Stdout.WriteString("\nNotifications:\n") + os.Stdout.WriteString(sb.Notifications.String()) + os.Stdout.WriteString("\nStructures:\n") + os.Stdout.WriteString(sb.Structures.String()) + os.Stdout.WriteString("\nEnumerations:\n") + os.Stdout.WriteString(sb.Enumerations.String()) + os.Stdout.WriteString("\nTypeAliases:\n") + os.Stdout.WriteString(sb.TypeAliases.String()) +} diff --git a/tools/protocol-gen/protocol/enum.go b/tools/protocol-gen/protocol/enum.go new file mode 100644 index 00000000..b7148ba1 --- /dev/null +++ b/tools/protocol-gen/protocol/enum.go @@ -0,0 +1,54 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// Enumeration defines an enumeration. +type Enumeration struct { + // Whether the enumeration is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + + // An optional documentation. + Documentation string + + // The name of the enumeration. + Name string + + // Whether this is a proposed enumeration. If omitted, the enumeration is final. + Proposed bool + + // Since when (release number) this enumeration is available. Is empty if not known. + Since string + + // Whether the enumeration supports custom values (e.g. values which are not part of the set defined in values). If omitted no custom values are supported. + SupportsCustomValues bool + + // The type of the elements. + Type Type + + // The enum values. + Values []*EnumerationEntry +} + +func (Enumeration) isTypeDecl() {} + +// EnumerationEntry defines an enumeration entry. +type EnumerationEntry struct { + // Whether the enum entry is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + + // An optional documentation. + Documentation string + + // The name of the enum item. + Name string + + // Whether this is a proposed enumeration entry. If omitted, the enumeration entry is final. + Proposed bool + + // Since when (release number) this enumeration entry is available. Is undefined if not known. + Since string + + // The value (string or number). + Value any +} diff --git a/tools/protocol-gen/protocol/message_dir.go b/tools/protocol-gen/protocol/message_dir.go new file mode 100644 index 00000000..ca6c88e8 --- /dev/null +++ b/tools/protocol-gen/protocol/message_dir.go @@ -0,0 +1,13 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// MessageDirection indicates in which direction a message is sent in the protocol. +type MessageDirection string + +const ( + MessageDirectionClientToServer MessageDirection = "clientToServer" + MessageDirectionServerToClient MessageDirection = "serverToClient" + MessageDirectionBidirectional MessageDirection = "both" +) diff --git a/tools/protocol-gen/protocol/notification.go b/tools/protocol-gen/protocol/notification.go new file mode 100644 index 00000000..a0e5f440 --- /dev/null +++ b/tools/protocol-gen/protocol/notification.go @@ -0,0 +1,35 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// Notification represents a LSP notification. +type Notification struct { + // Whether the notification is deprecated or not. + // If deprecated the property contains the deprecation message. + Deprecated string + + // An optional documentation. + Documentation string + + // The direction in which this notification is sent in the protocol. + MessageDirection MessageDirection + + // The request's method name. + Method string + + // The parameter type(s) if any. + Params []Type + + // Whether this is a proposed notification. If omitted the notification is final. + Proposed bool + + // Optional a dynamic registration method if it different from the request's method. + RegistrationMethod string + + // Optional registration options if the notification supports dynamic registration. + RegistrationOptions Type + + // Since when (release number) this notification is available. Is undefined if not knownz. + Since string +} diff --git a/tools/protocol-gen/protocol/property.go b/tools/protocol-gen/protocol/property.go new file mode 100644 index 00000000..37b65fd2 --- /dev/null +++ b/tools/protocol-gen/protocol/property.go @@ -0,0 +1,31 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// Property represents an object property. +type Property struct { + // Whether the property is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + + // An optional documentation. + Documentation string + + // The property JSON name. + JSONName string + + // The property name. + Name string + + // Whether the property is optional. If omitted, the property is mandatory. + Optional bool + + // Whether this is a proposed property. If omitted, the structure is final. + Proposed bool + + // Since when (release number) this property is available. Is undefined if not known. + Since string + + // The type of the property. + Type Type +} diff --git a/tools/protocol-gen/protocol/protocol.go b/tools/protocol-gen/protocol/protocol.go new file mode 100644 index 00000000..6652e38d --- /dev/null +++ b/tools/protocol-gen/protocol/protocol.go @@ -0,0 +1,48 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// Protocol represents the LSP protocol. +type Protocol struct { + // The enumerations. + Enumerations []*Enumeration + + // Additional meta data. + MetaData *MetaData + + // The notifications. + Notifications []*Notification + + // The client -> server notifications. + ClientToServerNotifications []*Notification + + // The server -> client notifications. + ServerToClientNotifications []*Notification + + // The client -> server and server -> client notifications. + BidirectionalNotifications []*Notification + + // The requests. + Requests []*Request + + // The client -> server requests. + ClientToServerRequests []*Request + + // The server -> client requests. + ServerToClientRequests []*Request + + // The client -> server and server -> client requests. + BidirectionalRequests []*Request + + // The structures. + Structures []*Structure + + // The type aliases. + TypeAliases []*TypeAlias +} + +// MetaData is the protocol version. +type MetaData struct { + Version string +} diff --git a/tools/protocol-gen/protocol/request.go b/tools/protocol-gen/protocol/request.go new file mode 100644 index 00000000..8d280e50 --- /dev/null +++ b/tools/protocol-gen/protocol/request.go @@ -0,0 +1,43 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// Request represents a LSP request. +type Request struct { + // Whether the request is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + + // An optional documentation. + Documentation string + + // An optional error data type. + ErrorData Type + + // The direction in which this request is sent in the protocol. + MessageDirection MessageDirection + + // The request's method name. + Method string + + // The parameter type(s) if any. + Params []Type + + // Optional partial result type if the request supports partial result reporting. + PartialResult Type + + // Whether this is a proposed feature. If omitted the feature is final. + Proposed bool + + // Optional a dynamic registration method if it different from the request's method. + RegistrationMethod string + + // Optional registration options if the request supports dynamic registration. + RegistrationOptions Type + + // The result type. + Result Type + + // Since when (release number) this request is available. Is undefined if not known. + Since string +} diff --git a/tools/protocol-gen/protocol/structure.go b/tools/protocol-gen/protocol/structure.go new file mode 100644 index 00000000..122837de --- /dev/null +++ b/tools/protocol-gen/protocol/structure.go @@ -0,0 +1,42 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// Structure defines the structure of an object literal. +type Structure struct { + // Whether the structure is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + + // An optional documentation. + Documentation string + + // Structures extended from. This structures form a polymorphic type hierarchy. + Extends []Type + + // Structures to mix in. The properties of these structures are `copied` into this structure. Mixins don't form a polymorphic type hierarchy in LSP. + Mixins []Type + + // The name of the structure. + Name string + + // The properties. + Properties []*Property + + // Whether this is a proposed structure. If omitted, the structure is final. + Proposed bool + + // Since when (release number) this structure is available. Is undefined if not known. + Since string + + // The 'kind' property, used to identify the structure type. + Kind string + + // Child structures of this structure. + NestedStructures []*Structure + + // The list of structure names (outermost first) to get to this structure. + NestedNames []string +} + +func (Structure) isTypeDecl() {} diff --git a/tools/protocol-gen/protocol/structure_literal.go b/tools/protocol-gen/protocol/structure_literal.go new file mode 100644 index 00000000..5bc3adcb --- /dev/null +++ b/tools/protocol-gen/protocol/structure_literal.go @@ -0,0 +1,22 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// StructureLiteral defines an unnamed structure of an object literal. +type StructureLiteral struct { + // Whether the literal is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + + // An optional documentation. + Documentation string + + // The properties. + Properties []*Property + + // Whether this is a proposed structure. If omitted, the structure is final. + Proposed bool + + // Since when (release number) this structure is available. Is undefined if not known. + Since string +} diff --git a/tools/protocol-gen/protocol/type.go b/tools/protocol-gen/protocol/type.go new file mode 100644 index 00000000..23f60cfc --- /dev/null +++ b/tools/protocol-gen/protocol/type.go @@ -0,0 +1,258 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +import ( + "fmt" + "strconv" + + "github.com/gobuffalo/flect" +) + +// Type is the LSP type. +type Type interface { + fmt.Stringer + + isType() + HasSubTypes() bool + SubTypes() []Type +} + +type BaseType interface { + fmt.Stringer + + isBaseType() +} + +func RecursiveTypesOf(t Type) []Type { + stack := []Type{t} + seen := map[Type]struct{}{} + types := []Type{} + for len(stack) > 0 { + stack, t = stack[:len(stack)-1], stack[len(stack)-1] + if _, existing := seen[t]; !existing { + seen[t] = struct{}{} + types = append(types, t) + stack = append(stack, t.SubTypes()...) + } + } + return types +} + +type URIType struct{} + +var ( + _ Type = URIType{} + _ BaseType = URIType{} +) + +func (URIType) isType() {} +func (URIType) HasSubTypes() bool { return false } +func (URIType) SubTypes() []Type { return nil } +func (t URIType) String() string { return "uri.URI" } +func (URIType) isBaseType() {} + +type DocumentUriType struct{} + +var ( + _ Type = DocumentUriType{} + _ BaseType = DocumentUriType{} +) + +func (DocumentUriType) isType() {} +func (DocumentUriType) HasSubTypes() bool { return false } +func (DocumentUriType) SubTypes() []Type { return nil } +func (t DocumentUriType) String() string { return flect.Pascalize("DocumentUri") } +func (DocumentUriType) isBaseType() {} + +type IntegerType struct{} + +var ( + _ Type = IntegerType{} + _ BaseType = IntegerType{} +) + +func (IntegerType) isType() {} +func (IntegerType) HasSubTypes() bool { return false } +func (IntegerType) SubTypes() []Type { return nil } +func (t IntegerType) String() string { return "int32" } +func (IntegerType) isBaseType() {} + +type UintegerType struct{} + +var ( + _ Type = UintegerType{} + _ BaseType = UintegerType{} +) + +func (UintegerType) isType() {} +func (UintegerType) HasSubTypes() bool { return false } +func (UintegerType) SubTypes() []Type { return nil } +func (t UintegerType) String() string { return "uint32" } +func (UintegerType) isBaseType() {} + +type DecimalType struct{} + +var ( + _ Type = DecimalType{} + _ BaseType = DecimalType{} +) + +func (DecimalType) isType() {} +func (DecimalType) HasSubTypes() bool { return false } +func (DecimalType) SubTypes() []Type { return nil } +func (t DecimalType) String() string { return "float64" } +func (DecimalType) isBaseType() {} + +type StringType struct{} + +var ( + _ Type = StringType{} + _ BaseType = StringType{} +) + +func (StringType) isType() {} +func (StringType) HasSubTypes() bool { return false } +func (StringType) SubTypes() []Type { return nil } +func (t StringType) String() string { return "string" } +func (StringType) isBaseType() {} + +type BooleanType struct{} + +var ( + _ Type = BooleanType{} + _ BaseType = BooleanType{} +) + +func (BooleanType) isType() {} +func (BooleanType) HasSubTypes() bool { return false } +func (BooleanType) SubTypes() []Type { return nil } +func (t BooleanType) String() string { return "bool" } +func (BooleanType) isBaseType() {} + +type NullType struct{} + +var _ Type = NullType{} + +func (NullType) isType() {} +func (NullType) HasSubTypes() bool { return false } +func (NullType) SubTypes() []Type { return nil } +func (t NullType) String() string { return "nil" } + +type RegExpType struct{} + +var _ Type = RegExpType{} + +func (RegExpType) isType() {} +func (RegExpType) HasSubTypes() bool { return false } +func (RegExpType) SubTypes() []Type { return nil } +func (t RegExpType) String() string { return "*regexp.Regexp" } + +// AndType represents an and type (e.g. TextDocumentParams & WorkDoneProgressParams). +type AndType struct{ Items []Type } + +var _ Type = (*AndType)(nil) + +func (AndType) isType() {} +func (AndType) HasSubTypes() bool { return true } +func (t *AndType) SubTypes() []Type { return t.Items } +func (t *AndType) String() string { return "TODO(zchee): AndType" } // TODO(zchee): implements + +// ArrayType represents an array type (e.g. TextDocument[]). +type ArrayType struct{ Element Type } + +var _ Type = (*ArrayType)(nil) + +func (ArrayType) isType() {} +func (ArrayType) HasSubTypes() bool { return true } +func (t *ArrayType) SubTypes() []Type { return []Type{t.Element} } +func (t *ArrayType) String() string { return "TODO(zchee): ArrayType" } // TODO(zchee): implements + +// BooleanLiteralType represents a boolean literal type (e.g. kind: true). +// kind: booleanLiteral +type BooleanLiteralType struct{ Value bool } + +var _ Type = BooleanLiteralType{} + +func (BooleanLiteralType) isType() {} +func (BooleanLiteralType) HasSubTypes() bool { return false } +func (BooleanLiteralType) SubTypes() []Type { return nil } +func (t BooleanLiteralType) String() string { return strconv.FormatBool(t.Value) } // TODO(zchee): implements + +// IntegerLiteralType represents an integer literal type (e.g. kind: 1). +type IntegerLiteralType struct{ Value int } + +var _ Type = IntegerLiteralType{} + +func (IntegerLiteralType) isType() {} +func (IntegerLiteralType) HasSubTypes() bool { return false } +func (IntegerLiteralType) SubTypes() []Type { return nil } +func (t IntegerLiteralType) String() string { return strconv.FormatInt(int64(t.Value), 10) } // TODO(zchee): implements + +// MapType represents a JSON object map (e.g. interface Map { [key: K] => V; }). +type MapType struct { + Key Type + Value Type +} + +var _ Type = (*MapType)(nil) + +func (MapType) isType() {} +func (MapType) HasSubTypes() bool { return true } +func (t *MapType) SubTypes() []Type { return []Type{t.Key, t.Value} } +func (t *MapType) String() string { return "TODO(zchee): MapType" } // TODO(zchee): implements + +// OrType represents an or type (e.g. Location | LocationLink) +type OrType struct{ Items []Type } + +var _ Type = (*OrType)(nil) + +func (OrType) isType() {} +func (OrType) HasSubTypes() bool { return true } +func (t *OrType) SubTypes() []Type { return t.Items } +func (t *OrType) String() string { return "TODO(zchee): OrType" } // TODO(zchee): implements + +// StringLiteralType represents a string literal type (e.g. kind: 'rename'). +type StringLiteralType struct{ Value string } + +var _ Type = (*StringLiteralType)(nil) + +func (StringLiteralType) isType() {} +func (StringLiteralType) HasSubTypes() bool { return false } +func (StringLiteralType) SubTypes() []Type { return nil } +func (t *StringLiteralType) String() string { return t.Value } // TODO(zchee): implements + +// StructureLiteralType represents a literal structure (e.g. property: { start: uinteger; end: uinteger; }). +type StructureLiteralType struct{ Value *StructureLiteral } + +var _ Type = (*StructureLiteralType)(nil) + +func (StructureLiteralType) isType() {} +func (StructureLiteralType) HasSubTypes() bool { return false } +func (StructureLiteralType) SubTypes() []Type { return nil } +func (t *StructureLiteralType) String() string { return "TODO(zchee): StructureLiteralType" } // TODO(zchee): implements + +// ReferenceType represents a reference to another type (e.g. TextDocument). +// This is either a Structure, a Enumeration or a TypeAlias in the same meta model. +type ReferenceType struct { + Name string + TypeDecl TypeDecl +} + +var _ Type = (*ReferenceType)(nil) + +func (ReferenceType) isType() {} +func (ReferenceType) HasSubTypes() bool { return false } +func (ReferenceType) SubTypes() []Type { return nil } +func (t ReferenceType) String() string { return t.Name } // TODO(zchee): correct? + +// TupleType represents a tuple type (e.g. [integer, integer]). +type TupleType struct{ Items []Type } + +var _ Type = (*TupleType)(nil) + +func (TupleType) isType() {} +func (TupleType) HasSubTypes() bool { return true } +func (t *TupleType) SubTypes() []Type { return t.Items } +func (t *TupleType) String() string { return "TODO(zchee): TupleType" } // TODO(zchee): implements diff --git a/tools/protocol-gen/protocol/type_alias.go b/tools/protocol-gen/protocol/type_alias.go new file mode 100644 index 00000000..35151a86 --- /dev/null +++ b/tools/protocol-gen/protocol/type_alias.go @@ -0,0 +1,28 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// TypeAlias defines a type alias. (e.g. type Definition = Location | LocationLink). +type TypeAlias struct { + // Whether the type alias is deprecated or not. + // If deprecated the property contains the deprecation message. + Deprecated string + + // An optional documentation. + Documentation string + + // The name of the type alias. + Name string + + // Whether this is a proposed type alias. If omitted, the type alias is final. + Proposed bool + + // Since when (release number) this structure is available. Is undefined if not known. + Since string + + // The aliased type. + Type Type +} + +func (TypeAlias) isTypeDecl() {} diff --git a/tools/protocol-gen/protocol/type_decl.go b/tools/protocol-gen/protocol/type_decl.go new file mode 100644 index 00000000..eedc5d90 --- /dev/null +++ b/tools/protocol-gen/protocol/type_decl.go @@ -0,0 +1,9 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package protocol + +// TypeDecl is an interface used to classify protocol types represent a LSP type declaration. +type TypeDecl interface { + isTypeDecl() +} diff --git a/tools/protocol-gen/resolver/resolver.go b/tools/protocol-gen/resolver/resolver.go new file mode 100644 index 00000000..edcbed34 --- /dev/null +++ b/tools/protocol-gen/resolver/resolver.go @@ -0,0 +1,474 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package resolver + +import ( + "fmt" + "regexp" + "strings" + + "github.com/gobuffalo/flect" + "golang.org/x/text/cases" + "golang.org/x/text/language" + + "go.lsp.dev/protocol/tools/protocol-gen/protocol" + "go.lsp.dev/protocol/tools/protocol-gen/schema" +) + +// Resolve resolves the JSON MetaModel to a Protocol, which can be consumed by the templates +func Resolve(model schema.MetaModel) (*protocol.Protocol, error) { + r := resolver{} + out := r.model(model) + if r.err != nil { + return &protocol.Protocol{}, r.err + } + return out, nil +} + +type resolver struct { + stack []string + err error + newStructureLiteralType func(*schema.StructureLiteralType) protocol.Type + allReferenceTypes []*protocol.ReferenceType + typeDecls map[string]protocol.TypeDecl + typeDeclsSeen map[string]bool +} + +func (r *resolver) pushScope(msg string, args ...any) (pop func()) { + r.stack = append(r.stack, fmt.Sprintf(msg, args...)) + return func() { r.stack = r.stack[:len(r.stack)-1] } +} + +func (r *resolver) error(msg string, args ...any) { + if r.err != nil { + return + } + sb := strings.Builder{} + sb.WriteString(fmt.Sprintf(msg, args...)) + for i := len(r.stack) - 1; i >= 0; i-- { + sb.WriteString("\nwhile ") + sb.WriteString(r.stack[i]) + } + r.err = fmt.Errorf("%v", sb.String()) +} + +func (r *resolver) model(in schema.MetaModel) *protocol.Protocol { + defer r.pushScope("resolving model")() + out := &protocol.Protocol{ + Enumerations: transform(in.Enumerations, r.enumeration), + MetaData: r.metadata(in.MetaData), + Notifications: transform(in.Notifications, r.notification), + ClientToServerNotifications: []*protocol.Notification{}, + ServerToClientNotifications: []*protocol.Notification{}, + BidirectionalNotifications: []*protocol.Notification{}, + Requests: transform(in.Requests, r.request), + Structures: transform(in.Structures, r.structure), + TypeAliases: transform(in.TypeAliases, r.typeAlias), + ServerToClientRequests: []*protocol.Request{}, + ClientToServerRequests: []*protocol.Request{}, + BidirectionalRequests: []*protocol.Request{}, + } + + r.resolveTypes(out) + + for _, notification := range out.Notifications { + switch notification.MessageDirection { + case protocol.MessageDirectionClientToServer: + out.ClientToServerNotifications = append(out.ClientToServerNotifications, notification) + case protocol.MessageDirectionServerToClient: + out.ServerToClientNotifications = append(out.ServerToClientNotifications, notification) + case protocol.MessageDirectionBidirectional: + out.BidirectionalNotifications = append(out.BidirectionalNotifications, notification) + } + } + for _, request := range out.Requests { + switch request.MessageDirection { + case protocol.MessageDirectionClientToServer: + out.ClientToServerRequests = append(out.ClientToServerRequests, request) + case protocol.MessageDirectionServerToClient: + out.ServerToClientRequests = append(out.ServerToClientRequests, request) + case protocol.MessageDirectionBidirectional: + out.BidirectionalRequests = append(out.BidirectionalRequests, request) + } + } + out.TypeAliases = r.sortTypeAliases(out.TypeAliases) + out.Structures = r.sortStructures(out.Structures) + + return out +} + +func (r *resolver) enumeration(in schema.Enumeration) *protocol.Enumeration { + defer r.pushScope("resolving enumeration '%v'", in.Name)() + return &protocol.Enumeration{ + Deprecated: in.Deprecated, + Documentation: r.documentation(in.Documentation), + Name: r.className(in.Name), + Proposed: in.Proposed, + Since: in.Since, + SupportsCustomValues: in.SupportsCustomValues, + Type: r.type_(in.Type), + Values: transform(in.Values, r.enumerationEntry), + } +} + +func (r *resolver) enumerationEntry(in schema.EnumerationEntry) *protocol.EnumerationEntry { + defer r.pushScope("resolving enumeration entry '%v'", in.Name)() + return &protocol.EnumerationEntry{ + Deprecated: in.Deprecated, + Documentation: r.documentation(in.Documentation), + Name: r.className(in.Name), + Proposed: in.Proposed, + Since: in.Since, + Value: r.value(in.Value), + } +} + +func (r *resolver) metadata(in schema.MetaData) *protocol.MetaData { + defer r.pushScope("resolving metadata")() + return &protocol.MetaData{Version: in.Version} +} + +func (r *resolver) notification(in schema.Notification) *protocol.Notification { + defer r.pushScope("resolving notification '%v'", in.Method)() + return &protocol.Notification{ + Deprecated: in.Deprecated, + Documentation: r.documentation(in.Documentation), + MessageDirection: r.messageDirection(in.MessageDirection), + Method: in.Method, + Params: r.types(in.Params), + Proposed: in.Proposed, + RegistrationMethod: in.RegistrationMethod, + RegistrationOptions: r.type_(in.RegistrationOptions), + Since: in.Since, + } +} + +func (r *resolver) request(in schema.Request) *protocol.Request { + defer r.pushScope("resolving request '%v'", in.Method)() + return &protocol.Request{ + Deprecated: in.Deprecated, + Documentation: r.documentation(in.Documentation), + ErrorData: r.type_(in.ErrorData), + MessageDirection: r.messageDirection(in.MessageDirection), + Method: in.Method, + Params: r.types(in.Params), + PartialResult: r.type_(in.PartialResult), + Proposed: in.Proposed, + RegistrationMethod: in.RegistrationMethod, + RegistrationOptions: r.type_(in.RegistrationOptions), + Result: r.type_(in.Result), + Since: in.Since, + } +} + +func (r *resolver) structure(in schema.Structure) *protocol.Structure { + defer r.pushScope("resolving structure '%v'", in.Name)() + name := r.className(in.Name) + out := &protocol.Structure{ + Deprecated: in.Deprecated, + Documentation: r.documentation(in.Documentation), + Extends: transform(in.Extends, r.type_), + Mixins: transform(in.Mixins, r.type_), + Name: name, + Proposed: in.Proposed, + Since: in.Since, + NestedNames: []string{name}, + } + for _, propertyIn := range in.Properties { + defer scopedAssignment(&r.newStructureLiteralType, func(in *schema.StructureLiteralType) protocol.Type { + name := cases.Title(language.Und, cases.NoLower).String(propertyIn.Name) + out.NestedStructures = append(out.NestedStructures, + &protocol.Structure{ + Deprecated: in.Value.Deprecated, + Documentation: r.documentation(in.Value.Documentation), + Properties: transform(in.Value.Properties, r.property), + Name: name, + Proposed: in.Value.Proposed, + Since: in.Value.Since, + NestedNames: append(append([]string{}, out.NestedNames...), name), + }, + ) + ref := &protocol.ReferenceType{Name: name} + r.allReferenceTypes = append(r.allReferenceTypes, ref) + return ref + })() + propertyOut := r.property(propertyIn) + if propertyOut.JSONName == "kind" { + if lit, ok := propertyOut.Type.(*protocol.StringLiteralType); ok { + out.Kind = lit.Value + continue + } + } + out.Properties = append(out.Properties, propertyOut) + } + return out +} + +func (r *resolver) property(in schema.Property) *protocol.Property { + defer r.pushScope("resolving property '%v'", in.Name)() + return &protocol.Property{ + Deprecated: in.Deprecated, + Documentation: r.documentation(in.Documentation), + JSONName: in.Name, + Name: flect.Underscore(in.Name), + Optional: in.Optional, + Proposed: in.Proposed, + Since: in.Since, + Type: r.type_(in.Type), + } +} + +func (r *resolver) typeAlias(in schema.TypeAlias) *protocol.TypeAlias { + defer r.pushScope("resolving type alias '%v'", in.Name)() + return &protocol.TypeAlias{ + Deprecated: in.Deprecated, + Documentation: r.documentation(in.Documentation), + Name: r.className(in.Name), + Proposed: in.Proposed, + Since: in.Since, + Type: r.type_(in.Type), + } +} + +func (r *resolver) types(in schema.Nodes) []protocol.Type { + return transform(in.Nodes, r.typeImpl) +} + +func (r *resolver) type_(in schema.Type) protocol.Type { + return r.typeImpl(in.Node) +} + +func (r *resolver) value(in any) any { + switch in := in.(type) { + case string: + return fmt.Sprintf(`"%v"`, in) + default: + return in + } +} + +func (r *resolver) typeImpl(in schema.Node) protocol.Type { + switch in := in.(type) { + case nil: + return nil + case *schema.BaseType: + switch in.Name { + case schema.URI: + return &protocol.URIType{} + case schema.DocumentUri: + return &protocol.DocumentUriType{} + case schema.Integer: + return &protocol.IntegerType{} + case schema.Uinteger: + return &protocol.UintegerType{} + case schema.Decimal: + return &protocol.DecimalType{} + case schema.RegExp: + return &protocol.RegExpType{} + case schema.String: + return &protocol.StringType{} + case schema.Boolean: + return &protocol.BooleanType{} + case schema.Null: + return &protocol.NullType{} + } + + case *schema.ArrayType: + return &protocol.ArrayType{Element: r.type_(in.Element)} + + case *schema.ReferenceType: + out := &protocol.ReferenceType{Name: r.className(in.Name)} + r.allReferenceTypes = append(r.allReferenceTypes, out) + return out + + case *schema.AndType: + return &protocol.AndType{Items: transform(in.Items, r.type_)} + + case *schema.OrType: + return &protocol.OrType{Items: transform(in.Items, r.type_)} + + case *schema.MapType: + return &protocol.MapType{Key: r.type_(in.Key), Value: r.type_(in.Value)} + + case *schema.StringLiteralType: + return &protocol.StringLiteralType{Value: in.Value} + + case *schema.StructureLiteralType: + return r.newStructureLiteralType(in) + + case *schema.TupleType: + return &protocol.TupleType{Items: transform(in.Items, r.type_)} + } + r.error("invalid type %T %+v", in, in) + return nil +} + +func (r *resolver) structureLiteral(in schema.StructureLiteral) *protocol.StructureLiteral { + defer r.pushScope("resolving structure literal")() + return &protocol.StructureLiteral{ + Deprecated: in.Deprecated, + Documentation: r.documentation(in.Documentation), + Properties: transform(in.Properties, r.property), + Proposed: in.Proposed, + Since: in.Since, + } +} + +func (r *resolver) messageDirection(in schema.MessageDirection) protocol.MessageDirection { + switch in { + case schema.MessageDirectionServerToClient: + return protocol.MessageDirectionServerToClient + case schema.MessageDirectionClientToServer: + return protocol.MessageDirectionClientToServer + case schema.MessageDirectionBoth: + return protocol.MessageDirectionBidirectional + } + r.error("invalid message direction %+v", in) + return "" +} + +func (r *resolver) className(name string) string { + if strings.HasPrefix(name, "_") { + name = strings.TrimLeft(name, "_") + "Base" + } + name = strings.TrimLeft(name, "$") + name = strings.ReplaceAll(name, "/", "_") + name = flect.Capitalize(name) + return name +} + +var reLinkTag = regexp.MustCompile(`{@link[\s]+([^}]+)}`) + +func (r *resolver) documentation(in string) string { + s := reLinkTag.ReplaceAllString(in, "$1") + s = strings.ReplaceAll(s, "\n", " ") + s = strings.ReplaceAll(s, " ", " ") + s = strings.ReplaceAll(s, " ", " ") + // s = strings.ReplaceAll(s, "@proposed", "\n\nProposed in:") + s = strings.ReplaceAll(s, "@sample", "\n\nExample:") + // s = strings.ReplaceAll(s, "@since", "\n\n@since") + s = strings.ReplaceAll(s, "@deprecated", "\n\nDeprecated:") + + return strings.TrimSpace(s) +} + +func (r *resolver) resolveTypes(p *protocol.Protocol) { + r.typeDecls = map[string]protocol.TypeDecl{} + register := func(name string, ty protocol.TypeDecl) { + if existing, found := r.typeDecls[name]; found { + r.error("duplicate definition for '%v'. %T and %T", name, ty, existing) + return + } + r.typeDecls[name] = ty + } + lookup := func(name string) protocol.TypeDecl { + typeDecl, found := r.typeDecls[name] + if !found { + r.error("referenced type '%v' not found", name) + } + return typeDecl + } + + for _, a := range p.TypeAliases { + register(a.Name, a) + } + for _, e := range p.Enumerations { + register(e.Name, e) + } + for _, s := range p.Structures { + register(s.Name, s) + for _, n := range s.NestedStructures { + register(s.Name+"::"+n.Name, s) + } + } + + for _, a := range r.allReferenceTypes { + a.TypeDecl = lookup(a.Name) + } +} + +func (r *resolver) sortTypeAliases(in []*protocol.TypeAlias) []*protocol.TypeAlias { + aliases := map[string]*protocol.TypeAlias{} + for _, a := range in { + aliases[a.Name] = a + } + + sorted := make([]*protocol.TypeAlias, 0, len(in)) + seen := map[string]struct{}{} + stack := append([]*protocol.TypeAlias{}, in...) + + for len(stack) > 0 { + alias := stack[len(stack)-1] + stack = stack[:len(stack)-1] + if _, found := seen[alias.Name]; found { + continue + } + seen[alias.Name] = struct{}{} + for _, ty := range protocol.RecursiveTypesOf(alias.Type) { + if ref, ok := ty.(*protocol.ReferenceType); ok { + if dep, ok := aliases[ref.Name]; ok { + stack = append(stack, dep) + } + } + } + sorted = append(sorted, alias) + } + + return sorted +} + +func (r *resolver) sortStructures(in []*protocol.Structure) []*protocol.Structure { + structures := map[string]*protocol.Structure{} + for _, s := range in { + structures[s.Name] = s + } + + sorted := []*protocol.Structure{} + seen := map[string]struct{}{} + + var visit func(s *protocol.Structure) + visit = func(s *protocol.Structure) { + if _, found := seen[s.Name]; found { + return + } + seen[s.Name] = struct{}{} + for _, ext := range s.Extends { + if ref, ok := ext.(*protocol.ReferenceType); ok { + if dep, ok := structures[ref.Name]; ok { + visit(dep) + } + } + } + for _, property := range s.Properties { + for _, ty := range protocol.RecursiveTypesOf(property.Type) { + if ref, ok := ty.(*protocol.ReferenceType); ok { + if dep, ok := structures[ref.Name]; ok { + visit(dep) + } + } + } + } + sorted = append(sorted, s) + } + + for _, s := range in { + visit(s) + } + return sorted +} + +func scopedAssignment[T any](p *T, val T) func() { + old := *p + *p = val + return func() { *p = old } +} + +// transform returns a new slice by transforming each element with the function fn +func transform[IN, OUT any](in []IN, fn func(in IN) OUT) []OUT { + out := make([]OUT, len(in)) + for i, el := range in { + out[i] = fn(el) + } + return out +} diff --git a/tools/protocol-gen/schema/metaModel.go b/tools/protocol-gen/schema/metaModel.go new file mode 100644 index 00000000..fe88ae20 --- /dev/null +++ b/tools/protocol-gen/schema/metaModel.go @@ -0,0 +1,485 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: Apache-2.0 + +package schema + +import ( + "encoding/json" + "fmt" + "io" +) + +// Decode decodes the LSP JSON to a MetaModel +func Decode(r io.Reader) (MetaModel, error) { + out := MetaModel{} + d := json.NewDecoder(r) + d.DisallowUnknownFields() + if err := d.Decode(&out); err != nil { + return MetaModel{}, err + } + return out, nil +} + +// MetaModel represents the actual meta model +type MetaModel struct { + // Additional meta data. + MetaData MetaData `json:"metaData" yaml:"metaData"` + + // The requests. + Requests []Request `json:"requests" yaml:"requests"` + + // The notifications. + Notifications []Notification `json:"notifications" yaml:"notifications"` + + // The structures. + Structures []Structure `json:"structures" yaml:"structures"` + + // The enumerations. + Enumerations []Enumeration `json:"enumerations" yaml:"enumerations"` + + // The type aliases. + TypeAliases []TypeAlias `json:"typeAliases" yaml:"typeAliases"` +} + +type MetaData struct { + // The protocol version + Version string `json:"version" yaml:"version"` +} + +type BaseTypes string + +const ( + URI BaseTypes = "URI" + DocumentUri BaseTypes = "DocumentUri" + Integer BaseTypes = "integer" + Uinteger BaseTypes = "uinteger" + Decimal BaseTypes = "decimal" + RegExp BaseTypes = "RegExp" + String BaseTypes = "string" + Boolean BaseTypes = "boolean" + Null BaseTypes = "null" +) + +type TypeKind string + +const ( + TypeKindBase TypeKind = "base" + TypeKindReference TypeKind = "reference" + TypeKindArray TypeKind = "array" + TypeKindMap TypeKind = "map" + TypeKindAnd TypeKind = "and" + TypeKindOr TypeKind = "or" + TypeKindTuple TypeKind = "tuple" + TypeKindLiteral TypeKind = "literal" + TypeKindStringLiteral TypeKind = "stringLiteral" + TypeKindIntegerLiteral TypeKind = "integerLiteral" + TypeKindBooleanLiteral TypeKind = "booleanLiteral" +) + +// MessageDirection indicates in which direction a message is sent in the protocol +type MessageDirection string + +const ( + MessageDirectionClientToServer MessageDirection = "clientToServer" + MessageDirectionServerToClient MessageDirection = "serverToClient" + MessageDirectionBoth MessageDirection = "both" +) + +type Node interface { + isType() +} + +// Type represents a metaModel type. +type Type struct { + Node Node +} + +func (t *Type) UnmarshalJSON(data []byte) error { + s := struct { + Kind TypeKind + }{} + if err := json.Unmarshal(data, &s); err != nil { + return err + } + switch s.Kind { + case TypeKindBase: + t.Node = &BaseType{} + case TypeKindReference: + t.Node = &ReferenceType{} + case TypeKindArray: + t.Node = &ArrayType{} + case TypeKindMap: + t.Node = &MapType{} + case TypeKindAnd: + t.Node = &AndType{} + case TypeKindOr: + t.Node = &OrType{} + case TypeKindTuple: + t.Node = &TupleType{} + case TypeKindLiteral: + t.Node = &StructureLiteralType{} + case TypeKindStringLiteral: + t.Node = &StringLiteralType{} + case TypeKindIntegerLiteral: + t.Node = &IntegerLiteralType{} + case TypeKindBooleanLiteral: + t.Node = &BooleanLiteralType{} + default: + return fmt.Errorf("unhandled Type kind '%v'", s.Kind) + } + + return json.Unmarshal(data, t.Node) +} + +// Nodes represents a slice of [Type]. +type Nodes struct { + Nodes []Node +} + +func (t *Nodes) UnmarshalJSON(data []byte) error { + single := Type{} + if err := json.Unmarshal(data, &single); err == nil { + t.Nodes = []Node{single.Node} + return nil + } + + multi := []Type{} + if err := json.Unmarshal(data, &multi); err != nil { + return err + } + for _, e := range multi { + t.Nodes = append(t.Nodes, e.Node) + } + + return nil +} + +// BaseType represents a base type like string or DocumentUri. +type BaseType struct { + Name BaseTypes `json:"name" yaml:"name"` +} + +var _ Node = BaseType{} + +func (BaseType) isType() {} + +// ReferenceType represents a reference to another type (e.g. TextDocument). +// This is either a Structure, a Enumeration or a TypeAlias in the same meta model. +type ReferenceType struct { + Name string `json:"name" yaml:"name"` +} + +var _ Node = ReferenceType{} + +func (ReferenceType) isType() {} +func (ReferenceType) isMapKeyType() {} + +// ArrayType represents an array type (e.g. TextDocument[]). +type ArrayType struct { + Element Type `json:"element" yaml:"element"` +} + +var _ Node = ArrayType{} + +func (ArrayType) isType() {} + +// MapKeyType represents a type that can be used as a key in a map type. +// If a reference type is used then the type must either resolve to a string or integer type. +// (e.g. type ChangeAnnotationIdentifier === string). +type MapKeyType interface { + isMapKeyType() +} + +type MapKeyTypeBase string + +func (MapKeyTypeBase) isMapKeyType() {} + +const ( + MapKeyType_URI MapKeyTypeBase = "URI" + MapKeyType_DocumentUri MapKeyTypeBase = "DocumentUri" + MapKeyType_String MapKeyTypeBase = "string" + MapKeyType_Integer MapKeyTypeBase = "integer" +) + +// MapType represents a JSON object map (e.g. interface Map { [key: K] => V; }). +type MapType struct { + Key Type `json:"key" yaml:"key"` + Value Type `json:"value" yaml:"value"` +} + +var _ Node = MapType{} + +func (MapType) isType() {} + +// AndType represents an and type (e.g. TextDocumentParams & WorkDoneProgressParams). +type AndType struct { + Items []Type `json:"items" yaml:"items"` +} + +var _ Node = AndType{} + +func (AndType) isType() {} + +// OrType represents an or type (e.g. Location | LocationLink) +type OrType struct { + Items []Type `json:"items" yaml:"items"` +} + +var _ Node = OrType{} + +func (OrType) isType() {} + +// TupleType represents a tuple type (e.g. [integer, integer]). +type TupleType struct { + Items []Type `json:"items" yaml:"items"` +} + +var _ Node = TupleType{} + +func (TupleType) isType() {} + +// StructureLiteralType represents a literal structure (e.g. property: { start: uinteger; end: uinteger; }) +type StructureLiteralType struct { + Value StructureLiteral `json:"value" yaml:"value"` +} + +var _ Node = StructureLiteralType{} + +func (StructureLiteralType) isType() {} + +// StructureLiteral defines an unnamed structure of an object literal +type StructureLiteral struct { + // The properties. + Properties []Property `json:"properties" yaml:"properties"` + + // An optional documentation. + Documentation string `json:"documentation,omitempty" yaml:"documentation,omitempty"` + + // Since when (release number) this structure is available. Is undefined if not known. + Since string `json:"since,omitempty" yaml:"since,omitempty"` + + // Whether this is a proposed structure. If omitted, the structure is final. + Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` + + // Whether the literal is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` +} + +// StringLiteralType represents a string literal type (e.g. kind: 'rename') +type StringLiteralType struct { + Value string `json:"value" yaml:"value"` +} + +var _ Node = StringLiteralType{} + +func (StringLiteralType) isType() {} + +// IntegerLiteralType represents an integer literal type (e.g. kind: 1). +type IntegerLiteralType struct { + Value bool `json:"value" yaml:"value"` +} + +var _ Node = IntegerLiteralType{} + +func (IntegerLiteralType) isType() {} + +// BooleanLiteralType represents a boolean literal type (e.g. kind: true). +// kind: booleanLiteral +type BooleanLiteralType struct { + Value bool `json:"value" yaml:"value"` +} + +var _ Node = BooleanLiteralType{} + +func (BooleanLiteralType) isType() {} + +// Request represents a LSP request +type Request struct { + // The request's method name. + Method string `json:"method" yaml:"method"` + + // The parameter type(s) if any. + Params Nodes `json:"params,omitempty" yaml:"params,omitempty"` + + // The result type. + Result Type `json:"result" yaml:"result"` + + // Optional partial result type if the request supports partial result reporting. + PartialResult Type `json:"partialResult,omitempty" yaml:"partialResult,omitempty"` + + // An optional error data type. + ErrorData Type `json:"errorData,omitempty" yaml:"errorData,omitempty"` + + // Optional a dynamic registration method if it different from the request's method. + RegistrationMethod string `json:"registrationMethod,omitempty" yaml:"registrationMethod,omitempty"` + + // Optional registration options if the request supports dynamic registration. + RegistrationOptions Type `json:"registrationOptions,omitempty" yaml:"registrationOptions,omitempty"` + + // The direction in which this request is sent in the protocol. + MessageDirection MessageDirection `json:"messageDirection" yaml:"messageDirection"` + + // An optional documentation. + Documentation string `json:"documentation,omitempty" yaml:"documentation,omitempty"` + + // Since when (release number) this request is available. Is undefined if not known. + Since string `json:"since,omitempty" yaml:"since,omitempty"` + + // Whether this is a proposed feature. If omitted the feature is final. + Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` + + // Whether the request is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` +} + +// Notification represents a LSP notification +type Notification struct { + // The request's method name. + Method string `json:"method" yaml:"method"` + + // The parameter type(s) if any. + Params Nodes `json:"params,omitempty" yaml:"params,omitempty"` + + // Optional a dynamic registration method if it different from the request's method. + RegistrationMethod string `json:"registrationMethod,omitempty" yaml:"registrationMethod,omitempty"` + + // Optional registration options if the notification supports dynamic registration. + RegistrationOptions Type `json:"registrationOptions,omitempty" yaml:"registrationOptions,omitempty"` + + // The direction in which this notification is sent in the protocol. + MessageDirection MessageDirection `json:"messageDirection" yaml:"messageDirection"` + + // An optional documentation. + Documentation string `json:"documentation,omitempty" yaml:"documentation,omitempty"` + + // Since when (release number) this notification is available. Is undefined if not known. + Since string `json:"since,omitempty" yaml:"since,omitempty"` + + // Whether this is a proposed notification. If omitted the notification is final. + Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` + + // Whether the notification is deprecated or not. + // If deprecated the property contains the deprecation message. + Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` +} + +// Structure defines the structure of an object literal +type Structure struct { + // The name of the structure. + Name string `json:"name" yaml:"name"` + + // Structures extended from. This structures form a polymorphic type hierarchy. + Extends []Type `json:"extends,omitempty" yaml:"extends,omitempty"` + + // Structures to mix in. The properties of these structures are `copied` into this structure. Mixins don't form a polymorphic type hierarchy in LSP. + Mixins []Type `json:"mixins,omitempty" yaml:"mixins,omitempty"` + + // The properties. + Properties []Property `json:"properties" yaml:"properties"` + + // An optional documentation. + Documentation string `json:"documentation,omitempty" yaml:"documentation,omitempty"` + + // Since when (release number) this structure is available. Is undefined if not known. + Since string `json:"since,omitempty" yaml:"since,omitempty"` + + // Whether this is a proposed structure. If omitted, the structure is final. + Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` + + // Whether the structure is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` +} + +// Enumeration defines an enumeration. +type Enumeration struct { + // The name of the enumeration. + Name string `json:"name" yaml:"name"` + + // The type of the elements. + Type Type `json:"type" yaml:"type"` + + // The enum values. + Values []EnumerationEntry `json:"values" yaml:"values"` + + // Whether the enumeration supports custom values (e.g. values which are not part of the set defined in values). If omitted no custom values are supported. + SupportsCustomValues bool `json:"supportsCustomValues,omitempty" yaml:"supportsCustomValues,omitempty"` + + // An optional documentation. + Documentation string `json:"documentation,omitempty" yaml:"documentation,omitempty"` + + // Since when (release number) this enumeration is available. Is empty if not known. + Since string `json:"since,omitempty" yaml:"since,omitempty"` + + // Whether this is a proposed enumeration. If omitted, the enumeration is final. + Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` + + // Whether the enumeration is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` +} + +// EnumerationEntry defines an enumeration entry +type EnumerationEntry struct { + // The name of the enum item. + Name string `json:"name,strictcase" yaml:"name"` + + // The value (string or number). + Value any `json:"value" yaml:"value"` + + // An optional documentation. + Documentation string `json:"documentation,omitempty" yaml:"documentation,omitempty"` + + // Since when (release number) this enumeration entry is available. Is undefined if not known. + Since string `json:"since,omitempty" yaml:"since,omitempty"` + + // Whether this is a proposed enumeration entry. If omitted, the enumeration entry is final. + Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` + + // Whether the enum entry is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` +} + +// TypeAlias defines a type alias. (e.g. type Definition = Location | LocationLink) +type TypeAlias struct { + // The name of the type alias. + Name string `json:"name" yaml:"name"` + + // The aliased type. + Type Type `json:"type" yaml:"type"` + + // An optional documentation. + Documentation string `json:"documentation,omitempty" yaml:"documentation,omitempty"` + + // Since when (release number) this structure is available. Is undefined if not known. + Since string `json:"since,omitempty" yaml:"since,omitempty"` + + // Whether this is a proposed type alias. If omitted, the type alias is final. + Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` + + // Whether the type alias is deprecated or not. + // If deprecated the property contains the deprecation message. + Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` +} + +// Property represents an object property +type Property struct { + // The property name. + Name string `json:"name" yaml:"name"` + + // The type of the property. + Type Type `json:"type" yaml:"type"` + + // Whether the property is optional. If omitted, the property is mandatory. + Optional bool `json:"optional,omitempty" yaml:"optional,omitempty"` + + // An optional documentation. + Documentation string `json:"documentation,omitempty" yaml:"documentation,omitempty"` + + // Since when (release number) this property is available. Is undefined if not known. + Since string `json:"since,omitempty" yaml:"since,omitempty"` + + // Whether this is a proposed property. If omitted, the structure is final. + Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` + + // Whether the property is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` +} From 07dcae9bc4da88516ba0faa811fc6ce6ed87cc82 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 5 May 2024 23:41:03 +0900 Subject: [PATCH 02/19] WIP2 Signed-off-by: Koichi Shiraishi --- .golangci.yml | 1 - client.go | 336 ++++---- client_interface.go | 197 +++++ doc.go | 12 +- errors.go | 6 +- go.mod | 5 +- go.sum | 2 - protocol.go | 67 ++ server.go | 1873 +++++++++++++++++++++++-------------------- server_interface.go | 681 ++++++++++++++++ 10 files changed, 2146 insertions(+), 1034 deletions(-) create mode 100644 client_interface.go create mode 100644 server_interface.go diff --git a/.golangci.yml b/.golangci.yml index 68060b7a..d9e7f132 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -85,7 +85,6 @@ linters: - staticcheck # It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint. - stylecheck # Stylecheck is a replacement for golint - tagalign # check that struct tags are well aligned - - tagliatelle # Checks the struct tags. - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 - testableexamples # linter checks if examples are testable (have an expected output) - thelper # thelper detects Go test helpers without t.Helper() call and checks the consistency of test helpers diff --git a/client.go b/client.go index e3df68e2..806f0131 100644 --- a/client.go +++ b/client.go @@ -8,11 +8,9 @@ import ( "context" "fmt" - "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" - "go.lsp.dev/pkg/xcontext" ) // ClientDispatcher returns a Client that dispatches LSP requests across the @@ -28,7 +26,7 @@ func ClientDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Client { func ClientHandler(client Client, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := xcontext.Detach(ctx) + xctx := context.WithoutCancel(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -52,12 +50,12 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := json.NewDecoder(bytes.NewReader(req.Params())) + dec := newDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodProgress: // notification - defer logger.Debug(MethodProgress, zap.Error(err)) + case MethodClientProgress: // notification + defer logger.Debug(MethodClientProgress, zap.Error(err)) var params ProgressParams if err := dec.Decode(¶ms); err != nil { @@ -68,27 +66,27 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodWorkDoneProgressCreate: // request - defer logger.Debug(MethodWorkDoneProgressCreate, zap.Error(err)) + case MethodLogTrace: // notification + defer logger.Debug(MethodLogTrace, zap.Error(err)) - var params WorkDoneProgressCreateParams + var params LogTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.WorkDoneProgressCreate(ctx, ¶ms) + err := client.LogTrace(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWindowLogMessage: // notification - defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) + case MethodTelemetryEvent: // notification + defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) - var params LogMessageParams + var params any if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.LogMessage(ctx, ¶ms) + err := client.TelemetryEvent(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -100,7 +98,19 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.PublishDiagnostics(ctx, ¶ms) + err := client.TextDocumentPublishDiagnostics(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWindowLogMessage: // notification + defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) + + var params LogMessageParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.WindowLogMessage(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -112,55 +122,67 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.ShowMessage(ctx, ¶ms) + err := client.WindowShowMessage(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWindowShowMessageRequest: // request - defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) + case MethodClientRegisterCapability: // request + defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) - var params ShowMessageRequestParams + var params RegistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := client.ShowMessageRequest(ctx, ¶ms) + err := client.ClientRegisterCapability(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTelemetryEvent: // notification - defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) + case MethodClientUnregisterCapability: // request + defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) - var params interface{} + var params UnregistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.Telemetry(ctx, ¶ms) + err := client.ClientUnregisterCapability(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodClientRegisterCapability: // request - defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) + case MethodWindowShowDocument: // request + defer logger.Debug(MethodWindowShowDocument, zap.Error(err)) - var params RegistrationParams + var params ShowDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.RegisterCapability(ctx, ¶ms) + resp, err := client.WindowShowDocument(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodClientUnregisterCapability: // request - defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) + case MethodWindowShowMessageRequest: // request + defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) - var params UnregistrationParams + var params ShowMessageRequestParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.UnregisterCapability(ctx, ¶ms) + resp, err := client.WindowShowMessageRequest(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWindowWorkDoneProgressCreate: // request + defer logger.Debug(MethodWindowWorkDoneProgressCreate, zap.Error(err)) + + var params WorkDoneProgressCreateParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.WindowWorkDoneProgressCreate(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -172,10 +194,17 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.ApplyEdit(ctx, ¶ms) + resp, err := client.WorkspaceApplyEdit(ctx, ¶ms) return true, reply(ctx, resp, err) + case MethodWorkspaceCodeLensRefresh: // request + defer logger.Debug(MethodWorkspaceCodeLensRefresh, zap.Error(err)) + + err := client.WorkspaceCodeLensRefresh(ctx) + + return true, reply(ctx, nil, err) + case MethodWorkspaceConfiguration: // request defer logger.Debug(MethodWorkspaceConfiguration, zap.Error(err)) @@ -184,80 +213,53 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.Configuration(ctx, ¶ms) + resp, err := client.WorkspaceConfiguration(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceWorkspaceFolders: // request - defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) - - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) - } + case MethodWorkspaceDiagnosticRefresh: // request + defer logger.Debug(MethodWorkspaceDiagnosticRefresh, zap.Error(err)) - resp, err := client.WorkspaceFolders(ctx) + err := client.WorkspaceDiagnosticRefresh(ctx) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - default: - return false, nil - } -} + case MethodWorkspaceFoldingRangeRefresh: // request + defer logger.Debug(MethodWorkspaceFoldingRangeRefresh, zap.Error(err)) -// Client represents a Language Server Protocol client. -type Client interface { - Progress(ctx context.Context, params *ProgressParams) (err error) - WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) - LogMessage(ctx context.Context, params *LogMessageParams) (err error) - PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) - ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) - ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (result *MessageActionItem, err error) - Telemetry(ctx context.Context, params interface{}) (err error) - RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) - UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) - ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) - Configuration(ctx context.Context, params *ConfigurationParams) (result []interface{}, err error) - WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) -} + err := client.WorkspaceFoldingRangeRefresh(ctx) -// list of client methods. -const ( - // MethodProgress method name of "$/progress". - MethodProgress = "$/progress" + return true, reply(ctx, nil, err) - // MethodWorkDoneProgressCreate method name of "window/workDoneProgress/create". - MethodWorkDoneProgressCreate = "window/workDoneProgress/create" + case MethodWorkspaceInlayHintRefresh: // request + defer logger.Debug(MethodWorkspaceInlayHintRefresh, zap.Error(err)) - // MethodWindowShowMessage method name of "window/showMessage". - MethodWindowShowMessage = "window/showMessage" + err := client.WorkspaceInlayHintRefresh(ctx) - // MethodWindowShowMessageRequest method name of "window/showMessageRequest. - MethodWindowShowMessageRequest = "window/showMessageRequest" + return true, reply(ctx, nil, err) - // MethodWindowLogMessage method name of "window/logMessage. - MethodWindowLogMessage = "window/logMessage" + case MethodWorkspaceSemanticTokensRefresh: // request + defer logger.Debug(MethodWorkspaceSemanticTokensRefresh, zap.Error(err)) - // MethodTelemetryEvent method name of "telemetry/event. - MethodTelemetryEvent = "telemetry/event" + err := client.WorkspaceSemanticTokensRefresh(ctx) - // MethodClientRegisterCapability method name of "client/registerCapability. - MethodClientRegisterCapability = "client/registerCapability" + return true, reply(ctx, nil, err) - // MethodClientUnregisterCapability method name of "client/unregisterCapability. - MethodClientUnregisterCapability = "client/unregisterCapability" + case MethodWorkspaceWorkspaceFolders: // request + defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) - // MethodTextDocumentPublishDiagnostics method name of "textDocument/publishDiagnostics. - MethodTextDocumentPublishDiagnostics = "textDocument/publishDiagnostics" + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } - // MethodWorkspaceApplyEdit method name of "workspace/applyEdit. - MethodWorkspaceApplyEdit = "workspace/applyEdit" + resp, err := client.WorkspaceWorkspaceFolders(ctx) - // MethodWorkspaceConfiguration method name of "workspace/configuration. - MethodWorkspaceConfiguration = "workspace/configuration" + return true, reply(ctx, resp, err) - // MethodWorkspaceWorkspaceFolders method name of "workspace/workspaceFolders". - MethodWorkspaceWorkspaceFolders = "workspace/workspaceFolders" -) + default: + return false, nil + } +} // client implements a Language Server Protocol client. type client struct { @@ -269,6 +271,13 @@ type client struct { // compiler time check whether the Client implements ClientInterface interface. var _ Client = (*client)(nil) +func (c *client) CancelRequest(ctx context.Context, params *CancelParams) (err error) { + c.logger.Debug("notify " + MethodClientCancelRequest) + defer c.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodClientCancelRequest, params) +} + // Progress is the base protocol offers also support to report progress in a generic fashion. // // This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and @@ -276,28 +285,25 @@ var _ Client = (*client)(nil) // // @since 3.16.0. func (c *client) Progress(ctx context.Context, params *ProgressParams) (err error) { - c.logger.Debug("call " + MethodProgress) - defer c.logger.Debug("end "+MethodProgress, zap.Error(err)) + c.logger.Debug("notify " + MethodClientProgress) + defer c.logger.Debug("end "+MethodClientProgress, zap.Error(err)) - return c.Conn.Notify(ctx, MethodProgress, params) + return c.Conn.Notify(ctx, MethodClientProgress, params) } -// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. -// -// @since 3.16.0. -func (c *client) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { - c.logger.Debug("call " + MethodWorkDoneProgressCreate) - defer c.logger.Debug("end "+MethodWorkDoneProgressCreate, zap.Error(err)) +func (c *client) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { + c.logger.Debug("notify " + MethodLogTrace) + defer c.logger.Debug("end "+MethodLogTrace, zap.Error(err)) - return Call(ctx, c.Conn, MethodWorkDoneProgressCreate, params, nil) + return c.Conn.Notify(ctx, MethodLogTrace, params) } -// LogMessage sends the notification from the server to the client to ask the client to log a particular message. -func (c *client) LogMessage(ctx context.Context, params *LogMessageParams) (err error) { - c.logger.Debug("call " + MethodWindowLogMessage) - defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) +// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. +func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { + c.logger.Debug("notify " + MethodTelemetryEvent) + defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) - return c.Conn.Notify(ctx, MethodWindowLogMessage, params) + return c.Conn.Notify(ctx, MethodTelemetryEvent, params) } // PublishDiagnostics sends the notification from the server to the client to signal results of validation runs. @@ -310,40 +316,28 @@ func (c *client) LogMessage(ctx context.Context, params *LogMessageParams) (err // When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. // If the computed set is empty it has to push the empty array to clear former diagnostics. // Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side. -func (c *client) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { - c.logger.Debug("call " + MethodTextDocumentPublishDiagnostics) +func (c *client) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { + c.logger.Debug("notify " + MethodTextDocumentPublishDiagnostics) defer c.logger.Debug("end "+MethodTextDocumentPublishDiagnostics, zap.Error(err)) return c.Conn.Notify(ctx, MethodTextDocumentPublishDiagnostics, params) } -// ShowMessage sends the notification from a server to a client to ask the -// client to display a particular message in the user interface. -func (c *client) ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { - return c.Conn.Notify(ctx, MethodWindowShowMessage, params) -} - -// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. -// -// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. -func (c *client) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { - c.logger.Debug("call " + MethodWindowShowMessageRequest) - defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) - - var result *MessageActionItem - if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { - return nil, err - } +// LogMessage sends the notification from the server to the client to ask the client to log a particular message. +func (c *client) WindowLogMessage(ctx context.Context, params *LogMessageParams) (err error) { + c.logger.Debug("notify " + MethodWindowLogMessage) + defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) - return result, nil + return c.Conn.Notify(ctx, MethodWindowLogMessage, params) } -// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. -func (c *client) Telemetry(ctx context.Context, params interface{}) (err error) { - c.logger.Debug("call " + MethodTelemetryEvent) - defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) +// ShowMessage sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) WindowShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { + c.logger.Debug("notify " + MethodWindowShowMessage) + defer c.logger.Debug("end "+MethodWindowShowMessage, zap.Error(err)) - return c.Conn.Notify(ctx, MethodTelemetryEvent, params) + return c.Conn.Notify(ctx, MethodWindowShowMessage, params) } // RegisterCapability sends the request from the server to the client to register for a new capability on the client side. @@ -352,7 +346,7 @@ func (c *client) Telemetry(ctx context.Context, params interface{}) (err error) // // A client opts in via the dynamicRegistration property on the specific client capabilities. // A client can even provide dynamic registration for capability A but not for capability B (see TextDocumentClientCapabilities as an example). -func (c *client) RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { +func (c *client) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { c.logger.Debug("call " + MethodClientRegisterCapability) defer c.logger.Debug("end "+MethodClientRegisterCapability, zap.Error(err)) @@ -360,15 +354,54 @@ func (c *client) RegisterCapability(ctx context.Context, params *RegistrationPar } // UnregisterCapability sends the request from the server to the client to unregister a previously registered capability. -func (c *client) UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { +func (c *client) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { c.logger.Debug("call " + MethodClientUnregisterCapability) defer c.logger.Debug("end "+MethodClientUnregisterCapability, zap.Error(err)) return Call(ctx, c.Conn, MethodClientUnregisterCapability, params, nil) } +// ShowMessage sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (_ *ShowDocumentResult, err error) { + c.logger.Debug("call " + MethodWindowShowDocument) + defer c.logger.Debug("end "+MethodWindowShowDocument, zap.Error(err)) + + var result *ShowDocumentResult + if err := Call(ctx, c.Conn, MethodWindowShowDocument, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. +// +// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. +func (c *client) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { + c.logger.Debug("call " + MethodWindowShowMessageRequest) + defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) + + var result *MessageActionItem + if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. +// +// @since 3.16.0. +func (c *client) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { + c.logger.Debug("call " + MethodWindowWorkDoneProgressCreate) + defer c.logger.Debug("end "+MethodWindowWorkDoneProgressCreate, zap.Error(err)) + + return Call(ctx, c.Conn, MethodWindowWorkDoneProgressCreate, params, nil) +} + // ApplyEdit sends the request from the server to the client to modify resource on the client side. -func (c *client) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) { +func (c *client) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResult, err error) { c.logger.Debug("call " + MethodWorkspaceApplyEdit) defer c.logger.Debug("end "+MethodWorkspaceApplyEdit, zap.Error(err)) @@ -379,16 +412,20 @@ func (c *client) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams return result, nil } +func (c *client) WorkspaceCodeLensRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceCodeLensRefresh) +} + // Configuration sends the request from the server to the client to fetch configuration settings from the client. // // The request can fetch several configuration settings in one roundtrip. // The order of the returned configuration settings correspond to the order of the // passed ConfigurationItems (e.g. the first item in the response is the result for the first configuration item in the params). -func (c *client) Configuration(ctx context.Context, params *ConfigurationParams) (_ []interface{}, err error) { +func (c *client) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) (_ []any, err error) { c.logger.Debug("call " + MethodWorkspaceConfiguration) defer c.logger.Debug("end "+MethodWorkspaceConfiguration, zap.Error(err)) - var result []interface{} + var result []any if err := Call(ctx, c.Conn, MethodWorkspaceConfiguration, params, &result); err != nil { return nil, err } @@ -396,12 +433,39 @@ func (c *client) Configuration(ctx context.Context, params *ConfigurationParams) return result, nil } +func (c *client) WorkspaceDiagnosticRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceDiagnosticRefresh) +} + +func (c *client) WorkspaceFoldingRangeRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceFoldingRangeRefresh) +} + +func (c *client) WorkspaceInlayHintRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceInlayHintRefresh) +} + +func (c *client) WorkspaceInlineValueRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceInlineValueRefresh) +} + +func (c *client) WorkspaceSemanticTokensRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceSemanticTokensRefresh) +} + +func (c *client) refresh(ctx context.Context, method string) (err error) { + c.logger.Debug("call " + method) + defer c.logger.Debug("end "+method, zap.Error(err)) + + return c.Conn.Notify(ctx, method, nil) +} + // WorkspaceFolders sends the request from the server to the client to fetch the current open list of workspace folders. // // Returns null in the response if only a single file is open in the tool. Returns an empty array if a workspace is open but no folders are configured. // // @since 3.6.0. -func (c *client) WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) { +func (c *client) WorkspaceWorkspaceFolders(ctx context.Context) (result []*WorkspaceFolder, err error) { c.logger.Debug("call " + MethodWorkspaceWorkspaceFolders) defer c.logger.Debug("end "+MethodWorkspaceWorkspaceFolders, zap.Error(err)) diff --git a/client_interface.go b/client_interface.go new file mode 100644 index 00000000..01ee1d19 --- /dev/null +++ b/client_interface.go @@ -0,0 +1,197 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "context" + + "go.lsp.dev/jsonrpc2" +) + +const ( + MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification + MethodClientProgress ClientMethod = "$/progress" // bidirect client notification + MethodLogTrace ClientMethod = "$/logTrace" // client notification + MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification + MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification + MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification + MethodWindowShowMessage ClientMethod = "window/showMessage" // client notification + MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request + MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request + MethodWindowShowDocument ClientMethod = "window/showDocument" // client request + MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request + MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request + MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request + MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request + MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request + MethodWorkspaceDiagnosticRefresh ClientMethod = "workspace/diagnostic/refresh" // client request + MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request + MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request + MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request + MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request + MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request +) + +type Client interface { + CancelRequest(ctx context.Context, params *CancelParams) error + + Progress(ctx context.Context, params *ProgressParams) error + + LogTrace(ctx context.Context, params *LogTraceParams) error + + // TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data. + TelemetryEvent(ctx context.Context, params any) error + + // TextDocumentPublishDiagnostics diagnostics notification are sent from the server to the client to signal results of validation runs. + TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error + + // WindowLogMessage the log message notification is sent from the server to the client to ask the client to log a particular message. + WindowLogMessage(ctx context.Context, params *LogMessageParams) error + + // WindowShowMessage the show message notification is sent from a server to a client to ask the client to display a particular message in the user interface. + WindowShowMessage(ctx context.Context, params *ShowMessageParams) error + // ClientRegisterCapability the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side. + ClientRegisterCapability(ctx context.Context, params *RegistrationParams) error + + // ClientUnregisterCapability the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side. + ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) error + + // WindowShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser. + // + // @since 3.16.0 + WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) + + // WindowShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user. + WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) + + // WindowWorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server. + WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error + + // WorkspaceApplyEdit a request sent from the server to the client to modified certain resources. + WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) + + // WorkspaceCodeLensRefresh a request to refresh all code actions + // + // @since 3.16.0 + WorkspaceCodeLensRefresh(ctx context.Context) error + + // WorkspaceConfiguration the 'workspace/configuration' request is sent from the server to the client to fetch a certain configuration setting. This pull model replaces the old push model were the client signaled configuration + // change via an event. If the server still needs to react to configuration changes (since the server caches the result of `workspace/configuration` requests) the server should register for an empty configuration change event and empty the cache if such an event is received. + WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) ([]any, error) + + // WorkspaceDiagnosticRefresh the diagnostic refresh request definition. + // + // @since 3.17.0 + WorkspaceDiagnosticRefresh(ctx context.Context) error + + // WorkspaceFoldingRangeRefresh. + // + // @since 3.18.0 proposed + WorkspaceFoldingRangeRefresh(ctx context.Context) error + + // WorkspaceInlayHintRefresh. + // + // @since 3.17.0 + WorkspaceInlayHintRefresh(ctx context.Context) error + + // WorkspaceInlineValueRefresh. + // + // @since 3.17.0 + WorkspaceInlineValueRefresh(ctx context.Context) error + + // WorkspaceSemanticTokensRefresh. + // + // @since 3.16.0 + WorkspaceSemanticTokensRefresh(ctx context.Context) error + + // WorkspaceWorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders. + WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) +} + +// UnimplementedClient should be embedded to have forward compatible implementations. +type UnimplementedClient struct{} + +func (UnimplementedClient) CancelRequest(ctx context.Context, params *CancelParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) Progress(ctx context.Context, params *ProgressParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowLogMessage(ctx context.Context, params *LogMessageParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowShowMessage(ctx context.Context, params *ShowMessageParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceCodeLensRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) ([]any, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceDiagnosticRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceFoldingRangeRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceInlayHintRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceInlineValueRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceSemanticTokensRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) { + return nil, jsonrpc2.ErrInternal +} diff --git a/doc.go b/doc.go index 48737839..ccb35623 100644 --- a/doc.go +++ b/doc.go @@ -9,15 +9,15 @@ // It is a literal transcription, with unmodified comments, and only the changes // required to make it Go code. // -// - Names are uppercased to export them. +// Names are uppercased to export them. // -// - All fields have JSON tags added to correct the names. +// All fields have JSON tags added to correct the names. // -// - Fields marked with a ? are also marked as "omitempty". +// Fields marked with a ? are also marked as "omitempty". // -// - Fields that are "|| null" are made pointers. +// Fields that are "|| null" are made pointers. // -// - Fields that are string or number are left as string. +// Fields that are string or number are left as string. // -// - Fields that are type "number" are made float64. +// Fields that are type "number" are made float64. package protocol // import "go.lsp.dev/protocol" diff --git a/errors.go b/errors.go index 2f415cf7..51417d1d 100644 --- a/errors.go +++ b/errors.go @@ -1,9 +1,11 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors +// Copyright 2024 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol -import "go.lsp.dev/jsonrpc2" +import ( + "go.lsp.dev/jsonrpc2" +) const ( // LSPReservedErrorRangeStart is the start range of LSP reserved error codes. diff --git a/go.mod b/go.mod index 68663a43..9f65d1f3 100644 --- a/go.mod +++ b/go.mod @@ -3,16 +3,15 @@ module go.lsp.dev/protocol go 1.22.2 require ( - github.com/google/go-cmp v0.6.0 - github.com/segmentio/encoding v0.4.0 go.lsp.dev/jsonrpc2 v0.10.0 - go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 go.lsp.dev/uri v0.3.0 go.uber.org/zap v1.27.0 ) require ( + github.com/google/go-cmp v0.6.0 // indirect github.com/segmentio/asm v1.1.3 // indirect + github.com/segmentio/encoding v0.4.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect ) diff --git a/go.sum b/go.sum index b092fc5d..4241d3ae 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,6 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= go.lsp.dev/jsonrpc2 v0.10.0 h1:Pr/YcXJoEOTMc/b6OTmcR1DPJ3mSWl/SWiU1Cct6VmI= go.lsp.dev/jsonrpc2 v0.10.0/go.mod h1:fmEzIdXPi/rf6d4uFcayi8HpFP1nBF99ERP1htC72Ac= -go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 h1:hCzQgh6UcwbKgNSRurYWSqh8MufqRRPODRBblutn4TE= -go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2/go.mod h1:gtSHRuYfbCT0qnbLnovpie/WEmqyJ7T4n6VXiFMBtcw= go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo= go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= diff --git a/protocol.go b/protocol.go index 7d90b255..236a0497 100644 --- a/protocol.go +++ b/protocol.go @@ -5,12 +5,79 @@ package protocol import ( "context" + "encoding/json" + "io" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" ) +// MarshalFunc function type of marshal JSON data. +// +// Default is used [json.Marshal]. +type MarshalFunc func(v any) ([]byte, error) + +var marshal MarshalFunc = json.Marshal + +func RegiserMarshaler(fn MarshalFunc) { + marshal = fn +} + +// UnmarshalFunc function type of unmarshal JSON data. +// +// Default is used [json.Unmarshal]. +type UnmarshalFunc func(data []byte, v any) error + +var unmarshal UnmarshalFunc = json.Unmarshal + +func RegiserUnmarshaler(fn UnmarshalFunc) { + unmarshal = fn +} + +// JSONEncoder encodes and writes to the underlying data stream. +type JSONEncoder interface { + Encode(any) error +} + +// EncoderFunc function type of JSONEncoder. +// +// Default is used [json.NewEncoder] with SetEscapeHTML to false. +type EncoderFunc func(io.Writer) JSONEncoder + +var newEncoder EncoderFunc = defaultEncoder + +func defaultEncoder(w io.Writer) JSONEncoder { + enc := json.NewEncoder(w) + enc.SetEscapeHTML(false) + return enc +} + +func RegiserEncoder(fn EncoderFunc) { + newEncoder = fn +} + +// JSONDecoder decodes and reads to the underlying data stream. +type JSONDecoder interface { + Decode(v any) error +} + +// DecoderFunc function type of JSONDecoder. +// +// Default is used [json.NewDecoder]. +type DecoderFunc func(io.Reader) JSONDecoder + +var newDecoder DecoderFunc = defaultDecoder + +func defaultDecoder(r io.Reader) JSONDecoder { + dec := json.NewDecoder(r) + return dec +} + +func RegiserDecoder(fn DecoderFunc) { + newDecoder = fn +} + // NewServer returns the context in which client is embedded, jsonrpc2.Conn, and the Client. func NewServer(ctx context.Context, server Server, stream jsonrpc2.Stream, logger *zap.Logger) (context.Context, jsonrpc2.Conn, Client) { conn := jsonrpc2.NewConn(stream) diff --git a/server.go b/server.go index a7ce1717..1abb8464 100644 --- a/server.go +++ b/server.go @@ -8,11 +8,9 @@ import ( "context" "fmt" - "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" - "go.lsp.dev/pkg/xcontext" ) // ServerDispatcher returns a Server that dispatches LSP requests across the @@ -30,7 +28,7 @@ func ServerDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Server { func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := xcontext.Detach(ctx) + xctx := context.WithoutCancel(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -42,8 +40,8 @@ func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { // TODO: This code is wrong, it ignores handler and assumes non standard // request handles everything // non standard request should just be a layered handler. - var params interface{} - if err := json.Unmarshal(req.Params(), ¶ms); err != nil { + var params any + if err := unmarshal(req.Params(), ¶ms); err != nil { return replyParseError(ctx, reply, err) } @@ -63,42 +61,31 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := json.NewDecoder(bytes.NewReader(req.Params())) + dec := newDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodInitialize: // request - defer logger.Debug(MethodInitialize, zap.Error(err)) + case MethodServerProgress: // notification + defer logger.Debug(MethodServerProgress, zap.Error(err)) - var params InitializeParams + var params ProgressParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Initialize(ctx, ¶ms) + err := server.Progress(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodInitialized: // notification - defer logger.Debug(MethodInitialized, zap.Error(err)) + case MethodSetTrace: // notification + defer logger.Debug(MethodSetTrace, zap.Error(err)) - var params InitializedParams + var params SetTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.Initialized(ctx, ¶ms) - - return true, reply(ctx, nil, err) - - case MethodShutdown: // request - defer logger.Debug(MethodShutdown, zap.Error(err)) - - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) - } - - err := server.Shutdown(ctx) + err := server.SetTrace(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -113,147 +100,135 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodWorkDoneProgressCancel: // notification - defer logger.Debug(MethodWorkDoneProgressCancel, zap.Error(err)) + case MethodInitialized: // notification + defer logger.Debug(MethodInitialized, zap.Error(err)) - var params WorkDoneProgressCancelParams + var params InitializedParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WorkDoneProgressCancel(ctx, ¶ms) + err := server.Initialized(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodLogTrace: // notification - defer logger.Debug(MethodLogTrace, zap.Error(err)) + case MethodNotebookDocumentDidChange: // notification + defer logger.Debug(MethodNotebookDocumentDidChange, zap.Error(err)) - var params LogTraceParams + var params DidChangeNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.LogTrace(ctx, ¶ms) + err := server.NotebookDocumentDidChange(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodSetTrace: // notification - defer logger.Debug(MethodSetTrace, zap.Error(err)) + case MethodNotebookDocumentDidClose: // notification + defer logger.Debug(MethodNotebookDocumentDidClose, zap.Error(err)) - var params SetTraceParams + var params DidCloseNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.SetTrace(ctx, ¶ms) + err := server.NotebookDocumentDidClose(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentCodeAction: // request - defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) - - var params CodeActionParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.CodeAction(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentCodeLens: // request - defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) + case MethodNotebookDocumentDidOpen: // notification + defer logger.Debug(MethodNotebookDocumentDidOpen, zap.Error(err)) - var params CodeLensParams + var params DidOpenNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeLens(ctx, ¶ms) + err := server.NotebookDocumentDidOpen(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodCodeLensResolve: // request - defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) + case MethodNotebookDocumentDidSave: // notification + defer logger.Debug(MethodNotebookDocumentDidSave, zap.Error(err)) - var params CodeLens + var params DidSaveNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeLensResolve(ctx, ¶ms) + err := server.NotebookDocumentDidSave(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentColorPresentation: // request - defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) + case MethodTextDocumentDidChange: // notification + defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) - var params ColorPresentationParams + var params DidChangeTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.ColorPresentation(ctx, ¶ms) + err := server.TextDocumentDidChange(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentCompletion: // request - defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) + case MethodTextDocumentDidClose: // notification + defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) - var params CompletionParams + var params DidCloseTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Completion(ctx, ¶ms) + err := server.TextDocumentDidClose(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodCompletionItemResolve: // request - defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) + case MethodTextDocumentDidOpen: // notification + defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) - var params CompletionItem + var params DidOpenTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CompletionResolve(ctx, ¶ms) + err := server.TextDocumentDidOpen(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDeclaration: // request - defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) + case MethodTextDocumentDidSave: // notification + defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) - var params DeclarationParams + var params DidSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Declaration(ctx, ¶ms) + err := server.TextDocumentDidSave(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDefinition: // request - defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) + case MethodTextDocumentWillSave: // notification + defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) - var params DefinitionParams + var params WillSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Definition(ctx, ¶ms) + err := server.TextDocumentWillSave(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDidChange: // notification - defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) + case MethodWindowWorkDoneProgressCancel: // notification + defer logger.Debug(MethodWindowWorkDoneProgressCancel, zap.Error(err)) - var params DidChangeTextDocumentParams + var params WorkDoneProgressCancelParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidChange(ctx, ¶ms) + err := server.WindowWorkDoneProgressCancel(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -265,7 +240,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.DidChangeConfiguration(ctx, ¶ms) + err := server.WorkspaceDidChangeConfiguration(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -277,7 +252,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.DidChangeWatchedFiles(ctx, ¶ms) + err := server.WorkspaceDidChangeWatchedFiles(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -289,380 +264,404 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.DidChangeWorkspaceFolders(ctx, ¶ms) + err := server.WorkspaceDidChangeWorkspaceFolders(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDidClose: // notification - defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) + case MethodWorkspaceDidCreateFiles: // notification + defer logger.Debug(MethodWorkspaceDidCreateFiles, zap.Error(err)) - var params DidCloseTextDocumentParams + var params CreateFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidClose(ctx, ¶ms) + err := server.WorkspaceDidCreateFiles(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDidOpen: // notification - defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) + case MethodWorkspaceDidDeleteFiles: // notification + defer logger.Debug(MethodWorkspaceDidDeleteFiles, zap.Error(err)) - var params DidOpenTextDocumentParams + var params DeleteFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidOpen(ctx, ¶ms) + err := server.WorkspaceDidDeleteFiles(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDidSave: // notification - defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) + case MethodWorkspaceDidRenameFiles: // notification + defer logger.Debug(MethodWorkspaceDidRenameFiles, zap.Error(err)) - var params DidSaveTextDocumentParams + var params RenameFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidSave(ctx, ¶ms) + err := server.WorkspaceDidRenameFiles(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDocumentColor: // request - defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) + case MethodCallHierarchyIncomingCalls: // request + defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) - var params DocumentColorParams + var params CallHierarchyIncomingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentColor(ctx, ¶ms) + resp, err := server.CallHierarchyIncomingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentHighlight: // request - defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) + case MethodCallHierarchyOutgoingCalls: // request + defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) - var params DocumentHighlightParams + var params CallHierarchyOutgoingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentHighlight(ctx, ¶ms) + resp, err := server.CallHierarchyOutgoingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentLink: // request - defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) + case MethodCodeActionResolve: // request + defer logger.Debug(MethodCodeActionResolve, zap.Error(err)) - var params DocumentLinkParams + var params CodeAction if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentLink(ctx, ¶ms) + resp, err := server.CodeActionResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDocumentLinkResolve: // request - defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) + case MethodCodeLensResolve: // request + defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) - var params DocumentLink + var params CodeLens if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentLinkResolve(ctx, ¶ms) + resp, err := server.CodeLensResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentSymbol: // request - defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) + case MethodCompletionItemResolve: // request + defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) - var params DocumentSymbolParams + var params CompletionItem if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentSymbol(ctx, ¶ms) + resp, err := server.CompletionItemResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceExecuteCommand: // request - defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) + case MethodDocumentLinkResolve: // request + defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) - var params ExecuteCommandParams + var params DocumentLink if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.ExecuteCommand(ctx, ¶ms) + resp, err := server.DocumentLinkResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFoldingRange: // request - defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) + case MethodInitialize: // request + defer logger.Debug(MethodInitialize, zap.Error(err)) - var params FoldingRangeParams + var params InitializeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.FoldingRanges(ctx, ¶ms) + resp, err := server.Initialize(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFormatting: // request - defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) + case MethodInlayHintResolve: // request + defer logger.Debug(MethodInlayHintResolve, zap.Error(err)) - var params DocumentFormattingParams + var params InlayHint if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Formatting(ctx, ¶ms) + resp, err := server.InlayHintResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentHover: // request - defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) + case MethodShutdown: // request + defer logger.Debug(MethodShutdown, zap.Error(err)) - var params HoverParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) } - resp, err := server.Hover(ctx, ¶ms) + err := server.Shutdown(ctx) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentImplementation: // request - defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) + case MethodTextDocumentCodeAction: // request + defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) - var params ImplementationParams + var params CodeActionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Implementation(ctx, ¶ms) + resp, err := server.TextDocumentCodeAction(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentOnTypeFormatting: // request - defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) + case MethodTextDocumentCodeLens: // request + defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) - var params DocumentOnTypeFormattingParams + var params CodeLensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.OnTypeFormatting(ctx, ¶ms) + resp, err := server.TextDocumentCodeLens(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentPrepareRename: // request - defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) + case MethodTextDocumentColorPresentation: // request + defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) - var params PrepareRenameParams + var params ColorPresentationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.PrepareRename(ctx, ¶ms) + resp, err := server.TextDocumentColorPresentation(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentRangeFormatting: // request - defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) + case MethodTextDocumentCompletion: // request + defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) - var params DocumentRangeFormattingParams + var params CompletionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.RangeFormatting(ctx, ¶ms) + resp, err := server.TextDocumentCompletion(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentReferences: // request - defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) + case MethodTextDocumentDeclaration: // request + defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) - var params ReferenceParams + var params DeclarationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.References(ctx, ¶ms) + resp, err := server.TextDocumentDeclaration(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentRename: // request - defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) + case MethodTextDocumentDefinition: // request + defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) - var params RenameParams + var params DefinitionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Rename(ctx, ¶ms) + resp, err := server.TextDocumentDefinition(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSignatureHelp: // request - defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) + case MethodTextDocumentDiagnostic: // request + defer logger.Debug(MethodTextDocumentDiagnostic, zap.Error(err)) - var params SignatureHelpParams + var params DocumentDiagnosticParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SignatureHelp(ctx, ¶ms) + resp, err := server.TextDocumentDiagnostic(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceSymbol: // request - defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) + case MethodTextDocumentDocumentColor: // request + defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) - var params WorkspaceSymbolParams + var params DocumentColorParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Symbols(ctx, ¶ms) + resp, err := server.TextDocumentDocumentColor(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentTypeDefinition: // request - defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) + case MethodTextDocumentDocumentHighlight: // request + defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) - var params TypeDefinitionParams + var params DocumentHighlightParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TypeDefinition(ctx, ¶ms) + resp, err := server.TextDocumentDocumentHighlight(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentWillSave: // notification - defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) + case MethodTextDocumentDocumentLink: // request + defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) - var params WillSaveTextDocumentParams + var params DocumentLinkParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WillSave(ctx, ¶ms) + resp, err := server.TextDocumentDocumentLink(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentWillSaveWaitUntil: // request - defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) + case MethodTextDocumentDocumentSymbol: // request + defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) - var params WillSaveTextDocumentParams + var params DocumentSymbolParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillSaveWaitUntil(ctx, ¶ms) + resp, err := server.TextDocumentDocumentSymbol(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodShowDocument: // request - defer logger.Debug(MethodShowDocument, zap.Error(err)) + case MethodTextDocumentFoldingRange: // request + defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) - var params ShowDocumentParams + var params FoldingRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.ShowDocument(ctx, ¶ms) + resp, err := server.TextDocumentFoldingRange(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWillCreateFiles: // request - defer logger.Debug(MethodWillCreateFiles, zap.Error(err)) + case MethodTextDocumentFormatting: // request + defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) - var params CreateFilesParams + var params DocumentFormattingParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillCreateFiles(ctx, ¶ms) + resp, err := server.TextDocumentFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDidCreateFiles: // notification - defer logger.Debug(MethodDidCreateFiles, zap.Error(err)) + case MethodTextDocumentHover: // request + defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) - var params CreateFilesParams + var params HoverParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidCreateFiles(ctx, ¶ms) + resp, err := server.TextDocumentHover(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodWillRenameFiles: // request - defer logger.Debug(MethodWillRenameFiles, zap.Error(err)) + case MethodTextDocumentImplementation: // request + defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) - var params RenameFilesParams + var params ImplementationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillRenameFiles(ctx, ¶ms) + resp, err := server.TextDocumentImplementation(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDidRenameFiles: // notification - defer logger.Debug(MethodDidRenameFiles, zap.Error(err)) + case MethodTextDocumentInlayHint: // request + defer logger.Debug(MethodTextDocumentInlayHint, zap.Error(err)) - var params RenameFilesParams + var params InlayHintParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidRenameFiles(ctx, ¶ms) + resp, err := server.TextDocumentInlayHint(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodWillDeleteFiles: // request - defer logger.Debug(MethodWillDeleteFiles, zap.Error(err)) + case MethodTextDocumentInlineCompletion: // request + defer logger.Debug(MethodTextDocumentInlineCompletion, zap.Error(err)) - var params DeleteFilesParams + var params InlineCompletionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillDeleteFiles(ctx, ¶ms) + resp, err := server.TextDocumentInlineCompletion(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDidDeleteFiles: // notification - defer logger.Debug(MethodDidDeleteFiles, zap.Error(err)) + case MethodTextDocumentInlineValue: // request + defer logger.Debug(MethodTextDocumentInlineValue, zap.Error(err)) - var params DeleteFilesParams + var params InlineValueParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidDeleteFiles(ctx, ¶ms) + resp, err := server.TextDocumentInlineValue(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodCodeLensRefresh: // request - defer logger.Debug(MethodCodeLensRefresh, zap.Error(err)) + case MethodTextDocumentLinkedEditingRange: // request + defer logger.Debug(MethodTextDocumentLinkedEditingRange, zap.Error(err)) - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + var params LinkedEditingRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) } - err := server.CodeLensRefresh(ctx) + resp, err := server.TextDocumentLinkedEditingRange(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) + + case MethodTextDocumentMoniker: // request + defer logger.Debug(MethodTextDocumentMoniker, zap.Error(err)) + + var params MonikerParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentMoniker(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentOnTypeFormatting: // request + defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) + + var params DocumentOnTypeFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentOnTypeFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) case MethodTextDocumentPrepareCallHierarchy: // request defer logger.Debug(MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) @@ -672,102 +671,271 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.PrepareCallHierarchy(ctx, ¶ms) + resp, err := server.TextDocumentPrepareCallHierarchy(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCallHierarchyIncomingCalls: // request - defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) + case MethodTextDocumentPrepareRename: // request + defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) - var params CallHierarchyIncomingCallsParams + var params PrepareRenameParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.IncomingCalls(ctx, ¶ms) + resp, err := server.TextDocumentPrepareRename(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCallHierarchyOutgoingCalls: // request - defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) + case MethodTextDocumentPrepareTypeHierarchy: // request + defer logger.Debug(MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) - var params CallHierarchyOutgoingCallsParams + var params TypeHierarchyPrepareParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.OutgoingCalls(ctx, ¶ms) + resp, err := server.TextDocumentPrepareTypeHierarchy(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensFull: // request - defer logger.Debug(MethodSemanticTokensFull, zap.Error(err)) + case MethodTextDocumentRangeFormatting: // request + defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) + + var params DocumentRangeFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentRangeFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentRangesFormatting: // request + defer logger.Debug(MethodTextDocumentRangesFormatting, zap.Error(err)) + + var params DocumentRangesFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentRangesFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentReferences: // request + defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) + + var params ReferenceParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentReferences(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentRename: // request + defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) + + var params RenameParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentRename(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSelectionRange: // request + defer logger.Debug(MethodTextDocumentSelectionRange, zap.Error(err)) + + var params SelectionRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentSelectionRange(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSemanticTokensFull: // request + defer logger.Debug(MethodTextDocumentSemanticTokensFull, zap.Error(err)) var params SemanticTokensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SemanticTokensFull(ctx, ¶ms) + resp, err := server.TextDocumentSemanticTokensFull(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensFullDelta: // request - defer logger.Debug(MethodSemanticTokensFullDelta, zap.Error(err)) + case MethodTextDocumentSemanticTokensFullDelta: // request + defer logger.Debug(MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) var params SemanticTokensDeltaParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SemanticTokensFullDelta(ctx, ¶ms) + resp, err := server.TextDocumentSemanticTokensFullDelta(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensRange: // request - defer logger.Debug(MethodSemanticTokensRange, zap.Error(err)) + case MethodTextDocumentSemanticTokensRange: // request + defer logger.Debug(MethodTextDocumentSemanticTokensRange, zap.Error(err)) var params SemanticTokensRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SemanticTokensRange(ctx, ¶ms) + resp, err := server.TextDocumentSemanticTokensRange(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensRefresh: // request - defer logger.Debug(MethodSemanticTokensRefresh, zap.Error(err)) + case MethodTextDocumentSignatureHelp: // request + defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + var params SignatureHelpParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) } - err := server.SemanticTokensRefresh(ctx) + resp, err := server.TextDocumentSignatureHelp(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodLinkedEditingRange: // request - defer logger.Debug(MethodLinkedEditingRange, zap.Error(err)) + case MethodTextDocumentTypeDefinition: // request + defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) - var params LinkedEditingRangeParams + var params TypeDefinitionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.LinkedEditingRange(ctx, ¶ms) + resp, err := server.TextDocumentTypeDefinition(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodMoniker: // request - defer logger.Debug(MethodMoniker, zap.Error(err)) + case MethodTextDocumentWillSaveWaitUntil: // request + defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - var params MonikerParams + var params WillSaveTextDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentWillSaveWaitUntil(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTypeHierarchySubtypes: // request + defer logger.Debug(MethodTypeHierarchySubtypes, zap.Error(err)) + + var params TypeHierarchySubtypesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TypeHierarchySubtypes(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTypeHierarchySupertypes: // request + defer logger.Debug(MethodTypeHierarchySupertypes, zap.Error(err)) + + var params TypeHierarchySupertypesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TypeHierarchySupertypes(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceDiagnostic: // request + defer logger.Debug(MethodWorkspaceDiagnostic, zap.Error(err)) + + var params WorkspaceDiagnosticParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceDiagnostic(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceExecuteCommand: // request + defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) + + var params ExecuteCommandParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceExecuteCommand(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceSymbol: // request + defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) + + var params WorkspaceSymbolParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceSymbol(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillCreateFiles: // request + defer logger.Debug(MethodWorkspaceWillCreateFiles, zap.Error(err)) + + var params CreateFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceWillCreateFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillDeleteFiles: // request + defer logger.Debug(MethodWorkspaceWillDeleteFiles, zap.Error(err)) + + var params DeleteFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceWillDeleteFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillRenameFiles: // request + defer logger.Debug(MethodWorkspaceWillRenameFiles, zap.Error(err)) + + var params RenameFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceWillRenameFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceSymbolResolve: // request + defer logger.Debug(MethodWorkspaceSymbolResolve, zap.Error(err)) + + var params WorkspaceSymbol if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Moniker(ctx, ¶ms) + resp, err := server.WorkspaceSymbolResolve(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -776,262 +944,317 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, } } -// Server represents a Language Server Protocol server. -type Server interface { - Initialize(ctx context.Context, params *InitializeParams) (result *InitializeResult, err error) - Initialized(ctx context.Context, params *InitializedParams) (err error) - Shutdown(ctx context.Context) (err error) - Exit(ctx context.Context) (err error) - WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) - LogTrace(ctx context.Context, params *LogTraceParams) (err error) - SetTrace(ctx context.Context, params *SetTraceParams) (err error) - CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) - CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) - CodeLensResolve(ctx context.Context, params *CodeLens) (result *CodeLens, err error) - ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) - Completion(ctx context.Context, params *CompletionParams) (result *CompletionList, err error) - CompletionResolve(ctx context.Context, params *CompletionItem) (result *CompletionItem, err error) - Declaration(ctx context.Context, params *DeclarationParams) (result []Location /* Declaration | DeclarationLink[] | null */, err error) - Definition(ctx context.Context, params *DefinitionParams) (result []Location /* Definition | DefinitionLink[] | null */, err error) - DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) - DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) - DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) - DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) - DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) - DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) - DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) - DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) - DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) - DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) - DocumentLinkResolve(ctx context.Context, params *DocumentLink) (result *DocumentLink, err error) - DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{} /* []SymbolInformation | []DocumentSymbol */, err error) - ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) - FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) - Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) - Hover(ctx context.Context, params *HoverParams) (result *Hover, err error) - Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) - OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) - PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) - RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) - References(ctx context.Context, params *ReferenceParams) (result []Location, err error) - Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) - SignatureHelp(ctx context.Context, params *SignatureHelpParams) (result *SignatureHelp, err error) - Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) - TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) - WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) - WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) - ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) - WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) - DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) - WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) - DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) - WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) - DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) - CodeLensRefresh(ctx context.Context) (err error) - PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) - IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) - OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) - SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) - SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{} /* SemanticTokens | SemanticTokensDelta */, err error) - SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) - SemanticTokensRefresh(ctx context.Context) (err error) - LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) - Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) - Request(ctx context.Context, method string, params interface{}) (result interface{}, err error) -} - -// list of server methods. -const ( - // MethodCancelRequest method name of "$/cancelRequest". - MethodCancelRequest = "$/cancelRequest" - - // MethodInitialize method name of "initialize". - MethodInitialize = "initialize" - - // MethodInitialized method name of "initialized". - MethodInitialized = "initialized" - - // MethodShutdown method name of "shutdown". - MethodShutdown = "shutdown" - - // MethodExit method name of "exit". - MethodExit = "exit" - - // MethodWorkDoneProgressCancel method name of "window/workDoneProgress/cancel". - MethodWorkDoneProgressCancel = "window/workDoneProgress/cancel" - - // MethodLogTrace method name of "$/logTrace". - MethodLogTrace = "$/logTrace" - - // MethodSetTrace method name of "$/setTrace". - MethodSetTrace = "$/setTrace" - - // MethodTextDocumentCodeAction method name of "textDocument/codeAction". - MethodTextDocumentCodeAction = "textDocument/codeAction" - - // MethodTextDocumentCodeLens method name of "textDocument/codeLens". - MethodTextDocumentCodeLens = "textDocument/codeLens" - - // MethodCodeLensResolve method name of "codeLens/resolve". - MethodCodeLensResolve = "codeLens/resolve" - - // MethodTextDocumentColorPresentation method name of "textDocument/colorPresentation". - MethodTextDocumentColorPresentation = "textDocument/colorPresentation" - - // MethodTextDocumentCompletion method name of "textDocument/completion". - MethodTextDocumentCompletion = "textDocument/completion" - - // MethodCompletionItemResolve method name of "completionItem/resolve". - MethodCompletionItemResolve = "completionItem/resolve" - - // MethodTextDocumentDeclaration method name of "textDocument/declaration". - MethodTextDocumentDeclaration = "textDocument/declaration" +// server implements a Language Server Protocol server. +type server struct { + jsonrpc2.Conn - // MethodTextDocumentDefinition method name of "textDocument/definition". - MethodTextDocumentDefinition = "textDocument/definition" + logger *zap.Logger +} - // MethodTextDocumentDidChange method name of "textDocument/didChange". - MethodTextDocumentDidChange = "textDocument/didChange" +var _ Server = (*server)(nil) - // MethodWorkspaceDidChangeConfiguration method name of "workspace/didChangeConfiguration". - MethodWorkspaceDidChangeConfiguration = "workspace/didChangeConfiguration" +func (s *server) CancelRequest(ctx context.Context, params *CancelParams) (err error) { + s.logger.Debug("notify " + MethodClientCancelRequest) + defer s.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) - // MethodWorkspaceDidChangeWatchedFiles method name of "workspace/didChangeWatchedFiles". - MethodWorkspaceDidChangeWatchedFiles = "workspace/didChangeWatchedFiles" + return s.Conn.Notify(ctx, MethodClientCancelRequest, params) +} - // MethodWorkspaceDidChangeWorkspaceFolders method name of "workspace/didChangeWorkspaceFolders". - MethodWorkspaceDidChangeWorkspaceFolders = "workspace/didChangeWorkspaceFolders" +// Progress is the base protocol offers also support to report progress in a generic fashion. +// +// This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and +// partial result progress to support streaming of results. +// +// @since 3.16.0. +func (s *server) Progress(ctx context.Context, params *ProgressParams) (err error) { + s.logger.Debug("notify " + MethodClientProgress) + defer s.logger.Debug("end "+MethodClientProgress, zap.Error(err)) - // MethodTextDocumentDidClose method name of "textDocument/didClose". - MethodTextDocumentDidClose = "textDocument/didClose" + return s.Conn.Notify(ctx, MethodClientProgress, params) +} - // MethodTextDocumentDidOpen method name of "textDocument/didOpen". - MethodTextDocumentDidOpen = "textDocument/didOpen" +// SetTrace a notification that should be used by the client to modify the trace setting of the server. +// +// @since 3.16.0. +func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { + s.logger.Debug("notify " + MethodSetTrace) + defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) - // MethodTextDocumentDidSave method name of "textDocument/didSave". - MethodTextDocumentDidSave = "textDocument/didSave" + return s.Conn.Notify(ctx, MethodSetTrace, params) +} - // MethodTextDocumentDocumentColor method name of"textDocument/documentColor". - MethodTextDocumentDocumentColor = "textDocument/documentColor" +// Exit a notification to ask the server to exit its process. +// +// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. +func (s *server) Exit(ctx context.Context) (err error) { + s.logger.Debug("notify " + MethodExit) + defer s.logger.Debug("end "+MethodExit, zap.Error(err)) - // MethodTextDocumentDocumentHighlight method name of "textDocument/documentHighlight". - MethodTextDocumentDocumentHighlight = "textDocument/documentHighlight" + return s.Conn.Notify(ctx, MethodExit, nil) +} - // MethodTextDocumentDocumentLink method name of "textDocument/documentLink". - MethodTextDocumentDocumentLink = "textDocument/documentLink" +// Initialized sends the notification from the client to the server after the client received the result of the +// initialize request but before the client is sending any other request or notification to the server. +// +// The server can use the initialized notification for example to dynamically register capabilities. +// The initialized notification may only be sent once. +func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { + s.logger.Debug("notify " + MethodInitialized) + defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) - // MethodDocumentLinkResolve method name of "documentLink/resolve". - MethodDocumentLinkResolve = "documentLink/resolve" + return s.Conn.Notify(ctx, MethodInitialized, params) +} - // MethodTextDocumentDocumentSymbol method name of "textDocument/documentSymbol". - MethodTextDocumentDocumentSymbol = "textDocument/documentSymbol" +func (s *server) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidChange) + defer s.logger.Debug("end "+MethodNotebookDocumentDidChange, zap.Error(err)) - // MethodWorkspaceExecuteCommand method name of "workspace/executeCommand". - MethodWorkspaceExecuteCommand = "workspace/executeCommand" + return s.Conn.Notify(ctx, MethodNotebookDocumentDidChange, params) +} - // MethodTextDocumentFoldingRange method name of "textDocument/foldingRange". - MethodTextDocumentFoldingRange = "textDocument/foldingRange" +// NotebookDocumentDidClose a notification sent when a notebook closes. +// +// @since 3.17.0 +func (s *server) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidClose) + defer s.logger.Debug("end "+MethodNotebookDocumentDidClose, zap.Error(err)) - // MethodTextDocumentFormatting method name of "textDocument/formatting". - MethodTextDocumentFormatting = "textDocument/formatting" + return s.Conn.Notify(ctx, MethodNotebookDocumentDidClose, params) +} - // MethodTextDocumentHover method name of "textDocument/hover". - MethodTextDocumentHover = "textDocument/hover" +// NotebookDocumentDidOpen a notification sent when a notebook opens. +// +// @since 3.17.0 +func (s *server) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidOpen) + defer s.logger.Debug("end "+MethodNotebookDocumentDidOpen, zap.Error(err)) - // MethodTextDocumentImplementation method name of "textDocument/implementation". - MethodTextDocumentImplementation = "textDocument/implementation" + return s.Conn.Notify(ctx, MethodNotebookDocumentDidOpen, params) +} - // MethodTextDocumentOnTypeFormatting method name of "textDocument/onTypeFormatting". - MethodTextDocumentOnTypeFormatting = "textDocument/onTypeFormatting" +// NotebookDocumentDidSave a notification sent when a notebook document is saved. +// +// @since 3.17.0 +func (s *server) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidSave) + defer s.logger.Debug("end "+MethodNotebookDocumentDidSave, zap.Error(err)) - // MethodTextDocumentPrepareRename method name of "textDocument/prepareRename". - MethodTextDocumentPrepareRename = "textDocument/prepareRename" + return s.Conn.Notify(ctx, MethodNotebookDocumentDidSave, params) +} - // MethodTextDocumentRangeFormatting method name of "textDocument/rangeFormatting". - MethodTextDocumentRangeFormatting = "textDocument/rangeFormatting" +// DidChange sends the notification from the client to the server to signal changes to a text document. +// +// In 2.0 the shape of the params has changed to include proper version numbers and language ids. +func (s *server) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { + s.logger.Debug("notify " + MethodTextDocumentDidChange) + defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) - // MethodTextDocumentReferences method name of "textDocument/references". - MethodTextDocumentReferences = "textDocument/references" + return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) +} - // MethodTextDocumentRename method name of "textDocument/rename". - MethodTextDocumentRename = "textDocument/rename" +// DidClose sends the notification from the client to the server when the document got closed in the client. +// +// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). +// As with the open notification the close notification is about managing the document’s content. +// Receiving a close notification doesn’t mean that the document was open in an editor before. +// +// A close notification requires a previous open notification to be sent. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidClose) + defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) - // MethodTextDocumentSignatureHelp method name of "textDocument/signatureHelp". - MethodTextDocumentSignatureHelp = "textDocument/signatureHelp" + return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) +} + +// DidOpen sends the open notification from the client to the server to signal newly opened text documents. +// +// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. +// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. +// +// An open notification must not be sent more than once without a corresponding close notification send before. +// This means open and close notification must be balanced and the max open count for a particular textDocument is one. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidOpen) + defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) +} + +// DidSave sends the notification from the client to the server when the document was saved in the client. +func (s *server) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidSave) + defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) +} + +// WillSave sends the notification from the client to the server before the document is actually saved. +func (s *server) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentWillSave) + defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) +} + +// WindowWorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the +// server side using the "window/workDoneProgress/create". +func (s *server) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { + s.logger.Debug("call " + MethodWindowWorkDoneProgressCancel) + defer s.logger.Debug("end "+MethodWindowWorkDoneProgressCancel, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWindowWorkDoneProgressCancel, params) +} + +// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. +func (s *server) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) +} + +// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. +// +// It is recommended that servers register for these file events using the registration mechanism. +// In former implementations clients pushed file events without the server actively asking for it. +func (s *server) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) - // MethodWorkspaceSymbol method name of "workspace/symbol". - MethodWorkspaceSymbol = "workspace/symbol" + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) +} - // MethodTextDocumentTypeDefinition method name of "textDocument/typeDefinition". - MethodTextDocumentTypeDefinition = "textDocument/typeDefinition" +// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. +// +// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; +// or if the server has registered itself to receive this notification. +// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. +// +// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). +func (s *server) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) - // MethodTextDocumentWillSave method name of "textDocument/willSave". - MethodTextDocumentWillSave = "textDocument/willSave" + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) +} - // MethodTextDocumentWillSaveWaitUntil method name of "textDocument/willSaveWaitUntil". - MethodTextDocumentWillSaveWaitUntil = "textDocument/willSaveWaitUntil" +// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. +// +// @since 3.16.0. +func (s *server) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidCreateFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidCreateFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidCreateFiles, params) +} + +// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. +// +// @since 3.16.0. +func (s *server) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidDeleteFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidDeleteFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidDeleteFiles, params) +} + +// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. +// +// @since 3.16.0. +func (s *server) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidRenameFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidRenameFiles, zap.Error(err)) - // MethodShowDocument method name of "window/showDocument". - MethodShowDocument = "window/showDocument" + return s.Conn.Notify(ctx, MethodWorkspaceDidRenameFiles, params) +} - // MethodWillCreateFiles method name of "workspace/willCreateFiles". - MethodWillCreateFiles = "workspace/willCreateFiles" +// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (_ []*CallHierarchyIncomingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) - // MethodDidCreateFiles method name of "workspace/didCreateFiles". - MethodDidCreateFiles = "workspace/didCreateFiles" + var result []*CallHierarchyIncomingCall + if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { + return nil, err + } - // MethodWillRenameFiles method name of "workspace/willRenameFiles". - MethodWillRenameFiles = "workspace/willRenameFiles" + return result, nil +} - // MethodDidRenameFiles method name of "workspace/didRenameFiles". - MethodDidRenameFiles = "workspace/didRenameFiles" +// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (_ []*CallHierarchyOutgoingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) - // MethodWillDeleteFiles method name of "workspace/willDeleteFiles". - MethodWillDeleteFiles = "workspace/willDeleteFiles" + var result []*CallHierarchyOutgoingCall + if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { + return nil, err + } - // MethodDidDeleteFiles method name of "workspace/didDeleteFiles". - MethodDidDeleteFiles = "workspace/didDeleteFiles" + return result, nil +} - // MethodCodeLensRefresh method name of "workspace/codeLens/refresh". - MethodCodeLensRefresh = "workspace/codeLens/refresh" +func (s *server) CodeActionResolve(ctx context.Context, params *CodeAction) (_ *CodeAction, err error) { + s.logger.Debug("call " + MethodCodeActionResolve) + defer s.logger.Debug("end "+MethodCodeActionResolve, zap.Error(err)) - // MethodTextDocumentPrepareCallHierarchy method name of "textDocument/prepareCallHierarchy". - MethodTextDocumentPrepareCallHierarchy = "textDocument/prepareCallHierarchy" + var result *CodeAction + if err := Call(ctx, s.Conn, MethodCodeActionResolve, params, &result); err != nil { + return nil, err + } - // MethodCallHierarchyIncomingCalls method name of "callHierarchy/incomingCalls". - MethodCallHierarchyIncomingCalls = "callHierarchy/incomingCalls" + return result, nil +} - // MethodCallHierarchyOutgoingCalls method name of "callHierarchy/outgoingCalls". - MethodCallHierarchyOutgoingCalls = "callHierarchy/outgoingCalls" +// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. +func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { + s.logger.Debug("call " + MethodCodeLensResolve) + defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) - // MethodSemanticTokensFull method name of "textDocument/semanticTokens/full". - MethodSemanticTokensFull = "textDocument/semanticTokens/full" + var result *CodeLens + if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { + return nil, err + } - // MethodSemanticTokensFullDelta method name of "textDocument/semanticTokens/full/delta". - MethodSemanticTokensFullDelta = "textDocument/semanticTokens/full/delta" + return result, nil +} - // MethodSemanticTokensRange method name of "textDocument/semanticTokens/range". - MethodSemanticTokensRange = "textDocument/semanticTokens/range" +// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. +func (s *server) CompletionItemResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { + s.logger.Debug("call " + MethodCompletionItemResolve) + defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) - // MethodSemanticTokensRefresh method name of "workspace/semanticTokens/refresh". - MethodSemanticTokensRefresh = "workspace/semanticTokens/refresh" + var result *CompletionItem + if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { + return nil, err + } - // MethodLinkedEditingRange method name of "textDocument/linkedEditingRange". - MethodLinkedEditingRange = "textDocument/linkedEditingRange" + return result, nil +} - // MethodMoniker method name of "textDocument/moniker". - MethodMoniker = "textDocument/moniker" -) +// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. +func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { + s.logger.Debug("call " + MethodDocumentLinkResolve) + defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) -// server implements a Language Server Protocol server. -type server struct { - jsonrpc2.Conn + var result *DocumentLink + if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { + return nil, err + } - logger *zap.Logger + return result, nil } -var _ Server = (*server)(nil) - // Initialize sents the request as the first request from the client to the server. // // If the server receives a request or notification before the initialize request it should act as follows: @@ -1057,16 +1280,16 @@ func (s *server) Initialize(ctx context.Context, params *InitializeParams) (_ *I return result, nil } -// Initialized sends the notification from the client to the server after the client received the result of the -// initialize request but before the client is sending any other request or notification to the server. -// -// The server can use the initialized notification for example to dynamically register capabilities. -// The initialized notification may only be sent once. -func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { - s.logger.Debug("notify " + MethodInitialized) - defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) +func (s *server) InlayHintResolve(ctx context.Context, params *InlayHint) (_ *InlayHint, err error) { + s.logger.Debug("call " + MethodInlayHintResolve) + defer s.logger.Debug("end "+MethodInlayHintResolve, zap.Error(err)) - return s.Conn.Notify(ctx, MethodInitialized, params) + var result *InlayHint + if err := Call(ctx, s.Conn, MethodInlayHintResolve, params, &result); err != nil { + return nil, err + } + + return result, nil } // Shutdown sents the request from the client to the server. @@ -1083,50 +1306,6 @@ func (s *server) Shutdown(ctx context.Context) (err error) { return Call(ctx, s.Conn, MethodShutdown, nil, nil) } -// Exit a notification to ask the server to exit its process. -// -// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. -func (s *server) Exit(ctx context.Context) (err error) { - s.logger.Debug("notify " + MethodExit) - defer s.logger.Debug("end "+MethodExit, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodExit, nil) -} - -// LogTrace a notification to log the trace of the server’s execution. -// -// The amount and content of these notifications depends on the current trace configuration. -// -// If trace is "off", the server should not send any logTrace notification. If trace is "message", -// the server should not add the "verbose" field in the LogTraceParams. -// -// @since 3.16.0. -func (s *server) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { - s.logger.Debug("notify " + MethodLogTrace) - defer s.logger.Debug("end "+MethodLogTrace, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodLogTrace, params) -} - -// SetTrace a notification that should be used by the client to modify the trace setting of the server. -// -// @since 3.16.0. -func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { - s.logger.Debug("notify " + MethodSetTrace) - defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodSetTrace, params) -} - -// WorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the -// server side using the "window/workDoneProgress/create". -func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { - s.logger.Debug("call " + MethodWorkDoneProgressCancel) - defer s.logger.Debug("end "+MethodWorkDoneProgressCancel, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkDoneProgressCancel, params) -} - // CodeAction sends the request is from the client to the server to compute commands for a given text document and range. // // These commands are typically code fixes to either fix problems or to beautify/refactor code. The result of a `textDocument/codeAction` @@ -1135,10 +1314,11 @@ func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDonePro // To ensure that a server is useful in many clients the commands specified in a code actions should be handled by the // server and not by the client (see `workspace/executeCommand` and `ServerCapabilities.executeCommandProvider`). // If the client supports providing edits with a code action then the mode should be used. -func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) { +func (s *server) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (_ *TextDocumentCodeActionResult, err error) { s.logger.Debug("call " + MethodTextDocumentCodeAction) defer s.logger.Debug("end "+MethodTextDocumentCodeAction, zap.Error(err)) + var result *TextDocumentCodeActionResult if err := Call(ctx, s.Conn, MethodTextDocumentCodeAction, params, &result); err != nil { return nil, err } @@ -1147,10 +1327,11 @@ func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (resu } // CodeLens sends the request from the client to the server to compute code lenses for a given text document. -func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) { +func (s *server) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) (_ []*CodeLens, err error) { s.logger.Debug("call " + MethodTextDocumentCodeLens) defer s.logger.Debug("end "+MethodTextDocumentCodeLens, zap.Error(err)) + var result []*CodeLens if err := Call(ctx, s.Conn, MethodTextDocumentCodeLens, params, &result); err != nil { return nil, err } @@ -1158,29 +1339,17 @@ func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (result [ return result, nil } -// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. -func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { - s.logger.Debug("call " + MethodCodeLensResolve) - defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) - - var result *CodeLens - if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // ColorPresentation sends the request from the client to the server to obtain a list of presentations for a color value at a given location. // // # Clients can use the result to // // - modify a color reference. // - show in a color picker and let users pick one of the presentations. -func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) { +func (s *server) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) (_ []*ColorPresentation, err error) { s.logger.Debug("call " + MethodTextDocumentColorPresentation) defer s.logger.Debug("end "+MethodTextDocumentColorPresentation, zap.Error(err)) + var result []*ColorPresentation if err := Call(ctx, s.Conn, MethodTextDocumentColorPresentation, params, &result); err != nil { return nil, err } @@ -1201,11 +1370,11 @@ func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentatio // The returned completion item should have the documentation property filled in. The request can delay the computation of // the `detail` and `documentation` properties. However, properties that are needed for the initial sorting and filtering, // like `sortText`, `filterText`, `insertText`, and `textEdit` must be provided in the `textDocument/completion` response and must not be changed during resolve. -func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *CompletionList, err error) { +func (s *server) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (_ *TextDocumentCompletionResult, err error) { s.logger.Debug("call " + MethodTextDocumentCompletion) defer s.logger.Debug("end "+MethodTextDocumentCompletion, zap.Error(err)) - var result *CompletionList + var result *TextDocumentCompletionResult if err := Call(ctx, s.Conn, MethodTextDocumentCompletion, params, &result); err != nil { return nil, err } @@ -1213,28 +1382,16 @@ func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *C return result, nil } -// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. -func (s *server) CompletionResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { - s.logger.Debug("call " + MethodCompletionItemResolve) - defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) - - var result *CompletionItem - if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // Declaration sends the request from the client to the server to resolve the declaration location of a symbol at a given text document position. // // The result type LocationLink[] got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.declaration.linkSupport`. // // @since 3.14.0. -func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (result []Location, err error) { +func (s *server) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (_ *TextDocumentDeclarationResult, err error) { s.logger.Debug("call " + MethodTextDocumentDeclaration) defer s.logger.Debug("end "+MethodTextDocumentDeclaration, zap.Error(err)) + var result *TextDocumentDeclarationResult if err := Call(ctx, s.Conn, MethodTextDocumentDeclaration, params, &result); err != nil { return nil, err } @@ -1247,10 +1404,11 @@ func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (re // The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.definition.linkSupport`. // // @since 3.14.0. -func (s *server) Definition(ctx context.Context, params *DefinitionParams) (result []Location, err error) { +func (s *server) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (_ *TextDocumentDefinitionResult, err error) { s.logger.Debug("call " + MethodTextDocumentDefinition) defer s.logger.Debug("end "+MethodTextDocumentDefinition, zap.Error(err)) + var result *TextDocumentDefinitionResult if err := Call(ctx, s.Conn, MethodTextDocumentDefinition, params, &result); err != nil { return nil, err } @@ -1258,85 +1416,16 @@ func (s *server) Definition(ctx context.Context, params *DefinitionParams) (resu return result, nil } -// DidChange sends the notification from the client to the server to signal changes to a text document. -// -// In 2.0 the shape of the params has changed to include proper version numbers and language ids. -func (s *server) DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { - s.logger.Debug("notify " + MethodTextDocumentDidChange) - defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) -} - -// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. -func (s *server) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) -} - -// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. -// -// It is recommended that servers register for these file events using the registration mechanism. -// In former implementations clients pushed file events without the server actively asking for it. -func (s *server) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) -} - -// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. -// -// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; -// or if the server has registered itself to receive this notification. -// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. -// -// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). -func (s *server) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) -} - -// DidClose sends the notification from the client to the server when the document got closed in the client. -// -// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). -// As with the open notification the close notification is about managing the document’s content. -// Receiving a close notification doesn’t mean that the document was open in an editor before. -// -// A close notification requires a previous open notification to be sent. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidClose) - defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) -} - -// DidOpen sends the open notification from the client to the server to signal newly opened text documents. -// -// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. -// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. -// -// An open notification must not be sent more than once without a corresponding close notification send before. -// This means open and close notification must be balanced and the max open count for a particular textDocument is one. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidOpen) - defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) -} +func (s *server) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (_ *DocumentDiagnosticReport, err error) { + s.logger.Debug("call " + MethodTextDocumentDiagnostic) + defer s.logger.Debug("end "+MethodTextDocumentDiagnostic, zap.Error(err)) -// DidSave sends the notification from the client to the server when the document was saved in the client. -func (s *server) DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidSave) - defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) + var result *DocumentDiagnosticReport + if err := Call(ctx, s.Conn, MethodTextDocumentDiagnostic, params, &result); err != nil { + return nil, err + } - return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) + return result, nil } // DocumentColor sends the request from the client to the server to list all color references found in a given text document. @@ -1348,10 +1437,11 @@ func (s *server) DidSave(ctx context.Context, params *DidSaveTextDocumentParams) // // - Color boxes showing the actual color next to the reference // - Show a color picker when a color reference is edited. -func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) { +func (s *server) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) (_ []*ColorInformation, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentColor) defer s.logger.Debug("end "+MethodTextDocumentDocumentColor, zap.Error(err)) + var result []*ColorInformation if err := Call(ctx, s.Conn, MethodTextDocumentDocumentColor, params, &result); err != nil { return nil, err } @@ -1365,10 +1455,11 @@ func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) // However we kept ‘textDocument/documentHighlight’ and ‘textDocument/references’ separate requests since the first one is allowed to be more fuzzy. // // Symbol matches usually have a `DocumentHighlightKind` of `Read` or `Write` whereas fuzzy or textual matches use `Text` as the kind. -func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) { +func (s *server) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (_ []*DocumentHighlight, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentHighlight) defer s.logger.Debug("end "+MethodTextDocumentDocumentHighlight, zap.Error(err)) + var result []*DocumentHighlight if err := Call(ctx, s.Conn, MethodTextDocumentDocumentHighlight, params, &result); err != nil { return nil, err } @@ -1377,10 +1468,11 @@ func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighligh } // DocumentLink sends the request from the client to the server to request the location of links in a document. -func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) { +func (s *server) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) (_ []*DocumentLink, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentLink) defer s.logger.Debug("end "+MethodTextDocumentDocumentLink, zap.Error(err)) + var result []*DocumentLink if err := Call(ctx, s.Conn, MethodTextDocumentDocumentLink, params, &result); err != nil { return nil, err } @@ -1388,95 +1480,145 @@ func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) ( return result, nil } -// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. -func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { - s.logger.Debug("call " + MethodDocumentLinkResolve) - defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) +// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. +// +// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. +func (s *server) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (_ *TextDocumentDocumentSymbolResult, err error) { + s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) + defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) - var result *DocumentLink - if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { + var result *TextDocumentDocumentSymbolResult + if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { return nil, err } return result, nil } -// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. +// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. // -// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. -func (s *server) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{}, err error) { - s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) - defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) +// @since version 3.10.0. +func (s *server) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) (_ []*FoldingRange, err error) { + s.logger.Debug("call " + MethodTextDocumentFoldingRange) + defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { + var result []*FoldingRange + if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { return nil, err } return result, nil } -// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. +// Formatting sends the request from the client to the server to format a whole document. +func (s *server) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentFormatting) + defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) + + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Hover sends the request is from the client to the server to request hover information at a given text document position. +func (s *server) TextDocumentHover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { + s.logger.Debug("call " + MethodTextDocumentHover) + defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) + + var result *Hover + if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. // -// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the -// request `workspace/applyEdit` which is sent from the server to the client. -func (s *server) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) { - s.logger.Debug("call " + MethodWorkspaceExecuteCommand) - defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. +func (s *server) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (_ *TextDocumentImplementationResult, err error) { + s.logger.Debug("call " + MethodTextDocumentImplementation) + defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) + + var result *TextDocumentImplementationResult + if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { + return nil, err + } - if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { + return result, nil +} + +func (s *server) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) (_ []*InlayHint, err error) { + s.logger.Debug("call " + MethodTextDocumentInlayHint) + defer s.logger.Debug("end "+MethodTextDocumentInlayHint, zap.Error(err)) + + var result []*InlayHint + if err := Call(ctx, s.Conn, MethodTextDocumentInlayHint, params, &result); err != nil { return nil, err } return result, nil } -// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. -// -// @since version 3.10.0. -func (s *server) FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) { - s.logger.Debug("call " + MethodTextDocumentFoldingRange) - defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) +func (s *server) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (_ *TextDocumentInlineCompletionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentInlineCompletion) + defer s.logger.Debug("end "+MethodTextDocumentInlineCompletion, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { + var result *TextDocumentInlineCompletionResult + if err := Call(ctx, s.Conn, MethodTextDocumentInlineCompletion, params, &result); err != nil { return nil, err } return result, nil } -// Formatting sends the request from the client to the server to format a whole document. -func (s *server) Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentFormatting) - defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) +func (s *server) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) (_ []*InlineValue, err error) { + s.logger.Debug("call " + MethodTextDocumentInlineValue) + defer s.logger.Debug("end "+MethodTextDocumentInlineValue, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { + var result []*InlineValue + if err := Call(ctx, s.Conn, MethodTextDocumentInlineValue, params, &result); err != nil { return nil, err } return result, nil } -// Hover sends the request is from the client to the server to request hover information at a given text document position. -func (s *server) Hover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { - s.logger.Debug("call " + MethodTextDocumentHover) - defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) +// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. +// +// Optionally a word pattern can be returned to describe valid contents. +// +// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. +// +// @since 3.16.0. +func (s *server) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (_ *LinkedEditingRanges, err error) { + s.logger.Debug("call " + MethodTextDocumentLinkedEditingRange) + defer s.logger.Debug("end "+MethodTextDocumentLinkedEditingRange, zap.Error(err)) - var result *Hover - if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { + var result *LinkedEditingRanges + if err := Call(ctx, s.Conn, MethodTextDocumentLinkedEditingRange, params, &result); err != nil { return nil, err } return result, nil } -// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. +// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. // -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. -func (s *server) Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) { - s.logger.Debug("call " + MethodTextDocumentImplementation) - defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) +// An array of Moniker types is returned as response to indicate possible monikers at the given location. +// +// If no monikers can be calculated, an empty array or null should be returned. +// +// @since 3.16.0. +func (s *server) TextDocumentMoniker(ctx context.Context, params *MonikerParams) (_ []*Moniker, err error) { + s.logger.Debug("call " + MethodTextDocumentMoniker) + defer s.logger.Debug("end "+MethodTextDocumentMoniker, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { + var result []*Moniker + if err := Call(ctx, s.Conn, MethodTextDocumentMoniker, params, &result); err != nil { return nil, err } @@ -1484,10 +1626,11 @@ func (s *server) Implementation(ctx context.Context, params *ImplementationParam } // OnTypeFormatting sends the request from the client to the server to format parts of the document during typing. -func (s *server) OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) { +func (s *server) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (_ []*TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentOnTypeFormatting) defer s.logger.Debug("end "+MethodTextDocumentOnTypeFormatting, zap.Error(err)) + var result []*TextEdit if err := Call(ctx, s.Conn, MethodTextDocumentOnTypeFormatting, params, &result); err != nil { return nil, err } @@ -1495,385 +1638,347 @@ func (s *server) OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFor return result, nil } -// PrepareRename sends the request from the client to the server to setup and test the validity of a rename operation at a given location. +// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. // -// @since version 3.12.0. -func (s *server) PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) { - s.logger.Debug("call " + MethodTextDocumentPrepareRename) - defer s.logger.Debug("end "+MethodTextDocumentPrepareRename, zap.Error(err)) +// The call hierarchy requests are executed in two steps: +// 1. first a call hierarchy item is resolved for the given text document position +// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. +// +// @since 3.16.0. +func (s *server) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (_ []*CallHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentPrepareRename, params, &result); err != nil { + var result []*CallHierarchyItem + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { return nil, err } return result, nil } -// RangeFormatting sends the request from the client to the server to format a given range in a document. -func (s *server) RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentRangeFormatting) - defer s.logger.Debug("end "+MethodTextDocumentRangeFormatting, zap.Error(err)) +// PrepareRename sends the request from the client to the server to setup and test the validity of a rename operation at a given location. +// +// @since version 3.12.0. +func (s *server) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (_ *PrepareRenameResult, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareRename) + defer s.logger.Debug("end "+MethodTextDocumentPrepareRename, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentRangeFormatting, params, &result); err != nil { + var result *PrepareRenameResult + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareRename, params, &result); err != nil { return nil, err } return result, nil } -// References sends the request from the client to the server to resolve project-wide references for the symbol denoted by the given text document position. -func (s *server) References(ctx context.Context, params *ReferenceParams) (result []Location, err error) { - s.logger.Debug("call " + MethodTextDocumentReferences) - defer s.logger.Debug("end "+MethodTextDocumentReferences, zap.Error(err)) +func (s *server) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareTypeHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentReferences, params, &result); err != nil { + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareTypeHierarchy, params, &result); err != nil { return nil, err } return result, nil } -// Rename sends the request from the client to the server to perform a workspace-wide rename of a symbol. -func (s *server) Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentRename) - defer s.logger.Debug("end "+MethodTextDocumentRename, zap.Error(err)) +// RangeFormatting sends the request from the client to the server to format a given range in a document. +func (s *server) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRangeFormatting) + defer s.logger.Debug("end "+MethodTextDocumentRangeFormatting, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentRename, params, &result); err != nil { + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRangeFormatting, params, &result); err != nil { return nil, err } return result, nil } -// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. -func (s *server) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { - s.logger.Debug("call " + MethodTextDocumentSignatureHelp) - defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) +func (s *server) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRangesFormatting) + defer s.logger.Debug("end "+MethodTextDocumentRangesFormatting, zap.Error(err)) - var result *SignatureHelp - if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRangesFormatting, params, &result); err != nil { return nil, err } return result, nil } -// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. -func (s *server) Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) { - s.logger.Debug("call " + MethodWorkspaceSymbol) - defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) +// References sends the request from the client to the server to resolve project-wide references for the symbol denoted by the given text document position. +func (s *server) TextDocumentReferences(ctx context.Context, params *ReferenceParams) (_ []*Location, err error) { + s.logger.Debug("call " + MethodTextDocumentReferences) + defer s.logger.Debug("end "+MethodTextDocumentReferences, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { + var result []*Location + if err := Call(ctx, s.Conn, MethodTextDocumentReferences, params, &result); err != nil { return nil, err } return result, nil } -// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. -// -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. -// -// @since version 3.6.0. -func (s *server) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) { - s.logger.Debug("call " + MethodTextDocumentTypeDefinition) - defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) +// Rename sends the request from the client to the server to perform a workspace-wide rename of a symbol. +func (s *server) TextDocumentRename(ctx context.Context, params *RenameParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRename) + defer s.logger.Debug("end "+MethodTextDocumentRename, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRename, params, &result); err != nil { return nil, err } return result, nil } -// WillSave sends the notification from the client to the server before the document is actually saved. -func (s *server) WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentWillSave) - defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) -} - -// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. -// -// The request can return an array of TextEdits which will be applied to the text document before it is saved. -// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. -// This is done to keep the save fast and reliable. -func (s *server) WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) - defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) +func (s *server) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) (_ []*SelectionRange, err error) { + s.logger.Debug("call " + MethodTextDocumentSelectionRange) + defer s.logger.Debug("end "+MethodTextDocumentSelectionRange, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { + var result []*SelectionRange + if err := Call(ctx, s.Conn, MethodTextDocumentSelectionRange, params, &result); err != nil { return nil, err } return result, nil } -// ShowDocument sends the request from a server to a client to ask the client to display a particular document in the user interface. +// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. +// +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. // // @since 3.16.0. -func (s *server) ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) { - s.logger.Debug("call " + MethodShowDocument) - defer s.logger.Debug("end "+MethodShowDocument, zap.Error(err)) +func (s *server) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (_ *SemanticTokens, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensFull) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFull, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodShowDocument, params, &result); err != nil { + var result *SemanticTokens + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFull, params, &result); err != nil { return nil, err } return result, nil } -// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. +// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. // // @since 3.16.0. -func (s *server) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWillCreateFiles) - defer s.logger.Debug("end "+MethodWillCreateFiles, zap.Error(err)) +func (s *server) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (_ *TextDocumentSemanticTokensFullDeltaResult, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensFullDelta) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWillCreateFiles, params, &result); err != nil { + var result *TextDocumentSemanticTokensFullDeltaResult + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFullDelta, params, &result); err != nil { return nil, err } return result, nil } -// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. -// -// @since 3.16.0. -func (s *server) DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { - s.logger.Debug("call " + MethodDidCreateFiles) - defer s.logger.Debug("end "+MethodDidCreateFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodDidCreateFiles, params) -} - -// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. +// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. +// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). +// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. +// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. // // @since 3.16.0. -func (s *server) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWillRenameFiles) - defer s.logger.Debug("end "+MethodWillRenameFiles, zap.Error(err)) +func (s *server) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (_ *SemanticTokens, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensRange) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensRange, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWillRenameFiles, params, &result); err != nil { + var result *SemanticTokens + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensRange, params, &result); err != nil { return nil, err } return result, nil } -// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. -// -// @since 3.16.0. -func (s *server) DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { - s.logger.Debug("call " + MethodDidRenameFiles) - defer s.logger.Debug("end "+MethodDidRenameFiles, zap.Error(err)) +// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. +func (s *server) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { + s.logger.Debug("call " + MethodTextDocumentSignatureHelp) + defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) + + var result *SignatureHelp + if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { + return nil, err + } - return s.Conn.Notify(ctx, MethodDidRenameFiles, params) + return result, nil } -// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. -// -// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. +// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. // -// @since 3.16.0. -func (s *server) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWillDeleteFiles) - defer s.logger.Debug("end "+MethodWillDeleteFiles, zap.Error(err)) +// @since version 3.6.0. +func (s *server) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (_ *TextDocumentTypeDefinitionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentTypeDefinition) + defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWillDeleteFiles, params, &result); err != nil { + var result *TextDocumentTypeDefinitionResult + if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { return nil, err } return result, nil } -// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. +// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. // -// @since 3.16.0. -func (s *server) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { - s.logger.Debug("call " + MethodDidDeleteFiles) - defer s.logger.Debug("end "+MethodDidDeleteFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodDidDeleteFiles, params) -} +// The request can return an array of TextEdits which will be applied to the text document before it is saved. +// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. +// This is done to keep the save fast and reliable. +func (s *server) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) + defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) -// CodeLensRefresh sent from the server to the client. -// -// Servers can use it to ask clients to refresh the code lenses currently shown in editors. -// As a result the client should ask the server to recompute the code lenses for these editors. -// This is useful if a server detects a configuration change which requires a re-calculation of all code lenses. -// -// Note that the client still has the freedom to delay the re-calculation of the code lenses if for example an editor is currently not visible. -// -// @since 3.16.0. -func (s *server) CodeLensRefresh(ctx context.Context) (err error) { - s.logger.Debug("call " + MethodCodeLensRefresh) - defer s.logger.Debug("end "+MethodCodeLensRefresh, zap.Error(err)) + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { + return nil, err + } - return Call(ctx, s.Conn, MethodCodeLensRefresh, nil, nil) + return result, nil } -// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. -// -// The call hierarchy requests are executed in two steps: -// 1. first a call hierarchy item is resolved for the given text document position -// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. -// -// @since 3.16.0. -func (s *server) PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) { - s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) - defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) +func (s *server) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTypeHierarchySubtypes) + defer s.logger.Debug("end "+MethodTypeHierarchySubtypes, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTypeHierarchySubtypes, params, &result); err != nil { return nil, err } return result, nil } -// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -func (s *server) IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) +func (s *server) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTypeHierarchySupertypes) + defer s.logger.Debug("end "+MethodTypeHierarchySupertypes, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTypeHierarchySupertypes, params, &result); err != nil { return nil, err } return result, nil } -// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -func (s *server) OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) +func (s *server) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (_ *WorkspaceDiagnosticReport, err error) { + s.logger.Debug("call " + MethodWorkspaceDiagnostic) + defer s.logger.Debug("end "+MethodWorkspaceDiagnostic, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { + var result *WorkspaceDiagnosticReport + if err := Call(ctx, s.Conn, MethodWorkspaceDiagnostic, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. -// -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. -// -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. // -// @since 3.16.0. -func (s *server) SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) { - s.logger.Debug("call " + MethodSemanticTokensFull) - defer s.logger.Debug("end "+MethodSemanticTokensFull, zap.Error(err)) +// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the +// request `workspace/applyEdit` which is sent from the server to the client. +func (s *server) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result any, err error) { + s.logger.Debug("call " + MethodWorkspaceExecuteCommand) + defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodSemanticTokensFull, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. -// -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. -// -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. -// -// @since 3.16.0. -func (s *server) SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{}, err error) { - s.logger.Debug("call " + MethodSemanticTokensFullDelta) - defer s.logger.Debug("end "+MethodSemanticTokensFullDelta, zap.Error(err)) +// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. +func (s *server) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (_ *WorkspaceSymbolResult, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbol) + defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodSemanticTokensFullDelta, params, &result); err != nil { + var result *WorkspaceSymbolResult + if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. +// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. // -// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). -// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. // -// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. // // @since 3.16.0. -func (s *server) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) { - s.logger.Debug("call " + MethodSemanticTokensRange) - defer s.logger.Debug("end "+MethodSemanticTokensRange, zap.Error(err)) +func (s *server) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillCreateFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillCreateFiles, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodSemanticTokensRange, params, &result); err != nil { + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillCreateFiles, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensRefresh is sent from the server to the client. Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens. +// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. // -// As a result the client should ask the server to recompute the semantic tokens for these editors. -// This is useful if a server detects a project wide configuration change which requires a re-calculation of all semantic tokens. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. // -// Note that the client still has the freedom to delay the re-calculation of the semantic tokens if for example an editor is currently not visible. +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. // // @since 3.16.0. -func (s *server) SemanticTokensRefresh(ctx context.Context) (err error) { - s.logger.Debug("call " + MethodSemanticTokensRefresh) - defer s.logger.Debug("end "+MethodSemanticTokensRefresh, zap.Error(err)) +func (s *server) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillDeleteFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillDeleteFiles, zap.Error(err)) + + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillDeleteFiles, params, &result); err != nil { + return nil, err + } - return Call(ctx, s.Conn, MethodSemanticTokensRefresh, nil, nil) + return result, nil } -// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. +// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. // -// Optionally a word pattern can be returned to describe valid contents. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. // -// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. // // @since 3.16.0. -func (s *server) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) { - s.logger.Debug("call " + MethodLinkedEditingRange) - defer s.logger.Debug("end "+MethodLinkedEditingRange, zap.Error(err)) +func (s *server) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillRenameFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillRenameFiles, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodLinkedEditingRange, params, &result); err != nil { + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillRenameFiles, params, &result); err != nil { return nil, err } return result, nil } -// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. -// -// An array of Moniker types is returned as response to indicate possible monikers at the given location. -// -// If no monikers can be calculated, an empty array or null should be returned. -// -// @since 3.16.0. -func (s *server) Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) { - s.logger.Debug("call " + MethodMoniker) - defer s.logger.Debug("end "+MethodMoniker, zap.Error(err)) +func (s *server) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (_ *WorkspaceSymbol, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbolResolve) + defer s.logger.Debug("end "+MethodWorkspaceSymbolResolve, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodMoniker, params, &result); err != nil { + var result *WorkspaceSymbol + if err := Call(ctx, s.Conn, MethodWorkspaceSymbolResolve, params, &result); err != nil { return nil, err } @@ -1881,11 +1986,11 @@ func (s *server) Moniker(ctx context.Context, params *MonikerParams) (result []M } // Request sends a request from the client to the server that non-compliant with the Language Server Protocol specifications. -func (s *server) Request(ctx context.Context, method string, params interface{}) (interface{}, error) { +func (s *server) Request(ctx context.Context, method string, params any) (any, error) { s.logger.Debug("call " + method) defer s.logger.Debug("end " + method) - var result interface{} + var result any if err := Call(ctx, s.Conn, method, params, &result); err != nil { return nil, err } diff --git a/server_interface.go b/server_interface.go new file mode 100644 index 00000000..c97e0c8e --- /dev/null +++ b/server_interface.go @@ -0,0 +1,681 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "context" + + "go.lsp.dev/jsonrpc2" +) + +const ( + MethodServerCancelRequest ServerMethod = "$/cancelRequest" // bidirect server notification + MethodServerProgress ServerMethod = "$/progress" // bidirect server notification + MethodSetTrace ServerMethod = "$/setTrace" // server notification + MethodExit ServerMethod = "exit" // server notification + MethodInitialized ServerMethod = "initialized" // server notification + MethodNotebookDocumentDidChange ServerMethod = "notebookDocument/didChange" // server notification + MethodNotebookDocumentDidClose ServerMethod = "notebookDocument/didClose" // server notification + MethodNotebookDocumentDidOpen ServerMethod = "notebookDocument/didOpen" // server notification + MethodNotebookDocumentDidSave ServerMethod = "notebookDocument/didSave" // server notification + MethodTextDocumentDidChange ServerMethod = "textDocument/didChange" // server notification + MethodTextDocumentDidClose ServerMethod = "textDocument/didClose" // server notification + MethodTextDocumentDidOpen ServerMethod = "textDocument/didOpen" // server notification + MethodTextDocumentDidSave ServerMethod = "textDocument/didSave" // server notification + MethodTextDocumentWillSave ServerMethod = "textDocument/willSave" // server notification + MethodWindowWorkDoneProgressCancel ServerMethod = "window/workDoneProgress/cancel" // server notification + MethodWorkspaceDidChangeConfiguration ServerMethod = "workspace/didChangeConfiguration" // server notification + MethodWorkspaceDidChangeWatchedFiles ServerMethod = "workspace/didChangeWatchedFiles" // server notification + MethodWorkspaceDidChangeWorkspaceFolders ServerMethod = "workspace/didChangeWorkspaceFolders" // server notification + MethodWorkspaceDidCreateFiles ServerMethod = "workspace/didCreateFiles" // server notification + MethodWorkspaceDidDeleteFiles ServerMethod = "workspace/didDeleteFiles" // server notification + MethodWorkspaceDidRenameFiles ServerMethod = "workspace/didRenameFiles" // server notification + MethodCallHierarchyIncomingCalls ServerMethod = "callHierarchy/incomingCalls" // server request + MethodCallHierarchyOutgoingCalls ServerMethod = "callHierarchy/outgoingCalls" // server request + MethodCodeActionResolve ServerMethod = "codeAction/resolve" // server request + MethodCodeLensResolve ServerMethod = "codeLens/resolve" // server request + MethodCompletionItemResolve ServerMethod = "completionItem/resolve" // server request + MethodDocumentLinkResolve ServerMethod = "documentLink/resolve" // server request + MethodInitialize ServerMethod = "initialize" // server request + MethodInlayHintResolve ServerMethod = "inlayHint/resolve" // server request + MethodShutdown ServerMethod = "shutdown" // server request + MethodTextDocumentCodeAction ServerMethod = "textDocument/codeAction" // server request + MethodTextDocumentCodeLens ServerMethod = "textDocument/codeLens" // server request + MethodTextDocumentColorPresentation ServerMethod = "textDocument/colorPresentation" // server request + MethodTextDocumentCompletion ServerMethod = "textDocument/completion" // server request + MethodTextDocumentDeclaration ServerMethod = "textDocument/declaration" // server request + MethodTextDocumentDefinition ServerMethod = "textDocument/definition" // server request + MethodTextDocumentDiagnostic ServerMethod = "textDocument/diagnostic" // server request + MethodTextDocumentDocumentColor ServerMethod = "textDocument/documentColor" // server request + MethodTextDocumentDocumentHighlight ServerMethod = "textDocument/documentHighlight" // server request + MethodTextDocumentDocumentLink ServerMethod = "textDocument/documentLink" // server request + MethodTextDocumentDocumentSymbol ServerMethod = "textDocument/documentSymbol" // server request + MethodTextDocumentFoldingRange ServerMethod = "textDocument/foldingRange" // server request + MethodTextDocumentFormatting ServerMethod = "textDocument/formatting" // server request + MethodTextDocumentHover ServerMethod = "textDocument/hover" // server request + MethodTextDocumentImplementation ServerMethod = "textDocument/implementation" // server request + MethodTextDocumentInlayHint ServerMethod = "textDocument/inlayHint" // server request + MethodTextDocumentInlineCompletion ServerMethod = "textDocument/inlineCompletion" // server request + MethodTextDocumentInlineValue ServerMethod = "textDocument/inlineValue" // server request + MethodTextDocumentLinkedEditingRange ServerMethod = "textDocument/linkedEditingRange" // server request + MethodTextDocumentMoniker ServerMethod = "textDocument/moniker" // server request + MethodTextDocumentOnTypeFormatting ServerMethod = "textDocument/onTypeFormatting" // server request + MethodTextDocumentPrepareCallHierarchy ServerMethod = "textDocument/prepareCallHierarchy" // server request + MethodTextDocumentPrepareRename ServerMethod = "textDocument/prepareRename" // server request + MethodTextDocumentPrepareTypeHierarchy ServerMethod = "textDocument/prepareTypeHierarchy" // server request + MethodTextDocumentRangeFormatting ServerMethod = "textDocument/rangeFormatting" // server request + MethodTextDocumentRangesFormatting ServerMethod = "textDocument/rangesFormatting" // server request + MethodTextDocumentReferences ServerMethod = "textDocument/references" // server request + MethodTextDocumentRename ServerMethod = "textDocument/rename" // server request + MethodTextDocumentSelectionRange ServerMethod = "textDocument/selectionRange" // server request + MethodTextDocumentSemanticTokensFull ServerMethod = "textDocument/semanticTokens/full" // server request + MethodTextDocumentSemanticTokensFullDelta ServerMethod = "textDocument/semanticTokens/full/delta" // server request + MethodTextDocumentSemanticTokensRange ServerMethod = "textDocument/semanticTokens/range" // server request + MethodTextDocumentSignatureHelp ServerMethod = "textDocument/signatureHelp" // server request + MethodTextDocumentTypeDefinition ServerMethod = "textDocument/typeDefinition" // server request + MethodTextDocumentWillSaveWaitUntil ServerMethod = "textDocument/willSaveWaitUntil" // server request + MethodTypeHierarchySubtypes ServerMethod = "typeHierarchy/subtypes" // server request + MethodTypeHierarchySupertypes ServerMethod = "typeHierarchy/supertypes" // server request + MethodWorkspaceDiagnostic ServerMethod = "workspace/diagnostic" // server request + MethodWorkspaceExecuteCommand ServerMethod = "workspace/executeCommand" // server request + MethodWorkspaceSymbol ServerMethod = "workspace/symbol" // server request + MethodWorkspaceWillCreateFiles ServerMethod = "workspace/willCreateFiles" // server request + MethodWorkspaceWillDeleteFiles ServerMethod = "workspace/willDeleteFiles" // server request + MethodWorkspaceWillRenameFiles ServerMethod = "workspace/willRenameFiles" // server request + MethodWorkspaceSymbolResolve ServerMethod = "workspaceSymbol/resolve" // server request +) + +type Server interface { + CancelRequest(ctx context.Context, params *CancelParams) error + + Progress(ctx context.Context, params *ProgressParams) error + + SetTrace(ctx context.Context, params *SetTraceParams) error + + // Exit the exit event is sent from the client to the server to ask the server to exit its process. + Exit(ctx context.Context) error + + // Initialized the initialized notification is sent from the client to the server after the client is fully initialized and the server is allowed to send requests from the server to the client. + Initialized(ctx context.Context, params *InitializedParams) error + + NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) error + + // NotebookDocumentDidClose a notification sent when a notebook closes. + // + // @since 3.17.0 + NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) error + + // NotebookDocumentDidOpen a notification sent when a notebook opens. + // + // @since 3.17.0 + NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) error + + // NotebookDocumentDidSave a notification sent when a notebook document is saved. + // + // @since 3.17.0 + NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) error + + // TextDocumentDidChange the document change notification is sent from the client to the server to signal changes to a text document. + TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) error + + // TextDocumentDidClose the document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notification to be sent. + TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) error + + // TextDocumentDidOpen the document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one. + TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) error + + // TextDocumentDidSave the document save notification is sent from the client to the server when the document got saved in the client. + TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) error + + // TextDocumentWillSave a document will save notification is sent from the client to the server before the document is actually saved. + TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) error + + // WindowWorkDoneProgressCancel the `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress initiated on the server side. + WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error + + // WorkspaceDidChangeConfiguration the configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains the changed configuration as defined by the language client. + WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error + + // WorkspaceDidChangeWatchedFiles the watched files notification is sent from the client to the server when the client detects changes + // to file watched by the language client. + WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error + + // WorkspaceDidChangeWorkspaceFolders the `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace folder configuration changes. + WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error + + // WorkspaceDidCreateFiles the did create files notification is sent from the client to the server when files were created from + // within the client. + // + // @since 3.16.0 + WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) error + + // WorkspaceDidDeleteFiles the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. + // + // @since 3.16.0 + WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error + + // WorkspaceDidRenameFiles the did rename files notification is sent from the client to the server when files were renamed from + // within the client. + // + // @since 3.16.0 + WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) error + // CallHierarchyIncomingCalls a request to resolve the incoming calls for a given `CallHierarchyItem`. + // + // @since 3.16.0 + CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) ([]*CallHierarchyIncomingCall, error) + + // CallHierarchyOutgoingCalls a request to resolve the outgoing calls for a given `CallHierarchyItem`. + // + // @since 3.16.0 + CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) + + // CodeActionResolve request to resolve additional information for a given code action.The request's parameter is of type + // CodeAction the response is of type CodeAction or a Thenable that resolves to such. + CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) + + // CodeLensResolve a request to resolve a command for a given code lens. + CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) + + // CompletionItemResolve request to resolve additional information for a given completion item.The request's parameter is of type CompletionItem the response is of type CompletionItem or a Thenable that resolves to such. + CompletionItemResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) + + // DocumentLinkResolve request to resolve additional information for a given document link. The request's parameter is of type DocumentLink the response is of type DocumentLink or a Thenable that resolves to such. + DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) + + // Initialize the initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type InitializeParams the response if of type InitializeResult of a Thenable that resolves to such. + Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) + + // InlayHintResolve a request to resolve additional properties for an inlay hint. The request's parameter is of type InlayHint, the response is of type InlayHint or a Thenable that resolves to such. + // + // @since 3.17.0 + InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) + + // Shutdown a shutdown request is sent from the client to the server. It is sent once when the client decides to + // shutdown the server. The only notification that is sent after a shutdown request is the exit event. + Shutdown(ctx context.Context) error + + // TextDocumentCodeAction a request to provide commands for the given text document and range. + TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (*TextDocumentCodeActionResult, error) + + // TextDocumentCodeLens a request to provide code lens for the given text document. + TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) + + // TextDocumentColorPresentation a request to list all presentation for a color. The request's parameter is of type ColorPresentationParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. + TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) + + // TextDocumentCompletion request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, + // `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. + TextDocumentCompletion(ctx context.Context, params *CompletionParams) (*TextDocumentCompletionResult, error) + + // TextDocumentDeclaration a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a + // typed array of DeclarationLink or a Thenable that resolves to such. + TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (*TextDocumentDeclarationResult, error) + + // TextDocumentDefinition a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed + // array of DefinitionLink or a Thenable that resolves to such. + TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (*TextDocumentDefinitionResult, error) + + // TextDocumentDiagnostic the document diagnostic request definition. + // + // @since 3.17.0 + TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) + + // TextDocumentDocumentColor a request to list all color symbols found in a given text document. The request's parameter is of type DocumentColorParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. + TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) + + // TextDocumentDocumentHighlight request to resolve a DocumentHighlight for a given text document position. The request's parameter is of type TextDocumentPosition the request response is an array of type DocumentHighlight or a Thenable that resolves to such. + TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) + + // TextDocumentDocumentLink a request to provide document links. + TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) + + // TextDocumentDocumentSymbol a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that + // resolves to such. + TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*TextDocumentDocumentSymbolResult, error) + + // TextDocumentFoldingRange a request to provide folding ranges in a document. The request's parameter is of type FoldingRangeParams, the response is of type FoldingRangeList or a Thenable that resolves to such. + TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) + + // TextDocumentFormatting a request to format a whole document. + TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) + + // TextDocumentHover request to request hover information at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type Hover or a Thenable that resolves to such. + TextDocumentHover(ctx context.Context, params *HoverParams) (*Hover, error) + + // TextDocumentImplementation a request to resolve the implementation locations of a symbol at a given text document position. The + // request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. + TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (*TextDocumentImplementationResult, error) + + // TextDocumentInlayHint a request to provide inlay hints in a document. The request's parameter is of type InlayHintsParams, + // the response is of type InlayHint InlayHint[] or a Thenable that resolves to such. + // + // @since 3.17.0 + TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) + + // TextDocumentInlineCompletion a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (*TextDocumentInlineCompletionResult, error) + + // TextDocumentInlineValue a request to provide inline values in a document. The request's parameter is of type InlineValueParams, the response is of type InlineValue InlineValue[] or a Thenable that resolves to such. + // + // @since 3.17.0 + TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) + + // TextDocumentLinkedEditingRange a request to provide ranges that can be edited together. + // + // @since 3.16.0 + TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) + + // TextDocumentMoniker a request to get the moniker of a symbol at a given text document position. The request parameter is + // of type TextDocumentPositionParams. The response is of type Moniker Moniker[] or `null`. + TextDocumentMoniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) + + // TextDocumentOnTypeFormatting a request to format a document on type. + TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) + + // TextDocumentPrepareCallHierarchy a request to result a `CallHierarchyItem` in a document at a given position. Can be used as an input + // to an incoming or outgoing call hierarchy. + // + // @since 3.16.0 + TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) + + // TextDocumentPrepareRename a request to test and perform the setup necessary for a rename. 3.16 - support for default behavior. + // + // @since 3.16 - support for default behavior + TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) + + // TextDocumentPrepareTypeHierarchy a request to result a `TypeHierarchyItem` in a document at a given position. Can be used as an input + // to a subtypes or supertypes type hierarchy. + // + // @since 3.17.0 + TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) + + // TextDocumentRangeFormatting a request to format a range in a document. + TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) + + // TextDocumentRangesFormatting a request to format ranges in a document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) + + // TextDocumentReferences a request to resolve project-wide references for the symbol denoted by the given text document position. The request's parameter is of type ReferenceParams the response is of type Location Location[] or a Thenable that resolves to such. + TextDocumentReferences(ctx context.Context, params *ReferenceParams) ([]*Location, error) + + // TextDocumentRename a request to rename a symbol. + TextDocumentRename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) + + // TextDocumentSelectionRange a request to provide selection ranges in a document. The request's parameter is of type SelectionRangeParams, the response is of type SelectionRange SelectionRange[] or a Thenable that resolves to such. + TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) + + // TextDocumentSemanticTokensFull. + // + // @since 3.16.0 + TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) + + // TextDocumentSemanticTokensFullDelta. + // + // @since 3.16.0 + TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*TextDocumentSemanticTokensFullDeltaResult, error) + + // TextDocumentSemanticTokensRange. + // + // @since 3.16.0 + TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) + + TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) + + // TextDocumentTypeDefinition a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. + TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TextDocumentTypeDefinitionResult, error) + + // TextDocumentWillSaveWaitUntil a document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before + // it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable. + TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) + + // TypeHierarchySubtypes a request to resolve the subtypes for a given `TypeHierarchyItem`. + // + // @since 3.17.0 + TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) + + // TypeHierarchySupertypes a request to resolve the supertypes for a given `TypeHierarchyItem`. + // + // @since 3.17.0 + TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) + + // WorkspaceDiagnostic the workspace diagnostic request definition. + // + // @since 3.17.0 + WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) + + // WorkspaceExecuteCommand a request send from the client to the server to execute a command. The request might return a workspace edit which the client will apply to the workspace. + WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) + + // WorkspaceSymbol a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. + // The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + // + // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) + + // WorkspaceWillCreateFiles the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a `WorkspaceEdit` which will be applied to workspace before the files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file to be created. + // + // @since 3.16.0 + WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) + + // WorkspaceWillDeleteFiles the did delete files notification is sent from the client to the server when files were deleted from + // within the client. + // + // @since 3.16.0 + WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) + + // WorkspaceWillRenameFiles the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. + // + // @since 3.16.0 + WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) + + // WorkspaceSymbolResolve a request to resolve the range inside the workspace symbol's location. + // + // @since 3.17.0 + WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (*WorkspaceSymbol, error) + + Request(ctx context.Context, method string, params any) (any, error) +} + +// UnimplementedServer should be embedded to have forward compatible implementations. +type UnimplementedServer struct{} + +func (UnimplementedServer) CancelRequest(ctx context.Context, params *CancelParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Progress(ctx context.Context, params *ProgressParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) SetTrace(ctx context.Context, params *SetTraceParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Exit(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Initialized(ctx context.Context, params *InitializedParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) ([]*CallHierarchyIncomingCall, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CompletionItemResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Shutdown(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (*TextDocumentCodeActionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (*TextDocumentCompletionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (*TextDocumentDeclarationResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (*TextDocumentDefinitionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*TextDocumentDocumentSymbolResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentHover(ctx context.Context, params *HoverParams) (*Hover, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (*TextDocumentImplementationResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (*TextDocumentInlineCompletionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentMoniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentReferences(ctx context.Context, params *ReferenceParams) ([]*Location, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentRename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*TextDocumentSemanticTokensFullDeltaResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TextDocumentTypeDefinitionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (*WorkspaceSymbol, error) { + return nil, jsonrpc2.ErrInternal +} From 06683996ac8c2ff23a4c8755f96d2c4fc906c384 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 5 May 2024 23:41:37 +0900 Subject: [PATCH 03/19] WIP3 Signed-off-by: Koichi Shiraishi --- client.go | 337 +- go.mod | 5 +- go.sum | 2 + protocol/base.go | 57 + protocol/basic.go | 570 ++++ protocol/client.go | 477 +++ .../client_interface.go | 0 protocol/context.go | 35 + protocol/document.go | 470 +++ protocol/errors.go | 42 + protocol/handler.go | 31 + protocol/language.go | 2736 +++++++++++++++ protocol/lifecycle.go | 1339 ++++++++ protocol/protocol.go | 109 + protocol/server.go | 1999 +++++++++++ .../server_interface.go | 0 protocol/typealias.go | 602 ++++ protocol/types.go | 20 + protocol/types_generics.go | 2953 +++++++++++++++++ protocol/window.go | 110 + protocol/workspace.go | 475 +++ server.go | 1874 +++++------ tools/protocol-gen/generator/generator.go | 4 +- 23 files changed, 13054 insertions(+), 1193 deletions(-) create mode 100644 protocol/base.go create mode 100644 protocol/basic.go create mode 100644 protocol/client.go rename client_interface.go => protocol/client_interface.go (100%) create mode 100644 protocol/context.go create mode 100644 protocol/document.go create mode 100644 protocol/errors.go create mode 100644 protocol/handler.go create mode 100644 protocol/language.go create mode 100644 protocol/lifecycle.go create mode 100644 protocol/protocol.go create mode 100644 protocol/server.go rename server_interface.go => protocol/server_interface.go (100%) create mode 100644 protocol/typealias.go create mode 100644 protocol/types.go create mode 100644 protocol/types_generics.go create mode 100644 protocol/window.go create mode 100644 protocol/workspace.go diff --git a/client.go b/client.go index 806f0131..1f9817bb 100644 --- a/client.go +++ b/client.go @@ -8,9 +8,11 @@ import ( "context" "fmt" + "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" + "go.lsp.dev/pkg/xcontext" ) // ClientDispatcher returns a Client that dispatches LSP requests across the @@ -26,7 +28,7 @@ func ClientDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Client { func ClientHandler(client Client, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := context.WithoutCancel(ctx) + xctx := xcontext.Detach(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -50,12 +52,12 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := newDecoder(bytes.NewReader(req.Params())) + dec := json.NewDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodClientProgress: // notification - defer logger.Debug(MethodClientProgress, zap.Error(err)) + case MethodProgress: // notification + defer logger.Debug(MethodProgress, zap.Error(err)) var params ProgressParams if err := dec.Decode(¶ms); err != nil { @@ -66,27 +68,27 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodLogTrace: // notification - defer logger.Debug(MethodLogTrace, zap.Error(err)) + case MethodWorkDoneProgressCreate: // request + defer logger.Debug(MethodWorkDoneProgressCreate, zap.Error(err)) - var params LogTraceParams + var params WorkDoneProgressCreateParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.LogTrace(ctx, ¶ms) + err := client.WorkDoneProgressCreate(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTelemetryEvent: // notification - defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) + case MethodWindowLogMessage: // notification + defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) - var params any + var params LogMessageParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.TelemetryEvent(ctx, ¶ms) + err := client.LogMessage(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -98,19 +100,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.TextDocumentPublishDiagnostics(ctx, ¶ms) - - return true, reply(ctx, nil, err) - - case MethodWindowLogMessage: // notification - defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) - - var params LogMessageParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - err := client.WindowLogMessage(ctx, ¶ms) + err := client.PublishDiagnostics(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -122,67 +112,55 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.WindowShowMessage(ctx, ¶ms) + err := client.ShowMessage(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodClientRegisterCapability: // request - defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) + case MethodWindowShowMessageRequest: // request + defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) - var params RegistrationParams + var params ShowMessageRequestParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.ClientRegisterCapability(ctx, ¶ms) + resp, err := client.ShowMessageRequest(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodClientUnregisterCapability: // request - defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) + case MethodTelemetryEvent: // notification + defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) - var params UnregistrationParams + var params interface{} if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.ClientUnregisterCapability(ctx, ¶ms) + err := client.Telemetry(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWindowShowDocument: // request - defer logger.Debug(MethodWindowShowDocument, zap.Error(err)) - - var params ShowDocumentParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := client.WindowShowDocument(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWindowShowMessageRequest: // request - defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) + case MethodClientRegisterCapability: // request + defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) - var params ShowMessageRequestParams + var params RegistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := client.WindowShowMessageRequest(ctx, ¶ms) + err := client.RegisterCapability(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodWindowWorkDoneProgressCreate: // request - defer logger.Debug(MethodWindowWorkDoneProgressCreate, zap.Error(err)) + case MethodClientUnregisterCapability: // request + defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) - var params WorkDoneProgressCreateParams + var params UnregistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.WindowWorkDoneProgressCreate(ctx, ¶ms) + err := client.UnregisterCapability(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -194,17 +172,10 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.WorkspaceApplyEdit(ctx, ¶ms) + resp, err := client.ApplyEdit(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceCodeLensRefresh: // request - defer logger.Debug(MethodWorkspaceCodeLensRefresh, zap.Error(err)) - - err := client.WorkspaceCodeLensRefresh(ctx) - - return true, reply(ctx, nil, err) - case MethodWorkspaceConfiguration: // request defer logger.Debug(MethodWorkspaceConfiguration, zap.Error(err)) @@ -213,53 +184,80 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.WorkspaceConfiguration(ctx, ¶ms) + resp, err := client.Configuration(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceDiagnosticRefresh: // request - defer logger.Debug(MethodWorkspaceDiagnosticRefresh, zap.Error(err)) + case MethodWorkspaceWorkspaceFolders: // request + defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) - err := client.WorkspaceDiagnosticRefresh(ctx) + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } - return true, reply(ctx, nil, err) + resp, err := client.WorkspaceFolders(ctx) - case MethodWorkspaceFoldingRangeRefresh: // request - defer logger.Debug(MethodWorkspaceFoldingRangeRefresh, zap.Error(err)) + return true, reply(ctx, resp, err) - err := client.WorkspaceFoldingRangeRefresh(ctx) + default: + return false, nil + } +} - return true, reply(ctx, nil, err) +// Client represents a Language Server Protocol client. +type Client interface { + Progress(ctx context.Context, params *ProgressParams) (err error) + WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) + LogMessage(ctx context.Context, params *LogMessageParams) (err error) + PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) + ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) + ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (result *MessageActionItem, err error) + Telemetry(ctx context.Context, params interface{}) (err error) + RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) + UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) + ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) + Configuration(ctx context.Context, params *ConfigurationParams) (result []interface{}, err error) + WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) +} - case MethodWorkspaceInlayHintRefresh: // request - defer logger.Debug(MethodWorkspaceInlayHintRefresh, zap.Error(err)) +// list of client methods. +const ( + // MethodProgress method name of "$/progress". + MethodProgress = "$/progress" - err := client.WorkspaceInlayHintRefresh(ctx) + // MethodWorkDoneProgressCreate method name of "window/workDoneProgress/create". + MethodWorkDoneProgressCreate = "window/workDoneProgress/create" - return true, reply(ctx, nil, err) + // MethodWindowShowMessage method name of "window/showMessage". + MethodWindowShowMessage = "window/showMessage" - case MethodWorkspaceSemanticTokensRefresh: // request - defer logger.Debug(MethodWorkspaceSemanticTokensRefresh, zap.Error(err)) + // MethodWindowShowMessageRequest method name of "window/showMessageRequest. + MethodWindowShowMessageRequest = "window/showMessageRequest" - err := client.WorkspaceSemanticTokensRefresh(ctx) + // MethodWindowLogMessage method name of "window/logMessage. + MethodWindowLogMessage = "window/logMessage" - return true, reply(ctx, nil, err) + // MethodTelemetryEvent method name of "telemetry/event. + MethodTelemetryEvent = "telemetry/event" - case MethodWorkspaceWorkspaceFolders: // request - defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) + // MethodClientRegisterCapability method name of "client/registerCapability. + MethodClientRegisterCapability = "client/registerCapability" - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) - } + // MethodClientUnregisterCapability method name of "client/unregisterCapability. + MethodClientUnregisterCapability = "client/unregisterCapability" - resp, err := client.WorkspaceWorkspaceFolders(ctx) + // MethodTextDocumentPublishDiagnostics method name of "textDocument/publishDiagnostics. + MethodTextDocumentPublishDiagnostics = "textDocument/publishDiagnostics" - return true, reply(ctx, resp, err) + // MethodWorkspaceApplyEdit method name of "workspace/applyEdit. + MethodWorkspaceApplyEdit = "workspace/applyEdit" - default: - return false, nil - } -} + // MethodWorkspaceConfiguration method name of "workspace/configuration. + MethodWorkspaceConfiguration = "workspace/configuration" + + // MethodWorkspaceWorkspaceFolders method name of "workspace/workspaceFolders". + MethodWorkspaceWorkspaceFolders = "workspace/workspaceFolders" +) // client implements a Language Server Protocol client. type client struct { @@ -271,13 +269,6 @@ type client struct { // compiler time check whether the Client implements ClientInterface interface. var _ Client = (*client)(nil) -func (c *client) CancelRequest(ctx context.Context, params *CancelParams) (err error) { - c.logger.Debug("notify " + MethodClientCancelRequest) - defer c.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) - - return c.Conn.Notify(ctx, MethodClientCancelRequest, params) -} - // Progress is the base protocol offers also support to report progress in a generic fashion. // // This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and @@ -285,25 +276,28 @@ func (c *client) CancelRequest(ctx context.Context, params *CancelParams) (err e // // @since 3.16.0. func (c *client) Progress(ctx context.Context, params *ProgressParams) (err error) { - c.logger.Debug("notify " + MethodClientProgress) - defer c.logger.Debug("end "+MethodClientProgress, zap.Error(err)) + c.logger.Debug("call " + MethodProgress) + defer c.logger.Debug("end "+MethodProgress, zap.Error(err)) - return c.Conn.Notify(ctx, MethodClientProgress, params) + return c.Conn.Notify(ctx, MethodProgress, params) } -func (c *client) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { - c.logger.Debug("notify " + MethodLogTrace) - defer c.logger.Debug("end "+MethodLogTrace, zap.Error(err)) +// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. +// +// @since 3.16.0. +func (c *client) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { + c.logger.Debug("call " + MethodWorkDoneProgressCreate) + defer c.logger.Debug("end "+MethodWorkDoneProgressCreate, zap.Error(err)) - return c.Conn.Notify(ctx, MethodLogTrace, params) + return Call(ctx, c.Conn, MethodWorkDoneProgressCreate, params, nil) } -// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. -func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { - c.logger.Debug("notify " + MethodTelemetryEvent) - defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) +// LogMessage sends the notification from the server to the client to ask the client to log a particular message. +func (c *client) LogMessage(ctx context.Context, params *LogMessageParams) (err error) { + c.logger.Debug("call " + MethodWindowLogMessage) + defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) - return c.Conn.Notify(ctx, MethodTelemetryEvent, params) + return c.Conn.Notify(ctx, MethodWindowLogMessage, params) } // PublishDiagnostics sends the notification from the server to the client to signal results of validation runs. @@ -316,28 +310,40 @@ func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { // When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. // If the computed set is empty it has to push the empty array to clear former diagnostics. // Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side. -func (c *client) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { - c.logger.Debug("notify " + MethodTextDocumentPublishDiagnostics) +func (c *client) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { + c.logger.Debug("call " + MethodTextDocumentPublishDiagnostics) defer c.logger.Debug("end "+MethodTextDocumentPublishDiagnostics, zap.Error(err)) return c.Conn.Notify(ctx, MethodTextDocumentPublishDiagnostics, params) } -// LogMessage sends the notification from the server to the client to ask the client to log a particular message. -func (c *client) WindowLogMessage(ctx context.Context, params *LogMessageParams) (err error) { - c.logger.Debug("notify " + MethodWindowLogMessage) - defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) +// ShowMessage sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { + return c.Conn.Notify(ctx, MethodWindowShowMessage, params) +} - return c.Conn.Notify(ctx, MethodWindowLogMessage, params) +// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. +// +// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. +func (c *client) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { + c.logger.Debug("call " + MethodWindowShowMessageRequest) + defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) + + var result *MessageActionItem + if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { + return nil, err + } + + return result, nil } -// ShowMessage sends the notification from a server to a client to ask the -// client to display a particular message in the user interface. -func (c *client) WindowShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { - c.logger.Debug("notify " + MethodWindowShowMessage) - defer c.logger.Debug("end "+MethodWindowShowMessage, zap.Error(err)) +// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. +func (c *client) Telemetry(ctx context.Context, params interface{}) (err error) { + c.logger.Debug("call " + MethodTelemetryEvent) + defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) - return c.Conn.Notify(ctx, MethodWindowShowMessage, params) + return c.Conn.Notify(ctx, MethodTelemetryEvent, params) } // RegisterCapability sends the request from the server to the client to register for a new capability on the client side. @@ -346,7 +352,7 @@ func (c *client) WindowShowMessage(ctx context.Context, params *ShowMessageParam // // A client opts in via the dynamicRegistration property on the specific client capabilities. // A client can even provide dynamic registration for capability A but not for capability B (see TextDocumentClientCapabilities as an example). -func (c *client) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { +func (c *client) RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { c.logger.Debug("call " + MethodClientRegisterCapability) defer c.logger.Debug("end "+MethodClientRegisterCapability, zap.Error(err)) @@ -354,54 +360,15 @@ func (c *client) ClientRegisterCapability(ctx context.Context, params *Registrat } // UnregisterCapability sends the request from the server to the client to unregister a previously registered capability. -func (c *client) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { +func (c *client) UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { c.logger.Debug("call " + MethodClientUnregisterCapability) defer c.logger.Debug("end "+MethodClientUnregisterCapability, zap.Error(err)) return Call(ctx, c.Conn, MethodClientUnregisterCapability, params, nil) } -// ShowMessage sends the notification from a server to a client to ask the -// client to display a particular message in the user interface. -func (c *client) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (_ *ShowDocumentResult, err error) { - c.logger.Debug("call " + MethodWindowShowDocument) - defer c.logger.Debug("end "+MethodWindowShowDocument, zap.Error(err)) - - var result *ShowDocumentResult - if err := Call(ctx, c.Conn, MethodWindowShowDocument, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. -// -// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. -func (c *client) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { - c.logger.Debug("call " + MethodWindowShowMessageRequest) - defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) - - var result *MessageActionItem - if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. -// -// @since 3.16.0. -func (c *client) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { - c.logger.Debug("call " + MethodWindowWorkDoneProgressCreate) - defer c.logger.Debug("end "+MethodWindowWorkDoneProgressCreate, zap.Error(err)) - - return Call(ctx, c.Conn, MethodWindowWorkDoneProgressCreate, params, nil) -} - // ApplyEdit sends the request from the server to the client to modify resource on the client side. -func (c *client) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResult, err error) { +func (c *client) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) { c.logger.Debug("call " + MethodWorkspaceApplyEdit) defer c.logger.Debug("end "+MethodWorkspaceApplyEdit, zap.Error(err)) @@ -412,20 +379,16 @@ func (c *client) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceE return result, nil } -func (c *client) WorkspaceCodeLensRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceCodeLensRefresh) -} - // Configuration sends the request from the server to the client to fetch configuration settings from the client. // // The request can fetch several configuration settings in one roundtrip. // The order of the returned configuration settings correspond to the order of the // passed ConfigurationItems (e.g. the first item in the response is the result for the first configuration item in the params). -func (c *client) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) (_ []any, err error) { +func (c *client) Configuration(ctx context.Context, params *ConfigurationParams) (_ []interface{}, err error) { c.logger.Debug("call " + MethodWorkspaceConfiguration) defer c.logger.Debug("end "+MethodWorkspaceConfiguration, zap.Error(err)) - var result []any + var result []interface{} if err := Call(ctx, c.Conn, MethodWorkspaceConfiguration, params, &result); err != nil { return nil, err } @@ -433,39 +396,12 @@ func (c *client) WorkspaceConfiguration(ctx context.Context, params *Configurati return result, nil } -func (c *client) WorkspaceDiagnosticRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceDiagnosticRefresh) -} - -func (c *client) WorkspaceFoldingRangeRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceFoldingRangeRefresh) -} - -func (c *client) WorkspaceInlayHintRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceInlayHintRefresh) -} - -func (c *client) WorkspaceInlineValueRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceInlineValueRefresh) -} - -func (c *client) WorkspaceSemanticTokensRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceSemanticTokensRefresh) -} - -func (c *client) refresh(ctx context.Context, method string) (err error) { - c.logger.Debug("call " + method) - defer c.logger.Debug("end "+method, zap.Error(err)) - - return c.Conn.Notify(ctx, method, nil) -} - // WorkspaceFolders sends the request from the server to the client to fetch the current open list of workspace folders. // // Returns null in the response if only a single file is open in the tool. Returns an empty array if a workspace is open but no folders are configured. // // @since 3.6.0. -func (c *client) WorkspaceWorkspaceFolders(ctx context.Context) (result []*WorkspaceFolder, err error) { +func (c *client) WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) { c.logger.Debug("call " + MethodWorkspaceWorkspaceFolders) defer c.logger.Debug("end "+MethodWorkspaceWorkspaceFolders, zap.Error(err)) @@ -475,3 +411,4 @@ func (c *client) WorkspaceWorkspaceFolders(ctx context.Context) (result []*Works return result, nil } + diff --git a/go.mod b/go.mod index 9f65d1f3..68663a43 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,16 @@ module go.lsp.dev/protocol go 1.22.2 require ( + github.com/google/go-cmp v0.6.0 + github.com/segmentio/encoding v0.4.0 go.lsp.dev/jsonrpc2 v0.10.0 + go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 go.lsp.dev/uri v0.3.0 go.uber.org/zap v1.27.0 ) require ( - github.com/google/go-cmp v0.6.0 // indirect github.com/segmentio/asm v1.1.3 // indirect - github.com/segmentio/encoding v0.4.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect ) diff --git a/go.sum b/go.sum index 4241d3ae..b092fc5d 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= go.lsp.dev/jsonrpc2 v0.10.0 h1:Pr/YcXJoEOTMc/b6OTmcR1DPJ3mSWl/SWiU1Cct6VmI= go.lsp.dev/jsonrpc2 v0.10.0/go.mod h1:fmEzIdXPi/rf6d4uFcayi8HpFP1nBF99ERP1htC72Ac= +go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 h1:hCzQgh6UcwbKgNSRurYWSqh8MufqRRPODRBblutn4TE= +go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2/go.mod h1:gtSHRuYfbCT0qnbLnovpie/WEmqyJ7T4n6VXiFMBtcw= go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo= go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= diff --git a/protocol/base.go b/protocol/base.go new file mode 100644 index 00000000..5d110210 --- /dev/null +++ b/protocol/base.go @@ -0,0 +1,57 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +// ErrorCodes predefined error codes. +type ErrorCodes int32 + +const ( + ParseErrorErrorCodes ErrorCodes = -32700 + + InvalidRequestErrorCodes ErrorCodes = -32600 + + MethodNotFoundErrorCodes ErrorCodes = -32601 + + InvalidParamsErrorCodes ErrorCodes = -32602 + + InternalErrorErrorCodes ErrorCodes = -32603 + + // ServerNotInitializedErrorCodes error code indicating that a server received a notification or request before the server has received the `initialize` request. + ServerNotInitializedErrorCodes ErrorCodes = -32002 + + UnknownErrorCodeErrorCodes ErrorCodes = -32001 +) + +type LSPErrorCodes int32 + +const ( + // RequestFailedLSPErrorCodes a request failed but it was syntactically correct, e.g the method name was known and the parameters were valid. The error message should contain human readable information about why the request failed. + // + // @since 3.17.0 + RequestFailedLSPErrorCodes LSPErrorCodes = -32803 + + // ServerCancelledLSPErrorCodes the server cancelled the request. This error code should only be used for requests that explicitly support being server cancellable. + // + // @since 3.17.0 + ServerCancelledLSPErrorCodes LSPErrorCodes = -32802 + + // ContentModifiedLSPErrorCodes the server detected that the content of a document got modified outside normal conditions. A server should NOT send this error code if it detects a content change in it unprocessed messages. The result even computed on an older state might still be useful for the client. If a client decides that a result is not of any use anymore the client should cancel the request. + ContentModifiedLSPErrorCodes LSPErrorCodes = -32801 + + // RequestCancelledLSPErrorCodes the client has canceled a request and a server as detected the cancel. + RequestCancelledLSPErrorCodes LSPErrorCodes = -32800 +) + +type CancelParams struct { + // ID the request id to cancel. + ID CancelParamsID `json:"id"` +} + +type ProgressParams struct { + // Token the progress token provided by the client or server. + Token ProgressToken `json:"token"` + + // Value the progress data. + Value any `json:"value"` +} diff --git a/protocol/basic.go b/protocol/basic.go new file mode 100644 index 00000000..e661f2c9 --- /dev/null +++ b/protocol/basic.go @@ -0,0 +1,570 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "go.lsp.dev/uri" +) + +type TraceValue string + +const ( + // OffTraceValue turn tracing off. + OffTraceValue TraceValue = "off" + + // MessagesTraceValue trace messages only. + MessagesTraceValue TraceValue = "messages" + + // VerboseTraceValue verbose message tracing. + VerboseTraceValue TraceValue = "verbose" +) + +// MarkupKind describes the content type that a client supports in various result literals like `Hover`, `ParameterInfo` or `CompletionItem`. Please note that `MarkupKinds` must not start with a `$`. This kinds are +// reserved for internal usage. +type MarkupKind string + +const ( + // PlainTextMarkupKind plain text is supported as a content format. + PlainTextMarkupKind MarkupKind = "plaintext" + + // MarkdownMarkupKind markdown is supported as a content format. + MarkdownMarkupKind MarkupKind = "markdown" +) + +// LanguageKind predefined Language kinds 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type LanguageKind string + +const ( + AbapLanguageKind LanguageKind = "abap" + + WindowsBatLanguageKind LanguageKind = "bat" + + BibTeXLanguageKind LanguageKind = "bibtex" + + ClojureLanguageKind LanguageKind = "clojure" + + CoffeescriptLanguageKind LanguageKind = "coffeescript" + + CLanguageKind LanguageKind = "c" + + CppLanguageKind LanguageKind = "cpp" + + CsharpLanguageKind LanguageKind = "csharp" + + CssLanguageKind LanguageKind = "css" + + // DLanguageKind. + // + // @since 3.18.0 proposed + DLanguageKind LanguageKind = "d" + + // DelphiLanguageKind. + // + // @since 3.18.0 proposed + DelphiLanguageKind LanguageKind = "pascal" + + DiffLanguageKind LanguageKind = "diff" + + DartLanguageKind LanguageKind = "dart" + + DockerfileLanguageKind LanguageKind = "dockerfile" + + ElixirLanguageKind LanguageKind = "elixir" + + ErlangLanguageKind LanguageKind = "erlang" + + FsharpLanguageKind LanguageKind = "fsharp" + + GitCommitLanguageKind LanguageKind = "git-commit" + + GitRebaseLanguageKind LanguageKind = "rebase" + + GoLanguageKind LanguageKind = "go" + + GroovyLanguageKind LanguageKind = "groovy" + + HandlebarsLanguageKind LanguageKind = "handlebars" + + HTMLLanguageKind LanguageKind = "html" + + IniLanguageKind LanguageKind = "ini" + + JavaLanguageKind LanguageKind = "java" + + JavaScriptLanguageKind LanguageKind = "javascript" + + JavaScriptReactLanguageKind LanguageKind = "javascriptreact" + + JSONLanguageKind LanguageKind = "json" + + LaTeXLanguageKind LanguageKind = "latex" + + LessLanguageKind LanguageKind = "less" + + LuaLanguageKind LanguageKind = "lua" + + MakefileLanguageKind LanguageKind = "makefile" + + MarkdownLanguageKind LanguageKind = "markdown" + + ObjectiveCLanguageKind LanguageKind = "objective-c" + + ObjectiveCPPLanguageKind LanguageKind = "objective-cpp" + + // PascalLanguageKind. + // + // @since 3.18.0 proposed + PascalLanguageKind LanguageKind = "pascal" + + PerlLanguageKind LanguageKind = "perl" + + Perl6LanguageKind LanguageKind = "perl6" + + PhpLanguageKind LanguageKind = "php" + + PowershellLanguageKind LanguageKind = "powershell" + + PugLanguageKind LanguageKind = "jade" + + PythonLanguageKind LanguageKind = "python" + + RLanguageKind LanguageKind = "r" + + RazorLanguageKind LanguageKind = "razor" + + RubyLanguageKind LanguageKind = "ruby" + + RustLanguageKind LanguageKind = "rust" + + ScssLanguageKind LanguageKind = "scss" + + SassLanguageKind LanguageKind = "sass" + + ScalaLanguageKind LanguageKind = "scala" + + ShaderLabLanguageKind LanguageKind = "shaderlab" + + ShellScriptLanguageKind LanguageKind = "shellscript" + + SQLLanguageKind LanguageKind = "sql" + + SwiftLanguageKind LanguageKind = "swift" + + TypeScriptLanguageKind LanguageKind = "typescript" + + TypeScriptReactLanguageKind LanguageKind = "typescriptreact" + + TeXLanguageKind LanguageKind = "tex" + + VisualBasicLanguageKind LanguageKind = "vb" + + XmlLanguageKind LanguageKind = "xml" + + XslLanguageKind LanguageKind = "xsl" + + YamlLanguageKind LanguageKind = "yaml" +) + +// PositionEncodingKind a set of predefined position encoding kinds. +// +// @since 3.17.0 +type PositionEncodingKind string + +const ( + // UTF8PositionEncodingKind character offsets count UTF-8 code units (e.g. bytes). + UTF8PositionEncodingKind PositionEncodingKind = "utf-8" + + // Utf16PositionEncodingKind character offsets count UTF-16 code units. This is the default and must always be supported by servers. + Utf16PositionEncodingKind PositionEncodingKind = "utf-16" + + // Utf32PositionEncodingKind character offsets count UTF-32 code units. Implementation note: these are the same as Unicode codepoints, so this `PositionEncodingKind` may also be used for an encoding-agnostic representation of character offsets. + Utf32PositionEncodingKind PositionEncodingKind = "utf-32" +) + +// DiagnosticSeverity the diagnostic's severity. +type DiagnosticSeverity uint32 + +const ( + // ErrorDiagnosticSeverity reports an error. + ErrorDiagnosticSeverity DiagnosticSeverity = 1 + + // WarningDiagnosticSeverity reports a warning. + WarningDiagnosticSeverity DiagnosticSeverity = 2 + + // InformationDiagnosticSeverity reports an information. + InformationDiagnosticSeverity DiagnosticSeverity = 3 + + // HintDiagnosticSeverity reports a hint. + HintDiagnosticSeverity DiagnosticSeverity = 4 +) + +// DiagnosticTag the diagnostic tags. +// +// @since 3.15.0 +type DiagnosticTag uint32 + +const ( + // UnnecessaryDiagnosticTag unused or unnecessary code. Clients are allowed to render diagnostics with this tag faded out instead of having an error squiggle. + UnnecessaryDiagnosticTag DiagnosticTag = 1 + + // DeprecatedDiagnosticTag deprecated or obsolete code. Clients are allowed to rendered diagnostics with this tag strike through. + DeprecatedDiagnosticTag DiagnosticTag = 2 +) + +type ResourceOperationKind string + +const ( + // CreateResourceOperationKind supports creating new files and folders. + CreateResourceOperationKind ResourceOperationKind = "create" + + // RenameResourceOperationKind supports renaming existing files and folders. + RenameResourceOperationKind ResourceOperationKind = "rename" + + // DeleteResourceOperationKind supports deleting existing files and folders. + DeleteResourceOperationKind ResourceOperationKind = "delete" +) + +type FailureHandlingKind string + +const ( + // AbortFailureHandlingKind applying the workspace change is simply aborted if one of the changes provided fails. All operations + // executed before the failing operation stay executed. + AbortFailureHandlingKind FailureHandlingKind = "abort" + + // TransactionalFailureHandlingKind all operations are executed transactional. That means they either all succeed or no changes at all are applied to the workspace. + TransactionalFailureHandlingKind FailureHandlingKind = "transactional" + + // TextOnlyTransactionalFailureHandlingKind if the workspace edit contains only textual file changes they are executed transactional. If resource changes (create, rename or delete file) are part of the change the failure handling strategy is abort. + TextOnlyTransactionalFailureHandlingKind FailureHandlingKind = "textOnlyTransactional" + + // UndoFailureHandlingKind the client tries to undo the operations already executed. But there is no guarantee that this is succeeding. + UndoFailureHandlingKind FailureHandlingKind = "undo" +) + +// TextDocumentIdentifier a literal to identify a text document in the client. +type TextDocumentIdentifier struct { + // URI the text document's uri. + URI DocumentURI `json:"uri"` +} + +// Position position in a text document expressed as zero-based line and character offset. Prior to 3.17 the offsets were always based on a UTF-16 string representation. So a string of the form `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀` is 1 and the character offset of b is 3 since `𐐀` is represented using two code units in UTF-16. Since 3.17 clients and servers +// can agree on a different string encoding representation (e.g. UTF-8). The client announces it's supported encoding via the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities). The value is an array of position encodings the client supports, with decreasing preference (e.g. the encoding at index `0` is the most preferred one). To stay backwards compatible the only mandatory encoding is +// UTF-16 represented via the string `utf-16`. The server can pick one of the encodings offered by the client and signals that encoding back to the client via the initialize result's property [`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value `utf-16` is missing from the client's capability `general.positionEncodings` servers can safely assume that the client supports UTF-16. If the server omits the position encoding in its initialize result the encoding defaults to the string value `utf-16`. Implementation considerations: since the conversion from one encoding into another requires the content of the file / line the conversion is best done where the file is read which is usually on the server side. Positions are line end character agnostic. So you can not specify a position that denotes `\r|\n` or `\n|` where `|` represents the character offset. 3.17.0 - support for negotiated position encoding. +// +// @since 3.17.0 - support for negotiated position encoding. +type Position struct { + // Line line position in a document (zero-based). If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document. If a line number is negative, it defaults to . + // + // @since 3.17.0 - support for negotiated position encoding. + Line uint32 `json:"line"` + + // Character character offset on a line in a document (zero-based). The meaning of this offset is determined by the negotiated `PositionEncodingKind`. If the character value is greater than the line length it defaults back to the line length. + // + // @since 3.17.0 - support for negotiated position encoding. + Character uint32 `json:"character"` +} + +// TextDocumentPositionParams a parameter literal used in requests to pass a text document and a position inside that document. +type TextDocumentPositionParams struct { + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Position the position inside the text document. + Position Position `json:"position"` +} + +// Range a range in a text document expressed as (zero-based) start and end positions. If you want to specify +// a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line. For example: ```ts { start: { line: 5, character: 23 } end : { line 6, character : 0 } } ```. +type Range struct { + // Start the range's start position. + Start Position `json:"start"` + + // End the range's end position. + End Position `json:"end"` +} + +// Location represents a location inside a resource, such as a line inside a text file. +type Location struct { + URI DocumentURI `json:"uri"` + + Range Range `json:"range"` +} + +// TextEdit a text edit applicable to a text document. +type TextEdit struct { + // Range the range of the text document to be manipulated. To insert text into a document create a range where start === end. + Range Range `json:"range"` + + // NewText the string to be inserted. For delete operations use an empty string. + NewText string `json:"newText"` +} + +type WorkDoneProgressOptions struct { + WorkDoneProgress bool `json:"workDoneProgress,omitempty"` +} + +// OptionalVersionedTextDocumentIdentifier a text document identifier to optionally denote a specific version of a text document. +type OptionalVersionedTextDocumentIdentifier struct { + // extends + TextDocumentIdentifier + + // Version the version number of this document. If a versioned text document identifier is sent from the server + // to the client and the file is not open in the editor (the server has not received an open notification before) the server can send `null` to indicate that the version is unknown and the content on disk is the truth (as specified with document content ownership). + Version int32 `json:"version,omitempty"` +} + +// AnnotatedTextEdit a special text edit with an additional change annotation. +// +// @since 3.16.0. +type AnnotatedTextEdit struct { + // extends + TextEdit + + // AnnotationID the actual identifier of the change annotation. + // + // @since 3.16.0. + AnnotationID ChangeAnnotationIdentifier `json:"annotationId"` +} + +// TextDocumentEdit describes textual changes on a text document. A TextDocumentEdit describes all changes on a document +// version Si and after they are applied move the document to version Si+1. So the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any kind of ordering. However the edits must be non overlapping. +type TextDocumentEdit struct { + // TextDocument the text document to change. + TextDocument OptionalVersionedTextDocumentIdentifier `json:"textDocument"` + + // Edits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. + Edits TextDocumentEditEdits `json:"edits"` +} + +// ChangeAnnotation additional information that describes document changes. +// +// @since 3.16.0 +type ChangeAnnotation struct { + // Label a human-readable string describing the actual change. The string is rendered prominent in the user interface. + // + // @since 3.16.0 + Label string `json:"label"` + + // NeedsConfirmation a flag which indicates that user confirmation is needed before applying the change. + // + // @since 3.16.0 + NeedsConfirmation bool `json:"needsConfirmation,omitempty"` + + // Description a human-readable string which is rendered less prominent in the user interface. + // + // @since 3.16.0 + Description string `json:"description,omitempty"` +} + +// WorkspaceEdit a workspace edit represents changes to many resources managed in the workspace. The edit should either provide `changes` or `documentChanges`. If documentChanges are present they are preferred over `changes` if the client can handle versioned document edits. Since version 3.13.0 a workspace edit can +// contain resource operations as well. If resource operations are present clients need to execute the operations in the order in which they are provided. So a workspace edit for example can consist of the following two changes: (1) a create file a.txt and (2) a text document edit which insert text into file a.txt. An invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will cause failure of the operation. How the client recovers from the failure is described by the client capability: `workspace.workspaceEdit.failureHandling`. +type WorkspaceEdit struct { + // Changes holds changes to existing resources. + Changes map[DocumentURI][]TextEdit `json:"changes,omitempty"` + + // DocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are + // either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. + DocumentChanges WorkspaceEditDocumentChanges `json:"documentChanges,omitempty"` + + // ChangeAnnotations a map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and delete file / folder operations. Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`. + ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"` +} + +// MarkupContent a `MarkupContent` literal represents a string value which content is interpreted base on its kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds. If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting Here is an example how such a +// string can be constructed using JavaScript / TypeScript: ```ts let markdown: MarkdownContent = +// { kind: MarkupKind.Markdown, value: [ '# Header', 'Some text', '```typescript', 'someCode();', +// '```' ].join('\n') }; ``` *Please Note* that clients might sanitize the return markdown. A client could decide to remove HTML from the markdown to avoid script execution. +type MarkupContent struct { + // Kind the type of the Markup. + Kind MarkupKind `json:"kind"` + + // Value the content itself. + Value string `json:"value"` +} + +// Command represents a reference to a command. Provides a title which will be used to represent a command in the UI and, optionally, an array of arguments which will be passed to the command handler function when invoked. +type Command struct { + // Title title of the command, like `save`. + Title string `json:"title"` + + // Tooltip an optional tooltip. 3.18.0 @proposed. + Tooltip string `json:"tooltip,omitempty"` + + // Command the identifier of the actual command handler. + Command string `json:"command"` + + // Arguments arguments that the command handler should be invoked with. + Arguments []any `json:"arguments,omitempty"` +} + +// CodeDescription structure to capture a description for an error code. +// +// @since 3.16.0 +type CodeDescription struct { + // Href an URI to open with more information about the diagnostic error. + // + // @since 3.16.0 + Href uri.URI `json:"href"` +} + +// DiagnosticRelatedInformation represents a related message and source code location for a diagnostic. This should be used to point +// to code locations that cause or related to a diagnostics, e.g when duplicating a symbol in a scope. +type DiagnosticRelatedInformation struct { + // Location the location of this related diagnostic information. + Location Location `json:"location"` + + // Message the message of this related diagnostic information. + Message string `json:"message"` +} + +// Diagnostic represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a resource. +type Diagnostic struct { + // Range the range at which the message applies. + Range Range `json:"range"` + + // Severity the diagnostic's severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint. + Severity DiagnosticSeverity `json:"severity,omitempty"` + + // Code the diagnostic's code, which usually appear in the user interface. + Code DiagnosticCode `json:"code,omitempty"` + + // CodeDescription an optional property to describe the error code. Requires the code field (above) to be present/not null. + CodeDescription *CodeDescription `json:"codeDescription,omitempty"` + + // Source a human-readable string describing the source of this diagnostic, e.g. 'typescript' or 'super lint'. + // It usually appears in the user interface. + Source string `json:"source,omitempty"` + + // Message the diagnostic's message. It usually appears in the user interface. + Message string `json:"message"` + + // Tags additional metadata about the diagnostic. + Tags []DiagnosticTag `json:"tags,omitempty"` + + // RelatedInformation an array of related diagnostic information, e.g. when symbol-names within a scope collide all definitions can be marked via this property. + RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"` + + // Data a data entry field that is preserved between a `textDocument/publishDiagnostics` notification and `textDocument/codeAction` request. + Data any `json:"data,omitempty"` +} + +// TextDocumentItem an item to transfer a text document from the client to the server. +type TextDocumentItem struct { + // URI the text document's uri. + URI DocumentURI `json:"uri"` + + // LanguageID the text document's language identifier. + LanguageID LanguageKind `json:"languageId"` + + // Version the version number of this document (it will increase after each change, including undo/redo). + Version int32 `json:"version"` + + // Text the content of the opened text document. + Text string `json:"text"` +} + +// VersionedTextDocumentIdentifier a text document identifier to denote a specific version of a text document. +type VersionedTextDocumentIdentifier struct { + // extends + TextDocumentIdentifier + + // Version the version number of this document. + Version int32 `json:"version"` +} + +// StringValue a string value used as a snippet is a template which allows to insert text and to control the editor +// cursor when insertion happens. A snippet can define tab stops and placeholders with `$1`, `$2` +// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Variables are defined with `$name` and `${name:default value}`. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type StringValue struct { + // Value the snippet string. + // + // @since 3.18.0 proposed + Value string `json:"value"` +} + +// ChangeAnnotationsSupportOptions. +// +// @since 3.18.0 proposed +type ChangeAnnotationsSupportOptions struct { + // GroupsOnLabel whether the client groups edits with equal labels into tree nodes, for instance all edits labelled with "Changes in Strings" would be a tree node. + // + // @since 3.18.0 proposed + GroupsOnLabel bool `json:"groupsOnLabel,omitempty"` +} + +type WorkspaceEditClientCapabilities struct { + // DocumentChanges the client supports versioned document changes in `WorkspaceEdit`s. + DocumentChanges bool `json:"documentChanges,omitempty"` + + // ResourceOperations the resource operations the client supports. Clients should at least support 'create', 'rename' and 'delete' files and folders. + ResourceOperations []ResourceOperationKind `json:"resourceOperations,omitempty"` + + // FailureHandling the failure handling strategy of a client if applying the workspace edit fails. + FailureHandling FailureHandlingKind `json:"failureHandling,omitempty"` + + // NormalizesLineEndings whether the client normalizes line endings to the client specific setting. If set to `true` the client will normalize line ending characters in a workspace edit to the client-specified new line character. + NormalizesLineEndings bool `json:"normalizesLineEndings,omitempty"` + + // ChangeAnnotationSupport whether the client in general supports change annotations on text edits, create file, rename file and delete file changes. + ChangeAnnotationSupport *ChangeAnnotationsSupportOptions `json:"changeAnnotationSupport,omitempty"` +} + +type WorkDoneProgressBegin struct { + // Title mandatory title of the progress operation. Used to briefly inform about the kind of operation being performed. Examples: "Indexing" or "Linking dependencies". + Title string `json:"title"` + + // Cancellable controls if a cancel button should show to allow the user to cancel the long running operation. Clients that don't support cancellation are allowed to ignore the setting. + Cancellable bool `json:"cancellable,omitempty"` + + // Message optional, more detailed associated progress message. Contains complementary information to the `title`. Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". If unset, the previous progress message (if any) is still valid. + Message string `json:"message,omitempty"` + + // Percentage optional progress percentage to display (value 100 is considered 100%). If not provided infinite progress is assumed and clients are allowed to ignore the `percentage` value in subsequent in report notifications. The value should be steadily rising. Clients are free to ignore values that are not following this rule. The value range is [0, 100]. + Percentage uint32 `json:"percentage,omitempty"` +} + +type WorkDoneProgressReport struct { + // Cancellable controls enablement state of a cancel button. Clients that don't support cancellation or don't support controlling the button's enablement state are allowed to ignore the property. + Cancellable bool `json:"cancellable,omitempty"` + + // Message optional, more detailed associated progress message. Contains complementary information to the `title`. Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". If unset, the previous progress message (if any) is still valid. + Message string `json:"message,omitempty"` + + // Percentage optional progress percentage to display (value 100 is considered 100%). If not provided infinite progress is assumed and clients are allowed to ignore the `percentage` value in subsequent in report notifications. The value should be steadily rising. Clients are free to ignore values that are not following this rule. The value range is [0, 100]. + Percentage uint32 `json:"percentage,omitempty"` +} + +type WorkDoneProgressEnd struct { + // Message optional, a final message indicating to for example indicate the outcome of the operation. + Message string `json:"message,omitempty"` +} + +type WorkDoneProgressParams struct { + // WorkDoneToken an optional token that a server can use to report work done progress. + WorkDoneToken *ProgressToken `json:"workDoneToken,omitempty"` +} + +type PartialResultParams struct { + // PartialResultToken an optional token that a server can use to report partial results (e.g. streaming) to the client. + PartialResultToken *ProgressToken `json:"partialResultToken,omitempty"` +} + +// LocationLink represents the connection of two locations. Provides additional metadata over normal Location locations, including an origin range. +type LocationLink struct { + // OriginSelectionRange span of the origin of this link. Used as the underlined span for mouse interaction. Defaults to the word range at the definition position. + OriginSelectionRange *Range `json:"originSelectionRange,omitempty"` + + // TargetURI the target resource identifier of this link. + TargetURI DocumentURI `json:"targetUri"` + + // TargetRange the full target range of this link. If the target for example is a symbol then target range is the range enclosing this symbol not including leading/trailing whitespace but everything else like comments. This information is typically used to highlight the range in the editor. + TargetRange Range `json:"targetRange"` + + // TargetSelectionRange the range that should be selected and revealed when this link is being followed, e.g the name of a function. Must be contained by the `targetRange`. See also `DocumentSymbol#range`. + TargetSelectionRange Range `json:"targetSelectionRange"` +} diff --git a/protocol/client.go b/protocol/client.go new file mode 100644 index 00000000..806f0131 --- /dev/null +++ b/protocol/client.go @@ -0,0 +1,477 @@ +// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "bytes" + "context" + "fmt" + + "go.uber.org/zap" + + "go.lsp.dev/jsonrpc2" +) + +// ClientDispatcher returns a Client that dispatches LSP requests across the +// given jsonrpc2 connection. +func ClientDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Client { + return &client{ + Conn: conn, + logger: logger, + } +} + +// ClientHandler handler of LSP client. +func ClientHandler(client Client, handler jsonrpc2.Handler) jsonrpc2.Handler { + h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { + if ctx.Err() != nil { + xctx := context.WithoutCancel(ctx) + + return reply(xctx, nil, ErrRequestCancelled) + } + + handled, err := clientDispatch(ctx, client, reply, req) + if handled || err != nil { + return err + } + + return handler(ctx, reply, req) + } + + return h +} + +// clientDispatch implements jsonrpc2.Handler. +// +//nolint:funlen,cyclop +func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, req jsonrpc2.Request) (handled bool, err error) { + if ctx.Err() != nil { + return true, reply(ctx, nil, ErrRequestCancelled) + } + + dec := newDecoder(bytes.NewReader(req.Params())) + logger := LoggerFromContext(ctx) + + switch req.Method() { + case MethodClientProgress: // notification + defer logger.Debug(MethodClientProgress, zap.Error(err)) + + var params ProgressParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.Progress(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodLogTrace: // notification + defer logger.Debug(MethodLogTrace, zap.Error(err)) + + var params LogTraceParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.LogTrace(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodTelemetryEvent: // notification + defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) + + var params any + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.TelemetryEvent(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodTextDocumentPublishDiagnostics: // notification + defer logger.Debug(MethodTextDocumentPublishDiagnostics, zap.Error(err)) + + var params PublishDiagnosticsParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.TextDocumentPublishDiagnostics(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWindowLogMessage: // notification + defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) + + var params LogMessageParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.WindowLogMessage(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWindowShowMessage: // notification + defer logger.Debug(MethodWindowShowMessage, zap.Error(err)) + + var params ShowMessageParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.WindowShowMessage(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodClientRegisterCapability: // request + defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) + + var params RegistrationParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.ClientRegisterCapability(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodClientUnregisterCapability: // request + defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) + + var params UnregistrationParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.ClientUnregisterCapability(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWindowShowDocument: // request + defer logger.Debug(MethodWindowShowDocument, zap.Error(err)) + + var params ShowDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := client.WindowShowDocument(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWindowShowMessageRequest: // request + defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) + + var params ShowMessageRequestParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := client.WindowShowMessageRequest(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWindowWorkDoneProgressCreate: // request + defer logger.Debug(MethodWindowWorkDoneProgressCreate, zap.Error(err)) + + var params WorkDoneProgressCreateParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.WindowWorkDoneProgressCreate(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceApplyEdit: // request + defer logger.Debug(MethodWorkspaceApplyEdit, zap.Error(err)) + + var params ApplyWorkspaceEditParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := client.WorkspaceApplyEdit(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceCodeLensRefresh: // request + defer logger.Debug(MethodWorkspaceCodeLensRefresh, zap.Error(err)) + + err := client.WorkspaceCodeLensRefresh(ctx) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceConfiguration: // request + defer logger.Debug(MethodWorkspaceConfiguration, zap.Error(err)) + + var params ConfigurationParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := client.WorkspaceConfiguration(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceDiagnosticRefresh: // request + defer logger.Debug(MethodWorkspaceDiagnosticRefresh, zap.Error(err)) + + err := client.WorkspaceDiagnosticRefresh(ctx) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceFoldingRangeRefresh: // request + defer logger.Debug(MethodWorkspaceFoldingRangeRefresh, zap.Error(err)) + + err := client.WorkspaceFoldingRangeRefresh(ctx) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceInlayHintRefresh: // request + defer logger.Debug(MethodWorkspaceInlayHintRefresh, zap.Error(err)) + + err := client.WorkspaceInlayHintRefresh(ctx) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceSemanticTokensRefresh: // request + defer logger.Debug(MethodWorkspaceSemanticTokensRefresh, zap.Error(err)) + + err := client.WorkspaceSemanticTokensRefresh(ctx) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceWorkspaceFolders: // request + defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) + + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } + + resp, err := client.WorkspaceWorkspaceFolders(ctx) + + return true, reply(ctx, resp, err) + + default: + return false, nil + } +} + +// client implements a Language Server Protocol client. +type client struct { + jsonrpc2.Conn + + logger *zap.Logger +} + +// compiler time check whether the Client implements ClientInterface interface. +var _ Client = (*client)(nil) + +func (c *client) CancelRequest(ctx context.Context, params *CancelParams) (err error) { + c.logger.Debug("notify " + MethodClientCancelRequest) + defer c.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodClientCancelRequest, params) +} + +// Progress is the base protocol offers also support to report progress in a generic fashion. +// +// This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and +// partial result progress to support streaming of results. +// +// @since 3.16.0. +func (c *client) Progress(ctx context.Context, params *ProgressParams) (err error) { + c.logger.Debug("notify " + MethodClientProgress) + defer c.logger.Debug("end "+MethodClientProgress, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodClientProgress, params) +} + +func (c *client) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { + c.logger.Debug("notify " + MethodLogTrace) + defer c.logger.Debug("end "+MethodLogTrace, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodLogTrace, params) +} + +// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. +func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { + c.logger.Debug("notify " + MethodTelemetryEvent) + defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodTelemetryEvent, params) +} + +// PublishDiagnostics sends the notification from the server to the client to signal results of validation runs. +// +// Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary. The following rule is used for VS Code servers that generate diagnostics: +// +// - if a language is single file only (for example HTML) then diagnostics are cleared by the server when the file is closed. +// - if a language has a project system (for example C#) diagnostics are not cleared when a file closes. When a project is opened all diagnostics for all files are recomputed (or read from a cache). +// +// When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. +// If the computed set is empty it has to push the empty array to clear former diagnostics. +// Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side. +func (c *client) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { + c.logger.Debug("notify " + MethodTextDocumentPublishDiagnostics) + defer c.logger.Debug("end "+MethodTextDocumentPublishDiagnostics, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodTextDocumentPublishDiagnostics, params) +} + +// LogMessage sends the notification from the server to the client to ask the client to log a particular message. +func (c *client) WindowLogMessage(ctx context.Context, params *LogMessageParams) (err error) { + c.logger.Debug("notify " + MethodWindowLogMessage) + defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodWindowLogMessage, params) +} + +// ShowMessage sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) WindowShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { + c.logger.Debug("notify " + MethodWindowShowMessage) + defer c.logger.Debug("end "+MethodWindowShowMessage, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodWindowShowMessage, params) +} + +// RegisterCapability sends the request from the server to the client to register for a new capability on the client side. +// +// Not all clients need to support dynamic capability registration. +// +// A client opts in via the dynamicRegistration property on the specific client capabilities. +// A client can even provide dynamic registration for capability A but not for capability B (see TextDocumentClientCapabilities as an example). +func (c *client) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { + c.logger.Debug("call " + MethodClientRegisterCapability) + defer c.logger.Debug("end "+MethodClientRegisterCapability, zap.Error(err)) + + return Call(ctx, c.Conn, MethodClientRegisterCapability, params, nil) +} + +// UnregisterCapability sends the request from the server to the client to unregister a previously registered capability. +func (c *client) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { + c.logger.Debug("call " + MethodClientUnregisterCapability) + defer c.logger.Debug("end "+MethodClientUnregisterCapability, zap.Error(err)) + + return Call(ctx, c.Conn, MethodClientUnregisterCapability, params, nil) +} + +// ShowMessage sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (_ *ShowDocumentResult, err error) { + c.logger.Debug("call " + MethodWindowShowDocument) + defer c.logger.Debug("end "+MethodWindowShowDocument, zap.Error(err)) + + var result *ShowDocumentResult + if err := Call(ctx, c.Conn, MethodWindowShowDocument, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. +// +// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. +func (c *client) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { + c.logger.Debug("call " + MethodWindowShowMessageRequest) + defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) + + var result *MessageActionItem + if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. +// +// @since 3.16.0. +func (c *client) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { + c.logger.Debug("call " + MethodWindowWorkDoneProgressCreate) + defer c.logger.Debug("end "+MethodWindowWorkDoneProgressCreate, zap.Error(err)) + + return Call(ctx, c.Conn, MethodWindowWorkDoneProgressCreate, params, nil) +} + +// ApplyEdit sends the request from the server to the client to modify resource on the client side. +func (c *client) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResult, err error) { + c.logger.Debug("call " + MethodWorkspaceApplyEdit) + defer c.logger.Debug("end "+MethodWorkspaceApplyEdit, zap.Error(err)) + + if err := Call(ctx, c.Conn, MethodWorkspaceApplyEdit, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (c *client) WorkspaceCodeLensRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceCodeLensRefresh) +} + +// Configuration sends the request from the server to the client to fetch configuration settings from the client. +// +// The request can fetch several configuration settings in one roundtrip. +// The order of the returned configuration settings correspond to the order of the +// passed ConfigurationItems (e.g. the first item in the response is the result for the first configuration item in the params). +func (c *client) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) (_ []any, err error) { + c.logger.Debug("call " + MethodWorkspaceConfiguration) + defer c.logger.Debug("end "+MethodWorkspaceConfiguration, zap.Error(err)) + + var result []any + if err := Call(ctx, c.Conn, MethodWorkspaceConfiguration, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (c *client) WorkspaceDiagnosticRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceDiagnosticRefresh) +} + +func (c *client) WorkspaceFoldingRangeRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceFoldingRangeRefresh) +} + +func (c *client) WorkspaceInlayHintRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceInlayHintRefresh) +} + +func (c *client) WorkspaceInlineValueRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceInlineValueRefresh) +} + +func (c *client) WorkspaceSemanticTokensRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceSemanticTokensRefresh) +} + +func (c *client) refresh(ctx context.Context, method string) (err error) { + c.logger.Debug("call " + method) + defer c.logger.Debug("end "+method, zap.Error(err)) + + return c.Conn.Notify(ctx, method, nil) +} + +// WorkspaceFolders sends the request from the server to the client to fetch the current open list of workspace folders. +// +// Returns null in the response if only a single file is open in the tool. Returns an empty array if a workspace is open but no folders are configured. +// +// @since 3.6.0. +func (c *client) WorkspaceWorkspaceFolders(ctx context.Context) (result []*WorkspaceFolder, err error) { + c.logger.Debug("call " + MethodWorkspaceWorkspaceFolders) + defer c.logger.Debug("end "+MethodWorkspaceWorkspaceFolders, zap.Error(err)) + + if err := Call(ctx, c.Conn, MethodWorkspaceWorkspaceFolders, nil, &result); err != nil { + return nil, err + } + + return result, nil +} diff --git a/client_interface.go b/protocol/client_interface.go similarity index 100% rename from client_interface.go rename to protocol/client_interface.go diff --git a/protocol/context.go b/protocol/context.go new file mode 100644 index 00000000..81ccb888 --- /dev/null +++ b/protocol/context.go @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: 2020 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "context" + + "go.uber.org/zap" +) + +type ( + ctxLogger struct{} + ctxClient struct{} +) + +// WithLogger returns the context with zap.Logger value. +func WithLogger(ctx context.Context, logger *zap.Logger) context.Context { + return context.WithValue(ctx, ctxLogger{}, logger) +} + +// LoggerFromContext extracts zap.Logger from context. +func LoggerFromContext(ctx context.Context) *zap.Logger { + logger, ok := ctx.Value(ctxLogger{}).(*zap.Logger) + if !ok { + return zap.NewNop() + } + + return logger +} + +// WithClient returns the context with Client value. +func WithClient(ctx context.Context, client Client) context.Context { + return context.WithValue(ctx, ctxClient{}, client) +} diff --git a/protocol/document.go b/protocol/document.go new file mode 100644 index 00000000..1d7400ea --- /dev/null +++ b/protocol/document.go @@ -0,0 +1,470 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "go.lsp.dev/uri" +) + +// TextDocumentSaveReason represents reasons why a text document is saved. +type TextDocumentSaveReason uint32 + +const ( + // ManualTextDocumentSaveReason manually triggered, e.g. by the user pressing save, by starting debugging, or by an API call. + ManualTextDocumentSaveReason TextDocumentSaveReason = 1 + + // AfterDelayTextDocumentSaveReason automatic after a delay. + AfterDelayTextDocumentSaveReason TextDocumentSaveReason = 2 + + // FocusOutTextDocumentSaveReason when the editor lost focus. + FocusOutTextDocumentSaveReason TextDocumentSaveReason = 3 +) + +// NotebookCellKind a notebook cell kind. +// +// @since 3.17.0 +type NotebookCellKind uint32 + +const ( + // MarkupNotebookCellKind a markup-cell is formatted source that is used for display. + MarkupNotebookCellKind NotebookCellKind = 1 + + // CodeNotebookCellKind a code-cell is source code. + CodeNotebookCellKind NotebookCellKind = 2 +) + +type ExecutionSummary struct { + // ExecutionOrder a strict monotonically increasing value indicating the execution order of a cell inside a notebook. + ExecutionOrder uint32 `json:"executionOrder"` + + // Success whether the execution was successful or not if known by the client. + Success bool `json:"success,omitempty"` +} + +// NotebookCell a notebook cell. A cell's document URI must be unique across ALL notebook cells and can therefore be +// used to uniquely identify a notebook cell or the cell's text document. +// +// @since 3.17.0 +type NotebookCell struct { + // Kind the cell's kind. + // + // @since 3.17.0 + Kind NotebookCellKind `json:"kind"` + + // Document the URI of the cell's text document content. + // + // @since 3.17.0 + Document DocumentURI `json:"document"` + + // Metadata additional metadata stored with the cell. Note: should always be an object literal (e.g. LSPObject). + // + // @since 3.17.0 + Metadata map[string]any `json:"metadata,omitempty"` + + // ExecutionSummary additional execution summary information if supported by the client. + // + // @since 3.17.0 + ExecutionSummary *ExecutionSummary `json:"executionSummary,omitempty"` +} + +// NotebookDocument a notebook document. +// +// @since 3.17.0 +type NotebookDocument struct { + // URI the notebook document's uri. + // + // @since 3.17.0 + URI uri.URI `json:"uri"` + + // NotebookType the type of the notebook. + // + // @since 3.17.0 + NotebookType string `json:"notebookType"` + + // Version the version number of this document (it will increase after each change, including undo/redo). + // + // @since 3.17.0 + Version int32 `json:"version"` + + // Metadata additional metadata stored with the notebook document. Note: should always be an object literal (e.g. LSPObject). + // + // @since 3.17.0 + Metadata map[string]any `json:"metadata,omitempty"` + + // Cells the cells of a notebook. + // + // @since 3.17.0 + Cells []NotebookCell `json:"cells"` +} + +// DidOpenNotebookDocumentParams the params sent in an open notebook document notification. +// +// @since 3.17.0 +type DidOpenNotebookDocumentParams struct { + // NotebookDocument the notebook document that got opened. + // + // @since 3.17.0 + NotebookDocument NotebookDocument `json:"notebookDocument"` + + // CellTextDocuments the text documents that represent the content of a notebook cell. + // + // @since 3.17.0 + CellTextDocuments []TextDocumentItem `json:"cellTextDocuments"` +} + +// NotebookCellLanguage. +// +// @since 3.18.0 proposed +type NotebookCellLanguage struct { + // @since 3.18.0 proposed + Language string `json:"language"` +} + +// NotebookDocumentFilterWithCells. +// +// @since 3.18.0 proposed +type NotebookDocumentFilterWithCells struct { + // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. + // + // @since 3.18.0 proposed + Notebook NotebookDocumentFilterWithCellsNotebook `json:"notebook,omitempty"` + + // Cells the cells of the matching notebook to be synced. + // + // @since 3.18.0 proposed + Cells []NotebookCellLanguage `json:"cells"` +} + +// NotebookDocumentFilterWithNotebook. +// +// @since 3.18.0 proposed +type NotebookDocumentFilterWithNotebook struct { + // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. + // + // @since 3.18.0 proposed + Notebook NotebookDocumentFilterWithNotebookNotebook `json:"notebook"` + + // Cells the cells of the matching notebook to be synced. + // + // @since 3.18.0 proposed + Cells []NotebookCellLanguage `json:"cells,omitempty"` +} + +// NotebookDocumentSyncOptions options specific to a notebook plus its cells to be synced to the server. If a selector provides a notebook document filter but no cell selector all cells of a matching notebook document will be synced. If a selector provides no notebook document filter but only a cell selector all notebook document +// that contain at least one matching cell will be synced. +// +// @since 3.17.0 +type NotebookDocumentSyncOptions struct { + // NotebookSelector the notebooks to be synced. + // + // @since 3.17.0 + NotebookSelector NotebookDocumentSyncOptionsNotebookSelector `json:"notebookSelector"` + + // Save whether save notification should be forwarded to the server. Will only be honored if mode === `notebook`. + // + // @since 3.17.0 + Save bool `json:"save,omitempty"` +} + +// NotebookDocumentSyncRegistrationOptions registration options specific to a notebook. +// +// @since 3.17.0 +type NotebookDocumentSyncRegistrationOptions struct { + // extends + NotebookDocumentSyncOptions + // mixins + StaticRegistrationOptions +} + +// VersionedNotebookDocumentIdentifier a versioned notebook document identifier. +// +// @since 3.17.0 +type VersionedNotebookDocumentIdentifier struct { + // Version the version number of this notebook document. + // + // @since 3.17.0 + Version int32 `json:"version"` + + // URI the notebook document's uri. + // + // @since 3.17.0 + URI uri.URI `json:"uri"` +} + +// NotebookCellArrayChange a change describing how to move a `NotebookCell` array from state S to S'. +// +// @since 3.17.0 +type NotebookCellArrayChange struct { + // Start the start oftest of the cell that changed. + // + // @since 3.17.0 + Start uint32 `json:"start"` + + // DeleteCount the deleted cells. + // + // @since 3.17.0 + DeleteCount uint32 `json:"deleteCount"` + + // Cells the new cells, if any. + // + // @since 3.17.0 + Cells []NotebookCell `json:"cells,omitempty"` +} + +// NotebookDocumentCellChangeStructure structural changes to cells in a notebook document. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type NotebookDocumentCellChangeStructure struct { + // Array the change to the cell array. + // + // @since 3.18.0 proposed + Array NotebookCellArrayChange `json:"array"` + + // DidOpen additional opened cell text documents. + // + // @since 3.18.0 proposed + DidOpen []TextDocumentItem `json:"didOpen,omitempty"` + + // DidClose additional closed cell text documents. + // + // @since 3.18.0 proposed + DidClose []TextDocumentIdentifier `json:"didClose,omitempty"` +} + +// NotebookDocumentCellContentChanges content changes to a cell in a notebook document. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type NotebookDocumentCellContentChanges struct { + // @since 3.18.0 proposed + Document VersionedTextDocumentIdentifier `json:"document"` + + // @since 3.18.0 proposed + Changes []TextDocumentContentChangeEvent `json:"changes"` +} + +// NotebookDocumentCellChanges cell changes to a notebook document. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type NotebookDocumentCellChanges struct { + // Structure changes to the cell structure to add or remove cells. + // + // @since 3.18.0 proposed + Structure *NotebookDocumentCellChangeStructure `json:"structure,omitempty"` + + // Data changes to notebook cells properties like its kind, execution summary or metadata. + // + // @since 3.18.0 proposed + Data []NotebookCell `json:"data,omitempty"` + + // TextContent changes to the text content of notebook cells. + // + // @since 3.18.0 proposed + TextContent []NotebookDocumentCellContentChanges `json:"textContent,omitempty"` +} + +// NotebookDocumentChangeEvent a change event for a notebook document. +// +// @since 3.17.0 +type NotebookDocumentChangeEvent struct { + // Metadata the changed meta data if any. Note: should always be an object literal (e.g. LSPObject). + // + // @since 3.17.0 + Metadata map[string]any `json:"metadata,omitempty"` + + // Cells changes to cells. + // + // @since 3.17.0 + Cells *NotebookDocumentCellChanges `json:"cells,omitempty"` +} + +// DidChangeNotebookDocumentParams the params sent in a change notebook document notification. +// +// @since 3.17.0 +type DidChangeNotebookDocumentParams struct { + // NotebookDocument the notebook document that did change. The version number points to the version after all provided changes have been applied. If only the text document content of a cell changes the notebook version doesn't necessarily have to change. + // + // @since 3.17.0 + NotebookDocument VersionedNotebookDocumentIdentifier `json:"notebookDocument"` + + // Change the actual changes to the notebook document. The changes describe single state changes to the notebook document. So if there are two changes c1 (at array index 0) and c2 (at array index 1) for a notebook in state S then c1 moves the notebook from S to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed on the state S'. To mirror the content of a notebook using change events use the following approach: - start with the same initial content - apply the 'notebookDocument/didChange' notifications in the order you receive them. - apply the `NotebookChangeEvent`s in a single notification in the order you receive them. + // + // @since 3.17.0 + Change NotebookDocumentChangeEvent `json:"change"` +} + +// NotebookDocumentIdentifier a literal to identify a notebook document in the client. +// +// @since 3.17.0 +type NotebookDocumentIdentifier struct { + // URI the notebook document's uri. + // + // @since 3.17.0 + URI uri.URI `json:"uri"` +} + +// DidSaveNotebookDocumentParams the params sent in a save notebook document notification. +// +// @since 3.17.0 +type DidSaveNotebookDocumentParams struct { + // NotebookDocument the notebook document that got saved. + // + // @since 3.17.0 + NotebookDocument NotebookDocumentIdentifier `json:"notebookDocument"` +} + +// DidCloseNotebookDocumentParams the params sent in a close notebook document notification. +// +// @since 3.17.0 +type DidCloseNotebookDocumentParams struct { + // NotebookDocument the notebook document that got closed. + // + // @since 3.17.0 + NotebookDocument NotebookDocumentIdentifier `json:"notebookDocument"` + + // CellTextDocuments the text documents that represent the content of a notebook cell that got closed. + // + // @since 3.17.0 + CellTextDocuments []TextDocumentIdentifier `json:"cellTextDocuments"` +} + +// SaveOptions save options. +type SaveOptions struct { + // IncludeText the client is supposed to include the content on save. + IncludeText bool `json:"includeText,omitempty"` +} + +type TextDocumentSyncOptions struct { + // OpenClose open and close notifications are sent to the server. If omitted open close notification should not be sent. + OpenClose bool `json:"openClose,omitempty"` + + // Change change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full and TextDocumentSyncKind.Incremental. If omitted it defaults to TextDocumentSyncKind.None. + Change TextDocumentSyncKind `json:"change,omitempty"` + + // WillSave if present will save notifications are sent to the server. If omitted the notification should not be + // sent. + WillSave bool `json:"willSave,omitempty"` + + // WillSaveWaitUntil if present will save wait until requests are sent to the server. If omitted the request should not be sent. + WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` + + // Save if present save notifications are sent to the server. If omitted the notification should not be sent. + Save TextDocumentSyncOptionsSave `json:"save,omitempty"` +} + +// DidOpenTextDocumentParams the parameters sent in an open text document notification. +type DidOpenTextDocumentParams struct { + // TextDocument the document that was opened. + TextDocument TextDocumentItem `json:"textDocument"` +} + +// DidChangeTextDocumentParams the change text document notification's parameters. +type DidChangeTextDocumentParams struct { + // TextDocument the document that did change. The version number points to the version after all provided content changes have been applied. + TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` + + // ContentChanges the actual content changes. The content changes describe single state changes to the document. So if + // there are two content changes c1 (at array index 0) and c2 (at array index 1) for a document in state S then c1 moves the document from S to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed on the state S'. To mirror the content of a document using change events use the following approach: - start with the same initial content - apply the 'textDocument/didChange' + // notifications in the order you receive them. - apply the `TextDocumentContentChangeEvent`s in a single notification in the order you receive them. + ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` +} + +// TextDocumentChangeRegistrationOptions describe options to be used when registered for text document change events. +type TextDocumentChangeRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + + // SyncKind how documents are synced to the server. + SyncKind TextDocumentSyncKind `json:"syncKind"` +} + +// DidCloseTextDocumentParams the parameters sent in a close text document notification. +type DidCloseTextDocumentParams struct { + // TextDocument the document that was closed. + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// DidSaveTextDocumentParams the parameters sent in a save text document notification. +type DidSaveTextDocumentParams struct { + // TextDocument the document that was saved. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Text optional the content when saved. Depends on the includeText value when the save notification was requested. + Text string `json:"text,omitempty"` +} + +// TextDocumentSaveRegistrationOptions save registration options. +type TextDocumentSaveRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + SaveOptions +} + +// WillSaveTextDocumentParams the parameters sent in a will save text document notification. +type WillSaveTextDocumentParams struct { + // TextDocument the document that will be saved. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Reason the 'TextDocumentSaveReason'. + Reason TextDocumentSaveReason `json:"reason"` +} + +// NotebookDocumentFilterNotebookType a notebook document filter where `notebookType` is required field. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type NotebookDocumentFilterNotebookType struct { + // NotebookType the type of the enclosing notebook. + // + // @since 3.18.0 proposed + NotebookType string `json:"notebookType"` + + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 proposed + Scheme string `json:"scheme,omitempty"` + + // Pattern a glob pattern. + // + // @since 3.18.0 proposed + Pattern string `json:"pattern,omitempty"` +} + +// NotebookDocumentFilterScheme a notebook document filter where `scheme` is required field. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type NotebookDocumentFilterScheme struct { + // NotebookType the type of the enclosing notebook. + // + // @since 3.18.0 proposed + NotebookType string `json:"notebookType,omitempty"` + + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 proposed + Scheme string `json:"scheme"` + + // Pattern a glob pattern. + // + // @since 3.18.0 proposed + Pattern string `json:"pattern,omitempty"` +} + +// NotebookDocumentFilterPattern a notebook document filter where `pattern` is required field. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type NotebookDocumentFilterPattern struct { + // NotebookType the type of the enclosing notebook. + // + // @since 3.18.0 proposed + NotebookType string `json:"notebookType,omitempty"` + + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 proposed + Scheme string `json:"scheme,omitempty"` + + // Pattern a glob pattern. + // + // @since 3.18.0 proposed + Pattern string `json:"pattern"` +} diff --git a/protocol/errors.go b/protocol/errors.go new file mode 100644 index 00000000..51417d1d --- /dev/null +++ b/protocol/errors.go @@ -0,0 +1,42 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "go.lsp.dev/jsonrpc2" +) + +const ( + // LSPReservedErrorRangeStart is the start range of LSP reserved error codes. + // + // It doesn't denote a real error code. + // + // @since 3.16.0. + LSPReservedErrorRangeStart jsonrpc2.Code = -32899 + + // CodeContentModified is the state change that invalidates the result of a request in execution. + // + // Defined by the protocol. + CodeContentModified jsonrpc2.Code = -32801 + + // CodeRequestCancelled is the cancellation error. + // + // Defined by the protocol. + CodeRequestCancelled jsonrpc2.Code = -32800 + + // LSPReservedErrorRangeEnd is the end range of LSP reserved error codes. + // + // It doesn't denote a real error code. + // + // @since 3.16.0. + LSPReservedErrorRangeEnd jsonrpc2.Code = -32800 +) + +var ( + // ErrContentModified should be used when a request is canceled early. + ErrContentModified = jsonrpc2.NewError(CodeContentModified, "cancelled JSON-RPC") + + // ErrRequestCancelled should be used when a request is canceled early. + ErrRequestCancelled = jsonrpc2.NewError(CodeRequestCancelled, "cancelled JSON-RPC") +) diff --git a/protocol/handler.go b/protocol/handler.go new file mode 100644 index 00000000..a038a4cd --- /dev/null +++ b/protocol/handler.go @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: 2021 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "context" + "fmt" + + "go.lsp.dev/jsonrpc2" +) + +// Handlers default jsonrpc2.Handler. +func Handlers(handler jsonrpc2.Handler) jsonrpc2.Handler { + return jsonrpc2.AsyncHandler( + jsonrpc2.ReplyHandler(handler), + ) +} + +// Call calls method to params and result. +func Call(ctx context.Context, conn jsonrpc2.Conn, method string, params, result interface{}) error { + _, err := conn.Call(ctx, method, params, result) + if ctx.Err() != nil { + } + + return err +} + +func replyParseError(ctx context.Context, reply jsonrpc2.Replier, err error) error { + return reply(ctx, nil, fmt.Errorf("%w: %w", jsonrpc2.ErrParse, err)) +} diff --git a/protocol/language.go b/protocol/language.go new file mode 100644 index 00000000..3ff98743 --- /dev/null +++ b/protocol/language.go @@ -0,0 +1,2736 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "go.lsp.dev/uri" +) + +// SemanticTokenTypes a set of predefined token types. This set is not fixed an clients can specify additional token types +// via the corresponding client capabilities. +// +// @since 3.16.0 +type SemanticTokenTypes string + +const ( + NamespaceSemanticTokenTypes SemanticTokenTypes = "namespace" + + // TypeSemanticTokenTypes represents a generic type. Acts as a fallback for types which can't be mapped to a specific type like class or enum. + TypeSemanticTokenTypes SemanticTokenTypes = "type" + + ClassSemanticTokenTypes SemanticTokenTypes = "class" + + EnumSemanticTokenTypes SemanticTokenTypes = "enum" + + InterfaceSemanticTokenTypes SemanticTokenTypes = "interface" + + StructSemanticTokenTypes SemanticTokenTypes = "struct" + + TypeParameterSemanticTokenTypes SemanticTokenTypes = "typeParameter" + + ParameterSemanticTokenTypes SemanticTokenTypes = "parameter" + + VariableSemanticTokenTypes SemanticTokenTypes = "variable" + + PropertySemanticTokenTypes SemanticTokenTypes = "property" + + EnumMemberSemanticTokenTypes SemanticTokenTypes = "enumMember" + + EventSemanticTokenTypes SemanticTokenTypes = "event" + + FunctionSemanticTokenTypes SemanticTokenTypes = "function" + + MethodSemanticTokenTypes SemanticTokenTypes = "method" + + MacroSemanticTokenTypes SemanticTokenTypes = "macro" + + KeywordSemanticTokenTypes SemanticTokenTypes = "keyword" + + ModifierSemanticTokenTypes SemanticTokenTypes = "modifier" + + CommentSemanticTokenTypes SemanticTokenTypes = "comment" + + StringSemanticTokenTypes SemanticTokenTypes = "string" + + NumberSemanticTokenTypes SemanticTokenTypes = "number" + + RegexpSemanticTokenTypes SemanticTokenTypes = "regexp" + + OperatorSemanticTokenTypes SemanticTokenTypes = "operator" + + // DecoratorSemanticTokenTypes. + // + // @since 3.17.0 + DecoratorSemanticTokenTypes SemanticTokenTypes = "decorator" +) + +// SemanticTokenModifiers a set of predefined token modifiers. This set is not fixed an clients can specify additional token types via the corresponding client capabilities. +// +// @since 3.16.0 +type SemanticTokenModifiers string + +const ( + DeclarationSemanticTokenModifiers SemanticTokenModifiers = "declaration" + + DefinitionSemanticTokenModifiers SemanticTokenModifiers = "definition" + + ReadonlySemanticTokenModifiers SemanticTokenModifiers = "readonly" + + StaticSemanticTokenModifiers SemanticTokenModifiers = "static" + + DeprecatedSemanticTokenModifiers SemanticTokenModifiers = "deprecated" + + AbstractSemanticTokenModifiers SemanticTokenModifiers = "abstract" + + AsyncSemanticTokenModifiers SemanticTokenModifiers = "async" + + ModificationSemanticTokenModifiers SemanticTokenModifiers = "modification" + + DocumentationSemanticTokenModifiers SemanticTokenModifiers = "documentation" + + DefaultLibrarySemanticTokenModifiers SemanticTokenModifiers = "defaultLibrary" +) + +// DocumentDiagnosticReportKind the document diagnostic report kinds. +// +// @since 3.17.0 +type DocumentDiagnosticReportKind string + +const ( + // FullDocumentDiagnosticReportKind a diagnostic report with a full set of problems. + FullDocumentDiagnosticReportKind DocumentDiagnosticReportKind = "full" + + // UnchangedDocumentDiagnosticReportKind a report indicating that the last returned report is still accurate. + UnchangedDocumentDiagnosticReportKind DocumentDiagnosticReportKind = "unchanged" +) + +// FoldingRangeKind a set of predefined range kinds. +type FoldingRangeKind string + +const ( + // CommentFoldingRangeKind folding range for a comment. + CommentFoldingRangeKind FoldingRangeKind = "comment" + + // ImportsFoldingRangeKind folding range for an import or include. + ImportsFoldingRangeKind FoldingRangeKind = "imports" + + // RegionFoldingRangeKind folding range for a region (e.g. `#region`). + RegionFoldingRangeKind FoldingRangeKind = "region" +) + +// SymbolKind a symbol kind. +type SymbolKind uint32 + +const ( + FileSymbolKind SymbolKind = 1 + + ModuleSymbolKind SymbolKind = 2 + + NamespaceSymbolKind SymbolKind = 3 + + PackageSymbolKind SymbolKind = 4 + + ClassSymbolKind SymbolKind = 5 + + MethodSymbolKind SymbolKind = 6 + + PropertySymbolKind SymbolKind = 7 + + FieldSymbolKind SymbolKind = 8 + + ConstructorSymbolKind SymbolKind = 9 + + EnumSymbolKind SymbolKind = 10 + + InterfaceSymbolKind SymbolKind = 11 + + FunctionSymbolKind SymbolKind = 12 + + VariableSymbolKind SymbolKind = 13 + + ConstantSymbolKind SymbolKind = 14 + + StringSymbolKind SymbolKind = 15 + + NumberSymbolKind SymbolKind = 16 + + BooleanSymbolKind SymbolKind = 17 + + ArraySymbolKind SymbolKind = 18 + + ObjectSymbolKind SymbolKind = 19 + + KeySymbolKind SymbolKind = 20 + + NullSymbolKind SymbolKind = 21 + + EnumMemberSymbolKind SymbolKind = 22 + + StructSymbolKind SymbolKind = 23 + + EventSymbolKind SymbolKind = 24 + + OperatorSymbolKind SymbolKind = 25 + + TypeParameterSymbolKind SymbolKind = 26 +) + +// SymbolTag symbol tags are extra annotations that tweak the rendering of a symbol. +// +// @since 3.16 +type SymbolTag uint32 + +const ( + // DeprecatedSymbolTag render a symbol as obsolete, usually using a strike-out. + DeprecatedSymbolTag SymbolTag = 1 +) + +// UniquenessLevel moniker uniqueness level to define scope of the moniker. +// +// @since 3.16.0 +type UniquenessLevel string + +const ( + // DocumentUniquenessLevel the moniker is only unique inside a document. + DocumentUniquenessLevel UniquenessLevel = "document" + + // ProjectUniquenessLevel the moniker is unique inside a project for which a dump got created. + ProjectUniquenessLevel UniquenessLevel = "project" + + // GroupUniquenessLevel the moniker is unique inside the group to which a project belongs. + GroupUniquenessLevel UniquenessLevel = "group" + + // SchemeUniquenessLevel the moniker is unique inside the moniker scheme. + SchemeUniquenessLevel UniquenessLevel = "scheme" + + // GlobalUniquenessLevel the moniker is globally unique. + GlobalUniquenessLevel UniquenessLevel = "global" +) + +// MonikerKind the moniker kind. +// +// @since 3.16.0 +type MonikerKind string + +const ( + // ImportMonikerKind the moniker represent a symbol that is imported into a project. + ImportMonikerKind MonikerKind = "import" + + // ExportMonikerKind the moniker represents a symbol that is exported from a project. + ExportMonikerKind MonikerKind = "export" + + // LocalMonikerKind the moniker represents a symbol that is local to a project (e.g. a local variable of a function, a class not visible outside the project, ...). + LocalMonikerKind MonikerKind = "local" +) + +// InlayHintKind inlay hint kinds. +// +// @since 3.17.0 +type InlayHintKind uint32 + +const ( + // TypeInlayHintKind an inlay hint that for a type annotation. + TypeInlayHintKind InlayHintKind = 1 + + // ParameterInlayHintKind an inlay hint that is for a parameter. + ParameterInlayHintKind InlayHintKind = 2 +) + +// CompletionItemKind the kind of a completion entry. +type CompletionItemKind uint32 + +const ( + TextCompletionItemKind CompletionItemKind = 1 + + MethodCompletionItemKind CompletionItemKind = 2 + + FunctionCompletionItemKind CompletionItemKind = 3 + + ConstructorCompletionItemKind CompletionItemKind = 4 + + FieldCompletionItemKind CompletionItemKind = 5 + + VariableCompletionItemKind CompletionItemKind = 6 + + ClassCompletionItemKind CompletionItemKind = 7 + + InterfaceCompletionItemKind CompletionItemKind = 8 + + ModuleCompletionItemKind CompletionItemKind = 9 + + PropertyCompletionItemKind CompletionItemKind = 10 + + UnitCompletionItemKind CompletionItemKind = 11 + + ValueCompletionItemKind CompletionItemKind = 12 + + EnumCompletionItemKind CompletionItemKind = 13 + + KeywordCompletionItemKind CompletionItemKind = 14 + + SnippetCompletionItemKind CompletionItemKind = 15 + + ColorCompletionItemKind CompletionItemKind = 16 + + FileCompletionItemKind CompletionItemKind = 17 + + ReferenceCompletionItemKind CompletionItemKind = 18 + + FolderCompletionItemKind CompletionItemKind = 19 + + EnumMemberCompletionItemKind CompletionItemKind = 20 + + ConstantCompletionItemKind CompletionItemKind = 21 + + StructCompletionItemKind CompletionItemKind = 22 + + EventCompletionItemKind CompletionItemKind = 23 + + OperatorCompletionItemKind CompletionItemKind = 24 + + TypeParameterCompletionItemKind CompletionItemKind = 25 +) + +// CompletionItemTag completion item tags are extra annotations that tweak the rendering of a completion item. +// +// @since 3.15.0 +type CompletionItemTag uint32 + +const ( + // DeprecatedCompletionItemTag render a completion as obsolete, usually using a strike-out. + DeprecatedCompletionItemTag CompletionItemTag = 1 +) + +// InsertTextFormat defines whether the insert text in a completion item should be interpreted as plain text or a snippet. +type InsertTextFormat uint32 + +const ( + // PlainTextInsertTextFormat the primary text to be inserted is treated as a plain string. + PlainTextInsertTextFormat InsertTextFormat = 1 + + // SnippetInsertTextFormat the primary text to be inserted is treated as a snippet. A snippet can define tab stops and placeholders with `$1`, `$2` and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Placeholders with equal identifiers are linked, that is typing in one will update others too. See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax. + SnippetInsertTextFormat InsertTextFormat = 2 +) + +// InsertTextMode how whitespace and indentation is handled during completion item insertion. +// +// @since 3.16.0 +type InsertTextMode uint32 + +const ( + // AsIsInsertTextMode the insertion or replace strings is taken as it is. If the value is multi line the lines below the cursor will be inserted using the indentation defined in the string value. The client will not apply any kind of adjustments to the string. + AsIsInsertTextMode InsertTextMode = 1 + + // AdjustIndentationInsertTextMode the editor adjusts leading whitespace of new lines so that they match the indentation up to the cursor of the line for which the item is accepted. Consider a line like this: <2tabs><3tabs>foo. + // Accepting a multi line completion item is indented using 2 tabs and all following lines inserted will be indented using 2 tabs as well. + AdjustIndentationInsertTextMode InsertTextMode = 2 +) + +// DocumentHighlightKind a document highlight kind. +type DocumentHighlightKind uint32 + +const ( + // TextDocumentHighlightKind a textual occurrence. + TextDocumentHighlightKind DocumentHighlightKind = 1 + + // ReadDocumentHighlightKind read-access of a symbol, like reading a variable. + ReadDocumentHighlightKind DocumentHighlightKind = 2 + + // WriteDocumentHighlightKind write-access of a symbol, like writing to a variable. + WriteDocumentHighlightKind DocumentHighlightKind = 3 +) + +// CodeActionKind a set of predefined code action kinds. +type CodeActionKind string + +const ( + // EmptyCodeActionKind empty kind. + EmptyCodeActionKind CodeActionKind = "" + + // QuickFixCodeActionKind base kind for quickfix actions: 'quickfix'. + QuickFixCodeActionKind CodeActionKind = "quickfix" + + // RefactorCodeActionKind base kind for refactoring actions: 'refactor'. + RefactorCodeActionKind CodeActionKind = "refactor" + + // RefactorExtractCodeActionKind base kind for refactoring extraction actions: 'refactor.extract' Example extract actions: - Extract method - Extract function - Extract variable - Extract interface from class - . + RefactorExtractCodeActionKind CodeActionKind = "refactor.extract" + + // RefactorInlineCodeActionKind base kind for refactoring inline actions: 'refactor.inline' Example inline actions: - Inline function - Inline variable - Inline constant - . + RefactorInlineCodeActionKind CodeActionKind = "refactor.inline" + + // RefactorMoveCodeActionKind base kind for refactoring move actions: `refactor.move` Example move actions: - Move a function to a + // new file - Move a property between classes - Move method to base class - ... 3.18.0 @proposed. + // + // @since 3.18.0 proposed + RefactorMoveCodeActionKind CodeActionKind = "refactor.move" + + // RefactorRewriteCodeActionKind base kind for refactoring rewrite actions: 'refactor.rewrite' Example rewrite actions: - Convert JavaScript function to class - Add or remove parameter - Encapsulate field - Make method static - Move method to base class - . + RefactorRewriteCodeActionKind CodeActionKind = "refactor.rewrite" + + // SourceCodeActionKind base kind for source actions: `source` Source code actions apply to the entire file. + SourceCodeActionKind CodeActionKind = "source" + + // SourceOrganizeImportsCodeActionKind base kind for an organize imports source action: `source.organizeImports`. + SourceOrganizeImportsCodeActionKind CodeActionKind = "source.organizeImports" + + // SourceFixAllCodeActionKind base kind for auto-fix source actions: `source.fixAll`. Fix all actions automatically fix errors that have a clear fix that do not require user input. They should not suppress errors or perform unsafe + // fixes such as generating new types or classes. + // + // @since 3.15.0 + SourceFixAllCodeActionKind CodeActionKind = "source.fixAll" + + // NotebookCodeActionKind base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using this should always begin with `notebook.` + // + // @since 3.18.0 + NotebookCodeActionKind CodeActionKind = "notebook" +) + +// InlineCompletionTriggerKind describes how an InlineCompletionItemProvider inline completion provider was triggered. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionTriggerKind uint32 + +const ( + // InvokedInlineCompletionTriggerKind completion was triggered explicitly by a user gesture. + InvokedInlineCompletionTriggerKind InlineCompletionTriggerKind = 1 + + // AutomaticInlineCompletionTriggerKind completion was triggered automatically while editing. + AutomaticInlineCompletionTriggerKind InlineCompletionTriggerKind = 2 +) + +// CompletionTriggerKind how a completion was triggered. +type CompletionTriggerKind uint32 + +const ( + // InvokedCompletionTriggerKind completion was triggered by typing an identifier (24x7 code complete), manual invocation (e.g Ctrl+Space) or via API. + InvokedCompletionTriggerKind CompletionTriggerKind = 1 + + // TriggerCharacterCompletionTriggerKind completion was triggered by a trigger character specified by the `triggerCharacters` properties of the `CompletionRegistrationOptions`. + TriggerCharacterCompletionTriggerKind CompletionTriggerKind = 2 + + // TriggerForIncompleteCompletionsCompletionTriggerKind completion was re-triggered as current completion list is incomplete. + TriggerForIncompleteCompletionsCompletionTriggerKind CompletionTriggerKind = 3 +) + +// SignatureHelpTriggerKind how a signature help was triggered. +// +// @since 3.15.0 +type SignatureHelpTriggerKind uint32 + +const ( + // InvokedSignatureHelpTriggerKind signature help was invoked manually by the user or by a command. + InvokedSignatureHelpTriggerKind SignatureHelpTriggerKind = 1 + + // TriggerCharacterSignatureHelpTriggerKind signature help was triggered by a trigger character. + TriggerCharacterSignatureHelpTriggerKind SignatureHelpTriggerKind = 2 + + // ContentChangeSignatureHelpTriggerKind signature help was triggered by the cursor moving or by the document content changing. + ContentChangeSignatureHelpTriggerKind SignatureHelpTriggerKind = 3 +) + +// CodeActionTriggerKind the reason why code actions were requested. +// +// @since 3.17.0 +type CodeActionTriggerKind uint32 + +const ( + // InvokedCodeActionTriggerKind code actions were explicitly requested by the user or by an extension. + InvokedCodeActionTriggerKind CodeActionTriggerKind = 1 + + // AutomaticCodeActionTriggerKind code actions were requested automatically. This typically happens when current selection in a file changes, but can also be triggered when file content changes. + AutomaticCodeActionTriggerKind CodeActionTriggerKind = 2 +) + +type PrepareSupportDefaultBehavior uint32 + +const ( + // IdentifierPrepareSupportDefaultBehavior the client's default behavior is to select the identifier according the to language's syntax rule. + IdentifierPrepareSupportDefaultBehavior PrepareSupportDefaultBehavior = 1 +) + +type TokenFormat string + +const ( + RelativeTokenFormat TokenFormat = "relative" +) + +type ImplementationParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +type ImplementationOptions struct { + // mixins + WorkDoneProgressOptions +} + +type ImplementationRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + ImplementationOptions + // mixins + StaticRegistrationOptions +} + +type TypeDefinitionParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +type TypeDefinitionOptions struct { + // mixins + WorkDoneProgressOptions +} + +type TypeDefinitionRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + TypeDefinitionOptions + // mixins + StaticRegistrationOptions +} + +// DocumentColorParams parameters for a DocumentColorRequest. +type DocumentColorParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// Color represents a color in RGBA space. +type Color struct { + // Red the red component of this color in the range [0-1]. + Red float64 `json:"red"` + + // Green the green component of this color in the range [0-1]. + Green float64 `json:"green"` + + // Blue the blue component of this color in the range [0-1]. + Blue float64 `json:"blue"` + + // Alpha the alpha component of this color in the range [0-1]. + Alpha float64 `json:"alpha"` +} + +// ColorInformation represents a color range from a document. +type ColorInformation struct { + // Range the range in the document where this color appears. + Range Range `json:"range"` + + // Color the actual color value for this color range. + Color Color `json:"color"` +} + +type DocumentColorOptions struct { + // mixins + WorkDoneProgressOptions +} + +type DocumentColorRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentColorOptions + // mixins + StaticRegistrationOptions +} + +// ColorPresentationParams parameters for a ColorPresentationRequest. +type ColorPresentationParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Color the color to request presentations for. + Color Color `json:"color"` + + // Range the range where the color would be inserted. Serves as a context. + Range Range `json:"range"` +} + +type ColorPresentation struct { + // Label the label of this color presentation. It will be shown on the color picker header. By default this is also the text that is inserted when selecting this color presentation. + Label string `json:"label"` + + // TextEdit an TextEdit edit which is applied to a document when selecting this presentation for the color. When + // `falsy` the ColorPresentation.label label is used. + TextEdit *TextEdit `json:"textEdit,omitempty"` + + // AdditionalTextEdits an optional array of additional TextEdit text edits that are applied when selecting this color presentation. Edits must not overlap with the main ColorPresentation.textEdit edit nor with themselves. + AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"` +} + +// FoldingRangeParams parameters for a FoldingRangeRequest. +type FoldingRangeParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// FoldingRange represents a folding range. To be valid, start and end line must be bigger than zero and smaller than the number of lines in the document. Clients are free to ignore invalid ranges. +type FoldingRange struct { + // StartLine the zero-based start line of the range to fold. The folded area starts after the line's last character. To be valid, the end must be zero or larger and smaller than the number of lines in the document. + StartLine uint32 `json:"startLine"` + + // StartCharacter the zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line. + StartCharacter uint32 `json:"startCharacter,omitempty"` + + // EndLine the zero-based end line of the range to fold. The folded area ends with the line's last character. To be valid, the end must be zero or larger and smaller than the number of lines in the document. + EndLine uint32 `json:"endLine"` + + // EndCharacter the zero-based character offset before the folded range ends. If not defined, defaults to the length + // of the end line. + EndCharacter uint32 `json:"endCharacter,omitempty"` + + // Kind describes the kind of the folding range such as 'comment' or 'region'. The kind is used to categorize folding ranges and used by commands like 'Fold all comments'. See FoldingRangeKind for an enumeration of standardized kinds. + Kind FoldingRangeKind `json:"kind,omitempty"` + + // CollapsedText the text that the client should show when the specified range is collapsed. If not defined or not supported by the client, a default will be chosen by the client. + CollapsedText string `json:"collapsedText,omitempty"` +} + +type FoldingRangeOptions struct { + // mixins + WorkDoneProgressOptions +} + +type FoldingRangeRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + FoldingRangeOptions + // mixins + StaticRegistrationOptions +} + +type DeclarationParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +type DeclarationOptions struct { + // mixins + WorkDoneProgressOptions +} + +type DeclarationRegistrationOptions struct { + // extends + DeclarationOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// SelectionRangeParams a parameter literal used in selection range requests. +type SelectionRangeParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Positions the positions inside the text document. + Positions []Position `json:"positions"` +} + +// SelectionRange a selection range represents a part of a selection hierarchy. A selection range may have a parent selection range that contains it. +type SelectionRange struct { + // Range the Range range of this selection range. + Range Range `json:"range"` + + // Parent the parent selection range containing this range. Therefore `parent.range` must contain `this.range`. + Parent *SelectionRange `json:"parent,omitempty"` +} + +type SelectionRangeOptions struct { + // mixins + WorkDoneProgressOptions +} + +type SelectionRangeRegistrationOptions struct { + // extends + SelectionRangeOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// CallHierarchyPrepareParams the parameter of a `textDocument/prepareCallHierarchy` request. +// +// @since 3.16.0 +type CallHierarchyPrepareParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams +} + +// CallHierarchyItem represents programming constructs like functions or constructors in the context of call hierarchy. +// +// @since 3.16.0 +type CallHierarchyItem struct { + // Name the name of this item. + // + // @since 3.16.0 + Name string `json:"name"` + + // Kind the kind of this item. + // + // @since 3.16.0 + Kind SymbolKind `json:"kind"` + + // Tags tags for this item. + // + // @since 3.16.0 + Tags []SymbolTag `json:"tags,omitempty"` + + // Detail more detail for this item, e.g. the signature of a function. + // + // @since 3.16.0 + Detail string `json:"detail,omitempty"` + + // URI the resource identifier of this item. + // + // @since 3.16.0 + URI DocumentURI `json:"uri"` + + // Range the range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code. + // + // @since 3.16.0 + Range Range `json:"range"` + + // SelectionRange the range that should be selected and revealed when this symbol is being picked, e.g. the name of a function. Must be contained by the CallHierarchyItem.range `range`. + // + // @since 3.16.0 + SelectionRange Range `json:"selectionRange"` + + // Data a data entry field that is preserved between a call hierarchy prepare and incoming calls or outgoing + // calls requests. + // + // @since 3.16.0 + Data any `json:"data,omitempty"` +} + +// CallHierarchyOptions call hierarchy options used during static registration. +// +// @since 3.16.0 +type CallHierarchyOptions struct { + // mixins + WorkDoneProgressOptions +} + +// CallHierarchyRegistrationOptions call hierarchy options used during static or dynamic registration. +// +// @since 3.16.0 +type CallHierarchyRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + CallHierarchyOptions + // mixins + StaticRegistrationOptions +} + +// CallHierarchyIncomingCallsParams the parameter of a `callHierarchy/incomingCalls` request. +// +// @since 3.16.0 +type CallHierarchyIncomingCallsParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // @since 3.16.0 + Item CallHierarchyItem `json:"item"` +} + +// CallHierarchyIncomingCall represents an incoming call, e.g. a caller of a method or constructor. +// +// @since 3.16.0 +type CallHierarchyIncomingCall struct { + // From the item that makes the call. + // + // @since 3.16.0 + From CallHierarchyItem `json:"from"` + + // FromRanges the ranges at which the calls appear. This is relative to the caller denoted by CallHierarchyIncomingCall.from `this.from`. + // + // @since 3.16.0 + FromRanges []Range `json:"fromRanges"` +} + +// CallHierarchyOutgoingCallsParams the parameter of a `callHierarchy/outgoingCalls` request. +// +// @since 3.16.0 +type CallHierarchyOutgoingCallsParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // @since 3.16.0 + Item CallHierarchyItem `json:"item"` +} + +// CallHierarchyOutgoingCall represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc. +// +// @since 3.16.0 +type CallHierarchyOutgoingCall struct { + // To the item that is called. + // + // @since 3.16.0 + To CallHierarchyItem `json:"to"` + + // FromRanges the range at which this item is called. This is the range relative to the caller, e.g the item passed to CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls `provideCallHierarchyOutgoingCalls` + // and not CallHierarchyOutgoingCall.to `this.to`. + // + // @since 3.16.0 + FromRanges []Range `json:"fromRanges"` +} + +// SemanticTokensParams. +// +// @since 3.16.0 +type SemanticTokensParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + // + // @since 3.16.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// SemanticTokens. +// +// @since 3.16.0 +type SemanticTokens struct { + // ResultID an optional result id. If provided and clients support delta updating the client will include the result id in the next semantic token request. A server can then instead of computing all semantic tokens again simply send a delta. + // + // @since 3.16.0 + ResultID string `json:"resultId,omitempty"` + + // Data the actual tokens. + // + // @since 3.16.0 + Data []uint32 `json:"data"` +} + +// SemanticTokensPartialResult. +// +// @since 3.16.0 +type SemanticTokensPartialResult struct { + // @since 3.16.0 + Data []uint32 `json:"data"` +} + +// SemanticTokensLegend. +// +// @since 3.16.0 +type SemanticTokensLegend struct { + // TokenTypes the token types a server uses. + // + // @since 3.16.0 + TokenTypes []string `json:"tokenTypes"` + + // TokenModifiers the token modifiers a server uses. + // + // @since 3.16.0 + TokenModifiers []string `json:"tokenModifiers"` +} + +// SemanticTokensFullDelta semantic tokens options to support deltas for full documents 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type SemanticTokensFullDelta struct { + // Delta the server supports deltas for full documents. + // + // @since 3.18.0 proposed + Delta bool `json:"delta,omitempty"` +} + +// SemanticTokensOptions. +// +// @since 3.16.0 +type SemanticTokensOptions struct { + // mixins + WorkDoneProgressOptions + + // Legend the legend used by the server. + // + // @since 3.16.0 + Legend SemanticTokensLegend `json:"legend"` + + // Range server supports providing semantic tokens for a specific range of a document. + // + // @since 3.16.0 + Range SemanticTokensOptionsRange `json:"range,omitempty"` + + // Full server supports providing semantic tokens for a full document. + // + // @since 3.16.0 + Full SemanticTokensOptionsFull `json:"full,omitempty"` +} + +// SemanticTokensRegistrationOptions. +// +// @since 3.16.0 +type SemanticTokensRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + SemanticTokensOptions + // mixins + StaticRegistrationOptions +} + +// SemanticTokensDeltaParams. +// +// @since 3.16.0 +type SemanticTokensDeltaParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + // + // @since 3.16.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // PreviousResultID the result id of a previous response. The result Id can either point to a full response or a delta response depending on what was received last. + // + // @since 3.16.0 + PreviousResultID string `json:"previousResultId"` +} + +// SemanticTokensEdit. +// +// @since 3.16.0 +type SemanticTokensEdit struct { + // Start the start offset of the edit. + // + // @since 3.16.0 + Start uint32 `json:"start"` + + // DeleteCount the count of elements to remove. + // + // @since 3.16.0 + DeleteCount uint32 `json:"deleteCount"` + + // Data the elements to insert. + // + // @since 3.16.0 + Data []uint32 `json:"data,omitempty"` +} + +// SemanticTokensDelta. +// +// @since 3.16.0 +type SemanticTokensDelta struct { + // @since 3.16.0 + ResultID string `json:"resultId,omitempty"` + + // Edits the semantic token edits to transform a previous result into a new result. + // + // @since 3.16.0 + Edits []SemanticTokensEdit `json:"edits"` +} + +// SemanticTokensDeltaPartialResult. +// +// @since 3.16.0 +type SemanticTokensDeltaPartialResult struct { + // @since 3.16.0 + Edits []SemanticTokensEdit `json:"edits"` +} + +// SemanticTokensRangeParams. +// +// @since 3.16.0 +type SemanticTokensRangeParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + // + // @since 3.16.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Range the range the semantic tokens are requested for. + // + // @since 3.16.0 + Range Range `json:"range"` +} + +type LinkedEditingRangeParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams +} + +// LinkedEditingRanges the result of a linked editing range request. +// +// @since 3.16.0 +type LinkedEditingRanges struct { + // Ranges a list of ranges that can be edited together. The ranges must have identical length and contain identical text content. The ranges cannot overlap. + // + // @since 3.16.0 + Ranges []Range `json:"ranges"` + + // WordPattern an optional word pattern (regular expression) that describes valid contents for the given ranges. If + // no pattern is provided, the client configuration's word pattern will be used. + // + // @since 3.16.0 + WordPattern string `json:"wordPattern,omitempty"` +} + +type LinkedEditingRangeOptions struct { + // mixins + WorkDoneProgressOptions +} + +type LinkedEditingRangeRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + LinkedEditingRangeOptions + // mixins + StaticRegistrationOptions +} + +type MonikerParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +// Moniker moniker definition to match LSIF 0.5 moniker definition. +// +// @since 3.16.0 +type Moniker struct { + // Scheme the scheme of the moniker. For example tsc or .Net. + // + // @since 3.16.0 + Scheme string `json:"scheme"` + + // Identifier the identifier of the moniker. The value is opaque in LSIF however schema owners are allowed to define the structure if they want. + // + // @since 3.16.0 + Identifier string `json:"identifier"` + + // Unique the scope in which the moniker is unique. + // + // @since 3.16.0 + Unique UniquenessLevel `json:"unique"` + + // Kind the moniker kind if known. + // + // @since 3.16.0 + Kind MonikerKind `json:"kind,omitempty"` +} + +type MonikerOptions struct { + // mixins + WorkDoneProgressOptions +} + +type MonikerRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + MonikerOptions +} + +// TypeHierarchyPrepareParams the parameter of a `textDocument/prepareTypeHierarchy` request. +// +// @since 3.17.0 +type TypeHierarchyPrepareParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams +} + +// TypeHierarchyItem. +// +// @since 3.17.0 +type TypeHierarchyItem struct { + // Name the name of this item. + // + // @since 3.17.0 + Name string `json:"name"` + + // Kind the kind of this item. + // + // @since 3.17.0 + Kind SymbolKind `json:"kind"` + + // Tags tags for this item. + // + // @since 3.17.0 + Tags []SymbolTag `json:"tags,omitempty"` + + // Detail more detail for this item, e.g. the signature of a function. + // + // @since 3.17.0 + Detail string `json:"detail,omitempty"` + + // URI the resource identifier of this item. + // + // @since 3.17.0 + URI DocumentURI `json:"uri"` + + // Range the range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code. + // + // @since 3.17.0 + Range Range `json:"range"` + + // SelectionRange the range that should be selected and revealed when this symbol is being picked, e.g. the name of a function. Must be contained by the TypeHierarchyItem.range `range`. + // + // @since 3.17.0 + SelectionRange Range `json:"selectionRange"` + + // Data a data entry field that is preserved between a type hierarchy prepare and supertypes or subtypes requests. It could also be used to identify the type hierarchy in the server, helping improve the performance on resolving supertypes and subtypes. + // + // @since 3.17.0 + Data any `json:"data,omitempty"` +} + +// TypeHierarchyOptions type hierarchy options used during static registration. +// +// @since 3.17.0 +type TypeHierarchyOptions struct { + // mixins + WorkDoneProgressOptions +} + +// TypeHierarchyRegistrationOptions type hierarchy options used during static or dynamic registration. +// +// @since 3.17.0 +type TypeHierarchyRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + TypeHierarchyOptions + // mixins + StaticRegistrationOptions +} + +// TypeHierarchySupertypesParams the parameter of a `typeHierarchy/supertypes` request. +// +// @since 3.17.0 +type TypeHierarchySupertypesParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // @since 3.17.0 + Item TypeHierarchyItem `json:"item"` +} + +// TypeHierarchySubtypesParams the parameter of a `typeHierarchy/subtypes` request. +// +// @since 3.17.0 +type TypeHierarchySubtypesParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // @since 3.17.0 + Item TypeHierarchyItem `json:"item"` +} + +// InlineValueContext. +// +// @since 3.17.0 +type InlineValueContext struct { + // FrameID the stack frame (as a DAP Id) where the execution has stopped. + // + // @since 3.17.0 + FrameID int32 `json:"frameId"` + + // StoppedLocation the document range where execution has stopped. Typically the end position of the range denotes the line where the inline values are shown. + // + // @since 3.17.0 + StoppedLocation Range `json:"stoppedLocation"` +} + +// InlineValueParams a parameter literal used in inline value requests. +// +// @since 3.17.0 +type InlineValueParams struct { + // mixins + WorkDoneProgressParams + + // TextDocument the text document. + // + // @since 3.17.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Range the document range for which inline values should be computed. + // + // @since 3.17.0 + Range Range `json:"range"` + + // Context additional information about the context in which inline values were requested. + // + // @since 3.17.0 + Context InlineValueContext `json:"context"` +} + +// InlineValueOptions inline value options used during static registration. +// +// @since 3.17.0 +type InlineValueOptions struct { + // mixins + WorkDoneProgressOptions +} + +// InlineValueRegistrationOptions inline value options used during static or dynamic registration. +// +// @since 3.17.0 +type InlineValueRegistrationOptions struct { + // extends + InlineValueOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// InlayHintParams a parameter literal used in inlay hint requests. +// +// @since 3.17.0 +type InlayHintParams struct { + // mixins + WorkDoneProgressParams + + // TextDocument the text document. + // + // @since 3.17.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Range the document range for which inlay hints should be computed. + // + // @since 3.17.0 + Range Range `json:"range"` +} + +// InlayHintLabelPart an inlay hint label part allows for interactive and composite labels of inlay hints. +// +// @since 3.17.0 +type InlayHintLabelPart struct { + // Value the value of this label part. + // + // @since 3.17.0 + Value string `json:"value"` + + // Tooltip the tooltip text when you hover over this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. + // + // @since 3.17.0 + Tooltip InlayHintLabelPartTooltip `json:"tooltip,omitempty"` + + // Location an optional source code location that represents this label part. The editor will use this location for the hover and for code navigation features: This part will become a clickable link that resolves + // to the definition of the symbol at the given location (not necessarily the location itself), it shows the hover that shows at the given location, and it shows a context menu with further code navigation commands. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. + // + // @since 3.17.0 + Location *Location `json:"location,omitempty"` + + // Command an optional command for this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. + // + // @since 3.17.0 + Command *Command `json:"command,omitempty"` +} + +// InlayHint inlay hint information. +// +// @since 3.17.0 +type InlayHint struct { + // Position the position of this hint. If multiple hints have the same position, they will be shown in the order + // they appear in the response. + // + // @since 3.17.0 + Position Position `json:"position"` + + // Label the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty. + // + // @since 3.17.0 + Label InlayHintLabel `json:"label"` + + // Kind the kind of this hint. Can be omitted in which case the client should fall back to a reasonable default. + // + // @since 3.17.0 + Kind InlayHintKind `json:"kind,omitempty"` + + // TextEdits optional text edits that are performed when accepting this inlay hint. *Note* that edits are expected to change the document so that the inlay hint (or its nearest variant) is now part of the document + // and the inlay hint itself is now obsolete. + // + // @since 3.17.0 + TextEdits []TextEdit `json:"textEdits,omitempty"` + + // Tooltip the tooltip text when you hover over this item. + // + // @since 3.17.0 + Tooltip InlayHintTooltip `json:"tooltip,omitempty"` + + // PaddingLeft render padding before the hint. Note: Padding should use the editor's background color, not the background color of the hint itself. That means padding can be used to visually align/separate an inlay hint. + // + // @since 3.17.0 + PaddingLeft bool `json:"paddingLeft,omitempty"` + + // PaddingRight render padding after the hint. Note: Padding should use the editor's background color, not the background color of the hint itself. That means padding can be used to visually align/separate an inlay hint. + // + // @since 3.17.0 + PaddingRight bool `json:"paddingRight,omitempty"` + + // Data a data entry field that is preserved on an inlay hint between a `textDocument/inlayHint` and a `inlayHint/resolve` request. + // + // @since 3.17.0 + Data any `json:"data,omitempty"` +} + +// InlayHintOptions inlay hint options used during static registration. +// +// @since 3.17.0 +type InlayHintOptions struct { + // mixins + WorkDoneProgressOptions + + // ResolveProvider the server provides support to resolve additional information for an inlay hint item. + // + // @since 3.17.0 + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// InlayHintRegistrationOptions inlay hint options used during static or dynamic registration. +// +// @since 3.17.0 +type InlayHintRegistrationOptions struct { + // extends + InlayHintOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// DocumentDiagnosticParams parameters of the document diagnostic request. +// +// @since 3.17.0 +type DocumentDiagnosticParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + // + // @since 3.17.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Identifier the additional identifier provided during registration. + // + // @since 3.17.0 + Identifier string `json:"identifier,omitempty"` + + // PreviousResultID the result id of a previous response if provided. + // + // @since 3.17.0 + PreviousResultID string `json:"previousResultId,omitempty"` +} + +// UnchangedDocumentDiagnosticReport a diagnostic report indicating that the last returned report is still accurate. +// +// @since 3.17.0 +type UnchangedDocumentDiagnosticReport struct { + // ResultID a result id which will be sent on the next diagnostic request for the same document. + // + // @since 3.17.0 + ResultID string `json:"resultId"` +} + +// FullDocumentDiagnosticReport a diagnostic report with a full set of problems. +// +// @since 3.17.0 +type FullDocumentDiagnosticReport struct { + // ResultID an optional result id. If provided it will be sent on the next diagnostic request for the same document. + // + // @since 3.17.0 + ResultID string `json:"resultId,omitempty"` + + // Items the actual items. + // + // @since 3.17.0 + Items []Diagnostic `json:"items"` +} + +// DocumentDiagnosticReportPartialResult a partial result for a document diagnostic report. +// +// @since 3.17.0 +type DocumentDiagnosticReportPartialResult struct { + // @since 3.17.0 + RelatedDocuments map[DocumentURI]DocumentDiagnosticReportPartialResultRelatedDocuments `json:"relatedDocuments"` +} + +// DiagnosticServerCancellationData cancellation data returned from a diagnostic request. +// +// @since 3.17.0 +type DiagnosticServerCancellationData struct { + // @since 3.17.0 + RetriggerRequest bool `json:"retriggerRequest"` +} + +// DiagnosticOptions diagnostic options. +// +// @since 3.17.0 +type DiagnosticOptions struct { + // mixins + WorkDoneProgressOptions + + // Identifier an optional identifier under which the diagnostics are managed by the client. + // + // @since 3.17.0 + Identifier string `json:"identifier,omitempty"` + + // InterFileDependencies 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. + // + // @since 3.17.0 + InterFileDependencies bool `json:"interFileDependencies"` + + // WorkspaceDiagnostics the server provides support for workspace diagnostics as well. + // + // @since 3.17.0 + WorkspaceDiagnostics bool `json:"workspaceDiagnostics"` +} + +// DiagnosticRegistrationOptions diagnostic registration options. +// +// @since 3.17.0 +type DiagnosticRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DiagnosticOptions + // mixins + StaticRegistrationOptions +} + +// PreviousResultID a previous result id in a workspace pull request. +// +// @since 3.17.0 +type PreviousResultID struct { + // URI the URI for which the client knowns a result id. + // + // @since 3.17.0 + URI DocumentURI `json:"uri"` + + // Value the value of the previous result id. + // + // @since 3.17.0 + Value string `json:"value"` +} + +// WorkspaceDiagnosticParams parameters of the workspace diagnostic request. +// +// @since 3.17.0 +type WorkspaceDiagnosticParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // Identifier the additional identifier provided during registration. + // + // @since 3.17.0 + Identifier string `json:"identifier,omitempty"` + + // PreviousResultIDS the currently known diagnostic reports with their previous result ids. + // + // @since 3.17.0 + PreviousResultIDS []PreviousResultID `json:"previousResultIds"` +} + +// WorkspaceDiagnosticReport a workspace diagnostic report. +// +// @since 3.17.0 +type WorkspaceDiagnosticReport struct { + // @since 3.17.0 + Items []WorkspaceDocumentDiagnosticReport `json:"items"` +} + +// WorkspaceDiagnosticReportPartialResult a partial result for a workspace diagnostic report. +// +// @since 3.17.0 +type WorkspaceDiagnosticReportPartialResult struct { + // @since 3.17.0 + Items []WorkspaceDocumentDiagnosticReport `json:"items"` +} + +// SelectedCompletionInfo describes the currently selected completion item. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type SelectedCompletionInfo struct { + // Range the range that will be replaced if this completion item is accepted. + // + // @since 3.18.0 proposed + Range Range `json:"range"` + + // Text the text the range will be replaced with if this completion is accepted. + // + // @since 3.18.0 proposed + Text string `json:"text"` +} + +// InlineCompletionContext provides information about the context in which an inline completion was requested. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionContext struct { + // TriggerKind describes how the inline completion was triggered. + // + // @since 3.18.0 proposed + TriggerKind InlineCompletionTriggerKind `json:"triggerKind"` + + // SelectedCompletionInfo provides information about the currently selected item in the autocomplete widget if it is visible. + // + // @since 3.18.0 proposed + SelectedCompletionInfo *SelectedCompletionInfo `json:"selectedCompletionInfo,omitempty"` +} + +// InlineCompletionParams a parameter literal used in inline completion requests. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + + // Context additional information about the context in which inline completions were requested. + // + // @since 3.18.0 proposed + Context InlineCompletionContext `json:"context"` +} + +// InlineCompletionItem an inline completion item represents a text snippet that is proposed inline to complete text that is +// being typed. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionItem struct { + // InsertText the text to replace the range with. Must be set. + // + // @since 3.18.0 proposed + InsertText InlineCompletionItemInsertText `json:"insertText"` + + // FilterText a text that is used to decide if this inline completion should be shown. When `falsy` the InlineCompletionItem.insertText is used. + // + // @since 3.18.0 proposed + FilterText string `json:"filterText,omitempty"` + + // Range the range to replace. Must begin and end on the same line. + // + // @since 3.18.0 proposed + Range *Range `json:"range,omitempty"` + + // Command an optional Command that is executed *after* inserting this completion. + // + // @since 3.18.0 proposed + Command *Command `json:"command,omitempty"` +} + +// InlineCompletionList represents a collection of InlineCompletionItem inline completion items to be presented in the editor. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionList struct { + // Items the inline completion items. + // + // @since 3.18.0 proposed + Items []InlineCompletionItem `json:"items"` +} + +// InlineCompletionOptions inline completion options used during static registration. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionOptions struct { + // mixins + WorkDoneProgressOptions +} + +// InlineCompletionRegistrationOptions inline completion options used during static or dynamic registration. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionRegistrationOptions struct { + // extends + InlineCompletionOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// ServerCompletionItemOptions. +// +// @since 3.18.0 proposed +type ServerCompletionItemOptions struct { + // LabelDetailsSupport the server has support for completion item label details (see also `CompletionItemLabelDetails`) when receiving a completion item in a resolve call. + // @since 3.18.0 proposed + LabelDetailsSupport bool `json:"labelDetailsSupport,omitempty"` +} + +// CompletionOptions completion options. +type CompletionOptions struct { + // mixins + WorkDoneProgressOptions + + // TriggerCharacters most tools trigger completion request automatically without explicitly requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user starts to type an identifier. For example if the user types `c` in a JavaScript file code complete will automatically pop up present `console` besides others as a completion item. Characters that make up identifiers don't need to be listed here. If code complete should automatically be trigger on characters not being valid inside an identifier (for example `.` in JavaScript) list them in `triggerCharacters`. + TriggerCharacters []string `json:"triggerCharacters,omitempty"` + + // AllCommitCharacters the list of all possible characters that commit a completion. This field can be used if clients don't support individual commit characters per completion item. See `ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport` If a server provides both `allCommitCharacters` and commit characters on an individual completion item the ones on the completion item win. + AllCommitCharacters []string `json:"allCommitCharacters,omitempty"` + + // ResolveProvider the server provides support to resolve additional information for a completion item. + ResolveProvider bool `json:"resolveProvider,omitempty"` + + // CompletionItem the server supports the following `CompletionItem` specific capabilities. + CompletionItem *ServerCompletionItemOptions `json:"completionItem,omitempty"` +} + +// HoverOptions hover options. +type HoverOptions struct { + // mixins + WorkDoneProgressOptions +} + +// SignatureHelpOptions server Capabilities for a SignatureHelpRequest. +type SignatureHelpOptions struct { + // mixins + WorkDoneProgressOptions + + // TriggerCharacters list of characters that trigger signature help automatically. + TriggerCharacters []string `json:"triggerCharacters,omitempty"` + + // RetriggerCharacters list of characters that re-trigger signature help. These trigger characters are only active when signature help is already showing. All trigger characters are also counted as re-trigger characters. + RetriggerCharacters []string `json:"retriggerCharacters,omitempty"` +} + +// DefinitionOptions server Capabilities for a DefinitionRequest. +type DefinitionOptions struct { + // mixins + WorkDoneProgressOptions +} + +// ReferenceOptions reference options. +type ReferenceOptions struct { + // mixins + WorkDoneProgressOptions +} + +// DocumentHighlightOptions provider options for a DocumentHighlightRequest. +type DocumentHighlightOptions struct { + // mixins + WorkDoneProgressOptions +} + +// DocumentSymbolOptions provider options for a DocumentSymbolRequest. +type DocumentSymbolOptions struct { + // mixins + WorkDoneProgressOptions + + // Label a human-readable string that is shown when multiple outlines trees are shown for the same document. + Label string `json:"label,omitempty"` +} + +// CodeActionKindDocumentation documentation for a class of code actions. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type CodeActionKindDocumentation struct { + // Kind the kind of the code action being documented. If the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any refactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the documentation will only be shown when extract refactoring code actions are returned. + // + // @since 3.18.0 proposed + Kind CodeActionKind `json:"kind"` + + // Command command that is ued to display the documentation to the user. The title of this documentation code action is taken from {@linkcode Command.title}. + // + // @since 3.18.0 proposed + Command Command `json:"command"` +} + +// CodeActionOptions provider options for a CodeActionRequest. +type CodeActionOptions struct { + // mixins + WorkDoneProgressOptions + + // CodeActionKinds codeActionKinds that this server may return. The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server may list out every specific kind they provide. + CodeActionKinds []CodeActionKind `json:"codeActionKinds,omitempty"` + + // Documentation static documentation for a class of code actions. Documentation from the provider should be shown in + // the code actions menu if either: - Code actions of `kind` are requested by the editor. In this + // case, the editor will show the documentation that most closely matches the requested code action kind. For example, if a provider has documentation for both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`, the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`. - Any code actions of `kind` are returned by the provider. At most one documentation entry should be shown per provider. 3.18.0 @proposed. + Documentation []CodeActionKindDocumentation `json:"documentation,omitempty"` + + // ResolveProvider the server provides support to resolve additional information for a code action. + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// CodeLensOptions code Lens provider options of a CodeLensRequest. +type CodeLensOptions struct { + // mixins + WorkDoneProgressOptions + + // ResolveProvider code lens has a resolve provider as well. + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// DocumentLinkOptions provider options for a DocumentLinkRequest. +type DocumentLinkOptions struct { + // mixins + WorkDoneProgressOptions + + // ResolveProvider document links have a resolve provider as well. + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// WorkspaceSymbolOptions server capabilities for a WorkspaceSymbolRequest. +type WorkspaceSymbolOptions struct { + // mixins + WorkDoneProgressOptions + + // ResolveProvider the server provides support to resolve additional information for a workspace symbol. + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// DocumentFormattingOptions provider options for a DocumentFormattingRequest. +type DocumentFormattingOptions struct { + // mixins + WorkDoneProgressOptions +} + +// DocumentRangeFormattingOptions provider options for a DocumentRangeFormattingRequest. +type DocumentRangeFormattingOptions struct { + // mixins + WorkDoneProgressOptions + + // RangesSupport whether the server supports formatting multiple ranges at once. 3.18.0 @proposed. + RangesSupport bool `json:"rangesSupport,omitempty"` +} + +// DocumentOnTypeFormattingOptions provider options for a DocumentOnTypeFormattingRequest. +type DocumentOnTypeFormattingOptions struct { + // FirstTriggerCharacter a character on which formatting should be triggered, like `{`. + FirstTriggerCharacter string `json:"firstTriggerCharacter"` + + // MoreTriggerCharacter more trigger characters. + MoreTriggerCharacter []string `json:"moreTriggerCharacter,omitempty"` +} + +// RenameOptions provider options for a RenameRequest. +type RenameOptions struct { + // mixins + WorkDoneProgressOptions + + // PrepareProvider renames should be checked and tested before being executed. version . + PrepareProvider bool `json:"prepareProvider,omitempty"` +} + +// ExecuteCommandOptions the server capabilities of a ExecuteCommandRequest. +type ExecuteCommandOptions struct { + // mixins + WorkDoneProgressOptions + + // Commands the commands to be executed on the server. + Commands []string `json:"commands"` +} + +// PublishDiagnosticsParams the publish diagnostic notification's parameters. +type PublishDiagnosticsParams struct { + // URI the URI for which diagnostic information is reported. + URI DocumentURI `json:"uri"` + + // Version optional the version number of the document the diagnostics are published for. + Version int32 `json:"version,omitempty"` + + // Diagnostics an array of diagnostic information items. + Diagnostics []Diagnostic `json:"diagnostics"` +} + +// CompletionContext contains additional information about the context in which a completion request is triggered. +type CompletionContext struct { + // TriggerKind how the completion was triggered. + TriggerKind CompletionTriggerKind `json:"triggerKind"` + + // TriggerCharacter the trigger character (a single character) that has trigger code complete. Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`. + TriggerCharacter string `json:"triggerCharacter,omitempty"` +} + +// CompletionParams completion parameters. +type CompletionParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams + + // Context the completion context. This is only available it the client specifies to send this using the client + // capability `textDocument.completion.contextSupport === true`. + Context *CompletionContext `json:"context,omitempty"` +} + +// CompletionItemLabelDetails additional details for a completion item label. +// +// @since 3.17.0 +type CompletionItemLabelDetails struct { + // Detail an optional string which is rendered less prominently directly after CompletionItem.label label, without any spacing. Should be used for function signatures and type annotations. + // + // @since 3.17.0 + Detail string `json:"detail,omitempty"` + + // Description an optional string which is rendered less prominently after CompletionItem.detail. Should be used for fully qualified names and file paths. + // + // @since 3.17.0 + Description string `json:"description,omitempty"` +} + +// InsertReplaceEdit a special text edit to provide an insert and a replace operation. +// +// @since 3.16.0 +type InsertReplaceEdit struct { + // NewText the string to be inserted. + // + // @since 3.16.0 + NewText string `json:"newText"` + + // Insert the range if the insert is requested. + // + // @since 3.16.0 + Insert Range `json:"insert"` + + // Replace the range if the replace is requested. + // + // @since 3.16.0 + Replace Range `json:"replace"` +} + +// CompletionItem a completion item represents a text snippet that is proposed to complete text that is being typed. +type CompletionItem struct { + // Label the label of this completion item. The label property is also by default the text that is inserted when selecting this completion. If label details are provided the label itself should be an unqualified name of the completion item. + Label string `json:"label"` + + // LabelDetails additional details for the label + LabelDetails *CompletionItemLabelDetails `json:"labelDetails,omitempty"` + + // Kind the kind of this completion item. Based of the kind an icon is chosen by the editor. + Kind CompletionItemKind `json:"kind,omitempty"` + + // Tags tags for this completion item. + Tags []CompletionItemTag `json:"tags,omitempty"` + + // Detail a human-readable string with additional information about this item, like type or symbol information. + Detail string `json:"detail,omitempty"` + + // Documentation a human-readable string that represents a doc-comment. + Documentation CompletionItemDocumentation `json:"documentation,omitempty"` + + // Deprecated indicates if this item is deprecated. + // + // Deprecated: Use `tags` instead. + Deprecated bool `json:"deprecated,omitempty"` + + // Preselect select this item when showing. *Note* that only one completion item can be selected and that the tool / client decides which item that is. The rule is that the *first* item of those that match best is + // selected. + Preselect bool `json:"preselect,omitempty"` + + // SortText a string that should be used when comparing this item with other items. When `falsy` the CompletionItem.label label is used. + SortText string `json:"sortText,omitempty"` + + // FilterText a string that should be used when filtering a set of completion items. When `falsy` the CompletionItem.label label is used. + FilterText string `json:"filterText,omitempty"` + + // InsertText a string that should be inserted into a document when selecting this completion. When `falsy` the CompletionItem.label label is used. The `insertText` is subject to interpretation by the client side. Some tools might not take the string literally. For example VS Code when code complete is requested in this example `con` and a completion item with an `insertText` of `console` is provided it will only insert `sole`. Therefore it is recommended to use `textEdit` instead since it avoids additional client side interpretation. + InsertText string `json:"insertText,omitempty"` + + // InsertTextFormat the format of the insert text. The format applies to both the `insertText` property and the `newText` property of a provided `textEdit`. If omitted defaults to `InsertTextFormat.PlainText`. Please note that the insertTextFormat doesn't apply to `additionalTextEdits`. + InsertTextFormat InsertTextFormat `json:"insertTextFormat,omitempty"` + + // InsertTextMode how whitespace and indentation is handled during completion item insertion. If not provided the clients default value depends on the `textDocument.completion.insertTextMode` client capability. + InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"` + + // TextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`. + TextEdit CompletionItemTextEdit `json:"textEdit,omitempty"` + + // TextEditText the edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range. Clients will only honor this property if they opt into completion list item defaults using the capability `completionList.itemDefaults`. If not provided and a list's default range is provided the label property is used as a text. + TextEditText string `json:"textEditText,omitempty"` + + // AdditionalTextEdits an optional array of additional TextEdit text edits that are applied when selecting this completion. + // Edits must not overlap (including the same insert position) with the main CompletionItem.textEdit edit nor with themselves. Additional text edits should be used to change text unrelated to the current cursor position (for example adding an import statement at the top of the file if the completion item will insert an unqualified type). + AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"` + + // CommitCharacters an optional set of characters that when pressed while this completion is active will accept it first + // and then type that character. *Note* that all commit characters should have `length=1` and that superfluous characters will be ignored. + CommitCharacters []string `json:"commitCharacters,omitempty"` + + // Command an optional Command command that is executed *after* inserting this completion. *Note* that additional modifications to the current document should be described with the CompletionItem.additionalTextEdits additionalTextEdits-property. + Command *Command `json:"command,omitempty"` + + // Data a data entry field that is preserved on a completion item between a CompletionRequest and a CompletionResolveRequest. + Data any `json:"data,omitempty"` +} + +// EditRangeWithInsertReplace edit range variant that includes ranges for insert and replace operations. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type EditRangeWithInsertReplace struct { + // @since 3.18.0 proposed + Insert Range `json:"insert"` + + // @since 3.18.0 proposed + Replace Range `json:"replace"` +} + +// CompletionItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value the one from the item is used. Servers are only allowed to return default values if the client signals support for this via +// the `completionList.itemDefaults` capability. +// +// @since 3.17.0 +type CompletionItemDefaults struct { + // CommitCharacters a default commit character set. + // @since 3.17.0 + CommitCharacters []string `json:"commitCharacters,omitempty"` + + // EditRange a default edit range. + // @since 3.17.0 + EditRange CompletionItemDefaultsEditRange `json:"editRange,omitempty"` + + // InsertTextFormat a default insert text format. + // @since 3.17.0 + InsertTextFormat InsertTextFormat `json:"insertTextFormat,omitempty"` + + // InsertTextMode a default insert text mode. + // @since 3.17.0 + InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"` + + // Data a default data value. + // @since 3.17.0 + Data any `json:"data,omitempty"` +} + +// CompletionList represents a collection of CompletionItem completion items to be presented in the editor. +type CompletionList struct { + // IsIncomplete this list it not complete. Further typing results in recomputing this list. Recomputed lists have all their items replaced (not appended) in the incomplete completion sessions. + IsIncomplete bool `json:"isIncomplete"` + + // ItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value the one from the item is used. Servers are only allowed to return default values if the client signals support for this via + // the `completionList.itemDefaults` capability. + ItemDefaults *CompletionItemDefaults `json:"itemDefaults,omitempty"` + + // Items the completion items. + Items []CompletionItem `json:"items"` +} + +// CompletionRegistrationOptions registration options for a CompletionRequest. +type CompletionRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + CompletionOptions +} + +// HoverParams parameters for a HoverRequest. +type HoverParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams +} + +// Hover the result of a hover request. +type Hover struct { + // Contents the hover's content. + Contents HoverContents `json:"contents"` + + // Range an optional range inside the text document that is used to visualize the hover, e.g. by changing the + // background color. + Range *Range `json:"range,omitempty"` +} + +// HoverRegistrationOptions registration options for a HoverRequest. +type HoverRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + HoverOptions +} + +// ParameterInformation represents a parameter of a callable-signature. A parameter can have a label and a doc-comment. +type ParameterInformation struct { + // Label the label of this parameter information. Either a string or an inclusive start and exclusive end offsets within its containing signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 string representation as `Position` and `Range` does. To avoid ambiguities a server should use the [start, end] offset value instead of using a substring. Whether a client support this is controlled via `labelOffsetSupport` client capability. *Note*: a label of type string should be a substring of its containing signature label. Its intended use case is to highlight the parameter label + // part in the `SignatureInformation.label`. + Label ParameterInformationLabel `json:"label"` + + // Documentation the human-readable doc-comment of this parameter. Will be shown in the UI but can be omitted. + Documentation ParameterInformationDocumentation `json:"documentation,omitempty"` +} + +// SignatureInformation represents the signature of something callable. A signature can have a label, like a function-name, a doc-comment, and a set of parameters. +type SignatureInformation struct { + // Label the label of this signature. Will be shown in the UI. + Label string `json:"label"` + + // Documentation the human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. + Documentation SignatureInformationDocumentation `json:"documentation,omitempty"` + + // Parameters the parameters of this signature. + Parameters []ParameterInformation `json:"parameters,omitempty"` + + // ActiveParameter the index of the active parameter. If `null`, no parameter of the signature is active (for example a + // named argument that does not match any declared parameters). This is only valid if the client specifies the client capability `textDocument.signatureHelp.noActiveParameterSupport === true` If provided (or `null`), this is used in place of `SignatureHelp.activeParameter`. + ActiveParameter uint32 `json:"activeParameter,omitempty"` +} + +// SignatureHelp signature help represents the signature of something callable. There can be multiple signature but only one active and only one active parameter. +type SignatureHelp struct { + // Signatures one or more signatures. + Signatures []SignatureInformation `json:"signatures"` + + // ActiveSignature the active signature. If omitted or the value lies outside the range of `signatures` the value defaults to zero or is ignored if the `SignatureHelp` has no signatures. Whenever possible implementors should make an active decision about the active signature and shouldn't rely on a default value. In future version of the protocol this property might become mandatory to better express this. + ActiveSignature uint32 `json:"activeSignature,omitempty"` + + // ActiveParameter the active parameter of the active signature. If `null`, no parameter of the signature is active (for example a named argument that does not match any declared parameters). This is only valid if the client specifies the client capability `textDocument.signatureHelp.noActiveParameterSupport === true` + // If omitted or the value lies outside the range of `signatures[activeSignature].parameters` defaults to 0 if the active signature has parameters. If the active signature has no parameters it is ignored. In future version of the protocol this property might become mandatory (but still nullable) to better express the active parameter if the active signature does have any. + ActiveParameter uint32 `json:"activeParameter,omitempty"` +} + +// SignatureHelpContext additional information about the context in which a signature help request was triggered. +// +// @since 3.15.0 +type SignatureHelpContext struct { + // TriggerKind action that caused signature help to be triggered. + // + // @since 3.15.0 + TriggerKind SignatureHelpTriggerKind `json:"triggerKind"` + + // TriggerCharacter character that caused signature help to be triggered. This is undefined when `triggerKind !== SignatureHelpTriggerKind.TriggerCharacter`. + // + // @since 3.15.0 + TriggerCharacter string `json:"triggerCharacter,omitempty"` + + // IsRetrigger `true` if signature help was already showing when it was triggered. Retriggers occurs when the signature help is already active and can be caused by actions such as typing a trigger character, a cursor move, or document content changes. + // + // @since 3.15.0 + IsRetrigger bool `json:"isRetrigger"` + + // ActiveSignatureHelp the currently active `SignatureHelp`. The `activeSignatureHelp` has its `SignatureHelp.activeSignature` field updated based on the user navigating through available signatures. + // + // @since 3.15.0 + ActiveSignatureHelp *SignatureHelp `json:"activeSignatureHelp,omitempty"` +} + +// SignatureHelpParams parameters for a SignatureHelpRequest. +type SignatureHelpParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + + // Context the signature help context. This is only available if the client specifies to send this using the client capability `textDocument.signatureHelp.contextSupport === true` + Context *SignatureHelpContext `json:"context,omitempty"` +} + +// SignatureHelpRegistrationOptions registration options for a SignatureHelpRequest. +type SignatureHelpRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + SignatureHelpOptions +} + +// DefinitionParams parameters for a DefinitionRequest. +type DefinitionParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +// DefinitionRegistrationOptions registration options for a DefinitionRequest. +type DefinitionRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DefinitionOptions +} + +// ReferenceContext value-object that contains additional information when requesting references. +type ReferenceContext struct { + // IncludeDeclaration include the declaration of the current symbol. + IncludeDeclaration bool `json:"includeDeclaration"` +} + +// ReferenceParams parameters for a ReferencesRequest. +type ReferenceParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams + + Context ReferenceContext `json:"context"` +} + +// ReferenceRegistrationOptions registration options for a ReferencesRequest. +type ReferenceRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + ReferenceOptions +} + +// DocumentHighlightParams parameters for a DocumentHighlightRequest. +type DocumentHighlightParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +// DocumentHighlight a document highlight is a range inside a text document which deserves special attention. Usually a document highlight is visualized by changing the background color of its range. +type DocumentHighlight struct { + // Range the range this highlight applies to. + Range Range `json:"range"` + + // Kind the highlight kind, default is DocumentHighlightKind.Text text. + Kind DocumentHighlightKind `json:"kind,omitempty"` +} + +// DocumentHighlightRegistrationOptions registration options for a DocumentHighlightRequest. +type DocumentHighlightRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentHighlightOptions +} + +// DocumentSymbolParams parameters for a DocumentSymbolRequest. +type DocumentSymbolParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// BaseSymbolInformation a base for all symbol information. +type BaseSymbolInformation struct { + // Name the name of this symbol. + Name string `json:"name"` + + // Kind the kind of this symbol. + Kind SymbolKind `json:"kind"` + + // Tags tags for this symbol. + Tags []SymbolTag `json:"tags,omitempty"` + + // ContainerName the name of the symbol containing this symbol. This information is for user interface purposes (e.g. + // to render a qualifier in the user interface if necessary). It can't be used to re-infer a hierarchy for the document symbols. + ContainerName string `json:"containerName,omitempty"` +} + +// SymbolInformation represents information about programming constructs like variables, classes, interfaces etc. +type SymbolInformation struct { + // extends + BaseSymbolInformation + + // Deprecated indicates if this symbol is deprecated. + // + // Deprecated: Use tags instead. + Deprecated bool `json:"deprecated,omitempty"` + + // Location the location of this symbol. The location's range is used by a tool to reveal the location in the editor. If the symbol is selected in the tool the range's start information is used to position the cursor. So the range usually spans more than the actual symbol's name and does normally include things + // like visibility modifiers. The range doesn't have to denote a node range in the sense of an abstract syntax tree. It can therefore not be used to re-construct a hierarchy of the symbols. + Location Location `json:"location"` +} + +// DocumentSymbol represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document symbols can be hierarchical and they have two ranges: one that encloses its definition and one that points to its most interesting range, e.g. the range of an identifier. +type DocumentSymbol struct { + // Name the name of this symbol. Will be displayed in the user interface and therefore must not be an empty string or a string only consisting of white spaces. + Name string `json:"name"` + + // Detail more detail for this symbol, e.g the signature of a function. + Detail string `json:"detail,omitempty"` + + // Kind the kind of this symbol. + Kind SymbolKind `json:"kind"` + + // Tags tags for this document symbol. + Tags []SymbolTag `json:"tags,omitempty"` + + // Deprecated indicates if this symbol is deprecated. + // + // Deprecated: Use tags instead. + Deprecated bool `json:"deprecated,omitempty"` + + // Range the range enclosing this symbol not including leading/trailing whitespace but everything else like comments. This information is typically used to determine if the clients cursor is inside the symbol to reveal in the symbol in the UI. + Range Range `json:"range"` + + // SelectionRange the range that should be selected and revealed when this symbol is being picked, e.g the name of a function. Must be contained by the `range`. + SelectionRange Range `json:"selectionRange"` + + // Children children of this symbol, e.g. properties of a class. + Children []DocumentSymbol `json:"children,omitempty"` +} + +// DocumentSymbolRegistrationOptions registration options for a DocumentSymbolRequest. +type DocumentSymbolRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentSymbolOptions +} + +// CodeActionContext contains additional diagnostic information about the context in which a CodeActionProvider.provideCodeActions code action is run. +type CodeActionContext struct { + // Diagnostics an array of diagnostics known on the client side overlapping the range provided to the `textDocument/codeAction` request. They are provided so that the server knows which errors are currently presented to the user for the given range. There is no guarantee that these accurately reflect the error state of the resource. The primary parameter to compute code actions is the provided range. + Diagnostics []Diagnostic `json:"diagnostics"` + + // Only requested kind of actions to return. Actions not of this kind are filtered out by the client before being shown. So servers can omit computing them. + Only []CodeActionKind `json:"only,omitempty"` + + // TriggerKind the reason why code actions were requested. + TriggerKind CodeActionTriggerKind `json:"triggerKind,omitempty"` +} + +// CodeActionParams the parameters of a CodeActionRequest. +type CodeActionParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the document in which the command was invoked. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Range the range for which the command was invoked. + Range Range `json:"range"` + + // Context context carrying additional information. + Context CodeActionContext `json:"context"` +} + +// CodeActionDisabled captures why the code action is currently disabled. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type CodeActionDisabled struct { + // Reason human readable description of why the code action is currently disabled. This is displayed in the code actions UI. + // + // @since 3.18.0 proposed + Reason string `json:"reason"` +} + +// CodeAction a code action represents a change that can be performed in code, e.g. to fix a problem or to refactor code. A CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed. +type CodeAction struct { + // Title a short, human-readable, title for this code action. + Title string `json:"title"` + + // Kind the kind of the code action. Used to filter code actions. + Kind CodeActionKind `json:"kind,omitempty"` + + // Diagnostics the diagnostics that this code action resolves. + Diagnostics []Diagnostic `json:"diagnostics,omitempty"` + + // IsPreferred marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted by keybindings. A quick fix should be marked preferred if it properly addresses the underlying error. A refactoring should be marked preferred if it is the most reasonable choice of actions to take. + IsPreferred bool `json:"isPreferred,omitempty"` + + // Disabled marks that the code action cannot currently be applied. Clients should follow the following guidelines regarding disabled code actions: - Disabled code actions are not shown in automatic [lightbulbs](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) code action menus. - Disabled + // actions are shown as faded out in the code action menu when the user requests a more specific type of code action, such as refactorings. - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions) that auto applies a code action and only disabled code actions are returned, the client should show the user an error message with `reason` + // in the editor. + Disabled *CodeActionDisabled `json:"disabled,omitempty"` + + // Edit the workspace edit this code action performs. + Edit *WorkspaceEdit `json:"edit,omitempty"` + + // Command a command this code action executes. If a code action provides an edit and a command, first the edit + // is executed and then the command. + Command *Command `json:"command,omitempty"` + + // Data a data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request. + Data any `json:"data,omitempty"` +} + +// CodeActionRegistrationOptions registration options for a CodeActionRequest. +type CodeActionRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + CodeActionOptions +} + +// LocationURIOnly location with only uri and does not include range. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type LocationURIOnly struct { + // @since 3.18.0 proposed + URI DocumentURI `json:"uri"` +} + +// CodeLensParams the parameters of a CodeLensRequest. +type CodeLensParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the document to request code lens for. + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// CodeLens a code lens represents a Command command that should be shown along with source text, like the number of references, a way to run tests, etc. A code lens is _unresolved_ when no command is associated to it. For performance reasons the creation of a code lens and resolving should be done in two stages. +type CodeLens struct { + // Range the range in which this code lens is valid. Should only span a single line. + Range Range `json:"range"` + + // Command the command this code lens represents. + Command *Command `json:"command,omitempty"` + + // Data a data entry field that is preserved on a code lens item between a CodeLensRequest and a CodeLensResolveRequest. + Data any `json:"data,omitempty"` +} + +// CodeLensRegistrationOptions registration options for a CodeLensRequest. +type CodeLensRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + CodeLensOptions +} + +// DocumentLinkParams the parameters of a DocumentLinkRequest. +type DocumentLinkParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the document to provide document links for. + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// DocumentLink a document link is a range in a text document that links to an internal or external resource, like another text document or a web site. +type DocumentLink struct { + // Range the range this link applies to. + Range Range `json:"range"` + + // Target the uri this link points to. If missing a resolve request is sent later. + Target uri.URI `json:"target,omitempty"` + + // Tooltip the tooltip text when you hover over this link. If a tooltip is provided, is will be displayed in a string that includes instructions on how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS, user settings, and localization. + Tooltip string `json:"tooltip,omitempty"` + + // Data a data entry field that is preserved on a document link between a DocumentLinkRequest and a DocumentLinkResolveRequest. + Data any `json:"data,omitempty"` +} + +// DocumentLinkRegistrationOptions registration options for a DocumentLinkRequest. +type DocumentLinkRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentLinkOptions +} + +// FormattingOptions value-object describing what options formatting should use. +type FormattingOptions struct { + // TabSize size of a tab in spaces. + TabSize uint32 `json:"tabSize"` + + // InsertSpaces prefer spaces over tabs. + InsertSpaces bool `json:"insertSpaces"` + + // TrimTrailingWhitespace trim trailing whitespace on a line. + TrimTrailingWhitespace bool `json:"trimTrailingWhitespace,omitempty"` + + // InsertFinalNewline insert a newline character at the end of the file if one does not exist. + InsertFinalNewline bool `json:"insertFinalNewline,omitempty"` + + // TrimFinalNewlines trim all newlines after the final newline at the end of the file. + TrimFinalNewlines bool `json:"trimFinalNewlines,omitempty"` +} + +// DocumentFormattingParams the parameters of a DocumentFormattingRequest. +type DocumentFormattingParams struct { + // mixins + WorkDoneProgressParams + + // TextDocument the document to format. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Options the format options. + Options FormattingOptions `json:"options"` +} + +// DocumentFormattingRegistrationOptions registration options for a DocumentFormattingRequest. +type DocumentFormattingRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentFormattingOptions +} + +// DocumentRangeFormattingParams the parameters of a DocumentRangeFormattingRequest. +type DocumentRangeFormattingParams struct { + // mixins + WorkDoneProgressParams + + // TextDocument the document to format. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Range the range to format. + Range Range `json:"range"` + + // Options the format options. + Options FormattingOptions `json:"options"` +} + +// DocumentRangeFormattingRegistrationOptions registration options for a DocumentRangeFormattingRequest. +type DocumentRangeFormattingRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentRangeFormattingOptions +} + +// DocumentRangesFormattingParams the parameters of a DocumentRangesFormattingRequest. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type DocumentRangesFormattingParams struct { + // mixins + WorkDoneProgressParams + + // TextDocument the document to format. + // + // @since 3.18.0 proposed + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Ranges the ranges to format. + // + // @since 3.18.0 proposed + Ranges []Range `json:"ranges"` + + // Options the format options. + // + // @since 3.18.0 proposed + Options FormattingOptions `json:"options"` +} + +// DocumentOnTypeFormattingParams the parameters of a DocumentOnTypeFormattingRequest. +type DocumentOnTypeFormattingParams struct { + // TextDocument the document to format. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Position the position around which the on type formatting should happen. This is not necessarily the exact position where the character denoted by the property `ch` got typed. + Position Position `json:"position"` + + // Ch the character that has been typed that triggered the formatting on type request. That is not necessarily the last character that got inserted into the document since the client could auto insert characters as well (e.g. like automatic brace completion). + Ch string `json:"ch"` + + // Options the formatting options. + Options FormattingOptions `json:"options"` +} + +// DocumentOnTypeFormattingRegistrationOptions registration options for a DocumentOnTypeFormattingRequest. +type DocumentOnTypeFormattingRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentOnTypeFormattingOptions +} + +// RenameParams the parameters of a RenameRequest. +type RenameParams struct { + // mixins + WorkDoneProgressParams + + // TextDocument the document to rename. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Position the position at which this request was sent. + Position Position `json:"position"` + + // NewName the new name of the symbol. If the given name is not valid the request must return a ResponseError with an appropriate message set. + NewName string `json:"newName"` +} + +// RenameRegistrationOptions registration options for a RenameRequest. +type RenameRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + RenameOptions +} + +type PrepareRenameParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams +} + +// ExecuteCommandParams the parameters of a ExecuteCommandRequest. +type ExecuteCommandParams struct { + // mixins + WorkDoneProgressParams + + // Command the identifier of the actual command handler. + Command string `json:"command"` + + // Arguments arguments that the command should be invoked with. + Arguments []any `json:"arguments,omitempty"` +} + +// ExecuteCommandRegistrationOptions registration options for a ExecuteCommandRequest. +type ExecuteCommandRegistrationOptions struct { + // extends + ExecuteCommandOptions +} + +// InlineValueText provide inline value as text. +// +// @since 3.17.0 +type InlineValueText struct { + // Range the document range for which the inline value applies. + // + // @since 3.17.0 + Range Range `json:"range"` + + // Text the text of the inline value. + // + // @since 3.17.0 + Text string `json:"text"` +} + +// InlineValueVariableLookup provide inline value through a variable lookup. If only a range is specified, the variable name will +// be extracted from the underlying document. An optional variable name can be used to override the extracted name. +// +// @since 3.17.0 +type InlineValueVariableLookup struct { + // Range the document range for which the inline value applies. The range is used to extract the variable name from the underlying document. + // + // @since 3.17.0 + Range Range `json:"range"` + + // VariableName if specified the name of the variable to look up. + // + // @since 3.17.0 + VariableName string `json:"variableName,omitempty"` + + // CaseSensitiveLookup how to perform the lookup. + // + // @since 3.17.0 + CaseSensitiveLookup bool `json:"caseSensitiveLookup"` +} + +// InlineValueEvaluatableExpression provide an inline value through an expression evaluation. If only a range is specified, the expression will be extracted from the underlying document. An optional expression can be used to override the extracted expression. +// +// @since 3.17.0 +type InlineValueEvaluatableExpression struct { + // Range the document range for which the inline value applies. The range is used to extract the evaluatable expression from the underlying document. + // + // @since 3.17.0 + Range Range `json:"range"` + + // Expression if specified the expression overrides the extracted expression. + // + // @since 3.17.0 + Expression string `json:"expression,omitempty"` +} + +// RelatedFullDocumentDiagnosticReport a full diagnostic report with a set of related documents. +// +// @since 3.17.0 +type RelatedFullDocumentDiagnosticReport struct { + // extends + FullDocumentDiagnosticReport + + // RelatedDocuments 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]RelatedFullDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` +} + +// RelatedUnchangedDocumentDiagnosticReport an unchanged diagnostic report with a set of related documents. +// +// @since 3.17.0 +type RelatedUnchangedDocumentDiagnosticReport struct { + // extends + UnchangedDocumentDiagnosticReport + + // RelatedDocuments 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]RelatedUnchangedDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` +} + +// PrepareRenamePlaceholder. +// +// @since 3.18.0 proposed +type PrepareRenamePlaceholder struct { + // @since 3.18.0 proposed + Range Range `json:"range"` + + // @since 3.18.0 proposed + Placeholder string `json:"placeholder"` +} + +// PrepareRenameDefaultBehavior. +// +// @since 3.18.0 proposed +type PrepareRenameDefaultBehavior struct { + // @since 3.18.0 proposed + DefaultBehavior bool `json:"defaultBehavior"` +} + +// WorkspaceFullDocumentDiagnosticReport a full document diagnostic report for a workspace diagnostic result. +// +// @since 3.17.0 +type WorkspaceFullDocumentDiagnosticReport struct { + // extends + FullDocumentDiagnosticReport + + // URI the URI for which diagnostic information is reported. + // + // @since 3.17.0 + URI DocumentURI `json:"uri"` + + // Version the version number for which the diagnostics are reported. If the document is not marked as open `null` can be provided. + // + // @since 3.17.0 + Version int32 `json:"version,omitempty"` +} + +// WorkspaceUnchangedDocumentDiagnosticReport an unchanged document diagnostic report for a workspace diagnostic result. +// +// @since 3.17.0 +type WorkspaceUnchangedDocumentDiagnosticReport struct { + // extends + UnchangedDocumentDiagnosticReport + + // URI the URI for which diagnostic information is reported. + // + // @since 3.17.0 + URI DocumentURI `json:"uri"` + + // Version the version number for which the diagnostics are reported. If the document is not marked as open `null` can be provided. + // + // @since 3.17.0 + Version int32 `json:"version,omitempty"` +} + +// TextDocumentContentChangePartial. +// +// @since 3.18.0 proposed +type TextDocumentContentChangePartial struct { + // Range the range of the document that changed. + // + // @since 3.18.0 proposed + Range Range `json:"range"` + + // RangeLength the optional length of the range that got replaced. + // + // Deprecated: use range instead. + // + // @since 3.18.0 proposed + RangeLength uint32 `json:"rangeLength,omitempty"` + + // Text the new text for the provided range. + // + // @since 3.18.0 proposed + Text string `json:"text"` +} + +// TextDocumentContentChangeWholeDocument. +// +// @since 3.18.0 proposed +type TextDocumentContentChangeWholeDocument struct { + // Text the new text of the whole document. + // + // @since 3.18.0 proposed + Text string `json:"text"` +} + +// MarkedStringWithLanguage. +// +// @since 3.18.0 proposed +type MarkedStringWithLanguage struct { + // @since 3.18.0 proposed + Language string `json:"language"` + + // @since 3.18.0 proposed + Value string `json:"value"` +} + +// NotebookCellTextDocumentFilter a notebook cell text document filter denotes a cell text document by different properties. +// +// @since 3.17.0 +type NotebookCellTextDocumentFilter struct { + // Notebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. + // + // @since 3.17.0 + Notebook NotebookCellTextDocumentFilterNotebook `json:"notebook"` + + // Language a language id like `python`. Will be matched against the language id of the notebook cell document. '*' matches every language. + // + // @since 3.17.0 + Language string `json:"language,omitempty"` +} + +// TextDocumentFilterLanguage a document filter where `language` is required field. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentFilterLanguage struct { + // Language a language id, like `typescript`. + // + // @since 3.18.0 proposed + Language string `json:"language"` + + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 proposed + Scheme string `json:"scheme,omitempty"` + + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. + // + // @since 3.18.0 proposed + Pattern string `json:"pattern,omitempty"` +} + +// TextDocumentFilterScheme a document filter where `scheme` is required field. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentFilterScheme struct { + // Language a language id, like `typescript`. + // + // @since 3.18.0 proposed + Language string `json:"language,omitempty"` + + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 proposed + Scheme string `json:"scheme"` + + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. + // + // @since 3.18.0 proposed + Pattern string `json:"pattern,omitempty"` +} + +// TextDocumentFilterPattern a document filter where `pattern` is required field. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentFilterPattern struct { + // Language a language id, like `typescript`. + // + // @since 3.18.0 proposed + Language string `json:"language,omitempty"` + + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 proposed + Scheme string `json:"scheme,omitempty"` + + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. + // + // @since 3.18.0 proposed + Pattern string `json:"pattern"` +} diff --git a/protocol/lifecycle.go b/protocol/lifecycle.go new file mode 100644 index 00000000..dff7e64d --- /dev/null +++ b/protocol/lifecycle.go @@ -0,0 +1,1339 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +// TextDocumentSyncKind defines how the host (editor) should sync document changes to the language server. +type TextDocumentSyncKind uint32 + +const ( + // NoneTextDocumentSyncKind documents should not be synced at all. + NoneTextDocumentSyncKind TextDocumentSyncKind = 0 + + // FullTextDocumentSyncKind documents are synced by always sending the full content of the document. + FullTextDocumentSyncKind TextDocumentSyncKind = 1 + + // IncrementalTextDocumentSyncKind documents are synced by sending the full content on open. After that only incremental updates to the + // document are send. + IncrementalTextDocumentSyncKind TextDocumentSyncKind = 2 +) + +// TextDocumentRegistrationOptions general text document registration options. +type TextDocumentRegistrationOptions struct { + // DocumentSelector a document selector to identify the scope of the registration. If set to null the document selector provided on the client side will be used. + DocumentSelector *DocumentSelector `json:"documentSelector,omitempty"` +} + +// Registration general parameters to register for a notification or to register a provider. +type Registration struct { + // ID the id used to register the request. The id can be used to deregister the request again. + ID string `json:"id"` + + // Method the method / capability to register for. + Method string `json:"method"` + + // RegisterOptions options necessary for the registration. + RegisterOptions any `json:"registerOptions,omitempty"` +} + +type RegistrationParams struct { + Registrations []Registration `json:"registrations"` +} + +// Unregistration general parameters to unregister a request or notification. +type Unregistration struct { + // ID the id used to unregister the request or notification. Usually an id provided during the register request. + ID string `json:"id"` + + // Method the method to unregister for. + Method string `json:"method"` +} + +type UnregistrationParams struct { + Unregisterations []Unregistration `json:"unregisterations"` +} + +// ClientInfo information about the client 3.15.0 3.18.0 ClientInfo type name added. @proposed. +// +// @since 3.18.0 ClientInfo type name added. proposed +type ClientInfo struct { + // Name the name of the client as defined by the client. + // + // @since 3.18.0 ClientInfo type name added. proposed + Name string `json:"name"` + + // Version the client's version as defined by the client. + // + // @since 3.18.0 ClientInfo type name added. proposed + Version string `json:"version,omitempty"` +} + +// SemanticTokensWorkspaceClientCapabilities. +// +// @since 3.16.0 +type SemanticTokensWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all semantic tokens currently shown. It should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. + // + // @since 3.16.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// CodeLensWorkspaceClientCapabilities. +// +// @since 3.16.0 +type CodeLensWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all code lenses currently shown. It + // should be used with absolute care and is useful for situation where a server for example detect a project wide change that requires such a calculation. + // + // @since 3.16.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// FileOperationClientCapabilities capabilities relating to events from file operations by the user in the client. These events do not come from the file system, they come from user operations like renaming a file in the UI. +// +// @since 3.16.0 +type FileOperationClientCapabilities struct { + // DynamicRegistration whether the client supports dynamic registration for file requests/notifications. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // DidCreate the client has support for sending didCreateFiles notifications. + // + // @since 3.16.0 + DidCreate bool `json:"didCreate,omitempty"` + + // WillCreate the client has support for sending willCreateFiles requests. + // + // @since 3.16.0 + WillCreate bool `json:"willCreate,omitempty"` + + // DidRename the client has support for sending didRenameFiles notifications. + // + // @since 3.16.0 + DidRename bool `json:"didRename,omitempty"` + + // WillRename the client has support for sending willRenameFiles requests. + // + // @since 3.16.0 + WillRename bool `json:"willRename,omitempty"` + + // DidDelete the client has support for sending didDeleteFiles notifications. + // + // @since 3.16.0 + DidDelete bool `json:"didDelete,omitempty"` + + // WillDelete the client has support for sending willDeleteFiles requests. + // + // @since 3.16.0 + WillDelete bool `json:"willDelete,omitempty"` +} + +// InlineValueWorkspaceClientCapabilities client workspace capabilities specific to inline values. +// +// @since 3.17.0 +type InlineValueWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all inline values currently shown. It should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. + // + // @since 3.17.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// InlayHintWorkspaceClientCapabilities client workspace capabilities specific to inlay hints. +// +// @since 3.17.0 +type InlayHintWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all inlay hints currently shown. It + // should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. + // + // @since 3.17.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// DiagnosticWorkspaceClientCapabilities workspace client capabilities specific to diagnostic pull requests. +// +// @since 3.17.0 +type DiagnosticWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all pulled diagnostics currently shown. It should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. + // + // @since 3.17.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// FoldingRangeWorkspaceClientCapabilities client workspace capabilities specific to folding ranges 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type FoldingRangeWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all folding ranges currently shown. + // It should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. 3.18.0 @proposed. + // @since 3.18.0 proposed + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// WorkspaceClientCapabilities workspace specific client capabilities. +type WorkspaceClientCapabilities struct { + // ApplyEdit the client supports applying batch edits to the workspace by supporting the request 'workspace/applyEdit'. + ApplyEdit bool `json:"applyEdit,omitempty"` + + // WorkspaceEdit capabilities specific to `WorkspaceEdit`s. + WorkspaceEdit *WorkspaceEditClientCapabilities `json:"workspaceEdit,omitempty"` + + // DidChangeConfiguration capabilities specific to the `workspace/didChangeConfiguration` notification. + DidChangeConfiguration *DidChangeConfigurationClientCapabilities `json:"didChangeConfiguration,omitempty"` + + // DidChangeWatchedFiles capabilities specific to the `workspace/didChangeWatchedFiles` notification. + DidChangeWatchedFiles *DidChangeWatchedFilesClientCapabilities `json:"didChangeWatchedFiles,omitempty"` + + // Symbol capabilities specific to the `workspace/symbol` request. + Symbol *WorkspaceSymbolClientCapabilities `json:"symbol,omitempty"` + + // ExecuteCommand capabilities specific to the `workspace/executeCommand` request. + ExecuteCommand *ExecuteCommandClientCapabilities `json:"executeCommand,omitempty"` + + // WorkspaceFolders the client has support for workspace folders. + WorkspaceFolders bool `json:"workspaceFolders,omitempty"` + + // Configuration the client supports `workspace/configuration` requests. + Configuration bool `json:"configuration,omitempty"` + + // SemanticTokens capabilities specific to the semantic token requests scoped to the workspace. + SemanticTokens *SemanticTokensWorkspaceClientCapabilities `json:"semanticTokens,omitempty"` + + // CodeLens capabilities specific to the code lens requests scoped to the workspace. + CodeLens *CodeLensWorkspaceClientCapabilities `json:"codeLens,omitempty"` + + // FileOperations the client has support for file notifications/requests for user operations on files. Since . + FileOperations *FileOperationClientCapabilities `json:"fileOperations,omitempty"` + + // InlineValue capabilities specific to the inline values requests scoped to the workspace. + InlineValue *InlineValueWorkspaceClientCapabilities `json:"inlineValue,omitempty"` + + // InlayHint capabilities specific to the inlay hint requests scoped to the workspace. + InlayHint *InlayHintWorkspaceClientCapabilities `json:"inlayHint,omitempty"` + + // Diagnostics capabilities specific to the diagnostic requests scoped to the workspace. + Diagnostics *DiagnosticWorkspaceClientCapabilities `json:"diagnostics,omitempty"` + + // FoldingRange capabilities specific to the folding range requests scoped to the workspace. 3.18.0 @proposed. + FoldingRange *FoldingRangeWorkspaceClientCapabilities `json:"foldingRange,omitempty"` +} + +type TextDocumentSyncClientCapabilities struct { + // DynamicRegistration whether text document synchronization supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // WillSave the client supports sending will save notifications. + WillSave bool `json:"willSave,omitempty"` + + // WillSaveWaitUntil the client supports sending a will save request and waits for a response providing text edits which will be applied to the document before it is saved. + WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` + + // DidSave the client supports did save notifications. + DidSave bool `json:"didSave,omitempty"` +} + +// CompletionItemTagOptions. +// +// @since 3.18.0 proposed +type CompletionItemTagOptions struct { + // ValueSet the tags supported by the client. + // + // @since 3.18.0 proposed + ValueSet []CompletionItemTag `json:"valueSet"` +} + +// ClientCompletionItemResolveOptions. +// +// @since 3.18.0 proposed +type ClientCompletionItemResolveOptions struct { + // Properties the properties that a client can resolve lazily. + // + // @since 3.18.0 proposed + Properties []string `json:"properties"` +} + +// ClientCompletionItemInsertTextModeOptions. +// +// @since 3.18.0 proposed +type ClientCompletionItemInsertTextModeOptions struct { + // @since 3.18.0 proposed + ValueSet []InsertTextMode `json:"valueSet"` +} + +// ClientCompletionItemOptions. +// +// @since 3.18.0 proposed +type ClientCompletionItemOptions struct { + // SnippetSupport client supports snippets as insert text. A snippet can define tab stops and placeholders with `$1`, `$2` and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Placeholders with equal identifiers are linked, that is typing in one will update others too. + // + // @since 3.18.0 proposed + SnippetSupport bool `json:"snippetSupport,omitempty"` + + // CommitCharactersSupport client supports commit characters on a completion item. + // + // @since 3.18.0 proposed + CommitCharactersSupport bool `json:"commitCharactersSupport,omitempty"` + + // DocumentationFormat client supports the following content formats for the documentation property. The order describes the preferred format of the client. + // + // @since 3.18.0 proposed + DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` + + // DeprecatedSupport client supports the deprecated property on a completion item. + // + // @since 3.18.0 proposed + DeprecatedSupport bool `json:"deprecatedSupport,omitempty"` + + // PreselectSupport client supports the preselect property on a completion item. + // + // @since 3.18.0 proposed + PreselectSupport bool `json:"preselectSupport,omitempty"` + + // TagSupport client supports the tag property on a completion item. Clients supporting tags have to handle unknown tags gracefully. Clients especially need to preserve unknown tags when sending a completion item back to the server in a resolve call. + // @since 3.18.0 proposed + TagSupport *CompletionItemTagOptions `json:"tagSupport,omitempty"` + + // InsertReplaceSupport client support insert replace edit to control different behavior if a completion item is inserted in + // the text or should replace text. + // @since 3.18.0 proposed + InsertReplaceSupport bool `json:"insertReplaceSupport,omitempty"` + + // ResolveSupport indicates which properties a client can resolve lazily on a completion item. Before version 3.16.0 only the predefined properties `documentation` and `details` could be resolved lazily. + // @since 3.18.0 proposed + ResolveSupport *ClientCompletionItemResolveOptions `json:"resolveSupport,omitempty"` + + // InsertTextModeSupport the client supports the `insertTextMode` property on a completion item to override the whitespace handling mode as defined by the client (see `insertTextMode`). + // @since 3.18.0 proposed + InsertTextModeSupport *ClientCompletionItemInsertTextModeOptions `json:"insertTextModeSupport,omitempty"` + + // LabelDetailsSupport the client has support for completion item label details (see also `CompletionItemLabelDetails`). + // @since 3.18.0 proposed + LabelDetailsSupport bool `json:"labelDetailsSupport,omitempty"` +} + +// ClientCompletionItemOptionsKind. +// +// @since 3.18.0 proposed +type ClientCompletionItemOptionsKind struct { + // ValueSet the completion item kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. If this property is not present the client only supports the completion items kinds from `Text` to `Reference` as defined in the initial version of the protocol. + // + // @since 3.18.0 proposed + ValueSet []CompletionItemKind `json:"valueSet,omitempty"` +} + +// CompletionListCapabilities the client supports the following `CompletionList` specific capabilities. +// +// @since 3.17.0 +type CompletionListCapabilities struct { + // ItemDefaults the client supports the following itemDefaults on a completion list. The value lists the supported property names of the `CompletionList.itemDefaults` object. If omitted no properties are supported. + // @since 3.17.0 + ItemDefaults []string `json:"itemDefaults,omitempty"` +} + +// CompletionClientCapabilities completion client capabilities. +type CompletionClientCapabilities struct { + // DynamicRegistration whether completion supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // CompletionItem the client supports the following `CompletionItem` specific capabilities. + CompletionItem *ClientCompletionItemOptions `json:"completionItem,omitempty"` + + CompletionItemKind *ClientCompletionItemOptionsKind `json:"completionItemKind,omitempty"` + + // InsertTextMode defines how the client handles whitespace and indentation when accepting a completion item that uses + // multi line text in either `insertText` or `textEdit`. + InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"` + + // ContextSupport the client supports to send additional context information for a `textDocument/completion` request. + ContextSupport bool `json:"contextSupport,omitempty"` + + // CompletionList the client supports the following `CompletionList` specific capabilities. + CompletionList *CompletionListCapabilities `json:"completionList,omitempty"` +} + +type HoverClientCapabilities struct { + // DynamicRegistration whether hover supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // ContentFormat client supports the following content formats for the content property. The order describes the preferred format of the client. + ContentFormat []MarkupKind `json:"contentFormat,omitempty"` +} + +// ClientSignatureParameterInformationOptions. +// +// @since 3.18.0 proposed +type ClientSignatureParameterInformationOptions struct { + // LabelOffsetSupport the client supports processing label offsets instead of a simple label string. + // @since 3.18.0 proposed + LabelOffsetSupport bool `json:"labelOffsetSupport,omitempty"` +} + +// ClientSignatureInformationOptions. +// +// @since 3.18.0 proposed +type ClientSignatureInformationOptions struct { + // DocumentationFormat client supports the following content formats for the documentation property. The order describes the preferred format of the client. + // + // @since 3.18.0 proposed + DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` + + // ParameterInformation client capabilities specific to parameter information. + // + // @since 3.18.0 proposed + ParameterInformation *ClientSignatureParameterInformationOptions `json:"parameterInformation,omitempty"` + + // ActiveParameterSupport the client supports the `activeParameter` property on `SignatureInformation` literal. + // @since 3.18.0 proposed + ActiveParameterSupport bool `json:"activeParameterSupport,omitempty"` + + // NoActiveParameterSupport the client supports the `activeParameter` property on `SignatureHelp`/`SignatureInformation` being set to `null` to indicate that no parameter should be active. 3.18.0 @proposed. + // @since 3.18.0 proposed + NoActiveParameterSupport bool `json:"noActiveParameterSupport,omitempty"` +} + +// SignatureHelpClientCapabilities client Capabilities for a SignatureHelpRequest. +type SignatureHelpClientCapabilities struct { + // DynamicRegistration whether signature help supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // SignatureInformation the client supports the following `SignatureInformation` specific properties. + SignatureInformation *ClientSignatureInformationOptions `json:"signatureInformation,omitempty"` + + // ContextSupport the client supports to send additional context information for a `textDocument/signatureHelp` request. A client that opts into contextSupport will also support the `retriggerCharacters` on `SignatureHelpOptions`. + ContextSupport bool `json:"contextSupport,omitempty"` +} + +// DeclarationClientCapabilities. +// +// @since 3.14.0 +type DeclarationClientCapabilities struct { + // DynamicRegistration whether declaration supports dynamic registration. If this is set to `true` the client supports the new `DeclarationRegistrationOptions` return value for the corresponding server capability as well. + // + // @since 3.14.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // LinkSupport the client supports additional metadata in the form of declaration links. + // + // @since 3.14.0 + LinkSupport bool `json:"linkSupport,omitempty"` +} + +// DefinitionClientCapabilities client Capabilities for a DefinitionRequest. +type DefinitionClientCapabilities struct { + // DynamicRegistration whether definition supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // LinkSupport the client supports additional metadata in the form of definition links. + LinkSupport bool `json:"linkSupport,omitempty"` +} + +// TypeDefinitionClientCapabilities since . +type TypeDefinitionClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration. If this is set to `true` the client supports the new `TypeDefinitionRegistrationOptions` return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // LinkSupport the client supports additional metadata in the form of definition links. Since . + LinkSupport bool `json:"linkSupport,omitempty"` +} + +// ImplementationClientCapabilities. +// +// @since 3.6.0 +type ImplementationClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration. If this is set to `true` the client supports the new `ImplementationRegistrationOptions` return value for the corresponding server capability as well. + // + // @since 3.6.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // LinkSupport the client supports additional metadata in the form of definition links. + // @since 3.6.0 + LinkSupport bool `json:"linkSupport,omitempty"` +} + +// ReferenceClientCapabilities client Capabilities for a ReferencesRequest. +type ReferenceClientCapabilities struct { + // DynamicRegistration whether references supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// DocumentHighlightClientCapabilities client Capabilities for a DocumentHighlightRequest. +type DocumentHighlightClientCapabilities struct { + // DynamicRegistration whether document highlight supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// DocumentSymbolClientCapabilities client Capabilities for a DocumentSymbolRequest. +type DocumentSymbolClientCapabilities struct { + // DynamicRegistration whether document symbol supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // SymbolKind specific capabilities for the `SymbolKind` in the `textDocument/documentSymbol` request. + SymbolKind *ClientSymbolKindOptions `json:"symbolKind,omitempty"` + + // HierarchicalDocumentSymbolSupport the client supports hierarchical document symbols. + HierarchicalDocumentSymbolSupport bool `json:"hierarchicalDocumentSymbolSupport,omitempty"` + + // TagSupport the client supports tags on `SymbolInformation`. Tags are supported on `DocumentSymbol` if `hierarchicalDocumentSymbolSupport` is set to true. Clients supporting tags have to handle unknown tags gracefully. + TagSupport *ClientSymbolTagOptions `json:"tagSupport,omitempty"` + + // LabelSupport the client supports an additional label presented in the UI when registering a document symbol provider. + LabelSupport bool `json:"labelSupport,omitempty"` +} + +// ClientCodeActionKindOptions. +// +// @since 3.18.0 proposed +type ClientCodeActionKindOptions struct { + // ValueSet the code action kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. + // + // @since 3.18.0 proposed + ValueSet []CodeActionKind `json:"valueSet"` +} + +// ClientCodeActionLiteralOptions. +// +// @since 3.18.0 proposed +type ClientCodeActionLiteralOptions struct { + // CodeActionKind the code action kind is support with the following value set. + // + // @since 3.18.0 proposed + CodeActionKind ClientCodeActionKindOptions `json:"codeActionKind"` +} + +// ClientCodeActionResolveOptions. +// +// @since 3.18.0 proposed +type ClientCodeActionResolveOptions struct { + // Properties the properties that a client can resolve lazily. + // + // @since 3.18.0 proposed + Properties []string `json:"properties"` +} + +// CodeActionClientCapabilities the Client Capabilities of a CodeActionRequest. +type CodeActionClientCapabilities struct { + // DynamicRegistration whether code action supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // CodeActionLiteralSupport the client support code action literals of type `CodeAction` as a valid response of the `textDocument/codeAction` request. If the property is not set the request can only return `Command` literals. + CodeActionLiteralSupport *ClientCodeActionLiteralOptions `json:"codeActionLiteralSupport,omitempty"` + + // IsPreferredSupport whether code action supports the `isPreferred` property. + IsPreferredSupport bool `json:"isPreferredSupport,omitempty"` + + // DisabledSupport whether code action supports the `disabled` property. + DisabledSupport bool `json:"disabledSupport,omitempty"` + + // DataSupport whether code action supports the `data` property which is preserved between a `textDocument/codeAction` and a `codeAction/resolve` request. + DataSupport bool `json:"dataSupport,omitempty"` + + // ResolveSupport whether the client supports resolving additional code action properties via a separate `codeAction/resolve` request. + ResolveSupport *ClientCodeActionResolveOptions `json:"resolveSupport,omitempty"` + + // HonorsChangeAnnotations whether the client honors the change annotations in text edits and resource operations returned via the `CodeAction#edit` property by for example presenting the workspace edit in the user interface and asking for confirmation. + HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitempty"` + + // DocumentationSupport whether the client supports documentation for a class of code actions. 3.18.0 @proposed. + DocumentationSupport bool `json:"documentationSupport,omitempty"` +} + +// CodeLensClientCapabilities the client capabilities of a CodeLensRequest. +type CodeLensClientCapabilities struct { + // DynamicRegistration whether code lens supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// DocumentLinkClientCapabilities the client capabilities of a DocumentLinkRequest. +type DocumentLinkClientCapabilities struct { + // DynamicRegistration whether document link supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // TooltipSupport whether the client supports the `tooltip` property on `DocumentLink`. + TooltipSupport bool `json:"tooltipSupport,omitempty"` +} + +type DocumentColorClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration. If this is set to `true` the client supports the new `DocumentColorRegistrationOptions` return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// DocumentFormattingClientCapabilities client capabilities of a DocumentFormattingRequest. +type DocumentFormattingClientCapabilities struct { + // DynamicRegistration whether formatting supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// DocumentRangeFormattingClientCapabilities client capabilities of a DocumentRangeFormattingRequest. +type DocumentRangeFormattingClientCapabilities struct { + // DynamicRegistration whether range formatting supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // RangesSupport whether the client supports formatting multiple ranges at once. 3.18.0 @proposed. + RangesSupport bool `json:"rangesSupport,omitempty"` +} + +// DocumentOnTypeFormattingClientCapabilities client capabilities of a DocumentOnTypeFormattingRequest. +type DocumentOnTypeFormattingClientCapabilities struct { + // DynamicRegistration whether on type formatting supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +type RenameClientCapabilities struct { + // DynamicRegistration whether rename supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // PrepareSupport client supports testing for validity of rename operations before execution. + PrepareSupport bool `json:"prepareSupport,omitempty"` + + // PrepareSupportDefaultBehavior client supports the default behavior result. The value indicates the default behavior used by the client. + PrepareSupportDefaultBehavior PrepareSupportDefaultBehavior `json:"prepareSupportDefaultBehavior,omitempty"` + + // HonorsChangeAnnotations whether the client honors the change annotations in text edits and resource operations returned via the rename request's workspace edit by for example presenting the workspace edit in the user interface and asking for confirmation. + HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitempty"` +} + +// ClientFoldingRangeKindOptions. +// +// @since 3.18.0 proposed +type ClientFoldingRangeKindOptions struct { + // ValueSet the folding range kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. + // + // @since 3.18.0 proposed + ValueSet []FoldingRangeKind `json:"valueSet,omitempty"` +} + +// ClientFoldingRangeOptions. +// +// @since 3.18.0 proposed +type ClientFoldingRangeOptions struct { + // CollapsedText if set, the client signals that it supports setting collapsedText on folding ranges to display custom labels instead of the default text. + // @since 3.18.0 proposed + CollapsedText bool `json:"collapsedText,omitempty"` +} + +type FoldingRangeClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration for folding range providers. If this is set to `true` the client supports the new `FoldingRangeRegistrationOptions` return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // RangeLimit the maximum number of folding ranges that the client prefers to receive per document. The value serves as a hint, servers are free to follow the limit. + RangeLimit uint32 `json:"rangeLimit,omitempty"` + + // LineFoldingOnly if set, the client signals that it only supports folding complete lines. If set, client will ignore specified `startCharacter` and `endCharacter` properties in a FoldingRange. + LineFoldingOnly bool `json:"lineFoldingOnly,omitempty"` + + // FoldingRangeKind specific options for the folding range kind. + FoldingRangeKind *ClientFoldingRangeKindOptions `json:"foldingRangeKind,omitempty"` + + // FoldingRange specific options for the folding range. + FoldingRange *ClientFoldingRangeOptions `json:"foldingRange,omitempty"` +} + +type SelectionRangeClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration for selection range providers. If this is set to `true` the client supports the new `SelectionRangeRegistrationOptions` return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// ClientDiagnosticsTagOptions. +// +// @since 3.18.0 proposed +type ClientDiagnosticsTagOptions struct { + // ValueSet the tags supported by the client. + // + // @since 3.18.0 proposed + ValueSet []DiagnosticTag `json:"valueSet"` +} + +// PublishDiagnosticsClientCapabilities the publish diagnostic client capabilities. +type PublishDiagnosticsClientCapabilities struct { + // RelatedInformation whether the clients accepts diagnostics with related information. + RelatedInformation bool `json:"relatedInformation,omitempty"` + + // TagSupport client supports the tag property to provide meta data about a diagnostic. Clients supporting tags have to handle unknown tags gracefully. + TagSupport *ClientDiagnosticsTagOptions `json:"tagSupport,omitempty"` + + // VersionSupport whether the client interprets the version property of the `textDocument/publishDiagnostics` notification's parameter. + VersionSupport bool `json:"versionSupport,omitempty"` + + // CodeDescriptionSupport client supports a codeDescription property + CodeDescriptionSupport bool `json:"codeDescriptionSupport,omitempty"` + + // DataSupport whether code action supports the `data` property which is preserved between a `textDocument/publishDiagnostics` and `textDocument/codeAction` request. + DataSupport bool `json:"dataSupport,omitempty"` +} + +// CallHierarchyClientCapabilities. +// +// @since 3.16.0 +type CallHierarchyClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// ClientSemanticTokensRequestFullDelta. +// +// @since 3.18.0 proposed +type ClientSemanticTokensRequestFullDelta struct { + // Delta the client will send the `textDocument/semanticTokens/full/delta` request if the server provides a corresponding handler. + // + // @since 3.18.0 proposed + Delta bool `json:"delta,omitempty"` +} + +// ClientSemanticTokensRequestOptions. +// +// @since 3.18.0 proposed +type ClientSemanticTokensRequestOptions struct { + // Range the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. + // + // @since 3.18.0 proposed + Range ClientSemanticTokensRequestOptionsRange `json:"range,omitempty"` + + // Full the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. + // + // @since 3.18.0 proposed + Full ClientSemanticTokensRequestOptionsFull `json:"full,omitempty"` +} + +// SemanticTokensClientCapabilities. +// +// @since 3.16.0 +type SemanticTokensClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // Requests which requests the client supports and might send to the server depending on the server's capability. Please note that clients might not show semantic tokens or degrade some of the user experience if a range or full request is advertised by the client but not provided by the server. If for example the client capability `requests.full` and `request.range` are both set to true but the server only provides a range provider the client might not render a minimap correctly or might even decide to not show any semantic tokens at all. + // + // @since 3.16.0 + Requests ClientSemanticTokensRequestOptions `json:"requests"` + + // TokenTypes the token types that the client supports. + // + // @since 3.16.0 + TokenTypes []string `json:"tokenTypes"` + + // TokenModifiers the token modifiers that the client supports. + // + // @since 3.16.0 + TokenModifiers []string `json:"tokenModifiers"` + + // Formats the token formats the clients supports. + // + // @since 3.16.0 + Formats []TokenFormat `json:"formats"` + + // OverlappingTokenSupport whether the client supports tokens that can overlap each other. + // + // @since 3.16.0 + OverlappingTokenSupport bool `json:"overlappingTokenSupport,omitempty"` + + // MultilineTokenSupport whether the client supports tokens that can span multiple lines. + // + // @since 3.16.0 + MultilineTokenSupport bool `json:"multilineTokenSupport,omitempty"` + + // ServerCancelSupport whether the client allows the server to actively cancel a semantic token request, e.g. supports returning LSPErrorCodes.ServerCancelled. If a server does the client needs to retrigger the request. + // @since 3.16.0 + ServerCancelSupport bool `json:"serverCancelSupport,omitempty"` + + // AugmentsSyntaxTokens whether the client uses semantic tokens to augment existing syntax tokens. If set to `true` client side created syntax tokens and semantic tokens are both used for colorization. If set to `false` the client only uses the returned semantic tokens for colorization. If the value is `undefined` then the + // client behavior is not specified. + // @since 3.16.0 + AugmentsSyntaxTokens bool `json:"augmentsSyntaxTokens,omitempty"` +} + +// LinkedEditingRangeClientCapabilities client capabilities for the linked editing range request. +// +// @since 3.16.0 +type LinkedEditingRangeClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// MonikerClientCapabilities client capabilities specific to the moniker request. +// +// @since 3.16.0 +type MonikerClientCapabilities struct { + // DynamicRegistration whether moniker supports dynamic registration. If this is set to `true` the client supports the new `MonikerRegistrationOptions` return value for the corresponding server capability as well. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// TypeHierarchyClientCapabilities. +// +// @since 3.17.0 +type TypeHierarchyClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// InlineValueClientCapabilities client capabilities specific to inline values. +// +// @since 3.17.0 +type InlineValueClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration for inline value providers. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// ClientInlayHintResolveOptions. +// +// @since 3.18.0 proposed +type ClientInlayHintResolveOptions struct { + // Properties the properties that a client can resolve lazily. + // + // @since 3.18.0 proposed + Properties []string `json:"properties"` +} + +// InlayHintClientCapabilities inlay hint client capabilities. +// +// @since 3.17.0 +type InlayHintClientCapabilities struct { + // DynamicRegistration whether inlay hints support dynamic registration. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // ResolveSupport indicates which properties a client can resolve lazily on an inlay hint. + // + // @since 3.17.0 + ResolveSupport *ClientInlayHintResolveOptions `json:"resolveSupport,omitempty"` +} + +// DiagnosticClientCapabilities client capabilities specific to diagnostic pull requests. +// +// @since 3.17.0 +type DiagnosticClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // RelatedDocumentSupport whether the clients supports related documents for document diagnostic pulls. + // + // @since 3.17.0 + RelatedDocumentSupport bool `json:"relatedDocumentSupport,omitempty"` +} + +// InlineCompletionClientCapabilities client capabilities specific to inline completions. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration for inline completion providers. + // + // @since 3.18.0 proposed + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// TextDocumentClientCapabilities text document specific client capabilities. +type TextDocumentClientCapabilities struct { + // Synchronization defines which synchronization capabilities the client supports. + Synchronization *TextDocumentSyncClientCapabilities `json:"synchronization,omitempty"` + + // Completion capabilities specific to the `textDocument/completion` request. + Completion *CompletionClientCapabilities `json:"completion,omitempty"` + + // Hover capabilities specific to the `textDocument/hover` request. + Hover *HoverClientCapabilities `json:"hover,omitempty"` + + // SignatureHelp capabilities specific to the `textDocument/signatureHelp` request. + SignatureHelp *SignatureHelpClientCapabilities `json:"signatureHelp,omitempty"` + + // Declaration capabilities specific to the `textDocument/declaration` request. + Declaration *DeclarationClientCapabilities `json:"declaration,omitempty"` + + // Definition capabilities specific to the `textDocument/definition` request. + Definition *DefinitionClientCapabilities `json:"definition,omitempty"` + + // TypeDefinition capabilities specific to the `textDocument/typeDefinition` request. + TypeDefinition *TypeDefinitionClientCapabilities `json:"typeDefinition,omitempty"` + + // Implementation capabilities specific to the `textDocument/implementation` request. + Implementation *ImplementationClientCapabilities `json:"implementation,omitempty"` + + // References capabilities specific to the `textDocument/references` request. + References *ReferenceClientCapabilities `json:"references,omitempty"` + + // DocumentHighlight capabilities specific to the `textDocument/documentHighlight` request. + DocumentHighlight *DocumentHighlightClientCapabilities `json:"documentHighlight,omitempty"` + + // DocumentSymbol capabilities specific to the `textDocument/documentSymbol` request. + DocumentSymbol *DocumentSymbolClientCapabilities `json:"documentSymbol,omitempty"` + + // CodeAction capabilities specific to the `textDocument/codeAction` request. + CodeAction *CodeActionClientCapabilities `json:"codeAction,omitempty"` + + // CodeLens capabilities specific to the `textDocument/codeLens` request. + CodeLens *CodeLensClientCapabilities `json:"codeLens,omitempty"` + + // DocumentLink capabilities specific to the `textDocument/documentLink` request. + DocumentLink *DocumentLinkClientCapabilities `json:"documentLink,omitempty"` + + // ColorProvider capabilities specific to the `textDocument/documentColor` and the `textDocument/colorPresentation` request. + ColorProvider *DocumentColorClientCapabilities `json:"colorProvider,omitempty"` + + // Formatting capabilities specific to the `textDocument/formatting` request. + Formatting *DocumentFormattingClientCapabilities `json:"formatting,omitempty"` + + // RangeFormatting capabilities specific to the `textDocument/rangeFormatting` request. + RangeFormatting *DocumentRangeFormattingClientCapabilities `json:"rangeFormatting,omitempty"` + + // OnTypeFormatting capabilities specific to the `textDocument/onTypeFormatting` request. + OnTypeFormatting *DocumentOnTypeFormattingClientCapabilities `json:"onTypeFormatting,omitempty"` + + // Rename capabilities specific to the `textDocument/rename` request. + Rename *RenameClientCapabilities `json:"rename,omitempty"` + + // FoldingRange capabilities specific to the `textDocument/foldingRange` request. + FoldingRange *FoldingRangeClientCapabilities `json:"foldingRange,omitempty"` + + // SelectionRange capabilities specific to the `textDocument/selectionRange` request. + SelectionRange *SelectionRangeClientCapabilities `json:"selectionRange,omitempty"` + + // PublishDiagnostics capabilities specific to the `textDocument/publishDiagnostics` notification. + PublishDiagnostics *PublishDiagnosticsClientCapabilities `json:"publishDiagnostics,omitempty"` + + // CallHierarchy capabilities specific to the various call hierarchy requests. + CallHierarchy *CallHierarchyClientCapabilities `json:"callHierarchy,omitempty"` + + // SemanticTokens capabilities specific to the various semantic token request. + SemanticTokens *SemanticTokensClientCapabilities `json:"semanticTokens,omitempty"` + + // LinkedEditingRange capabilities specific to the `textDocument/linkedEditingRange` request. + LinkedEditingRange *LinkedEditingRangeClientCapabilities `json:"linkedEditingRange,omitempty"` + + // Moniker client capabilities specific to the `textDocument/moniker` request. + Moniker *MonikerClientCapabilities `json:"moniker,omitempty"` + + // TypeHierarchy capabilities specific to the various type hierarchy requests. + TypeHierarchy *TypeHierarchyClientCapabilities `json:"typeHierarchy,omitempty"` + + // InlineValue capabilities specific to the `textDocument/inlineValue` request. + InlineValue *InlineValueClientCapabilities `json:"inlineValue,omitempty"` + + // InlayHint capabilities specific to the `textDocument/inlayHint` request. + InlayHint *InlayHintClientCapabilities `json:"inlayHint,omitempty"` + + // Diagnostic capabilities specific to the diagnostic pull model. + Diagnostic *DiagnosticClientCapabilities `json:"diagnostic,omitempty"` + + // InlineCompletion client capabilities specific to inline completions. 3.18.0 @proposed. + InlineCompletion *InlineCompletionClientCapabilities `json:"inlineCompletion,omitempty"` +} + +// NotebookDocumentSyncClientCapabilities notebook specific client capabilities. +// +// @since 3.17.0 +type NotebookDocumentSyncClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // ExecutionSummarySupport the client supports sending execution summary data per cell. + // + // @since 3.17.0 + ExecutionSummarySupport bool `json:"executionSummarySupport,omitempty"` +} + +// NotebookDocumentClientCapabilities capabilities specific to the notebook document support. +// +// @since 3.17.0 +type NotebookDocumentClientCapabilities struct { + // Synchronization capabilities specific to notebook document synchronization + // @since 3.17.0 + Synchronization NotebookDocumentSyncClientCapabilities `json:"synchronization"` +} + +// ClientShowMessageActionItemOptions. +// +// @since 3.18.0 proposed +type ClientShowMessageActionItemOptions struct { + // AdditionalPropertiesSupport whether the client supports additional attributes which are preserved and send back to the server in + // the request's response. + // + // @since 3.18.0 proposed + AdditionalPropertiesSupport bool `json:"additionalPropertiesSupport,omitempty"` +} + +// ShowMessageRequestClientCapabilities show message request client capabilities. +type ShowMessageRequestClientCapabilities struct { + // MessageActionItem capabilities specific to the `MessageActionItem` type. + MessageActionItem *ClientShowMessageActionItemOptions `json:"messageActionItem,omitempty"` +} + +// ShowDocumentClientCapabilities client capabilities for the showDocument request. +// +// @since 3.16.0 +type ShowDocumentClientCapabilities struct { + // Support the client has support for the showDocument request. + // + // @since 3.16.0 + Support bool `json:"support"` +} + +type WindowClientCapabilities struct { + // WorkDoneProgress it indicates whether the client supports server initiated progress using the `window/workDoneProgress/create` request. The capability also controls Whether client supports handling of progress notifications. If set servers are allowed to report a `workDoneProgress` property in the request specific server capabilities. + WorkDoneProgress bool `json:"workDoneProgress,omitempty"` + + // ShowMessage capabilities specific to the showMessage request. + ShowMessage *ShowMessageRequestClientCapabilities `json:"showMessage,omitempty"` + + // ShowDocument capabilities specific to the showDocument request. + ShowDocument *ShowDocumentClientCapabilities `json:"showDocument,omitempty"` +} + +// StaleRequestSupportOptions. +// +// @since 3.18.0 proposed +type StaleRequestSupportOptions struct { + // Cancel the client will actively cancel the request. + // + // @since 3.18.0 proposed + Cancel bool `json:"cancel"` + + // RetryOnContentModified the list of requests for which the client will retry the request if it receives a response with error code `ContentModified`. + // + // @since 3.18.0 proposed + RetryOnContentModified []string `json:"retryOnContentModified"` +} + +// RegularExpressionsClientCapabilities client capabilities specific to regular expressions. +// +// @since 3.16.0 +type RegularExpressionsClientCapabilities struct { + // Engine the engine's name. + // + // @since 3.16.0 + Engine RegularExpressionEngineKind `json:"engine"` + + // Version the engine's version. + // + // @since 3.16.0 + Version string `json:"version,omitempty"` +} + +// MarkdownClientCapabilities client capabilities specific to the used markdown parser. +// +// @since 3.16.0 +type MarkdownClientCapabilities struct { + // Parser the name of the parser. + // + // @since 3.16.0 + Parser string `json:"parser"` + + // Version the version of the parser. + // + // @since 3.16.0 + Version string `json:"version,omitempty"` + + // AllowedTags a list of HTML tags that the client allows / supports in Markdown. + // @since 3.16.0 + AllowedTags []string `json:"allowedTags,omitempty"` +} + +// GeneralClientCapabilities general client capabilities. +// +// @since 3.16.0 +type GeneralClientCapabilities struct { + // StaleRequestSupport client capability that signals how the client handles stale requests (e.g. a request for which the client will not process the response anymore since the information is outdated). + // @since 3.16.0 + StaleRequestSupport *StaleRequestSupportOptions `json:"staleRequestSupport,omitempty"` + + // RegularExpressions client capabilities specific to regular expressions. + // @since 3.16.0 + RegularExpressions *RegularExpressionsClientCapabilities `json:"regularExpressions,omitempty"` + + // Markdown client capabilities specific to the client's markdown parser. + // @since 3.16.0 + Markdown *MarkdownClientCapabilities `json:"markdown,omitempty"` + + // PositionEncodings the position encodings supported by the client. Client and server have to agree on the same position + // encoding to ensure that offsets (e.g. character position in a line) are interpreted the same on both sides. To keep the protocol backwards compatible the following applies: if the value 'utf-16' + // is missing from the array of position encodings servers can assume that the client supports UTF-16. UTF-16 is therefore a mandatory encoding. If omitted it defaults to ['utf-16']. Implementation + // considerations: since the conversion from one encoding into another requires the content of the file / line the conversion is best done where the file is read which is usually on the server side. + // @since 3.16.0 + PositionEncodings []PositionEncodingKind `json:"positionEncodings,omitempty"` +} + +// ClientCapabilities defines the capabilities provided by the client. +type ClientCapabilities struct { + // Workspace workspace specific client capabilities. + Workspace *WorkspaceClientCapabilities `json:"workspace,omitempty"` + + // TextDocument text document specific client capabilities. + TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"` + + // NotebookDocument capabilities specific to the notebook document support. + NotebookDocument *NotebookDocumentClientCapabilities `json:"notebookDocument,omitempty"` + + // Window window specific client capabilities. + Window *WindowClientCapabilities `json:"window,omitempty"` + + // General general client capabilities. + General *GeneralClientCapabilities `json:"general,omitempty"` + + // Experimental experimental client capabilities. + Experimental any `json:"experimental,omitempty"` +} + +// InitializeParamsBase the initialize parameters. +type InitializeParamsBase struct { + // mixins + WorkDoneProgressParams + + // ProcessID the process Id of the parent process that started the server. Is `null` if the process has not been started by another process. If the parent process is not alive then the server should exit. + ProcessID int32 `json:"processId,omitempty"` + + // ClientInfo information about the client + ClientInfo *ClientInfo `json:"clientInfo,omitempty"` + + // Locale the locale the client is currently showing the user interface in. This must not necessarily be the locale of the operating system. Uses IETF language tags as the value's syntax (See https://en.wikipedia.org/wiki/IETF_language_tag) + Locale string `json:"locale,omitempty"` + + // RootPath the rootPath of the workspace. Is null if no folder is open. // // Deprecated: in favour of rootUri. + RootPath string `json:"rootPath,omitempty"` + + // RootURI the rootUri of the workspace. Is null if no folder is open. If both `rootPath` and `rootUri` are set + // `rootUri` wins. // // Deprecated: in favour of workspaceFolders. + RootURI DocumentURI `json:"rootUri,omitempty"` + + // Capabilities the capabilities provided by the client (editor or tool). + Capabilities ClientCapabilities `json:"capabilities"` + + // InitializationOptions user provided initialization options. + InitializationOptions any `json:"initializationOptions,omitempty"` + + // Trace the initial trace setting. If omitted trace is disabled ('off'). + Trace TraceValue `json:"trace,omitempty"` +} + +type WorkspaceFoldersInitializeParams struct { + // WorkspaceFolders the workspace folders configured in the client when the server starts. This property is only available if the client supports workspace folders. It can be `null` if the client supports workspace folders but none are configured. + WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders,omitempty"` +} + +type InitializeParams struct { + // extends + InitializeParamsBase + WorkspaceFoldersInitializeParams +} + +// FileOperationOptions options for notifications/requests for user operations on files. +// +// @since 3.16.0 +type FileOperationOptions struct { + // DidCreate the server is interested in receiving didCreateFiles notifications. + // + // @since 3.16.0 + DidCreate *FileOperationRegistrationOptions `json:"didCreate,omitempty"` + + // WillCreate the server is interested in receiving willCreateFiles requests. + // + // @since 3.16.0 + WillCreate *FileOperationRegistrationOptions `json:"willCreate,omitempty"` + + // DidRename the server is interested in receiving didRenameFiles notifications. + // + // @since 3.16.0 + DidRename *FileOperationRegistrationOptions `json:"didRename,omitempty"` + + // WillRename the server is interested in receiving willRenameFiles requests. + // + // @since 3.16.0 + WillRename *FileOperationRegistrationOptions `json:"willRename,omitempty"` + + // DidDelete the server is interested in receiving didDeleteFiles file notifications. + // + // @since 3.16.0 + DidDelete *FileOperationRegistrationOptions `json:"didDelete,omitempty"` + + // WillDelete the server is interested in receiving willDeleteFiles file requests. + // + // @since 3.16.0 + WillDelete *FileOperationRegistrationOptions `json:"willDelete,omitempty"` +} + +// WorkspaceOptions defines workspace specific capabilities of the server. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type WorkspaceOptions struct { + // WorkspaceFolders the server supports workspace folder. + // @since 3.18.0 proposed + WorkspaceFolders *WorkspaceFoldersServerCapabilities `json:"workspaceFolders,omitempty"` + + // FileOperations the server is interested in notifications/requests for operations on files. + // @since 3.18.0 proposed + FileOperations *FileOperationOptions `json:"fileOperations,omitempty"` +} + +// ServerCapabilities defines the capabilities provided by a language server. +type ServerCapabilities struct { + // PositionEncoding the position encoding the server picked from the encodings offered by the client via the client capability `general.positionEncodings`. If the client didn't provide any position encodings the only valid value that a server can return is 'utf-16'. If omitted it defaults to 'utf-16'. + PositionEncoding PositionEncodingKind `json:"positionEncoding,omitempty"` + + // TextDocumentSync defines how text documents are synced. Is either a detailed structure defining each notification or for backwards compatibility the TextDocumentSyncKind number. + TextDocumentSync ServerCapabilitiesTextDocumentSync `json:"textDocumentSync,omitempty"` + + // NotebookDocumentSync defines how notebook documents are synced. + NotebookDocumentSync ServerCapabilitiesNotebookDocumentSync `json:"notebookDocumentSync,omitempty"` + + // CompletionProvider the server provides completion support. + CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"` + + // HoverProvider the server provides hover support. + HoverProvider ServerCapabilitiesHoverProvider `json:"hoverProvider,omitempty"` + + // SignatureHelpProvider the server provides signature help support. + SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` + + // DeclarationProvider the server provides Goto Declaration support. + DeclarationProvider ServerCapabilitiesDeclarationProvider `json:"declarationProvider,omitempty"` + + // DefinitionProvider the server provides goto definition support. + DefinitionProvider ServerCapabilitiesDefinitionProvider `json:"definitionProvider,omitempty"` + + // TypeDefinitionProvider the server provides Goto Type Definition support. + TypeDefinitionProvider ServerCapabilitiesTypeDefinitionProvider `json:"typeDefinitionProvider,omitempty"` + + // ImplementationProvider the server provides Goto Implementation support. + ImplementationProvider ServerCapabilitiesImplementationProvider `json:"implementationProvider,omitempty"` + + // ReferencesProvider the server provides find references support. + ReferencesProvider ServerCapabilitiesReferencesProvider `json:"referencesProvider,omitempty"` + + // DocumentHighlightProvider the server provides document highlight support. + DocumentHighlightProvider ServerCapabilitiesDocumentHighlightProvider `json:"documentHighlightProvider,omitempty"` + + // DocumentSymbolProvider the server provides document symbol support. + DocumentSymbolProvider ServerCapabilitiesDocumentSymbolProvider `json:"documentSymbolProvider,omitempty"` + + // CodeActionProvider the server provides code actions. CodeActionOptions may only be specified if the client states that it supports `codeActionLiteralSupport` in its initial `initialize` request. + CodeActionProvider ServerCapabilitiesCodeActionProvider `json:"codeActionProvider,omitempty"` + + // CodeLensProvider the server provides code lens. + CodeLensProvider *CodeLensOptions `json:"codeLensProvider,omitempty"` + + // DocumentLinkProvider the server provides document link support. + DocumentLinkProvider *DocumentLinkOptions `json:"documentLinkProvider,omitempty"` + + // ColorProvider the server provides color provider support. + ColorProvider ServerCapabilitiesColorProvider `json:"colorProvider,omitempty"` + + // WorkspaceSymbolProvider the server provides workspace symbol support. + WorkspaceSymbolProvider ServerCapabilitiesWorkspaceSymbolProvider `json:"workspaceSymbolProvider,omitempty"` + + // DocumentFormattingProvider the server provides document formatting. + DocumentFormattingProvider ServerCapabilitiesDocumentFormattingProvider `json:"documentFormattingProvider,omitempty"` + + // DocumentRangeFormattingProvider the server provides document range formatting. + DocumentRangeFormattingProvider ServerCapabilitiesDocumentRangeFormattingProvider `json:"documentRangeFormattingProvider,omitempty"` + + // DocumentOnTypeFormattingProvider the server provides document formatting on typing. + DocumentOnTypeFormattingProvider *DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"` + + // RenameProvider the server provides rename support. RenameOptions may only be specified if the client states that it + // supports `prepareSupport` in its initial `initialize` request. + RenameProvider ServerCapabilitiesRenameProvider `json:"renameProvider,omitempty"` + + // FoldingRangeProvider the server provides folding provider support. + FoldingRangeProvider ServerCapabilitiesFoldingRangeProvider `json:"foldingRangeProvider,omitempty"` + + // SelectionRangeProvider the server provides selection range support. + SelectionRangeProvider ServerCapabilitiesSelectionRangeProvider `json:"selectionRangeProvider,omitempty"` + + // ExecuteCommandProvider the server provides execute command support. + ExecuteCommandProvider *ExecuteCommandOptions `json:"executeCommandProvider,omitempty"` + + // CallHierarchyProvider the server provides call hierarchy support. + CallHierarchyProvider ServerCapabilitiesCallHierarchyProvider `json:"callHierarchyProvider,omitempty"` + + // LinkedEditingRangeProvider the server provides linked editing range support. + LinkedEditingRangeProvider ServerCapabilitiesLinkedEditingRangeProvider `json:"linkedEditingRangeProvider,omitempty"` + + // SemanticTokensProvider the server provides semantic tokens support. + SemanticTokensProvider ServerCapabilitiesSemanticTokensProvider `json:"semanticTokensProvider,omitempty"` + + // MonikerProvider the server provides moniker support. + MonikerProvider ServerCapabilitiesMonikerProvider `json:"monikerProvider,omitempty"` + + // TypeHierarchyProvider the server provides type hierarchy support. + TypeHierarchyProvider ServerCapabilitiesTypeHierarchyProvider `json:"typeHierarchyProvider,omitempty"` + + // InlineValueProvider the server provides inline values. + InlineValueProvider ServerCapabilitiesInlineValueProvider `json:"inlineValueProvider,omitempty"` + + // InlayHintProvider the server provides inlay hints. + InlayHintProvider ServerCapabilitiesInlayHintProvider `json:"inlayHintProvider,omitempty"` + + // DiagnosticProvider the server has support for pull model diagnostics. + DiagnosticProvider ServerCapabilitiesDiagnosticProvider `json:"diagnosticProvider,omitempty"` + + // InlineCompletionProvider inline completion options used during static registration. 3.18.0 @proposed. + InlineCompletionProvider ServerCapabilitiesInlineCompletionProvider `json:"inlineCompletionProvider,omitempty"` + + // Workspace workspace specific server capabilities. + Workspace *WorkspaceOptions `json:"workspace,omitempty"` + + // Experimental experimental server capabilities. + Experimental any `json:"experimental,omitempty"` +} + +// ServerInfo information about the server 3.15.0 3.18.0 ServerInfo type name added. @proposed. +// +// @since 3.18.0 ServerInfo type name added. proposed +type ServerInfo struct { + // Name the name of the server as defined by the server. + // + // @since 3.18.0 ServerInfo type name added. proposed + Name string `json:"name"` + + // Version the server's version as defined by the server. + // + // @since 3.18.0 ServerInfo type name added. proposed + Version string `json:"version,omitempty"` +} + +// InitializeResult the result returned from an initialize request. +type InitializeResult struct { + // Capabilities the capabilities the language server provides. + Capabilities ServerCapabilities `json:"capabilities"` + + // ServerInfo information about the server. + ServerInfo *ServerInfo `json:"serverInfo,omitempty"` +} + +// InitializeError the data type of the ResponseError if the initialize request fails. +type InitializeError struct { + // Retry indicates whether the client execute the following retry logic: (1) show the message provided by the + // ResponseError to the user (2) user selects retry or cancel (3) if user selected retry the initialize method is sent again. + Retry bool `json:"retry"` +} + +type InitializedParams struct{} + +type SetTraceParams struct { + Value TraceValue `json:"value"` +} + +type LogTraceParams struct { + Message string `json:"message"` + + Verbose string `json:"verbose,omitempty"` +} + +// StaticRegistrationOptions static registration options to be returned in the initialize request. +type StaticRegistrationOptions struct { + // ID the id used to register the request. The id can be used to deregister the request again. See also Registration#id. + ID string `json:"id,omitempty"` +} diff --git a/protocol/protocol.go b/protocol/protocol.go new file mode 100644 index 00000000..236a0497 --- /dev/null +++ b/protocol/protocol.go @@ -0,0 +1,109 @@ +// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "context" + "encoding/json" + "io" + + "go.uber.org/zap" + + "go.lsp.dev/jsonrpc2" +) + +// MarshalFunc function type of marshal JSON data. +// +// Default is used [json.Marshal]. +type MarshalFunc func(v any) ([]byte, error) + +var marshal MarshalFunc = json.Marshal + +func RegiserMarshaler(fn MarshalFunc) { + marshal = fn +} + +// UnmarshalFunc function type of unmarshal JSON data. +// +// Default is used [json.Unmarshal]. +type UnmarshalFunc func(data []byte, v any) error + +var unmarshal UnmarshalFunc = json.Unmarshal + +func RegiserUnmarshaler(fn UnmarshalFunc) { + unmarshal = fn +} + +// JSONEncoder encodes and writes to the underlying data stream. +type JSONEncoder interface { + Encode(any) error +} + +// EncoderFunc function type of JSONEncoder. +// +// Default is used [json.NewEncoder] with SetEscapeHTML to false. +type EncoderFunc func(io.Writer) JSONEncoder + +var newEncoder EncoderFunc = defaultEncoder + +func defaultEncoder(w io.Writer) JSONEncoder { + enc := json.NewEncoder(w) + enc.SetEscapeHTML(false) + return enc +} + +func RegiserEncoder(fn EncoderFunc) { + newEncoder = fn +} + +// JSONDecoder decodes and reads to the underlying data stream. +type JSONDecoder interface { + Decode(v any) error +} + +// DecoderFunc function type of JSONDecoder. +// +// Default is used [json.NewDecoder]. +type DecoderFunc func(io.Reader) JSONDecoder + +var newDecoder DecoderFunc = defaultDecoder + +func defaultDecoder(r io.Reader) JSONDecoder { + dec := json.NewDecoder(r) + return dec +} + +func RegiserDecoder(fn DecoderFunc) { + newDecoder = fn +} + +// NewServer returns the context in which client is embedded, jsonrpc2.Conn, and the Client. +func NewServer(ctx context.Context, server Server, stream jsonrpc2.Stream, logger *zap.Logger) (context.Context, jsonrpc2.Conn, Client) { + conn := jsonrpc2.NewConn(stream) + cliint := ClientDispatcher(conn, logger.Named("client")) + ctx = WithClient(ctx, cliint) + + conn.Go(ctx, + Handlers( + ServerHandler(server, jsonrpc2.MethodNotFoundHandler), + ), + ) + + return ctx, conn, cliint +} + +// NewClient returns the context in which Client is embedded, jsonrpc2.Conn, and the Server. +func NewClient(ctx context.Context, client Client, stream jsonrpc2.Stream, logger *zap.Logger) (context.Context, jsonrpc2.Conn, Server) { + ctx = WithClient(ctx, client) + + conn := jsonrpc2.NewConn(stream) + conn.Go(ctx, + Handlers( + ClientHandler(client, jsonrpc2.MethodNotFoundHandler), + ), + ) + server := ServerDispatcher(conn, logger.Named("server")) + + return ctx, conn, server +} diff --git a/protocol/server.go b/protocol/server.go new file mode 100644 index 00000000..1abb8464 --- /dev/null +++ b/protocol/server.go @@ -0,0 +1,1999 @@ +// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "bytes" + "context" + "fmt" + + "go.uber.org/zap" + + "go.lsp.dev/jsonrpc2" +) + +// ServerDispatcher returns a Server that dispatches LSP requests across the +// given jsonrpc2 connection. +func ServerDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Server { + return &server{ + Conn: conn, + logger: logger, + } +} + +// ServerHandler jsonrpc2.Handler of Language Server Prococol Server. +// +//nolint:unparam,revive +func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { + h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { + if ctx.Err() != nil { + xctx := context.WithoutCancel(ctx) + + return reply(xctx, nil, ErrRequestCancelled) + } + handled, err := serverDispatch(ctx, server, reply, req) + if handled || err != nil { + return err + } + + // TODO: This code is wrong, it ignores handler and assumes non standard + // request handles everything + // non standard request should just be a layered handler. + var params any + if err := unmarshal(req.Params(), ¶ms); err != nil { + return replyParseError(ctx, reply, err) + } + + resp, err := server.Request(ctx, req.Method(), params) + + return reply(ctx, resp, err) + } + + return h +} + +// serverDispatch implements jsonrpc2.Handler. +// +//nolint:gocognit,funlen,gocyclo,cyclop,maintidx +func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, req jsonrpc2.Request) (handled bool, err error) { + if ctx.Err() != nil { + return true, reply(ctx, nil, ErrRequestCancelled) + } + + dec := newDecoder(bytes.NewReader(req.Params())) + logger := LoggerFromContext(ctx) + + switch req.Method() { + case MethodServerProgress: // notification + defer logger.Debug(MethodServerProgress, zap.Error(err)) + + var params ProgressParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.Progress(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodSetTrace: // notification + defer logger.Debug(MethodSetTrace, zap.Error(err)) + + var params SetTraceParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.SetTrace(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodExit: // notification + defer logger.Debug(MethodExit, zap.Error(err)) + + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } + + err := server.Exit(ctx) + + return true, reply(ctx, nil, err) + + case MethodInitialized: // notification + defer logger.Debug(MethodInitialized, zap.Error(err)) + + var params InitializedParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.Initialized(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodNotebookDocumentDidChange: // notification + defer logger.Debug(MethodNotebookDocumentDidChange, zap.Error(err)) + + var params DidChangeNotebookDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.NotebookDocumentDidChange(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodNotebookDocumentDidClose: // notification + defer logger.Debug(MethodNotebookDocumentDidClose, zap.Error(err)) + + var params DidCloseNotebookDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.NotebookDocumentDidClose(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodNotebookDocumentDidOpen: // notification + defer logger.Debug(MethodNotebookDocumentDidOpen, zap.Error(err)) + + var params DidOpenNotebookDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.NotebookDocumentDidOpen(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodNotebookDocumentDidSave: // notification + defer logger.Debug(MethodNotebookDocumentDidSave, zap.Error(err)) + + var params DidSaveNotebookDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.NotebookDocumentDidSave(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodTextDocumentDidChange: // notification + defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) + + var params DidChangeTextDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.TextDocumentDidChange(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodTextDocumentDidClose: // notification + defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) + + var params DidCloseTextDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.TextDocumentDidClose(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodTextDocumentDidOpen: // notification + defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) + + var params DidOpenTextDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.TextDocumentDidOpen(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodTextDocumentDidSave: // notification + defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) + + var params DidSaveTextDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.TextDocumentDidSave(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodTextDocumentWillSave: // notification + defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) + + var params WillSaveTextDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.TextDocumentWillSave(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWindowWorkDoneProgressCancel: // notification + defer logger.Debug(MethodWindowWorkDoneProgressCancel, zap.Error(err)) + + var params WorkDoneProgressCancelParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.WindowWorkDoneProgressCancel(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceDidChangeConfiguration: // notification + defer logger.Debug(MethodWorkspaceDidChangeConfiguration, zap.Error(err)) + + var params DidChangeConfigurationParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.WorkspaceDidChangeConfiguration(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceDidChangeWatchedFiles: // notification + defer logger.Debug(MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) + + var params DidChangeWatchedFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.WorkspaceDidChangeWatchedFiles(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceDidChangeWorkspaceFolders: // notification + defer logger.Debug(MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) + + var params DidChangeWorkspaceFoldersParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.WorkspaceDidChangeWorkspaceFolders(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceDidCreateFiles: // notification + defer logger.Debug(MethodWorkspaceDidCreateFiles, zap.Error(err)) + + var params CreateFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.WorkspaceDidCreateFiles(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceDidDeleteFiles: // notification + defer logger.Debug(MethodWorkspaceDidDeleteFiles, zap.Error(err)) + + var params DeleteFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.WorkspaceDidDeleteFiles(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWorkspaceDidRenameFiles: // notification + defer logger.Debug(MethodWorkspaceDidRenameFiles, zap.Error(err)) + + var params RenameFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := server.WorkspaceDidRenameFiles(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodCallHierarchyIncomingCalls: // request + defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) + + var params CallHierarchyIncomingCallsParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.CallHierarchyIncomingCalls(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodCallHierarchyOutgoingCalls: // request + defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) + + var params CallHierarchyOutgoingCallsParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.CallHierarchyOutgoingCalls(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodCodeActionResolve: // request + defer logger.Debug(MethodCodeActionResolve, zap.Error(err)) + + var params CodeAction + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.CodeActionResolve(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodCodeLensResolve: // request + defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) + + var params CodeLens + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.CodeLensResolve(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodCompletionItemResolve: // request + defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) + + var params CompletionItem + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.CompletionItemResolve(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodDocumentLinkResolve: // request + defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) + + var params DocumentLink + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.DocumentLinkResolve(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodInitialize: // request + defer logger.Debug(MethodInitialize, zap.Error(err)) + + var params InitializeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.Initialize(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodInlayHintResolve: // request + defer logger.Debug(MethodInlayHintResolve, zap.Error(err)) + + var params InlayHint + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.InlayHintResolve(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodShutdown: // request + defer logger.Debug(MethodShutdown, zap.Error(err)) + + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } + + err := server.Shutdown(ctx) + + return true, reply(ctx, nil, err) + + case MethodTextDocumentCodeAction: // request + defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) + + var params CodeActionParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentCodeAction(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentCodeLens: // request + defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) + + var params CodeLensParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentCodeLens(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentColorPresentation: // request + defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) + + var params ColorPresentationParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentColorPresentation(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentCompletion: // request + defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) + + var params CompletionParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentCompletion(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentDeclaration: // request + defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) + + var params DeclarationParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentDeclaration(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentDefinition: // request + defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) + + var params DefinitionParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentDefinition(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentDiagnostic: // request + defer logger.Debug(MethodTextDocumentDiagnostic, zap.Error(err)) + + var params DocumentDiagnosticParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentDiagnostic(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentDocumentColor: // request + defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) + + var params DocumentColorParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentDocumentColor(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentDocumentHighlight: // request + defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) + + var params DocumentHighlightParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentDocumentHighlight(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentDocumentLink: // request + defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) + + var params DocumentLinkParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentDocumentLink(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentDocumentSymbol: // request + defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) + + var params DocumentSymbolParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentDocumentSymbol(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentFoldingRange: // request + defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) + + var params FoldingRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentFoldingRange(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentFormatting: // request + defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) + + var params DocumentFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentHover: // request + defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) + + var params HoverParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentHover(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentImplementation: // request + defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) + + var params ImplementationParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentImplementation(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentInlayHint: // request + defer logger.Debug(MethodTextDocumentInlayHint, zap.Error(err)) + + var params InlayHintParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentInlayHint(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentInlineCompletion: // request + defer logger.Debug(MethodTextDocumentInlineCompletion, zap.Error(err)) + + var params InlineCompletionParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentInlineCompletion(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentInlineValue: // request + defer logger.Debug(MethodTextDocumentInlineValue, zap.Error(err)) + + var params InlineValueParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentInlineValue(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentLinkedEditingRange: // request + defer logger.Debug(MethodTextDocumentLinkedEditingRange, zap.Error(err)) + + var params LinkedEditingRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentLinkedEditingRange(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentMoniker: // request + defer logger.Debug(MethodTextDocumentMoniker, zap.Error(err)) + + var params MonikerParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentMoniker(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentOnTypeFormatting: // request + defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) + + var params DocumentOnTypeFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentOnTypeFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentPrepareCallHierarchy: // request + defer logger.Debug(MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) + + var params CallHierarchyPrepareParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentPrepareCallHierarchy(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentPrepareRename: // request + defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) + + var params PrepareRenameParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentPrepareRename(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentPrepareTypeHierarchy: // request + defer logger.Debug(MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) + + var params TypeHierarchyPrepareParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentPrepareTypeHierarchy(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentRangeFormatting: // request + defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) + + var params DocumentRangeFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentRangeFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentRangesFormatting: // request + defer logger.Debug(MethodTextDocumentRangesFormatting, zap.Error(err)) + + var params DocumentRangesFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentRangesFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentReferences: // request + defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) + + var params ReferenceParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentReferences(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentRename: // request + defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) + + var params RenameParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentRename(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSelectionRange: // request + defer logger.Debug(MethodTextDocumentSelectionRange, zap.Error(err)) + + var params SelectionRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentSelectionRange(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSemanticTokensFull: // request + defer logger.Debug(MethodTextDocumentSemanticTokensFull, zap.Error(err)) + + var params SemanticTokensParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentSemanticTokensFull(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSemanticTokensFullDelta: // request + defer logger.Debug(MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) + + var params SemanticTokensDeltaParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentSemanticTokensFullDelta(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSemanticTokensRange: // request + defer logger.Debug(MethodTextDocumentSemanticTokensRange, zap.Error(err)) + + var params SemanticTokensRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentSemanticTokensRange(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSignatureHelp: // request + defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) + + var params SignatureHelpParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentSignatureHelp(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentTypeDefinition: // request + defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) + + var params TypeDefinitionParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentTypeDefinition(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentWillSaveWaitUntil: // request + defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) + + var params WillSaveTextDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentWillSaveWaitUntil(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTypeHierarchySubtypes: // request + defer logger.Debug(MethodTypeHierarchySubtypes, zap.Error(err)) + + var params TypeHierarchySubtypesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TypeHierarchySubtypes(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTypeHierarchySupertypes: // request + defer logger.Debug(MethodTypeHierarchySupertypes, zap.Error(err)) + + var params TypeHierarchySupertypesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TypeHierarchySupertypes(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceDiagnostic: // request + defer logger.Debug(MethodWorkspaceDiagnostic, zap.Error(err)) + + var params WorkspaceDiagnosticParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceDiagnostic(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceExecuteCommand: // request + defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) + + var params ExecuteCommandParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceExecuteCommand(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceSymbol: // request + defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) + + var params WorkspaceSymbolParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceSymbol(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillCreateFiles: // request + defer logger.Debug(MethodWorkspaceWillCreateFiles, zap.Error(err)) + + var params CreateFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceWillCreateFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillDeleteFiles: // request + defer logger.Debug(MethodWorkspaceWillDeleteFiles, zap.Error(err)) + + var params DeleteFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceWillDeleteFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillRenameFiles: // request + defer logger.Debug(MethodWorkspaceWillRenameFiles, zap.Error(err)) + + var params RenameFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceWillRenameFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceSymbolResolve: // request + defer logger.Debug(MethodWorkspaceSymbolResolve, zap.Error(err)) + + var params WorkspaceSymbol + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceSymbolResolve(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + default: + return false, nil + } +} + +// server implements a Language Server Protocol server. +type server struct { + jsonrpc2.Conn + + logger *zap.Logger +} + +var _ Server = (*server)(nil) + +func (s *server) CancelRequest(ctx context.Context, params *CancelParams) (err error) { + s.logger.Debug("notify " + MethodClientCancelRequest) + defer s.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodClientCancelRequest, params) +} + +// Progress is the base protocol offers also support to report progress in a generic fashion. +// +// This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and +// partial result progress to support streaming of results. +// +// @since 3.16.0. +func (s *server) Progress(ctx context.Context, params *ProgressParams) (err error) { + s.logger.Debug("notify " + MethodClientProgress) + defer s.logger.Debug("end "+MethodClientProgress, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodClientProgress, params) +} + +// SetTrace a notification that should be used by the client to modify the trace setting of the server. +// +// @since 3.16.0. +func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { + s.logger.Debug("notify " + MethodSetTrace) + defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodSetTrace, params) +} + +// Exit a notification to ask the server to exit its process. +// +// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. +func (s *server) Exit(ctx context.Context) (err error) { + s.logger.Debug("notify " + MethodExit) + defer s.logger.Debug("end "+MethodExit, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodExit, nil) +} + +// Initialized sends the notification from the client to the server after the client received the result of the +// initialize request but before the client is sending any other request or notification to the server. +// +// The server can use the initialized notification for example to dynamically register capabilities. +// The initialized notification may only be sent once. +func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { + s.logger.Debug("notify " + MethodInitialized) + defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodInitialized, params) +} + +func (s *server) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidChange) + defer s.logger.Debug("end "+MethodNotebookDocumentDidChange, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodNotebookDocumentDidChange, params) +} + +// NotebookDocumentDidClose a notification sent when a notebook closes. +// +// @since 3.17.0 +func (s *server) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidClose) + defer s.logger.Debug("end "+MethodNotebookDocumentDidClose, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodNotebookDocumentDidClose, params) +} + +// NotebookDocumentDidOpen a notification sent when a notebook opens. +// +// @since 3.17.0 +func (s *server) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidOpen) + defer s.logger.Debug("end "+MethodNotebookDocumentDidOpen, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodNotebookDocumentDidOpen, params) +} + +// NotebookDocumentDidSave a notification sent when a notebook document is saved. +// +// @since 3.17.0 +func (s *server) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidSave) + defer s.logger.Debug("end "+MethodNotebookDocumentDidSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodNotebookDocumentDidSave, params) +} + +// DidChange sends the notification from the client to the server to signal changes to a text document. +// +// In 2.0 the shape of the params has changed to include proper version numbers and language ids. +func (s *server) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { + s.logger.Debug("notify " + MethodTextDocumentDidChange) + defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) +} + +// DidClose sends the notification from the client to the server when the document got closed in the client. +// +// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). +// As with the open notification the close notification is about managing the document’s content. +// Receiving a close notification doesn’t mean that the document was open in an editor before. +// +// A close notification requires a previous open notification to be sent. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidClose) + defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) +} + +// DidOpen sends the open notification from the client to the server to signal newly opened text documents. +// +// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. +// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. +// +// An open notification must not be sent more than once without a corresponding close notification send before. +// This means open and close notification must be balanced and the max open count for a particular textDocument is one. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidOpen) + defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) +} + +// DidSave sends the notification from the client to the server when the document was saved in the client. +func (s *server) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidSave) + defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) +} + +// WillSave sends the notification from the client to the server before the document is actually saved. +func (s *server) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentWillSave) + defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) +} + +// WindowWorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the +// server side using the "window/workDoneProgress/create". +func (s *server) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { + s.logger.Debug("call " + MethodWindowWorkDoneProgressCancel) + defer s.logger.Debug("end "+MethodWindowWorkDoneProgressCancel, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWindowWorkDoneProgressCancel, params) +} + +// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. +func (s *server) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) +} + +// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. +// +// It is recommended that servers register for these file events using the registration mechanism. +// In former implementations clients pushed file events without the server actively asking for it. +func (s *server) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) +} + +// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. +// +// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; +// or if the server has registered itself to receive this notification. +// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. +// +// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). +func (s *server) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) +} + +// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. +// +// @since 3.16.0. +func (s *server) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidCreateFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidCreateFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidCreateFiles, params) +} + +// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. +// +// @since 3.16.0. +func (s *server) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidDeleteFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidDeleteFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidDeleteFiles, params) +} + +// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. +// +// @since 3.16.0. +func (s *server) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidRenameFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidRenameFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidRenameFiles, params) +} + +// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (_ []*CallHierarchyIncomingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) + + var result []*CallHierarchyIncomingCall + if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (_ []*CallHierarchyOutgoingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) + + var result []*CallHierarchyOutgoingCall + if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) CodeActionResolve(ctx context.Context, params *CodeAction) (_ *CodeAction, err error) { + s.logger.Debug("call " + MethodCodeActionResolve) + defer s.logger.Debug("end "+MethodCodeActionResolve, zap.Error(err)) + + var result *CodeAction + if err := Call(ctx, s.Conn, MethodCodeActionResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. +func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { + s.logger.Debug("call " + MethodCodeLensResolve) + defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) + + var result *CodeLens + if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. +func (s *server) CompletionItemResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { + s.logger.Debug("call " + MethodCompletionItemResolve) + defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) + + var result *CompletionItem + if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. +func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { + s.logger.Debug("call " + MethodDocumentLinkResolve) + defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) + + var result *DocumentLink + if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Initialize sents the request as the first request from the client to the server. +// +// If the server receives a request or notification before the initialize request it should act as follows: +// +// - For a request the response should be an error with code: -32002. The message can be picked by the server. +// - Notifications should be dropped, except for the exit notification. This will allow the exit of a server without an initialize request. +// +// Until the server has responded to the initialize request with an InitializeResult, the client +// must not send any additional requests or notifications to the server. +// In addition the server is not allowed to send any requests or notifications to the client until +// it has responded with an InitializeResult, with the exception that during the initialize request +// the server is allowed to send the notifications window/showMessage, window/logMessage and telemetry/event +// as well as the window/showMessageRequest request to the client. +func (s *server) Initialize(ctx context.Context, params *InitializeParams) (_ *InitializeResult, err error) { + s.logger.Debug("call " + MethodInitialize) + defer s.logger.Debug("end "+MethodInitialize, zap.Error(err)) + + var result *InitializeResult + if err := Call(ctx, s.Conn, MethodInitialize, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) InlayHintResolve(ctx context.Context, params *InlayHint) (_ *InlayHint, err error) { + s.logger.Debug("call " + MethodInlayHintResolve) + defer s.logger.Debug("end "+MethodInlayHintResolve, zap.Error(err)) + + var result *InlayHint + if err := Call(ctx, s.Conn, MethodInlayHintResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Shutdown sents the request from the client to the server. +// +// It asks the server to shut down, but to not exit (otherwise the response might not be delivered correctly to the client). +// There is a separate exit notification that asks the server to exit. +// +// Clients must not sent any notifications other than `exit` or requests to a server to which they have sent a shutdown requests. +// If a server receives requests after a shutdown request those requests should be errored with `InvalidRequest`. +func (s *server) Shutdown(ctx context.Context) (err error) { + s.logger.Debug("call " + MethodShutdown) + defer s.logger.Debug("end "+MethodShutdown, zap.Error(err)) + + return Call(ctx, s.Conn, MethodShutdown, nil, nil) +} + +// CodeAction sends the request is from the client to the server to compute commands for a given text document and range. +// +// These commands are typically code fixes to either fix problems or to beautify/refactor code. The result of a `textDocument/codeAction` +// request is an array of `Command` literals which are typically presented in the user interface. +// +// To ensure that a server is useful in many clients the commands specified in a code actions should be handled by the +// server and not by the client (see `workspace/executeCommand` and `ServerCapabilities.executeCommandProvider`). +// If the client supports providing edits with a code action then the mode should be used. +func (s *server) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (_ *TextDocumentCodeActionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentCodeAction) + defer s.logger.Debug("end "+MethodTextDocumentCodeAction, zap.Error(err)) + + var result *TextDocumentCodeActionResult + if err := Call(ctx, s.Conn, MethodTextDocumentCodeAction, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// CodeLens sends the request from the client to the server to compute code lenses for a given text document. +func (s *server) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) (_ []*CodeLens, err error) { + s.logger.Debug("call " + MethodTextDocumentCodeLens) + defer s.logger.Debug("end "+MethodTextDocumentCodeLens, zap.Error(err)) + + var result []*CodeLens + if err := Call(ctx, s.Conn, MethodTextDocumentCodeLens, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// ColorPresentation sends the request from the client to the server to obtain a list of presentations for a color value at a given location. +// +// # Clients can use the result to +// +// - modify a color reference. +// - show in a color picker and let users pick one of the presentations. +func (s *server) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) (_ []*ColorPresentation, err error) { + s.logger.Debug("call " + MethodTextDocumentColorPresentation) + defer s.logger.Debug("end "+MethodTextDocumentColorPresentation, zap.Error(err)) + + var result []*ColorPresentation + if err := Call(ctx, s.Conn, MethodTextDocumentColorPresentation, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Completion sends the request from the client to the server to compute completion items at a given cursor position. +// +// Completion items are presented in the IntelliSense user interface. +// If computing full completion items is expensive, servers can additionally provide a handler for the completion item resolve request (‘completionItem/resolve’). +// +// This request is sent when a completion item is selected in the user interface. +// A typical use case is for example: the ‘textDocument/completion’ request doesn’t fill in the documentation property +// for returned completion items since it is expensive to compute. When the item is selected in the user interface then +// a ‘completionItem/resolve’ request is sent with the selected completion item as a parameter. +// +// The returned completion item should have the documentation property filled in. The request can delay the computation of +// the `detail` and `documentation` properties. However, properties that are needed for the initial sorting and filtering, +// like `sortText`, `filterText`, `insertText`, and `textEdit` must be provided in the `textDocument/completion` response and must not be changed during resolve. +func (s *server) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (_ *TextDocumentCompletionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentCompletion) + defer s.logger.Debug("end "+MethodTextDocumentCompletion, zap.Error(err)) + + var result *TextDocumentCompletionResult + if err := Call(ctx, s.Conn, MethodTextDocumentCompletion, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Declaration sends the request from the client to the server to resolve the declaration location of a symbol at a given text document position. +// +// The result type LocationLink[] got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.declaration.linkSupport`. +// +// @since 3.14.0. +func (s *server) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (_ *TextDocumentDeclarationResult, err error) { + s.logger.Debug("call " + MethodTextDocumentDeclaration) + defer s.logger.Debug("end "+MethodTextDocumentDeclaration, zap.Error(err)) + + var result *TextDocumentDeclarationResult + if err := Call(ctx, s.Conn, MethodTextDocumentDeclaration, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Definition sends the request from the client to the server to resolve the definition location of a symbol at a given text document position. +// +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.definition.linkSupport`. +// +// @since 3.14.0. +func (s *server) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (_ *TextDocumentDefinitionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentDefinition) + defer s.logger.Debug("end "+MethodTextDocumentDefinition, zap.Error(err)) + + var result *TextDocumentDefinitionResult + if err := Call(ctx, s.Conn, MethodTextDocumentDefinition, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (_ *DocumentDiagnosticReport, err error) { + s.logger.Debug("call " + MethodTextDocumentDiagnostic) + defer s.logger.Debug("end "+MethodTextDocumentDiagnostic, zap.Error(err)) + + var result *DocumentDiagnosticReport + if err := Call(ctx, s.Conn, MethodTextDocumentDiagnostic, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// DocumentColor sends the request from the client to the server to list all color references found in a given text document. +// +// Along with the range, a color value in RGB is returned. +// +// Clients can use the result to decorate color references in an editor. +// For example: +// +// - Color boxes showing the actual color next to the reference +// - Show a color picker when a color reference is edited. +func (s *server) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) (_ []*ColorInformation, err error) { + s.logger.Debug("call " + MethodTextDocumentDocumentColor) + defer s.logger.Debug("end "+MethodTextDocumentDocumentColor, zap.Error(err)) + + var result []*ColorInformation + if err := Call(ctx, s.Conn, MethodTextDocumentDocumentColor, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// DocumentHighlight sends the request is from the client to the server to resolve a document highlights for a given text document position. +// +// For programming languages this usually highlights all references to the symbol scoped to this file. +// However we kept ‘textDocument/documentHighlight’ and ‘textDocument/references’ separate requests since the first one is allowed to be more fuzzy. +// +// Symbol matches usually have a `DocumentHighlightKind` of `Read` or `Write` whereas fuzzy or textual matches use `Text` as the kind. +func (s *server) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (_ []*DocumentHighlight, err error) { + s.logger.Debug("call " + MethodTextDocumentDocumentHighlight) + defer s.logger.Debug("end "+MethodTextDocumentDocumentHighlight, zap.Error(err)) + + var result []*DocumentHighlight + if err := Call(ctx, s.Conn, MethodTextDocumentDocumentHighlight, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// DocumentLink sends the request from the client to the server to request the location of links in a document. +func (s *server) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) (_ []*DocumentLink, err error) { + s.logger.Debug("call " + MethodTextDocumentDocumentLink) + defer s.logger.Debug("end "+MethodTextDocumentDocumentLink, zap.Error(err)) + + var result []*DocumentLink + if err := Call(ctx, s.Conn, MethodTextDocumentDocumentLink, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. +// +// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. +func (s *server) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (_ *TextDocumentDocumentSymbolResult, err error) { + s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) + defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) + + var result *TextDocumentDocumentSymbolResult + if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. +// +// @since version 3.10.0. +func (s *server) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) (_ []*FoldingRange, err error) { + s.logger.Debug("call " + MethodTextDocumentFoldingRange) + defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) + + var result []*FoldingRange + if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Formatting sends the request from the client to the server to format a whole document. +func (s *server) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentFormatting) + defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) + + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Hover sends the request is from the client to the server to request hover information at a given text document position. +func (s *server) TextDocumentHover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { + s.logger.Debug("call " + MethodTextDocumentHover) + defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) + + var result *Hover + if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. +// +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. +func (s *server) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (_ *TextDocumentImplementationResult, err error) { + s.logger.Debug("call " + MethodTextDocumentImplementation) + defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) + + var result *TextDocumentImplementationResult + if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) (_ []*InlayHint, err error) { + s.logger.Debug("call " + MethodTextDocumentInlayHint) + defer s.logger.Debug("end "+MethodTextDocumentInlayHint, zap.Error(err)) + + var result []*InlayHint + if err := Call(ctx, s.Conn, MethodTextDocumentInlayHint, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (_ *TextDocumentInlineCompletionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentInlineCompletion) + defer s.logger.Debug("end "+MethodTextDocumentInlineCompletion, zap.Error(err)) + + var result *TextDocumentInlineCompletionResult + if err := Call(ctx, s.Conn, MethodTextDocumentInlineCompletion, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) (_ []*InlineValue, err error) { + s.logger.Debug("call " + MethodTextDocumentInlineValue) + defer s.logger.Debug("end "+MethodTextDocumentInlineValue, zap.Error(err)) + + var result []*InlineValue + if err := Call(ctx, s.Conn, MethodTextDocumentInlineValue, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. +// +// Optionally a word pattern can be returned to describe valid contents. +// +// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. +// +// @since 3.16.0. +func (s *server) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (_ *LinkedEditingRanges, err error) { + s.logger.Debug("call " + MethodTextDocumentLinkedEditingRange) + defer s.logger.Debug("end "+MethodTextDocumentLinkedEditingRange, zap.Error(err)) + + var result *LinkedEditingRanges + if err := Call(ctx, s.Conn, MethodTextDocumentLinkedEditingRange, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. +// +// An array of Moniker types is returned as response to indicate possible monikers at the given location. +// +// If no monikers can be calculated, an empty array or null should be returned. +// +// @since 3.16.0. +func (s *server) TextDocumentMoniker(ctx context.Context, params *MonikerParams) (_ []*Moniker, err error) { + s.logger.Debug("call " + MethodTextDocumentMoniker) + defer s.logger.Debug("end "+MethodTextDocumentMoniker, zap.Error(err)) + + var result []*Moniker + if err := Call(ctx, s.Conn, MethodTextDocumentMoniker, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// OnTypeFormatting sends the request from the client to the server to format parts of the document during typing. +func (s *server) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentOnTypeFormatting) + defer s.logger.Debug("end "+MethodTextDocumentOnTypeFormatting, zap.Error(err)) + + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentOnTypeFormatting, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. +// +// The call hierarchy requests are executed in two steps: +// 1. first a call hierarchy item is resolved for the given text document position +// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. +// +// @since 3.16.0. +func (s *server) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (_ []*CallHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) + + var result []*CallHierarchyItem + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// PrepareRename sends the request from the client to the server to setup and test the validity of a rename operation at a given location. +// +// @since version 3.12.0. +func (s *server) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (_ *PrepareRenameResult, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareRename) + defer s.logger.Debug("end "+MethodTextDocumentPrepareRename, zap.Error(err)) + + var result *PrepareRenameResult + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareRename, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareTypeHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) + + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareTypeHierarchy, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// RangeFormatting sends the request from the client to the server to format a given range in a document. +func (s *server) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRangeFormatting) + defer s.logger.Debug("end "+MethodTextDocumentRangeFormatting, zap.Error(err)) + + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRangeFormatting, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRangesFormatting) + defer s.logger.Debug("end "+MethodTextDocumentRangesFormatting, zap.Error(err)) + + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRangesFormatting, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// References sends the request from the client to the server to resolve project-wide references for the symbol denoted by the given text document position. +func (s *server) TextDocumentReferences(ctx context.Context, params *ReferenceParams) (_ []*Location, err error) { + s.logger.Debug("call " + MethodTextDocumentReferences) + defer s.logger.Debug("end "+MethodTextDocumentReferences, zap.Error(err)) + + var result []*Location + if err := Call(ctx, s.Conn, MethodTextDocumentReferences, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Rename sends the request from the client to the server to perform a workspace-wide rename of a symbol. +func (s *server) TextDocumentRename(ctx context.Context, params *RenameParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRename) + defer s.logger.Debug("end "+MethodTextDocumentRename, zap.Error(err)) + + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRename, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) (_ []*SelectionRange, err error) { + s.logger.Debug("call " + MethodTextDocumentSelectionRange) + defer s.logger.Debug("end "+MethodTextDocumentSelectionRange, zap.Error(err)) + + var result []*SelectionRange + if err := Call(ctx, s.Conn, MethodTextDocumentSelectionRange, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. +// +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// +// @since 3.16.0. +func (s *server) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (_ *SemanticTokens, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensFull) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFull, zap.Error(err)) + + var result *SemanticTokens + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFull, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. +// +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// +// @since 3.16.0. +func (s *server) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (_ *TextDocumentSemanticTokensFullDeltaResult, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensFullDelta) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) + + var result *TextDocumentSemanticTokensFullDeltaResult + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFullDelta, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. +// +// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). +// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. +// +// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. +// +// @since 3.16.0. +func (s *server) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (_ *SemanticTokens, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensRange) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensRange, zap.Error(err)) + + var result *SemanticTokens + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensRange, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. +func (s *server) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { + s.logger.Debug("call " + MethodTextDocumentSignatureHelp) + defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) + + var result *SignatureHelp + if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. +// +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. +// +// @since version 3.6.0. +func (s *server) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (_ *TextDocumentTypeDefinitionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentTypeDefinition) + defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) + + var result *TextDocumentTypeDefinitionResult + if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. +// +// The request can return an array of TextEdits which will be applied to the text document before it is saved. +// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. +// This is done to keep the save fast and reliable. +func (s *server) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) + defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) + + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTypeHierarchySubtypes) + defer s.logger.Debug("end "+MethodTypeHierarchySubtypes, zap.Error(err)) + + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTypeHierarchySubtypes, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTypeHierarchySupertypes) + defer s.logger.Debug("end "+MethodTypeHierarchySupertypes, zap.Error(err)) + + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTypeHierarchySupertypes, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (_ *WorkspaceDiagnosticReport, err error) { + s.logger.Debug("call " + MethodWorkspaceDiagnostic) + defer s.logger.Debug("end "+MethodWorkspaceDiagnostic, zap.Error(err)) + + var result *WorkspaceDiagnosticReport + if err := Call(ctx, s.Conn, MethodWorkspaceDiagnostic, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. +// +// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the +// request `workspace/applyEdit` which is sent from the server to the client. +func (s *server) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result any, err error) { + s.logger.Debug("call " + MethodWorkspaceExecuteCommand) + defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) + + if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. +func (s *server) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (_ *WorkspaceSymbolResult, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbol) + defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) + + var result *WorkspaceSymbolResult + if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. +// +// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. +// +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. +// +// @since 3.16.0. +func (s *server) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillCreateFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillCreateFiles, zap.Error(err)) + + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillCreateFiles, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. +// +// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. +// +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. +// +// @since 3.16.0. +func (s *server) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillDeleteFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillDeleteFiles, zap.Error(err)) + + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillDeleteFiles, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. +// +// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. +// +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. +// +// @since 3.16.0. +func (s *server) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillRenameFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillRenameFiles, zap.Error(err)) + + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillRenameFiles, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (s *server) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (_ *WorkspaceSymbol, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbolResolve) + defer s.logger.Debug("end "+MethodWorkspaceSymbolResolve, zap.Error(err)) + + var result *WorkspaceSymbol + if err := Call(ctx, s.Conn, MethodWorkspaceSymbolResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Request sends a request from the client to the server that non-compliant with the Language Server Protocol specifications. +func (s *server) Request(ctx context.Context, method string, params any) (any, error) { + s.logger.Debug("call " + method) + defer s.logger.Debug("end " + method) + + var result any + if err := Call(ctx, s.Conn, method, params, &result); err != nil { + return nil, err + } + + return result, nil +} diff --git a/server_interface.go b/protocol/server_interface.go similarity index 100% rename from server_interface.go rename to protocol/server_interface.go diff --git a/protocol/typealias.go b/protocol/typealias.go new file mode 100644 index 00000000..ca6e6a25 --- /dev/null +++ b/protocol/typealias.go @@ -0,0 +1,602 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import "fmt" + +type RegularExpressionEngineKind string + +// Pattern the glob pattern to watch relative to the base path. Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none - `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) +// +// @since 3.17.0 +type Pattern string + +// NotebookDocumentFilter a notebook document filter denotes a notebook document by different properties. The properties will be match against the notebook's URI (same as with documents) +// +// @since 3.17.0 +type NotebookDocumentFilter struct { + Value any `json:"value"` +} + +func NewNotebookDocumentFilter[T NotebookDocumentFilterNotebookType | NotebookDocumentFilterScheme | NotebookDocumentFilterPattern](x T) NotebookDocumentFilter { + return NotebookDocumentFilter{ + Value: x, + } +} + +func (t NotebookDocumentFilter) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case NotebookDocumentFilterNotebookType: + return marshal(x) + case NotebookDocumentFilterScheme: + return marshal(x) + case NotebookDocumentFilterPattern: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *NotebookDocumentFilter) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 NotebookDocumentFilterNotebookType + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 NotebookDocumentFilterScheme + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 NotebookDocumentFilterPattern + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// TextDocumentFilter a document filter denotes a document by different properties like the TextDocument.languageId language, the Uri.scheme scheme of its resource, or a glob-pattern that is applied to the TextDocument.fileName path. Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) // // Example: A language filter that applies to typescript files on disk: `{ language: 'typescript', scheme: 'file' }` // // Example: A language filter that applies to all package.json paths: `{ language: 'json', pattern: '**package.json' }` +// +// @since 3.17.0 +type TextDocumentFilter struct { + Value any `json:"value"` +} + +func NewTextDocumentFilter[T TextDocumentFilterLanguage | TextDocumentFilterScheme | TextDocumentFilterPattern](x T) TextDocumentFilter { + return TextDocumentFilter{ + Value: x, + } +} + +func (t TextDocumentFilter) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case TextDocumentFilterLanguage: + return marshal(x) + case TextDocumentFilterScheme: + return marshal(x) + case TextDocumentFilterPattern: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *TextDocumentFilter) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 TextDocumentFilterLanguage + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 TextDocumentFilterScheme + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 TextDocumentFilterPattern + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// GlobPattern the glob pattern. Either a string pattern or a relative pattern. +// +// @since 3.17.0 +type GlobPattern struct { + Value any `json:"value"` +} + +func NewGlobPattern[T Pattern | RelativePattern](x T) GlobPattern { + return GlobPattern{ + Value: x, + } +} + +func (t GlobPattern) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Pattern: + return marshal(x) + case RelativePattern: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *GlobPattern) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Pattern + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 RelativePattern + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DocumentFilter a document filter describes a top level text document or a notebook cell document. 3.17.0 - proposed +// support for NotebookCellTextDocumentFilter. +// +// @since 3.17.0 - proposed support for NotebookCellTextDocumentFilter. +type DocumentFilter struct { + Value any `json:"value"` +} + +func NewDocumentFilter[T TextDocumentFilter | NotebookCellTextDocumentFilter](x T) DocumentFilter { + return DocumentFilter{ + Value: x, + } +} + +func (t DocumentFilter) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case TextDocumentFilter: + return marshal(x) + case NotebookCellTextDocumentFilter: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *DocumentFilter) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 TextDocumentFilter + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 NotebookCellTextDocumentFilter + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// MarkedString markedString can be used to render human readable text. It is either a markdown string or a code-block that provides a language and a code snippet. The language identifier is semantically equal to the +// optional language identifier in fenced code blocks in GitHub issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting The pair of a language and a value is an equivalent to markdown: ```${language} ${value} ``` Note that markdown strings will be sanitized - that means html will be escaped. // // Deprecated: use MarkupContent instead. +type MarkedString struct { + Value any `json:"value"` +} + +func NewMarkedString[T string | MarkedStringWithLanguage](x T) MarkedString { + return MarkedString{ + Value: x, + } +} + +func (t MarkedString) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case MarkedStringWithLanguage: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *MarkedString) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 MarkedStringWithLanguage + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// TextDocumentContentChangeEvent an event describing a change to a text document. If only a text is provided it is considered to be the full content of the document. +type TextDocumentContentChangeEvent struct { + Value any `json:"value"` +} + +func NewTextDocumentContentChangeEvent[T TextDocumentContentChangePartial | TextDocumentContentChangeWholeDocument](x T) TextDocumentContentChangeEvent { + return TextDocumentContentChangeEvent{ + Value: x, + } +} + +func (t TextDocumentContentChangeEvent) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case TextDocumentContentChangePartial: + return marshal(x) + case TextDocumentContentChangeWholeDocument: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *TextDocumentContentChangeEvent) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 TextDocumentContentChangePartial + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 TextDocumentContentChangeWholeDocument + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// WorkspaceDocumentDiagnosticReport a workspace diagnostic document report. +// +// @since 3.17.0 +type WorkspaceDocumentDiagnosticReport struct { + Value any `json:"value"` +} + +func NewWorkspaceDocumentDiagnosticReport[T WorkspaceFullDocumentDiagnosticReport | WorkspaceUnchangedDocumentDiagnosticReport](x T) WorkspaceDocumentDiagnosticReport { + return WorkspaceDocumentDiagnosticReport{ + Value: x, + } +} + +func (t WorkspaceDocumentDiagnosticReport) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case WorkspaceFullDocumentDiagnosticReport: + return marshal(x) + case WorkspaceUnchangedDocumentDiagnosticReport: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *WorkspaceDocumentDiagnosticReport) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 WorkspaceFullDocumentDiagnosticReport + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 WorkspaceUnchangedDocumentDiagnosticReport + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// ChangeAnnotationIdentifier an identifier to refer to a change annotation stored with a workspace edit. +type ChangeAnnotationIdentifier string + +type ProgressToken struct { + Value any `json:"value"` +} + +func NewProgressToken[T int32 | string](x T) ProgressToken { + return ProgressToken{ + Value: x, + } +} + +func (t ProgressToken) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case int32: + return marshal(x) + case string: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *ProgressToken) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 int32 + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 string + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DocumentSelector a document selector is the combination of one or many document filters. // // Example: `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]`; The use of a string as a document filter is deprecated +// +// @since 3.16.0. +type DocumentSelector []DocumentFilter + +type PrepareRenameResult struct { + Value any `json:"value"` +} + +func NewPrepareRenameResult[T Range | PrepareRenamePlaceholder | PrepareRenameDefaultBehavior](x T) PrepareRenameResult { + return PrepareRenameResult{ + Value: x, + } +} + +func (t PrepareRenameResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Range: + return marshal(x) + case PrepareRenamePlaceholder: + return marshal(x) + case PrepareRenameDefaultBehavior: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *PrepareRenameResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Range + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 PrepareRenamePlaceholder + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 PrepareRenameDefaultBehavior + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DocumentDiagnosticReport the result of a document diagnostic pull request. A report can either be a full report containing all diagnostics for the requested document or an unchanged report indicating that nothing has changed in terms of diagnostics in comparison to the last pull request. +// +// @since 3.17.0 +type DocumentDiagnosticReport struct { + Value any `json:"value"` +} + +func NewDocumentDiagnosticReport[T RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport](x T) DocumentDiagnosticReport { + return DocumentDiagnosticReport{ + Value: x, + } +} + +func (t DocumentDiagnosticReport) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case RelatedFullDocumentDiagnosticReport: + return marshal(x) + case RelatedUnchangedDocumentDiagnosticReport: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *DocumentDiagnosticReport) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 RelatedFullDocumentDiagnosticReport + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 RelatedUnchangedDocumentDiagnosticReport + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// InlineValue inline value information can be provided by different means: - directly as a text value (class InlineValueText). - as a name to use for a variable lookup (class InlineValueVariableLookup) - as an evaluatable expression (class InlineValueEvaluatableExpression) The InlineValue types combines all inline value types into one type. +// +// @since 3.17.0 +type InlineValue struct { + Value any `json:"value"` +} + +func NewInlineValue[T InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression](x T) InlineValue { + return InlineValue{ + Value: x, + } +} + +func (t InlineValue) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case InlineValueText: + return marshal(x) + case InlineValueVariableLookup: + return marshal(x) + case InlineValueEvaluatableExpression: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *InlineValue) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 InlineValueText + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 InlineValueVariableLookup + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 InlineValueEvaluatableExpression + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DeclarationLink information about where a symbol is declared. Provides additional metadata over normal Location location declarations, including the range of the declaring symbol. Servers should prefer returning `DeclarationLink` over `Declaration` if supported by the client. +type DeclarationLink LocationLink + +// Declaration the declaration of a symbol representation as one or many Location locations. +type Declaration struct { + Value any `json:"value"` +} + +func NewDeclaration[T Location | []Location](x T) Declaration { + return Declaration{ + Value: x, + } +} + +func (t Declaration) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Location: + return marshal(x) + case []Location: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *Declaration) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Location + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []Location + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DefinitionLink information about where a symbol is defined. Provides additional metadata over normal Location location definitions, including the range of the defining symbol. +type DefinitionLink LocationLink + +// Definition the definition of a symbol represented as one or many Location locations. For most programming languages there is only one location at which a symbol is defined. Servers should prefer returning `DefinitionLink` over `Definition` if supported by the client. +type Definition struct { + Value any `json:"value"` +} + +func NewDefinition[T Location | []Location](x T) Definition { + return Definition{ + Value: x, + } +} + +func (t Definition) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Location: + return marshal(x) + case []Location: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *Definition) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Location + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []Location + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} diff --git a/protocol/types.go b/protocol/types.go new file mode 100644 index 00000000..e5cadd52 --- /dev/null +++ b/protocol/types.go @@ -0,0 +1,20 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +type DocumentURI string + +type ClientMethod = string + +type ServerMethod = string + +// UnmarshalError indicates that a JSON value did not conform to +// one of the expected cases of an LSP union type. +type UnmarshalError struct { + msg string +} + +func (e UnmarshalError) Error() string { + return e.msg +} diff --git a/protocol/types_generics.go b/protocol/types_generics.go new file mode 100644 index 00000000..4a63dead --- /dev/null +++ b/protocol/types_generics.go @@ -0,0 +1,2953 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "fmt" + + "go.lsp.dev/uri" +) + +// CancelParamsID the request id to cancel. +type CancelParamsID struct { + Value any `json:"value"` +} + +func NewCancelParamsID[T int32 | string](x T) CancelParamsID { + return CancelParamsID{ + Value: x, + } +} + +func (t CancelParamsID) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case int32: + return marshal(x) + case string: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CancelParamsID) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 int32 + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 string + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [int32 string]"} +} + +// ClientSemanticTokensRequestOptionsFull the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. +// +// @since 3.18.0 proposed +type ClientSemanticTokensRequestOptionsFull struct { + Value any `json:"value"` +} + +func NewClientSemanticTokensRequestOptionsFull[T bool | ClientSemanticTokensRequestFullDelta](x T) ClientSemanticTokensRequestOptionsFull { + return ClientSemanticTokensRequestOptionsFull{ + Value: x, + } +} + +func (t ClientSemanticTokensRequestOptionsFull) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case ClientSemanticTokensRequestFullDelta: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ClientSemanticTokensRequestOptionsFull) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 ClientSemanticTokensRequestFullDelta + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool ClientSemanticTokensRequestFullDelta]"} +} + +// ClientSemanticTokensRequestOptionsRange the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. +// +// @since 3.18.0 proposed +type ClientSemanticTokensRequestOptionsRange struct { + Value any `json:"value"` +} + +func NewClientSemanticTokensRequestOptionsRange[T bool | Range](x T) ClientSemanticTokensRequestOptionsRange { + return ClientSemanticTokensRequestOptionsRange{ + Value: x, + } +} + +func (t ClientSemanticTokensRequestOptionsRange) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case Range: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ClientSemanticTokensRequestOptionsRange) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 Range + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool Range]"} +} + +// CompletionItemDefaultsEditRange a default edit range. +// +// @since 3.17.0 +type CompletionItemDefaultsEditRange struct { + Value any `json:"value"` +} + +func NewCompletionItemDefaultsEditRange[T Range | EditRangeWithInsertReplace](x T) CompletionItemDefaultsEditRange { + return CompletionItemDefaultsEditRange{ + Value: x, + } +} + +func (t CompletionItemDefaultsEditRange) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Range: + return marshal(x) + case EditRangeWithInsertReplace: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CompletionItemDefaultsEditRange) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Range + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 EditRangeWithInsertReplace + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Range EditRangeWithInsertReplace]"} +} + +// CompletionItemDocumentation a human-readable string that represents a doc-comment. +type CompletionItemDocumentation struct { + Value any `json:"value"` +} + +func NewCompletionItemDocumentation[T string | MarkupContent](x T) CompletionItemDocumentation { + return CompletionItemDocumentation{ + Value: x, + } +} + +func (t CompletionItemDocumentation) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case MarkupContent: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CompletionItemDocumentation) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// CompletionItemTextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`. +type CompletionItemTextEdit struct { + Value any `json:"value"` +} + +func NewCompletionItemTextEdit[T TextEdit | InsertReplaceEdit](x T) CompletionItemTextEdit { + return CompletionItemTextEdit{ + Value: x, + } +} + +func (t CompletionItemTextEdit) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case TextEdit: + return marshal(x) + case InsertReplaceEdit: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CompletionItemTextEdit) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 TextEdit + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 InsertReplaceEdit + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextEdit InsertReplaceEdit]"} +} + +// DiagnosticCode the diagnostic's code, which usually appear in the user interface. +type DiagnosticCode struct { + Value any `json:"value"` +} + +func NewDiagnosticCode[T int32 | string](x T) DiagnosticCode { + return DiagnosticCode{ + Value: x, + } +} + +func (t DiagnosticCode) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case int32: + return marshal(x) + case string: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DiagnosticCode) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 int32 + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 string + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [int32 string]"} +} + +type DidChangeConfigurationRegistrationOptionsSection struct { + Value any `json:"value"` +} + +func NewDidChangeConfigurationRegistrationOptionsSection[T string | []string](x T) DidChangeConfigurationRegistrationOptionsSection { + return DidChangeConfigurationRegistrationOptionsSection{ + Value: x, + } +} + +func (t DidChangeConfigurationRegistrationOptionsSection) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case []string: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DidChangeConfigurationRegistrationOptionsSection) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []string + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string []string]"} +} + +// @since 3.17.0 +type DocumentDiagnosticReportPartialResultRelatedDocuments struct { + Value any `json:"value"` +} + +func NewDocumentDiagnosticReportPartialResultRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](x T) DocumentDiagnosticReportPartialResultRelatedDocuments { + return DocumentDiagnosticReportPartialResultRelatedDocuments{ + Value: x, + } +} + +func (t DocumentDiagnosticReportPartialResultRelatedDocuments) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case FullDocumentDiagnosticReport: + return marshal(x) + case UnchangedDocumentDiagnosticReport: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DocumentDiagnosticReportPartialResultRelatedDocuments) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 FullDocumentDiagnosticReport + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 UnchangedDocumentDiagnosticReport + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} +} + +// HoverContents the hover's content. +type HoverContents struct { + Value any `json:"value"` +} + +func NewHoverContents[T MarkupContent | MarkedString | []MarkedString](x T) HoverContents { + return HoverContents{ + Value: x, + } +} + +func (t HoverContents) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case MarkupContent: + return marshal(x) + case MarkedString: + return marshal(x) + case []MarkedString: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *HoverContents) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 MarkupContent + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 MarkedString + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 []MarkedString + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [MarkupContent MarkedString []MarkedString]"} +} + +// InlayHintLabel the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty. +// +// @since 3.17.0 +type InlayHintLabel struct { + Value any `json:"value"` +} + +func NewInlayHintLabel[T string | []InlayHintLabelPart](x T) InlayHintLabel { + return InlayHintLabel{ + Value: x, + } +} + +func (t InlayHintLabel) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case []InlayHintLabelPart: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlayHintLabel) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []InlayHintLabelPart + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string []InlayHintLabelPart]"} +} + +// InlayHintLabelPartTooltip the tooltip text when you hover over this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. +// +// @since 3.17.0 +type InlayHintLabelPartTooltip struct { + Value any `json:"value"` +} + +func NewInlayHintLabelPartTooltip[T string | MarkupContent](x T) InlayHintLabelPartTooltip { + return InlayHintLabelPartTooltip{ + Value: x, + } +} + +func (t InlayHintLabelPartTooltip) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case MarkupContent: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlayHintLabelPartTooltip) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// InlayHintTooltip the tooltip text when you hover over this item. +// +// @since 3.17.0 +type InlayHintTooltip struct { + Value any `json:"value"` +} + +func NewInlayHintTooltip[T string | MarkupContent](x T) InlayHintTooltip { + return InlayHintTooltip{ + Value: x, + } +} + +func (t InlayHintTooltip) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case MarkupContent: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlayHintTooltip) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// InlineCompletionItemInsertText the text to replace the range with. Must be set. +// +// @since 3.18.0 proposed +type InlineCompletionItemInsertText struct { + Value any `json:"value"` +} + +func NewInlineCompletionItemInsertText[T string | StringValue](x T) InlineCompletionItemInsertText { + return InlineCompletionItemInsertText{ + Value: x, + } +} + +func (t InlineCompletionItemInsertText) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case StringValue: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlineCompletionItemInsertText) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 StringValue + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string StringValue]"} +} + +// NotebookCellTextDocumentFilterNotebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. +// +// @since 3.17.0 +type NotebookCellTextDocumentFilterNotebook struct { + Value any `json:"value"` +} + +func NewNotebookCellTextDocumentFilterNotebook[T string | NotebookDocumentFilter](x T) NotebookCellTextDocumentFilterNotebook { + return NotebookCellTextDocumentFilterNotebook{ + Value: x, + } +} + +func (t NotebookCellTextDocumentFilterNotebook) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case NotebookDocumentFilter: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *NotebookCellTextDocumentFilterNotebook) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 NotebookDocumentFilter + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} +} + +// NotebookDocumentFilterWithCellsNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. +// +// @since 3.18.0 proposed +type NotebookDocumentFilterWithCellsNotebook struct { + Value any `json:"value"` +} + +func NewNotebookDocumentFilterWithCellsNotebook[T string | NotebookDocumentFilter](x T) NotebookDocumentFilterWithCellsNotebook { + return NotebookDocumentFilterWithCellsNotebook{ + Value: x, + } +} + +func (t NotebookDocumentFilterWithCellsNotebook) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case NotebookDocumentFilter: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *NotebookDocumentFilterWithCellsNotebook) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 NotebookDocumentFilter + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} +} + +// NotebookDocumentFilterWithNotebookNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. +// +// @since 3.18.0 proposed +type NotebookDocumentFilterWithNotebookNotebook struct { + Value any `json:"value"` +} + +func NewNotebookDocumentFilterWithNotebookNotebook[T string | NotebookDocumentFilter](x T) NotebookDocumentFilterWithNotebookNotebook { + return NotebookDocumentFilterWithNotebookNotebook{ + Value: x, + } +} + +func (t NotebookDocumentFilterWithNotebookNotebook) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case NotebookDocumentFilter: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *NotebookDocumentFilterWithNotebookNotebook) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 NotebookDocumentFilter + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} +} + +// NotebookDocumentSyncOptionsNotebookSelector the notebooks to be synced. +// +// @since 3.17.0 +type NotebookDocumentSyncOptionsNotebookSelector struct { + Value any `json:"value"` +} + +func NewNotebookDocumentSyncOptionsNotebookSelector[T NotebookDocumentFilterWithNotebook | NotebookDocumentFilterWithCells](x T) NotebookDocumentSyncOptionsNotebookSelector { + return NotebookDocumentSyncOptionsNotebookSelector{ + Value: x, + } +} + +func (t NotebookDocumentSyncOptionsNotebookSelector) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case NotebookDocumentFilterWithNotebook: + return marshal(x) + case NotebookDocumentFilterWithCells: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *NotebookDocumentSyncOptionsNotebookSelector) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 NotebookDocumentFilterWithNotebook + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 NotebookDocumentFilterWithCells + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [NotebookDocumentFilterWithNotebook NotebookDocumentFilterWithCells]"} +} + +// ParameterInformationDocumentation the human-readable doc-comment of this parameter. Will be shown in the UI but can be omitted. +type ParameterInformationDocumentation struct { + Value any `json:"value"` +} + +func NewParameterInformationDocumentation[T string | MarkupContent](x T) ParameterInformationDocumentation { + return ParameterInformationDocumentation{ + Value: x, + } +} + +func (t ParameterInformationDocumentation) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case MarkupContent: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ParameterInformationDocumentation) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// ParameterInformationLabel the label of this parameter information. Either a string or an inclusive start and exclusive end offsets within its containing signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 string representation as `Position` and `Range` does. To avoid ambiguities a server should use the [start, end] offset value instead of using a substring. Whether a client support this is controlled via `labelOffsetSupport` client capability. *Note*: a label of type string should be a substring of its containing signature label. Its intended use case is to highlight the parameter label +// part in the `SignatureInformation.label`. +type ParameterInformationLabel struct { + Value any `json:"value"` +} + +func NewParameterInformationLabel[T string | uint32](x T) ParameterInformationLabel { + return ParameterInformationLabel{ + Value: x, + } +} + +func (t ParameterInformationLabel) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case uint32: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ParameterInformationLabel) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 uint32 + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string uint32]"} +} + +// RelatedFullDocumentDiagnosticReportRelatedDocuments 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 +type RelatedFullDocumentDiagnosticReportRelatedDocuments struct { + Value any `json:"value"` +} + +func NewRelatedFullDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](x T) RelatedFullDocumentDiagnosticReportRelatedDocuments { + return RelatedFullDocumentDiagnosticReportRelatedDocuments{ + Value: x, + } +} + +func (t RelatedFullDocumentDiagnosticReportRelatedDocuments) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case FullDocumentDiagnosticReport: + return marshal(x) + case UnchangedDocumentDiagnosticReport: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *RelatedFullDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 FullDocumentDiagnosticReport + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 UnchangedDocumentDiagnosticReport + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} +} + +// RelatedUnchangedDocumentDiagnosticReportRelatedDocuments 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 +type RelatedUnchangedDocumentDiagnosticReportRelatedDocuments struct { + Value any `json:"value"` +} + +func NewRelatedUnchangedDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](x T) RelatedUnchangedDocumentDiagnosticReportRelatedDocuments { + return RelatedUnchangedDocumentDiagnosticReportRelatedDocuments{ + Value: x, + } +} + +func (t RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case FullDocumentDiagnosticReport: + return marshal(x) + case UnchangedDocumentDiagnosticReport: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 FullDocumentDiagnosticReport + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 UnchangedDocumentDiagnosticReport + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} +} + +// RelativePatternBaseURI a workspace folder or a base URI to which this pattern will be matched against relatively. +// +// @since 3.17.0 +type RelativePatternBaseURI struct { + Value any `json:"value"` +} + +func NewRelativePatternBaseURI[T WorkspaceFolder | uri.URI](x T) RelativePatternBaseURI { + return RelativePatternBaseURI{ + Value: x, + } +} + +func (t RelativePatternBaseURI) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case WorkspaceFolder: + return marshal(x) + case uri.URI: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *RelativePatternBaseURI) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 WorkspaceFolder + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 uri.URI + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [WorkspaceFolder uri.URI]"} +} + +// SemanticTokensOptionsFull server supports providing semantic tokens for a full document. +// +// @since 3.16.0 +type SemanticTokensOptionsFull struct { + Value any `json:"value"` +} + +func NewSemanticTokensOptionsFull[T bool | SemanticTokensFullDelta](x T) SemanticTokensOptionsFull { + return SemanticTokensOptionsFull{ + Value: x, + } +} + +func (t SemanticTokensOptionsFull) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case SemanticTokensFullDelta: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *SemanticTokensOptionsFull) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 SemanticTokensFullDelta + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool SemanticTokensFullDelta]"} +} + +// SemanticTokensOptionsRange server supports providing semantic tokens for a specific range of a document. +// +// @since 3.16.0 +type SemanticTokensOptionsRange struct { + Value any `json:"value"` +} + +func NewSemanticTokensOptionsRange[T bool | Range](x T) SemanticTokensOptionsRange { + return SemanticTokensOptionsRange{ + Value: x, + } +} + +func (t SemanticTokensOptionsRange) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case Range: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *SemanticTokensOptionsRange) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 Range + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool Range]"} +} + +// ServerCapabilitiesCallHierarchyProvider the server provides call hierarchy support. +type ServerCapabilitiesCallHierarchyProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesCallHierarchyProvider[T bool | CallHierarchyOptions | CallHierarchyRegistrationOptions](x T) ServerCapabilitiesCallHierarchyProvider { + return ServerCapabilitiesCallHierarchyProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesCallHierarchyProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case CallHierarchyOptions: + return marshal(x) + case CallHierarchyRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesCallHierarchyProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 CallHierarchyOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 CallHierarchyRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool CallHierarchyOptions CallHierarchyRegistrationOptions]"} +} + +// ServerCapabilitiesCodeActionProvider the server provides code actions. CodeActionOptions may only be specified if the client states that it supports `codeActionLiteralSupport` in its initial `initialize` request. +type ServerCapabilitiesCodeActionProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesCodeActionProvider[T bool | CodeActionOptions](x T) ServerCapabilitiesCodeActionProvider { + return ServerCapabilitiesCodeActionProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesCodeActionProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case CodeActionOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesCodeActionProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 CodeActionOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool CodeActionOptions]"} +} + +// ServerCapabilitiesColorProvider the server provides color provider support. +type ServerCapabilitiesColorProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesColorProvider[T bool | DocumentColorOptions | DocumentColorRegistrationOptions](x T) ServerCapabilitiesColorProvider { + return ServerCapabilitiesColorProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesColorProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case DocumentColorOptions: + return marshal(x) + case DocumentColorRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesColorProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 DocumentColorOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 DocumentColorRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentColorOptions DocumentColorRegistrationOptions]"} +} + +// ServerCapabilitiesDeclarationProvider the server provides Goto Declaration support. +type ServerCapabilitiesDeclarationProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesDeclarationProvider[T bool | DeclarationOptions | DeclarationRegistrationOptions](x T) ServerCapabilitiesDeclarationProvider { + return ServerCapabilitiesDeclarationProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesDeclarationProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case DeclarationOptions: + return marshal(x) + case DeclarationRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDeclarationProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 DeclarationOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 DeclarationRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DeclarationOptions DeclarationRegistrationOptions]"} +} + +// ServerCapabilitiesDefinitionProvider the server provides goto definition support. +type ServerCapabilitiesDefinitionProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesDefinitionProvider[T bool | DefinitionOptions](x T) ServerCapabilitiesDefinitionProvider { + return ServerCapabilitiesDefinitionProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesDefinitionProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case DefinitionOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDefinitionProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 DefinitionOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DefinitionOptions]"} +} + +// ServerCapabilitiesDiagnosticProvider the server has support for pull model diagnostics. +type ServerCapabilitiesDiagnosticProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesDiagnosticProvider[T DiagnosticOptions | DiagnosticRegistrationOptions](x T) ServerCapabilitiesDiagnosticProvider { + return ServerCapabilitiesDiagnosticProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesDiagnosticProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case DiagnosticOptions: + return marshal(x) + case DiagnosticRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDiagnosticProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 DiagnosticOptions + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 DiagnosticRegistrationOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [DiagnosticOptions DiagnosticRegistrationOptions]"} +} + +// ServerCapabilitiesDocumentFormattingProvider the server provides document formatting. +type ServerCapabilitiesDocumentFormattingProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesDocumentFormattingProvider[T bool | DocumentFormattingOptions](x T) ServerCapabilitiesDocumentFormattingProvider { + return ServerCapabilitiesDocumentFormattingProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesDocumentFormattingProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case DocumentFormattingOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDocumentFormattingProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 DocumentFormattingOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentFormattingOptions]"} +} + +// ServerCapabilitiesDocumentHighlightProvider the server provides document highlight support. +type ServerCapabilitiesDocumentHighlightProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesDocumentHighlightProvider[T bool | DocumentHighlightOptions](x T) ServerCapabilitiesDocumentHighlightProvider { + return ServerCapabilitiesDocumentHighlightProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesDocumentHighlightProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case DocumentHighlightOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDocumentHighlightProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 DocumentHighlightOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentHighlightOptions]"} +} + +// ServerCapabilitiesDocumentRangeFormattingProvider the server provides document range formatting. +type ServerCapabilitiesDocumentRangeFormattingProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesDocumentRangeFormattingProvider[T bool | DocumentRangeFormattingOptions](x T) ServerCapabilitiesDocumentRangeFormattingProvider { + return ServerCapabilitiesDocumentRangeFormattingProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesDocumentRangeFormattingProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case DocumentRangeFormattingOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDocumentRangeFormattingProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 DocumentRangeFormattingOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentRangeFormattingOptions]"} +} + +// ServerCapabilitiesDocumentSymbolProvider the server provides document symbol support. +type ServerCapabilitiesDocumentSymbolProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesDocumentSymbolProvider[T bool | DocumentSymbolOptions](x T) ServerCapabilitiesDocumentSymbolProvider { + return ServerCapabilitiesDocumentSymbolProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesDocumentSymbolProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case DocumentSymbolOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDocumentSymbolProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 DocumentSymbolOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentSymbolOptions]"} +} + +// ServerCapabilitiesFoldingRangeProvider the server provides folding provider support. +type ServerCapabilitiesFoldingRangeProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesFoldingRangeProvider[T bool | FoldingRangeOptions | FoldingRangeRegistrationOptions](x T) ServerCapabilitiesFoldingRangeProvider { + return ServerCapabilitiesFoldingRangeProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesFoldingRangeProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case FoldingRangeOptions: + return marshal(x) + case FoldingRangeRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesFoldingRangeProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 FoldingRangeOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 FoldingRangeRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool FoldingRangeOptions FoldingRangeRegistrationOptions]"} +} + +// ServerCapabilitiesHoverProvider the server provides hover support. +type ServerCapabilitiesHoverProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesHoverProvider[T bool | HoverOptions](x T) ServerCapabilitiesHoverProvider { + return ServerCapabilitiesHoverProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesHoverProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case HoverOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesHoverProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 HoverOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool HoverOptions]"} +} + +// ServerCapabilitiesImplementationProvider the server provides Goto Implementation support. +type ServerCapabilitiesImplementationProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesImplementationProvider[T bool | ImplementationOptions | ImplementationRegistrationOptions](x T) ServerCapabilitiesImplementationProvider { + return ServerCapabilitiesImplementationProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesImplementationProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case ImplementationOptions: + return marshal(x) + case ImplementationRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesImplementationProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 ImplementationOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 ImplementationRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool ImplementationOptions ImplementationRegistrationOptions]"} +} + +// ServerCapabilitiesInlayHintProvider the server provides inlay hints. +type ServerCapabilitiesInlayHintProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesInlayHintProvider[T bool | InlayHintOptions | InlayHintRegistrationOptions](x T) ServerCapabilitiesInlayHintProvider { + return ServerCapabilitiesInlayHintProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesInlayHintProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case InlayHintOptions: + return marshal(x) + case InlayHintRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesInlayHintProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 InlayHintOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 InlayHintRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool InlayHintOptions InlayHintRegistrationOptions]"} +} + +// ServerCapabilitiesInlineCompletionProvider inline completion options used during static registration. 3.18.0 @proposed. +type ServerCapabilitiesInlineCompletionProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesInlineCompletionProvider[T bool | InlineCompletionOptions](x T) ServerCapabilitiesInlineCompletionProvider { + return ServerCapabilitiesInlineCompletionProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesInlineCompletionProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case InlineCompletionOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesInlineCompletionProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 InlineCompletionOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool InlineCompletionOptions]"} +} + +// ServerCapabilitiesInlineValueProvider the server provides inline values. +type ServerCapabilitiesInlineValueProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesInlineValueProvider[T bool | InlineValueOptions | InlineValueRegistrationOptions](x T) ServerCapabilitiesInlineValueProvider { + return ServerCapabilitiesInlineValueProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesInlineValueProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case InlineValueOptions: + return marshal(x) + case InlineValueRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesInlineValueProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 InlineValueOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 InlineValueRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool InlineValueOptions InlineValueRegistrationOptions]"} +} + +// ServerCapabilitiesLinkedEditingRangeProvider the server provides linked editing range support. +type ServerCapabilitiesLinkedEditingRangeProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesLinkedEditingRangeProvider[T bool | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions](x T) ServerCapabilitiesLinkedEditingRangeProvider { + return ServerCapabilitiesLinkedEditingRangeProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesLinkedEditingRangeProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case LinkedEditingRangeOptions: + return marshal(x) + case LinkedEditingRangeRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesLinkedEditingRangeProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 LinkedEditingRangeOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 LinkedEditingRangeRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool LinkedEditingRangeOptions LinkedEditingRangeRegistrationOptions]"} +} + +// ServerCapabilitiesMonikerProvider the server provides moniker support. +type ServerCapabilitiesMonikerProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesMonikerProvider[T bool | MonikerOptions | MonikerRegistrationOptions](x T) ServerCapabilitiesMonikerProvider { + return ServerCapabilitiesMonikerProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesMonikerProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case MonikerOptions: + return marshal(x) + case MonikerRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesMonikerProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 MonikerOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 MonikerRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool MonikerOptions MonikerRegistrationOptions]"} +} + +// ServerCapabilitiesNotebookDocumentSync defines how notebook documents are synced. +type ServerCapabilitiesNotebookDocumentSync struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesNotebookDocumentSync[T NotebookDocumentSyncOptions | NotebookDocumentSyncRegistrationOptions](x T) ServerCapabilitiesNotebookDocumentSync { + return ServerCapabilitiesNotebookDocumentSync{ + Value: x, + } +} + +func (t ServerCapabilitiesNotebookDocumentSync) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case NotebookDocumentSyncOptions: + return marshal(x) + case NotebookDocumentSyncRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesNotebookDocumentSync) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 NotebookDocumentSyncOptions + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 NotebookDocumentSyncRegistrationOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [NotebookDocumentSyncOptions NotebookDocumentSyncRegistrationOptions]"} +} + +// ServerCapabilitiesReferencesProvider the server provides find references support. +type ServerCapabilitiesReferencesProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesReferencesProvider[T bool | ReferenceOptions](x T) ServerCapabilitiesReferencesProvider { + return ServerCapabilitiesReferencesProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesReferencesProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case ReferenceOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesReferencesProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 ReferenceOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool ReferenceOptions]"} +} + +// ServerCapabilitiesRenameProvider the server provides rename support. RenameOptions may only be specified if the client states that it +// supports `prepareSupport` in its initial `initialize` request. +type ServerCapabilitiesRenameProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesRenameProvider[T bool | RenameOptions](x T) ServerCapabilitiesRenameProvider { + return ServerCapabilitiesRenameProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesRenameProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case RenameOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesRenameProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 RenameOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool RenameOptions]"} +} + +// ServerCapabilitiesSelectionRangeProvider the server provides selection range support. +type ServerCapabilitiesSelectionRangeProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesSelectionRangeProvider[T bool | SelectionRangeOptions | SelectionRangeRegistrationOptions](x T) ServerCapabilitiesSelectionRangeProvider { + return ServerCapabilitiesSelectionRangeProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesSelectionRangeProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case SelectionRangeOptions: + return marshal(x) + case SelectionRangeRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesSelectionRangeProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 SelectionRangeOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 SelectionRangeRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool SelectionRangeOptions SelectionRangeRegistrationOptions]"} +} + +// ServerCapabilitiesSemanticTokensProvider the server provides semantic tokens support. +type ServerCapabilitiesSemanticTokensProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesSemanticTokensProvider[T SemanticTokensOptions | SemanticTokensRegistrationOptions](x T) ServerCapabilitiesSemanticTokensProvider { + return ServerCapabilitiesSemanticTokensProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesSemanticTokensProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case SemanticTokensOptions: + return marshal(x) + case SemanticTokensRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesSemanticTokensProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 SemanticTokensOptions + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 SemanticTokensRegistrationOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [SemanticTokensOptions SemanticTokensRegistrationOptions]"} +} + +// ServerCapabilitiesTextDocumentSync defines how text documents are synced. Is either a detailed structure defining each notification or for backwards compatibility the TextDocumentSyncKind number. +type ServerCapabilitiesTextDocumentSync struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesTextDocumentSync[T TextDocumentSyncOptions | TextDocumentSyncKind](x T) ServerCapabilitiesTextDocumentSync { + return ServerCapabilitiesTextDocumentSync{ + Value: x, + } +} + +func (t ServerCapabilitiesTextDocumentSync) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case TextDocumentSyncOptions: + return marshal(x) + case TextDocumentSyncKind: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesTextDocumentSync) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 TextDocumentSyncOptions + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 TextDocumentSyncKind + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextDocumentSyncOptions TextDocumentSyncKind]"} +} + +// ServerCapabilitiesTypeDefinitionProvider the server provides Goto Type Definition support. +type ServerCapabilitiesTypeDefinitionProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesTypeDefinitionProvider[T bool | TypeDefinitionOptions | TypeDefinitionRegistrationOptions](x T) ServerCapabilitiesTypeDefinitionProvider { + return ServerCapabilitiesTypeDefinitionProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesTypeDefinitionProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case TypeDefinitionOptions: + return marshal(x) + case TypeDefinitionRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesTypeDefinitionProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 TypeDefinitionOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 TypeDefinitionRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool TypeDefinitionOptions TypeDefinitionRegistrationOptions]"} +} + +// ServerCapabilitiesTypeHierarchyProvider the server provides type hierarchy support. +type ServerCapabilitiesTypeHierarchyProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesTypeHierarchyProvider[T bool | TypeHierarchyOptions | TypeHierarchyRegistrationOptions](x T) ServerCapabilitiesTypeHierarchyProvider { + return ServerCapabilitiesTypeHierarchyProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesTypeHierarchyProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case TypeHierarchyOptions: + return marshal(x) + case TypeHierarchyRegistrationOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesTypeHierarchyProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 TypeHierarchyOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 TypeHierarchyRegistrationOptions + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool TypeHierarchyOptions TypeHierarchyRegistrationOptions]"} +} + +// ServerCapabilitiesWorkspaceSymbolProvider the server provides workspace symbol support. +type ServerCapabilitiesWorkspaceSymbolProvider struct { + Value any `json:"value"` +} + +func NewServerCapabilitiesWorkspaceSymbolProvider[T bool | WorkspaceSymbolOptions](x T) ServerCapabilitiesWorkspaceSymbolProvider { + return ServerCapabilitiesWorkspaceSymbolProvider{ + Value: x, + } +} + +func (t ServerCapabilitiesWorkspaceSymbolProvider) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case WorkspaceSymbolOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesWorkspaceSymbolProvider) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 WorkspaceSymbolOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool WorkspaceSymbolOptions]"} +} + +// SignatureInformationDocumentation the human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. +type SignatureInformationDocumentation struct { + Value any `json:"value"` +} + +func NewSignatureInformationDocumentation[T string | MarkupContent](x T) SignatureInformationDocumentation { + return SignatureInformationDocumentation{ + Value: x, + } +} + +func (t SignatureInformationDocumentation) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case MarkupContent: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *SignatureInformationDocumentation) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// TextDocumentCodeActionResult a request to provide commands for the given text document and range. +type TextDocumentCodeActionResult struct { + Value any `json:"value"` +} + +func NewTextDocumentCodeActionResult[T Command | CodeAction](x T) TextDocumentCodeActionResult { + return TextDocumentCodeActionResult{ + Value: x, + } +} + +func (t TextDocumentCodeActionResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Command: + return marshal(x) + case CodeAction: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentCodeActionResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Command + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 CodeAction + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} +} + +// TextDocumentCompletionResult request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, +// `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. +type TextDocumentCompletionResult struct { + Value any `json:"value"` +} + +func NewTextDocumentCompletionResult[T []CompletionItem | CompletionList](x T) TextDocumentCompletionResult { + return TextDocumentCompletionResult{ + Value: x, + } +} + +func (t TextDocumentCompletionResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case []CompletionItem: + return marshal(x) + case CompletionList: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentCompletionResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 []CompletionItem + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 CompletionList + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} +} + +// TextDocumentDeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a +// typed array of DeclarationLink or a Thenable that resolves to such. +type TextDocumentDeclarationResult struct { + Value any `json:"value"` +} + +func NewTextDocumentDeclarationResult[T Declaration | []DeclarationLink](x T) TextDocumentDeclarationResult { + return TextDocumentDeclarationResult{ + Value: x, + } +} + +func (t TextDocumentDeclarationResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Declaration: + return marshal(x) + case []DeclarationLink: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentDeclarationResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Declaration + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []DeclarationLink + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Declaration []DeclarationLink]"} +} + +// TextDocumentDefinitionResult a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed +// array of DefinitionLink or a Thenable that resolves to such. +type TextDocumentDefinitionResult struct { + Value any `json:"value"` +} + +func NewTextDocumentDefinitionResult[T Definition | []DefinitionLink](x T) TextDocumentDefinitionResult { + return TextDocumentDefinitionResult{ + Value: x, + } +} + +func (t TextDocumentDefinitionResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Definition: + return marshal(x) + case []DefinitionLink: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentDefinitionResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Definition + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + +// TextDocumentDocumentSymbolResult a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that +// resolves to such. +type TextDocumentDocumentSymbolResult struct { + Value any `json:"value"` +} + +func NewTextDocumentDocumentSymbolResult[T []SymbolInformation | []DocumentSymbol](x T) TextDocumentDocumentSymbolResult { + return TextDocumentDocumentSymbolResult{ + Value: x, + } +} + +func (t TextDocumentDocumentSymbolResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case []SymbolInformation: + return marshal(x) + case []DocumentSymbol: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentDocumentSymbolResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 []SymbolInformation + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []DocumentSymbol + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} +} + +// TextDocumentEditEdits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. +type TextDocumentEditEdits struct { + Value any `json:"value"` +} + +func NewTextDocumentEditEdits[T TextEdit | AnnotatedTextEdit](x T) TextDocumentEditEdits { + return TextDocumentEditEdits{ + Value: x, + } +} + +func (t TextDocumentEditEdits) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case TextEdit: + return marshal(x) + case AnnotatedTextEdit: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentEditEdits) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 TextEdit + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 AnnotatedTextEdit + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextEdit AnnotatedTextEdit]"} +} + +// TextDocumentImplementationResult a request to resolve the implementation locations of a symbol at a given text document position. The +// request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. +type TextDocumentImplementationResult struct { + Value any `json:"value"` +} + +func NewTextDocumentImplementationResult[T Definition | []DefinitionLink](x T) TextDocumentImplementationResult { + return TextDocumentImplementationResult{ + Value: x, + } +} + +func (t TextDocumentImplementationResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Definition: + return marshal(x) + case []DefinitionLink: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentImplementationResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Definition + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + +// TextDocumentInlineCompletionResult a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentInlineCompletionResult struct { + Value any `json:"value"` +} + +func NewTextDocumentInlineCompletionResult[T InlineCompletionList | []InlineCompletionItem](x T) TextDocumentInlineCompletionResult { + return TextDocumentInlineCompletionResult{ + Value: x, + } +} + +func (t TextDocumentInlineCompletionResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case InlineCompletionList: + return marshal(x) + case []InlineCompletionItem: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentInlineCompletionResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 InlineCompletionList + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []InlineCompletionItem + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} +} + +// TextDocumentSemanticTokensFullDeltaResult. +// +// @since 3.16.0 +type TextDocumentSemanticTokensFullDeltaResult struct { + Value any `json:"value"` +} + +func NewTextDocumentSemanticTokensFullDeltaResult[T SemanticTokens | SemanticTokensDelta](x T) TextDocumentSemanticTokensFullDeltaResult { + return TextDocumentSemanticTokensFullDeltaResult{ + Value: x, + } +} + +func (t TextDocumentSemanticTokensFullDeltaResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case SemanticTokens: + return marshal(x) + case SemanticTokensDelta: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentSemanticTokensFullDeltaResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 SemanticTokens + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 SemanticTokensDelta + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} +} + +// TextDocumentSyncOptionsSave if present save notifications are sent to the server. If omitted the notification should not be sent. +type TextDocumentSyncOptionsSave struct { + Value any `json:"value"` +} + +func NewTextDocumentSyncOptionsSave[T bool | SaveOptions](x T) TextDocumentSyncOptionsSave { + return TextDocumentSyncOptionsSave{ + Value: x, + } +} + +func (t TextDocumentSyncOptionsSave) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case bool: + return marshal(x) + case SaveOptions: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentSyncOptionsSave) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 bool + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 SaveOptions + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool SaveOptions]"} +} + +// TextDocumentTypeDefinitionResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. +type TextDocumentTypeDefinitionResult struct { + Value any `json:"value"` +} + +func NewTextDocumentTypeDefinitionResult[T Definition | []DefinitionLink](x T) TextDocumentTypeDefinitionResult { + return TextDocumentTypeDefinitionResult{ + Value: x, + } +} + +func (t TextDocumentTypeDefinitionResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Definition: + return marshal(x) + case []DefinitionLink: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentTypeDefinitionResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Definition + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + +// WorkspaceEditDocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are +// either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. +type WorkspaceEditDocumentChanges struct { + Value any `json:"value"` +} + +func NewWorkspaceEditDocumentChanges[T TextDocumentEdit | CreateFile | RenameFile | DeleteFile](x T) WorkspaceEditDocumentChanges { + return WorkspaceEditDocumentChanges{ + Value: x, + } +} + +func (t WorkspaceEditDocumentChanges) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case TextDocumentEdit: + return marshal(x) + case CreateFile: + return marshal(x) + case RenameFile: + return marshal(x) + case DeleteFile: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceEditDocumentChanges) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 TextDocumentEdit + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 CreateFile + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + var h2 RenameFile + if err := unmarshal(x, &h2); err == nil { + t.Value = h2 + return nil + } + var h3 DeleteFile + if err := unmarshal(x, &h3); err == nil { + t.Value = h3 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextDocumentEdit CreateFile RenameFile DeleteFile]"} +} + +// WorkspaceFoldersServerCapabilitiesChangeNotifications whether the server wants to receive workspace folder change notifications. If a string is provided the string is treated as an ID under which the notification is registered on the client side. The ID can be used to unregister for these events using the `client/unregisterCapability` request. +type WorkspaceFoldersServerCapabilitiesChangeNotifications struct { + Value any `json:"value"` +} + +func NewWorkspaceFoldersServerCapabilitiesChangeNotifications[T string | bool](x T) WorkspaceFoldersServerCapabilitiesChangeNotifications { + return WorkspaceFoldersServerCapabilitiesChangeNotifications{ + Value: x, + } +} + +func (t WorkspaceFoldersServerCapabilitiesChangeNotifications) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case string: + return marshal(x) + case bool: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceFoldersServerCapabilitiesChangeNotifications) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 string + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 bool + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string bool]"} +} + +// WorkspaceSymbolLocation the location of the symbol. Whether a server is allowed to return a location without a range depends +// on the client capability `workspace.symbol.resolveSupport`. See SymbolInformation#location for +// more details. +// +// @since 3.17.0 +type WorkspaceSymbolLocation struct { + Value any `json:"value"` +} + +func NewWorkspaceSymbolLocation[T Location | LocationURIOnly](x T) WorkspaceSymbolLocation { + return WorkspaceSymbolLocation{ + Value: x, + } +} + +func (t WorkspaceSymbolLocation) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case Location: + return marshal(x) + case LocationURIOnly: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceSymbolLocation) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 Location + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 LocationURIOnly + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Location LocationURIOnly]"} +} + +// WorkspaceSymbolResult a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. +// The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. +// +// @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. +type WorkspaceSymbolResult struct { + Value any `json:"value"` +} + +func NewWorkspaceSymbolResult[T []SymbolInformation | []WorkspaceSymbol](x T) WorkspaceSymbolResult { + return WorkspaceSymbolResult{ + Value: x, + } +} + +func (t WorkspaceSymbolResult) MarshalJSON() ([]byte, error) { + switch x := t.Value.(type) { + case []SymbolInformation: + return marshal(x) + case []WorkspaceSymbol: + return marshal(x) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceSymbolResult) UnmarshalJSON(x []byte) error { + if string(x) == "null" { + t.Value = nil + return nil + } + var h0 []SymbolInformation + if err := unmarshal(x, &h0); err == nil { + t.Value = h0 + return nil + } + var h1 []WorkspaceSymbol + if err := unmarshal(x, &h1); err == nil { + t.Value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []WorkspaceSymbol]"} +} diff --git a/protocol/window.go b/protocol/window.go new file mode 100644 index 00000000..6527f4d0 --- /dev/null +++ b/protocol/window.go @@ -0,0 +1,110 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "go.lsp.dev/uri" +) + +// MessageType the message type. +type MessageType uint32 + +const ( + // ErrorMessageType an error message. + ErrorMessageType MessageType = 1 + + // WarningMessageType a warning message. + WarningMessageType MessageType = 2 + + // InfoMessageType an information message. + InfoMessageType MessageType = 3 + + // LogMessageType a log message. + LogMessageType MessageType = 4 + + // DebugMessageType a debug message. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + DebugMessageType MessageType = 5 +) + +type WorkDoneProgressCreateParams struct { + // Token the token to be used to report progress. + Token ProgressToken `json:"token"` +} + +type WorkDoneProgressCancelParams struct { + // Token the token to be used to report progress. + Token ProgressToken `json:"token"` +} + +// ShowDocumentParams params to show a resource in the UI. +// +// @since 3.16.0 +type ShowDocumentParams struct { + // URI the uri to show. + // + // @since 3.16.0 + URI uri.URI `json:"uri"` + + // External indicates to show the resource in an external program. To show, for example, `https://code.visualstudio.com/` in the default WEB browser set `external` to `true`. + // + // @since 3.16.0 + External bool `json:"external,omitempty"` + + // TakeFocus an optional property to indicate whether the editor showing the document should take focus or not. Clients might ignore this property if an external program is started. + // + // @since 3.16.0 + TakeFocus bool `json:"takeFocus,omitempty"` + + // Selection an optional selection range if the document is a text document. Clients might ignore the property if + // an external program is started or the file is not a text file. + // + // @since 3.16.0 + Selection *Range `json:"selection,omitempty"` +} + +// ShowDocumentResult the result of a showDocument request. +// +// @since 3.16.0 +type ShowDocumentResult struct { + // Success a boolean indicating if the show was successful. + // + // @since 3.16.0 + Success bool `json:"success"` +} + +// ShowMessageParams the parameters of a notification message. +type ShowMessageParams struct { + // Type the message type. See MessageType. + Type MessageType `json:"type"` + + // Message the actual message. + Message string `json:"message"` +} + +type MessageActionItem struct { + // Title a short title like 'Retry', 'Open Log' etc. + Title string `json:"title"` +} + +type ShowMessageRequestParams struct { + // Type the message type. See MessageType. + Type MessageType `json:"type"` + + // Message the actual message. + Message string `json:"message"` + + // Actions the message action items to present. + Actions []MessageActionItem `json:"actions,omitempty"` +} + +// LogMessageParams the log message parameters. +type LogMessageParams struct { + // Type the message type. See MessageType. + Type MessageType `json:"type"` + + // Message the actual message. + Message string `json:"message"` +} diff --git a/protocol/workspace.go b/protocol/workspace.go new file mode 100644 index 00000000..151d1774 --- /dev/null +++ b/protocol/workspace.go @@ -0,0 +1,475 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "go.lsp.dev/uri" +) + +// FileChangeType the file event type. +type FileChangeType uint32 + +const ( + // CreatedFileChangeType the file got created. + CreatedFileChangeType FileChangeType = 1 + + // ChangedFileChangeType the file got changed. + ChangedFileChangeType FileChangeType = 2 + + // DeletedFileChangeType the file got deleted. + DeletedFileChangeType FileChangeType = 3 +) + +type WatchKind uint32 + +const ( + // CreateWatchKind interested in create events. + CreateWatchKind WatchKind = 1 + + // ChangeWatchKind interested in change events. + ChangeWatchKind WatchKind = 2 + + // DeleteWatchKind interested in delete events. + DeleteWatchKind WatchKind = 4 +) + +// FileOperationPatternKind a pattern kind describing if a glob pattern matches a file a folder or both. +// +// @since 3.16.0 +type FileOperationPatternKind string + +const ( + // FileFileOperationPatternKind the pattern matches a file only. + FileFileOperationPatternKind FileOperationPatternKind = "file" + + // FolderFileOperationPatternKind the pattern matches a folder only. + FolderFileOperationPatternKind FileOperationPatternKind = "folder" +) + +// WorkspaceFolder a workspace folder inside a client. +type WorkspaceFolder struct { + // URI the associated URI for this workspace folder. + URI uri.URI `json:"uri"` + + // Name the name of the workspace folder. Used to refer to this workspace folder in the user interface. + Name string `json:"name"` +} + +// WorkspaceFoldersChangeEvent the workspace folder change event. +type WorkspaceFoldersChangeEvent struct { + // Added the array of added workspace folders. + Added []WorkspaceFolder `json:"added"` + + // Removed the array of the removed workspace folders. + Removed []WorkspaceFolder `json:"removed"` +} + +// DidChangeWorkspaceFoldersParams the parameters of a `workspace/didChangeWorkspaceFolders` notification. +type DidChangeWorkspaceFoldersParams struct { + // Event the actual workspace folder change event. + Event WorkspaceFoldersChangeEvent `json:"event"` +} + +type ConfigurationItem struct { + // ScopeURI the scope to get the configuration section for. + ScopeURI uri.URI `json:"scopeUri,omitempty"` + + // Section the configuration section asked for. + Section string `json:"section,omitempty"` +} + +// ConfigurationParams the parameters of a configuration request. +type ConfigurationParams struct { + Items []ConfigurationItem `json:"items"` +} + +// FileCreate represents information on a file/folder create. +// +// @since 3.16.0 +type FileCreate struct { + // URI a file:// URI for the location of the file/folder being created. + // + // @since 3.16.0 + URI string `json:"uri"` +} + +// CreateFilesParams the parameters sent in notifications/requests for user-initiated creation of files. +// +// @since 3.16.0 +type CreateFilesParams struct { + // Files an array of all files/folders created in this operation. + // + // @since 3.16.0 + Files []FileCreate `json:"files"` +} + +// ResourceOperation a generic resource operation. +type ResourceOperation struct { + // Kind the resource operation kind. + Kind string `json:"kind"` + + // AnnotationID an optional annotation identifier describing the operation. + AnnotationID *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` +} + +// DeleteFileOptions delete file options. +type DeleteFileOptions struct { + // Recursive delete the content recursively if a folder is denoted. + Recursive bool `json:"recursive,omitempty"` + + // IgnoreIfNotExists ignore the operation if the file doesn't exist. + IgnoreIfNotExists bool `json:"ignoreIfNotExists,omitempty"` +} + +// DeleteFile delete file operation. +type DeleteFile struct { + // extends + ResourceOperation + + // URI the file to delete. + URI DocumentURI `json:"uri"` + + // Options delete options. + Options *DeleteFileOptions `json:"options,omitempty"` +} + +// RenameFileOptions rename file options. +type RenameFileOptions struct { + // Overwrite overwrite target if existing. Overwrite wins over `ignoreIfExists`. + Overwrite bool `json:"overwrite,omitempty"` + + // IgnoreIfExists ignores if target exists. + IgnoreIfExists bool `json:"ignoreIfExists,omitempty"` +} + +// RenameFile rename file operation. +type RenameFile struct { + // extends + ResourceOperation + + // OldURI the old (existing) location. + OldURI DocumentURI `json:"oldUri"` + + // NewURI the new location. + NewURI DocumentURI `json:"newUri"` + + // Options rename options. + Options *RenameFileOptions `json:"options,omitempty"` +} + +// CreateFileOptions options to create a file. +type CreateFileOptions struct { + // Overwrite overwrite existing file. Overwrite wins over `ignoreIfExists`. + Overwrite bool `json:"overwrite,omitempty"` + + // IgnoreIfExists ignore if exists. + IgnoreIfExists bool `json:"ignoreIfExists,omitempty"` +} + +// CreateFile create file operation. +type CreateFile struct { + // extends + ResourceOperation + + // URI the resource to create. + URI DocumentURI `json:"uri"` + + // Options additional options. + Options *CreateFileOptions `json:"options,omitempty"` +} + +// FileOperationPatternOptions matching options for the file operation pattern. +// +// @since 3.16.0 +type FileOperationPatternOptions struct { + // IgnoreCase the pattern should be matched ignoring casing. + // + // @since 3.16.0 + IgnoreCase bool `json:"ignoreCase,omitempty"` +} + +// FileOperationPattern a pattern to describe in which file operation requests or notifications the server is interested in receiving. +// +// @since 3.16.0 +type FileOperationPattern struct { + // Glob the glob pattern to match. Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`). + // + // @since 3.16.0 + Glob string `json:"glob"` + + // Matches whether to match files or folders with this pattern. Matches both if undefined. + // + // @since 3.16.0 + Matches FileOperationPatternKind `json:"matches,omitempty"` + + // Options additional options used during matching. + // + // @since 3.16.0 + Options *FileOperationPatternOptions `json:"options,omitempty"` +} + +// FileOperationFilter a filter to describe in which file operation requests or notifications the server is interested in receiving. +// +// @since 3.16.0 +type FileOperationFilter struct { + // Scheme a Uri scheme like `file` or `untitled`. + // + // @since 3.16.0 + Scheme string `json:"scheme,omitempty"` + + // Pattern the actual file operation pattern. + // + // @since 3.16.0 + Pattern FileOperationPattern `json:"pattern"` +} + +// FileOperationRegistrationOptions the options to register for file operations. +// +// @since 3.16.0 +type FileOperationRegistrationOptions struct { + // Filters the actual filters. + // + // @since 3.16.0 + Filters []FileOperationFilter `json:"filters"` +} + +// FileRename represents information on a file/folder rename. +// +// @since 3.16.0 +type FileRename struct { + // OldURI a file:// URI for the original location of the file/folder being renamed. + // + // @since 3.16.0 + OldURI string `json:"oldUri"` + + // NewURI a file:// URI for the new location of the file/folder being renamed. + // + // @since 3.16.0 + NewURI string `json:"newUri"` +} + +// RenameFilesParams the parameters sent in notifications/requests for user-initiated renames of files. +// +// @since 3.16.0 +type RenameFilesParams struct { + // Files an array of all files/folders renamed in this operation. When a folder is renamed, only the folder will be included, and not its children. + // + // @since 3.16.0 + Files []FileRename `json:"files"` +} + +// FileDelete represents information on a file/folder delete. +// +// @since 3.16.0 +type FileDelete struct { + // URI a file:// URI for the location of the file/folder being deleted. + // + // @since 3.16.0 + URI string `json:"uri"` +} + +// DeleteFilesParams the parameters sent in notifications/requests for user-initiated deletes of files. +// +// @since 3.16.0 +type DeleteFilesParams struct { + // Files an array of all files/folders deleted in this operation. + // + // @since 3.16.0 + Files []FileDelete `json:"files"` +} + +type DidChangeConfigurationClientCapabilities struct { + // DynamicRegistration did change configuration notification supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +type DidChangeWatchedFilesClientCapabilities struct { + // DynamicRegistration did change watched files notification supports dynamic registration. Please note that the current protocol doesn't support static configuration for file changes from the server side. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // RelativePatternSupport whether the client has support for RelativePattern relative pattern or not. + RelativePatternSupport bool `json:"relativePatternSupport,omitempty"` +} + +// ClientSymbolKindOptions. +// +// @since 3.18.0 proposed +type ClientSymbolKindOptions struct { + // ValueSet the symbol kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. If this property is not present the client only supports the symbol kinds from `File` to `Array` as defined in the initial version of the protocol. + // + // @since 3.18.0 proposed + ValueSet []SymbolKind `json:"valueSet,omitempty"` +} + +// ClientSymbolTagOptions. +// +// @since 3.18.0 proposed +type ClientSymbolTagOptions struct { + // ValueSet the tags supported by the client. + // + // @since 3.18.0 proposed + ValueSet []SymbolTag `json:"valueSet"` +} + +// ClientSymbolResolveOptions. +// +// @since 3.18.0 proposed +type ClientSymbolResolveOptions struct { + // Properties the properties that a client can resolve lazily. Usually `location.range`. + // + // @since 3.18.0 proposed + Properties []string `json:"properties"` +} + +// WorkspaceSymbolClientCapabilities client capabilities for a WorkspaceSymbolRequest. +type WorkspaceSymbolClientCapabilities struct { + // DynamicRegistration symbol request supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // SymbolKind specific capabilities for the `SymbolKind` in the `workspace/symbol` request. + SymbolKind *ClientSymbolKindOptions `json:"symbolKind,omitempty"` + + // TagSupport the client supports tags on `SymbolInformation`. Clients supporting tags have to handle unknown tags + // gracefully. + TagSupport *ClientSymbolTagOptions `json:"tagSupport,omitempty"` + + // ResolveSupport the client support partial workspace symbols. The client will send the request `workspaceSymbol/resolve` to the server to resolve additional properties. + ResolveSupport *ClientSymbolResolveOptions `json:"resolveSupport,omitempty"` +} + +// ExecuteCommandClientCapabilities the client capabilities of a ExecuteCommandRequest. +type ExecuteCommandClientCapabilities struct { + // DynamicRegistration execute command supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +type WorkspaceFoldersServerCapabilities struct { + // Supported the server has support for workspace folders. + Supported bool `json:"supported,omitempty"` + + // ChangeNotifications whether the server wants to receive workspace folder change notifications. If a string is provided the string is treated as an ID under which the notification is registered on the client side. The ID can be used to unregister for these events using the `client/unregisterCapability` request. + ChangeNotifications WorkspaceFoldersServerCapabilitiesChangeNotifications `json:"changeNotifications,omitempty"` +} + +// DidChangeConfigurationParams the parameters of a change configuration notification. +type DidChangeConfigurationParams struct { + // Settings the actual changed settings. + Settings any `json:"settings"` +} + +type DidChangeConfigurationRegistrationOptions struct { + Section DidChangeConfigurationRegistrationOptionsSection `json:"section,omitempty"` +} + +// FileEvent an event describing a file change. +type FileEvent struct { + // URI the file's uri. + URI DocumentURI `json:"uri"` + + // Type the change type. + Type FileChangeType `json:"type"` +} + +// DidChangeWatchedFilesParams the watched files change notification's parameters. +type DidChangeWatchedFilesParams struct { + // Changes the actual file events. + Changes []FileEvent `json:"changes"` +} + +type FileSystemWatcher struct { + // GlobPattern the glob pattern to watch. See GlobPattern glob pattern for more detail. 3.17.0 support for relative + // patterns. + GlobPattern GlobPattern `json:"globPattern"` + + // Kind the kind of events of interest. If omitted it defaults to WatchKind.Create | WatchKind.Change | WatchKind.Delete which is . + Kind WatchKind `json:"kind,omitempty"` +} + +// DidChangeWatchedFilesRegistrationOptions describe options to be used when registered for text document change events. +type DidChangeWatchedFilesRegistrationOptions struct { + // Watchers the watchers to register. + Watchers []FileSystemWatcher `json:"watchers"` +} + +// WorkspaceSymbolParams the parameters of a WorkspaceSymbolRequest. +type WorkspaceSymbolParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // Query a query string to filter symbols by. Clients may send an empty string here to request all symbols. + Query string `json:"query"` +} + +// WorkspaceSymbol a special workspace symbol that supports locations without a range. See also SymbolInformation. +// +// @since 3.17.0 +type WorkspaceSymbol struct { + // extends + BaseSymbolInformation + + // Location the location of the symbol. Whether a server is allowed to return a location without a range depends + // on the client capability `workspace.symbol.resolveSupport`. See SymbolInformation#location for + // more details. + // + // @since 3.17.0 + Location WorkspaceSymbolLocation `json:"location"` + + // Data a data entry field that is preserved on a workspace symbol between a workspace symbol request and a workspace symbol resolve request. + // + // @since 3.17.0 + Data any `json:"data,omitempty"` +} + +// WorkspaceSymbolRegistrationOptions registration options for a WorkspaceSymbolRequest. +type WorkspaceSymbolRegistrationOptions struct { + // extends + WorkspaceSymbolOptions +} + +// ApplyWorkspaceEditParams the parameters passed via an apply workspace edit request. +type ApplyWorkspaceEditParams struct { + // Label an optional label of the workspace edit. This label is presented in the user interface for example on an undo stack to undo the workspace edit. + Label string `json:"label,omitempty"` + + // Edit the edits to apply. + Edit WorkspaceEdit `json:"edit"` +} + +// ApplyWorkspaceEditResult the result returned from the apply workspace edit request. 3.17 renamed from ApplyWorkspaceEditResponse. +// +// @since 3.17 renamed from ApplyWorkspaceEditResponse +type ApplyWorkspaceEditResult struct { + // Applied indicates whether the edit was applied or not. + // + // @since 3.17 renamed from ApplyWorkspaceEditResponse + Applied bool `json:"applied"` + + // FailureReason an optional textual description for why the edit was not applied. This may be used by the server for + // diagnostic logging or to provide a suitable error for a request that triggered the edit. + // + // @since 3.17 renamed from ApplyWorkspaceEditResponse + FailureReason string `json:"failureReason,omitempty"` + + // FailedChange depending on the client's failure handling strategy `failedChange` might contain the index of the change that failed. This property is only available if the client signals a `failureHandlingStrategy` in its client capabilities. + // + // @since 3.17 renamed from ApplyWorkspaceEditResponse + FailedChange uint32 `json:"failedChange,omitempty"` +} + +// RelativePattern a relative pattern is a helper to construct glob patterns that are matched relatively to a base URI. +// The common value for a `baseUri` is a workspace folder root, but it can be another absolute URI as well. +// +// @since 3.17.0 +type RelativePattern struct { + // BaseURI a workspace folder or a base URI to which this pattern will be matched against relatively. + // + // @since 3.17.0 + BaseURI RelativePatternBaseURI `json:"baseUri"` + + // Pattern the actual glob pattern;. + // + // @since 3.17.0 + Pattern Pattern `json:"pattern"` +} diff --git a/server.go b/server.go index 1abb8464..fb7e693e 100644 --- a/server.go +++ b/server.go @@ -8,9 +8,11 @@ import ( "context" "fmt" + "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" + "go.lsp.dev/pkg/xcontext" ) // ServerDispatcher returns a Server that dispatches LSP requests across the @@ -28,7 +30,7 @@ func ServerDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Server { func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := context.WithoutCancel(ctx) + xctx := xcontext.Detach(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -40,8 +42,8 @@ func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { // TODO: This code is wrong, it ignores handler and assumes non standard // request handles everything // non standard request should just be a layered handler. - var params any - if err := unmarshal(req.Params(), ¶ms); err != nil { + var params interface{} + if err := json.Unmarshal(req.Params(), ¶ms); err != nil { return replyParseError(ctx, reply, err) } @@ -61,31 +63,42 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := newDecoder(bytes.NewReader(req.Params())) + dec := json.NewDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodServerProgress: // notification - defer logger.Debug(MethodServerProgress, zap.Error(err)) + case MethodInitialize: // request + defer logger.Debug(MethodInitialize, zap.Error(err)) - var params ProgressParams + var params InitializeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.Progress(ctx, ¶ms) + resp, err := server.Initialize(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodSetTrace: // notification - defer logger.Debug(MethodSetTrace, zap.Error(err)) + case MethodInitialized: // notification + defer logger.Debug(MethodInitialized, zap.Error(err)) - var params SetTraceParams + var params InitializedParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.SetTrace(ctx, ¶ms) + err := server.Initialized(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodShutdown: // request + defer logger.Debug(MethodShutdown, zap.Error(err)) + + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } + + err := server.Shutdown(ctx) return true, reply(ctx, nil, err) @@ -100,135 +113,147 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodInitialized: // notification - defer logger.Debug(MethodInitialized, zap.Error(err)) + case MethodWorkDoneProgressCancel: // notification + defer logger.Debug(MethodWorkDoneProgressCancel, zap.Error(err)) - var params InitializedParams + var params WorkDoneProgressCancelParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.Initialized(ctx, ¶ms) + err := server.WorkDoneProgressCancel(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodNotebookDocumentDidChange: // notification - defer logger.Debug(MethodNotebookDocumentDidChange, zap.Error(err)) + case MethodLogTrace: // notification + defer logger.Debug(MethodLogTrace, zap.Error(err)) - var params DidChangeNotebookDocumentParams + var params LogTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidChange(ctx, ¶ms) + err := server.LogTrace(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodNotebookDocumentDidClose: // notification - defer logger.Debug(MethodNotebookDocumentDidClose, zap.Error(err)) + case MethodSetTrace: // notification + defer logger.Debug(MethodSetTrace, zap.Error(err)) - var params DidCloseNotebookDocumentParams + var params SetTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidClose(ctx, ¶ms) + err := server.SetTrace(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodNotebookDocumentDidOpen: // notification - defer logger.Debug(MethodNotebookDocumentDidOpen, zap.Error(err)) + case MethodTextDocumentCodeAction: // request + defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) - var params DidOpenNotebookDocumentParams + var params CodeActionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidOpen(ctx, ¶ms) + resp, err := server.CodeAction(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodNotebookDocumentDidSave: // notification - defer logger.Debug(MethodNotebookDocumentDidSave, zap.Error(err)) + case MethodTextDocumentCodeLens: // request + defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) - var params DidSaveNotebookDocumentParams + var params CodeLensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidSave(ctx, ¶ms) + resp, err := server.CodeLens(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentDidChange: // notification - defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) + case MethodCodeLensResolve: // request + defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) - var params DidChangeTextDocumentParams + var params CodeLens if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidChange(ctx, ¶ms) + resp, err := server.CodeLensResolve(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentDidClose: // notification - defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) + case MethodTextDocumentColorPresentation: // request + defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) - var params DidCloseTextDocumentParams + var params ColorPresentationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidClose(ctx, ¶ms) + resp, err := server.ColorPresentation(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentDidOpen: // notification - defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) + case MethodTextDocumentCompletion: // request + defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) - var params DidOpenTextDocumentParams + var params CompletionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidOpen(ctx, ¶ms) + resp, err := server.Completion(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentDidSave: // notification - defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) + case MethodCompletionItemResolve: // request + defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) - var params DidSaveTextDocumentParams + var params CompletionItem if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidSave(ctx, ¶ms) + resp, err := server.CompletionResolve(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentWillSave: // notification - defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) + case MethodTextDocumentDeclaration: // request + defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) - var params WillSaveTextDocumentParams + var params DeclarationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentWillSave(ctx, ¶ms) + resp, err := server.Declaration(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodWindowWorkDoneProgressCancel: // notification - defer logger.Debug(MethodWindowWorkDoneProgressCancel, zap.Error(err)) + case MethodTextDocumentDefinition: // request + defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) - var params WorkDoneProgressCancelParams + var params DefinitionParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.Definition(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentDidChange: // notification + defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) + + var params DidChangeTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WindowWorkDoneProgressCancel(ctx, ¶ms) + err := server.DidChange(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -240,7 +265,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidChangeConfiguration(ctx, ¶ms) + err := server.DidChangeConfiguration(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -252,7 +277,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidChangeWatchedFiles(ctx, ¶ms) + err := server.DidChangeWatchedFiles(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -264,404 +289,380 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidChangeWorkspaceFolders(ctx, ¶ms) + err := server.DidChangeWorkspaceFolders(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWorkspaceDidCreateFiles: // notification - defer logger.Debug(MethodWorkspaceDidCreateFiles, zap.Error(err)) + case MethodTextDocumentDidClose: // notification + defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) - var params CreateFilesParams + var params DidCloseTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidCreateFiles(ctx, ¶ms) + err := server.DidClose(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWorkspaceDidDeleteFiles: // notification - defer logger.Debug(MethodWorkspaceDidDeleteFiles, zap.Error(err)) + case MethodTextDocumentDidOpen: // notification + defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) - var params DeleteFilesParams + var params DidOpenTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidDeleteFiles(ctx, ¶ms) + err := server.DidOpen(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWorkspaceDidRenameFiles: // notification - defer logger.Debug(MethodWorkspaceDidRenameFiles, zap.Error(err)) + case MethodTextDocumentDidSave: // notification + defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) - var params RenameFilesParams + var params DidSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidRenameFiles(ctx, ¶ms) + err := server.DidSave(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodCallHierarchyIncomingCalls: // request - defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) + case MethodTextDocumentDocumentColor: // request + defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) - var params CallHierarchyIncomingCallsParams + var params DocumentColorParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CallHierarchyIncomingCalls(ctx, ¶ms) + resp, err := server.DocumentColor(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCallHierarchyOutgoingCalls: // request - defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) + case MethodTextDocumentDocumentHighlight: // request + defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) - var params CallHierarchyOutgoingCallsParams + var params DocumentHighlightParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CallHierarchyOutgoingCalls(ctx, ¶ms) + resp, err := server.DocumentHighlight(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCodeActionResolve: // request - defer logger.Debug(MethodCodeActionResolve, zap.Error(err)) + case MethodTextDocumentDocumentLink: // request + defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) - var params CodeAction + var params DocumentLinkParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeActionResolve(ctx, ¶ms) + resp, err := server.DocumentLink(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCodeLensResolve: // request - defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) + case MethodDocumentLinkResolve: // request + defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) - var params CodeLens + var params DocumentLink if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeLensResolve(ctx, ¶ms) + resp, err := server.DocumentLinkResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCompletionItemResolve: // request - defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) + case MethodTextDocumentDocumentSymbol: // request + defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) - var params CompletionItem + var params DocumentSymbolParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CompletionItemResolve(ctx, ¶ms) + resp, err := server.DocumentSymbol(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDocumentLinkResolve: // request - defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) + case MethodWorkspaceExecuteCommand: // request + defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) - var params DocumentLink + var params ExecuteCommandParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentLinkResolve(ctx, ¶ms) + resp, err := server.ExecuteCommand(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodInitialize: // request - defer logger.Debug(MethodInitialize, zap.Error(err)) + case MethodTextDocumentFoldingRange: // request + defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) - var params InitializeParams + var params FoldingRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Initialize(ctx, ¶ms) + resp, err := server.FoldingRanges(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodInlayHintResolve: // request - defer logger.Debug(MethodInlayHintResolve, zap.Error(err)) + case MethodTextDocumentFormatting: // request + defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) - var params InlayHint + var params DocumentFormattingParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.InlayHintResolve(ctx, ¶ms) + resp, err := server.Formatting(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodShutdown: // request - defer logger.Debug(MethodShutdown, zap.Error(err)) + case MethodTextDocumentHover: // request + defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + var params HoverParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) } - err := server.Shutdown(ctx) + resp, err := server.Hover(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentCodeAction: // request - defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) + case MethodTextDocumentImplementation: // request + defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) - var params CodeActionParams + var params ImplementationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentCodeAction(ctx, ¶ms) + resp, err := server.Implementation(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentCodeLens: // request - defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) + case MethodTextDocumentOnTypeFormatting: // request + defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) - var params CodeLensParams + var params DocumentOnTypeFormattingParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentCodeLens(ctx, ¶ms) + resp, err := server.OnTypeFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentColorPresentation: // request - defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) + case MethodTextDocumentPrepareRename: // request + defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) - var params ColorPresentationParams + var params PrepareRenameParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentColorPresentation(ctx, ¶ms) + resp, err := server.PrepareRename(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentCompletion: // request - defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) + case MethodTextDocumentRangeFormatting: // request + defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) - var params CompletionParams + var params DocumentRangeFormattingParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentCompletion(ctx, ¶ms) + resp, err := server.RangeFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDeclaration: // request - defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) + case MethodTextDocumentReferences: // request + defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) - var params DeclarationParams + var params ReferenceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDeclaration(ctx, ¶ms) + resp, err := server.References(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDefinition: // request - defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) + case MethodTextDocumentRename: // request + defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) - var params DefinitionParams + var params RenameParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDefinition(ctx, ¶ms) + resp, err := server.Rename(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDiagnostic: // request - defer logger.Debug(MethodTextDocumentDiagnostic, zap.Error(err)) + case MethodTextDocumentSignatureHelp: // request + defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) - var params DocumentDiagnosticParams + var params SignatureHelpParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDiagnostic(ctx, ¶ms) + resp, err := server.SignatureHelp(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentColor: // request - defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) + case MethodWorkspaceSymbol: // request + defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) - var params DocumentColorParams + var params WorkspaceSymbolParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentColor(ctx, ¶ms) + resp, err := server.Symbols(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentHighlight: // request - defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) + case MethodTextDocumentTypeDefinition: // request + defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) - var params DocumentHighlightParams + var params TypeDefinitionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentHighlight(ctx, ¶ms) + resp, err := server.TypeDefinition(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentLink: // request - defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) + case MethodTextDocumentWillSave: // notification + defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) - var params DocumentLinkParams + var params WillSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentLink(ctx, ¶ms) + err := server.WillSave(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDocumentSymbol: // request - defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) + case MethodTextDocumentWillSaveWaitUntil: // request + defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - var params DocumentSymbolParams + var params WillSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentSymbol(ctx, ¶ms) + resp, err := server.WillSaveWaitUntil(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFoldingRange: // request - defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) + case MethodShowDocument: // request + defer logger.Debug(MethodShowDocument, zap.Error(err)) - var params FoldingRangeParams + var params ShowDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentFoldingRange(ctx, ¶ms) + resp, err := server.ShowDocument(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFormatting: // request - defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) + case MethodWillCreateFiles: // request + defer logger.Debug(MethodWillCreateFiles, zap.Error(err)) - var params DocumentFormattingParams + var params CreateFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentFormatting(ctx, ¶ms) + resp, err := server.WillCreateFiles(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentHover: // request - defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) + case MethodDidCreateFiles: // notification + defer logger.Debug(MethodDidCreateFiles, zap.Error(err)) - var params HoverParams + var params CreateFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentHover(ctx, ¶ms) + err := server.DidCreateFiles(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentImplementation: // request - defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) + case MethodWillRenameFiles: // request + defer logger.Debug(MethodWillRenameFiles, zap.Error(err)) - var params ImplementationParams + var params RenameFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentImplementation(ctx, ¶ms) + resp, err := server.WillRenameFiles(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentInlayHint: // request - defer logger.Debug(MethodTextDocumentInlayHint, zap.Error(err)) + case MethodDidRenameFiles: // notification + defer logger.Debug(MethodDidRenameFiles, zap.Error(err)) - var params InlayHintParams + var params RenameFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentInlayHint(ctx, ¶ms) + err := server.DidRenameFiles(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentInlineCompletion: // request - defer logger.Debug(MethodTextDocumentInlineCompletion, zap.Error(err)) + case MethodWillDeleteFiles: // request + defer logger.Debug(MethodWillDeleteFiles, zap.Error(err)) - var params InlineCompletionParams + var params DeleteFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentInlineCompletion(ctx, ¶ms) + resp, err := server.WillDeleteFiles(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentInlineValue: // request - defer logger.Debug(MethodTextDocumentInlineValue, zap.Error(err)) + case MethodDidDeleteFiles: // notification + defer logger.Debug(MethodDidDeleteFiles, zap.Error(err)) - var params InlineValueParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentInlineValue(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentLinkedEditingRange: // request - defer logger.Debug(MethodTextDocumentLinkedEditingRange, zap.Error(err)) - - var params LinkedEditingRangeParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentLinkedEditingRange(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentMoniker: // request - defer logger.Debug(MethodTextDocumentMoniker, zap.Error(err)) - - var params MonikerParams + var params DeleteFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentMoniker(ctx, ¶ms) + err := server.DidDeleteFiles(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentOnTypeFormatting: // request - defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) + case MethodCodeLensRefresh: // request + defer logger.Debug(MethodCodeLensRefresh, zap.Error(err)) - var params DocumentOnTypeFormattingParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) } - resp, err := server.TextDocumentOnTypeFormatting(ctx, ¶ms) + err := server.CodeLensRefresh(ctx) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) case MethodTextDocumentPrepareCallHierarchy: // request defer logger.Debug(MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) @@ -671,271 +672,102 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentPrepareCallHierarchy(ctx, ¶ms) + resp, err := server.PrepareCallHierarchy(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentPrepareRename: // request - defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) - - var params PrepareRenameParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentPrepareRename(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentPrepareTypeHierarchy: // request - defer logger.Debug(MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) - - var params TypeHierarchyPrepareParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentPrepareTypeHierarchy(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentRangeFormatting: // request - defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) - - var params DocumentRangeFormattingParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentRangeFormatting(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentRangesFormatting: // request - defer logger.Debug(MethodTextDocumentRangesFormatting, zap.Error(err)) - - var params DocumentRangesFormattingParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentRangesFormatting(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentReferences: // request - defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) - - var params ReferenceParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentReferences(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentRename: // request - defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) + case MethodCallHierarchyIncomingCalls: // request + defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) - var params RenameParams + var params CallHierarchyIncomingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentRename(ctx, ¶ms) + resp, err := server.IncomingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSelectionRange: // request - defer logger.Debug(MethodTextDocumentSelectionRange, zap.Error(err)) + case MethodCallHierarchyOutgoingCalls: // request + defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) - var params SelectionRangeParams + var params CallHierarchyOutgoingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSelectionRange(ctx, ¶ms) + resp, err := server.OutgoingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSemanticTokensFull: // request - defer logger.Debug(MethodTextDocumentSemanticTokensFull, zap.Error(err)) + case MethodSemanticTokensFull: // request + defer logger.Debug(MethodSemanticTokensFull, zap.Error(err)) var params SemanticTokensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSemanticTokensFull(ctx, ¶ms) + resp, err := server.SemanticTokensFull(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSemanticTokensFullDelta: // request - defer logger.Debug(MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) + case MethodSemanticTokensFullDelta: // request + defer logger.Debug(MethodSemanticTokensFullDelta, zap.Error(err)) var params SemanticTokensDeltaParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSemanticTokensFullDelta(ctx, ¶ms) + resp, err := server.SemanticTokensFullDelta(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSemanticTokensRange: // request - defer logger.Debug(MethodTextDocumentSemanticTokensRange, zap.Error(err)) + case MethodSemanticTokensRange: // request + defer logger.Debug(MethodSemanticTokensRange, zap.Error(err)) var params SemanticTokensRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSemanticTokensRange(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentSignatureHelp: // request - defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) - - var params SignatureHelpParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentSignatureHelp(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentTypeDefinition: // request - defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) - - var params TypeDefinitionParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentTypeDefinition(ctx, ¶ms) + resp, err := server.SemanticTokensRange(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentWillSaveWaitUntil: // request - defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - - var params WillSaveTextDocumentParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentWillSaveWaitUntil(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTypeHierarchySubtypes: // request - defer logger.Debug(MethodTypeHierarchySubtypes, zap.Error(err)) - - var params TypeHierarchySubtypesParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TypeHierarchySubtypes(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTypeHierarchySupertypes: // request - defer logger.Debug(MethodTypeHierarchySupertypes, zap.Error(err)) - - var params TypeHierarchySupertypesParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TypeHierarchySupertypes(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWorkspaceDiagnostic: // request - defer logger.Debug(MethodWorkspaceDiagnostic, zap.Error(err)) - - var params WorkspaceDiagnosticParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.WorkspaceDiagnostic(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWorkspaceExecuteCommand: // request - defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) - - var params ExecuteCommandParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.WorkspaceExecuteCommand(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWorkspaceSymbol: // request - defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) - - var params WorkspaceSymbolParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.WorkspaceSymbol(ctx, ¶ms) - - return true, reply(ctx, resp, err) + case MethodSemanticTokensRefresh: // request + defer logger.Debug(MethodSemanticTokensRefresh, zap.Error(err)) - case MethodWorkspaceWillCreateFiles: // request - defer logger.Debug(MethodWorkspaceWillCreateFiles, zap.Error(err)) - - var params CreateFilesParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.WorkspaceWillCreateFiles(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWorkspaceWillDeleteFiles: // request - defer logger.Debug(MethodWorkspaceWillDeleteFiles, zap.Error(err)) - - var params DeleteFilesParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) } - resp, err := server.WorkspaceWillDeleteFiles(ctx, ¶ms) + err := server.SemanticTokensRefresh(ctx) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodWorkspaceWillRenameFiles: // request - defer logger.Debug(MethodWorkspaceWillRenameFiles, zap.Error(err)) + case MethodLinkedEditingRange: // request + defer logger.Debug(MethodLinkedEditingRange, zap.Error(err)) - var params RenameFilesParams + var params LinkedEditingRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WorkspaceWillRenameFiles(ctx, ¶ms) + resp, err := server.LinkedEditingRange(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceSymbolResolve: // request - defer logger.Debug(MethodWorkspaceSymbolResolve, zap.Error(err)) + case MethodMoniker: // request + defer logger.Debug(MethodMoniker, zap.Error(err)) - var params WorkspaceSymbol + var params MonikerParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WorkspaceSymbolResolve(ctx, ¶ms) + resp, err := server.Moniker(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -944,317 +776,262 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, } } -// server implements a Language Server Protocol server. -type server struct { - jsonrpc2.Conn +// Server represents a Language Server Protocol server. +type Server interface { + Initialize(ctx context.Context, params *InitializeParams) (result *InitializeResult, err error) + Initialized(ctx context.Context, params *InitializedParams) (err error) + Shutdown(ctx context.Context) (err error) + Exit(ctx context.Context) (err error) + WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) + LogTrace(ctx context.Context, params *LogTraceParams) (err error) + SetTrace(ctx context.Context, params *SetTraceParams) (err error) + CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) + CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) + CodeLensResolve(ctx context.Context, params *CodeLens) (result *CodeLens, err error) + ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) + Completion(ctx context.Context, params *CompletionParams) (result *CompletionList, err error) + CompletionResolve(ctx context.Context, params *CompletionItem) (result *CompletionItem, err error) + Declaration(ctx context.Context, params *DeclarationParams) (result []Location /* Declaration | DeclarationLink[] | null */, err error) + Definition(ctx context.Context, params *DefinitionParams) (result []Location /* Definition | DefinitionLink[] | null */, err error) + DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) + DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) + DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) + DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) + DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) + DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) + DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) + DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) + DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) + DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) + DocumentLinkResolve(ctx context.Context, params *DocumentLink) (result *DocumentLink, err error) + DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{} /* []SymbolInformation | []DocumentSymbol */, err error) + ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) + FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) + Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) + Hover(ctx context.Context, params *HoverParams) (result *Hover, err error) + Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) + OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) + PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) + RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) + References(ctx context.Context, params *ReferenceParams) (result []Location, err error) + Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) + SignatureHelp(ctx context.Context, params *SignatureHelpParams) (result *SignatureHelp, err error) + Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) + TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) + WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) + WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) + ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) + WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) + DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) + WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) + DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) + WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) + DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) + CodeLensRefresh(ctx context.Context) (err error) + PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) + IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) + OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) + SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) + SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{} /* SemanticTokens | SemanticTokensDelta */, err error) + SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) + SemanticTokensRefresh(ctx context.Context) (err error) + LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) + Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) + Request(ctx context.Context, method string, params interface{}) (result interface{}, err error) +} + +// list of server methods. +const ( + // MethodCancelRequest method name of "$/cancelRequest". + MethodCancelRequest = "$/cancelRequest" + + // MethodInitialize method name of "initialize". + MethodInitialize = "initialize" + + // MethodInitialized method name of "initialized". + MethodInitialized = "initialized" + + // MethodShutdown method name of "shutdown". + MethodShutdown = "shutdown" + + // MethodExit method name of "exit". + MethodExit = "exit" + + // MethodWorkDoneProgressCancel method name of "window/workDoneProgress/cancel". + MethodWorkDoneProgressCancel = "window/workDoneProgress/cancel" + + // MethodLogTrace method name of "$/logTrace". + MethodLogTrace = "$/logTrace" + + // MethodSetTrace method name of "$/setTrace". + MethodSetTrace = "$/setTrace" + + // MethodTextDocumentCodeAction method name of "textDocument/codeAction". + MethodTextDocumentCodeAction = "textDocument/codeAction" + + // MethodTextDocumentCodeLens method name of "textDocument/codeLens". + MethodTextDocumentCodeLens = "textDocument/codeLens" + + // MethodCodeLensResolve method name of "codeLens/resolve". + MethodCodeLensResolve = "codeLens/resolve" + + // MethodTextDocumentColorPresentation method name of "textDocument/colorPresentation". + MethodTextDocumentColorPresentation = "textDocument/colorPresentation" + + // MethodTextDocumentCompletion method name of "textDocument/completion". + MethodTextDocumentCompletion = "textDocument/completion" + + // MethodCompletionItemResolve method name of "completionItem/resolve". + MethodCompletionItemResolve = "completionItem/resolve" + + // MethodTextDocumentDeclaration method name of "textDocument/declaration". + MethodTextDocumentDeclaration = "textDocument/declaration" - logger *zap.Logger -} + // MethodTextDocumentDefinition method name of "textDocument/definition". + MethodTextDocumentDefinition = "textDocument/definition" -var _ Server = (*server)(nil) + // MethodTextDocumentDidChange method name of "textDocument/didChange". + MethodTextDocumentDidChange = "textDocument/didChange" -func (s *server) CancelRequest(ctx context.Context, params *CancelParams) (err error) { - s.logger.Debug("notify " + MethodClientCancelRequest) - defer s.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) + // MethodWorkspaceDidChangeConfiguration method name of "workspace/didChangeConfiguration". + MethodWorkspaceDidChangeConfiguration = "workspace/didChangeConfiguration" - return s.Conn.Notify(ctx, MethodClientCancelRequest, params) -} + // MethodWorkspaceDidChangeWatchedFiles method name of "workspace/didChangeWatchedFiles". + MethodWorkspaceDidChangeWatchedFiles = "workspace/didChangeWatchedFiles" -// Progress is the base protocol offers also support to report progress in a generic fashion. -// -// This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and -// partial result progress to support streaming of results. -// -// @since 3.16.0. -func (s *server) Progress(ctx context.Context, params *ProgressParams) (err error) { - s.logger.Debug("notify " + MethodClientProgress) - defer s.logger.Debug("end "+MethodClientProgress, zap.Error(err)) + // MethodWorkspaceDidChangeWorkspaceFolders method name of "workspace/didChangeWorkspaceFolders". + MethodWorkspaceDidChangeWorkspaceFolders = "workspace/didChangeWorkspaceFolders" - return s.Conn.Notify(ctx, MethodClientProgress, params) -} + // MethodTextDocumentDidClose method name of "textDocument/didClose". + MethodTextDocumentDidClose = "textDocument/didClose" -// SetTrace a notification that should be used by the client to modify the trace setting of the server. -// -// @since 3.16.0. -func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { - s.logger.Debug("notify " + MethodSetTrace) - defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) + // MethodTextDocumentDidOpen method name of "textDocument/didOpen". + MethodTextDocumentDidOpen = "textDocument/didOpen" - return s.Conn.Notify(ctx, MethodSetTrace, params) -} + // MethodTextDocumentDidSave method name of "textDocument/didSave". + MethodTextDocumentDidSave = "textDocument/didSave" -// Exit a notification to ask the server to exit its process. -// -// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. -func (s *server) Exit(ctx context.Context) (err error) { - s.logger.Debug("notify " + MethodExit) - defer s.logger.Debug("end "+MethodExit, zap.Error(err)) + // MethodTextDocumentDocumentColor method name of"textDocument/documentColor". + MethodTextDocumentDocumentColor = "textDocument/documentColor" - return s.Conn.Notify(ctx, MethodExit, nil) -} + // MethodTextDocumentDocumentHighlight method name of "textDocument/documentHighlight". + MethodTextDocumentDocumentHighlight = "textDocument/documentHighlight" -// Initialized sends the notification from the client to the server after the client received the result of the -// initialize request but before the client is sending any other request or notification to the server. -// -// The server can use the initialized notification for example to dynamically register capabilities. -// The initialized notification may only be sent once. -func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { - s.logger.Debug("notify " + MethodInitialized) - defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) + // MethodTextDocumentDocumentLink method name of "textDocument/documentLink". + MethodTextDocumentDocumentLink = "textDocument/documentLink" - return s.Conn.Notify(ctx, MethodInitialized, params) -} + // MethodDocumentLinkResolve method name of "documentLink/resolve". + MethodDocumentLinkResolve = "documentLink/resolve" -func (s *server) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) (err error) { - s.logger.Debug("call " + MethodNotebookDocumentDidChange) - defer s.logger.Debug("end "+MethodNotebookDocumentDidChange, zap.Error(err)) + // MethodTextDocumentDocumentSymbol method name of "textDocument/documentSymbol". + MethodTextDocumentDocumentSymbol = "textDocument/documentSymbol" - return s.Conn.Notify(ctx, MethodNotebookDocumentDidChange, params) -} + // MethodWorkspaceExecuteCommand method name of "workspace/executeCommand". + MethodWorkspaceExecuteCommand = "workspace/executeCommand" -// NotebookDocumentDidClose a notification sent when a notebook closes. -// -// @since 3.17.0 -func (s *server) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) (err error) { - s.logger.Debug("call " + MethodNotebookDocumentDidClose) - defer s.logger.Debug("end "+MethodNotebookDocumentDidClose, zap.Error(err)) + // MethodTextDocumentFoldingRange method name of "textDocument/foldingRange". + MethodTextDocumentFoldingRange = "textDocument/foldingRange" - return s.Conn.Notify(ctx, MethodNotebookDocumentDidClose, params) -} + // MethodTextDocumentFormatting method name of "textDocument/formatting". + MethodTextDocumentFormatting = "textDocument/formatting" -// NotebookDocumentDidOpen a notification sent when a notebook opens. -// -// @since 3.17.0 -func (s *server) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) (err error) { - s.logger.Debug("call " + MethodNotebookDocumentDidOpen) - defer s.logger.Debug("end "+MethodNotebookDocumentDidOpen, zap.Error(err)) + // MethodTextDocumentHover method name of "textDocument/hover". + MethodTextDocumentHover = "textDocument/hover" - return s.Conn.Notify(ctx, MethodNotebookDocumentDidOpen, params) -} + // MethodTextDocumentImplementation method name of "textDocument/implementation". + MethodTextDocumentImplementation = "textDocument/implementation" -// NotebookDocumentDidSave a notification sent when a notebook document is saved. -// -// @since 3.17.0 -func (s *server) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) (err error) { - s.logger.Debug("call " + MethodNotebookDocumentDidSave) - defer s.logger.Debug("end "+MethodNotebookDocumentDidSave, zap.Error(err)) + // MethodTextDocumentOnTypeFormatting method name of "textDocument/onTypeFormatting". + MethodTextDocumentOnTypeFormatting = "textDocument/onTypeFormatting" - return s.Conn.Notify(ctx, MethodNotebookDocumentDidSave, params) -} + // MethodTextDocumentPrepareRename method name of "textDocument/prepareRename". + MethodTextDocumentPrepareRename = "textDocument/prepareRename" -// DidChange sends the notification from the client to the server to signal changes to a text document. -// -// In 2.0 the shape of the params has changed to include proper version numbers and language ids. -func (s *server) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { - s.logger.Debug("notify " + MethodTextDocumentDidChange) - defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) + // MethodTextDocumentRangeFormatting method name of "textDocument/rangeFormatting". + MethodTextDocumentRangeFormatting = "textDocument/rangeFormatting" - return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) -} + // MethodTextDocumentReferences method name of "textDocument/references". + MethodTextDocumentReferences = "textDocument/references" -// DidClose sends the notification from the client to the server when the document got closed in the client. -// -// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). -// As with the open notification the close notification is about managing the document’s content. -// Receiving a close notification doesn’t mean that the document was open in an editor before. -// -// A close notification requires a previous open notification to be sent. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidClose) - defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) + // MethodTextDocumentRename method name of "textDocument/rename". + MethodTextDocumentRename = "textDocument/rename" - return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) -} + // MethodTextDocumentSignatureHelp method name of "textDocument/signatureHelp". + MethodTextDocumentSignatureHelp = "textDocument/signatureHelp" -// DidOpen sends the open notification from the client to the server to signal newly opened text documents. -// -// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. -// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. -// -// An open notification must not be sent more than once without a corresponding close notification send before. -// This means open and close notification must be balanced and the max open count for a particular textDocument is one. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidOpen) - defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) -} - -// DidSave sends the notification from the client to the server when the document was saved in the client. -func (s *server) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidSave) - defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) -} - -// WillSave sends the notification from the client to the server before the document is actually saved. -func (s *server) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentWillSave) - defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) -} - -// WindowWorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the -// server side using the "window/workDoneProgress/create". -func (s *server) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { - s.logger.Debug("call " + MethodWindowWorkDoneProgressCancel) - defer s.logger.Debug("end "+MethodWindowWorkDoneProgressCancel, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWindowWorkDoneProgressCancel, params) -} - -// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. -func (s *server) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) -} - -// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. -// -// It is recommended that servers register for these file events using the registration mechanism. -// In former implementations clients pushed file events without the server actively asking for it. -func (s *server) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) + // MethodWorkspaceSymbol method name of "workspace/symbol". + MethodWorkspaceSymbol = "workspace/symbol" - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) -} + // MethodTextDocumentTypeDefinition method name of "textDocument/typeDefinition". + MethodTextDocumentTypeDefinition = "textDocument/typeDefinition" -// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. -// -// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; -// or if the server has registered itself to receive this notification. -// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. -// -// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). -func (s *server) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) + // MethodTextDocumentWillSave method name of "textDocument/willSave". + MethodTextDocumentWillSave = "textDocument/willSave" - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) -} + // MethodTextDocumentWillSaveWaitUntil method name of "textDocument/willSaveWaitUntil". + MethodTextDocumentWillSaveWaitUntil = "textDocument/willSaveWaitUntil" -// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. -// -// @since 3.16.0. -func (s *server) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidCreateFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidCreateFiles, zap.Error(err)) + // MethodShowDocument method name of "window/showDocument". + MethodShowDocument = "window/showDocument" - return s.Conn.Notify(ctx, MethodWorkspaceDidCreateFiles, params) -} - -// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. -// -// @since 3.16.0. -func (s *server) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidDeleteFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidDeleteFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidDeleteFiles, params) -} - -// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. -// -// @since 3.16.0. -func (s *server) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidRenameFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidRenameFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidRenameFiles, params) -} - -// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -func (s *server) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (_ []*CallHierarchyIncomingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) + // MethodWillCreateFiles method name of "workspace/willCreateFiles". + MethodWillCreateFiles = "workspace/willCreateFiles" - var result []*CallHierarchyIncomingCall - if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { - return nil, err - } + // MethodDidCreateFiles method name of "workspace/didCreateFiles". + MethodDidCreateFiles = "workspace/didCreateFiles" - return result, nil -} + // MethodWillRenameFiles method name of "workspace/willRenameFiles". + MethodWillRenameFiles = "workspace/willRenameFiles" -// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -func (s *server) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (_ []*CallHierarchyOutgoingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) + // MethodDidRenameFiles method name of "workspace/didRenameFiles". + MethodDidRenameFiles = "workspace/didRenameFiles" - var result []*CallHierarchyOutgoingCall - if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { - return nil, err - } + // MethodWillDeleteFiles method name of "workspace/willDeleteFiles". + MethodWillDeleteFiles = "workspace/willDeleteFiles" - return result, nil -} + // MethodDidDeleteFiles method name of "workspace/didDeleteFiles". + MethodDidDeleteFiles = "workspace/didDeleteFiles" -func (s *server) CodeActionResolve(ctx context.Context, params *CodeAction) (_ *CodeAction, err error) { - s.logger.Debug("call " + MethodCodeActionResolve) - defer s.logger.Debug("end "+MethodCodeActionResolve, zap.Error(err)) + // MethodCodeLensRefresh method name of "workspace/codeLens/refresh". + MethodCodeLensRefresh = "workspace/codeLens/refresh" - var result *CodeAction - if err := Call(ctx, s.Conn, MethodCodeActionResolve, params, &result); err != nil { - return nil, err - } + // MethodTextDocumentPrepareCallHierarchy method name of "textDocument/prepareCallHierarchy". + MethodTextDocumentPrepareCallHierarchy = "textDocument/prepareCallHierarchy" - return result, nil -} + // MethodCallHierarchyIncomingCalls method name of "callHierarchy/incomingCalls". + MethodCallHierarchyIncomingCalls = "callHierarchy/incomingCalls" -// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. -func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { - s.logger.Debug("call " + MethodCodeLensResolve) - defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) + // MethodCallHierarchyOutgoingCalls method name of "callHierarchy/outgoingCalls". + MethodCallHierarchyOutgoingCalls = "callHierarchy/outgoingCalls" - var result *CodeLens - if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { - return nil, err - } + // MethodSemanticTokensFull method name of "textDocument/semanticTokens/full". + MethodSemanticTokensFull = "textDocument/semanticTokens/full" - return result, nil -} + // MethodSemanticTokensFullDelta method name of "textDocument/semanticTokens/full/delta". + MethodSemanticTokensFullDelta = "textDocument/semanticTokens/full/delta" -// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. -func (s *server) CompletionItemResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { - s.logger.Debug("call " + MethodCompletionItemResolve) - defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) + // MethodSemanticTokensRange method name of "textDocument/semanticTokens/range". + MethodSemanticTokensRange = "textDocument/semanticTokens/range" - var result *CompletionItem - if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { - return nil, err - } + // MethodSemanticTokensRefresh method name of "workspace/semanticTokens/refresh". + MethodSemanticTokensRefresh = "workspace/semanticTokens/refresh" - return result, nil -} + // MethodLinkedEditingRange method name of "textDocument/linkedEditingRange". + MethodLinkedEditingRange = "textDocument/linkedEditingRange" -// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. -func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { - s.logger.Debug("call " + MethodDocumentLinkResolve) - defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) + // MethodMoniker method name of "textDocument/moniker". + MethodMoniker = "textDocument/moniker" +) - var result *DocumentLink - if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { - return nil, err - } +// server implements a Language Server Protocol server. +type server struct { + jsonrpc2.Conn - return result, nil + logger *zap.Logger } +var _ Server = (*server)(nil) + // Initialize sents the request as the first request from the client to the server. // // If the server receives a request or notification before the initialize request it should act as follows: @@ -1280,16 +1057,16 @@ func (s *server) Initialize(ctx context.Context, params *InitializeParams) (_ *I return result, nil } -func (s *server) InlayHintResolve(ctx context.Context, params *InlayHint) (_ *InlayHint, err error) { - s.logger.Debug("call " + MethodInlayHintResolve) - defer s.logger.Debug("end "+MethodInlayHintResolve, zap.Error(err)) - - var result *InlayHint - if err := Call(ctx, s.Conn, MethodInlayHintResolve, params, &result); err != nil { - return nil, err - } +// Initialized sends the notification from the client to the server after the client received the result of the +// initialize request but before the client is sending any other request or notification to the server. +// +// The server can use the initialized notification for example to dynamically register capabilities. +// The initialized notification may only be sent once. +func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { + s.logger.Debug("notify " + MethodInitialized) + defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) - return result, nil + return s.Conn.Notify(ctx, MethodInitialized, params) } // Shutdown sents the request from the client to the server. @@ -1306,6 +1083,50 @@ func (s *server) Shutdown(ctx context.Context) (err error) { return Call(ctx, s.Conn, MethodShutdown, nil, nil) } +// Exit a notification to ask the server to exit its process. +// +// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. +func (s *server) Exit(ctx context.Context) (err error) { + s.logger.Debug("notify " + MethodExit) + defer s.logger.Debug("end "+MethodExit, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodExit, nil) +} + +// LogTrace a notification to log the trace of the server’s execution. +// +// The amount and content of these notifications depends on the current trace configuration. +// +// If trace is "off", the server should not send any logTrace notification. If trace is "message", +// the server should not add the "verbose" field in the LogTraceParams. +// +// @since 3.16.0. +func (s *server) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { + s.logger.Debug("notify " + MethodLogTrace) + defer s.logger.Debug("end "+MethodLogTrace, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodLogTrace, params) +} + +// SetTrace a notification that should be used by the client to modify the trace setting of the server. +// +// @since 3.16.0. +func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { + s.logger.Debug("notify " + MethodSetTrace) + defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodSetTrace, params) +} + +// WorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the +// server side using the "window/workDoneProgress/create". +func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { + s.logger.Debug("call " + MethodWorkDoneProgressCancel) + defer s.logger.Debug("end "+MethodWorkDoneProgressCancel, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkDoneProgressCancel, params) +} + // CodeAction sends the request is from the client to the server to compute commands for a given text document and range. // // These commands are typically code fixes to either fix problems or to beautify/refactor code. The result of a `textDocument/codeAction` @@ -1314,11 +1135,10 @@ func (s *server) Shutdown(ctx context.Context) (err error) { // To ensure that a server is useful in many clients the commands specified in a code actions should be handled by the // server and not by the client (see `workspace/executeCommand` and `ServerCapabilities.executeCommandProvider`). // If the client supports providing edits with a code action then the mode should be used. -func (s *server) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (_ *TextDocumentCodeActionResult, err error) { +func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) { s.logger.Debug("call " + MethodTextDocumentCodeAction) defer s.logger.Debug("end "+MethodTextDocumentCodeAction, zap.Error(err)) - var result *TextDocumentCodeActionResult if err := Call(ctx, s.Conn, MethodTextDocumentCodeAction, params, &result); err != nil { return nil, err } @@ -1327,11 +1147,10 @@ func (s *server) TextDocumentCodeAction(ctx context.Context, params *CodeActionP } // CodeLens sends the request from the client to the server to compute code lenses for a given text document. -func (s *server) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) (_ []*CodeLens, err error) { +func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) { s.logger.Debug("call " + MethodTextDocumentCodeLens) defer s.logger.Debug("end "+MethodTextDocumentCodeLens, zap.Error(err)) - var result []*CodeLens if err := Call(ctx, s.Conn, MethodTextDocumentCodeLens, params, &result); err != nil { return nil, err } @@ -1339,17 +1158,29 @@ func (s *server) TextDocumentCodeLens(ctx context.Context, params *CodeLensParam return result, nil } +// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. +func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { + s.logger.Debug("call " + MethodCodeLensResolve) + defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) + + var result *CodeLens + if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + // ColorPresentation sends the request from the client to the server to obtain a list of presentations for a color value at a given location. // // # Clients can use the result to // // - modify a color reference. // - show in a color picker and let users pick one of the presentations. -func (s *server) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) (_ []*ColorPresentation, err error) { +func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) { s.logger.Debug("call " + MethodTextDocumentColorPresentation) defer s.logger.Debug("end "+MethodTextDocumentColorPresentation, zap.Error(err)) - var result []*ColorPresentation if err := Call(ctx, s.Conn, MethodTextDocumentColorPresentation, params, &result); err != nil { return nil, err } @@ -1370,11 +1201,11 @@ func (s *server) TextDocumentColorPresentation(ctx context.Context, params *Colo // The returned completion item should have the documentation property filled in. The request can delay the computation of // the `detail` and `documentation` properties. However, properties that are needed for the initial sorting and filtering, // like `sortText`, `filterText`, `insertText`, and `textEdit` must be provided in the `textDocument/completion` response and must not be changed during resolve. -func (s *server) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (_ *TextDocumentCompletionResult, err error) { +func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *CompletionList, err error) { s.logger.Debug("call " + MethodTextDocumentCompletion) defer s.logger.Debug("end "+MethodTextDocumentCompletion, zap.Error(err)) - var result *TextDocumentCompletionResult + var result *CompletionList if err := Call(ctx, s.Conn, MethodTextDocumentCompletion, params, &result); err != nil { return nil, err } @@ -1382,16 +1213,28 @@ func (s *server) TextDocumentCompletion(ctx context.Context, params *CompletionP return result, nil } +// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. +func (s *server) CompletionResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { + s.logger.Debug("call " + MethodCompletionItemResolve) + defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) + + var result *CompletionItem + if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + // Declaration sends the request from the client to the server to resolve the declaration location of a symbol at a given text document position. // // The result type LocationLink[] got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.declaration.linkSupport`. // // @since 3.14.0. -func (s *server) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (_ *TextDocumentDeclarationResult, err error) { +func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (result []Location, err error) { s.logger.Debug("call " + MethodTextDocumentDeclaration) defer s.logger.Debug("end "+MethodTextDocumentDeclaration, zap.Error(err)) - var result *TextDocumentDeclarationResult if err := Call(ctx, s.Conn, MethodTextDocumentDeclaration, params, &result); err != nil { return nil, err } @@ -1404,11 +1247,10 @@ func (s *server) TextDocumentDeclaration(ctx context.Context, params *Declaratio // The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.definition.linkSupport`. // // @since 3.14.0. -func (s *server) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (_ *TextDocumentDefinitionResult, err error) { +func (s *server) Definition(ctx context.Context, params *DefinitionParams) (result []Location, err error) { s.logger.Debug("call " + MethodTextDocumentDefinition) defer s.logger.Debug("end "+MethodTextDocumentDefinition, zap.Error(err)) - var result *TextDocumentDefinitionResult if err := Call(ctx, s.Conn, MethodTextDocumentDefinition, params, &result); err != nil { return nil, err } @@ -1416,16 +1258,85 @@ func (s *server) TextDocumentDefinition(ctx context.Context, params *DefinitionP return result, nil } -func (s *server) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (_ *DocumentDiagnosticReport, err error) { - s.logger.Debug("call " + MethodTextDocumentDiagnostic) - defer s.logger.Debug("end "+MethodTextDocumentDiagnostic, zap.Error(err)) +// DidChange sends the notification from the client to the server to signal changes to a text document. +// +// In 2.0 the shape of the params has changed to include proper version numbers and language ids. +func (s *server) DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { + s.logger.Debug("notify " + MethodTextDocumentDidChange) + defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) +} + +// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. +func (s *server) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) - var result *DocumentDiagnosticReport - if err := Call(ctx, s.Conn, MethodTextDocumentDiagnostic, params, &result); err != nil { - return nil, err - } + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) +} - return result, nil +// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. +// +// It is recommended that servers register for these file events using the registration mechanism. +// In former implementations clients pushed file events without the server actively asking for it. +func (s *server) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) +} + +// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. +// +// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; +// or if the server has registered itself to receive this notification. +// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. +// +// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). +func (s *server) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) +} + +// DidClose sends the notification from the client to the server when the document got closed in the client. +// +// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). +// As with the open notification the close notification is about managing the document’s content. +// Receiving a close notification doesn’t mean that the document was open in an editor before. +// +// A close notification requires a previous open notification to be sent. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidClose) + defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) +} + +// DidOpen sends the open notification from the client to the server to signal newly opened text documents. +// +// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. +// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. +// +// An open notification must not be sent more than once without a corresponding close notification send before. +// This means open and close notification must be balanced and the max open count for a particular textDocument is one. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidOpen) + defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) +} + +// DidSave sends the notification from the client to the server when the document was saved in the client. +func (s *server) DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidSave) + defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) } // DocumentColor sends the request from the client to the server to list all color references found in a given text document. @@ -1437,11 +1348,10 @@ func (s *server) TextDocumentDiagnostic(ctx context.Context, params *DocumentDia // // - Color boxes showing the actual color next to the reference // - Show a color picker when a color reference is edited. -func (s *server) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) (_ []*ColorInformation, err error) { +func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentColor) defer s.logger.Debug("end "+MethodTextDocumentDocumentColor, zap.Error(err)) - var result []*ColorInformation if err := Call(ctx, s.Conn, MethodTextDocumentDocumentColor, params, &result); err != nil { return nil, err } @@ -1455,11 +1365,10 @@ func (s *server) TextDocumentDocumentColor(ctx context.Context, params *Document // However we kept ‘textDocument/documentHighlight’ and ‘textDocument/references’ separate requests since the first one is allowed to be more fuzzy. // // Symbol matches usually have a `DocumentHighlightKind` of `Read` or `Write` whereas fuzzy or textual matches use `Text` as the kind. -func (s *server) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (_ []*DocumentHighlight, err error) { +func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentHighlight) defer s.logger.Debug("end "+MethodTextDocumentDocumentHighlight, zap.Error(err)) - var result []*DocumentHighlight if err := Call(ctx, s.Conn, MethodTextDocumentDocumentHighlight, params, &result); err != nil { return nil, err } @@ -1468,11 +1377,10 @@ func (s *server) TextDocumentDocumentHighlight(ctx context.Context, params *Docu } // DocumentLink sends the request from the client to the server to request the location of links in a document. -func (s *server) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) (_ []*DocumentLink, err error) { +func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentLink) defer s.logger.Debug("end "+MethodTextDocumentDocumentLink, zap.Error(err)) - var result []*DocumentLink if err := Call(ctx, s.Conn, MethodTextDocumentDocumentLink, params, &result); err != nil { return nil, err } @@ -1480,145 +1388,95 @@ func (s *server) TextDocumentDocumentLink(ctx context.Context, params *DocumentL return result, nil } -// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. -// -// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. -func (s *server) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (_ *TextDocumentDocumentSymbolResult, err error) { - s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) - defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) +// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. +func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { + s.logger.Debug("call " + MethodDocumentLinkResolve) + defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) - var result *TextDocumentDocumentSymbolResult - if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { + var result *DocumentLink + if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { return nil, err } return result, nil } -// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. +// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. // -// @since version 3.10.0. -func (s *server) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) (_ []*FoldingRange, err error) { - s.logger.Debug("call " + MethodTextDocumentFoldingRange) - defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) - - var result []*FoldingRange - if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// Formatting sends the request from the client to the server to format a whole document. -func (s *server) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) (_ []*TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentFormatting) - defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) - - var result []*TextEdit - if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// Hover sends the request is from the client to the server to request hover information at a given text document position. -func (s *server) TextDocumentHover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { - s.logger.Debug("call " + MethodTextDocumentHover) - defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) +// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. +func (s *server) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{}, err error) { + s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) + defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) - var result *Hover - if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { return nil, err } return result, nil } -// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. +// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. // -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. -func (s *server) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (_ *TextDocumentImplementationResult, err error) { - s.logger.Debug("call " + MethodTextDocumentImplementation) - defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) - - var result *TextDocumentImplementationResult - if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -func (s *server) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) (_ []*InlayHint, err error) { - s.logger.Debug("call " + MethodTextDocumentInlayHint) - defer s.logger.Debug("end "+MethodTextDocumentInlayHint, zap.Error(err)) +// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the +// request `workspace/applyEdit` which is sent from the server to the client. +func (s *server) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) { + s.logger.Debug("call " + MethodWorkspaceExecuteCommand) + defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) - var result []*InlayHint - if err := Call(ctx, s.Conn, MethodTextDocumentInlayHint, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (_ *TextDocumentInlineCompletionResult, err error) { - s.logger.Debug("call " + MethodTextDocumentInlineCompletion) - defer s.logger.Debug("end "+MethodTextDocumentInlineCompletion, zap.Error(err)) +// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. +// +// @since version 3.10.0. +func (s *server) FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) { + s.logger.Debug("call " + MethodTextDocumentFoldingRange) + defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) - var result *TextDocumentInlineCompletionResult - if err := Call(ctx, s.Conn, MethodTextDocumentInlineCompletion, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) (_ []*InlineValue, err error) { - s.logger.Debug("call " + MethodTextDocumentInlineValue) - defer s.logger.Debug("end "+MethodTextDocumentInlineValue, zap.Error(err)) +// Formatting sends the request from the client to the server to format a whole document. +func (s *server) Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentFormatting) + defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) - var result []*InlineValue - if err := Call(ctx, s.Conn, MethodTextDocumentInlineValue, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { return nil, err } return result, nil } -// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. -// -// Optionally a word pattern can be returned to describe valid contents. -// -// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. -// -// @since 3.16.0. -func (s *server) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (_ *LinkedEditingRanges, err error) { - s.logger.Debug("call " + MethodTextDocumentLinkedEditingRange) - defer s.logger.Debug("end "+MethodTextDocumentLinkedEditingRange, zap.Error(err)) +// Hover sends the request is from the client to the server to request hover information at a given text document position. +func (s *server) Hover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { + s.logger.Debug("call " + MethodTextDocumentHover) + defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) - var result *LinkedEditingRanges - if err := Call(ctx, s.Conn, MethodTextDocumentLinkedEditingRange, params, &result); err != nil { + var result *Hover + if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { return nil, err } return result, nil } -// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. -// -// An array of Moniker types is returned as response to indicate possible monikers at the given location. -// -// If no monikers can be calculated, an empty array or null should be returned. +// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. // -// @since 3.16.0. -func (s *server) TextDocumentMoniker(ctx context.Context, params *MonikerParams) (_ []*Moniker, err error) { - s.logger.Debug("call " + MethodTextDocumentMoniker) - defer s.logger.Debug("end "+MethodTextDocumentMoniker, zap.Error(err)) +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. +func (s *server) Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) { + s.logger.Debug("call " + MethodTextDocumentImplementation) + defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) - var result []*Moniker - if err := Call(ctx, s.Conn, MethodTextDocumentMoniker, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { return nil, err } @@ -1626,11 +1484,10 @@ func (s *server) TextDocumentMoniker(ctx context.Context, params *MonikerParams) } // OnTypeFormatting sends the request from the client to the server to format parts of the document during typing. -func (s *server) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (_ []*TextEdit, err error) { +func (s *server) OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentOnTypeFormatting) defer s.logger.Debug("end "+MethodTextDocumentOnTypeFormatting, zap.Error(err)) - var result []*TextEdit if err := Call(ctx, s.Conn, MethodTextDocumentOnTypeFormatting, params, &result); err != nil { return nil, err } @@ -1638,33 +1495,13 @@ func (s *server) TextDocumentOnTypeFormatting(ctx context.Context, params *Docum return result, nil } -// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. -// -// The call hierarchy requests are executed in two steps: -// 1. first a call hierarchy item is resolved for the given text document position -// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. -// -// @since 3.16.0. -func (s *server) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (_ []*CallHierarchyItem, err error) { - s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) - defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) - - var result []*CallHierarchyItem - if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // PrepareRename sends the request from the client to the server to setup and test the validity of a rename operation at a given location. // // @since version 3.12.0. -func (s *server) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (_ *PrepareRenameResult, err error) { +func (s *server) PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) { s.logger.Debug("call " + MethodTextDocumentPrepareRename) defer s.logger.Debug("end "+MethodTextDocumentPrepareRename, zap.Error(err)) - var result *PrepareRenameResult if err := Call(ctx, s.Conn, MethodTextDocumentPrepareRename, params, &result); err != nil { return nil, err } @@ -1672,24 +1509,11 @@ func (s *server) TextDocumentPrepareRename(ctx context.Context, params *PrepareR return result, nil } -func (s *server) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) (_ []*TypeHierarchyItem, err error) { - s.logger.Debug("call " + MethodTextDocumentPrepareTypeHierarchy) - defer s.logger.Debug("end "+MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) - - var result []*TypeHierarchyItem - if err := Call(ctx, s.Conn, MethodTextDocumentPrepareTypeHierarchy, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // RangeFormatting sends the request from the client to the server to format a given range in a document. -func (s *server) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (_ []*TextEdit, err error) { +func (s *server) RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentRangeFormatting) defer s.logger.Debug("end "+MethodTextDocumentRangeFormatting, zap.Error(err)) - var result []*TextEdit if err := Call(ctx, s.Conn, MethodTextDocumentRangeFormatting, params, &result); err != nil { return nil, err } @@ -1697,24 +1521,11 @@ func (s *server) TextDocumentRangeFormatting(ctx context.Context, params *Docume return result, nil } -func (s *server) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) (_ []*TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentRangesFormatting) - defer s.logger.Debug("end "+MethodTextDocumentRangesFormatting, zap.Error(err)) - - var result []*TextEdit - if err := Call(ctx, s.Conn, MethodTextDocumentRangesFormatting, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // References sends the request from the client to the server to resolve project-wide references for the symbol denoted by the given text document position. -func (s *server) TextDocumentReferences(ctx context.Context, params *ReferenceParams) (_ []*Location, err error) { +func (s *server) References(ctx context.Context, params *ReferenceParams) (result []Location, err error) { s.logger.Debug("call " + MethodTextDocumentReferences) defer s.logger.Debug("end "+MethodTextDocumentReferences, zap.Error(err)) - var result []*Location if err := Call(ctx, s.Conn, MethodTextDocumentReferences, params, &result); err != nil { return nil, err } @@ -1723,11 +1534,10 @@ func (s *server) TextDocumentReferences(ctx context.Context, params *ReferencePa } // Rename sends the request from the client to the server to perform a workspace-wide rename of a symbol. -func (s *server) TextDocumentRename(ctx context.Context, params *RenameParams) (_ *WorkspaceEdit, err error) { +func (s *server) Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) { s.logger.Debug("call " + MethodTextDocumentRename) defer s.logger.Debug("end "+MethodTextDocumentRename, zap.Error(err)) - var result *WorkspaceEdit if err := Call(ctx, s.Conn, MethodTextDocumentRename, params, &result); err != nil { return nil, err } @@ -1735,250 +1545,335 @@ func (s *server) TextDocumentRename(ctx context.Context, params *RenameParams) ( return result, nil } -func (s *server) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) (_ []*SelectionRange, err error) { - s.logger.Debug("call " + MethodTextDocumentSelectionRange) - defer s.logger.Debug("end "+MethodTextDocumentSelectionRange, zap.Error(err)) +// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. +func (s *server) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { + s.logger.Debug("call " + MethodTextDocumentSignatureHelp) + defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) - var result []*SelectionRange - if err := Call(ctx, s.Conn, MethodTextDocumentSelectionRange, params, &result); err != nil { + var result *SignatureHelp + if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. -// -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. -// -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. -// -// @since 3.16.0. -func (s *server) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (_ *SemanticTokens, err error) { - s.logger.Debug("call " + MethodTextDocumentSemanticTokensFull) - defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFull, zap.Error(err)) +// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. +func (s *server) Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbol) + defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) - var result *SemanticTokens - if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFull, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. -// -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. // -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. // -// @since 3.16.0. -func (s *server) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (_ *TextDocumentSemanticTokensFullDeltaResult, err error) { - s.logger.Debug("call " + MethodTextDocumentSemanticTokensFullDelta) - defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) +// @since version 3.6.0. +func (s *server) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) { + s.logger.Debug("call " + MethodTextDocumentTypeDefinition) + defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) - var result *TextDocumentSemanticTokensFullDeltaResult - if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFullDelta, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. -// -// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). -// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. -// -// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. +// WillSave sends the notification from the client to the server before the document is actually saved. +func (s *server) WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentWillSave) + defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) +} + +// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. // -// @since 3.16.0. -func (s *server) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (_ *SemanticTokens, err error) { - s.logger.Debug("call " + MethodTextDocumentSemanticTokensRange) - defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensRange, zap.Error(err)) +// The request can return an array of TextEdits which will be applied to the text document before it is saved. +// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. +// This is done to keep the save fast and reliable. +func (s *server) WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) + defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - var result *SemanticTokens - if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensRange, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { return nil, err } return result, nil } -// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. -func (s *server) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { - s.logger.Debug("call " + MethodTextDocumentSignatureHelp) - defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) +// ShowDocument sends the request from a server to a client to ask the client to display a particular document in the user interface. +// +// @since 3.16.0. +func (s *server) ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) { + s.logger.Debug("call " + MethodShowDocument) + defer s.logger.Debug("end "+MethodShowDocument, zap.Error(err)) - var result *SignatureHelp - if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodShowDocument, params, &result); err != nil { return nil, err } return result, nil } -// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. +// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. // -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. // -// @since version 3.6.0. -func (s *server) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (_ *TextDocumentTypeDefinitionResult, err error) { - s.logger.Debug("call " + MethodTextDocumentTypeDefinition) - defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. +// +// @since 3.16.0. +func (s *server) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWillCreateFiles) + defer s.logger.Debug("end "+MethodWillCreateFiles, zap.Error(err)) - var result *TextDocumentTypeDefinitionResult - if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWillCreateFiles, params, &result); err != nil { return nil, err } return result, nil } -// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. +// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. // -// The request can return an array of TextEdits which will be applied to the text document before it is saved. -// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. -// This is done to keep the save fast and reliable. -func (s *server) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (_ []*TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) - defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) +// @since 3.16.0. +func (s *server) DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { + s.logger.Debug("call " + MethodDidCreateFiles) + defer s.logger.Debug("end "+MethodDidCreateFiles, zap.Error(err)) - var result []*TextEdit - if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { + return s.Conn.Notify(ctx, MethodDidCreateFiles, params) +} + +// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. +// +// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. +// +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. +// +// @since 3.16.0. +func (s *server) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWillRenameFiles) + defer s.logger.Debug("end "+MethodWillRenameFiles, zap.Error(err)) + + if err := Call(ctx, s.Conn, MethodWillRenameFiles, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) (_ []*TypeHierarchyItem, err error) { - s.logger.Debug("call " + MethodTypeHierarchySubtypes) - defer s.logger.Debug("end "+MethodTypeHierarchySubtypes, zap.Error(err)) +// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. +// +// @since 3.16.0. +func (s *server) DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { + s.logger.Debug("call " + MethodDidRenameFiles) + defer s.logger.Debug("end "+MethodDidRenameFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodDidRenameFiles, params) +} + +// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. +// +// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. +// +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. +// +// @since 3.16.0. +func (s *server) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWillDeleteFiles) + defer s.logger.Debug("end "+MethodWillDeleteFiles, zap.Error(err)) - var result []*TypeHierarchyItem - if err := Call(ctx, s.Conn, MethodTypeHierarchySubtypes, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWillDeleteFiles, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) (_ []*TypeHierarchyItem, err error) { - s.logger.Debug("call " + MethodTypeHierarchySupertypes) - defer s.logger.Debug("end "+MethodTypeHierarchySupertypes, zap.Error(err)) +// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. +// +// @since 3.16.0. +func (s *server) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { + s.logger.Debug("call " + MethodDidDeleteFiles) + defer s.logger.Debug("end "+MethodDidDeleteFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodDidDeleteFiles, params) +} + +// CodeLensRefresh sent from the server to the client. +// +// Servers can use it to ask clients to refresh the code lenses currently shown in editors. +// As a result the client should ask the server to recompute the code lenses for these editors. +// This is useful if a server detects a configuration change which requires a re-calculation of all code lenses. +// +// Note that the client still has the freedom to delay the re-calculation of the code lenses if for example an editor is currently not visible. +// +// @since 3.16.0. +func (s *server) CodeLensRefresh(ctx context.Context) (err error) { + s.logger.Debug("call " + MethodCodeLensRefresh) + defer s.logger.Debug("end "+MethodCodeLensRefresh, zap.Error(err)) + + return Call(ctx, s.Conn, MethodCodeLensRefresh, nil, nil) +} + +// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. +// +// The call hierarchy requests are executed in two steps: +// 1. first a call hierarchy item is resolved for the given text document position +// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. +// +// @since 3.16.0. +func (s *server) PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) - var result []*TypeHierarchyItem - if err := Call(ctx, s.Conn, MethodTypeHierarchySupertypes, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (_ *WorkspaceDiagnosticReport, err error) { - s.logger.Debug("call " + MethodWorkspaceDiagnostic) - defer s.logger.Debug("end "+MethodWorkspaceDiagnostic, zap.Error(err)) +// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) - var result *WorkspaceDiagnosticReport - if err := Call(ctx, s.Conn, MethodWorkspaceDiagnostic, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { return nil, err } return result, nil } -// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. +// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. // -// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the -// request `workspace/applyEdit` which is sent from the server to the client. -func (s *server) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result any, err error) { - s.logger.Debug("call " + MethodWorkspaceExecuteCommand) - defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { return nil, err } return result, nil } -// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. -func (s *server) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (_ *WorkspaceSymbolResult, err error) { - s.logger.Debug("call " + MethodWorkspaceSymbol) - defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) +// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. +// +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// +// @since 3.16.0. +func (s *server) SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) { + s.logger.Debug("call " + MethodSemanticTokensFull) + defer s.logger.Debug("end "+MethodSemanticTokensFull, zap.Error(err)) - var result *WorkspaceSymbolResult - if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodSemanticTokensFull, params, &result); err != nil { return nil, err } return result, nil } -// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. +// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. // // @since 3.16.0. -func (s *server) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (_ *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWorkspaceWillCreateFiles) - defer s.logger.Debug("end "+MethodWorkspaceWillCreateFiles, zap.Error(err)) +func (s *server) SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{}, err error) { + s.logger.Debug("call " + MethodSemanticTokensFullDelta) + defer s.logger.Debug("end "+MethodSemanticTokensFullDelta, zap.Error(err)) - var result *WorkspaceEdit - if err := Call(ctx, s.Conn, MethodWorkspaceWillCreateFiles, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodSemanticTokensFullDelta, params, &result); err != nil { return nil, err } return result, nil } -// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. +// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. +// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). +// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. +// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. // // @since 3.16.0. -func (s *server) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (_ *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWorkspaceWillDeleteFiles) - defer s.logger.Debug("end "+MethodWorkspaceWillDeleteFiles, zap.Error(err)) +func (s *server) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) { + s.logger.Debug("call " + MethodSemanticTokensRange) + defer s.logger.Debug("end "+MethodSemanticTokensRange, zap.Error(err)) - var result *WorkspaceEdit - if err := Call(ctx, s.Conn, MethodWorkspaceWillDeleteFiles, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodSemanticTokensRange, params, &result); err != nil { return nil, err } return result, nil } -// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. +// SemanticTokensRefresh is sent from the server to the client. Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. +// As a result the client should ask the server to recompute the semantic tokens for these editors. +// This is useful if a server detects a project wide configuration change which requires a re-calculation of all semantic tokens. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. +// Note that the client still has the freedom to delay the re-calculation of the semantic tokens if for example an editor is currently not visible. +// +// @since 3.16.0. +func (s *server) SemanticTokensRefresh(ctx context.Context) (err error) { + s.logger.Debug("call " + MethodSemanticTokensRefresh) + defer s.logger.Debug("end "+MethodSemanticTokensRefresh, zap.Error(err)) + + return Call(ctx, s.Conn, MethodSemanticTokensRefresh, nil, nil) +} + +// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. +// +// Optionally a word pattern can be returned to describe valid contents. +// +// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. // // @since 3.16.0. -func (s *server) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (_ *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWorkspaceWillRenameFiles) - defer s.logger.Debug("end "+MethodWorkspaceWillRenameFiles, zap.Error(err)) +func (s *server) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) { + s.logger.Debug("call " + MethodLinkedEditingRange) + defer s.logger.Debug("end "+MethodLinkedEditingRange, zap.Error(err)) - var result *WorkspaceEdit - if err := Call(ctx, s.Conn, MethodWorkspaceWillRenameFiles, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodLinkedEditingRange, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (_ *WorkspaceSymbol, err error) { - s.logger.Debug("call " + MethodWorkspaceSymbolResolve) - defer s.logger.Debug("end "+MethodWorkspaceSymbolResolve, zap.Error(err)) +// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. +// +// An array of Moniker types is returned as response to indicate possible monikers at the given location. +// +// If no monikers can be calculated, an empty array or null should be returned. +// +// @since 3.16.0. +func (s *server) Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) { + s.logger.Debug("call " + MethodMoniker) + defer s.logger.Debug("end "+MethodMoniker, zap.Error(err)) - var result *WorkspaceSymbol - if err := Call(ctx, s.Conn, MethodWorkspaceSymbolResolve, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodMoniker, params, &result); err != nil { return nil, err } @@ -1986,14 +1881,15 @@ func (s *server) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSy } // Request sends a request from the client to the server that non-compliant with the Language Server Protocol specifications. -func (s *server) Request(ctx context.Context, method string, params any) (any, error) { +func (s *server) Request(ctx context.Context, method string, params interface{}) (interface{}, error) { s.logger.Debug("call " + method) defer s.logger.Debug("end " + method) - var result any + var result interface{} if err := Call(ctx, s.Conn, method, params, &result); err != nil { return nil, err } return result, nil } + diff --git a/tools/protocol-gen/generator/generator.go b/tools/protocol-gen/generator/generator.go index b5d05182..c985a66d 100644 --- a/tools/protocol-gen/generator/generator.go +++ b/tools/protocol-gen/generator/generator.go @@ -86,7 +86,7 @@ func (gen *Generator) writeTo(pp []Printer) (err error) { if err != nil { return err } - root := filepath.Join(filepath.Dir(filepath.Dir(cwd)), ".protocol") + root := filepath.Join(filepath.Dir(filepath.Dir(cwd)), "protocol") f, err = os.Create(filepath.Join(root, filename)) if err != nil { return fmt.Errorf("unable to open %s file: %w", filename, err) @@ -184,7 +184,7 @@ func (p *printer) WriteTo() (err error) { if err != nil { return err } - root := filepath.Join(filepath.Dir(filepath.Dir(cwd)), ".protocol") + root := filepath.Join(filepath.Dir(filepath.Dir(cwd)), "protocol") f, err := os.Create(filepath.Join(root, p.filename)) if err != nil { return fmt.Errorf("unable to open %s file: %w", p.filename, err) From 21fbdd7b56d57cfa6983b719a4395c8b487368de Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Wed, 8 May 2024 00:24:41 +0900 Subject: [PATCH 04/19] WIP4 Signed-off-by: Koichi Shiraishi --- client.go | 1 - protocol/lifecycle.go | 20 ++++++++++++++++++++ server.go | 1 - 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 1f9817bb..e3df68e2 100644 --- a/client.go +++ b/client.go @@ -411,4 +411,3 @@ func (c *client) WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder return result, nil } - diff --git a/protocol/lifecycle.go b/protocol/lifecycle.go index dff7e64d..df771860 100644 --- a/protocol/lifecycle.go +++ b/protocol/lifecycle.go @@ -3,6 +3,8 @@ package protocol +import "bytes" + // TextDocumentSyncKind defines how the host (editor) should sync document changes to the language server. type TextDocumentSyncKind uint32 @@ -1289,6 +1291,24 @@ type ServerCapabilities struct { Experimental any `json:"experimental,omitempty"` } +func (t ServerCapabilities) MarshalJSON() ([]byte, error) { + var b bytes.Buffer + buf, err := t.TextDocumentSync.MarshalJSON() + if err != nil { + return nil, err + } + b.Write(buf) + + return b.Bytes(), nil +} + +func (t *ServerCapabilities) UnmarshalJSON(x []byte) error { + if err := t.TextDocumentSync.UnmarshalJSON(x); err != nil { + return err + } + return nil +} + // ServerInfo information about the server 3.15.0 3.18.0 ServerInfo type name added. @proposed. // // @since 3.18.0 ServerInfo type name added. proposed diff --git a/server.go b/server.go index fb7e693e..a7ce1717 100644 --- a/server.go +++ b/server.go @@ -1892,4 +1892,3 @@ func (s *server) Request(ctx context.Context, method string, params interface{}) return result, nil } - From 326da7df1edeaac46cb51e02c6dd48b7a6dd3a1d Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Wed, 9 Oct 2024 04:50:18 +0900 Subject: [PATCH 05/19] tools: switch to use incu6us/goimports-reviser and update to latest Signed-off-by: Koichi Shiraishi --- Makefile | 7 +- tools/go.mod | 127 ++++++++++----------- tools/go.sum | 302 ++++++++++++++++++++++++++----------------------- tools/tools.go | 2 +- 4 files changed, 232 insertions(+), 206 deletions(-) diff --git a/Makefile b/Makefile index fcf09fca..e40dd405 100644 --- a/Makefile +++ b/Makefile @@ -64,9 +64,10 @@ coverage: tools/bin/gotestsum ## Takes packages test coverage. ##@ fmt, lint .PHONY: fmt -fmt: tools/goimportz tools/gofumpt ## Run goimportz and gofumpt. +fmt: tools/goimports-reviser tools/gofumpt ## Run goimports-reviser and gofumpt. $(call target) - find . -iname "*.go" -not -path "./vendor/**" | xargs -P ${JOBS} ${TOOLS_BIN}/goimportz -local=${PKG},$(subst /protocol,,$(PKG)) -w + @${TOOLS_BIN}/goimports-reviser -use-cache -project-name ${PKG} -company-prefixes $(dir ${PKG}) -set-alias -excludes "vendor/*,tools/*,_*,**/.*" ./... + ${TOOLS_BIN}/gofumpt -extra -w . find . -iname "*.go" -not -path "./vendor/**" | xargs -P ${JOBS} ${TOOLS_BIN}/gofumpt -extra -w .PHONY: lint @@ -89,7 +90,7 @@ tools/%: ## install an individual dependent tool tools/bin/%: ${TOOLS_DIR}/go.mod ${TOOLS_DIR}/go.sum @cd tools; \ for t in ${TOOLS}; do \ - if [ -z '$*' ] || [ $$(basename $$t) = '$*' ]; then \ + if [ -z '$*' ] || [ $$(basename $${t%%/v[0-9]*}) = '$*' ]; then \ echo "Install $$t ..." >&2; \ GOBIN=${TOOLS_BIN} CGO_ENABLED=0 go install -mod=mod ${GO_FLAGS} "$${t}"; \ fi \ diff --git a/tools/go.mod b/tools/go.mod index 29cdcd63..b6b6ec53 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,26 +1,27 @@ module go.lsp.dev/protocol/tools -go 1.22.2 +go 1.23 require ( - github.com/golangci/golangci-lint v1.57.2 - github.com/zchee/goimportz v1.1.0 - gotest.tools/gotestsum v1.11.0 - mvdan.cc/gofumpt v0.6.0 + github.com/golangci/golangci-lint v1.61.0 + github.com/incu6us/goimports-reviser/v3 v3.6.5 + gotest.tools/gotestsum v1.12.0 + mvdan.cc/gofumpt v0.7.0 ) require ( 4d63.com/gocheckcompilerdirectives v1.2.1 // indirect 4d63.com/gochecknoglobals v0.2.1 // indirect - github.com/4meepo/tagalign v1.3.3 // indirect - github.com/Abirdcfly/dupword v0.0.14 // indirect - github.com/Antonboom/errname v0.1.12 // indirect - github.com/Antonboom/nilnil v0.1.7 // indirect - github.com/Antonboom/testifylint v1.2.0 // indirect - github.com/BurntSushi/toml v1.3.2 // indirect + github.com/4meepo/tagalign v1.3.4 // indirect + github.com/Abirdcfly/dupword v0.1.1 // indirect + github.com/Antonboom/errname v0.1.13 // indirect + github.com/Antonboom/nilnil v0.1.9 // indirect + github.com/Antonboom/testifylint v1.4.3 // indirect + github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect + github.com/Crocmagnon/fatcontext v0.5.2 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect - github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0 // indirect - github.com/Masterminds/semver v1.5.0 // indirect + github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 // indirect + github.com/Masterminds/semver/v3 v3.3.0 // indirect github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect github.com/alecthomas/go-check-sumtype v0.1.4 // indirect github.com/alexkohler/nakedret/v2 v2.0.4 // indirect @@ -29,33 +30,33 @@ require ( github.com/ashanbrown/forbidigo v1.6.0 // indirect github.com/ashanbrown/makezero v1.1.1 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bitfield/gotestdox v0.2.1 // indirect + github.com/bitfield/gotestdox v0.2.2 // indirect github.com/bkielbasa/cyclop v1.2.1 // indirect github.com/blizzy78/varnamelen v0.8.0 // indirect - github.com/bombsimon/wsl/v4 v4.2.1 // indirect + github.com/bombsimon/wsl/v4 v4.4.1 // indirect github.com/breml/bidichk v0.2.7 // indirect github.com/breml/errchkjson v0.3.6 // indirect github.com/butuzov/ireturn v0.3.0 // indirect - github.com/butuzov/mirror v1.1.0 // indirect + github.com/butuzov/mirror v1.2.0 // indirect github.com/catenacyber/perfsprint v0.7.1 // indirect github.com/ccojocar/zxcvbn-go v1.0.2 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/charithe/durationcheck v0.0.10 // indirect github.com/chavacava/garif v0.1.0 // indirect - github.com/ckaznocha/intrange v0.1.1 // indirect + github.com/ckaznocha/intrange v0.2.0 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect - github.com/daixiang0/gci v0.12.3 // indirect + github.com/daixiang0/gci v0.13.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/dnephin/pflag v1.0.7 // indirect github.com/ettle/strcase v0.2.0 // indirect - github.com/fatih/color v1.16.0 // indirect + github.com/fatih/color v1.17.0 // indirect github.com/fatih/structtag v1.2.0 // indirect - github.com/firefart/nonamedreturns v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/firefart/nonamedreturns v1.0.5 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect - github.com/ghostiam/protogetter v0.3.5 // indirect - github.com/go-critic/go-critic v0.11.2 // indirect + github.com/ghostiam/protogetter v0.3.6 // indirect + github.com/go-critic/go-critic v0.11.4 // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect github.com/go-toolsmith/astequal v1.2.0 // indirect @@ -63,16 +64,17 @@ require ( github.com/go-toolsmith/astp v1.1.0 // indirect github.com/go-toolsmith/strparse v1.1.0 // indirect github.com/go-toolsmith/typep v1.1.0 // indirect - github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect + github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gofrs/flock v0.8.1 // indirect + github.com/gofrs/flock v0.12.1 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect - github.com/golangci/gofmt v0.0.0-20231018234816-f50ced29576e // indirect - github.com/golangci/misspell v0.4.1 // indirect + github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 // indirect + github.com/golangci/misspell v0.6.0 // indirect + github.com/golangci/modinfo v0.3.4 // indirect github.com/golangci/plugin-module-register v0.1.1 // indirect - github.com/golangci/revgrep v0.5.2 // indirect + github.com/golangci/revgrep v0.5.3 // indirect github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect @@ -81,24 +83,25 @@ require ( github.com/gostaticanalysis/comment v1.4.2 // indirect github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jgautheron/goconst v1.7.1 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect - github.com/jjti/go-spancheck v0.5.3 // indirect + github.com/jjti/go-spancheck v0.6.2 // indirect github.com/julz/importas v0.1.0 // indirect - github.com/karamaru-alpha/copyloopvar v1.0.10 // indirect + github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect github.com/kisielk/errcheck v1.7.0 // indirect github.com/kkHAIKE/contextcheck v1.1.5 // indirect github.com/kulti/thelper v0.6.3 // indirect github.com/kunwardeep/paralleltest v1.0.10 // indirect github.com/kyoh86/exportloopref v0.1.11 // indirect + github.com/lasiar/canonicalheader v1.1.1 // indirect github.com/ldez/gomoddirectives v0.2.4 // indirect github.com/ldez/tagliatelle v0.5.0 // indirect - github.com/leonklingele/grouper v1.1.1 // indirect + github.com/leonklingele/grouper v1.1.2 // indirect github.com/lufeee/execinquery v1.2.1 // indirect github.com/macabu/inamedparam v0.1.3 // indirect github.com/magiconair/properties v1.8.6 // indirect @@ -109,44 +112,44 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mgechev/revive v1.3.7 // indirect + github.com/mgechev/revive v1.3.9 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/moricho/tparallel v0.3.1 // indirect + github.com/moricho/tparallel v0.3.2 // indirect github.com/nakabonne/nestif v0.3.1 // indirect - github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/nishanths/exhaustive v0.12.0 // indirect github.com/nishanths/predeclared v0.2.2 // indirect github.com/nunnatsa/ginkgolinter v0.16.2 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml v1.9.5 // indirect - github.com/pelletier/go-toml/v2 v2.2.0 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/polyfloyd/go-errorlint v1.4.8 // indirect + github.com/polyfloyd/go-errorlint v1.6.0 // indirect github.com/prometheus/client_golang v1.12.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect - github.com/quasilyte/go-ruleguard v0.4.2 // indirect + github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 // indirect + github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect github.com/quasilyte/gogrep v0.5.0 // indirect github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect - github.com/ryancurrah/gomodguard v1.3.1 // indirect + github.com/ryancurrah/gomodguard v1.3.5 // indirect github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect github.com/sashamelentyev/interfacebloat v1.1.0 // indirect - github.com/sashamelentyev/usestdlibvars v1.25.0 // indirect - github.com/securego/gosec/v2 v2.19.0 // indirect + github.com/sashamelentyev/usestdlibvars v1.27.0 // indirect + github.com/securego/gosec/v2 v2.21.2 // indirect github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/sivchari/containedctx v1.0.3 // indirect - github.com/sivchari/tenv v1.7.1 // indirect + github.com/sivchari/tenv v1.10.0 // indirect github.com/sonatard/noctx v0.0.2 // indirect github.com/sourcegraph/go-diff v0.7.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.5.0 // indirect - github.com/spf13/cobra v1.7.0 // indirect + github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.12.0 // indirect @@ -155,40 +158,38 @@ require ( github.com/stretchr/objx v0.5.2 // indirect github.com/stretchr/testify v1.9.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect - github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect github.com/tdakkota/asciicheck v0.2.0 // indirect - github.com/tetafro/godot v1.4.16 // indirect + github.com/tetafro/godot v1.4.17 // indirect github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 // indirect github.com/timonwong/loggercheck v0.9.4 // indirect - github.com/tomarrell/wrapcheck/v2 v2.8.3 // indirect + github.com/tomarrell/wrapcheck/v2 v2.9.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect github.com/ultraware/funlen v0.1.0 // indirect - github.com/ultraware/whitespace v0.1.0 // indirect - github.com/uudashr/gocognit v1.1.2 // indirect + github.com/ultraware/whitespace v0.1.1 // indirect + github.com/uudashr/gocognit v1.1.3 // indirect github.com/xen0n/gosmopolitan v1.2.2 // indirect github.com/yagipy/maintidx v1.0.0 // indirect - github.com/yeya24/promlinter v0.2.0 // indirect + github.com/yeya24/promlinter v0.3.0 // indirect github.com/ykadowak/zerologlint v0.1.5 // indirect - gitlab.com/bosi/decorder v0.4.1 // indirect - go-simpler.org/musttag v0.9.0 // indirect - go-simpler.org/sloglint v0.5.0 // indirect + gitlab.com/bosi/decorder v0.4.2 // indirect + go-simpler.org/musttag v0.12.2 // indirect + go-simpler.org/sloglint v0.7.2 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/automaxprocs v1.5.3 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect + golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect - golang.org/x/mod v0.16.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.10.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.19.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect - gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect + golang.org/x/mod v0.21.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.18.0 // indirect + golang.org/x/text v0.18.0 // indirect + golang.org/x/tools v0.24.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - honnef.co/go/tools v0.4.7 // indirect - mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14 // indirect + honnef.co/go/tools v0.5.1 // indirect + mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect ) diff --git a/tools/go.sum b/tools/go.sum index 9077cd8c..e7ac12d7 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -35,26 +35,28 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/4meepo/tagalign v1.3.3 h1:ZsOxcwGD/jP4U/aw7qeWu58i7dwYemfy5Y+IF1ACoNw= -github.com/4meepo/tagalign v1.3.3/go.mod h1:Q9c1rYMZJc9dPRkbQPpcBNCLEmY2njbAsXhQOZFE2dE= -github.com/Abirdcfly/dupword v0.0.14 h1:3U4ulkc8EUo+CaT105/GJ1BQwtgyj6+VaBVbAX11Ba8= -github.com/Abirdcfly/dupword v0.0.14/go.mod h1:VKDAbxdY8YbKUByLGg8EETzYSuC4crm9WwI6Y3S0cLI= -github.com/Antonboom/errname v0.1.12 h1:oh9ak2zUtsLp5oaEd/erjB4GPu9w19NyoIskZClDcQY= -github.com/Antonboom/errname v0.1.12/go.mod h1:bK7todrzvlaZoQagP1orKzWXv59X/x0W0Io2XT1Ssro= -github.com/Antonboom/nilnil v0.1.7 h1:ofgL+BA7vlA1K2wNQOsHzLJ2Pw5B5DpWRLdDAVvvTow= -github.com/Antonboom/nilnil v0.1.7/go.mod h1:TP+ScQWVEq0eSIxqU8CbdT5DFWoHp0MbP+KMUO1BKYQ= -github.com/Antonboom/testifylint v1.2.0 h1:015bxD8zc5iY8QwTp4+RG9I4kIbqwvGX9TrBbb7jGdM= -github.com/Antonboom/testifylint v1.2.0/go.mod h1:rkmEqjqVnHDRNsinyN6fPSLnoajzFwsCcguJgwADBkw= +github.com/4meepo/tagalign v1.3.4 h1:P51VcvBnf04YkHzjfclN6BbsopfJR5rxs1n+5zHt+w8= +github.com/4meepo/tagalign v1.3.4/go.mod h1:M+pnkHH2vG8+qhE5bVc/zeP7HS/j910Fwa9TUSyZVI0= +github.com/Abirdcfly/dupword v0.1.1 h1:Bsxe0fIw6OwBtXMIncaTxCLHYO5BB+3mcsR5E8VXloY= +github.com/Abirdcfly/dupword v0.1.1/go.mod h1:B49AcJdTYYkpd4HjgAcutNGG9HZ2JWwKunH9Y2BA6sM= +github.com/Antonboom/errname v0.1.13 h1:JHICqsewj/fNckzrfVSe+T33svwQxmjC+1ntDsHOVvM= +github.com/Antonboom/errname v0.1.13/go.mod h1:uWyefRYRN54lBg6HseYCFhs6Qjcy41Y3Jl/dVhA87Ns= +github.com/Antonboom/nilnil v0.1.9 h1:eKFMejSxPSA9eLSensFmjW2XTgTwJMjZ8hUHtV4s/SQ= +github.com/Antonboom/nilnil v0.1.9/go.mod h1:iGe2rYwCq5/Me1khrysB4nwI7swQvjclR8/YRPl5ihQ= +github.com/Antonboom/testifylint v1.4.3 h1:ohMt6AHuHgttaQ1xb6SSnxCeK4/rnK7KKzbvs7DmEck= +github.com/Antonboom/testifylint v1.4.3/go.mod h1:+8Q9+AOLsz5ZiQiiYujJKs9mNz398+M6UgslP4qgJLA= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= +github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Crocmagnon/fatcontext v0.5.2 h1:vhSEg8Gqng8awhPju2w7MKHqMlg4/NI+gSDHtR3xgwA= +github.com/Crocmagnon/fatcontext v0.5.2/go.mod h1:87XhRMaInHP44Q7Tlc7jkgKKB7kZAOPiDkFMdKCC+74= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= -github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0 h1:sATXp1x6/axKxz2Gjxv8MALP0bXaNRfQinEwyfMcx8c= -github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0/go.mod h1:Nl76DrGNJTA1KJ0LePKBw/vznBX1EHbAZX8mwjR82nI= -github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= -github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 h1:/fTUt5vmbkAcMBt4YQiuC23cV0kEsN1MVMNqeOW43cU= +github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0/go.mod h1:ONJg5sxcbsdQQ4pOW8TGdTidT2TMAUy/2Xhr8mrYaao= +github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= +github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/OpenPeeDeeP/depguard/v2 v2.2.0 h1:vDfG60vDtIuf0MEOhmLlLLSzqaRM8EMcgJPdp74zmpA= github.com/OpenPeeDeeP/depguard/v2 v2.2.0/go.mod h1:CIzddKRvLBC4Au5aYP/i3nyaWQ+ClszLIuVocRiCYFQ= github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk= @@ -84,22 +86,22 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bitfield/gotestdox v0.2.1 h1:Zj8IMLAO5/oiAKoMmtN96eyFiPZraJRTH2p0zDgtxc0= -github.com/bitfield/gotestdox v0.2.1/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY= +github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE= +github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY= github.com/bkielbasa/cyclop v1.2.1 h1:AeF71HZDob1P2/pRm1so9cd1alZnrpyc4q2uP2l0gJY= github.com/bkielbasa/cyclop v1.2.1/go.mod h1:K/dT/M0FPAiYjBgQGau7tz+3TMh4FWAEqlMhzFWCrgM= github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M= github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= -github.com/bombsimon/wsl/v4 v4.2.1 h1:Cxg6u+XDWff75SIFFmNsqnIOgob+Q9hG6y/ioKbRFiM= -github.com/bombsimon/wsl/v4 v4.2.1/go.mod h1:Xu/kDxGZTofQcDGCtQe9KCzhHphIe0fDuyWTxER9Feo= +github.com/bombsimon/wsl/v4 v4.4.1 h1:jfUaCkN+aUpobrMO24zwyAMwMAV5eSziCkOKEauOLdw= +github.com/bombsimon/wsl/v4 v4.4.1/go.mod h1:Xu/kDxGZTofQcDGCtQe9KCzhHphIe0fDuyWTxER9Feo= github.com/breml/bidichk v0.2.7 h1:dAkKQPLl/Qrk7hnP6P+E0xOodrq8Us7+U0o4UBOAlQY= github.com/breml/bidichk v0.2.7/go.mod h1:YodjipAGI9fGcYM7II6wFvGhdMYsC5pHDlGzqvEW3tQ= github.com/breml/errchkjson v0.3.6 h1:VLhVkqSBH96AvXEyclMR37rZslRrY2kcyq+31HCsVrA= github.com/breml/errchkjson v0.3.6/go.mod h1:jhSDoFheAF2RSDOlCfhHO9KqhZgAYLyvHe7bRCX8f/U= github.com/butuzov/ireturn v0.3.0 h1:hTjMqWw3y5JC3kpnC5vXmFJAWI/m31jaCYQqzkS6PL0= github.com/butuzov/ireturn v0.3.0/go.mod h1:A09nIiwiqzN/IoVo9ogpa0Hzi9fex1kd9PSD6edP5ZA= -github.com/butuzov/mirror v1.1.0 h1:ZqX54gBVMXu78QLoiqdwpl2mgmoOJTk7s4p4o+0avZI= -github.com/butuzov/mirror v1.1.0/go.mod h1:8Q0BdQU6rC6WILDiBM60DBfvV78OLJmMmixe7GF45AE= +github.com/butuzov/mirror v1.2.0 h1:9YVK1qIjNspaqWutSv8gsge2e/Xpq1eqEkslEUHy5cs= +github.com/butuzov/mirror v1.2.0/go.mod h1:DqZZDtzm42wIAIyHXeN8W/qb1EPlb9Qn/if9icBOpdQ= github.com/catenacyber/perfsprint v0.7.1 h1:PGW5G/Kxn+YrN04cRAZKC+ZuvlVwolYMrIyyTJ/rMmc= github.com/catenacyber/perfsprint v0.7.1/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50= github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg= @@ -115,15 +117,15 @@ github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+U github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/ckaznocha/intrange v0.1.1 h1:gHe4LfqCspWkh8KpJFs20fJz3XRHFBFUV9yI7Itu83Q= -github.com/ckaznocha/intrange v0.1.1/go.mod h1:RWffCw/vKBwHeOEwWdCikAtY0q4gGt8VhJZEEA5n+RE= +github.com/ckaznocha/intrange v0.2.0 h1:FykcZuJ8BD7oX93YbO1UY9oZtkRbp+1/kJcDjkefYLs= +github.com/ckaznocha/intrange v0.2.0/go.mod h1:r5I7nUlAAG56xmkOpw4XVr16BXhwYTUdcuRFeevn1oE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo= github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc= -github.com/daixiang0/gci v0.12.3 h1:yOZI7VAxAGPQmkb1eqt5g/11SUlwoat1fSblGLmdiQc= -github.com/daixiang0/gci v0.12.3/go.mod h1:xtHP9N7AHdNvtRNfcx9gwTDfw7FRJx4bZUsiEfiNNAI= +github.com/daixiang0/gci v0.13.5 h1:kThgmH1yBmZSBCh1EJVxQ7JsHpm5Oms0AMed/0LaH4c= +github.com/daixiang0/gci v0.13.5/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -138,22 +140,23 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q= github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= -github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= -github.com/firefart/nonamedreturns v1.0.4 h1:abzI1p7mAEPYuR4A+VLKn4eNDOycjYo2phmY9sfv40Y= -github.com/firefart/nonamedreturns v1.0.4/go.mod h1:TDhe/tjI1BXo48CmYbUduTV7BdIga8MAO/xbKdcVsGI= -github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= -github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= -github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/firefart/nonamedreturns v1.0.5 h1:tM+Me2ZaXs8tfdDw3X6DOX++wMCOqzYUho6tUTYIdRA= +github.com/firefart/nonamedreturns v1.0.5/go.mod h1:gHJjDqhGM4WyPt639SOZs+G89Ko7QKH5R5BhnO6xJhw= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= -github.com/ghostiam/protogetter v0.3.5 h1:+f7UiF8XNd4w3a//4DnusQ2SZjPkUjxkMEfjbxOK4Ug= -github.com/ghostiam/protogetter v0.3.5/go.mod h1:7lpeDnEJ1ZjL/YtyoN99ljO4z0pd3H0d18/t2dPBxHw= -github.com/go-critic/go-critic v0.11.2 h1:81xH/2muBphEgPtcwH1p6QD+KzXl2tMSi3hXjBSxDnM= -github.com/go-critic/go-critic v0.11.2/go.mod h1:OePaicfjsf+KPy33yq4gzv6CO7TEQ9Rom6ns1KsJnl8= +github.com/ghostiam/protogetter v0.3.6 h1:R7qEWaSgFCsy20yYHNIJsU9ZOb8TziSRRxuAOTVKeOk= +github.com/ghostiam/protogetter v0.3.6/go.mod h1:7lpeDnEJ1ZjL/YtyoN99ljO4z0pd3H0d18/t2dPBxHw= +github.com/go-critic/go-critic v0.11.4 h1:O7kGOCx0NDIni4czrkRIXTnit0mkyKOCePh3My6OyEU= +github.com/go-critic/go-critic v0.11.4/go.mod h1:2QAdo4iuLik5S9YG0rT4wcZ8QxwHYkrr6/2MWAiv/vc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -163,11 +166,13 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= +github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-toolsmith/astcast v1.1.0 h1:+JN9xZV1A+Re+95pgnMgDboWNVnIMMQXwfBwLRPgSC8= github.com/go-toolsmith/astcast v1.1.0/go.mod h1:qdcuFWeGGS2xX5bLM/c3U9lewg7+Zu4mr+xPwZIB4ZU= github.com/go-toolsmith/astcopy v1.1.0 h1:YGwBN0WM+ekI/6SS6+52zLDEf8Yvp3n2seZITCUBt5s= @@ -187,14 +192,14 @@ github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQi github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ= github.com/go-toolsmith/typep v1.1.0 h1:fIRYDyF+JywLfqzyhdiHzRop/GQDxxNhLGQ6gFUNHus= github.com/go-toolsmith/typep v1.1.0/go.mod h1:fVIw+7zjdsMxDA3ITWnH1yOiw1rnTQKCsF/sk2H/qig= -github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 h1:TQcrn6Wq+sKGkpyPvppOz99zsMBaUOKXq6HSv655U1c= -github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= +github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/go-xmlfmt/xmlfmt v1.1.2 h1:Nea7b4icn8s57fTx1M5AI4qQT5HEM3rVUO8MuE6g80U= github.com/go-xmlfmt/xmlfmt v1.1.2/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= +github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -227,16 +232,18 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a h1:w8hkcTqaFpzKqonE9uMCefW1WDie15eSP/4MssdenaM= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= -github.com/golangci/gofmt v0.0.0-20231018234816-f50ced29576e h1:ULcKCDV1LOZPFxGZaA6TlQbiM3J2GCPnkx/bGF6sX/g= -github.com/golangci/gofmt v0.0.0-20231018234816-f50ced29576e/go.mod h1:Pm5KhLPA8gSnQwrQ6ukebRcapGb/BG9iUkdaiCcGHJM= -github.com/golangci/golangci-lint v1.57.2 h1:NNhxfZyL5He1WWDrIvl1a4n5bvWZBcgAqBwlJAAgLTw= -github.com/golangci/golangci-lint v1.57.2/go.mod h1:ApiG3S3Ca23QyfGp5BmsorTiVxJpr5jGiNS0BkdSidg= -github.com/golangci/misspell v0.4.1 h1:+y73iSicVy2PqyX7kmUefHusENlrP9YwuHZHPLGQj/g= -github.com/golangci/misspell v0.4.1/go.mod h1:9mAN1quEo3DlpbaIKKyEvRxK1pwqR9s/Sea1bJCtlNI= +github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 h1:/1322Qns6BtQxUZDTAT4SdcoxknUki7IAoK4SAXr8ME= +github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9/go.mod h1:Oesb/0uFAyWoaw1U1qS5zyjCg5NP9C9iwjnI4tIsXEE= +github.com/golangci/golangci-lint v1.61.0 h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8= +github.com/golangci/golangci-lint v1.61.0/go.mod h1:e4lztIrJJgLPhWvFPDkhiMwEFRrWlmFbrZea3FsJyN8= +github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs= +github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo= +github.com/golangci/modinfo v0.3.4 h1:oU5huX3fbxqQXdfspamej74DFX0kyGLkw1ppvXoJ8GA= +github.com/golangci/modinfo v0.3.4/go.mod h1:wytF1M5xl9u0ij8YSvhkEVPP3M5Mc7XLl1pxH3B2aUM= github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+2f7zX0H6Jkw1Ol6c= github.com/golangci/plugin-module-register v0.1.1/go.mod h1:TTpqoB6KkwOJMV8u7+NyXMrkwwESJLOkfl9TxR1DGFc= -github.com/golangci/revgrep v0.5.2 h1:EndcWoRhcnfj2NHQ+28hyuXpLMF+dQmCN+YaeeIl4FU= -github.com/golangci/revgrep v0.5.2/go.mod h1:bjAMA+Sh/QUfTDcHzxfyHxr4xKvllVr/0sCv2e7jJHA= +github.com/golangci/revgrep v0.5.3 h1:3tL7c1XBMtWHHqVpS5ChmiAAoe4PF/d5+ULzV9sLAzs= +github.com/golangci/revgrep v0.5.3/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k= github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed h1:IURFTjxeTfNFP0hTEi1YKjB/ub8zkpaOqFFMApi2EAs= github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed/go.mod h1:XLXN8bNw4CGRPaqgl3bv/lhz7bsGPh4/xSaMTbo2vkQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -266,8 +273,8 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= @@ -288,8 +295,8 @@ github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod github.com/gostaticanalysis/testutil v0.4.0 h1:nhdCmubdmDF6VEatUNjgUZBJKWRqugoISdUv3PPQgHY= github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Repi5x3CuviD3dgAZaBU= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -299,14 +306,16 @@ github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSo github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/incu6us/goimports-reviser/v3 v3.6.5 h1:RsdDyWW1R7hS2lp5ixpCgPzt+3MLnt1ptoW8BZgulWY= +github.com/incu6us/goimports-reviser/v3 v3.6.5/go.mod h1:r0jYpyePwPYiqxl4qjZ0xZgVEPKS/ePqVCT3XNuwR54= github.com/jgautheron/goconst v1.7.1 h1:VpdAG7Ca7yvvJk5n8dMwQhfEZJh95kl/Hl9S1OI5Jkk= github.com/jgautheron/goconst v1.7.1/go.mod h1:aAosetZ5zaeC/2EfMeRswtxUFBpe2Hr7HzkgX4fanO4= github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs= github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c= github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af h1:KA9BjwUk7KlCh6S9EAGWBt1oExIUv9WyNCiRz5amv48= github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0= -github.com/jjti/go-spancheck v0.5.3 h1:vfq4s2IB8T3HvbpiwDTYgVPj1Ze/ZSXrTtaZRTc7CuM= -github.com/jjti/go-spancheck v0.5.3/go.mod h1:eQdOX1k3T+nAKvZDyLC3Eby0La4dZ+I19iOl5NzSPFE= +github.com/jjti/go-spancheck v0.6.2 h1:iYtoxqPMzHUPp7St+5yA8+cONdyXD3ug6KK15n7Pklk= +github.com/jjti/go-spancheck v0.6.2/go.mod h1:+X7lvIrR5ZdUTkxFYqzJ0abr8Sb5LOo80uOhWNqIrYA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -318,8 +327,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/julz/importas v0.1.0 h1:F78HnrsjY3cR7j0etXy5+TU1Zuy7Xt08X/1aJnH5xXY= github.com/julz/importas v0.1.0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= -github.com/karamaru-alpha/copyloopvar v1.0.10 h1:8HYDy6KQYqTmD7JuhZMWS1nwPru9889XI24ROd/+WXI= -github.com/karamaru-alpha/copyloopvar v1.0.10/go.mod h1:u7CIfztblY0jZLOQZgH3oYsJzpC2A7S6u/lfgSXHy0k= +github.com/karamaru-alpha/copyloopvar v1.1.0 h1:x7gNyKcC2vRBO1H2Mks5u1VxQtYvFiym7fCjIP8RPos= +github.com/karamaru-alpha/copyloopvar v1.1.0/go.mod h1:u7CIfztblY0jZLOQZgH3oYsJzpC2A7S6u/lfgSXHy0k= github.com/kisielk/errcheck v1.7.0 h1:+SbscKmWJ5mOK/bO1zS60F5I9WwZDWOfRsC4RwfwRV0= github.com/kisielk/errcheck v1.7.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/FqKluHJQ= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -341,12 +350,14 @@ github.com/kunwardeep/paralleltest v1.0.10 h1:wrodoaKYzS2mdNVnc4/w31YaXFtsc21PCT github.com/kunwardeep/paralleltest v1.0.10/go.mod h1:2C7s65hONVqY7Q5Efj5aLzRCNLjw2h4eMc9EcypGjcY= github.com/kyoh86/exportloopref v0.1.11 h1:1Z0bcmTypkL3Q4k+IDHMWTcnCliEZcaPiIe0/ymEyhQ= github.com/kyoh86/exportloopref v0.1.11/go.mod h1:qkV4UF1zGl6EkF1ox8L5t9SwyeBAZ3qLMd6up458uqA= +github.com/lasiar/canonicalheader v1.1.1 h1:wC+dY9ZfiqiPwAexUApFush/csSPXeIi4QqyxXmng8I= +github.com/lasiar/canonicalheader v1.1.1/go.mod h1:cXkb3Dlk6XXy+8MVQnF23CYKWlyA7kfQhSw2CcZtZb0= github.com/ldez/gomoddirectives v0.2.4 h1:j3YjBIjEBbqZ0NKtBNzr8rtMHTOrLPeiwTkfUJZ3alg= github.com/ldez/gomoddirectives v0.2.4/go.mod h1:oWu9i62VcQDYp9EQ0ONTfqLNh+mDLWWDO+SO0qSQw5g= github.com/ldez/tagliatelle v0.5.0 h1:epgfuYt9v0CG3fms0pEgIMNPuFf/LpPIfjk4kyqSioo= github.com/ldez/tagliatelle v0.5.0/go.mod h1:rj1HmWiL1MiKQuOONhd09iySTEkUuE/8+5jtPYz9xa4= -github.com/leonklingele/grouper v1.1.1 h1:suWXRU57D4/Enn6pXR0QVqqWWrnJ9Osrz+5rjt8ivzU= -github.com/leonklingele/grouper v1.1.1/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY= +github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY= +github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= github.com/lufeee/execinquery v1.2.1 h1:hf0Ems4SHcUGBxpGN7Jz78z1ppVkP/837ZlETPCEtOM= github.com/lufeee/execinquery v1.2.1/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM= github.com/macabu/inamedparam v0.1.3 h1:2tk/phHkMlEL/1GNe/Yf6kkR/hkcUdAEY3L0hjYV1Mk= @@ -372,8 +383,8 @@ github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/Qd github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgechev/revive v1.3.7 h1:502QY0vQGe9KtYJ9FpxMz9rL+Fc/P13CI5POL4uHCcE= -github.com/mgechev/revive v1.3.7/go.mod h1:RJ16jUbF0OWC3co/+XTxmFNgEpUPwnnA0BRllX2aDNA= +github.com/mgechev/revive v1.3.9 h1:18Y3R4a2USSBF+QZKFQwVkBROUda7uoBlkEuBD+YD1A= +github.com/mgechev/revive v1.3.9/go.mod h1:+uxEIr5UH0TjXWHTno3xh4u7eg6jDpXKzQccA9UGhHU= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -383,14 +394,12 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/moricho/tparallel v0.3.1 h1:fQKD4U1wRMAYNngDonW5XupoB/ZGJHdpzrWqgyg9krA= -github.com/moricho/tparallel v0.3.1/go.mod h1:leENX2cUv7Sv2qDgdi0D0fCftN8fRC67Bcn8pqzeYNI= +github.com/moricho/tparallel v0.3.2 h1:odr8aZVFA3NZrNybggMkYO3rgPRcqjeQUlBBFVxKHTI= +github.com/moricho/tparallel v0.3.2/go.mod h1:OQ+K3b4Ln3l2TZveGCywybl68glfLEwFGqvnjok8b+U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nakabonne/nestif v0.3.1 h1:wm28nZjhQY5HyYPx+weN3Q65k6ilSBxDb8v5S81B81U= github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhKRf3Swg= github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs= github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= @@ -399,10 +408,10 @@ github.com/nunnatsa/ginkgolinter v0.16.2 h1:8iLqHIZvN4fTLDC0Ke9tbSZVcyVHoBs0HIbn github.com/nunnatsa/ginkgolinter v0.16.2/go.mod h1:4tWRinDN1FeJgU+iJANW/kz7xKN5nYRAOfJDQUS9dOQ= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= -github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= -github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= -github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= +github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= +github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= +github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= +github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= @@ -412,16 +421,16 @@ github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT9 github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo= -github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polyfloyd/go-errorlint v1.4.8 h1:jiEjKDH33ouFktyez7sckv6pHWif9B7SuS8cutDXFHw= -github.com/polyfloyd/go-errorlint v1.4.8/go.mod h1:NNCxFcFjZcw3xNjVdCchERkEM6Oz7wta2XJVxRftwO4= +github.com/polyfloyd/go-errorlint v1.6.0 h1:tftWV9DE7txiFzPpztTAwyoRLKNj9gpVm2cg8/OwcYY= +github.com/polyfloyd/go-errorlint v1.6.0/go.mod h1:HR7u8wuP1kb1NeN1zqTd1ZMlqUKPPHF+Id4vIPvDqVw= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -446,8 +455,10 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/quasilyte/go-ruleguard v0.4.2 h1:htXcXDK6/rO12kiTHKfHuqR4kr3Y4M0J0rOL6CH/BYs= -github.com/quasilyte/go-ruleguard v0.4.2/go.mod h1:GJLgqsLeo4qgavUoL8JeGFNS7qcisx3awV/w9eWTmNI= +github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 h1:+Wl/0aFp0hpuHM3H//KMft64WQ1yX9LdJY64Qm/gFCo= +github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1/go.mod h1:GJLgqsLeo4qgavUoL8JeGFNS7qcisx3awV/w9eWTmNI= +github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe60+5DqOpCjPE= +github.com/quasilyte/go-ruleguard/dsl v0.3.22/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= github.com/quasilyte/gogrep v0.5.0 h1:eTKODPXbI8ffJMN+W2aE0+oL0z/nh8/5eNdiO34SOAo= github.com/quasilyte/gogrep v0.5.0/go.mod h1:Cm9lpz9NZjEoL1tgZ2OgeUKPIxL1meE7eo60Z6Sk+Ng= github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 h1:TCg2WBOl980XxGFEZSS6KlBGIV0diGdySzxATTWoqaU= @@ -459,8 +470,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryancurrah/gomodguard v1.3.1 h1:fH+fUg+ngsQO0ruZXXHnA/2aNllWA1whly4a6UvyzGE= -github.com/ryancurrah/gomodguard v1.3.1/go.mod h1:DGFHzEhi6iJ0oIDfMuo3TgrS+L9gZvrEfmjjuelnRU0= +github.com/ryancurrah/gomodguard v1.3.5 h1:cShyguSwUEeC0jS7ylOiG/idnd1TpJ1LfHGpV3oJmPU= +github.com/ryancurrah/gomodguard v1.3.5/go.mod h1:MXlEPQRxgfPQa62O8wzK3Ozbkv9Rkqr+wKjSxTdsNJE= github.com/ryanrolds/sqlclosecheck v0.5.1 h1:dibWW826u0P8jNLsLN+En7+RqWWTYrjCB9fJfSfdyCU= github.com/ryanrolds/sqlclosecheck v0.5.1/go.mod h1:2g3dUjoS6AL4huFdv6wn55WpLIDjY7ZgUR4J8HOO/XQ= github.com/sanposhiho/wastedassign/v2 v2.0.7 h1:J+6nrY4VW+gC9xFzUc+XjPD3g3wF3je/NsJFwFK7Uxc= @@ -469,10 +480,10 @@ github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6Ng github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw= github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= -github.com/sashamelentyev/usestdlibvars v1.25.0 h1:IK8SI2QyFzy/2OD2PYnhy84dpfNo9qADrRt6LH8vSzU= -github.com/sashamelentyev/usestdlibvars v1.25.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= -github.com/securego/gosec/v2 v2.19.0 h1:gl5xMkOI0/E6Hxx0XCY2XujA3V7SNSefA8sC+3f1gnk= -github.com/securego/gosec/v2 v2.19.0/go.mod h1:hOkDcHz9J/XIgIlPDXalxjeVYsHxoWUc5zJSHxcB8YM= +github.com/sashamelentyev/usestdlibvars v1.27.0 h1:t/3jZpSXtRPRf2xr0m63i32ZrusyurIGT9E5wAvXQnI= +github.com/sashamelentyev/usestdlibvars v1.27.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= +github.com/securego/gosec/v2 v2.21.2 h1:deZp5zmYf3TWwU7A7cR2+SolbTpZ3HQiwFqnzQyEl3M= +github.com/securego/gosec/v2 v2.21.2/go.mod h1:au33kg78rNseF5PwPnTWhuYBFf534bvJRvOrgZ/bFzU= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c h1:W65qqJCIOVP4jpqPQ0YvHYKwcMEMVWIzWC5iNQQfBTU= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= @@ -484,8 +495,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE= github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= -github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak= -github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= +github.com/sivchari/tenv v1.10.0 h1:g/hzMA+dBCKqGXgW8AV/1xIWhAvDrx0zFKNR48NFMg0= +github.com/sivchari/tenv v1.10.0/go.mod h1:tdY24masnVoZFxYrHv/nD6Tc8FbkEtAQEEziXpyMgqY= github.com/sonatard/noctx v0.0.2 h1:L7Dz4De2zDQhW8S0t+KUjY0MAQJd6SgVwhzNIc4ok00= github.com/sonatard/noctx v0.0.2/go.mod h1:kzFz+CzWSjQ2OzIm46uJZoXuBpa2+0y3T36U18dWqIo= github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0= @@ -494,11 +505,10 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= @@ -525,36 +535,34 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= -github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c h1:+aPplBwWcHBo6q9xrfWdMrT9o4kltkmmvpemgIjep/8= -github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c/go.mod h1:SbErYREK7xXdsRiigaQiQkI9McGRzYMvlKYaP3Nimdk= github.com/tdakkota/asciicheck v0.2.0 h1:o8jvnUANo0qXtnslk2d3nMKTFNlOnJjRrNcj0j9qkHM= github.com/tdakkota/asciicheck v0.2.0/go.mod h1:Qb7Y9EgjCLJGup51gDHFzbI08/gbGhL/UVhYIPWG2rg= github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/tetafro/godot v1.4.16 h1:4ChfhveiNLk4NveAZ9Pu2AN8QZ2nkUGFuadM9lrr5D0= -github.com/tetafro/godot v1.4.16/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= +github.com/tetafro/godot v1.4.17 h1:pGzu+Ye7ZUEFx7LHU0dAKmCOXWsPjl7qA6iMGndsjPs= +github.com/tetafro/godot v1.4.17/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M= github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966/go.mod h1:27bSVNWSBOHm+qRp1T9qzaIpsWEP6TbUnei/43HK+PQ= github.com/timonwong/loggercheck v0.9.4 h1:HKKhqrjcVj8sxL7K77beXh0adEm6DLjV/QOGeMXEVi4= github.com/timonwong/loggercheck v0.9.4/go.mod h1:caz4zlPcgvpEkXgVnAJGowHAMW2NwHaNlpS8xDbVhTg= -github.com/tomarrell/wrapcheck/v2 v2.8.3 h1:5ov+Cbhlgi7s/a42BprYoxsr73CbdMUTzE3bRDFASUs= -github.com/tomarrell/wrapcheck/v2 v2.8.3/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= +github.com/tomarrell/wrapcheck/v2 v2.9.0 h1:801U2YCAjLhdN8zhZ/7tdjB3EnAoRlJHt/s+9hijLQ4= +github.com/tomarrell/wrapcheck/v2 v2.9.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= github.com/ultraware/funlen v0.1.0 h1:BuqclbkY6pO+cvxoq7OsktIXZpgBSkYTQtmwhAK81vI= github.com/ultraware/funlen v0.1.0/go.mod h1:XJqmOQja6DpxarLj6Jj1U7JuoS8PvL4nEqDaQhy22p4= -github.com/ultraware/whitespace v0.1.0 h1:O1HKYoh0kIeqE8sFqZf1o0qbORXUCOQFrlaQyZsczZw= -github.com/ultraware/whitespace v0.1.0/go.mod h1:/se4r3beMFNmewJ4Xmz0nMQ941GJt+qmSHGP9emHYe0= -github.com/uudashr/gocognit v1.1.2 h1:l6BAEKJqQH2UpKAPKdMfZf5kE4W/2xk8pfU1OVLvniI= -github.com/uudashr/gocognit v1.1.2/go.mod h1:aAVdLURqcanke8h3vg35BC++eseDm66Z7KmchI5et4k= +github.com/ultraware/whitespace v0.1.1 h1:bTPOGejYFulW3PkcrqkeQwOd6NKOOXvmGD9bo/Gk8VQ= +github.com/ultraware/whitespace v0.1.1/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= +github.com/uudashr/gocognit v1.1.3 h1:l+a111VcDbKfynh+airAy/DJQKaXh2m9vkoysMPSZyM= +github.com/uudashr/gocognit v1.1.3/go.mod h1:aKH8/e8xbTRBwjbCkwZ8qt4l2EpKXl31KMHgSS+lZ2U= github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU= github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg= github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM= github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= -github.com/yeya24/promlinter v0.2.0 h1:xFKDQ82orCU5jQujdaD8stOHiv8UN68BSdn2a8u8Y3o= -github.com/yeya24/promlinter v0.2.0/go.mod h1:u54lkmBOZrpEbQQ6gox2zWKKLKu2SGe+2KOiextY+IA= +github.com/yeya24/promlinter v0.3.0 h1:JVDbMp08lVCP7Y6NP3qHroGAO6z2yGKQtS5JsjqtoFs= +github.com/yeya24/promlinter v0.3.0/go.mod h1:cDfJQQYv9uYciW60QT0eeHlFodotkYZlL+YcPQN+mW4= github.com/ykadowak/zerologlint v0.1.5 h1:Gy/fMz1dFQN9JZTPjv1hxEk+sRWm05row04Yoolgdiw= github.com/ykadowak/zerologlint v0.1.5/go.mod h1:KaUskqF3e/v59oPmdq1U1DnKcuHokl2/K1U4pmIELKg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -564,16 +572,14 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zchee/goimportz v1.1.0 h1:d3uMl5YaEByKELGRqCjJLPq6u0Heuh11GkrALwrK/f0= -github.com/zchee/goimportz v1.1.0/go.mod h1:uMAFUmvaaGw4pX44LQNN6BCmqoSFGA219wFXkgrxndc= -gitlab.com/bosi/decorder v0.4.1 h1:VdsdfxhstabyhZovHafFw+9eJ6eU0d2CkFNJcZz/NU4= -gitlab.com/bosi/decorder v0.4.1/go.mod h1:jecSqWUew6Yle1pCr2eLWTensJMmsxHsBwt+PVbkAqA= -go-simpler.org/assert v0.7.0 h1:OzWWZqfNxt8cLS+MlUp6Tgk1HjPkmgdKBq9qvy8lZsA= -go-simpler.org/assert v0.7.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28= -go-simpler.org/musttag v0.9.0 h1:Dzt6/tyP9ONr5g9h9P3cnYWCxeBFRkd0uJL/w+1Mxos= -go-simpler.org/musttag v0.9.0/go.mod h1:gA9nThnalvNSKpEoyp3Ko4/vCX2xTpqKoUtNqXOnVR4= -go-simpler.org/sloglint v0.5.0 h1:2YCcd+YMuYpuqthCgubcF5lBSjb6berc5VMOYUHKrpY= -go-simpler.org/sloglint v0.5.0/go.mod h1:EUknX5s8iXqf18KQxKnaBHUPVriiPnOrPjjJcsaTcSQ= +gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo= +gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8= +go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ= +go-simpler.org/assert v0.9.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28= +go-simpler.org/musttag v0.12.2 h1:J7lRc2ysXOq7eM8rwaTYnNrHd5JwjppzB6mScysB2Cs= +go-simpler.org/musttag v0.12.2/go.mod h1:uN1DVIasMTQKk6XSik7yrJoEysGtR2GRqvWnI9S7TYM= +go-simpler.org/sloglint v0.7.2 h1:Wc9Em/Zeuu7JYpl+oKoYOsQSy2X560aVueCW/m6IijY= +go-simpler.org/sloglint v0.7.2/go.mod h1:US+9C80ppl7VsThQclkM7BkCHQAzuz8kHLsW3ppuluo= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -598,6 +604,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -608,8 +617,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= -golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f h1:phY1HzDcf18Aq9A8KkmRtY9WvOFIxN8wgfvy6Zm1DV8= @@ -644,8 +653,10 @@ golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -686,8 +697,11 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -708,8 +722,9 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -753,9 +768,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -766,8 +779,13 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -775,8 +793,11 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -789,8 +810,10 @@ golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -849,15 +872,16 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= -golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -937,14 +961,14 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -958,10 +982,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/gotestsum v1.11.0 h1:A88/QWw7acMjZH1dMe6KZFhw32odUOIjCiAU/Q4n3mI= -gotest.tools/gotestsum v1.11.0/go.mod h1:cUOKgFEvWAP0twchmiOvdzX0SBZX0UI58bGRpRIu4xs= -gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= -gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= +gotest.tools/gotestsum v1.12.0 h1:CmwtaGDkHxrZm4Ib0Vob89MTfpc3GrEFMJKovliPwGk= +gotest.tools/gotestsum v1.12.0/go.mod h1:fAvqkSptospfSbQw26CTYzNwnsE/ztqLeyhP0h67ARY= +gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -969,12 +993,12 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.4.7 h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs= -honnef.co/go/tools v0.4.7/go.mod h1:+rnGS1THNh8zMwnd2oVOTL9QF6vmfyG6ZXBULae2uc0= -mvdan.cc/gofumpt v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo= -mvdan.cc/gofumpt v0.6.0/go.mod h1:4L0wf+kgIPZtcCWXynNS2e6bhmj73umwnuXSZarixzA= -mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14 h1:zCr3iRRgdk5eIikZNDphGcM6KGVTx3Yu+/Uu9Es254w= -mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14/go.mod h1:ZzZjEpJDOmx8TdVU6umamY3Xy0UAQUI2DHbf05USVbI= +honnef.co/go/tools v0.5.1 h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I= +honnef.co/go/tools v0.5.1/go.mod h1:e9irvo83WDG9/irijV44wr3tbhcFeRnfpVlRqVwpzMs= +mvdan.cc/gofumpt v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= +mvdan.cc/gofumpt v0.7.0/go.mod h1:txVFJy/Sc/mvaycET54pV8SW8gWxTlUuGHVEcncmNUo= +mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f h1:lMpcwN6GxNbWtbpI1+xzFLSW8XzX0u72NttUGVFjO3U= +mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f/go.mod h1:RSLa7mKKCNeTTMHBw5Hsy2rfJmd6O2ivt9Dw9ZqCQpQ= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/tools/tools.go b/tools/tools.go index c1e8de48..e7eca1ba 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -9,7 +9,7 @@ package tools // tools we use during development. import ( _ "github.com/golangci/golangci-lint/cmd/golangci-lint" - _ "github.com/zchee/goimportz/cmd/goimportz" + _ "github.com/incu6us/goimports-reviser/v3" _ "gotest.tools/gotestsum" _ "mvdan.cc/gofumpt" ) From b8d27af9f043b94369bd765bef5089041b7722eb Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 5 May 2024 23:41:03 +0900 Subject: [PATCH 06/19] WIP2 Signed-off-by: Koichi Shiraishi --- client.go | 336 ++++---- client_interface.go | 197 +++++ go.mod | 5 +- go.sum | 2 - server.go | 1873 +++++++++++++++++++++++-------------------- server_interface.go | 681 ++++++++++++++++ 6 files changed, 2069 insertions(+), 1025 deletions(-) create mode 100644 client_interface.go create mode 100644 server_interface.go diff --git a/client.go b/client.go index e3df68e2..806f0131 100644 --- a/client.go +++ b/client.go @@ -8,11 +8,9 @@ import ( "context" "fmt" - "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" - "go.lsp.dev/pkg/xcontext" ) // ClientDispatcher returns a Client that dispatches LSP requests across the @@ -28,7 +26,7 @@ func ClientDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Client { func ClientHandler(client Client, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := xcontext.Detach(ctx) + xctx := context.WithoutCancel(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -52,12 +50,12 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := json.NewDecoder(bytes.NewReader(req.Params())) + dec := newDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodProgress: // notification - defer logger.Debug(MethodProgress, zap.Error(err)) + case MethodClientProgress: // notification + defer logger.Debug(MethodClientProgress, zap.Error(err)) var params ProgressParams if err := dec.Decode(¶ms); err != nil { @@ -68,27 +66,27 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodWorkDoneProgressCreate: // request - defer logger.Debug(MethodWorkDoneProgressCreate, zap.Error(err)) + case MethodLogTrace: // notification + defer logger.Debug(MethodLogTrace, zap.Error(err)) - var params WorkDoneProgressCreateParams + var params LogTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.WorkDoneProgressCreate(ctx, ¶ms) + err := client.LogTrace(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWindowLogMessage: // notification - defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) + case MethodTelemetryEvent: // notification + defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) - var params LogMessageParams + var params any if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.LogMessage(ctx, ¶ms) + err := client.TelemetryEvent(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -100,7 +98,19 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.PublishDiagnostics(ctx, ¶ms) + err := client.TextDocumentPublishDiagnostics(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodWindowLogMessage: // notification + defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) + + var params LogMessageParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.WindowLogMessage(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -112,55 +122,67 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.ShowMessage(ctx, ¶ms) + err := client.WindowShowMessage(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWindowShowMessageRequest: // request - defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) + case MethodClientRegisterCapability: // request + defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) - var params ShowMessageRequestParams + var params RegistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := client.ShowMessageRequest(ctx, ¶ms) + err := client.ClientRegisterCapability(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTelemetryEvent: // notification - defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) + case MethodClientUnregisterCapability: // request + defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) - var params interface{} + var params UnregistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.Telemetry(ctx, ¶ms) + err := client.ClientUnregisterCapability(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodClientRegisterCapability: // request - defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) + case MethodWindowShowDocument: // request + defer logger.Debug(MethodWindowShowDocument, zap.Error(err)) - var params RegistrationParams + var params ShowDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.RegisterCapability(ctx, ¶ms) + resp, err := client.WindowShowDocument(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodClientUnregisterCapability: // request - defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) + case MethodWindowShowMessageRequest: // request + defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) - var params UnregistrationParams + var params ShowMessageRequestParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.UnregisterCapability(ctx, ¶ms) + resp, err := client.WindowShowMessageRequest(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWindowWorkDoneProgressCreate: // request + defer logger.Debug(MethodWindowWorkDoneProgressCreate, zap.Error(err)) + + var params WorkDoneProgressCreateParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.WindowWorkDoneProgressCreate(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -172,10 +194,17 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.ApplyEdit(ctx, ¶ms) + resp, err := client.WorkspaceApplyEdit(ctx, ¶ms) return true, reply(ctx, resp, err) + case MethodWorkspaceCodeLensRefresh: // request + defer logger.Debug(MethodWorkspaceCodeLensRefresh, zap.Error(err)) + + err := client.WorkspaceCodeLensRefresh(ctx) + + return true, reply(ctx, nil, err) + case MethodWorkspaceConfiguration: // request defer logger.Debug(MethodWorkspaceConfiguration, zap.Error(err)) @@ -184,80 +213,53 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.Configuration(ctx, ¶ms) + resp, err := client.WorkspaceConfiguration(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceWorkspaceFolders: // request - defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) - - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) - } + case MethodWorkspaceDiagnosticRefresh: // request + defer logger.Debug(MethodWorkspaceDiagnosticRefresh, zap.Error(err)) - resp, err := client.WorkspaceFolders(ctx) + err := client.WorkspaceDiagnosticRefresh(ctx) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - default: - return false, nil - } -} + case MethodWorkspaceFoldingRangeRefresh: // request + defer logger.Debug(MethodWorkspaceFoldingRangeRefresh, zap.Error(err)) -// Client represents a Language Server Protocol client. -type Client interface { - Progress(ctx context.Context, params *ProgressParams) (err error) - WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) - LogMessage(ctx context.Context, params *LogMessageParams) (err error) - PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) - ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) - ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (result *MessageActionItem, err error) - Telemetry(ctx context.Context, params interface{}) (err error) - RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) - UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) - ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) - Configuration(ctx context.Context, params *ConfigurationParams) (result []interface{}, err error) - WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) -} + err := client.WorkspaceFoldingRangeRefresh(ctx) -// list of client methods. -const ( - // MethodProgress method name of "$/progress". - MethodProgress = "$/progress" + return true, reply(ctx, nil, err) - // MethodWorkDoneProgressCreate method name of "window/workDoneProgress/create". - MethodWorkDoneProgressCreate = "window/workDoneProgress/create" + case MethodWorkspaceInlayHintRefresh: // request + defer logger.Debug(MethodWorkspaceInlayHintRefresh, zap.Error(err)) - // MethodWindowShowMessage method name of "window/showMessage". - MethodWindowShowMessage = "window/showMessage" + err := client.WorkspaceInlayHintRefresh(ctx) - // MethodWindowShowMessageRequest method name of "window/showMessageRequest. - MethodWindowShowMessageRequest = "window/showMessageRequest" + return true, reply(ctx, nil, err) - // MethodWindowLogMessage method name of "window/logMessage. - MethodWindowLogMessage = "window/logMessage" + case MethodWorkspaceSemanticTokensRefresh: // request + defer logger.Debug(MethodWorkspaceSemanticTokensRefresh, zap.Error(err)) - // MethodTelemetryEvent method name of "telemetry/event. - MethodTelemetryEvent = "telemetry/event" + err := client.WorkspaceSemanticTokensRefresh(ctx) - // MethodClientRegisterCapability method name of "client/registerCapability. - MethodClientRegisterCapability = "client/registerCapability" + return true, reply(ctx, nil, err) - // MethodClientUnregisterCapability method name of "client/unregisterCapability. - MethodClientUnregisterCapability = "client/unregisterCapability" + case MethodWorkspaceWorkspaceFolders: // request + defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) - // MethodTextDocumentPublishDiagnostics method name of "textDocument/publishDiagnostics. - MethodTextDocumentPublishDiagnostics = "textDocument/publishDiagnostics" + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } - // MethodWorkspaceApplyEdit method name of "workspace/applyEdit. - MethodWorkspaceApplyEdit = "workspace/applyEdit" + resp, err := client.WorkspaceWorkspaceFolders(ctx) - // MethodWorkspaceConfiguration method name of "workspace/configuration. - MethodWorkspaceConfiguration = "workspace/configuration" + return true, reply(ctx, resp, err) - // MethodWorkspaceWorkspaceFolders method name of "workspace/workspaceFolders". - MethodWorkspaceWorkspaceFolders = "workspace/workspaceFolders" -) + default: + return false, nil + } +} // client implements a Language Server Protocol client. type client struct { @@ -269,6 +271,13 @@ type client struct { // compiler time check whether the Client implements ClientInterface interface. var _ Client = (*client)(nil) +func (c *client) CancelRequest(ctx context.Context, params *CancelParams) (err error) { + c.logger.Debug("notify " + MethodClientCancelRequest) + defer c.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodClientCancelRequest, params) +} + // Progress is the base protocol offers also support to report progress in a generic fashion. // // This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and @@ -276,28 +285,25 @@ var _ Client = (*client)(nil) // // @since 3.16.0. func (c *client) Progress(ctx context.Context, params *ProgressParams) (err error) { - c.logger.Debug("call " + MethodProgress) - defer c.logger.Debug("end "+MethodProgress, zap.Error(err)) + c.logger.Debug("notify " + MethodClientProgress) + defer c.logger.Debug("end "+MethodClientProgress, zap.Error(err)) - return c.Conn.Notify(ctx, MethodProgress, params) + return c.Conn.Notify(ctx, MethodClientProgress, params) } -// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. -// -// @since 3.16.0. -func (c *client) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { - c.logger.Debug("call " + MethodWorkDoneProgressCreate) - defer c.logger.Debug("end "+MethodWorkDoneProgressCreate, zap.Error(err)) +func (c *client) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { + c.logger.Debug("notify " + MethodLogTrace) + defer c.logger.Debug("end "+MethodLogTrace, zap.Error(err)) - return Call(ctx, c.Conn, MethodWorkDoneProgressCreate, params, nil) + return c.Conn.Notify(ctx, MethodLogTrace, params) } -// LogMessage sends the notification from the server to the client to ask the client to log a particular message. -func (c *client) LogMessage(ctx context.Context, params *LogMessageParams) (err error) { - c.logger.Debug("call " + MethodWindowLogMessage) - defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) +// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. +func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { + c.logger.Debug("notify " + MethodTelemetryEvent) + defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) - return c.Conn.Notify(ctx, MethodWindowLogMessage, params) + return c.Conn.Notify(ctx, MethodTelemetryEvent, params) } // PublishDiagnostics sends the notification from the server to the client to signal results of validation runs. @@ -310,40 +316,28 @@ func (c *client) LogMessage(ctx context.Context, params *LogMessageParams) (err // When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. // If the computed set is empty it has to push the empty array to clear former diagnostics. // Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side. -func (c *client) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { - c.logger.Debug("call " + MethodTextDocumentPublishDiagnostics) +func (c *client) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { + c.logger.Debug("notify " + MethodTextDocumentPublishDiagnostics) defer c.logger.Debug("end "+MethodTextDocumentPublishDiagnostics, zap.Error(err)) return c.Conn.Notify(ctx, MethodTextDocumentPublishDiagnostics, params) } -// ShowMessage sends the notification from a server to a client to ask the -// client to display a particular message in the user interface. -func (c *client) ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { - return c.Conn.Notify(ctx, MethodWindowShowMessage, params) -} - -// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. -// -// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. -func (c *client) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { - c.logger.Debug("call " + MethodWindowShowMessageRequest) - defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) - - var result *MessageActionItem - if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { - return nil, err - } +// LogMessage sends the notification from the server to the client to ask the client to log a particular message. +func (c *client) WindowLogMessage(ctx context.Context, params *LogMessageParams) (err error) { + c.logger.Debug("notify " + MethodWindowLogMessage) + defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) - return result, nil + return c.Conn.Notify(ctx, MethodWindowLogMessage, params) } -// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. -func (c *client) Telemetry(ctx context.Context, params interface{}) (err error) { - c.logger.Debug("call " + MethodTelemetryEvent) - defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) +// ShowMessage sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) WindowShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { + c.logger.Debug("notify " + MethodWindowShowMessage) + defer c.logger.Debug("end "+MethodWindowShowMessage, zap.Error(err)) - return c.Conn.Notify(ctx, MethodTelemetryEvent, params) + return c.Conn.Notify(ctx, MethodWindowShowMessage, params) } // RegisterCapability sends the request from the server to the client to register for a new capability on the client side. @@ -352,7 +346,7 @@ func (c *client) Telemetry(ctx context.Context, params interface{}) (err error) // // A client opts in via the dynamicRegistration property on the specific client capabilities. // A client can even provide dynamic registration for capability A but not for capability B (see TextDocumentClientCapabilities as an example). -func (c *client) RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { +func (c *client) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { c.logger.Debug("call " + MethodClientRegisterCapability) defer c.logger.Debug("end "+MethodClientRegisterCapability, zap.Error(err)) @@ -360,15 +354,54 @@ func (c *client) RegisterCapability(ctx context.Context, params *RegistrationPar } // UnregisterCapability sends the request from the server to the client to unregister a previously registered capability. -func (c *client) UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { +func (c *client) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { c.logger.Debug("call " + MethodClientUnregisterCapability) defer c.logger.Debug("end "+MethodClientUnregisterCapability, zap.Error(err)) return Call(ctx, c.Conn, MethodClientUnregisterCapability, params, nil) } +// ShowMessage sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (_ *ShowDocumentResult, err error) { + c.logger.Debug("call " + MethodWindowShowDocument) + defer c.logger.Debug("end "+MethodWindowShowDocument, zap.Error(err)) + + var result *ShowDocumentResult + if err := Call(ctx, c.Conn, MethodWindowShowDocument, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. +// +// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. +func (c *client) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { + c.logger.Debug("call " + MethodWindowShowMessageRequest) + defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) + + var result *MessageActionItem + if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. +// +// @since 3.16.0. +func (c *client) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { + c.logger.Debug("call " + MethodWindowWorkDoneProgressCreate) + defer c.logger.Debug("end "+MethodWindowWorkDoneProgressCreate, zap.Error(err)) + + return Call(ctx, c.Conn, MethodWindowWorkDoneProgressCreate, params, nil) +} + // ApplyEdit sends the request from the server to the client to modify resource on the client side. -func (c *client) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) { +func (c *client) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResult, err error) { c.logger.Debug("call " + MethodWorkspaceApplyEdit) defer c.logger.Debug("end "+MethodWorkspaceApplyEdit, zap.Error(err)) @@ -379,16 +412,20 @@ func (c *client) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams return result, nil } +func (c *client) WorkspaceCodeLensRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceCodeLensRefresh) +} + // Configuration sends the request from the server to the client to fetch configuration settings from the client. // // The request can fetch several configuration settings in one roundtrip. // The order of the returned configuration settings correspond to the order of the // passed ConfigurationItems (e.g. the first item in the response is the result for the first configuration item in the params). -func (c *client) Configuration(ctx context.Context, params *ConfigurationParams) (_ []interface{}, err error) { +func (c *client) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) (_ []any, err error) { c.logger.Debug("call " + MethodWorkspaceConfiguration) defer c.logger.Debug("end "+MethodWorkspaceConfiguration, zap.Error(err)) - var result []interface{} + var result []any if err := Call(ctx, c.Conn, MethodWorkspaceConfiguration, params, &result); err != nil { return nil, err } @@ -396,12 +433,39 @@ func (c *client) Configuration(ctx context.Context, params *ConfigurationParams) return result, nil } +func (c *client) WorkspaceDiagnosticRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceDiagnosticRefresh) +} + +func (c *client) WorkspaceFoldingRangeRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceFoldingRangeRefresh) +} + +func (c *client) WorkspaceInlayHintRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceInlayHintRefresh) +} + +func (c *client) WorkspaceInlineValueRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceInlineValueRefresh) +} + +func (c *client) WorkspaceSemanticTokensRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceSemanticTokensRefresh) +} + +func (c *client) refresh(ctx context.Context, method string) (err error) { + c.logger.Debug("call " + method) + defer c.logger.Debug("end "+method, zap.Error(err)) + + return c.Conn.Notify(ctx, method, nil) +} + // WorkspaceFolders sends the request from the server to the client to fetch the current open list of workspace folders. // // Returns null in the response if only a single file is open in the tool. Returns an empty array if a workspace is open but no folders are configured. // // @since 3.6.0. -func (c *client) WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) { +func (c *client) WorkspaceWorkspaceFolders(ctx context.Context) (result []*WorkspaceFolder, err error) { c.logger.Debug("call " + MethodWorkspaceWorkspaceFolders) defer c.logger.Debug("end "+MethodWorkspaceWorkspaceFolders, zap.Error(err)) diff --git a/client_interface.go b/client_interface.go new file mode 100644 index 00000000..01ee1d19 --- /dev/null +++ b/client_interface.go @@ -0,0 +1,197 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "context" + + "go.lsp.dev/jsonrpc2" +) + +const ( + MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification + MethodClientProgress ClientMethod = "$/progress" // bidirect client notification + MethodLogTrace ClientMethod = "$/logTrace" // client notification + MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification + MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification + MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification + MethodWindowShowMessage ClientMethod = "window/showMessage" // client notification + MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request + MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request + MethodWindowShowDocument ClientMethod = "window/showDocument" // client request + MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request + MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request + MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request + MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request + MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request + MethodWorkspaceDiagnosticRefresh ClientMethod = "workspace/diagnostic/refresh" // client request + MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request + MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request + MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request + MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request + MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request +) + +type Client interface { + CancelRequest(ctx context.Context, params *CancelParams) error + + Progress(ctx context.Context, params *ProgressParams) error + + LogTrace(ctx context.Context, params *LogTraceParams) error + + // TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data. + TelemetryEvent(ctx context.Context, params any) error + + // TextDocumentPublishDiagnostics diagnostics notification are sent from the server to the client to signal results of validation runs. + TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error + + // WindowLogMessage the log message notification is sent from the server to the client to ask the client to log a particular message. + WindowLogMessage(ctx context.Context, params *LogMessageParams) error + + // WindowShowMessage the show message notification is sent from a server to a client to ask the client to display a particular message in the user interface. + WindowShowMessage(ctx context.Context, params *ShowMessageParams) error + // ClientRegisterCapability the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side. + ClientRegisterCapability(ctx context.Context, params *RegistrationParams) error + + // ClientUnregisterCapability the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side. + ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) error + + // WindowShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser. + // + // @since 3.16.0 + WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) + + // WindowShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user. + WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) + + // WindowWorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server. + WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error + + // WorkspaceApplyEdit a request sent from the server to the client to modified certain resources. + WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) + + // WorkspaceCodeLensRefresh a request to refresh all code actions + // + // @since 3.16.0 + WorkspaceCodeLensRefresh(ctx context.Context) error + + // WorkspaceConfiguration the 'workspace/configuration' request is sent from the server to the client to fetch a certain configuration setting. This pull model replaces the old push model were the client signaled configuration + // change via an event. If the server still needs to react to configuration changes (since the server caches the result of `workspace/configuration` requests) the server should register for an empty configuration change event and empty the cache if such an event is received. + WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) ([]any, error) + + // WorkspaceDiagnosticRefresh the diagnostic refresh request definition. + // + // @since 3.17.0 + WorkspaceDiagnosticRefresh(ctx context.Context) error + + // WorkspaceFoldingRangeRefresh. + // + // @since 3.18.0 proposed + WorkspaceFoldingRangeRefresh(ctx context.Context) error + + // WorkspaceInlayHintRefresh. + // + // @since 3.17.0 + WorkspaceInlayHintRefresh(ctx context.Context) error + + // WorkspaceInlineValueRefresh. + // + // @since 3.17.0 + WorkspaceInlineValueRefresh(ctx context.Context) error + + // WorkspaceSemanticTokensRefresh. + // + // @since 3.16.0 + WorkspaceSemanticTokensRefresh(ctx context.Context) error + + // WorkspaceWorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders. + WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) +} + +// UnimplementedClient should be embedded to have forward compatible implementations. +type UnimplementedClient struct{} + +func (UnimplementedClient) CancelRequest(ctx context.Context, params *CancelParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) Progress(ctx context.Context, params *ProgressParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowLogMessage(ctx context.Context, params *LogMessageParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowShowMessage(ctx context.Context, params *ShowMessageParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceCodeLensRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) ([]any, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceDiagnosticRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceFoldingRangeRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceInlayHintRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceInlineValueRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceSemanticTokensRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) { + return nil, jsonrpc2.ErrInternal +} diff --git a/go.mod b/go.mod index 68663a43..9f65d1f3 100644 --- a/go.mod +++ b/go.mod @@ -3,16 +3,15 @@ module go.lsp.dev/protocol go 1.22.2 require ( - github.com/google/go-cmp v0.6.0 - github.com/segmentio/encoding v0.4.0 go.lsp.dev/jsonrpc2 v0.10.0 - go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 go.lsp.dev/uri v0.3.0 go.uber.org/zap v1.27.0 ) require ( + github.com/google/go-cmp v0.6.0 // indirect github.com/segmentio/asm v1.1.3 // indirect + github.com/segmentio/encoding v0.4.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect ) diff --git a/go.sum b/go.sum index b092fc5d..4241d3ae 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,6 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= go.lsp.dev/jsonrpc2 v0.10.0 h1:Pr/YcXJoEOTMc/b6OTmcR1DPJ3mSWl/SWiU1Cct6VmI= go.lsp.dev/jsonrpc2 v0.10.0/go.mod h1:fmEzIdXPi/rf6d4uFcayi8HpFP1nBF99ERP1htC72Ac= -go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 h1:hCzQgh6UcwbKgNSRurYWSqh8MufqRRPODRBblutn4TE= -go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2/go.mod h1:gtSHRuYfbCT0qnbLnovpie/WEmqyJ7T4n6VXiFMBtcw= go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo= go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= diff --git a/server.go b/server.go index a7ce1717..1abb8464 100644 --- a/server.go +++ b/server.go @@ -8,11 +8,9 @@ import ( "context" "fmt" - "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" - "go.lsp.dev/pkg/xcontext" ) // ServerDispatcher returns a Server that dispatches LSP requests across the @@ -30,7 +28,7 @@ func ServerDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Server { func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := xcontext.Detach(ctx) + xctx := context.WithoutCancel(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -42,8 +40,8 @@ func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { // TODO: This code is wrong, it ignores handler and assumes non standard // request handles everything // non standard request should just be a layered handler. - var params interface{} - if err := json.Unmarshal(req.Params(), ¶ms); err != nil { + var params any + if err := unmarshal(req.Params(), ¶ms); err != nil { return replyParseError(ctx, reply, err) } @@ -63,42 +61,31 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := json.NewDecoder(bytes.NewReader(req.Params())) + dec := newDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodInitialize: // request - defer logger.Debug(MethodInitialize, zap.Error(err)) + case MethodServerProgress: // notification + defer logger.Debug(MethodServerProgress, zap.Error(err)) - var params InitializeParams + var params ProgressParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Initialize(ctx, ¶ms) + err := server.Progress(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodInitialized: // notification - defer logger.Debug(MethodInitialized, zap.Error(err)) + case MethodSetTrace: // notification + defer logger.Debug(MethodSetTrace, zap.Error(err)) - var params InitializedParams + var params SetTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.Initialized(ctx, ¶ms) - - return true, reply(ctx, nil, err) - - case MethodShutdown: // request - defer logger.Debug(MethodShutdown, zap.Error(err)) - - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) - } - - err := server.Shutdown(ctx) + err := server.SetTrace(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -113,147 +100,135 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodWorkDoneProgressCancel: // notification - defer logger.Debug(MethodWorkDoneProgressCancel, zap.Error(err)) + case MethodInitialized: // notification + defer logger.Debug(MethodInitialized, zap.Error(err)) - var params WorkDoneProgressCancelParams + var params InitializedParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WorkDoneProgressCancel(ctx, ¶ms) + err := server.Initialized(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodLogTrace: // notification - defer logger.Debug(MethodLogTrace, zap.Error(err)) + case MethodNotebookDocumentDidChange: // notification + defer logger.Debug(MethodNotebookDocumentDidChange, zap.Error(err)) - var params LogTraceParams + var params DidChangeNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.LogTrace(ctx, ¶ms) + err := server.NotebookDocumentDidChange(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodSetTrace: // notification - defer logger.Debug(MethodSetTrace, zap.Error(err)) + case MethodNotebookDocumentDidClose: // notification + defer logger.Debug(MethodNotebookDocumentDidClose, zap.Error(err)) - var params SetTraceParams + var params DidCloseNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.SetTrace(ctx, ¶ms) + err := server.NotebookDocumentDidClose(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentCodeAction: // request - defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) - - var params CodeActionParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.CodeAction(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentCodeLens: // request - defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) + case MethodNotebookDocumentDidOpen: // notification + defer logger.Debug(MethodNotebookDocumentDidOpen, zap.Error(err)) - var params CodeLensParams + var params DidOpenNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeLens(ctx, ¶ms) + err := server.NotebookDocumentDidOpen(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodCodeLensResolve: // request - defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) + case MethodNotebookDocumentDidSave: // notification + defer logger.Debug(MethodNotebookDocumentDidSave, zap.Error(err)) - var params CodeLens + var params DidSaveNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeLensResolve(ctx, ¶ms) + err := server.NotebookDocumentDidSave(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentColorPresentation: // request - defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) + case MethodTextDocumentDidChange: // notification + defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) - var params ColorPresentationParams + var params DidChangeTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.ColorPresentation(ctx, ¶ms) + err := server.TextDocumentDidChange(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentCompletion: // request - defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) + case MethodTextDocumentDidClose: // notification + defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) - var params CompletionParams + var params DidCloseTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Completion(ctx, ¶ms) + err := server.TextDocumentDidClose(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodCompletionItemResolve: // request - defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) + case MethodTextDocumentDidOpen: // notification + defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) - var params CompletionItem + var params DidOpenTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CompletionResolve(ctx, ¶ms) + err := server.TextDocumentDidOpen(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDeclaration: // request - defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) + case MethodTextDocumentDidSave: // notification + defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) - var params DeclarationParams + var params DidSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Declaration(ctx, ¶ms) + err := server.TextDocumentDidSave(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDefinition: // request - defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) + case MethodTextDocumentWillSave: // notification + defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) - var params DefinitionParams + var params WillSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Definition(ctx, ¶ms) + err := server.TextDocumentWillSave(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDidChange: // notification - defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) + case MethodWindowWorkDoneProgressCancel: // notification + defer logger.Debug(MethodWindowWorkDoneProgressCancel, zap.Error(err)) - var params DidChangeTextDocumentParams + var params WorkDoneProgressCancelParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidChange(ctx, ¶ms) + err := server.WindowWorkDoneProgressCancel(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -265,7 +240,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.DidChangeConfiguration(ctx, ¶ms) + err := server.WorkspaceDidChangeConfiguration(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -277,7 +252,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.DidChangeWatchedFiles(ctx, ¶ms) + err := server.WorkspaceDidChangeWatchedFiles(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -289,380 +264,404 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.DidChangeWorkspaceFolders(ctx, ¶ms) + err := server.WorkspaceDidChangeWorkspaceFolders(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDidClose: // notification - defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) + case MethodWorkspaceDidCreateFiles: // notification + defer logger.Debug(MethodWorkspaceDidCreateFiles, zap.Error(err)) - var params DidCloseTextDocumentParams + var params CreateFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidClose(ctx, ¶ms) + err := server.WorkspaceDidCreateFiles(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDidOpen: // notification - defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) + case MethodWorkspaceDidDeleteFiles: // notification + defer logger.Debug(MethodWorkspaceDidDeleteFiles, zap.Error(err)) - var params DidOpenTextDocumentParams + var params DeleteFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidOpen(ctx, ¶ms) + err := server.WorkspaceDidDeleteFiles(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDidSave: // notification - defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) + case MethodWorkspaceDidRenameFiles: // notification + defer logger.Debug(MethodWorkspaceDidRenameFiles, zap.Error(err)) - var params DidSaveTextDocumentParams + var params RenameFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidSave(ctx, ¶ms) + err := server.WorkspaceDidRenameFiles(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDocumentColor: // request - defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) + case MethodCallHierarchyIncomingCalls: // request + defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) - var params DocumentColorParams + var params CallHierarchyIncomingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentColor(ctx, ¶ms) + resp, err := server.CallHierarchyIncomingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentHighlight: // request - defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) + case MethodCallHierarchyOutgoingCalls: // request + defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) - var params DocumentHighlightParams + var params CallHierarchyOutgoingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentHighlight(ctx, ¶ms) + resp, err := server.CallHierarchyOutgoingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentLink: // request - defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) + case MethodCodeActionResolve: // request + defer logger.Debug(MethodCodeActionResolve, zap.Error(err)) - var params DocumentLinkParams + var params CodeAction if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentLink(ctx, ¶ms) + resp, err := server.CodeActionResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDocumentLinkResolve: // request - defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) + case MethodCodeLensResolve: // request + defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) - var params DocumentLink + var params CodeLens if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentLinkResolve(ctx, ¶ms) + resp, err := server.CodeLensResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentSymbol: // request - defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) + case MethodCompletionItemResolve: // request + defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) - var params DocumentSymbolParams + var params CompletionItem if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentSymbol(ctx, ¶ms) + resp, err := server.CompletionItemResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceExecuteCommand: // request - defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) + case MethodDocumentLinkResolve: // request + defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) - var params ExecuteCommandParams + var params DocumentLink if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.ExecuteCommand(ctx, ¶ms) + resp, err := server.DocumentLinkResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFoldingRange: // request - defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) + case MethodInitialize: // request + defer logger.Debug(MethodInitialize, zap.Error(err)) - var params FoldingRangeParams + var params InitializeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.FoldingRanges(ctx, ¶ms) + resp, err := server.Initialize(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFormatting: // request - defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) + case MethodInlayHintResolve: // request + defer logger.Debug(MethodInlayHintResolve, zap.Error(err)) - var params DocumentFormattingParams + var params InlayHint if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Formatting(ctx, ¶ms) + resp, err := server.InlayHintResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentHover: // request - defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) + case MethodShutdown: // request + defer logger.Debug(MethodShutdown, zap.Error(err)) - var params HoverParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) } - resp, err := server.Hover(ctx, ¶ms) + err := server.Shutdown(ctx) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentImplementation: // request - defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) + case MethodTextDocumentCodeAction: // request + defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) - var params ImplementationParams + var params CodeActionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Implementation(ctx, ¶ms) + resp, err := server.TextDocumentCodeAction(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentOnTypeFormatting: // request - defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) + case MethodTextDocumentCodeLens: // request + defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) - var params DocumentOnTypeFormattingParams + var params CodeLensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.OnTypeFormatting(ctx, ¶ms) + resp, err := server.TextDocumentCodeLens(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentPrepareRename: // request - defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) + case MethodTextDocumentColorPresentation: // request + defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) - var params PrepareRenameParams + var params ColorPresentationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.PrepareRename(ctx, ¶ms) + resp, err := server.TextDocumentColorPresentation(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentRangeFormatting: // request - defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) + case MethodTextDocumentCompletion: // request + defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) - var params DocumentRangeFormattingParams + var params CompletionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.RangeFormatting(ctx, ¶ms) + resp, err := server.TextDocumentCompletion(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentReferences: // request - defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) + case MethodTextDocumentDeclaration: // request + defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) - var params ReferenceParams + var params DeclarationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.References(ctx, ¶ms) + resp, err := server.TextDocumentDeclaration(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentRename: // request - defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) + case MethodTextDocumentDefinition: // request + defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) - var params RenameParams + var params DefinitionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Rename(ctx, ¶ms) + resp, err := server.TextDocumentDefinition(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSignatureHelp: // request - defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) + case MethodTextDocumentDiagnostic: // request + defer logger.Debug(MethodTextDocumentDiagnostic, zap.Error(err)) - var params SignatureHelpParams + var params DocumentDiagnosticParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SignatureHelp(ctx, ¶ms) + resp, err := server.TextDocumentDiagnostic(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceSymbol: // request - defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) + case MethodTextDocumentDocumentColor: // request + defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) - var params WorkspaceSymbolParams + var params DocumentColorParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Symbols(ctx, ¶ms) + resp, err := server.TextDocumentDocumentColor(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentTypeDefinition: // request - defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) + case MethodTextDocumentDocumentHighlight: // request + defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) - var params TypeDefinitionParams + var params DocumentHighlightParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TypeDefinition(ctx, ¶ms) + resp, err := server.TextDocumentDocumentHighlight(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentWillSave: // notification - defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) + case MethodTextDocumentDocumentLink: // request + defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) - var params WillSaveTextDocumentParams + var params DocumentLinkParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WillSave(ctx, ¶ms) + resp, err := server.TextDocumentDocumentLink(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentWillSaveWaitUntil: // request - defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) + case MethodTextDocumentDocumentSymbol: // request + defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) - var params WillSaveTextDocumentParams + var params DocumentSymbolParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillSaveWaitUntil(ctx, ¶ms) + resp, err := server.TextDocumentDocumentSymbol(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodShowDocument: // request - defer logger.Debug(MethodShowDocument, zap.Error(err)) + case MethodTextDocumentFoldingRange: // request + defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) - var params ShowDocumentParams + var params FoldingRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.ShowDocument(ctx, ¶ms) + resp, err := server.TextDocumentFoldingRange(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWillCreateFiles: // request - defer logger.Debug(MethodWillCreateFiles, zap.Error(err)) + case MethodTextDocumentFormatting: // request + defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) - var params CreateFilesParams + var params DocumentFormattingParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillCreateFiles(ctx, ¶ms) + resp, err := server.TextDocumentFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDidCreateFiles: // notification - defer logger.Debug(MethodDidCreateFiles, zap.Error(err)) + case MethodTextDocumentHover: // request + defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) - var params CreateFilesParams + var params HoverParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidCreateFiles(ctx, ¶ms) + resp, err := server.TextDocumentHover(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodWillRenameFiles: // request - defer logger.Debug(MethodWillRenameFiles, zap.Error(err)) + case MethodTextDocumentImplementation: // request + defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) - var params RenameFilesParams + var params ImplementationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillRenameFiles(ctx, ¶ms) + resp, err := server.TextDocumentImplementation(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDidRenameFiles: // notification - defer logger.Debug(MethodDidRenameFiles, zap.Error(err)) + case MethodTextDocumentInlayHint: // request + defer logger.Debug(MethodTextDocumentInlayHint, zap.Error(err)) - var params RenameFilesParams + var params InlayHintParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidRenameFiles(ctx, ¶ms) + resp, err := server.TextDocumentInlayHint(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodWillDeleteFiles: // request - defer logger.Debug(MethodWillDeleteFiles, zap.Error(err)) + case MethodTextDocumentInlineCompletion: // request + defer logger.Debug(MethodTextDocumentInlineCompletion, zap.Error(err)) - var params DeleteFilesParams + var params InlineCompletionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillDeleteFiles(ctx, ¶ms) + resp, err := server.TextDocumentInlineCompletion(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDidDeleteFiles: // notification - defer logger.Debug(MethodDidDeleteFiles, zap.Error(err)) + case MethodTextDocumentInlineValue: // request + defer logger.Debug(MethodTextDocumentInlineValue, zap.Error(err)) - var params DeleteFilesParams + var params InlineValueParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidDeleteFiles(ctx, ¶ms) + resp, err := server.TextDocumentInlineValue(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodCodeLensRefresh: // request - defer logger.Debug(MethodCodeLensRefresh, zap.Error(err)) + case MethodTextDocumentLinkedEditingRange: // request + defer logger.Debug(MethodTextDocumentLinkedEditingRange, zap.Error(err)) - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + var params LinkedEditingRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) } - err := server.CodeLensRefresh(ctx) + resp, err := server.TextDocumentLinkedEditingRange(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) + + case MethodTextDocumentMoniker: // request + defer logger.Debug(MethodTextDocumentMoniker, zap.Error(err)) + + var params MonikerParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentMoniker(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentOnTypeFormatting: // request + defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) + + var params DocumentOnTypeFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentOnTypeFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) case MethodTextDocumentPrepareCallHierarchy: // request defer logger.Debug(MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) @@ -672,102 +671,271 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.PrepareCallHierarchy(ctx, ¶ms) + resp, err := server.TextDocumentPrepareCallHierarchy(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCallHierarchyIncomingCalls: // request - defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) + case MethodTextDocumentPrepareRename: // request + defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) - var params CallHierarchyIncomingCallsParams + var params PrepareRenameParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.IncomingCalls(ctx, ¶ms) + resp, err := server.TextDocumentPrepareRename(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCallHierarchyOutgoingCalls: // request - defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) + case MethodTextDocumentPrepareTypeHierarchy: // request + defer logger.Debug(MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) - var params CallHierarchyOutgoingCallsParams + var params TypeHierarchyPrepareParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.OutgoingCalls(ctx, ¶ms) + resp, err := server.TextDocumentPrepareTypeHierarchy(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensFull: // request - defer logger.Debug(MethodSemanticTokensFull, zap.Error(err)) + case MethodTextDocumentRangeFormatting: // request + defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) + + var params DocumentRangeFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentRangeFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentRangesFormatting: // request + defer logger.Debug(MethodTextDocumentRangesFormatting, zap.Error(err)) + + var params DocumentRangesFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentRangesFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentReferences: // request + defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) + + var params ReferenceParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentReferences(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentRename: // request + defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) + + var params RenameParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentRename(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSelectionRange: // request + defer logger.Debug(MethodTextDocumentSelectionRange, zap.Error(err)) + + var params SelectionRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentSelectionRange(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSemanticTokensFull: // request + defer logger.Debug(MethodTextDocumentSemanticTokensFull, zap.Error(err)) var params SemanticTokensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SemanticTokensFull(ctx, ¶ms) + resp, err := server.TextDocumentSemanticTokensFull(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensFullDelta: // request - defer logger.Debug(MethodSemanticTokensFullDelta, zap.Error(err)) + case MethodTextDocumentSemanticTokensFullDelta: // request + defer logger.Debug(MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) var params SemanticTokensDeltaParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SemanticTokensFullDelta(ctx, ¶ms) + resp, err := server.TextDocumentSemanticTokensFullDelta(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensRange: // request - defer logger.Debug(MethodSemanticTokensRange, zap.Error(err)) + case MethodTextDocumentSemanticTokensRange: // request + defer logger.Debug(MethodTextDocumentSemanticTokensRange, zap.Error(err)) var params SemanticTokensRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SemanticTokensRange(ctx, ¶ms) + resp, err := server.TextDocumentSemanticTokensRange(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensRefresh: // request - defer logger.Debug(MethodSemanticTokensRefresh, zap.Error(err)) + case MethodTextDocumentSignatureHelp: // request + defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + var params SignatureHelpParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) } - err := server.SemanticTokensRefresh(ctx) + resp, err := server.TextDocumentSignatureHelp(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodLinkedEditingRange: // request - defer logger.Debug(MethodLinkedEditingRange, zap.Error(err)) + case MethodTextDocumentTypeDefinition: // request + defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) - var params LinkedEditingRangeParams + var params TypeDefinitionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.LinkedEditingRange(ctx, ¶ms) + resp, err := server.TextDocumentTypeDefinition(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodMoniker: // request - defer logger.Debug(MethodMoniker, zap.Error(err)) + case MethodTextDocumentWillSaveWaitUntil: // request + defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - var params MonikerParams + var params WillSaveTextDocumentParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TextDocumentWillSaveWaitUntil(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTypeHierarchySubtypes: // request + defer logger.Debug(MethodTypeHierarchySubtypes, zap.Error(err)) + + var params TypeHierarchySubtypesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TypeHierarchySubtypes(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTypeHierarchySupertypes: // request + defer logger.Debug(MethodTypeHierarchySupertypes, zap.Error(err)) + + var params TypeHierarchySupertypesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TypeHierarchySupertypes(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceDiagnostic: // request + defer logger.Debug(MethodWorkspaceDiagnostic, zap.Error(err)) + + var params WorkspaceDiagnosticParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceDiagnostic(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceExecuteCommand: // request + defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) + + var params ExecuteCommandParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceExecuteCommand(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceSymbol: // request + defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) + + var params WorkspaceSymbolParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceSymbol(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillCreateFiles: // request + defer logger.Debug(MethodWorkspaceWillCreateFiles, zap.Error(err)) + + var params CreateFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceWillCreateFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillDeleteFiles: // request + defer logger.Debug(MethodWorkspaceWillDeleteFiles, zap.Error(err)) + + var params DeleteFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceWillDeleteFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillRenameFiles: // request + defer logger.Debug(MethodWorkspaceWillRenameFiles, zap.Error(err)) + + var params RenameFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceWillRenameFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceSymbolResolve: // request + defer logger.Debug(MethodWorkspaceSymbolResolve, zap.Error(err)) + + var params WorkspaceSymbol if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Moniker(ctx, ¶ms) + resp, err := server.WorkspaceSymbolResolve(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -776,262 +944,317 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, } } -// Server represents a Language Server Protocol server. -type Server interface { - Initialize(ctx context.Context, params *InitializeParams) (result *InitializeResult, err error) - Initialized(ctx context.Context, params *InitializedParams) (err error) - Shutdown(ctx context.Context) (err error) - Exit(ctx context.Context) (err error) - WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) - LogTrace(ctx context.Context, params *LogTraceParams) (err error) - SetTrace(ctx context.Context, params *SetTraceParams) (err error) - CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) - CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) - CodeLensResolve(ctx context.Context, params *CodeLens) (result *CodeLens, err error) - ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) - Completion(ctx context.Context, params *CompletionParams) (result *CompletionList, err error) - CompletionResolve(ctx context.Context, params *CompletionItem) (result *CompletionItem, err error) - Declaration(ctx context.Context, params *DeclarationParams) (result []Location /* Declaration | DeclarationLink[] | null */, err error) - Definition(ctx context.Context, params *DefinitionParams) (result []Location /* Definition | DefinitionLink[] | null */, err error) - DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) - DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) - DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) - DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) - DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) - DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) - DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) - DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) - DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) - DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) - DocumentLinkResolve(ctx context.Context, params *DocumentLink) (result *DocumentLink, err error) - DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{} /* []SymbolInformation | []DocumentSymbol */, err error) - ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) - FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) - Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) - Hover(ctx context.Context, params *HoverParams) (result *Hover, err error) - Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) - OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) - PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) - RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) - References(ctx context.Context, params *ReferenceParams) (result []Location, err error) - Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) - SignatureHelp(ctx context.Context, params *SignatureHelpParams) (result *SignatureHelp, err error) - Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) - TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) - WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) - WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) - ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) - WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) - DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) - WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) - DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) - WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) - DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) - CodeLensRefresh(ctx context.Context) (err error) - PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) - IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) - OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) - SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) - SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{} /* SemanticTokens | SemanticTokensDelta */, err error) - SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) - SemanticTokensRefresh(ctx context.Context) (err error) - LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) - Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) - Request(ctx context.Context, method string, params interface{}) (result interface{}, err error) -} - -// list of server methods. -const ( - // MethodCancelRequest method name of "$/cancelRequest". - MethodCancelRequest = "$/cancelRequest" - - // MethodInitialize method name of "initialize". - MethodInitialize = "initialize" - - // MethodInitialized method name of "initialized". - MethodInitialized = "initialized" - - // MethodShutdown method name of "shutdown". - MethodShutdown = "shutdown" - - // MethodExit method name of "exit". - MethodExit = "exit" - - // MethodWorkDoneProgressCancel method name of "window/workDoneProgress/cancel". - MethodWorkDoneProgressCancel = "window/workDoneProgress/cancel" - - // MethodLogTrace method name of "$/logTrace". - MethodLogTrace = "$/logTrace" - - // MethodSetTrace method name of "$/setTrace". - MethodSetTrace = "$/setTrace" - - // MethodTextDocumentCodeAction method name of "textDocument/codeAction". - MethodTextDocumentCodeAction = "textDocument/codeAction" - - // MethodTextDocumentCodeLens method name of "textDocument/codeLens". - MethodTextDocumentCodeLens = "textDocument/codeLens" - - // MethodCodeLensResolve method name of "codeLens/resolve". - MethodCodeLensResolve = "codeLens/resolve" - - // MethodTextDocumentColorPresentation method name of "textDocument/colorPresentation". - MethodTextDocumentColorPresentation = "textDocument/colorPresentation" - - // MethodTextDocumentCompletion method name of "textDocument/completion". - MethodTextDocumentCompletion = "textDocument/completion" - - // MethodCompletionItemResolve method name of "completionItem/resolve". - MethodCompletionItemResolve = "completionItem/resolve" - - // MethodTextDocumentDeclaration method name of "textDocument/declaration". - MethodTextDocumentDeclaration = "textDocument/declaration" +// server implements a Language Server Protocol server. +type server struct { + jsonrpc2.Conn - // MethodTextDocumentDefinition method name of "textDocument/definition". - MethodTextDocumentDefinition = "textDocument/definition" + logger *zap.Logger +} - // MethodTextDocumentDidChange method name of "textDocument/didChange". - MethodTextDocumentDidChange = "textDocument/didChange" +var _ Server = (*server)(nil) - // MethodWorkspaceDidChangeConfiguration method name of "workspace/didChangeConfiguration". - MethodWorkspaceDidChangeConfiguration = "workspace/didChangeConfiguration" +func (s *server) CancelRequest(ctx context.Context, params *CancelParams) (err error) { + s.logger.Debug("notify " + MethodClientCancelRequest) + defer s.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) - // MethodWorkspaceDidChangeWatchedFiles method name of "workspace/didChangeWatchedFiles". - MethodWorkspaceDidChangeWatchedFiles = "workspace/didChangeWatchedFiles" + return s.Conn.Notify(ctx, MethodClientCancelRequest, params) +} - // MethodWorkspaceDidChangeWorkspaceFolders method name of "workspace/didChangeWorkspaceFolders". - MethodWorkspaceDidChangeWorkspaceFolders = "workspace/didChangeWorkspaceFolders" +// Progress is the base protocol offers also support to report progress in a generic fashion. +// +// This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and +// partial result progress to support streaming of results. +// +// @since 3.16.0. +func (s *server) Progress(ctx context.Context, params *ProgressParams) (err error) { + s.logger.Debug("notify " + MethodClientProgress) + defer s.logger.Debug("end "+MethodClientProgress, zap.Error(err)) - // MethodTextDocumentDidClose method name of "textDocument/didClose". - MethodTextDocumentDidClose = "textDocument/didClose" + return s.Conn.Notify(ctx, MethodClientProgress, params) +} - // MethodTextDocumentDidOpen method name of "textDocument/didOpen". - MethodTextDocumentDidOpen = "textDocument/didOpen" +// SetTrace a notification that should be used by the client to modify the trace setting of the server. +// +// @since 3.16.0. +func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { + s.logger.Debug("notify " + MethodSetTrace) + defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) - // MethodTextDocumentDidSave method name of "textDocument/didSave". - MethodTextDocumentDidSave = "textDocument/didSave" + return s.Conn.Notify(ctx, MethodSetTrace, params) +} - // MethodTextDocumentDocumentColor method name of"textDocument/documentColor". - MethodTextDocumentDocumentColor = "textDocument/documentColor" +// Exit a notification to ask the server to exit its process. +// +// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. +func (s *server) Exit(ctx context.Context) (err error) { + s.logger.Debug("notify " + MethodExit) + defer s.logger.Debug("end "+MethodExit, zap.Error(err)) - // MethodTextDocumentDocumentHighlight method name of "textDocument/documentHighlight". - MethodTextDocumentDocumentHighlight = "textDocument/documentHighlight" + return s.Conn.Notify(ctx, MethodExit, nil) +} - // MethodTextDocumentDocumentLink method name of "textDocument/documentLink". - MethodTextDocumentDocumentLink = "textDocument/documentLink" +// Initialized sends the notification from the client to the server after the client received the result of the +// initialize request but before the client is sending any other request or notification to the server. +// +// The server can use the initialized notification for example to dynamically register capabilities. +// The initialized notification may only be sent once. +func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { + s.logger.Debug("notify " + MethodInitialized) + defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) - // MethodDocumentLinkResolve method name of "documentLink/resolve". - MethodDocumentLinkResolve = "documentLink/resolve" + return s.Conn.Notify(ctx, MethodInitialized, params) +} - // MethodTextDocumentDocumentSymbol method name of "textDocument/documentSymbol". - MethodTextDocumentDocumentSymbol = "textDocument/documentSymbol" +func (s *server) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidChange) + defer s.logger.Debug("end "+MethodNotebookDocumentDidChange, zap.Error(err)) - // MethodWorkspaceExecuteCommand method name of "workspace/executeCommand". - MethodWorkspaceExecuteCommand = "workspace/executeCommand" + return s.Conn.Notify(ctx, MethodNotebookDocumentDidChange, params) +} - // MethodTextDocumentFoldingRange method name of "textDocument/foldingRange". - MethodTextDocumentFoldingRange = "textDocument/foldingRange" +// NotebookDocumentDidClose a notification sent when a notebook closes. +// +// @since 3.17.0 +func (s *server) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidClose) + defer s.logger.Debug("end "+MethodNotebookDocumentDidClose, zap.Error(err)) - // MethodTextDocumentFormatting method name of "textDocument/formatting". - MethodTextDocumentFormatting = "textDocument/formatting" + return s.Conn.Notify(ctx, MethodNotebookDocumentDidClose, params) +} - // MethodTextDocumentHover method name of "textDocument/hover". - MethodTextDocumentHover = "textDocument/hover" +// NotebookDocumentDidOpen a notification sent when a notebook opens. +// +// @since 3.17.0 +func (s *server) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidOpen) + defer s.logger.Debug("end "+MethodNotebookDocumentDidOpen, zap.Error(err)) - // MethodTextDocumentImplementation method name of "textDocument/implementation". - MethodTextDocumentImplementation = "textDocument/implementation" + return s.Conn.Notify(ctx, MethodNotebookDocumentDidOpen, params) +} - // MethodTextDocumentOnTypeFormatting method name of "textDocument/onTypeFormatting". - MethodTextDocumentOnTypeFormatting = "textDocument/onTypeFormatting" +// NotebookDocumentDidSave a notification sent when a notebook document is saved. +// +// @since 3.17.0 +func (s *server) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidSave) + defer s.logger.Debug("end "+MethodNotebookDocumentDidSave, zap.Error(err)) - // MethodTextDocumentPrepareRename method name of "textDocument/prepareRename". - MethodTextDocumentPrepareRename = "textDocument/prepareRename" + return s.Conn.Notify(ctx, MethodNotebookDocumentDidSave, params) +} - // MethodTextDocumentRangeFormatting method name of "textDocument/rangeFormatting". - MethodTextDocumentRangeFormatting = "textDocument/rangeFormatting" +// DidChange sends the notification from the client to the server to signal changes to a text document. +// +// In 2.0 the shape of the params has changed to include proper version numbers and language ids. +func (s *server) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { + s.logger.Debug("notify " + MethodTextDocumentDidChange) + defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) - // MethodTextDocumentReferences method name of "textDocument/references". - MethodTextDocumentReferences = "textDocument/references" + return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) +} - // MethodTextDocumentRename method name of "textDocument/rename". - MethodTextDocumentRename = "textDocument/rename" +// DidClose sends the notification from the client to the server when the document got closed in the client. +// +// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). +// As with the open notification the close notification is about managing the document’s content. +// Receiving a close notification doesn’t mean that the document was open in an editor before. +// +// A close notification requires a previous open notification to be sent. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidClose) + defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) - // MethodTextDocumentSignatureHelp method name of "textDocument/signatureHelp". - MethodTextDocumentSignatureHelp = "textDocument/signatureHelp" + return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) +} + +// DidOpen sends the open notification from the client to the server to signal newly opened text documents. +// +// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. +// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. +// +// An open notification must not be sent more than once without a corresponding close notification send before. +// This means open and close notification must be balanced and the max open count for a particular textDocument is one. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidOpen) + defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) +} + +// DidSave sends the notification from the client to the server when the document was saved in the client. +func (s *server) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidSave) + defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) +} + +// WillSave sends the notification from the client to the server before the document is actually saved. +func (s *server) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentWillSave) + defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) +} + +// WindowWorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the +// server side using the "window/workDoneProgress/create". +func (s *server) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { + s.logger.Debug("call " + MethodWindowWorkDoneProgressCancel) + defer s.logger.Debug("end "+MethodWindowWorkDoneProgressCancel, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWindowWorkDoneProgressCancel, params) +} + +// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. +func (s *server) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) +} + +// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. +// +// It is recommended that servers register for these file events using the registration mechanism. +// In former implementations clients pushed file events without the server actively asking for it. +func (s *server) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) - // MethodWorkspaceSymbol method name of "workspace/symbol". - MethodWorkspaceSymbol = "workspace/symbol" + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) +} - // MethodTextDocumentTypeDefinition method name of "textDocument/typeDefinition". - MethodTextDocumentTypeDefinition = "textDocument/typeDefinition" +// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. +// +// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; +// or if the server has registered itself to receive this notification. +// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. +// +// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). +func (s *server) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) - // MethodTextDocumentWillSave method name of "textDocument/willSave". - MethodTextDocumentWillSave = "textDocument/willSave" + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) +} - // MethodTextDocumentWillSaveWaitUntil method name of "textDocument/willSaveWaitUntil". - MethodTextDocumentWillSaveWaitUntil = "textDocument/willSaveWaitUntil" +// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. +// +// @since 3.16.0. +func (s *server) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidCreateFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidCreateFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidCreateFiles, params) +} + +// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. +// +// @since 3.16.0. +func (s *server) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidDeleteFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidDeleteFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidDeleteFiles, params) +} + +// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. +// +// @since 3.16.0. +func (s *server) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidRenameFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidRenameFiles, zap.Error(err)) - // MethodShowDocument method name of "window/showDocument". - MethodShowDocument = "window/showDocument" + return s.Conn.Notify(ctx, MethodWorkspaceDidRenameFiles, params) +} - // MethodWillCreateFiles method name of "workspace/willCreateFiles". - MethodWillCreateFiles = "workspace/willCreateFiles" +// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (_ []*CallHierarchyIncomingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) - // MethodDidCreateFiles method name of "workspace/didCreateFiles". - MethodDidCreateFiles = "workspace/didCreateFiles" + var result []*CallHierarchyIncomingCall + if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { + return nil, err + } - // MethodWillRenameFiles method name of "workspace/willRenameFiles". - MethodWillRenameFiles = "workspace/willRenameFiles" + return result, nil +} - // MethodDidRenameFiles method name of "workspace/didRenameFiles". - MethodDidRenameFiles = "workspace/didRenameFiles" +// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (_ []*CallHierarchyOutgoingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) - // MethodWillDeleteFiles method name of "workspace/willDeleteFiles". - MethodWillDeleteFiles = "workspace/willDeleteFiles" + var result []*CallHierarchyOutgoingCall + if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { + return nil, err + } - // MethodDidDeleteFiles method name of "workspace/didDeleteFiles". - MethodDidDeleteFiles = "workspace/didDeleteFiles" + return result, nil +} - // MethodCodeLensRefresh method name of "workspace/codeLens/refresh". - MethodCodeLensRefresh = "workspace/codeLens/refresh" +func (s *server) CodeActionResolve(ctx context.Context, params *CodeAction) (_ *CodeAction, err error) { + s.logger.Debug("call " + MethodCodeActionResolve) + defer s.logger.Debug("end "+MethodCodeActionResolve, zap.Error(err)) - // MethodTextDocumentPrepareCallHierarchy method name of "textDocument/prepareCallHierarchy". - MethodTextDocumentPrepareCallHierarchy = "textDocument/prepareCallHierarchy" + var result *CodeAction + if err := Call(ctx, s.Conn, MethodCodeActionResolve, params, &result); err != nil { + return nil, err + } - // MethodCallHierarchyIncomingCalls method name of "callHierarchy/incomingCalls". - MethodCallHierarchyIncomingCalls = "callHierarchy/incomingCalls" + return result, nil +} - // MethodCallHierarchyOutgoingCalls method name of "callHierarchy/outgoingCalls". - MethodCallHierarchyOutgoingCalls = "callHierarchy/outgoingCalls" +// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. +func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { + s.logger.Debug("call " + MethodCodeLensResolve) + defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) - // MethodSemanticTokensFull method name of "textDocument/semanticTokens/full". - MethodSemanticTokensFull = "textDocument/semanticTokens/full" + var result *CodeLens + if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { + return nil, err + } - // MethodSemanticTokensFullDelta method name of "textDocument/semanticTokens/full/delta". - MethodSemanticTokensFullDelta = "textDocument/semanticTokens/full/delta" + return result, nil +} - // MethodSemanticTokensRange method name of "textDocument/semanticTokens/range". - MethodSemanticTokensRange = "textDocument/semanticTokens/range" +// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. +func (s *server) CompletionItemResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { + s.logger.Debug("call " + MethodCompletionItemResolve) + defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) - // MethodSemanticTokensRefresh method name of "workspace/semanticTokens/refresh". - MethodSemanticTokensRefresh = "workspace/semanticTokens/refresh" + var result *CompletionItem + if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { + return nil, err + } - // MethodLinkedEditingRange method name of "textDocument/linkedEditingRange". - MethodLinkedEditingRange = "textDocument/linkedEditingRange" + return result, nil +} - // MethodMoniker method name of "textDocument/moniker". - MethodMoniker = "textDocument/moniker" -) +// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. +func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { + s.logger.Debug("call " + MethodDocumentLinkResolve) + defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) -// server implements a Language Server Protocol server. -type server struct { - jsonrpc2.Conn + var result *DocumentLink + if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { + return nil, err + } - logger *zap.Logger + return result, nil } -var _ Server = (*server)(nil) - // Initialize sents the request as the first request from the client to the server. // // If the server receives a request or notification before the initialize request it should act as follows: @@ -1057,16 +1280,16 @@ func (s *server) Initialize(ctx context.Context, params *InitializeParams) (_ *I return result, nil } -// Initialized sends the notification from the client to the server after the client received the result of the -// initialize request but before the client is sending any other request or notification to the server. -// -// The server can use the initialized notification for example to dynamically register capabilities. -// The initialized notification may only be sent once. -func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { - s.logger.Debug("notify " + MethodInitialized) - defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) +func (s *server) InlayHintResolve(ctx context.Context, params *InlayHint) (_ *InlayHint, err error) { + s.logger.Debug("call " + MethodInlayHintResolve) + defer s.logger.Debug("end "+MethodInlayHintResolve, zap.Error(err)) - return s.Conn.Notify(ctx, MethodInitialized, params) + var result *InlayHint + if err := Call(ctx, s.Conn, MethodInlayHintResolve, params, &result); err != nil { + return nil, err + } + + return result, nil } // Shutdown sents the request from the client to the server. @@ -1083,50 +1306,6 @@ func (s *server) Shutdown(ctx context.Context) (err error) { return Call(ctx, s.Conn, MethodShutdown, nil, nil) } -// Exit a notification to ask the server to exit its process. -// -// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. -func (s *server) Exit(ctx context.Context) (err error) { - s.logger.Debug("notify " + MethodExit) - defer s.logger.Debug("end "+MethodExit, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodExit, nil) -} - -// LogTrace a notification to log the trace of the server’s execution. -// -// The amount and content of these notifications depends on the current trace configuration. -// -// If trace is "off", the server should not send any logTrace notification. If trace is "message", -// the server should not add the "verbose" field in the LogTraceParams. -// -// @since 3.16.0. -func (s *server) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { - s.logger.Debug("notify " + MethodLogTrace) - defer s.logger.Debug("end "+MethodLogTrace, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodLogTrace, params) -} - -// SetTrace a notification that should be used by the client to modify the trace setting of the server. -// -// @since 3.16.0. -func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { - s.logger.Debug("notify " + MethodSetTrace) - defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodSetTrace, params) -} - -// WorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the -// server side using the "window/workDoneProgress/create". -func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { - s.logger.Debug("call " + MethodWorkDoneProgressCancel) - defer s.logger.Debug("end "+MethodWorkDoneProgressCancel, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkDoneProgressCancel, params) -} - // CodeAction sends the request is from the client to the server to compute commands for a given text document and range. // // These commands are typically code fixes to either fix problems or to beautify/refactor code. The result of a `textDocument/codeAction` @@ -1135,10 +1314,11 @@ func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDonePro // To ensure that a server is useful in many clients the commands specified in a code actions should be handled by the // server and not by the client (see `workspace/executeCommand` and `ServerCapabilities.executeCommandProvider`). // If the client supports providing edits with a code action then the mode should be used. -func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) { +func (s *server) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (_ *TextDocumentCodeActionResult, err error) { s.logger.Debug("call " + MethodTextDocumentCodeAction) defer s.logger.Debug("end "+MethodTextDocumentCodeAction, zap.Error(err)) + var result *TextDocumentCodeActionResult if err := Call(ctx, s.Conn, MethodTextDocumentCodeAction, params, &result); err != nil { return nil, err } @@ -1147,10 +1327,11 @@ func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (resu } // CodeLens sends the request from the client to the server to compute code lenses for a given text document. -func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) { +func (s *server) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) (_ []*CodeLens, err error) { s.logger.Debug("call " + MethodTextDocumentCodeLens) defer s.logger.Debug("end "+MethodTextDocumentCodeLens, zap.Error(err)) + var result []*CodeLens if err := Call(ctx, s.Conn, MethodTextDocumentCodeLens, params, &result); err != nil { return nil, err } @@ -1158,29 +1339,17 @@ func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (result [ return result, nil } -// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. -func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { - s.logger.Debug("call " + MethodCodeLensResolve) - defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) - - var result *CodeLens - if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // ColorPresentation sends the request from the client to the server to obtain a list of presentations for a color value at a given location. // // # Clients can use the result to // // - modify a color reference. // - show in a color picker and let users pick one of the presentations. -func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) { +func (s *server) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) (_ []*ColorPresentation, err error) { s.logger.Debug("call " + MethodTextDocumentColorPresentation) defer s.logger.Debug("end "+MethodTextDocumentColorPresentation, zap.Error(err)) + var result []*ColorPresentation if err := Call(ctx, s.Conn, MethodTextDocumentColorPresentation, params, &result); err != nil { return nil, err } @@ -1201,11 +1370,11 @@ func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentatio // The returned completion item should have the documentation property filled in. The request can delay the computation of // the `detail` and `documentation` properties. However, properties that are needed for the initial sorting and filtering, // like `sortText`, `filterText`, `insertText`, and `textEdit` must be provided in the `textDocument/completion` response and must not be changed during resolve. -func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *CompletionList, err error) { +func (s *server) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (_ *TextDocumentCompletionResult, err error) { s.logger.Debug("call " + MethodTextDocumentCompletion) defer s.logger.Debug("end "+MethodTextDocumentCompletion, zap.Error(err)) - var result *CompletionList + var result *TextDocumentCompletionResult if err := Call(ctx, s.Conn, MethodTextDocumentCompletion, params, &result); err != nil { return nil, err } @@ -1213,28 +1382,16 @@ func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *C return result, nil } -// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. -func (s *server) CompletionResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { - s.logger.Debug("call " + MethodCompletionItemResolve) - defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) - - var result *CompletionItem - if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // Declaration sends the request from the client to the server to resolve the declaration location of a symbol at a given text document position. // // The result type LocationLink[] got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.declaration.linkSupport`. // // @since 3.14.0. -func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (result []Location, err error) { +func (s *server) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (_ *TextDocumentDeclarationResult, err error) { s.logger.Debug("call " + MethodTextDocumentDeclaration) defer s.logger.Debug("end "+MethodTextDocumentDeclaration, zap.Error(err)) + var result *TextDocumentDeclarationResult if err := Call(ctx, s.Conn, MethodTextDocumentDeclaration, params, &result); err != nil { return nil, err } @@ -1247,10 +1404,11 @@ func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (re // The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.definition.linkSupport`. // // @since 3.14.0. -func (s *server) Definition(ctx context.Context, params *DefinitionParams) (result []Location, err error) { +func (s *server) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (_ *TextDocumentDefinitionResult, err error) { s.logger.Debug("call " + MethodTextDocumentDefinition) defer s.logger.Debug("end "+MethodTextDocumentDefinition, zap.Error(err)) + var result *TextDocumentDefinitionResult if err := Call(ctx, s.Conn, MethodTextDocumentDefinition, params, &result); err != nil { return nil, err } @@ -1258,85 +1416,16 @@ func (s *server) Definition(ctx context.Context, params *DefinitionParams) (resu return result, nil } -// DidChange sends the notification from the client to the server to signal changes to a text document. -// -// In 2.0 the shape of the params has changed to include proper version numbers and language ids. -func (s *server) DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { - s.logger.Debug("notify " + MethodTextDocumentDidChange) - defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) -} - -// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. -func (s *server) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) -} - -// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. -// -// It is recommended that servers register for these file events using the registration mechanism. -// In former implementations clients pushed file events without the server actively asking for it. -func (s *server) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) -} - -// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. -// -// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; -// or if the server has registered itself to receive this notification. -// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. -// -// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). -func (s *server) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) -} - -// DidClose sends the notification from the client to the server when the document got closed in the client. -// -// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). -// As with the open notification the close notification is about managing the document’s content. -// Receiving a close notification doesn’t mean that the document was open in an editor before. -// -// A close notification requires a previous open notification to be sent. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidClose) - defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) -} - -// DidOpen sends the open notification from the client to the server to signal newly opened text documents. -// -// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. -// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. -// -// An open notification must not be sent more than once without a corresponding close notification send before. -// This means open and close notification must be balanced and the max open count for a particular textDocument is one. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidOpen) - defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) -} +func (s *server) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (_ *DocumentDiagnosticReport, err error) { + s.logger.Debug("call " + MethodTextDocumentDiagnostic) + defer s.logger.Debug("end "+MethodTextDocumentDiagnostic, zap.Error(err)) -// DidSave sends the notification from the client to the server when the document was saved in the client. -func (s *server) DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidSave) - defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) + var result *DocumentDiagnosticReport + if err := Call(ctx, s.Conn, MethodTextDocumentDiagnostic, params, &result); err != nil { + return nil, err + } - return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) + return result, nil } // DocumentColor sends the request from the client to the server to list all color references found in a given text document. @@ -1348,10 +1437,11 @@ func (s *server) DidSave(ctx context.Context, params *DidSaveTextDocumentParams) // // - Color boxes showing the actual color next to the reference // - Show a color picker when a color reference is edited. -func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) { +func (s *server) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) (_ []*ColorInformation, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentColor) defer s.logger.Debug("end "+MethodTextDocumentDocumentColor, zap.Error(err)) + var result []*ColorInformation if err := Call(ctx, s.Conn, MethodTextDocumentDocumentColor, params, &result); err != nil { return nil, err } @@ -1365,10 +1455,11 @@ func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) // However we kept ‘textDocument/documentHighlight’ and ‘textDocument/references’ separate requests since the first one is allowed to be more fuzzy. // // Symbol matches usually have a `DocumentHighlightKind` of `Read` or `Write` whereas fuzzy or textual matches use `Text` as the kind. -func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) { +func (s *server) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (_ []*DocumentHighlight, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentHighlight) defer s.logger.Debug("end "+MethodTextDocumentDocumentHighlight, zap.Error(err)) + var result []*DocumentHighlight if err := Call(ctx, s.Conn, MethodTextDocumentDocumentHighlight, params, &result); err != nil { return nil, err } @@ -1377,10 +1468,11 @@ func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighligh } // DocumentLink sends the request from the client to the server to request the location of links in a document. -func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) { +func (s *server) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) (_ []*DocumentLink, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentLink) defer s.logger.Debug("end "+MethodTextDocumentDocumentLink, zap.Error(err)) + var result []*DocumentLink if err := Call(ctx, s.Conn, MethodTextDocumentDocumentLink, params, &result); err != nil { return nil, err } @@ -1388,95 +1480,145 @@ func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) ( return result, nil } -// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. -func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { - s.logger.Debug("call " + MethodDocumentLinkResolve) - defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) +// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. +// +// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. +func (s *server) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (_ *TextDocumentDocumentSymbolResult, err error) { + s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) + defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) - var result *DocumentLink - if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { + var result *TextDocumentDocumentSymbolResult + if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { return nil, err } return result, nil } -// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. +// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. // -// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. -func (s *server) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{}, err error) { - s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) - defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) +// @since version 3.10.0. +func (s *server) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) (_ []*FoldingRange, err error) { + s.logger.Debug("call " + MethodTextDocumentFoldingRange) + defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { + var result []*FoldingRange + if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { return nil, err } return result, nil } -// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. +// Formatting sends the request from the client to the server to format a whole document. +func (s *server) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentFormatting) + defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) + + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Hover sends the request is from the client to the server to request hover information at a given text document position. +func (s *server) TextDocumentHover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { + s.logger.Debug("call " + MethodTextDocumentHover) + defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) + + var result *Hover + if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. // -// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the -// request `workspace/applyEdit` which is sent from the server to the client. -func (s *server) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) { - s.logger.Debug("call " + MethodWorkspaceExecuteCommand) - defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. +func (s *server) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (_ *TextDocumentImplementationResult, err error) { + s.logger.Debug("call " + MethodTextDocumentImplementation) + defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) + + var result *TextDocumentImplementationResult + if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { + return nil, err + } - if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { + return result, nil +} + +func (s *server) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) (_ []*InlayHint, err error) { + s.logger.Debug("call " + MethodTextDocumentInlayHint) + defer s.logger.Debug("end "+MethodTextDocumentInlayHint, zap.Error(err)) + + var result []*InlayHint + if err := Call(ctx, s.Conn, MethodTextDocumentInlayHint, params, &result); err != nil { return nil, err } return result, nil } -// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. -// -// @since version 3.10.0. -func (s *server) FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) { - s.logger.Debug("call " + MethodTextDocumentFoldingRange) - defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) +func (s *server) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (_ *TextDocumentInlineCompletionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentInlineCompletion) + defer s.logger.Debug("end "+MethodTextDocumentInlineCompletion, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { + var result *TextDocumentInlineCompletionResult + if err := Call(ctx, s.Conn, MethodTextDocumentInlineCompletion, params, &result); err != nil { return nil, err } return result, nil } -// Formatting sends the request from the client to the server to format a whole document. -func (s *server) Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentFormatting) - defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) +func (s *server) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) (_ []*InlineValue, err error) { + s.logger.Debug("call " + MethodTextDocumentInlineValue) + defer s.logger.Debug("end "+MethodTextDocumentInlineValue, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { + var result []*InlineValue + if err := Call(ctx, s.Conn, MethodTextDocumentInlineValue, params, &result); err != nil { return nil, err } return result, nil } -// Hover sends the request is from the client to the server to request hover information at a given text document position. -func (s *server) Hover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { - s.logger.Debug("call " + MethodTextDocumentHover) - defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) +// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. +// +// Optionally a word pattern can be returned to describe valid contents. +// +// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. +// +// @since 3.16.0. +func (s *server) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (_ *LinkedEditingRanges, err error) { + s.logger.Debug("call " + MethodTextDocumentLinkedEditingRange) + defer s.logger.Debug("end "+MethodTextDocumentLinkedEditingRange, zap.Error(err)) - var result *Hover - if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { + var result *LinkedEditingRanges + if err := Call(ctx, s.Conn, MethodTextDocumentLinkedEditingRange, params, &result); err != nil { return nil, err } return result, nil } -// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. +// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. // -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. -func (s *server) Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) { - s.logger.Debug("call " + MethodTextDocumentImplementation) - defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) +// An array of Moniker types is returned as response to indicate possible monikers at the given location. +// +// If no monikers can be calculated, an empty array or null should be returned. +// +// @since 3.16.0. +func (s *server) TextDocumentMoniker(ctx context.Context, params *MonikerParams) (_ []*Moniker, err error) { + s.logger.Debug("call " + MethodTextDocumentMoniker) + defer s.logger.Debug("end "+MethodTextDocumentMoniker, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { + var result []*Moniker + if err := Call(ctx, s.Conn, MethodTextDocumentMoniker, params, &result); err != nil { return nil, err } @@ -1484,10 +1626,11 @@ func (s *server) Implementation(ctx context.Context, params *ImplementationParam } // OnTypeFormatting sends the request from the client to the server to format parts of the document during typing. -func (s *server) OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) { +func (s *server) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (_ []*TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentOnTypeFormatting) defer s.logger.Debug("end "+MethodTextDocumentOnTypeFormatting, zap.Error(err)) + var result []*TextEdit if err := Call(ctx, s.Conn, MethodTextDocumentOnTypeFormatting, params, &result); err != nil { return nil, err } @@ -1495,385 +1638,347 @@ func (s *server) OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFor return result, nil } -// PrepareRename sends the request from the client to the server to setup and test the validity of a rename operation at a given location. +// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. // -// @since version 3.12.0. -func (s *server) PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) { - s.logger.Debug("call " + MethodTextDocumentPrepareRename) - defer s.logger.Debug("end "+MethodTextDocumentPrepareRename, zap.Error(err)) +// The call hierarchy requests are executed in two steps: +// 1. first a call hierarchy item is resolved for the given text document position +// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. +// +// @since 3.16.0. +func (s *server) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (_ []*CallHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentPrepareRename, params, &result); err != nil { + var result []*CallHierarchyItem + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { return nil, err } return result, nil } -// RangeFormatting sends the request from the client to the server to format a given range in a document. -func (s *server) RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentRangeFormatting) - defer s.logger.Debug("end "+MethodTextDocumentRangeFormatting, zap.Error(err)) +// PrepareRename sends the request from the client to the server to setup and test the validity of a rename operation at a given location. +// +// @since version 3.12.0. +func (s *server) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (_ *PrepareRenameResult, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareRename) + defer s.logger.Debug("end "+MethodTextDocumentPrepareRename, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentRangeFormatting, params, &result); err != nil { + var result *PrepareRenameResult + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareRename, params, &result); err != nil { return nil, err } return result, nil } -// References sends the request from the client to the server to resolve project-wide references for the symbol denoted by the given text document position. -func (s *server) References(ctx context.Context, params *ReferenceParams) (result []Location, err error) { - s.logger.Debug("call " + MethodTextDocumentReferences) - defer s.logger.Debug("end "+MethodTextDocumentReferences, zap.Error(err)) +func (s *server) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareTypeHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentReferences, params, &result); err != nil { + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareTypeHierarchy, params, &result); err != nil { return nil, err } return result, nil } -// Rename sends the request from the client to the server to perform a workspace-wide rename of a symbol. -func (s *server) Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentRename) - defer s.logger.Debug("end "+MethodTextDocumentRename, zap.Error(err)) +// RangeFormatting sends the request from the client to the server to format a given range in a document. +func (s *server) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRangeFormatting) + defer s.logger.Debug("end "+MethodTextDocumentRangeFormatting, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentRename, params, &result); err != nil { + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRangeFormatting, params, &result); err != nil { return nil, err } return result, nil } -// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. -func (s *server) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { - s.logger.Debug("call " + MethodTextDocumentSignatureHelp) - defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) +func (s *server) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRangesFormatting) + defer s.logger.Debug("end "+MethodTextDocumentRangesFormatting, zap.Error(err)) - var result *SignatureHelp - if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRangesFormatting, params, &result); err != nil { return nil, err } return result, nil } -// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. -func (s *server) Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) { - s.logger.Debug("call " + MethodWorkspaceSymbol) - defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) +// References sends the request from the client to the server to resolve project-wide references for the symbol denoted by the given text document position. +func (s *server) TextDocumentReferences(ctx context.Context, params *ReferenceParams) (_ []*Location, err error) { + s.logger.Debug("call " + MethodTextDocumentReferences) + defer s.logger.Debug("end "+MethodTextDocumentReferences, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { + var result []*Location + if err := Call(ctx, s.Conn, MethodTextDocumentReferences, params, &result); err != nil { return nil, err } return result, nil } -// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. -// -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. -// -// @since version 3.6.0. -func (s *server) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) { - s.logger.Debug("call " + MethodTextDocumentTypeDefinition) - defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) +// Rename sends the request from the client to the server to perform a workspace-wide rename of a symbol. +func (s *server) TextDocumentRename(ctx context.Context, params *RenameParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRename) + defer s.logger.Debug("end "+MethodTextDocumentRename, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRename, params, &result); err != nil { return nil, err } return result, nil } -// WillSave sends the notification from the client to the server before the document is actually saved. -func (s *server) WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentWillSave) - defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) -} - -// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. -// -// The request can return an array of TextEdits which will be applied to the text document before it is saved. -// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. -// This is done to keep the save fast and reliable. -func (s *server) WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) - defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) +func (s *server) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) (_ []*SelectionRange, err error) { + s.logger.Debug("call " + MethodTextDocumentSelectionRange) + defer s.logger.Debug("end "+MethodTextDocumentSelectionRange, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { + var result []*SelectionRange + if err := Call(ctx, s.Conn, MethodTextDocumentSelectionRange, params, &result); err != nil { return nil, err } return result, nil } -// ShowDocument sends the request from a server to a client to ask the client to display a particular document in the user interface. +// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. +// +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. // // @since 3.16.0. -func (s *server) ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) { - s.logger.Debug("call " + MethodShowDocument) - defer s.logger.Debug("end "+MethodShowDocument, zap.Error(err)) +func (s *server) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (_ *SemanticTokens, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensFull) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFull, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodShowDocument, params, &result); err != nil { + var result *SemanticTokens + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFull, params, &result); err != nil { return nil, err } return result, nil } -// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. +// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. // // @since 3.16.0. -func (s *server) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWillCreateFiles) - defer s.logger.Debug("end "+MethodWillCreateFiles, zap.Error(err)) +func (s *server) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (_ *TextDocumentSemanticTokensFullDeltaResult, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensFullDelta) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWillCreateFiles, params, &result); err != nil { + var result *TextDocumentSemanticTokensFullDeltaResult + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFullDelta, params, &result); err != nil { return nil, err } return result, nil } -// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. -// -// @since 3.16.0. -func (s *server) DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { - s.logger.Debug("call " + MethodDidCreateFiles) - defer s.logger.Debug("end "+MethodDidCreateFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodDidCreateFiles, params) -} - -// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. +// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. +// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). +// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. +// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. // // @since 3.16.0. -func (s *server) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWillRenameFiles) - defer s.logger.Debug("end "+MethodWillRenameFiles, zap.Error(err)) +func (s *server) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (_ *SemanticTokens, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensRange) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensRange, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWillRenameFiles, params, &result); err != nil { + var result *SemanticTokens + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensRange, params, &result); err != nil { return nil, err } return result, nil } -// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. -// -// @since 3.16.0. -func (s *server) DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { - s.logger.Debug("call " + MethodDidRenameFiles) - defer s.logger.Debug("end "+MethodDidRenameFiles, zap.Error(err)) +// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. +func (s *server) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { + s.logger.Debug("call " + MethodTextDocumentSignatureHelp) + defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) + + var result *SignatureHelp + if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { + return nil, err + } - return s.Conn.Notify(ctx, MethodDidRenameFiles, params) + return result, nil } -// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. -// -// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. +// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. // -// @since 3.16.0. -func (s *server) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWillDeleteFiles) - defer s.logger.Debug("end "+MethodWillDeleteFiles, zap.Error(err)) +// @since version 3.6.0. +func (s *server) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (_ *TextDocumentTypeDefinitionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentTypeDefinition) + defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWillDeleteFiles, params, &result); err != nil { + var result *TextDocumentTypeDefinitionResult + if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { return nil, err } return result, nil } -// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. +// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. // -// @since 3.16.0. -func (s *server) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { - s.logger.Debug("call " + MethodDidDeleteFiles) - defer s.logger.Debug("end "+MethodDidDeleteFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodDidDeleteFiles, params) -} +// The request can return an array of TextEdits which will be applied to the text document before it is saved. +// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. +// This is done to keep the save fast and reliable. +func (s *server) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) + defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) -// CodeLensRefresh sent from the server to the client. -// -// Servers can use it to ask clients to refresh the code lenses currently shown in editors. -// As a result the client should ask the server to recompute the code lenses for these editors. -// This is useful if a server detects a configuration change which requires a re-calculation of all code lenses. -// -// Note that the client still has the freedom to delay the re-calculation of the code lenses if for example an editor is currently not visible. -// -// @since 3.16.0. -func (s *server) CodeLensRefresh(ctx context.Context) (err error) { - s.logger.Debug("call " + MethodCodeLensRefresh) - defer s.logger.Debug("end "+MethodCodeLensRefresh, zap.Error(err)) + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { + return nil, err + } - return Call(ctx, s.Conn, MethodCodeLensRefresh, nil, nil) + return result, nil } -// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. -// -// The call hierarchy requests are executed in two steps: -// 1. first a call hierarchy item is resolved for the given text document position -// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. -// -// @since 3.16.0. -func (s *server) PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) { - s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) - defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) +func (s *server) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTypeHierarchySubtypes) + defer s.logger.Debug("end "+MethodTypeHierarchySubtypes, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTypeHierarchySubtypes, params, &result); err != nil { return nil, err } return result, nil } -// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -func (s *server) IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) +func (s *server) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTypeHierarchySupertypes) + defer s.logger.Debug("end "+MethodTypeHierarchySupertypes, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTypeHierarchySupertypes, params, &result); err != nil { return nil, err } return result, nil } -// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -func (s *server) OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) +func (s *server) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (_ *WorkspaceDiagnosticReport, err error) { + s.logger.Debug("call " + MethodWorkspaceDiagnostic) + defer s.logger.Debug("end "+MethodWorkspaceDiagnostic, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { + var result *WorkspaceDiagnosticReport + if err := Call(ctx, s.Conn, MethodWorkspaceDiagnostic, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. -// -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. -// -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. // -// @since 3.16.0. -func (s *server) SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) { - s.logger.Debug("call " + MethodSemanticTokensFull) - defer s.logger.Debug("end "+MethodSemanticTokensFull, zap.Error(err)) +// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the +// request `workspace/applyEdit` which is sent from the server to the client. +func (s *server) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result any, err error) { + s.logger.Debug("call " + MethodWorkspaceExecuteCommand) + defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodSemanticTokensFull, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. -// -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. -// -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. -// -// @since 3.16.0. -func (s *server) SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{}, err error) { - s.logger.Debug("call " + MethodSemanticTokensFullDelta) - defer s.logger.Debug("end "+MethodSemanticTokensFullDelta, zap.Error(err)) +// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. +func (s *server) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (_ *WorkspaceSymbolResult, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbol) + defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodSemanticTokensFullDelta, params, &result); err != nil { + var result *WorkspaceSymbolResult + if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. +// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. // -// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). -// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. // -// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. // // @since 3.16.0. -func (s *server) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) { - s.logger.Debug("call " + MethodSemanticTokensRange) - defer s.logger.Debug("end "+MethodSemanticTokensRange, zap.Error(err)) +func (s *server) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillCreateFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillCreateFiles, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodSemanticTokensRange, params, &result); err != nil { + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillCreateFiles, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensRefresh is sent from the server to the client. Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens. +// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. // -// As a result the client should ask the server to recompute the semantic tokens for these editors. -// This is useful if a server detects a project wide configuration change which requires a re-calculation of all semantic tokens. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. // -// Note that the client still has the freedom to delay the re-calculation of the semantic tokens if for example an editor is currently not visible. +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. // // @since 3.16.0. -func (s *server) SemanticTokensRefresh(ctx context.Context) (err error) { - s.logger.Debug("call " + MethodSemanticTokensRefresh) - defer s.logger.Debug("end "+MethodSemanticTokensRefresh, zap.Error(err)) +func (s *server) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillDeleteFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillDeleteFiles, zap.Error(err)) + + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillDeleteFiles, params, &result); err != nil { + return nil, err + } - return Call(ctx, s.Conn, MethodSemanticTokensRefresh, nil, nil) + return result, nil } -// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. +// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. // -// Optionally a word pattern can be returned to describe valid contents. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. // -// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. // // @since 3.16.0. -func (s *server) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) { - s.logger.Debug("call " + MethodLinkedEditingRange) - defer s.logger.Debug("end "+MethodLinkedEditingRange, zap.Error(err)) +func (s *server) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillRenameFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillRenameFiles, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodLinkedEditingRange, params, &result); err != nil { + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillRenameFiles, params, &result); err != nil { return nil, err } return result, nil } -// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. -// -// An array of Moniker types is returned as response to indicate possible monikers at the given location. -// -// If no monikers can be calculated, an empty array or null should be returned. -// -// @since 3.16.0. -func (s *server) Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) { - s.logger.Debug("call " + MethodMoniker) - defer s.logger.Debug("end "+MethodMoniker, zap.Error(err)) +func (s *server) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (_ *WorkspaceSymbol, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbolResolve) + defer s.logger.Debug("end "+MethodWorkspaceSymbolResolve, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodMoniker, params, &result); err != nil { + var result *WorkspaceSymbol + if err := Call(ctx, s.Conn, MethodWorkspaceSymbolResolve, params, &result); err != nil { return nil, err } @@ -1881,11 +1986,11 @@ func (s *server) Moniker(ctx context.Context, params *MonikerParams) (result []M } // Request sends a request from the client to the server that non-compliant with the Language Server Protocol specifications. -func (s *server) Request(ctx context.Context, method string, params interface{}) (interface{}, error) { +func (s *server) Request(ctx context.Context, method string, params any) (any, error) { s.logger.Debug("call " + method) defer s.logger.Debug("end " + method) - var result interface{} + var result any if err := Call(ctx, s.Conn, method, params, &result); err != nil { return nil, err } diff --git a/server_interface.go b/server_interface.go new file mode 100644 index 00000000..c97e0c8e --- /dev/null +++ b/server_interface.go @@ -0,0 +1,681 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "context" + + "go.lsp.dev/jsonrpc2" +) + +const ( + MethodServerCancelRequest ServerMethod = "$/cancelRequest" // bidirect server notification + MethodServerProgress ServerMethod = "$/progress" // bidirect server notification + MethodSetTrace ServerMethod = "$/setTrace" // server notification + MethodExit ServerMethod = "exit" // server notification + MethodInitialized ServerMethod = "initialized" // server notification + MethodNotebookDocumentDidChange ServerMethod = "notebookDocument/didChange" // server notification + MethodNotebookDocumentDidClose ServerMethod = "notebookDocument/didClose" // server notification + MethodNotebookDocumentDidOpen ServerMethod = "notebookDocument/didOpen" // server notification + MethodNotebookDocumentDidSave ServerMethod = "notebookDocument/didSave" // server notification + MethodTextDocumentDidChange ServerMethod = "textDocument/didChange" // server notification + MethodTextDocumentDidClose ServerMethod = "textDocument/didClose" // server notification + MethodTextDocumentDidOpen ServerMethod = "textDocument/didOpen" // server notification + MethodTextDocumentDidSave ServerMethod = "textDocument/didSave" // server notification + MethodTextDocumentWillSave ServerMethod = "textDocument/willSave" // server notification + MethodWindowWorkDoneProgressCancel ServerMethod = "window/workDoneProgress/cancel" // server notification + MethodWorkspaceDidChangeConfiguration ServerMethod = "workspace/didChangeConfiguration" // server notification + MethodWorkspaceDidChangeWatchedFiles ServerMethod = "workspace/didChangeWatchedFiles" // server notification + MethodWorkspaceDidChangeWorkspaceFolders ServerMethod = "workspace/didChangeWorkspaceFolders" // server notification + MethodWorkspaceDidCreateFiles ServerMethod = "workspace/didCreateFiles" // server notification + MethodWorkspaceDidDeleteFiles ServerMethod = "workspace/didDeleteFiles" // server notification + MethodWorkspaceDidRenameFiles ServerMethod = "workspace/didRenameFiles" // server notification + MethodCallHierarchyIncomingCalls ServerMethod = "callHierarchy/incomingCalls" // server request + MethodCallHierarchyOutgoingCalls ServerMethod = "callHierarchy/outgoingCalls" // server request + MethodCodeActionResolve ServerMethod = "codeAction/resolve" // server request + MethodCodeLensResolve ServerMethod = "codeLens/resolve" // server request + MethodCompletionItemResolve ServerMethod = "completionItem/resolve" // server request + MethodDocumentLinkResolve ServerMethod = "documentLink/resolve" // server request + MethodInitialize ServerMethod = "initialize" // server request + MethodInlayHintResolve ServerMethod = "inlayHint/resolve" // server request + MethodShutdown ServerMethod = "shutdown" // server request + MethodTextDocumentCodeAction ServerMethod = "textDocument/codeAction" // server request + MethodTextDocumentCodeLens ServerMethod = "textDocument/codeLens" // server request + MethodTextDocumentColorPresentation ServerMethod = "textDocument/colorPresentation" // server request + MethodTextDocumentCompletion ServerMethod = "textDocument/completion" // server request + MethodTextDocumentDeclaration ServerMethod = "textDocument/declaration" // server request + MethodTextDocumentDefinition ServerMethod = "textDocument/definition" // server request + MethodTextDocumentDiagnostic ServerMethod = "textDocument/diagnostic" // server request + MethodTextDocumentDocumentColor ServerMethod = "textDocument/documentColor" // server request + MethodTextDocumentDocumentHighlight ServerMethod = "textDocument/documentHighlight" // server request + MethodTextDocumentDocumentLink ServerMethod = "textDocument/documentLink" // server request + MethodTextDocumentDocumentSymbol ServerMethod = "textDocument/documentSymbol" // server request + MethodTextDocumentFoldingRange ServerMethod = "textDocument/foldingRange" // server request + MethodTextDocumentFormatting ServerMethod = "textDocument/formatting" // server request + MethodTextDocumentHover ServerMethod = "textDocument/hover" // server request + MethodTextDocumentImplementation ServerMethod = "textDocument/implementation" // server request + MethodTextDocumentInlayHint ServerMethod = "textDocument/inlayHint" // server request + MethodTextDocumentInlineCompletion ServerMethod = "textDocument/inlineCompletion" // server request + MethodTextDocumentInlineValue ServerMethod = "textDocument/inlineValue" // server request + MethodTextDocumentLinkedEditingRange ServerMethod = "textDocument/linkedEditingRange" // server request + MethodTextDocumentMoniker ServerMethod = "textDocument/moniker" // server request + MethodTextDocumentOnTypeFormatting ServerMethod = "textDocument/onTypeFormatting" // server request + MethodTextDocumentPrepareCallHierarchy ServerMethod = "textDocument/prepareCallHierarchy" // server request + MethodTextDocumentPrepareRename ServerMethod = "textDocument/prepareRename" // server request + MethodTextDocumentPrepareTypeHierarchy ServerMethod = "textDocument/prepareTypeHierarchy" // server request + MethodTextDocumentRangeFormatting ServerMethod = "textDocument/rangeFormatting" // server request + MethodTextDocumentRangesFormatting ServerMethod = "textDocument/rangesFormatting" // server request + MethodTextDocumentReferences ServerMethod = "textDocument/references" // server request + MethodTextDocumentRename ServerMethod = "textDocument/rename" // server request + MethodTextDocumentSelectionRange ServerMethod = "textDocument/selectionRange" // server request + MethodTextDocumentSemanticTokensFull ServerMethod = "textDocument/semanticTokens/full" // server request + MethodTextDocumentSemanticTokensFullDelta ServerMethod = "textDocument/semanticTokens/full/delta" // server request + MethodTextDocumentSemanticTokensRange ServerMethod = "textDocument/semanticTokens/range" // server request + MethodTextDocumentSignatureHelp ServerMethod = "textDocument/signatureHelp" // server request + MethodTextDocumentTypeDefinition ServerMethod = "textDocument/typeDefinition" // server request + MethodTextDocumentWillSaveWaitUntil ServerMethod = "textDocument/willSaveWaitUntil" // server request + MethodTypeHierarchySubtypes ServerMethod = "typeHierarchy/subtypes" // server request + MethodTypeHierarchySupertypes ServerMethod = "typeHierarchy/supertypes" // server request + MethodWorkspaceDiagnostic ServerMethod = "workspace/diagnostic" // server request + MethodWorkspaceExecuteCommand ServerMethod = "workspace/executeCommand" // server request + MethodWorkspaceSymbol ServerMethod = "workspace/symbol" // server request + MethodWorkspaceWillCreateFiles ServerMethod = "workspace/willCreateFiles" // server request + MethodWorkspaceWillDeleteFiles ServerMethod = "workspace/willDeleteFiles" // server request + MethodWorkspaceWillRenameFiles ServerMethod = "workspace/willRenameFiles" // server request + MethodWorkspaceSymbolResolve ServerMethod = "workspaceSymbol/resolve" // server request +) + +type Server interface { + CancelRequest(ctx context.Context, params *CancelParams) error + + Progress(ctx context.Context, params *ProgressParams) error + + SetTrace(ctx context.Context, params *SetTraceParams) error + + // Exit the exit event is sent from the client to the server to ask the server to exit its process. + Exit(ctx context.Context) error + + // Initialized the initialized notification is sent from the client to the server after the client is fully initialized and the server is allowed to send requests from the server to the client. + Initialized(ctx context.Context, params *InitializedParams) error + + NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) error + + // NotebookDocumentDidClose a notification sent when a notebook closes. + // + // @since 3.17.0 + NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) error + + // NotebookDocumentDidOpen a notification sent when a notebook opens. + // + // @since 3.17.0 + NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) error + + // NotebookDocumentDidSave a notification sent when a notebook document is saved. + // + // @since 3.17.0 + NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) error + + // TextDocumentDidChange the document change notification is sent from the client to the server to signal changes to a text document. + TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) error + + // TextDocumentDidClose the document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notification to be sent. + TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) error + + // TextDocumentDidOpen the document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one. + TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) error + + // TextDocumentDidSave the document save notification is sent from the client to the server when the document got saved in the client. + TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) error + + // TextDocumentWillSave a document will save notification is sent from the client to the server before the document is actually saved. + TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) error + + // WindowWorkDoneProgressCancel the `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress initiated on the server side. + WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error + + // WorkspaceDidChangeConfiguration the configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains the changed configuration as defined by the language client. + WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error + + // WorkspaceDidChangeWatchedFiles the watched files notification is sent from the client to the server when the client detects changes + // to file watched by the language client. + WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error + + // WorkspaceDidChangeWorkspaceFolders the `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace folder configuration changes. + WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error + + // WorkspaceDidCreateFiles the did create files notification is sent from the client to the server when files were created from + // within the client. + // + // @since 3.16.0 + WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) error + + // WorkspaceDidDeleteFiles the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. + // + // @since 3.16.0 + WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error + + // WorkspaceDidRenameFiles the did rename files notification is sent from the client to the server when files were renamed from + // within the client. + // + // @since 3.16.0 + WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) error + // CallHierarchyIncomingCalls a request to resolve the incoming calls for a given `CallHierarchyItem`. + // + // @since 3.16.0 + CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) ([]*CallHierarchyIncomingCall, error) + + // CallHierarchyOutgoingCalls a request to resolve the outgoing calls for a given `CallHierarchyItem`. + // + // @since 3.16.0 + CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) + + // CodeActionResolve request to resolve additional information for a given code action.The request's parameter is of type + // CodeAction the response is of type CodeAction or a Thenable that resolves to such. + CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) + + // CodeLensResolve a request to resolve a command for a given code lens. + CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) + + // CompletionItemResolve request to resolve additional information for a given completion item.The request's parameter is of type CompletionItem the response is of type CompletionItem or a Thenable that resolves to such. + CompletionItemResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) + + // DocumentLinkResolve request to resolve additional information for a given document link. The request's parameter is of type DocumentLink the response is of type DocumentLink or a Thenable that resolves to such. + DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) + + // Initialize the initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type InitializeParams the response if of type InitializeResult of a Thenable that resolves to such. + Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) + + // InlayHintResolve a request to resolve additional properties for an inlay hint. The request's parameter is of type InlayHint, the response is of type InlayHint or a Thenable that resolves to such. + // + // @since 3.17.0 + InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) + + // Shutdown a shutdown request is sent from the client to the server. It is sent once when the client decides to + // shutdown the server. The only notification that is sent after a shutdown request is the exit event. + Shutdown(ctx context.Context) error + + // TextDocumentCodeAction a request to provide commands for the given text document and range. + TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (*TextDocumentCodeActionResult, error) + + // TextDocumentCodeLens a request to provide code lens for the given text document. + TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) + + // TextDocumentColorPresentation a request to list all presentation for a color. The request's parameter is of type ColorPresentationParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. + TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) + + // TextDocumentCompletion request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, + // `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. + TextDocumentCompletion(ctx context.Context, params *CompletionParams) (*TextDocumentCompletionResult, error) + + // TextDocumentDeclaration a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a + // typed array of DeclarationLink or a Thenable that resolves to such. + TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (*TextDocumentDeclarationResult, error) + + // TextDocumentDefinition a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed + // array of DefinitionLink or a Thenable that resolves to such. + TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (*TextDocumentDefinitionResult, error) + + // TextDocumentDiagnostic the document diagnostic request definition. + // + // @since 3.17.0 + TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) + + // TextDocumentDocumentColor a request to list all color symbols found in a given text document. The request's parameter is of type DocumentColorParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. + TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) + + // TextDocumentDocumentHighlight request to resolve a DocumentHighlight for a given text document position. The request's parameter is of type TextDocumentPosition the request response is an array of type DocumentHighlight or a Thenable that resolves to such. + TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) + + // TextDocumentDocumentLink a request to provide document links. + TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) + + // TextDocumentDocumentSymbol a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that + // resolves to such. + TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*TextDocumentDocumentSymbolResult, error) + + // TextDocumentFoldingRange a request to provide folding ranges in a document. The request's parameter is of type FoldingRangeParams, the response is of type FoldingRangeList or a Thenable that resolves to such. + TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) + + // TextDocumentFormatting a request to format a whole document. + TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) + + // TextDocumentHover request to request hover information at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type Hover or a Thenable that resolves to such. + TextDocumentHover(ctx context.Context, params *HoverParams) (*Hover, error) + + // TextDocumentImplementation a request to resolve the implementation locations of a symbol at a given text document position. The + // request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. + TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (*TextDocumentImplementationResult, error) + + // TextDocumentInlayHint a request to provide inlay hints in a document. The request's parameter is of type InlayHintsParams, + // the response is of type InlayHint InlayHint[] or a Thenable that resolves to such. + // + // @since 3.17.0 + TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) + + // TextDocumentInlineCompletion a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (*TextDocumentInlineCompletionResult, error) + + // TextDocumentInlineValue a request to provide inline values in a document. The request's parameter is of type InlineValueParams, the response is of type InlineValue InlineValue[] or a Thenable that resolves to such. + // + // @since 3.17.0 + TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) + + // TextDocumentLinkedEditingRange a request to provide ranges that can be edited together. + // + // @since 3.16.0 + TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) + + // TextDocumentMoniker a request to get the moniker of a symbol at a given text document position. The request parameter is + // of type TextDocumentPositionParams. The response is of type Moniker Moniker[] or `null`. + TextDocumentMoniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) + + // TextDocumentOnTypeFormatting a request to format a document on type. + TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) + + // TextDocumentPrepareCallHierarchy a request to result a `CallHierarchyItem` in a document at a given position. Can be used as an input + // to an incoming or outgoing call hierarchy. + // + // @since 3.16.0 + TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) + + // TextDocumentPrepareRename a request to test and perform the setup necessary for a rename. 3.16 - support for default behavior. + // + // @since 3.16 - support for default behavior + TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) + + // TextDocumentPrepareTypeHierarchy a request to result a `TypeHierarchyItem` in a document at a given position. Can be used as an input + // to a subtypes or supertypes type hierarchy. + // + // @since 3.17.0 + TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) + + // TextDocumentRangeFormatting a request to format a range in a document. + TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) + + // TextDocumentRangesFormatting a request to format ranges in a document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) + + // TextDocumentReferences a request to resolve project-wide references for the symbol denoted by the given text document position. The request's parameter is of type ReferenceParams the response is of type Location Location[] or a Thenable that resolves to such. + TextDocumentReferences(ctx context.Context, params *ReferenceParams) ([]*Location, error) + + // TextDocumentRename a request to rename a symbol. + TextDocumentRename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) + + // TextDocumentSelectionRange a request to provide selection ranges in a document. The request's parameter is of type SelectionRangeParams, the response is of type SelectionRange SelectionRange[] or a Thenable that resolves to such. + TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) + + // TextDocumentSemanticTokensFull. + // + // @since 3.16.0 + TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) + + // TextDocumentSemanticTokensFullDelta. + // + // @since 3.16.0 + TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*TextDocumentSemanticTokensFullDeltaResult, error) + + // TextDocumentSemanticTokensRange. + // + // @since 3.16.0 + TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) + + TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) + + // TextDocumentTypeDefinition a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. + TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TextDocumentTypeDefinitionResult, error) + + // TextDocumentWillSaveWaitUntil a document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before + // it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable. + TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) + + // TypeHierarchySubtypes a request to resolve the subtypes for a given `TypeHierarchyItem`. + // + // @since 3.17.0 + TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) + + // TypeHierarchySupertypes a request to resolve the supertypes for a given `TypeHierarchyItem`. + // + // @since 3.17.0 + TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) + + // WorkspaceDiagnostic the workspace diagnostic request definition. + // + // @since 3.17.0 + WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) + + // WorkspaceExecuteCommand a request send from the client to the server to execute a command. The request might return a workspace edit which the client will apply to the workspace. + WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) + + // WorkspaceSymbol a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. + // The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + // + // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) + + // WorkspaceWillCreateFiles the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a `WorkspaceEdit` which will be applied to workspace before the files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file to be created. + // + // @since 3.16.0 + WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) + + // WorkspaceWillDeleteFiles the did delete files notification is sent from the client to the server when files were deleted from + // within the client. + // + // @since 3.16.0 + WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) + + // WorkspaceWillRenameFiles the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. + // + // @since 3.16.0 + WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) + + // WorkspaceSymbolResolve a request to resolve the range inside the workspace symbol's location. + // + // @since 3.17.0 + WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (*WorkspaceSymbol, error) + + Request(ctx context.Context, method string, params any) (any, error) +} + +// UnimplementedServer should be embedded to have forward compatible implementations. +type UnimplementedServer struct{} + +func (UnimplementedServer) CancelRequest(ctx context.Context, params *CancelParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Progress(ctx context.Context, params *ProgressParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) SetTrace(ctx context.Context, params *SetTraceParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Exit(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Initialized(ctx context.Context, params *InitializedParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) ([]*CallHierarchyIncomingCall, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CompletionItemResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Shutdown(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (*TextDocumentCodeActionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (*TextDocumentCompletionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (*TextDocumentDeclarationResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (*TextDocumentDefinitionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*TextDocumentDocumentSymbolResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentHover(ctx context.Context, params *HoverParams) (*Hover, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (*TextDocumentImplementationResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (*TextDocumentInlineCompletionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentMoniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentReferences(ctx context.Context, params *ReferenceParams) ([]*Location, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentRename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*TextDocumentSemanticTokensFullDeltaResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TextDocumentTypeDefinitionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (*WorkspaceSymbol, error) { + return nil, jsonrpc2.ErrInternal +} From 2464d76cd6e4ed765a80c8b86596472348459229 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Sun, 5 May 2024 23:41:37 +0900 Subject: [PATCH 07/19] WIP3 Signed-off-by: Koichi Shiraishi --- client.go | 337 ++++---- client_interface.go | 197 ----- go.mod | 5 +- go.sum | 2 + server.go | 1874 ++++++++++++++++++++----------------------- server_interface.go | 681 ---------------- 6 files changed, 1027 insertions(+), 2069 deletions(-) delete mode 100644 client_interface.go delete mode 100644 server_interface.go diff --git a/client.go b/client.go index 806f0131..1f9817bb 100644 --- a/client.go +++ b/client.go @@ -8,9 +8,11 @@ import ( "context" "fmt" + "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" + "go.lsp.dev/pkg/xcontext" ) // ClientDispatcher returns a Client that dispatches LSP requests across the @@ -26,7 +28,7 @@ func ClientDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Client { func ClientHandler(client Client, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := context.WithoutCancel(ctx) + xctx := xcontext.Detach(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -50,12 +52,12 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := newDecoder(bytes.NewReader(req.Params())) + dec := json.NewDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodClientProgress: // notification - defer logger.Debug(MethodClientProgress, zap.Error(err)) + case MethodProgress: // notification + defer logger.Debug(MethodProgress, zap.Error(err)) var params ProgressParams if err := dec.Decode(¶ms); err != nil { @@ -66,27 +68,27 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodLogTrace: // notification - defer logger.Debug(MethodLogTrace, zap.Error(err)) + case MethodWorkDoneProgressCreate: // request + defer logger.Debug(MethodWorkDoneProgressCreate, zap.Error(err)) - var params LogTraceParams + var params WorkDoneProgressCreateParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.LogTrace(ctx, ¶ms) + err := client.WorkDoneProgressCreate(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTelemetryEvent: // notification - defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) + case MethodWindowLogMessage: // notification + defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) - var params any + var params LogMessageParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.TelemetryEvent(ctx, ¶ms) + err := client.LogMessage(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -98,19 +100,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.TextDocumentPublishDiagnostics(ctx, ¶ms) - - return true, reply(ctx, nil, err) - - case MethodWindowLogMessage: // notification - defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) - - var params LogMessageParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - err := client.WindowLogMessage(ctx, ¶ms) + err := client.PublishDiagnostics(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -122,67 +112,55 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.WindowShowMessage(ctx, ¶ms) + err := client.ShowMessage(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodClientRegisterCapability: // request - defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) + case MethodWindowShowMessageRequest: // request + defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) - var params RegistrationParams + var params ShowMessageRequestParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.ClientRegisterCapability(ctx, ¶ms) + resp, err := client.ShowMessageRequest(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodClientUnregisterCapability: // request - defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) + case MethodTelemetryEvent: // notification + defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) - var params UnregistrationParams + var params interface{} if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.ClientUnregisterCapability(ctx, ¶ms) + err := client.Telemetry(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWindowShowDocument: // request - defer logger.Debug(MethodWindowShowDocument, zap.Error(err)) - - var params ShowDocumentParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := client.WindowShowDocument(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWindowShowMessageRequest: // request - defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) + case MethodClientRegisterCapability: // request + defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) - var params ShowMessageRequestParams + var params RegistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := client.WindowShowMessageRequest(ctx, ¶ms) + err := client.RegisterCapability(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodWindowWorkDoneProgressCreate: // request - defer logger.Debug(MethodWindowWorkDoneProgressCreate, zap.Error(err)) + case MethodClientUnregisterCapability: // request + defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) - var params WorkDoneProgressCreateParams + var params UnregistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.WindowWorkDoneProgressCreate(ctx, ¶ms) + err := client.UnregisterCapability(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -194,17 +172,10 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.WorkspaceApplyEdit(ctx, ¶ms) + resp, err := client.ApplyEdit(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceCodeLensRefresh: // request - defer logger.Debug(MethodWorkspaceCodeLensRefresh, zap.Error(err)) - - err := client.WorkspaceCodeLensRefresh(ctx) - - return true, reply(ctx, nil, err) - case MethodWorkspaceConfiguration: // request defer logger.Debug(MethodWorkspaceConfiguration, zap.Error(err)) @@ -213,53 +184,80 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.WorkspaceConfiguration(ctx, ¶ms) + resp, err := client.Configuration(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceDiagnosticRefresh: // request - defer logger.Debug(MethodWorkspaceDiagnosticRefresh, zap.Error(err)) + case MethodWorkspaceWorkspaceFolders: // request + defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) - err := client.WorkspaceDiagnosticRefresh(ctx) + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } - return true, reply(ctx, nil, err) + resp, err := client.WorkspaceFolders(ctx) - case MethodWorkspaceFoldingRangeRefresh: // request - defer logger.Debug(MethodWorkspaceFoldingRangeRefresh, zap.Error(err)) + return true, reply(ctx, resp, err) - err := client.WorkspaceFoldingRangeRefresh(ctx) + default: + return false, nil + } +} - return true, reply(ctx, nil, err) +// Client represents a Language Server Protocol client. +type Client interface { + Progress(ctx context.Context, params *ProgressParams) (err error) + WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) + LogMessage(ctx context.Context, params *LogMessageParams) (err error) + PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) + ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) + ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (result *MessageActionItem, err error) + Telemetry(ctx context.Context, params interface{}) (err error) + RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) + UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) + ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) + Configuration(ctx context.Context, params *ConfigurationParams) (result []interface{}, err error) + WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) +} - case MethodWorkspaceInlayHintRefresh: // request - defer logger.Debug(MethodWorkspaceInlayHintRefresh, zap.Error(err)) +// list of client methods. +const ( + // MethodProgress method name of "$/progress". + MethodProgress = "$/progress" - err := client.WorkspaceInlayHintRefresh(ctx) + // MethodWorkDoneProgressCreate method name of "window/workDoneProgress/create". + MethodWorkDoneProgressCreate = "window/workDoneProgress/create" - return true, reply(ctx, nil, err) + // MethodWindowShowMessage method name of "window/showMessage". + MethodWindowShowMessage = "window/showMessage" - case MethodWorkspaceSemanticTokensRefresh: // request - defer logger.Debug(MethodWorkspaceSemanticTokensRefresh, zap.Error(err)) + // MethodWindowShowMessageRequest method name of "window/showMessageRequest. + MethodWindowShowMessageRequest = "window/showMessageRequest" - err := client.WorkspaceSemanticTokensRefresh(ctx) + // MethodWindowLogMessage method name of "window/logMessage. + MethodWindowLogMessage = "window/logMessage" - return true, reply(ctx, nil, err) + // MethodTelemetryEvent method name of "telemetry/event. + MethodTelemetryEvent = "telemetry/event" - case MethodWorkspaceWorkspaceFolders: // request - defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) + // MethodClientRegisterCapability method name of "client/registerCapability. + MethodClientRegisterCapability = "client/registerCapability" - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) - } + // MethodClientUnregisterCapability method name of "client/unregisterCapability. + MethodClientUnregisterCapability = "client/unregisterCapability" - resp, err := client.WorkspaceWorkspaceFolders(ctx) + // MethodTextDocumentPublishDiagnostics method name of "textDocument/publishDiagnostics. + MethodTextDocumentPublishDiagnostics = "textDocument/publishDiagnostics" - return true, reply(ctx, resp, err) + // MethodWorkspaceApplyEdit method name of "workspace/applyEdit. + MethodWorkspaceApplyEdit = "workspace/applyEdit" - default: - return false, nil - } -} + // MethodWorkspaceConfiguration method name of "workspace/configuration. + MethodWorkspaceConfiguration = "workspace/configuration" + + // MethodWorkspaceWorkspaceFolders method name of "workspace/workspaceFolders". + MethodWorkspaceWorkspaceFolders = "workspace/workspaceFolders" +) // client implements a Language Server Protocol client. type client struct { @@ -271,13 +269,6 @@ type client struct { // compiler time check whether the Client implements ClientInterface interface. var _ Client = (*client)(nil) -func (c *client) CancelRequest(ctx context.Context, params *CancelParams) (err error) { - c.logger.Debug("notify " + MethodClientCancelRequest) - defer c.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) - - return c.Conn.Notify(ctx, MethodClientCancelRequest, params) -} - // Progress is the base protocol offers also support to report progress in a generic fashion. // // This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and @@ -285,25 +276,28 @@ func (c *client) CancelRequest(ctx context.Context, params *CancelParams) (err e // // @since 3.16.0. func (c *client) Progress(ctx context.Context, params *ProgressParams) (err error) { - c.logger.Debug("notify " + MethodClientProgress) - defer c.logger.Debug("end "+MethodClientProgress, zap.Error(err)) + c.logger.Debug("call " + MethodProgress) + defer c.logger.Debug("end "+MethodProgress, zap.Error(err)) - return c.Conn.Notify(ctx, MethodClientProgress, params) + return c.Conn.Notify(ctx, MethodProgress, params) } -func (c *client) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { - c.logger.Debug("notify " + MethodLogTrace) - defer c.logger.Debug("end "+MethodLogTrace, zap.Error(err)) +// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. +// +// @since 3.16.0. +func (c *client) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { + c.logger.Debug("call " + MethodWorkDoneProgressCreate) + defer c.logger.Debug("end "+MethodWorkDoneProgressCreate, zap.Error(err)) - return c.Conn.Notify(ctx, MethodLogTrace, params) + return Call(ctx, c.Conn, MethodWorkDoneProgressCreate, params, nil) } -// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. -func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { - c.logger.Debug("notify " + MethodTelemetryEvent) - defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) +// LogMessage sends the notification from the server to the client to ask the client to log a particular message. +func (c *client) LogMessage(ctx context.Context, params *LogMessageParams) (err error) { + c.logger.Debug("call " + MethodWindowLogMessage) + defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) - return c.Conn.Notify(ctx, MethodTelemetryEvent, params) + return c.Conn.Notify(ctx, MethodWindowLogMessage, params) } // PublishDiagnostics sends the notification from the server to the client to signal results of validation runs. @@ -316,28 +310,40 @@ func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { // When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. // If the computed set is empty it has to push the empty array to clear former diagnostics. // Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side. -func (c *client) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { - c.logger.Debug("notify " + MethodTextDocumentPublishDiagnostics) +func (c *client) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { + c.logger.Debug("call " + MethodTextDocumentPublishDiagnostics) defer c.logger.Debug("end "+MethodTextDocumentPublishDiagnostics, zap.Error(err)) return c.Conn.Notify(ctx, MethodTextDocumentPublishDiagnostics, params) } -// LogMessage sends the notification from the server to the client to ask the client to log a particular message. -func (c *client) WindowLogMessage(ctx context.Context, params *LogMessageParams) (err error) { - c.logger.Debug("notify " + MethodWindowLogMessage) - defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) +// ShowMessage sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { + return c.Conn.Notify(ctx, MethodWindowShowMessage, params) +} - return c.Conn.Notify(ctx, MethodWindowLogMessage, params) +// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. +// +// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. +func (c *client) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { + c.logger.Debug("call " + MethodWindowShowMessageRequest) + defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) + + var result *MessageActionItem + if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { + return nil, err + } + + return result, nil } -// ShowMessage sends the notification from a server to a client to ask the -// client to display a particular message in the user interface. -func (c *client) WindowShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { - c.logger.Debug("notify " + MethodWindowShowMessage) - defer c.logger.Debug("end "+MethodWindowShowMessage, zap.Error(err)) +// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. +func (c *client) Telemetry(ctx context.Context, params interface{}) (err error) { + c.logger.Debug("call " + MethodTelemetryEvent) + defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) - return c.Conn.Notify(ctx, MethodWindowShowMessage, params) + return c.Conn.Notify(ctx, MethodTelemetryEvent, params) } // RegisterCapability sends the request from the server to the client to register for a new capability on the client side. @@ -346,7 +352,7 @@ func (c *client) WindowShowMessage(ctx context.Context, params *ShowMessageParam // // A client opts in via the dynamicRegistration property on the specific client capabilities. // A client can even provide dynamic registration for capability A but not for capability B (see TextDocumentClientCapabilities as an example). -func (c *client) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { +func (c *client) RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { c.logger.Debug("call " + MethodClientRegisterCapability) defer c.logger.Debug("end "+MethodClientRegisterCapability, zap.Error(err)) @@ -354,54 +360,15 @@ func (c *client) ClientRegisterCapability(ctx context.Context, params *Registrat } // UnregisterCapability sends the request from the server to the client to unregister a previously registered capability. -func (c *client) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { +func (c *client) UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { c.logger.Debug("call " + MethodClientUnregisterCapability) defer c.logger.Debug("end "+MethodClientUnregisterCapability, zap.Error(err)) return Call(ctx, c.Conn, MethodClientUnregisterCapability, params, nil) } -// ShowMessage sends the notification from a server to a client to ask the -// client to display a particular message in the user interface. -func (c *client) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (_ *ShowDocumentResult, err error) { - c.logger.Debug("call " + MethodWindowShowDocument) - defer c.logger.Debug("end "+MethodWindowShowDocument, zap.Error(err)) - - var result *ShowDocumentResult - if err := Call(ctx, c.Conn, MethodWindowShowDocument, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. -// -// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. -func (c *client) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { - c.logger.Debug("call " + MethodWindowShowMessageRequest) - defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) - - var result *MessageActionItem - if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. -// -// @since 3.16.0. -func (c *client) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { - c.logger.Debug("call " + MethodWindowWorkDoneProgressCreate) - defer c.logger.Debug("end "+MethodWindowWorkDoneProgressCreate, zap.Error(err)) - - return Call(ctx, c.Conn, MethodWindowWorkDoneProgressCreate, params, nil) -} - // ApplyEdit sends the request from the server to the client to modify resource on the client side. -func (c *client) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResult, err error) { +func (c *client) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) { c.logger.Debug("call " + MethodWorkspaceApplyEdit) defer c.logger.Debug("end "+MethodWorkspaceApplyEdit, zap.Error(err)) @@ -412,20 +379,16 @@ func (c *client) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceE return result, nil } -func (c *client) WorkspaceCodeLensRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceCodeLensRefresh) -} - // Configuration sends the request from the server to the client to fetch configuration settings from the client. // // The request can fetch several configuration settings in one roundtrip. // The order of the returned configuration settings correspond to the order of the // passed ConfigurationItems (e.g. the first item in the response is the result for the first configuration item in the params). -func (c *client) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) (_ []any, err error) { +func (c *client) Configuration(ctx context.Context, params *ConfigurationParams) (_ []interface{}, err error) { c.logger.Debug("call " + MethodWorkspaceConfiguration) defer c.logger.Debug("end "+MethodWorkspaceConfiguration, zap.Error(err)) - var result []any + var result []interface{} if err := Call(ctx, c.Conn, MethodWorkspaceConfiguration, params, &result); err != nil { return nil, err } @@ -433,39 +396,12 @@ func (c *client) WorkspaceConfiguration(ctx context.Context, params *Configurati return result, nil } -func (c *client) WorkspaceDiagnosticRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceDiagnosticRefresh) -} - -func (c *client) WorkspaceFoldingRangeRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceFoldingRangeRefresh) -} - -func (c *client) WorkspaceInlayHintRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceInlayHintRefresh) -} - -func (c *client) WorkspaceInlineValueRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceInlineValueRefresh) -} - -func (c *client) WorkspaceSemanticTokensRefresh(ctx context.Context) (err error) { - return c.refresh(ctx, MethodWorkspaceSemanticTokensRefresh) -} - -func (c *client) refresh(ctx context.Context, method string) (err error) { - c.logger.Debug("call " + method) - defer c.logger.Debug("end "+method, zap.Error(err)) - - return c.Conn.Notify(ctx, method, nil) -} - // WorkspaceFolders sends the request from the server to the client to fetch the current open list of workspace folders. // // Returns null in the response if only a single file is open in the tool. Returns an empty array if a workspace is open but no folders are configured. // // @since 3.6.0. -func (c *client) WorkspaceWorkspaceFolders(ctx context.Context) (result []*WorkspaceFolder, err error) { +func (c *client) WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) { c.logger.Debug("call " + MethodWorkspaceWorkspaceFolders) defer c.logger.Debug("end "+MethodWorkspaceWorkspaceFolders, zap.Error(err)) @@ -475,3 +411,4 @@ func (c *client) WorkspaceWorkspaceFolders(ctx context.Context) (result []*Works return result, nil } + diff --git a/client_interface.go b/client_interface.go deleted file mode 100644 index 01ee1d19..00000000 --- a/client_interface.go +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright 2024 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "context" - - "go.lsp.dev/jsonrpc2" -) - -const ( - MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification - MethodClientProgress ClientMethod = "$/progress" // bidirect client notification - MethodLogTrace ClientMethod = "$/logTrace" // client notification - MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification - MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification - MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification - MethodWindowShowMessage ClientMethod = "window/showMessage" // client notification - MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request - MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request - MethodWindowShowDocument ClientMethod = "window/showDocument" // client request - MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request - MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request - MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request - MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request - MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request - MethodWorkspaceDiagnosticRefresh ClientMethod = "workspace/diagnostic/refresh" // client request - MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request - MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request - MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request - MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request - MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request -) - -type Client interface { - CancelRequest(ctx context.Context, params *CancelParams) error - - Progress(ctx context.Context, params *ProgressParams) error - - LogTrace(ctx context.Context, params *LogTraceParams) error - - // TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data. - TelemetryEvent(ctx context.Context, params any) error - - // TextDocumentPublishDiagnostics diagnostics notification are sent from the server to the client to signal results of validation runs. - TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error - - // WindowLogMessage the log message notification is sent from the server to the client to ask the client to log a particular message. - WindowLogMessage(ctx context.Context, params *LogMessageParams) error - - // WindowShowMessage the show message notification is sent from a server to a client to ask the client to display a particular message in the user interface. - WindowShowMessage(ctx context.Context, params *ShowMessageParams) error - // ClientRegisterCapability the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side. - ClientRegisterCapability(ctx context.Context, params *RegistrationParams) error - - // ClientUnregisterCapability the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side. - ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) error - - // WindowShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser. - // - // @since 3.16.0 - WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) - - // WindowShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user. - WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) - - // WindowWorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server. - WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error - - // WorkspaceApplyEdit a request sent from the server to the client to modified certain resources. - WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) - - // WorkspaceCodeLensRefresh a request to refresh all code actions - // - // @since 3.16.0 - WorkspaceCodeLensRefresh(ctx context.Context) error - - // WorkspaceConfiguration the 'workspace/configuration' request is sent from the server to the client to fetch a certain configuration setting. This pull model replaces the old push model were the client signaled configuration - // change via an event. If the server still needs to react to configuration changes (since the server caches the result of `workspace/configuration` requests) the server should register for an empty configuration change event and empty the cache if such an event is received. - WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) ([]any, error) - - // WorkspaceDiagnosticRefresh the diagnostic refresh request definition. - // - // @since 3.17.0 - WorkspaceDiagnosticRefresh(ctx context.Context) error - - // WorkspaceFoldingRangeRefresh. - // - // @since 3.18.0 proposed - WorkspaceFoldingRangeRefresh(ctx context.Context) error - - // WorkspaceInlayHintRefresh. - // - // @since 3.17.0 - WorkspaceInlayHintRefresh(ctx context.Context) error - - // WorkspaceInlineValueRefresh. - // - // @since 3.17.0 - WorkspaceInlineValueRefresh(ctx context.Context) error - - // WorkspaceSemanticTokensRefresh. - // - // @since 3.16.0 - WorkspaceSemanticTokensRefresh(ctx context.Context) error - - // WorkspaceWorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders. - WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) -} - -// UnimplementedClient should be embedded to have forward compatible implementations. -type UnimplementedClient struct{} - -func (UnimplementedClient) CancelRequest(ctx context.Context, params *CancelParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) Progress(ctx context.Context, params *ProgressParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WindowLogMessage(ctx context.Context, params *LogMessageParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WindowShowMessage(ctx context.Context, params *ShowMessageParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkspaceCodeLensRefresh(ctx context.Context) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) ([]any, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkspaceDiagnosticRefresh(ctx context.Context) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkspaceFoldingRangeRefresh(ctx context.Context) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkspaceInlayHintRefresh(ctx context.Context) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkspaceInlineValueRefresh(ctx context.Context) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkspaceSemanticTokensRefresh(ctx context.Context) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) { - return nil, jsonrpc2.ErrInternal -} diff --git a/go.mod b/go.mod index 9f65d1f3..68663a43 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,16 @@ module go.lsp.dev/protocol go 1.22.2 require ( + github.com/google/go-cmp v0.6.0 + github.com/segmentio/encoding v0.4.0 go.lsp.dev/jsonrpc2 v0.10.0 + go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 go.lsp.dev/uri v0.3.0 go.uber.org/zap v1.27.0 ) require ( - github.com/google/go-cmp v0.6.0 // indirect github.com/segmentio/asm v1.1.3 // indirect - github.com/segmentio/encoding v0.4.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect ) diff --git a/go.sum b/go.sum index 4241d3ae..b092fc5d 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= go.lsp.dev/jsonrpc2 v0.10.0 h1:Pr/YcXJoEOTMc/b6OTmcR1DPJ3mSWl/SWiU1Cct6VmI= go.lsp.dev/jsonrpc2 v0.10.0/go.mod h1:fmEzIdXPi/rf6d4uFcayi8HpFP1nBF99ERP1htC72Ac= +go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 h1:hCzQgh6UcwbKgNSRurYWSqh8MufqRRPODRBblutn4TE= +go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2/go.mod h1:gtSHRuYfbCT0qnbLnovpie/WEmqyJ7T4n6VXiFMBtcw= go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo= go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= diff --git a/server.go b/server.go index 1abb8464..fb7e693e 100644 --- a/server.go +++ b/server.go @@ -8,9 +8,11 @@ import ( "context" "fmt" + "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" + "go.lsp.dev/pkg/xcontext" ) // ServerDispatcher returns a Server that dispatches LSP requests across the @@ -28,7 +30,7 @@ func ServerDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Server { func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := context.WithoutCancel(ctx) + xctx := xcontext.Detach(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -40,8 +42,8 @@ func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { // TODO: This code is wrong, it ignores handler and assumes non standard // request handles everything // non standard request should just be a layered handler. - var params any - if err := unmarshal(req.Params(), ¶ms); err != nil { + var params interface{} + if err := json.Unmarshal(req.Params(), ¶ms); err != nil { return replyParseError(ctx, reply, err) } @@ -61,31 +63,42 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := newDecoder(bytes.NewReader(req.Params())) + dec := json.NewDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodServerProgress: // notification - defer logger.Debug(MethodServerProgress, zap.Error(err)) + case MethodInitialize: // request + defer logger.Debug(MethodInitialize, zap.Error(err)) - var params ProgressParams + var params InitializeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.Progress(ctx, ¶ms) + resp, err := server.Initialize(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodSetTrace: // notification - defer logger.Debug(MethodSetTrace, zap.Error(err)) + case MethodInitialized: // notification + defer logger.Debug(MethodInitialized, zap.Error(err)) - var params SetTraceParams + var params InitializedParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.SetTrace(ctx, ¶ms) + err := server.Initialized(ctx, ¶ms) + + return true, reply(ctx, nil, err) + + case MethodShutdown: // request + defer logger.Debug(MethodShutdown, zap.Error(err)) + + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } + + err := server.Shutdown(ctx) return true, reply(ctx, nil, err) @@ -100,135 +113,147 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodInitialized: // notification - defer logger.Debug(MethodInitialized, zap.Error(err)) + case MethodWorkDoneProgressCancel: // notification + defer logger.Debug(MethodWorkDoneProgressCancel, zap.Error(err)) - var params InitializedParams + var params WorkDoneProgressCancelParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.Initialized(ctx, ¶ms) + err := server.WorkDoneProgressCancel(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodNotebookDocumentDidChange: // notification - defer logger.Debug(MethodNotebookDocumentDidChange, zap.Error(err)) + case MethodLogTrace: // notification + defer logger.Debug(MethodLogTrace, zap.Error(err)) - var params DidChangeNotebookDocumentParams + var params LogTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidChange(ctx, ¶ms) + err := server.LogTrace(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodNotebookDocumentDidClose: // notification - defer logger.Debug(MethodNotebookDocumentDidClose, zap.Error(err)) + case MethodSetTrace: // notification + defer logger.Debug(MethodSetTrace, zap.Error(err)) - var params DidCloseNotebookDocumentParams + var params SetTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidClose(ctx, ¶ms) + err := server.SetTrace(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodNotebookDocumentDidOpen: // notification - defer logger.Debug(MethodNotebookDocumentDidOpen, zap.Error(err)) + case MethodTextDocumentCodeAction: // request + defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) - var params DidOpenNotebookDocumentParams + var params CodeActionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidOpen(ctx, ¶ms) + resp, err := server.CodeAction(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodNotebookDocumentDidSave: // notification - defer logger.Debug(MethodNotebookDocumentDidSave, zap.Error(err)) + case MethodTextDocumentCodeLens: // request + defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) - var params DidSaveNotebookDocumentParams + var params CodeLensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidSave(ctx, ¶ms) + resp, err := server.CodeLens(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentDidChange: // notification - defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) + case MethodCodeLensResolve: // request + defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) - var params DidChangeTextDocumentParams + var params CodeLens if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidChange(ctx, ¶ms) + resp, err := server.CodeLensResolve(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentDidClose: // notification - defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) + case MethodTextDocumentColorPresentation: // request + defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) - var params DidCloseTextDocumentParams + var params ColorPresentationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidClose(ctx, ¶ms) + resp, err := server.ColorPresentation(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentDidOpen: // notification - defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) + case MethodTextDocumentCompletion: // request + defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) - var params DidOpenTextDocumentParams + var params CompletionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidOpen(ctx, ¶ms) + resp, err := server.Completion(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentDidSave: // notification - defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) + case MethodCompletionItemResolve: // request + defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) - var params DidSaveTextDocumentParams + var params CompletionItem if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidSave(ctx, ¶ms) + resp, err := server.CompletionResolve(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentWillSave: // notification - defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) + case MethodTextDocumentDeclaration: // request + defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) - var params WillSaveTextDocumentParams + var params DeclarationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentWillSave(ctx, ¶ms) + resp, err := server.Declaration(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodWindowWorkDoneProgressCancel: // notification - defer logger.Debug(MethodWindowWorkDoneProgressCancel, zap.Error(err)) + case MethodTextDocumentDefinition: // request + defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) - var params WorkDoneProgressCancelParams + var params DefinitionParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.Definition(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentDidChange: // notification + defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) + + var params DidChangeTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WindowWorkDoneProgressCancel(ctx, ¶ms) + err := server.DidChange(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -240,7 +265,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidChangeConfiguration(ctx, ¶ms) + err := server.DidChangeConfiguration(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -252,7 +277,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidChangeWatchedFiles(ctx, ¶ms) + err := server.DidChangeWatchedFiles(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -264,404 +289,380 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidChangeWorkspaceFolders(ctx, ¶ms) + err := server.DidChangeWorkspaceFolders(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWorkspaceDidCreateFiles: // notification - defer logger.Debug(MethodWorkspaceDidCreateFiles, zap.Error(err)) + case MethodTextDocumentDidClose: // notification + defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) - var params CreateFilesParams + var params DidCloseTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidCreateFiles(ctx, ¶ms) + err := server.DidClose(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWorkspaceDidDeleteFiles: // notification - defer logger.Debug(MethodWorkspaceDidDeleteFiles, zap.Error(err)) + case MethodTextDocumentDidOpen: // notification + defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) - var params DeleteFilesParams + var params DidOpenTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidDeleteFiles(ctx, ¶ms) + err := server.DidOpen(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWorkspaceDidRenameFiles: // notification - defer logger.Debug(MethodWorkspaceDidRenameFiles, zap.Error(err)) + case MethodTextDocumentDidSave: // notification + defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) - var params RenameFilesParams + var params DidSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidRenameFiles(ctx, ¶ms) + err := server.DidSave(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodCallHierarchyIncomingCalls: // request - defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) + case MethodTextDocumentDocumentColor: // request + defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) - var params CallHierarchyIncomingCallsParams + var params DocumentColorParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CallHierarchyIncomingCalls(ctx, ¶ms) + resp, err := server.DocumentColor(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCallHierarchyOutgoingCalls: // request - defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) + case MethodTextDocumentDocumentHighlight: // request + defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) - var params CallHierarchyOutgoingCallsParams + var params DocumentHighlightParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CallHierarchyOutgoingCalls(ctx, ¶ms) + resp, err := server.DocumentHighlight(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCodeActionResolve: // request - defer logger.Debug(MethodCodeActionResolve, zap.Error(err)) + case MethodTextDocumentDocumentLink: // request + defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) - var params CodeAction + var params DocumentLinkParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeActionResolve(ctx, ¶ms) + resp, err := server.DocumentLink(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCodeLensResolve: // request - defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) + case MethodDocumentLinkResolve: // request + defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) - var params CodeLens + var params DocumentLink if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeLensResolve(ctx, ¶ms) + resp, err := server.DocumentLinkResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCompletionItemResolve: // request - defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) + case MethodTextDocumentDocumentSymbol: // request + defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) - var params CompletionItem + var params DocumentSymbolParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CompletionItemResolve(ctx, ¶ms) + resp, err := server.DocumentSymbol(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDocumentLinkResolve: // request - defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) + case MethodWorkspaceExecuteCommand: // request + defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) - var params DocumentLink + var params ExecuteCommandParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentLinkResolve(ctx, ¶ms) + resp, err := server.ExecuteCommand(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodInitialize: // request - defer logger.Debug(MethodInitialize, zap.Error(err)) + case MethodTextDocumentFoldingRange: // request + defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) - var params InitializeParams + var params FoldingRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Initialize(ctx, ¶ms) + resp, err := server.FoldingRanges(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodInlayHintResolve: // request - defer logger.Debug(MethodInlayHintResolve, zap.Error(err)) + case MethodTextDocumentFormatting: // request + defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) - var params InlayHint + var params DocumentFormattingParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.InlayHintResolve(ctx, ¶ms) + resp, err := server.Formatting(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodShutdown: // request - defer logger.Debug(MethodShutdown, zap.Error(err)) + case MethodTextDocumentHover: // request + defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + var params HoverParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) } - err := server.Shutdown(ctx) + resp, err := server.Hover(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentCodeAction: // request - defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) + case MethodTextDocumentImplementation: // request + defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) - var params CodeActionParams + var params ImplementationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentCodeAction(ctx, ¶ms) + resp, err := server.Implementation(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentCodeLens: // request - defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) + case MethodTextDocumentOnTypeFormatting: // request + defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) - var params CodeLensParams + var params DocumentOnTypeFormattingParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentCodeLens(ctx, ¶ms) + resp, err := server.OnTypeFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentColorPresentation: // request - defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) + case MethodTextDocumentPrepareRename: // request + defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) - var params ColorPresentationParams + var params PrepareRenameParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentColorPresentation(ctx, ¶ms) + resp, err := server.PrepareRename(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentCompletion: // request - defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) + case MethodTextDocumentRangeFormatting: // request + defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) - var params CompletionParams + var params DocumentRangeFormattingParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentCompletion(ctx, ¶ms) + resp, err := server.RangeFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDeclaration: // request - defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) + case MethodTextDocumentReferences: // request + defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) - var params DeclarationParams + var params ReferenceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDeclaration(ctx, ¶ms) + resp, err := server.References(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDefinition: // request - defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) + case MethodTextDocumentRename: // request + defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) - var params DefinitionParams + var params RenameParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDefinition(ctx, ¶ms) + resp, err := server.Rename(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDiagnostic: // request - defer logger.Debug(MethodTextDocumentDiagnostic, zap.Error(err)) + case MethodTextDocumentSignatureHelp: // request + defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) - var params DocumentDiagnosticParams + var params SignatureHelpParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDiagnostic(ctx, ¶ms) + resp, err := server.SignatureHelp(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentColor: // request - defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) + case MethodWorkspaceSymbol: // request + defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) - var params DocumentColorParams + var params WorkspaceSymbolParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentColor(ctx, ¶ms) + resp, err := server.Symbols(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentHighlight: // request - defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) + case MethodTextDocumentTypeDefinition: // request + defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) - var params DocumentHighlightParams + var params TypeDefinitionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentHighlight(ctx, ¶ms) + resp, err := server.TypeDefinition(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentLink: // request - defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) + case MethodTextDocumentWillSave: // notification + defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) - var params DocumentLinkParams + var params WillSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentLink(ctx, ¶ms) + err := server.WillSave(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDocumentSymbol: // request - defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) + case MethodTextDocumentWillSaveWaitUntil: // request + defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - var params DocumentSymbolParams + var params WillSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentSymbol(ctx, ¶ms) + resp, err := server.WillSaveWaitUntil(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFoldingRange: // request - defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) + case MethodShowDocument: // request + defer logger.Debug(MethodShowDocument, zap.Error(err)) - var params FoldingRangeParams + var params ShowDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentFoldingRange(ctx, ¶ms) + resp, err := server.ShowDocument(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFormatting: // request - defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) + case MethodWillCreateFiles: // request + defer logger.Debug(MethodWillCreateFiles, zap.Error(err)) - var params DocumentFormattingParams + var params CreateFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentFormatting(ctx, ¶ms) + resp, err := server.WillCreateFiles(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentHover: // request - defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) + case MethodDidCreateFiles: // notification + defer logger.Debug(MethodDidCreateFiles, zap.Error(err)) - var params HoverParams + var params CreateFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentHover(ctx, ¶ms) + err := server.DidCreateFiles(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentImplementation: // request - defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) + case MethodWillRenameFiles: // request + defer logger.Debug(MethodWillRenameFiles, zap.Error(err)) - var params ImplementationParams + var params RenameFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentImplementation(ctx, ¶ms) + resp, err := server.WillRenameFiles(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentInlayHint: // request - defer logger.Debug(MethodTextDocumentInlayHint, zap.Error(err)) + case MethodDidRenameFiles: // notification + defer logger.Debug(MethodDidRenameFiles, zap.Error(err)) - var params InlayHintParams + var params RenameFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentInlayHint(ctx, ¶ms) + err := server.DidRenameFiles(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentInlineCompletion: // request - defer logger.Debug(MethodTextDocumentInlineCompletion, zap.Error(err)) + case MethodWillDeleteFiles: // request + defer logger.Debug(MethodWillDeleteFiles, zap.Error(err)) - var params InlineCompletionParams + var params DeleteFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentInlineCompletion(ctx, ¶ms) + resp, err := server.WillDeleteFiles(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentInlineValue: // request - defer logger.Debug(MethodTextDocumentInlineValue, zap.Error(err)) + case MethodDidDeleteFiles: // notification + defer logger.Debug(MethodDidDeleteFiles, zap.Error(err)) - var params InlineValueParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentInlineValue(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentLinkedEditingRange: // request - defer logger.Debug(MethodTextDocumentLinkedEditingRange, zap.Error(err)) - - var params LinkedEditingRangeParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentLinkedEditingRange(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentMoniker: // request - defer logger.Debug(MethodTextDocumentMoniker, zap.Error(err)) - - var params MonikerParams + var params DeleteFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentMoniker(ctx, ¶ms) + err := server.DidDeleteFiles(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentOnTypeFormatting: // request - defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) + case MethodCodeLensRefresh: // request + defer logger.Debug(MethodCodeLensRefresh, zap.Error(err)) - var params DocumentOnTypeFormattingParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) } - resp, err := server.TextDocumentOnTypeFormatting(ctx, ¶ms) + err := server.CodeLensRefresh(ctx) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) case MethodTextDocumentPrepareCallHierarchy: // request defer logger.Debug(MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) @@ -671,271 +672,102 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentPrepareCallHierarchy(ctx, ¶ms) + resp, err := server.PrepareCallHierarchy(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentPrepareRename: // request - defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) - - var params PrepareRenameParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentPrepareRename(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentPrepareTypeHierarchy: // request - defer logger.Debug(MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) - - var params TypeHierarchyPrepareParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentPrepareTypeHierarchy(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentRangeFormatting: // request - defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) - - var params DocumentRangeFormattingParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentRangeFormatting(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentRangesFormatting: // request - defer logger.Debug(MethodTextDocumentRangesFormatting, zap.Error(err)) - - var params DocumentRangesFormattingParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentRangesFormatting(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentReferences: // request - defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) - - var params ReferenceParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentReferences(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentRename: // request - defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) + case MethodCallHierarchyIncomingCalls: // request + defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) - var params RenameParams + var params CallHierarchyIncomingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentRename(ctx, ¶ms) + resp, err := server.IncomingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSelectionRange: // request - defer logger.Debug(MethodTextDocumentSelectionRange, zap.Error(err)) + case MethodCallHierarchyOutgoingCalls: // request + defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) - var params SelectionRangeParams + var params CallHierarchyOutgoingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSelectionRange(ctx, ¶ms) + resp, err := server.OutgoingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSemanticTokensFull: // request - defer logger.Debug(MethodTextDocumentSemanticTokensFull, zap.Error(err)) + case MethodSemanticTokensFull: // request + defer logger.Debug(MethodSemanticTokensFull, zap.Error(err)) var params SemanticTokensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSemanticTokensFull(ctx, ¶ms) + resp, err := server.SemanticTokensFull(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSemanticTokensFullDelta: // request - defer logger.Debug(MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) + case MethodSemanticTokensFullDelta: // request + defer logger.Debug(MethodSemanticTokensFullDelta, zap.Error(err)) var params SemanticTokensDeltaParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSemanticTokensFullDelta(ctx, ¶ms) + resp, err := server.SemanticTokensFullDelta(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSemanticTokensRange: // request - defer logger.Debug(MethodTextDocumentSemanticTokensRange, zap.Error(err)) + case MethodSemanticTokensRange: // request + defer logger.Debug(MethodSemanticTokensRange, zap.Error(err)) var params SemanticTokensRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSemanticTokensRange(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentSignatureHelp: // request - defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) - - var params SignatureHelpParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentSignatureHelp(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentTypeDefinition: // request - defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) - - var params TypeDefinitionParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentTypeDefinition(ctx, ¶ms) + resp, err := server.SemanticTokensRange(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentWillSaveWaitUntil: // request - defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - - var params WillSaveTextDocumentParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TextDocumentWillSaveWaitUntil(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTypeHierarchySubtypes: // request - defer logger.Debug(MethodTypeHierarchySubtypes, zap.Error(err)) - - var params TypeHierarchySubtypesParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TypeHierarchySubtypes(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTypeHierarchySupertypes: // request - defer logger.Debug(MethodTypeHierarchySupertypes, zap.Error(err)) - - var params TypeHierarchySupertypesParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.TypeHierarchySupertypes(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWorkspaceDiagnostic: // request - defer logger.Debug(MethodWorkspaceDiagnostic, zap.Error(err)) - - var params WorkspaceDiagnosticParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.WorkspaceDiagnostic(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWorkspaceExecuteCommand: // request - defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) - - var params ExecuteCommandParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.WorkspaceExecuteCommand(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWorkspaceSymbol: // request - defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) - - var params WorkspaceSymbolParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.WorkspaceSymbol(ctx, ¶ms) - - return true, reply(ctx, resp, err) + case MethodSemanticTokensRefresh: // request + defer logger.Debug(MethodSemanticTokensRefresh, zap.Error(err)) - case MethodWorkspaceWillCreateFiles: // request - defer logger.Debug(MethodWorkspaceWillCreateFiles, zap.Error(err)) - - var params CreateFilesParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.WorkspaceWillCreateFiles(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodWorkspaceWillDeleteFiles: // request - defer logger.Debug(MethodWorkspaceWillDeleteFiles, zap.Error(err)) - - var params DeleteFilesParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) } - resp, err := server.WorkspaceWillDeleteFiles(ctx, ¶ms) + err := server.SemanticTokensRefresh(ctx) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodWorkspaceWillRenameFiles: // request - defer logger.Debug(MethodWorkspaceWillRenameFiles, zap.Error(err)) + case MethodLinkedEditingRange: // request + defer logger.Debug(MethodLinkedEditingRange, zap.Error(err)) - var params RenameFilesParams + var params LinkedEditingRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WorkspaceWillRenameFiles(ctx, ¶ms) + resp, err := server.LinkedEditingRange(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceSymbolResolve: // request - defer logger.Debug(MethodWorkspaceSymbolResolve, zap.Error(err)) + case MethodMoniker: // request + defer logger.Debug(MethodMoniker, zap.Error(err)) - var params WorkspaceSymbol + var params MonikerParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WorkspaceSymbolResolve(ctx, ¶ms) + resp, err := server.Moniker(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -944,317 +776,262 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, } } -// server implements a Language Server Protocol server. -type server struct { - jsonrpc2.Conn +// Server represents a Language Server Protocol server. +type Server interface { + Initialize(ctx context.Context, params *InitializeParams) (result *InitializeResult, err error) + Initialized(ctx context.Context, params *InitializedParams) (err error) + Shutdown(ctx context.Context) (err error) + Exit(ctx context.Context) (err error) + WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) + LogTrace(ctx context.Context, params *LogTraceParams) (err error) + SetTrace(ctx context.Context, params *SetTraceParams) (err error) + CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) + CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) + CodeLensResolve(ctx context.Context, params *CodeLens) (result *CodeLens, err error) + ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) + Completion(ctx context.Context, params *CompletionParams) (result *CompletionList, err error) + CompletionResolve(ctx context.Context, params *CompletionItem) (result *CompletionItem, err error) + Declaration(ctx context.Context, params *DeclarationParams) (result []Location /* Declaration | DeclarationLink[] | null */, err error) + Definition(ctx context.Context, params *DefinitionParams) (result []Location /* Definition | DefinitionLink[] | null */, err error) + DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) + DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) + DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) + DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) + DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) + DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) + DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) + DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) + DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) + DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) + DocumentLinkResolve(ctx context.Context, params *DocumentLink) (result *DocumentLink, err error) + DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{} /* []SymbolInformation | []DocumentSymbol */, err error) + ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) + FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) + Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) + Hover(ctx context.Context, params *HoverParams) (result *Hover, err error) + Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) + OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) + PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) + RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) + References(ctx context.Context, params *ReferenceParams) (result []Location, err error) + Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) + SignatureHelp(ctx context.Context, params *SignatureHelpParams) (result *SignatureHelp, err error) + Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) + TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) + WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) + WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) + ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) + WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) + DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) + WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) + DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) + WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) + DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) + CodeLensRefresh(ctx context.Context) (err error) + PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) + IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) + OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) + SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) + SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{} /* SemanticTokens | SemanticTokensDelta */, err error) + SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) + SemanticTokensRefresh(ctx context.Context) (err error) + LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) + Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) + Request(ctx context.Context, method string, params interface{}) (result interface{}, err error) +} + +// list of server methods. +const ( + // MethodCancelRequest method name of "$/cancelRequest". + MethodCancelRequest = "$/cancelRequest" + + // MethodInitialize method name of "initialize". + MethodInitialize = "initialize" + + // MethodInitialized method name of "initialized". + MethodInitialized = "initialized" + + // MethodShutdown method name of "shutdown". + MethodShutdown = "shutdown" + + // MethodExit method name of "exit". + MethodExit = "exit" + + // MethodWorkDoneProgressCancel method name of "window/workDoneProgress/cancel". + MethodWorkDoneProgressCancel = "window/workDoneProgress/cancel" + + // MethodLogTrace method name of "$/logTrace". + MethodLogTrace = "$/logTrace" + + // MethodSetTrace method name of "$/setTrace". + MethodSetTrace = "$/setTrace" + + // MethodTextDocumentCodeAction method name of "textDocument/codeAction". + MethodTextDocumentCodeAction = "textDocument/codeAction" + + // MethodTextDocumentCodeLens method name of "textDocument/codeLens". + MethodTextDocumentCodeLens = "textDocument/codeLens" + + // MethodCodeLensResolve method name of "codeLens/resolve". + MethodCodeLensResolve = "codeLens/resolve" + + // MethodTextDocumentColorPresentation method name of "textDocument/colorPresentation". + MethodTextDocumentColorPresentation = "textDocument/colorPresentation" + + // MethodTextDocumentCompletion method name of "textDocument/completion". + MethodTextDocumentCompletion = "textDocument/completion" + + // MethodCompletionItemResolve method name of "completionItem/resolve". + MethodCompletionItemResolve = "completionItem/resolve" + + // MethodTextDocumentDeclaration method name of "textDocument/declaration". + MethodTextDocumentDeclaration = "textDocument/declaration" - logger *zap.Logger -} + // MethodTextDocumentDefinition method name of "textDocument/definition". + MethodTextDocumentDefinition = "textDocument/definition" -var _ Server = (*server)(nil) + // MethodTextDocumentDidChange method name of "textDocument/didChange". + MethodTextDocumentDidChange = "textDocument/didChange" -func (s *server) CancelRequest(ctx context.Context, params *CancelParams) (err error) { - s.logger.Debug("notify " + MethodClientCancelRequest) - defer s.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) + // MethodWorkspaceDidChangeConfiguration method name of "workspace/didChangeConfiguration". + MethodWorkspaceDidChangeConfiguration = "workspace/didChangeConfiguration" - return s.Conn.Notify(ctx, MethodClientCancelRequest, params) -} + // MethodWorkspaceDidChangeWatchedFiles method name of "workspace/didChangeWatchedFiles". + MethodWorkspaceDidChangeWatchedFiles = "workspace/didChangeWatchedFiles" -// Progress is the base protocol offers also support to report progress in a generic fashion. -// -// This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and -// partial result progress to support streaming of results. -// -// @since 3.16.0. -func (s *server) Progress(ctx context.Context, params *ProgressParams) (err error) { - s.logger.Debug("notify " + MethodClientProgress) - defer s.logger.Debug("end "+MethodClientProgress, zap.Error(err)) + // MethodWorkspaceDidChangeWorkspaceFolders method name of "workspace/didChangeWorkspaceFolders". + MethodWorkspaceDidChangeWorkspaceFolders = "workspace/didChangeWorkspaceFolders" - return s.Conn.Notify(ctx, MethodClientProgress, params) -} + // MethodTextDocumentDidClose method name of "textDocument/didClose". + MethodTextDocumentDidClose = "textDocument/didClose" -// SetTrace a notification that should be used by the client to modify the trace setting of the server. -// -// @since 3.16.0. -func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { - s.logger.Debug("notify " + MethodSetTrace) - defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) + // MethodTextDocumentDidOpen method name of "textDocument/didOpen". + MethodTextDocumentDidOpen = "textDocument/didOpen" - return s.Conn.Notify(ctx, MethodSetTrace, params) -} + // MethodTextDocumentDidSave method name of "textDocument/didSave". + MethodTextDocumentDidSave = "textDocument/didSave" -// Exit a notification to ask the server to exit its process. -// -// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. -func (s *server) Exit(ctx context.Context) (err error) { - s.logger.Debug("notify " + MethodExit) - defer s.logger.Debug("end "+MethodExit, zap.Error(err)) + // MethodTextDocumentDocumentColor method name of"textDocument/documentColor". + MethodTextDocumentDocumentColor = "textDocument/documentColor" - return s.Conn.Notify(ctx, MethodExit, nil) -} + // MethodTextDocumentDocumentHighlight method name of "textDocument/documentHighlight". + MethodTextDocumentDocumentHighlight = "textDocument/documentHighlight" -// Initialized sends the notification from the client to the server after the client received the result of the -// initialize request but before the client is sending any other request or notification to the server. -// -// The server can use the initialized notification for example to dynamically register capabilities. -// The initialized notification may only be sent once. -func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { - s.logger.Debug("notify " + MethodInitialized) - defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) + // MethodTextDocumentDocumentLink method name of "textDocument/documentLink". + MethodTextDocumentDocumentLink = "textDocument/documentLink" - return s.Conn.Notify(ctx, MethodInitialized, params) -} + // MethodDocumentLinkResolve method name of "documentLink/resolve". + MethodDocumentLinkResolve = "documentLink/resolve" -func (s *server) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) (err error) { - s.logger.Debug("call " + MethodNotebookDocumentDidChange) - defer s.logger.Debug("end "+MethodNotebookDocumentDidChange, zap.Error(err)) + // MethodTextDocumentDocumentSymbol method name of "textDocument/documentSymbol". + MethodTextDocumentDocumentSymbol = "textDocument/documentSymbol" - return s.Conn.Notify(ctx, MethodNotebookDocumentDidChange, params) -} + // MethodWorkspaceExecuteCommand method name of "workspace/executeCommand". + MethodWorkspaceExecuteCommand = "workspace/executeCommand" -// NotebookDocumentDidClose a notification sent when a notebook closes. -// -// @since 3.17.0 -func (s *server) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) (err error) { - s.logger.Debug("call " + MethodNotebookDocumentDidClose) - defer s.logger.Debug("end "+MethodNotebookDocumentDidClose, zap.Error(err)) + // MethodTextDocumentFoldingRange method name of "textDocument/foldingRange". + MethodTextDocumentFoldingRange = "textDocument/foldingRange" - return s.Conn.Notify(ctx, MethodNotebookDocumentDidClose, params) -} + // MethodTextDocumentFormatting method name of "textDocument/formatting". + MethodTextDocumentFormatting = "textDocument/formatting" -// NotebookDocumentDidOpen a notification sent when a notebook opens. -// -// @since 3.17.0 -func (s *server) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) (err error) { - s.logger.Debug("call " + MethodNotebookDocumentDidOpen) - defer s.logger.Debug("end "+MethodNotebookDocumentDidOpen, zap.Error(err)) + // MethodTextDocumentHover method name of "textDocument/hover". + MethodTextDocumentHover = "textDocument/hover" - return s.Conn.Notify(ctx, MethodNotebookDocumentDidOpen, params) -} + // MethodTextDocumentImplementation method name of "textDocument/implementation". + MethodTextDocumentImplementation = "textDocument/implementation" -// NotebookDocumentDidSave a notification sent when a notebook document is saved. -// -// @since 3.17.0 -func (s *server) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) (err error) { - s.logger.Debug("call " + MethodNotebookDocumentDidSave) - defer s.logger.Debug("end "+MethodNotebookDocumentDidSave, zap.Error(err)) + // MethodTextDocumentOnTypeFormatting method name of "textDocument/onTypeFormatting". + MethodTextDocumentOnTypeFormatting = "textDocument/onTypeFormatting" - return s.Conn.Notify(ctx, MethodNotebookDocumentDidSave, params) -} + // MethodTextDocumentPrepareRename method name of "textDocument/prepareRename". + MethodTextDocumentPrepareRename = "textDocument/prepareRename" -// DidChange sends the notification from the client to the server to signal changes to a text document. -// -// In 2.0 the shape of the params has changed to include proper version numbers and language ids. -func (s *server) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { - s.logger.Debug("notify " + MethodTextDocumentDidChange) - defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) + // MethodTextDocumentRangeFormatting method name of "textDocument/rangeFormatting". + MethodTextDocumentRangeFormatting = "textDocument/rangeFormatting" - return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) -} + // MethodTextDocumentReferences method name of "textDocument/references". + MethodTextDocumentReferences = "textDocument/references" -// DidClose sends the notification from the client to the server when the document got closed in the client. -// -// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). -// As with the open notification the close notification is about managing the document’s content. -// Receiving a close notification doesn’t mean that the document was open in an editor before. -// -// A close notification requires a previous open notification to be sent. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidClose) - defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) + // MethodTextDocumentRename method name of "textDocument/rename". + MethodTextDocumentRename = "textDocument/rename" - return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) -} + // MethodTextDocumentSignatureHelp method name of "textDocument/signatureHelp". + MethodTextDocumentSignatureHelp = "textDocument/signatureHelp" -// DidOpen sends the open notification from the client to the server to signal newly opened text documents. -// -// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. -// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. -// -// An open notification must not be sent more than once without a corresponding close notification send before. -// This means open and close notification must be balanced and the max open count for a particular textDocument is one. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidOpen) - defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) -} - -// DidSave sends the notification from the client to the server when the document was saved in the client. -func (s *server) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidSave) - defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) -} - -// WillSave sends the notification from the client to the server before the document is actually saved. -func (s *server) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentWillSave) - defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) -} - -// WindowWorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the -// server side using the "window/workDoneProgress/create". -func (s *server) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { - s.logger.Debug("call " + MethodWindowWorkDoneProgressCancel) - defer s.logger.Debug("end "+MethodWindowWorkDoneProgressCancel, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWindowWorkDoneProgressCancel, params) -} - -// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. -func (s *server) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) -} - -// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. -// -// It is recommended that servers register for these file events using the registration mechanism. -// In former implementations clients pushed file events without the server actively asking for it. -func (s *server) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) + // MethodWorkspaceSymbol method name of "workspace/symbol". + MethodWorkspaceSymbol = "workspace/symbol" - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) -} + // MethodTextDocumentTypeDefinition method name of "textDocument/typeDefinition". + MethodTextDocumentTypeDefinition = "textDocument/typeDefinition" -// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. -// -// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; -// or if the server has registered itself to receive this notification. -// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. -// -// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). -func (s *server) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) + // MethodTextDocumentWillSave method name of "textDocument/willSave". + MethodTextDocumentWillSave = "textDocument/willSave" - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) -} + // MethodTextDocumentWillSaveWaitUntil method name of "textDocument/willSaveWaitUntil". + MethodTextDocumentWillSaveWaitUntil = "textDocument/willSaveWaitUntil" -// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. -// -// @since 3.16.0. -func (s *server) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidCreateFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidCreateFiles, zap.Error(err)) + // MethodShowDocument method name of "window/showDocument". + MethodShowDocument = "window/showDocument" - return s.Conn.Notify(ctx, MethodWorkspaceDidCreateFiles, params) -} - -// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. -// -// @since 3.16.0. -func (s *server) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidDeleteFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidDeleteFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidDeleteFiles, params) -} - -// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. -// -// @since 3.16.0. -func (s *server) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidRenameFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidRenameFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidRenameFiles, params) -} - -// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -func (s *server) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (_ []*CallHierarchyIncomingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) + // MethodWillCreateFiles method name of "workspace/willCreateFiles". + MethodWillCreateFiles = "workspace/willCreateFiles" - var result []*CallHierarchyIncomingCall - if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { - return nil, err - } + // MethodDidCreateFiles method name of "workspace/didCreateFiles". + MethodDidCreateFiles = "workspace/didCreateFiles" - return result, nil -} + // MethodWillRenameFiles method name of "workspace/willRenameFiles". + MethodWillRenameFiles = "workspace/willRenameFiles" -// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -func (s *server) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (_ []*CallHierarchyOutgoingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) + // MethodDidRenameFiles method name of "workspace/didRenameFiles". + MethodDidRenameFiles = "workspace/didRenameFiles" - var result []*CallHierarchyOutgoingCall - if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { - return nil, err - } + // MethodWillDeleteFiles method name of "workspace/willDeleteFiles". + MethodWillDeleteFiles = "workspace/willDeleteFiles" - return result, nil -} + // MethodDidDeleteFiles method name of "workspace/didDeleteFiles". + MethodDidDeleteFiles = "workspace/didDeleteFiles" -func (s *server) CodeActionResolve(ctx context.Context, params *CodeAction) (_ *CodeAction, err error) { - s.logger.Debug("call " + MethodCodeActionResolve) - defer s.logger.Debug("end "+MethodCodeActionResolve, zap.Error(err)) + // MethodCodeLensRefresh method name of "workspace/codeLens/refresh". + MethodCodeLensRefresh = "workspace/codeLens/refresh" - var result *CodeAction - if err := Call(ctx, s.Conn, MethodCodeActionResolve, params, &result); err != nil { - return nil, err - } + // MethodTextDocumentPrepareCallHierarchy method name of "textDocument/prepareCallHierarchy". + MethodTextDocumentPrepareCallHierarchy = "textDocument/prepareCallHierarchy" - return result, nil -} + // MethodCallHierarchyIncomingCalls method name of "callHierarchy/incomingCalls". + MethodCallHierarchyIncomingCalls = "callHierarchy/incomingCalls" -// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. -func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { - s.logger.Debug("call " + MethodCodeLensResolve) - defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) + // MethodCallHierarchyOutgoingCalls method name of "callHierarchy/outgoingCalls". + MethodCallHierarchyOutgoingCalls = "callHierarchy/outgoingCalls" - var result *CodeLens - if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { - return nil, err - } + // MethodSemanticTokensFull method name of "textDocument/semanticTokens/full". + MethodSemanticTokensFull = "textDocument/semanticTokens/full" - return result, nil -} + // MethodSemanticTokensFullDelta method name of "textDocument/semanticTokens/full/delta". + MethodSemanticTokensFullDelta = "textDocument/semanticTokens/full/delta" -// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. -func (s *server) CompletionItemResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { - s.logger.Debug("call " + MethodCompletionItemResolve) - defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) + // MethodSemanticTokensRange method name of "textDocument/semanticTokens/range". + MethodSemanticTokensRange = "textDocument/semanticTokens/range" - var result *CompletionItem - if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { - return nil, err - } + // MethodSemanticTokensRefresh method name of "workspace/semanticTokens/refresh". + MethodSemanticTokensRefresh = "workspace/semanticTokens/refresh" - return result, nil -} + // MethodLinkedEditingRange method name of "textDocument/linkedEditingRange". + MethodLinkedEditingRange = "textDocument/linkedEditingRange" -// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. -func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { - s.logger.Debug("call " + MethodDocumentLinkResolve) - defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) + // MethodMoniker method name of "textDocument/moniker". + MethodMoniker = "textDocument/moniker" +) - var result *DocumentLink - if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { - return nil, err - } +// server implements a Language Server Protocol server. +type server struct { + jsonrpc2.Conn - return result, nil + logger *zap.Logger } +var _ Server = (*server)(nil) + // Initialize sents the request as the first request from the client to the server. // // If the server receives a request or notification before the initialize request it should act as follows: @@ -1280,16 +1057,16 @@ func (s *server) Initialize(ctx context.Context, params *InitializeParams) (_ *I return result, nil } -func (s *server) InlayHintResolve(ctx context.Context, params *InlayHint) (_ *InlayHint, err error) { - s.logger.Debug("call " + MethodInlayHintResolve) - defer s.logger.Debug("end "+MethodInlayHintResolve, zap.Error(err)) - - var result *InlayHint - if err := Call(ctx, s.Conn, MethodInlayHintResolve, params, &result); err != nil { - return nil, err - } +// Initialized sends the notification from the client to the server after the client received the result of the +// initialize request but before the client is sending any other request or notification to the server. +// +// The server can use the initialized notification for example to dynamically register capabilities. +// The initialized notification may only be sent once. +func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { + s.logger.Debug("notify " + MethodInitialized) + defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) - return result, nil + return s.Conn.Notify(ctx, MethodInitialized, params) } // Shutdown sents the request from the client to the server. @@ -1306,6 +1083,50 @@ func (s *server) Shutdown(ctx context.Context) (err error) { return Call(ctx, s.Conn, MethodShutdown, nil, nil) } +// Exit a notification to ask the server to exit its process. +// +// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. +func (s *server) Exit(ctx context.Context) (err error) { + s.logger.Debug("notify " + MethodExit) + defer s.logger.Debug("end "+MethodExit, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodExit, nil) +} + +// LogTrace a notification to log the trace of the server’s execution. +// +// The amount and content of these notifications depends on the current trace configuration. +// +// If trace is "off", the server should not send any logTrace notification. If trace is "message", +// the server should not add the "verbose" field in the LogTraceParams. +// +// @since 3.16.0. +func (s *server) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { + s.logger.Debug("notify " + MethodLogTrace) + defer s.logger.Debug("end "+MethodLogTrace, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodLogTrace, params) +} + +// SetTrace a notification that should be used by the client to modify the trace setting of the server. +// +// @since 3.16.0. +func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { + s.logger.Debug("notify " + MethodSetTrace) + defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodSetTrace, params) +} + +// WorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the +// server side using the "window/workDoneProgress/create". +func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { + s.logger.Debug("call " + MethodWorkDoneProgressCancel) + defer s.logger.Debug("end "+MethodWorkDoneProgressCancel, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkDoneProgressCancel, params) +} + // CodeAction sends the request is from the client to the server to compute commands for a given text document and range. // // These commands are typically code fixes to either fix problems or to beautify/refactor code. The result of a `textDocument/codeAction` @@ -1314,11 +1135,10 @@ func (s *server) Shutdown(ctx context.Context) (err error) { // To ensure that a server is useful in many clients the commands specified in a code actions should be handled by the // server and not by the client (see `workspace/executeCommand` and `ServerCapabilities.executeCommandProvider`). // If the client supports providing edits with a code action then the mode should be used. -func (s *server) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (_ *TextDocumentCodeActionResult, err error) { +func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) { s.logger.Debug("call " + MethodTextDocumentCodeAction) defer s.logger.Debug("end "+MethodTextDocumentCodeAction, zap.Error(err)) - var result *TextDocumentCodeActionResult if err := Call(ctx, s.Conn, MethodTextDocumentCodeAction, params, &result); err != nil { return nil, err } @@ -1327,11 +1147,10 @@ func (s *server) TextDocumentCodeAction(ctx context.Context, params *CodeActionP } // CodeLens sends the request from the client to the server to compute code lenses for a given text document. -func (s *server) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) (_ []*CodeLens, err error) { +func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) { s.logger.Debug("call " + MethodTextDocumentCodeLens) defer s.logger.Debug("end "+MethodTextDocumentCodeLens, zap.Error(err)) - var result []*CodeLens if err := Call(ctx, s.Conn, MethodTextDocumentCodeLens, params, &result); err != nil { return nil, err } @@ -1339,17 +1158,29 @@ func (s *server) TextDocumentCodeLens(ctx context.Context, params *CodeLensParam return result, nil } +// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. +func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { + s.logger.Debug("call " + MethodCodeLensResolve) + defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) + + var result *CodeLens + if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + // ColorPresentation sends the request from the client to the server to obtain a list of presentations for a color value at a given location. // // # Clients can use the result to // // - modify a color reference. // - show in a color picker and let users pick one of the presentations. -func (s *server) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) (_ []*ColorPresentation, err error) { +func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) { s.logger.Debug("call " + MethodTextDocumentColorPresentation) defer s.logger.Debug("end "+MethodTextDocumentColorPresentation, zap.Error(err)) - var result []*ColorPresentation if err := Call(ctx, s.Conn, MethodTextDocumentColorPresentation, params, &result); err != nil { return nil, err } @@ -1370,11 +1201,11 @@ func (s *server) TextDocumentColorPresentation(ctx context.Context, params *Colo // The returned completion item should have the documentation property filled in. The request can delay the computation of // the `detail` and `documentation` properties. However, properties that are needed for the initial sorting and filtering, // like `sortText`, `filterText`, `insertText`, and `textEdit` must be provided in the `textDocument/completion` response and must not be changed during resolve. -func (s *server) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (_ *TextDocumentCompletionResult, err error) { +func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *CompletionList, err error) { s.logger.Debug("call " + MethodTextDocumentCompletion) defer s.logger.Debug("end "+MethodTextDocumentCompletion, zap.Error(err)) - var result *TextDocumentCompletionResult + var result *CompletionList if err := Call(ctx, s.Conn, MethodTextDocumentCompletion, params, &result); err != nil { return nil, err } @@ -1382,16 +1213,28 @@ func (s *server) TextDocumentCompletion(ctx context.Context, params *CompletionP return result, nil } +// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. +func (s *server) CompletionResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { + s.logger.Debug("call " + MethodCompletionItemResolve) + defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) + + var result *CompletionItem + if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { + return nil, err + } + + return result, nil +} + // Declaration sends the request from the client to the server to resolve the declaration location of a symbol at a given text document position. // // The result type LocationLink[] got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.declaration.linkSupport`. // // @since 3.14.0. -func (s *server) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (_ *TextDocumentDeclarationResult, err error) { +func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (result []Location, err error) { s.logger.Debug("call " + MethodTextDocumentDeclaration) defer s.logger.Debug("end "+MethodTextDocumentDeclaration, zap.Error(err)) - var result *TextDocumentDeclarationResult if err := Call(ctx, s.Conn, MethodTextDocumentDeclaration, params, &result); err != nil { return nil, err } @@ -1404,11 +1247,10 @@ func (s *server) TextDocumentDeclaration(ctx context.Context, params *Declaratio // The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.definition.linkSupport`. // // @since 3.14.0. -func (s *server) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (_ *TextDocumentDefinitionResult, err error) { +func (s *server) Definition(ctx context.Context, params *DefinitionParams) (result []Location, err error) { s.logger.Debug("call " + MethodTextDocumentDefinition) defer s.logger.Debug("end "+MethodTextDocumentDefinition, zap.Error(err)) - var result *TextDocumentDefinitionResult if err := Call(ctx, s.Conn, MethodTextDocumentDefinition, params, &result); err != nil { return nil, err } @@ -1416,16 +1258,85 @@ func (s *server) TextDocumentDefinition(ctx context.Context, params *DefinitionP return result, nil } -func (s *server) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (_ *DocumentDiagnosticReport, err error) { - s.logger.Debug("call " + MethodTextDocumentDiagnostic) - defer s.logger.Debug("end "+MethodTextDocumentDiagnostic, zap.Error(err)) +// DidChange sends the notification from the client to the server to signal changes to a text document. +// +// In 2.0 the shape of the params has changed to include proper version numbers and language ids. +func (s *server) DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { + s.logger.Debug("notify " + MethodTextDocumentDidChange) + defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) +} + +// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. +func (s *server) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) - var result *DocumentDiagnosticReport - if err := Call(ctx, s.Conn, MethodTextDocumentDiagnostic, params, &result); err != nil { - return nil, err - } + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) +} - return result, nil +// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. +// +// It is recommended that servers register for these file events using the registration mechanism. +// In former implementations clients pushed file events without the server actively asking for it. +func (s *server) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) +} + +// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. +// +// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; +// or if the server has registered itself to receive this notification. +// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. +// +// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). +func (s *server) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) +} + +// DidClose sends the notification from the client to the server when the document got closed in the client. +// +// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). +// As with the open notification the close notification is about managing the document’s content. +// Receiving a close notification doesn’t mean that the document was open in an editor before. +// +// A close notification requires a previous open notification to be sent. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidClose) + defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) +} + +// DidOpen sends the open notification from the client to the server to signal newly opened text documents. +// +// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. +// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. +// +// An open notification must not be sent more than once without a corresponding close notification send before. +// This means open and close notification must be balanced and the max open count for a particular textDocument is one. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidOpen) + defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) +} + +// DidSave sends the notification from the client to the server when the document was saved in the client. +func (s *server) DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidSave) + defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) } // DocumentColor sends the request from the client to the server to list all color references found in a given text document. @@ -1437,11 +1348,10 @@ func (s *server) TextDocumentDiagnostic(ctx context.Context, params *DocumentDia // // - Color boxes showing the actual color next to the reference // - Show a color picker when a color reference is edited. -func (s *server) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) (_ []*ColorInformation, err error) { +func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentColor) defer s.logger.Debug("end "+MethodTextDocumentDocumentColor, zap.Error(err)) - var result []*ColorInformation if err := Call(ctx, s.Conn, MethodTextDocumentDocumentColor, params, &result); err != nil { return nil, err } @@ -1455,11 +1365,10 @@ func (s *server) TextDocumentDocumentColor(ctx context.Context, params *Document // However we kept ‘textDocument/documentHighlight’ and ‘textDocument/references’ separate requests since the first one is allowed to be more fuzzy. // // Symbol matches usually have a `DocumentHighlightKind` of `Read` or `Write` whereas fuzzy or textual matches use `Text` as the kind. -func (s *server) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (_ []*DocumentHighlight, err error) { +func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentHighlight) defer s.logger.Debug("end "+MethodTextDocumentDocumentHighlight, zap.Error(err)) - var result []*DocumentHighlight if err := Call(ctx, s.Conn, MethodTextDocumentDocumentHighlight, params, &result); err != nil { return nil, err } @@ -1468,11 +1377,10 @@ func (s *server) TextDocumentDocumentHighlight(ctx context.Context, params *Docu } // DocumentLink sends the request from the client to the server to request the location of links in a document. -func (s *server) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) (_ []*DocumentLink, err error) { +func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentLink) defer s.logger.Debug("end "+MethodTextDocumentDocumentLink, zap.Error(err)) - var result []*DocumentLink if err := Call(ctx, s.Conn, MethodTextDocumentDocumentLink, params, &result); err != nil { return nil, err } @@ -1480,145 +1388,95 @@ func (s *server) TextDocumentDocumentLink(ctx context.Context, params *DocumentL return result, nil } -// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. -// -// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. -func (s *server) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (_ *TextDocumentDocumentSymbolResult, err error) { - s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) - defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) +// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. +func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { + s.logger.Debug("call " + MethodDocumentLinkResolve) + defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) - var result *TextDocumentDocumentSymbolResult - if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { + var result *DocumentLink + if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { return nil, err } return result, nil } -// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. +// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. // -// @since version 3.10.0. -func (s *server) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) (_ []*FoldingRange, err error) { - s.logger.Debug("call " + MethodTextDocumentFoldingRange) - defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) - - var result []*FoldingRange - if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// Formatting sends the request from the client to the server to format a whole document. -func (s *server) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) (_ []*TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentFormatting) - defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) - - var result []*TextEdit - if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// Hover sends the request is from the client to the server to request hover information at a given text document position. -func (s *server) TextDocumentHover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { - s.logger.Debug("call " + MethodTextDocumentHover) - defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) +// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. +func (s *server) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{}, err error) { + s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) + defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) - var result *Hover - if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { return nil, err } return result, nil } -// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. +// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. // -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. -func (s *server) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (_ *TextDocumentImplementationResult, err error) { - s.logger.Debug("call " + MethodTextDocumentImplementation) - defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) - - var result *TextDocumentImplementationResult - if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -func (s *server) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) (_ []*InlayHint, err error) { - s.logger.Debug("call " + MethodTextDocumentInlayHint) - defer s.logger.Debug("end "+MethodTextDocumentInlayHint, zap.Error(err)) +// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the +// request `workspace/applyEdit` which is sent from the server to the client. +func (s *server) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) { + s.logger.Debug("call " + MethodWorkspaceExecuteCommand) + defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) - var result []*InlayHint - if err := Call(ctx, s.Conn, MethodTextDocumentInlayHint, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (_ *TextDocumentInlineCompletionResult, err error) { - s.logger.Debug("call " + MethodTextDocumentInlineCompletion) - defer s.logger.Debug("end "+MethodTextDocumentInlineCompletion, zap.Error(err)) +// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. +// +// @since version 3.10.0. +func (s *server) FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) { + s.logger.Debug("call " + MethodTextDocumentFoldingRange) + defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) - var result *TextDocumentInlineCompletionResult - if err := Call(ctx, s.Conn, MethodTextDocumentInlineCompletion, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) (_ []*InlineValue, err error) { - s.logger.Debug("call " + MethodTextDocumentInlineValue) - defer s.logger.Debug("end "+MethodTextDocumentInlineValue, zap.Error(err)) +// Formatting sends the request from the client to the server to format a whole document. +func (s *server) Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentFormatting) + defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) - var result []*InlineValue - if err := Call(ctx, s.Conn, MethodTextDocumentInlineValue, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { return nil, err } return result, nil } -// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. -// -// Optionally a word pattern can be returned to describe valid contents. -// -// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. -// -// @since 3.16.0. -func (s *server) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (_ *LinkedEditingRanges, err error) { - s.logger.Debug("call " + MethodTextDocumentLinkedEditingRange) - defer s.logger.Debug("end "+MethodTextDocumentLinkedEditingRange, zap.Error(err)) +// Hover sends the request is from the client to the server to request hover information at a given text document position. +func (s *server) Hover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { + s.logger.Debug("call " + MethodTextDocumentHover) + defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) - var result *LinkedEditingRanges - if err := Call(ctx, s.Conn, MethodTextDocumentLinkedEditingRange, params, &result); err != nil { + var result *Hover + if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { return nil, err } return result, nil } -// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. -// -// An array of Moniker types is returned as response to indicate possible monikers at the given location. -// -// If no monikers can be calculated, an empty array or null should be returned. +// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. // -// @since 3.16.0. -func (s *server) TextDocumentMoniker(ctx context.Context, params *MonikerParams) (_ []*Moniker, err error) { - s.logger.Debug("call " + MethodTextDocumentMoniker) - defer s.logger.Debug("end "+MethodTextDocumentMoniker, zap.Error(err)) +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. +func (s *server) Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) { + s.logger.Debug("call " + MethodTextDocumentImplementation) + defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) - var result []*Moniker - if err := Call(ctx, s.Conn, MethodTextDocumentMoniker, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { return nil, err } @@ -1626,11 +1484,10 @@ func (s *server) TextDocumentMoniker(ctx context.Context, params *MonikerParams) } // OnTypeFormatting sends the request from the client to the server to format parts of the document during typing. -func (s *server) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (_ []*TextEdit, err error) { +func (s *server) OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentOnTypeFormatting) defer s.logger.Debug("end "+MethodTextDocumentOnTypeFormatting, zap.Error(err)) - var result []*TextEdit if err := Call(ctx, s.Conn, MethodTextDocumentOnTypeFormatting, params, &result); err != nil { return nil, err } @@ -1638,33 +1495,13 @@ func (s *server) TextDocumentOnTypeFormatting(ctx context.Context, params *Docum return result, nil } -// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. -// -// The call hierarchy requests are executed in two steps: -// 1. first a call hierarchy item is resolved for the given text document position -// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. -// -// @since 3.16.0. -func (s *server) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (_ []*CallHierarchyItem, err error) { - s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) - defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) - - var result []*CallHierarchyItem - if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // PrepareRename sends the request from the client to the server to setup and test the validity of a rename operation at a given location. // // @since version 3.12.0. -func (s *server) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (_ *PrepareRenameResult, err error) { +func (s *server) PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) { s.logger.Debug("call " + MethodTextDocumentPrepareRename) defer s.logger.Debug("end "+MethodTextDocumentPrepareRename, zap.Error(err)) - var result *PrepareRenameResult if err := Call(ctx, s.Conn, MethodTextDocumentPrepareRename, params, &result); err != nil { return nil, err } @@ -1672,24 +1509,11 @@ func (s *server) TextDocumentPrepareRename(ctx context.Context, params *PrepareR return result, nil } -func (s *server) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) (_ []*TypeHierarchyItem, err error) { - s.logger.Debug("call " + MethodTextDocumentPrepareTypeHierarchy) - defer s.logger.Debug("end "+MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) - - var result []*TypeHierarchyItem - if err := Call(ctx, s.Conn, MethodTextDocumentPrepareTypeHierarchy, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // RangeFormatting sends the request from the client to the server to format a given range in a document. -func (s *server) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (_ []*TextEdit, err error) { +func (s *server) RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentRangeFormatting) defer s.logger.Debug("end "+MethodTextDocumentRangeFormatting, zap.Error(err)) - var result []*TextEdit if err := Call(ctx, s.Conn, MethodTextDocumentRangeFormatting, params, &result); err != nil { return nil, err } @@ -1697,24 +1521,11 @@ func (s *server) TextDocumentRangeFormatting(ctx context.Context, params *Docume return result, nil } -func (s *server) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) (_ []*TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentRangesFormatting) - defer s.logger.Debug("end "+MethodTextDocumentRangesFormatting, zap.Error(err)) - - var result []*TextEdit - if err := Call(ctx, s.Conn, MethodTextDocumentRangesFormatting, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // References sends the request from the client to the server to resolve project-wide references for the symbol denoted by the given text document position. -func (s *server) TextDocumentReferences(ctx context.Context, params *ReferenceParams) (_ []*Location, err error) { +func (s *server) References(ctx context.Context, params *ReferenceParams) (result []Location, err error) { s.logger.Debug("call " + MethodTextDocumentReferences) defer s.logger.Debug("end "+MethodTextDocumentReferences, zap.Error(err)) - var result []*Location if err := Call(ctx, s.Conn, MethodTextDocumentReferences, params, &result); err != nil { return nil, err } @@ -1723,11 +1534,10 @@ func (s *server) TextDocumentReferences(ctx context.Context, params *ReferencePa } // Rename sends the request from the client to the server to perform a workspace-wide rename of a symbol. -func (s *server) TextDocumentRename(ctx context.Context, params *RenameParams) (_ *WorkspaceEdit, err error) { +func (s *server) Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) { s.logger.Debug("call " + MethodTextDocumentRename) defer s.logger.Debug("end "+MethodTextDocumentRename, zap.Error(err)) - var result *WorkspaceEdit if err := Call(ctx, s.Conn, MethodTextDocumentRename, params, &result); err != nil { return nil, err } @@ -1735,250 +1545,335 @@ func (s *server) TextDocumentRename(ctx context.Context, params *RenameParams) ( return result, nil } -func (s *server) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) (_ []*SelectionRange, err error) { - s.logger.Debug("call " + MethodTextDocumentSelectionRange) - defer s.logger.Debug("end "+MethodTextDocumentSelectionRange, zap.Error(err)) +// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. +func (s *server) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { + s.logger.Debug("call " + MethodTextDocumentSignatureHelp) + defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) - var result []*SelectionRange - if err := Call(ctx, s.Conn, MethodTextDocumentSelectionRange, params, &result); err != nil { + var result *SignatureHelp + if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. -// -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. -// -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. -// -// @since 3.16.0. -func (s *server) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (_ *SemanticTokens, err error) { - s.logger.Debug("call " + MethodTextDocumentSemanticTokensFull) - defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFull, zap.Error(err)) +// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. +func (s *server) Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbol) + defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) - var result *SemanticTokens - if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFull, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. -// -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. // -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. // -// @since 3.16.0. -func (s *server) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (_ *TextDocumentSemanticTokensFullDeltaResult, err error) { - s.logger.Debug("call " + MethodTextDocumentSemanticTokensFullDelta) - defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) +// @since version 3.6.0. +func (s *server) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) { + s.logger.Debug("call " + MethodTextDocumentTypeDefinition) + defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) - var result *TextDocumentSemanticTokensFullDeltaResult - if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFullDelta, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. -// -// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). -// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. -// -// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. +// WillSave sends the notification from the client to the server before the document is actually saved. +func (s *server) WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentWillSave) + defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) +} + +// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. // -// @since 3.16.0. -func (s *server) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (_ *SemanticTokens, err error) { - s.logger.Debug("call " + MethodTextDocumentSemanticTokensRange) - defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensRange, zap.Error(err)) +// The request can return an array of TextEdits which will be applied to the text document before it is saved. +// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. +// This is done to keep the save fast and reliable. +func (s *server) WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) + defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - var result *SemanticTokens - if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensRange, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { return nil, err } return result, nil } -// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. -func (s *server) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { - s.logger.Debug("call " + MethodTextDocumentSignatureHelp) - defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) +// ShowDocument sends the request from a server to a client to ask the client to display a particular document in the user interface. +// +// @since 3.16.0. +func (s *server) ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) { + s.logger.Debug("call " + MethodShowDocument) + defer s.logger.Debug("end "+MethodShowDocument, zap.Error(err)) - var result *SignatureHelp - if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodShowDocument, params, &result); err != nil { return nil, err } return result, nil } -// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. +// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. // -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. // -// @since version 3.6.0. -func (s *server) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (_ *TextDocumentTypeDefinitionResult, err error) { - s.logger.Debug("call " + MethodTextDocumentTypeDefinition) - defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. +// +// @since 3.16.0. +func (s *server) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWillCreateFiles) + defer s.logger.Debug("end "+MethodWillCreateFiles, zap.Error(err)) - var result *TextDocumentTypeDefinitionResult - if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWillCreateFiles, params, &result); err != nil { return nil, err } return result, nil } -// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. +// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. // -// The request can return an array of TextEdits which will be applied to the text document before it is saved. -// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. -// This is done to keep the save fast and reliable. -func (s *server) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (_ []*TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) - defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) +// @since 3.16.0. +func (s *server) DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { + s.logger.Debug("call " + MethodDidCreateFiles) + defer s.logger.Debug("end "+MethodDidCreateFiles, zap.Error(err)) - var result []*TextEdit - if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { + return s.Conn.Notify(ctx, MethodDidCreateFiles, params) +} + +// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. +// +// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. +// +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. +// +// @since 3.16.0. +func (s *server) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWillRenameFiles) + defer s.logger.Debug("end "+MethodWillRenameFiles, zap.Error(err)) + + if err := Call(ctx, s.Conn, MethodWillRenameFiles, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) (_ []*TypeHierarchyItem, err error) { - s.logger.Debug("call " + MethodTypeHierarchySubtypes) - defer s.logger.Debug("end "+MethodTypeHierarchySubtypes, zap.Error(err)) +// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. +// +// @since 3.16.0. +func (s *server) DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { + s.logger.Debug("call " + MethodDidRenameFiles) + defer s.logger.Debug("end "+MethodDidRenameFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodDidRenameFiles, params) +} + +// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. +// +// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. +// +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. +// +// @since 3.16.0. +func (s *server) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWillDeleteFiles) + defer s.logger.Debug("end "+MethodWillDeleteFiles, zap.Error(err)) - var result []*TypeHierarchyItem - if err := Call(ctx, s.Conn, MethodTypeHierarchySubtypes, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWillDeleteFiles, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) (_ []*TypeHierarchyItem, err error) { - s.logger.Debug("call " + MethodTypeHierarchySupertypes) - defer s.logger.Debug("end "+MethodTypeHierarchySupertypes, zap.Error(err)) +// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. +// +// @since 3.16.0. +func (s *server) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { + s.logger.Debug("call " + MethodDidDeleteFiles) + defer s.logger.Debug("end "+MethodDidDeleteFiles, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodDidDeleteFiles, params) +} + +// CodeLensRefresh sent from the server to the client. +// +// Servers can use it to ask clients to refresh the code lenses currently shown in editors. +// As a result the client should ask the server to recompute the code lenses for these editors. +// This is useful if a server detects a configuration change which requires a re-calculation of all code lenses. +// +// Note that the client still has the freedom to delay the re-calculation of the code lenses if for example an editor is currently not visible. +// +// @since 3.16.0. +func (s *server) CodeLensRefresh(ctx context.Context) (err error) { + s.logger.Debug("call " + MethodCodeLensRefresh) + defer s.logger.Debug("end "+MethodCodeLensRefresh, zap.Error(err)) + + return Call(ctx, s.Conn, MethodCodeLensRefresh, nil, nil) +} + +// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. +// +// The call hierarchy requests are executed in two steps: +// 1. first a call hierarchy item is resolved for the given text document position +// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. +// +// @since 3.16.0. +func (s *server) PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) - var result []*TypeHierarchyItem - if err := Call(ctx, s.Conn, MethodTypeHierarchySupertypes, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (_ *WorkspaceDiagnosticReport, err error) { - s.logger.Debug("call " + MethodWorkspaceDiagnostic) - defer s.logger.Debug("end "+MethodWorkspaceDiagnostic, zap.Error(err)) +// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) - var result *WorkspaceDiagnosticReport - if err := Call(ctx, s.Conn, MethodWorkspaceDiagnostic, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { return nil, err } return result, nil } -// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. +// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. // -// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the -// request `workspace/applyEdit` which is sent from the server to the client. -func (s *server) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result any, err error) { - s.logger.Debug("call " + MethodWorkspaceExecuteCommand) - defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { return nil, err } return result, nil } -// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. -func (s *server) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (_ *WorkspaceSymbolResult, err error) { - s.logger.Debug("call " + MethodWorkspaceSymbol) - defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) +// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. +// +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// +// @since 3.16.0. +func (s *server) SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) { + s.logger.Debug("call " + MethodSemanticTokensFull) + defer s.logger.Debug("end "+MethodSemanticTokensFull, zap.Error(err)) - var result *WorkspaceSymbolResult - if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodSemanticTokensFull, params, &result); err != nil { return nil, err } return result, nil } -// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. +// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. // // @since 3.16.0. -func (s *server) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (_ *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWorkspaceWillCreateFiles) - defer s.logger.Debug("end "+MethodWorkspaceWillCreateFiles, zap.Error(err)) +func (s *server) SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{}, err error) { + s.logger.Debug("call " + MethodSemanticTokensFullDelta) + defer s.logger.Debug("end "+MethodSemanticTokensFullDelta, zap.Error(err)) - var result *WorkspaceEdit - if err := Call(ctx, s.Conn, MethodWorkspaceWillCreateFiles, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodSemanticTokensFullDelta, params, &result); err != nil { return nil, err } return result, nil } -// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. +// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. +// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). +// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. +// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. // // @since 3.16.0. -func (s *server) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (_ *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWorkspaceWillDeleteFiles) - defer s.logger.Debug("end "+MethodWorkspaceWillDeleteFiles, zap.Error(err)) +func (s *server) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) { + s.logger.Debug("call " + MethodSemanticTokensRange) + defer s.logger.Debug("end "+MethodSemanticTokensRange, zap.Error(err)) - var result *WorkspaceEdit - if err := Call(ctx, s.Conn, MethodWorkspaceWillDeleteFiles, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodSemanticTokensRange, params, &result); err != nil { return nil, err } return result, nil } -// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. +// SemanticTokensRefresh is sent from the server to the client. Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens. // -// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. +// As a result the client should ask the server to recompute the semantic tokens for these editors. +// This is useful if a server detects a project wide configuration change which requires a re-calculation of all semantic tokens. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. +// Note that the client still has the freedom to delay the re-calculation of the semantic tokens if for example an editor is currently not visible. +// +// @since 3.16.0. +func (s *server) SemanticTokensRefresh(ctx context.Context) (err error) { + s.logger.Debug("call " + MethodSemanticTokensRefresh) + defer s.logger.Debug("end "+MethodSemanticTokensRefresh, zap.Error(err)) + + return Call(ctx, s.Conn, MethodSemanticTokensRefresh, nil, nil) +} + +// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. +// +// Optionally a word pattern can be returned to describe valid contents. +// +// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. // // @since 3.16.0. -func (s *server) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (_ *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWorkspaceWillRenameFiles) - defer s.logger.Debug("end "+MethodWorkspaceWillRenameFiles, zap.Error(err)) +func (s *server) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) { + s.logger.Debug("call " + MethodLinkedEditingRange) + defer s.logger.Debug("end "+MethodLinkedEditingRange, zap.Error(err)) - var result *WorkspaceEdit - if err := Call(ctx, s.Conn, MethodWorkspaceWillRenameFiles, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodLinkedEditingRange, params, &result); err != nil { return nil, err } return result, nil } -func (s *server) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (_ *WorkspaceSymbol, err error) { - s.logger.Debug("call " + MethodWorkspaceSymbolResolve) - defer s.logger.Debug("end "+MethodWorkspaceSymbolResolve, zap.Error(err)) +// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. +// +// An array of Moniker types is returned as response to indicate possible monikers at the given location. +// +// If no monikers can be calculated, an empty array or null should be returned. +// +// @since 3.16.0. +func (s *server) Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) { + s.logger.Debug("call " + MethodMoniker) + defer s.logger.Debug("end "+MethodMoniker, zap.Error(err)) - var result *WorkspaceSymbol - if err := Call(ctx, s.Conn, MethodWorkspaceSymbolResolve, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodMoniker, params, &result); err != nil { return nil, err } @@ -1986,14 +1881,15 @@ func (s *server) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSy } // Request sends a request from the client to the server that non-compliant with the Language Server Protocol specifications. -func (s *server) Request(ctx context.Context, method string, params any) (any, error) { +func (s *server) Request(ctx context.Context, method string, params interface{}) (interface{}, error) { s.logger.Debug("call " + method) defer s.logger.Debug("end " + method) - var result any + var result interface{} if err := Call(ctx, s.Conn, method, params, &result); err != nil { return nil, err } return result, nil } + diff --git a/server_interface.go b/server_interface.go deleted file mode 100644 index c97e0c8e..00000000 --- a/server_interface.go +++ /dev/null @@ -1,681 +0,0 @@ -// Copyright 2024 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "context" - - "go.lsp.dev/jsonrpc2" -) - -const ( - MethodServerCancelRequest ServerMethod = "$/cancelRequest" // bidirect server notification - MethodServerProgress ServerMethod = "$/progress" // bidirect server notification - MethodSetTrace ServerMethod = "$/setTrace" // server notification - MethodExit ServerMethod = "exit" // server notification - MethodInitialized ServerMethod = "initialized" // server notification - MethodNotebookDocumentDidChange ServerMethod = "notebookDocument/didChange" // server notification - MethodNotebookDocumentDidClose ServerMethod = "notebookDocument/didClose" // server notification - MethodNotebookDocumentDidOpen ServerMethod = "notebookDocument/didOpen" // server notification - MethodNotebookDocumentDidSave ServerMethod = "notebookDocument/didSave" // server notification - MethodTextDocumentDidChange ServerMethod = "textDocument/didChange" // server notification - MethodTextDocumentDidClose ServerMethod = "textDocument/didClose" // server notification - MethodTextDocumentDidOpen ServerMethod = "textDocument/didOpen" // server notification - MethodTextDocumentDidSave ServerMethod = "textDocument/didSave" // server notification - MethodTextDocumentWillSave ServerMethod = "textDocument/willSave" // server notification - MethodWindowWorkDoneProgressCancel ServerMethod = "window/workDoneProgress/cancel" // server notification - MethodWorkspaceDidChangeConfiguration ServerMethod = "workspace/didChangeConfiguration" // server notification - MethodWorkspaceDidChangeWatchedFiles ServerMethod = "workspace/didChangeWatchedFiles" // server notification - MethodWorkspaceDidChangeWorkspaceFolders ServerMethod = "workspace/didChangeWorkspaceFolders" // server notification - MethodWorkspaceDidCreateFiles ServerMethod = "workspace/didCreateFiles" // server notification - MethodWorkspaceDidDeleteFiles ServerMethod = "workspace/didDeleteFiles" // server notification - MethodWorkspaceDidRenameFiles ServerMethod = "workspace/didRenameFiles" // server notification - MethodCallHierarchyIncomingCalls ServerMethod = "callHierarchy/incomingCalls" // server request - MethodCallHierarchyOutgoingCalls ServerMethod = "callHierarchy/outgoingCalls" // server request - MethodCodeActionResolve ServerMethod = "codeAction/resolve" // server request - MethodCodeLensResolve ServerMethod = "codeLens/resolve" // server request - MethodCompletionItemResolve ServerMethod = "completionItem/resolve" // server request - MethodDocumentLinkResolve ServerMethod = "documentLink/resolve" // server request - MethodInitialize ServerMethod = "initialize" // server request - MethodInlayHintResolve ServerMethod = "inlayHint/resolve" // server request - MethodShutdown ServerMethod = "shutdown" // server request - MethodTextDocumentCodeAction ServerMethod = "textDocument/codeAction" // server request - MethodTextDocumentCodeLens ServerMethod = "textDocument/codeLens" // server request - MethodTextDocumentColorPresentation ServerMethod = "textDocument/colorPresentation" // server request - MethodTextDocumentCompletion ServerMethod = "textDocument/completion" // server request - MethodTextDocumentDeclaration ServerMethod = "textDocument/declaration" // server request - MethodTextDocumentDefinition ServerMethod = "textDocument/definition" // server request - MethodTextDocumentDiagnostic ServerMethod = "textDocument/diagnostic" // server request - MethodTextDocumentDocumentColor ServerMethod = "textDocument/documentColor" // server request - MethodTextDocumentDocumentHighlight ServerMethod = "textDocument/documentHighlight" // server request - MethodTextDocumentDocumentLink ServerMethod = "textDocument/documentLink" // server request - MethodTextDocumentDocumentSymbol ServerMethod = "textDocument/documentSymbol" // server request - MethodTextDocumentFoldingRange ServerMethod = "textDocument/foldingRange" // server request - MethodTextDocumentFormatting ServerMethod = "textDocument/formatting" // server request - MethodTextDocumentHover ServerMethod = "textDocument/hover" // server request - MethodTextDocumentImplementation ServerMethod = "textDocument/implementation" // server request - MethodTextDocumentInlayHint ServerMethod = "textDocument/inlayHint" // server request - MethodTextDocumentInlineCompletion ServerMethod = "textDocument/inlineCompletion" // server request - MethodTextDocumentInlineValue ServerMethod = "textDocument/inlineValue" // server request - MethodTextDocumentLinkedEditingRange ServerMethod = "textDocument/linkedEditingRange" // server request - MethodTextDocumentMoniker ServerMethod = "textDocument/moniker" // server request - MethodTextDocumentOnTypeFormatting ServerMethod = "textDocument/onTypeFormatting" // server request - MethodTextDocumentPrepareCallHierarchy ServerMethod = "textDocument/prepareCallHierarchy" // server request - MethodTextDocumentPrepareRename ServerMethod = "textDocument/prepareRename" // server request - MethodTextDocumentPrepareTypeHierarchy ServerMethod = "textDocument/prepareTypeHierarchy" // server request - MethodTextDocumentRangeFormatting ServerMethod = "textDocument/rangeFormatting" // server request - MethodTextDocumentRangesFormatting ServerMethod = "textDocument/rangesFormatting" // server request - MethodTextDocumentReferences ServerMethod = "textDocument/references" // server request - MethodTextDocumentRename ServerMethod = "textDocument/rename" // server request - MethodTextDocumentSelectionRange ServerMethod = "textDocument/selectionRange" // server request - MethodTextDocumentSemanticTokensFull ServerMethod = "textDocument/semanticTokens/full" // server request - MethodTextDocumentSemanticTokensFullDelta ServerMethod = "textDocument/semanticTokens/full/delta" // server request - MethodTextDocumentSemanticTokensRange ServerMethod = "textDocument/semanticTokens/range" // server request - MethodTextDocumentSignatureHelp ServerMethod = "textDocument/signatureHelp" // server request - MethodTextDocumentTypeDefinition ServerMethod = "textDocument/typeDefinition" // server request - MethodTextDocumentWillSaveWaitUntil ServerMethod = "textDocument/willSaveWaitUntil" // server request - MethodTypeHierarchySubtypes ServerMethod = "typeHierarchy/subtypes" // server request - MethodTypeHierarchySupertypes ServerMethod = "typeHierarchy/supertypes" // server request - MethodWorkspaceDiagnostic ServerMethod = "workspace/diagnostic" // server request - MethodWorkspaceExecuteCommand ServerMethod = "workspace/executeCommand" // server request - MethodWorkspaceSymbol ServerMethod = "workspace/symbol" // server request - MethodWorkspaceWillCreateFiles ServerMethod = "workspace/willCreateFiles" // server request - MethodWorkspaceWillDeleteFiles ServerMethod = "workspace/willDeleteFiles" // server request - MethodWorkspaceWillRenameFiles ServerMethod = "workspace/willRenameFiles" // server request - MethodWorkspaceSymbolResolve ServerMethod = "workspaceSymbol/resolve" // server request -) - -type Server interface { - CancelRequest(ctx context.Context, params *CancelParams) error - - Progress(ctx context.Context, params *ProgressParams) error - - SetTrace(ctx context.Context, params *SetTraceParams) error - - // Exit the exit event is sent from the client to the server to ask the server to exit its process. - Exit(ctx context.Context) error - - // Initialized the initialized notification is sent from the client to the server after the client is fully initialized and the server is allowed to send requests from the server to the client. - Initialized(ctx context.Context, params *InitializedParams) error - - NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) error - - // NotebookDocumentDidClose a notification sent when a notebook closes. - // - // @since 3.17.0 - NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) error - - // NotebookDocumentDidOpen a notification sent when a notebook opens. - // - // @since 3.17.0 - NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) error - - // NotebookDocumentDidSave a notification sent when a notebook document is saved. - // - // @since 3.17.0 - NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) error - - // TextDocumentDidChange the document change notification is sent from the client to the server to signal changes to a text document. - TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) error - - // TextDocumentDidClose the document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notification to be sent. - TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) error - - // TextDocumentDidOpen the document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one. - TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) error - - // TextDocumentDidSave the document save notification is sent from the client to the server when the document got saved in the client. - TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) error - - // TextDocumentWillSave a document will save notification is sent from the client to the server before the document is actually saved. - TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) error - - // WindowWorkDoneProgressCancel the `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress initiated on the server side. - WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error - - // WorkspaceDidChangeConfiguration the configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains the changed configuration as defined by the language client. - WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error - - // WorkspaceDidChangeWatchedFiles the watched files notification is sent from the client to the server when the client detects changes - // to file watched by the language client. - WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error - - // WorkspaceDidChangeWorkspaceFolders the `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace folder configuration changes. - WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error - - // WorkspaceDidCreateFiles the did create files notification is sent from the client to the server when files were created from - // within the client. - // - // @since 3.16.0 - WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) error - - // WorkspaceDidDeleteFiles the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. - // - // @since 3.16.0 - WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error - - // WorkspaceDidRenameFiles the did rename files notification is sent from the client to the server when files were renamed from - // within the client. - // - // @since 3.16.0 - WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) error - // CallHierarchyIncomingCalls a request to resolve the incoming calls for a given `CallHierarchyItem`. - // - // @since 3.16.0 - CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) ([]*CallHierarchyIncomingCall, error) - - // CallHierarchyOutgoingCalls a request to resolve the outgoing calls for a given `CallHierarchyItem`. - // - // @since 3.16.0 - CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) - - // CodeActionResolve request to resolve additional information for a given code action.The request's parameter is of type - // CodeAction the response is of type CodeAction or a Thenable that resolves to such. - CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) - - // CodeLensResolve a request to resolve a command for a given code lens. - CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) - - // CompletionItemResolve request to resolve additional information for a given completion item.The request's parameter is of type CompletionItem the response is of type CompletionItem or a Thenable that resolves to such. - CompletionItemResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) - - // DocumentLinkResolve request to resolve additional information for a given document link. The request's parameter is of type DocumentLink the response is of type DocumentLink or a Thenable that resolves to such. - DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) - - // Initialize the initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type InitializeParams the response if of type InitializeResult of a Thenable that resolves to such. - Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) - - // InlayHintResolve a request to resolve additional properties for an inlay hint. The request's parameter is of type InlayHint, the response is of type InlayHint or a Thenable that resolves to such. - // - // @since 3.17.0 - InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) - - // Shutdown a shutdown request is sent from the client to the server. It is sent once when the client decides to - // shutdown the server. The only notification that is sent after a shutdown request is the exit event. - Shutdown(ctx context.Context) error - - // TextDocumentCodeAction a request to provide commands for the given text document and range. - TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (*TextDocumentCodeActionResult, error) - - // TextDocumentCodeLens a request to provide code lens for the given text document. - TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) - - // TextDocumentColorPresentation a request to list all presentation for a color. The request's parameter is of type ColorPresentationParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. - TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) - - // TextDocumentCompletion request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, - // `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. - TextDocumentCompletion(ctx context.Context, params *CompletionParams) (*TextDocumentCompletionResult, error) - - // TextDocumentDeclaration a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a - // typed array of DeclarationLink or a Thenable that resolves to such. - TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (*TextDocumentDeclarationResult, error) - - // TextDocumentDefinition a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed - // array of DefinitionLink or a Thenable that resolves to such. - TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (*TextDocumentDefinitionResult, error) - - // TextDocumentDiagnostic the document diagnostic request definition. - // - // @since 3.17.0 - TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) - - // TextDocumentDocumentColor a request to list all color symbols found in a given text document. The request's parameter is of type DocumentColorParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. - TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) - - // TextDocumentDocumentHighlight request to resolve a DocumentHighlight for a given text document position. The request's parameter is of type TextDocumentPosition the request response is an array of type DocumentHighlight or a Thenable that resolves to such. - TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) - - // TextDocumentDocumentLink a request to provide document links. - TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) - - // TextDocumentDocumentSymbol a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that - // resolves to such. - TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*TextDocumentDocumentSymbolResult, error) - - // TextDocumentFoldingRange a request to provide folding ranges in a document. The request's parameter is of type FoldingRangeParams, the response is of type FoldingRangeList or a Thenable that resolves to such. - TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) - - // TextDocumentFormatting a request to format a whole document. - TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) - - // TextDocumentHover request to request hover information at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type Hover or a Thenable that resolves to such. - TextDocumentHover(ctx context.Context, params *HoverParams) (*Hover, error) - - // TextDocumentImplementation a request to resolve the implementation locations of a symbol at a given text document position. The - // request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. - TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (*TextDocumentImplementationResult, error) - - // TextDocumentInlayHint a request to provide inlay hints in a document. The request's parameter is of type InlayHintsParams, - // the response is of type InlayHint InlayHint[] or a Thenable that resolves to such. - // - // @since 3.17.0 - TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) - - // TextDocumentInlineCompletion a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. - // - // @since 3.18.0 proposed - TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (*TextDocumentInlineCompletionResult, error) - - // TextDocumentInlineValue a request to provide inline values in a document. The request's parameter is of type InlineValueParams, the response is of type InlineValue InlineValue[] or a Thenable that resolves to such. - // - // @since 3.17.0 - TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) - - // TextDocumentLinkedEditingRange a request to provide ranges that can be edited together. - // - // @since 3.16.0 - TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) - - // TextDocumentMoniker a request to get the moniker of a symbol at a given text document position. The request parameter is - // of type TextDocumentPositionParams. The response is of type Moniker Moniker[] or `null`. - TextDocumentMoniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) - - // TextDocumentOnTypeFormatting a request to format a document on type. - TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) - - // TextDocumentPrepareCallHierarchy a request to result a `CallHierarchyItem` in a document at a given position. Can be used as an input - // to an incoming or outgoing call hierarchy. - // - // @since 3.16.0 - TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) - - // TextDocumentPrepareRename a request to test and perform the setup necessary for a rename. 3.16 - support for default behavior. - // - // @since 3.16 - support for default behavior - TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) - - // TextDocumentPrepareTypeHierarchy a request to result a `TypeHierarchyItem` in a document at a given position. Can be used as an input - // to a subtypes or supertypes type hierarchy. - // - // @since 3.17.0 - TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) - - // TextDocumentRangeFormatting a request to format a range in a document. - TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) - - // TextDocumentRangesFormatting a request to format ranges in a document. 3.18.0 @proposed. - // - // @since 3.18.0 proposed - TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) - - // TextDocumentReferences a request to resolve project-wide references for the symbol denoted by the given text document position. The request's parameter is of type ReferenceParams the response is of type Location Location[] or a Thenable that resolves to such. - TextDocumentReferences(ctx context.Context, params *ReferenceParams) ([]*Location, error) - - // TextDocumentRename a request to rename a symbol. - TextDocumentRename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) - - // TextDocumentSelectionRange a request to provide selection ranges in a document. The request's parameter is of type SelectionRangeParams, the response is of type SelectionRange SelectionRange[] or a Thenable that resolves to such. - TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) - - // TextDocumentSemanticTokensFull. - // - // @since 3.16.0 - TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) - - // TextDocumentSemanticTokensFullDelta. - // - // @since 3.16.0 - TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*TextDocumentSemanticTokensFullDeltaResult, error) - - // TextDocumentSemanticTokensRange. - // - // @since 3.16.0 - TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) - - TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) - - // TextDocumentTypeDefinition a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. - TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TextDocumentTypeDefinitionResult, error) - - // TextDocumentWillSaveWaitUntil a document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before - // it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable. - TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) - - // TypeHierarchySubtypes a request to resolve the subtypes for a given `TypeHierarchyItem`. - // - // @since 3.17.0 - TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) - - // TypeHierarchySupertypes a request to resolve the supertypes for a given `TypeHierarchyItem`. - // - // @since 3.17.0 - TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) - - // WorkspaceDiagnostic the workspace diagnostic request definition. - // - // @since 3.17.0 - WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) - - // WorkspaceExecuteCommand a request send from the client to the server to execute a command. The request might return a workspace edit which the client will apply to the workspace. - WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) - - // WorkspaceSymbol a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. - // The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. - // - // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. - WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) - - // WorkspaceWillCreateFiles the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a `WorkspaceEdit` which will be applied to workspace before the files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file to be created. - // - // @since 3.16.0 - WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) - - // WorkspaceWillDeleteFiles the did delete files notification is sent from the client to the server when files were deleted from - // within the client. - // - // @since 3.16.0 - WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) - - // WorkspaceWillRenameFiles the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. - // - // @since 3.16.0 - WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) - - // WorkspaceSymbolResolve a request to resolve the range inside the workspace symbol's location. - // - // @since 3.17.0 - WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (*WorkspaceSymbol, error) - - Request(ctx context.Context, method string, params any) (any, error) -} - -// UnimplementedServer should be embedded to have forward compatible implementations. -type UnimplementedServer struct{} - -func (UnimplementedServer) CancelRequest(ctx context.Context, params *CancelParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) Progress(ctx context.Context, params *ProgressParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) SetTrace(ctx context.Context, params *SetTraceParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) Exit(ctx context.Context) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) Initialized(ctx context.Context, params *InitializedParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) ([]*CallHierarchyIncomingCall, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) CompletionItemResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) Shutdown(ctx context.Context) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (*TextDocumentCodeActionResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (*TextDocumentCompletionResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (*TextDocumentDeclarationResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (*TextDocumentDefinitionResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*TextDocumentDocumentSymbolResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentHover(ctx context.Context, params *HoverParams) (*Hover, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (*TextDocumentImplementationResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (*TextDocumentInlineCompletionResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentMoniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentReferences(ctx context.Context, params *ReferenceParams) ([]*Location, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentRename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*TextDocumentSemanticTokensFullDeltaResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TextDocumentTypeDefinitionResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (*WorkspaceSymbol, error) { - return nil, jsonrpc2.ErrInternal -} From 1b68a738a7592b5685ce2cfd5c6406fa470f81c8 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Mon, 7 Oct 2024 07:51:40 +0900 Subject: [PATCH 08/19] WIP5 Signed-off-by: Koichi Shiraishi --- protocol/base.go | 2 +- protocol/basic.go | 103 +- protocol/client.go | 22 +- protocol/client_interface.go | 52 +- protocol/document.go | 80 +- protocol/language.go | 167 +- protocol/lifecycle.go | 201 +- protocol/server.go | 15 + protocol/server_interface.go | 10 + protocol/typealias.go | 250 +- protocol/types_generics.go | 2042 +++++++++-------- protocol/workspace.go | 27 +- tools/protocol-gen/generator/enumeration.go | 15 +- .../protocol-gen/generator/generics_types.go | 52 +- tools/protocol-gen/generator/structure.go | 15 +- tools/protocol-gen/generator/typealiases.go | 14 +- tools/protocol-gen/main.go | 3 +- tools/protocol-gen/protocol/enum.go | 18 +- tools/protocol-gen/protocol/type.go | 36 +- tools/protocol-gen/resolver/resolver.go | 7 +- tools/protocol-gen/schema/metaModel.go | 51 +- 21 files changed, 1787 insertions(+), 1395 deletions(-) diff --git a/protocol/base.go b/protocol/base.go index 5d110210..28c99bcd 100644 --- a/protocol/base.go +++ b/protocol/base.go @@ -39,7 +39,7 @@ const ( // ContentModifiedLSPErrorCodes the server detected that the content of a document got modified outside normal conditions. A server should NOT send this error code if it detects a content change in it unprocessed messages. The result even computed on an older state might still be useful for the client. If a client decides that a result is not of any use anymore the client should cancel the request. ContentModifiedLSPErrorCodes LSPErrorCodes = -32801 - // RequestCancelledLSPErrorCodes the client has canceled a request and a server as detected the cancel. + // RequestCancelledLSPErrorCodes the client has canceled a request and a server has detected the cancel. RequestCancelledLSPErrorCodes LSPErrorCodes = -32800 ) diff --git a/protocol/basic.go b/protocol/basic.go index e661f2c9..0038cd14 100644 --- a/protocol/basic.go +++ b/protocol/basic.go @@ -88,6 +88,8 @@ const ( HandlebarsLanguageKind LanguageKind = "handlebars" + HaskellLanguageKind LanguageKind = "haskell" + HTMLLanguageKind LanguageKind = "html" IniLanguageKind LanguageKind = "ini" @@ -256,12 +258,12 @@ type TextDocumentIdentifier struct { // // @since 3.17.0 - support for negotiated position encoding. type Position struct { - // Line line position in a document (zero-based). If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document. If a line number is negative, it defaults to . + // Line line position in a document (zero-based). // // @since 3.17.0 - support for negotiated position encoding. Line uint32 `json:"line"` - // Character character offset on a line in a document (zero-based). The meaning of this offset is determined by the negotiated `PositionEncodingKind`. If the character value is greater than the line length it defaults back to the line length. + // Character character offset on a line in a document (zero-based). The meaning of this offset is determined by the negotiated `PositionEncodingKind`. // // @since 3.17.0 - support for negotiated position encoding. Character uint32 `json:"character"` @@ -316,6 +318,38 @@ type OptionalVersionedTextDocumentIdentifier struct { Version int32 `json:"version,omitempty"` } +// StringValue a string value used as a snippet is a template which allows to insert text and to control the editor +// cursor when insertion happens. A snippet can define tab stops and placeholders with `$1`, `$2` +// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Variables are defined with `$name` and `${name:default value}`. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type StringValue struct { + // Value the snippet string. + // + // @since 3.18.0 proposed + Value string `json:"value"` +} + +// SnippetTextEdit an interactive text edit. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type SnippetTextEdit struct { + // Range the range of the text document to be manipulated. + // + // @since 3.18.0 proposed + Range Range `json:"range"` + + // Snippet the snippet to be inserted. + // + // @since 3.18.0 proposed + Snippet StringValue `json:"snippet"` + + // AnnotationID the actual identifier of the snippet edit. + // + // @since 3.18.0 proposed + AnnotationID *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` +} + // AnnotatedTextEdit a special text edit with an additional change annotation. // // @since 3.16.0. @@ -335,7 +369,7 @@ type TextDocumentEdit struct { // TextDocument the text document to change. TextDocument OptionalVersionedTextDocumentIdentifier `json:"textDocument"` - // Edits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. + // Edits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. Edits TextDocumentEditEdits `json:"edits"` } @@ -425,7 +459,7 @@ type Diagnostic struct { // Range the range at which the message applies. Range Range `json:"range"` - // Severity the diagnostic's severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint. + // Severity the diagnostic's severity. To avoid interpretation mismatches when a server is used with different clients it is highly recommended that servers always provide a severity value. Severity DiagnosticSeverity `json:"severity,omitempty"` // Code the diagnostic's code, which usually appear in the user interface. @@ -475,25 +509,64 @@ type VersionedTextDocumentIdentifier struct { Version int32 `json:"version"` } -// StringValue a string value used as a snippet is a template which allows to insert text and to control the editor -// cursor when insertion happens. A snippet can define tab stops and placeholders with `$1`, `$2` -// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Variables are defined with `$name` and `${name:default value}`. 3.18.0 @proposed. +// TextDocumentContentParams parameters for the `workspace/textDocumentContent` request. 3.18.0 @proposed. // // @since 3.18.0 proposed -type StringValue struct { - // Value the snippet string. +type TextDocumentContentParams struct { + // URI the uri of the text document. // // @since 3.18.0 proposed - Value string `json:"value"` + URI DocumentURI `json:"uri"` } -// ChangeAnnotationsSupportOptions. +// TextDocumentContentResult result of the `workspace/textDocumentContent` request. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentContentResult struct { + // Text the text content of the text document. Please note, that the content of any subsequent open notifications for the text document might differ from the returned content due to whitespace and line ending + // normalizations done on the client. + // + // @since 3.18.0 proposed + Text string `json:"text"` +} + +// TextDocumentContentOptions text document content provider options. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentContentOptions struct { + // Schemes the schemes for which the server provides content. + // + // @since 3.18.0 proposed + Schemes []string `json:"schemes"` +} + +// TextDocumentContentRegistrationOptions text document content provider registration options. 3.18.0 @proposed. // // @since 3.18.0 proposed +type TextDocumentContentRegistrationOptions struct { + // extends + TextDocumentContentOptions + // mixins + StaticRegistrationOptions +} + +// TextDocumentContentRefreshParams parameters for the `workspace/textDocumentContent/refresh` request. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentContentRefreshParams struct { + // URI the uri of the text document to refresh. + // + // @since 3.18.0 proposed + URI DocumentURI `json:"uri"` +} + +// ChangeAnnotationsSupportOptions. +// +// @since 3.18.0 type ChangeAnnotationsSupportOptions struct { // GroupsOnLabel whether the client groups edits with equal labels into tree nodes, for instance all edits labelled with "Changes in Strings" would be a tree node. // - // @since 3.18.0 proposed + // @since 3.18.0 GroupsOnLabel bool `json:"groupsOnLabel,omitempty"` } @@ -512,6 +585,12 @@ type WorkspaceEditClientCapabilities struct { // ChangeAnnotationSupport whether the client in general supports change annotations on text edits, create file, rename file and delete file changes. ChangeAnnotationSupport *ChangeAnnotationsSupportOptions `json:"changeAnnotationSupport,omitempty"` + + // MetadataSupport whether the client supports `WorkspaceEditMetadata` in `WorkspaceEdit`s. 3.18.0 @proposed. + MetadataSupport bool `json:"metadataSupport,omitempty"` + + // SnippetEditSupport whether the client supports snippets as text edits. 3.18.0 @proposed. + SnippetEditSupport bool `json:"snippetEditSupport,omitempty"` } type WorkDoneProgressBegin struct { diff --git a/protocol/client.go b/protocol/client.go index 806f0131..23b7fe56 100644 --- a/protocol/client.go +++ b/protocol/client.go @@ -433,6 +433,13 @@ func (c *client) WorkspaceConfiguration(ctx context.Context, params *Configurati return result, nil } +func (c *client) refresh(ctx context.Context, method string) (err error) { + c.logger.Debug("call " + method) + defer c.logger.Debug("end "+method, zap.Error(err)) + + return c.Conn.Notify(ctx, method, nil) +} + func (c *client) WorkspaceDiagnosticRefresh(ctx context.Context) (err error) { return c.refresh(ctx, MethodWorkspaceDiagnosticRefresh) } @@ -453,11 +460,18 @@ func (c *client) WorkspaceSemanticTokensRefresh(ctx context.Context) (err error) return c.refresh(ctx, MethodWorkspaceSemanticTokensRefresh) } -func (c *client) refresh(ctx context.Context, method string) (err error) { - c.logger.Debug("call " + method) - defer c.logger.Debug("end "+method, zap.Error(err)) +// WorkspaceTextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +func (c *client) WorkspaceTextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) (err error) { + c.logger.Debug("call " + MethodWorkspaceTextDocumentContentRefresh) + defer c.logger.Debug("end "+MethodWorkspaceTextDocumentContentRefresh, zap.Error(err)) - return c.Conn.Notify(ctx, method, nil) + if err := Call(ctx, c.Conn, MethodWorkspaceTextDocumentContentRefresh, params, nil); err != nil { + return err + } + + return nil } // WorkspaceFolders sends the request from the server to the client to fetch the current open list of workspace folders. diff --git a/protocol/client_interface.go b/protocol/client_interface.go index 01ee1d19..5ef359be 100644 --- a/protocol/client_interface.go +++ b/protocol/client_interface.go @@ -10,27 +10,28 @@ import ( ) const ( - MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification - MethodClientProgress ClientMethod = "$/progress" // bidirect client notification - MethodLogTrace ClientMethod = "$/logTrace" // client notification - MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification - MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification - MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification - MethodWindowShowMessage ClientMethod = "window/showMessage" // client notification - MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request - MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request - MethodWindowShowDocument ClientMethod = "window/showDocument" // client request - MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request - MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request - MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request - MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request - MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request - MethodWorkspaceDiagnosticRefresh ClientMethod = "workspace/diagnostic/refresh" // client request - MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request - MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request - MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request - MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request - MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request + MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification + MethodClientProgress ClientMethod = "$/progress" // bidirect client notification + MethodLogTrace ClientMethod = "$/logTrace" // client notification + MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification + MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification + MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification + MethodWindowShowMessage ClientMethod = "window/showMessage" // client notification + MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request + MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request + MethodWindowShowDocument ClientMethod = "window/showDocument" // client request + MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request + MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request + MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request + MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request + MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request + MethodWorkspaceDiagnosticRefresh ClientMethod = "workspace/diagnostic/refresh" // client request + MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request + MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request + MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request + MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request + MethodWorkspaceTextDocumentContentRefresh ClientMethod = "workspace/textDocumentContent/refresh" // client request + MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request ) type Client interface { @@ -105,6 +106,11 @@ type Client interface { // @since 3.16.0 WorkspaceSemanticTokensRefresh(ctx context.Context) error + // WorkspaceTextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + WorkspaceTextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error + // WorkspaceWorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders. WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) } @@ -192,6 +198,10 @@ func (UnimplementedClient) WorkspaceSemanticTokensRefresh(ctx context.Context) e return jsonrpc2.ErrInternal } +func (UnimplementedClient) WorkspaceTextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error { + return jsonrpc2.ErrInternal +} + func (UnimplementedClient) WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) { return nil, jsonrpc2.ErrInternal } diff --git a/protocol/document.go b/protocol/document.go index 1d7400ea..8cec2854 100644 --- a/protocol/document.go +++ b/protocol/document.go @@ -115,39 +115,39 @@ type DidOpenNotebookDocumentParams struct { // NotebookCellLanguage. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookCellLanguage struct { - // @since 3.18.0 proposed + // @since 3.18.0 Language string `json:"language"` } // NotebookDocumentFilterWithCells. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentFilterWithCells struct { // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. // - // @since 3.18.0 proposed + // @since 3.18.0 Notebook NotebookDocumentFilterWithCellsNotebook `json:"notebook,omitempty"` // Cells the cells of the matching notebook to be synced. // - // @since 3.18.0 proposed + // @since 3.18.0 Cells []NotebookCellLanguage `json:"cells"` } // NotebookDocumentFilterWithNotebook. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentFilterWithNotebook struct { // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. // - // @since 3.18.0 proposed + // @since 3.18.0 Notebook NotebookDocumentFilterWithNotebookNotebook `json:"notebook"` // Cells the cells of the matching notebook to be synced. // - // @since 3.18.0 proposed + // @since 3.18.0 Cells []NotebookCellLanguage `json:"cells,omitempty"` } @@ -212,54 +212,54 @@ type NotebookCellArrayChange struct { Cells []NotebookCell `json:"cells,omitempty"` } -// NotebookDocumentCellChangeStructure structural changes to cells in a notebook document. 3.18.0 @proposed. +// NotebookDocumentCellChangeStructure structural changes to cells in a notebook document. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentCellChangeStructure struct { // Array the change to the cell array. // - // @since 3.18.0 proposed + // @since 3.18.0 Array NotebookCellArrayChange `json:"array"` // DidOpen additional opened cell text documents. // - // @since 3.18.0 proposed + // @since 3.18.0 DidOpen []TextDocumentItem `json:"didOpen,omitempty"` // DidClose additional closed cell text documents. // - // @since 3.18.0 proposed + // @since 3.18.0 DidClose []TextDocumentIdentifier `json:"didClose,omitempty"` } -// NotebookDocumentCellContentChanges content changes to a cell in a notebook document. 3.18.0 @proposed. +// NotebookDocumentCellContentChanges content changes to a cell in a notebook document. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentCellContentChanges struct { - // @since 3.18.0 proposed + // @since 3.18.0 Document VersionedTextDocumentIdentifier `json:"document"` - // @since 3.18.0 proposed + // @since 3.18.0 Changes []TextDocumentContentChangeEvent `json:"changes"` } -// NotebookDocumentCellChanges cell changes to a notebook document. 3.18.0 @proposed. +// NotebookDocumentCellChanges cell changes to a notebook document. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentCellChanges struct { // Structure changes to the cell structure to add or remove cells. // - // @since 3.18.0 proposed + // @since 3.18.0 Structure *NotebookDocumentCellChangeStructure `json:"structure,omitempty"` // Data changes to notebook cells properties like its kind, execution summary or metadata. // - // @since 3.18.0 proposed + // @since 3.18.0 Data []NotebookCell `json:"data,omitempty"` // TextContent changes to the text content of notebook cells. // - // @since 3.18.0 proposed + // @since 3.18.0 TextContent []NotebookDocumentCellContentChanges `json:"textContent,omitempty"` } @@ -409,62 +409,62 @@ type WillSaveTextDocumentParams struct { Reason TextDocumentSaveReason `json:"reason"` } -// NotebookDocumentFilterNotebookType a notebook document filter where `notebookType` is required field. 3.18.0 @proposed. +// NotebookDocumentFilterNotebookType a notebook document filter where `notebookType` is required field. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentFilterNotebookType struct { // NotebookType the type of the enclosing notebook. // - // @since 3.18.0 proposed + // @since 3.18.0 NotebookType string `json:"notebookType"` // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. // - // @since 3.18.0 proposed + // @since 3.18.0 Scheme string `json:"scheme,omitempty"` // Pattern a glob pattern. // - // @since 3.18.0 proposed - Pattern string `json:"pattern,omitempty"` + // @since 3.18.0 + Pattern *GlobPattern `json:"pattern,omitempty"` } -// NotebookDocumentFilterScheme a notebook document filter where `scheme` is required field. 3.18.0 @proposed. +// NotebookDocumentFilterScheme a notebook document filter where `scheme` is required field. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentFilterScheme struct { // NotebookType the type of the enclosing notebook. // - // @since 3.18.0 proposed + // @since 3.18.0 NotebookType string `json:"notebookType,omitempty"` // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. // - // @since 3.18.0 proposed + // @since 3.18.0 Scheme string `json:"scheme"` // Pattern a glob pattern. // - // @since 3.18.0 proposed - Pattern string `json:"pattern,omitempty"` + // @since 3.18.0 + Pattern *GlobPattern `json:"pattern,omitempty"` } -// NotebookDocumentFilterPattern a notebook document filter where `pattern` is required field. 3.18.0 @proposed. +// NotebookDocumentFilterPattern a notebook document filter where `pattern` is required field. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentFilterPattern struct { // NotebookType the type of the enclosing notebook. // - // @since 3.18.0 proposed + // @since 3.18.0 NotebookType string `json:"notebookType,omitempty"` // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. // - // @since 3.18.0 proposed + // @since 3.18.0 Scheme string `json:"scheme,omitempty"` // Pattern a glob pattern. // - // @since 3.18.0 proposed - Pattern string `json:"pattern"` + // @since 3.18.0 + Pattern GlobPattern `json:"pattern"` } diff --git a/protocol/language.go b/protocol/language.go index 3ff98743..5fcb5d16 100644 --- a/protocol/language.go +++ b/protocol/language.go @@ -63,6 +63,11 @@ const ( // // @since 3.17.0 DecoratorSemanticTokenTypes SemanticTokenTypes = "decorator" + + // LabelSemanticTokenTypes. + // + // @since 3.18.0 + LabelSemanticTokenTypes SemanticTokenTypes = "label" ) // SemanticTokenModifiers a set of predefined token modifiers. This set is not fixed an clients can specify additional token types via the corresponding client capabilities. @@ -387,6 +392,16 @@ const ( NotebookCodeActionKind CodeActionKind = "notebook" ) +// CodeActionTag code action tags are extra annotations that tweak the behavior of a code action. 3.18.0 - proposed. +// +// @since 3.18.0 - proposed +type CodeActionTag uint32 + +const ( + // LlmgeneratedCodeActionTag marks the code action as LLM-generated. + LlmgeneratedCodeActionTag CodeActionTag = 1 +) + // InlineCompletionTriggerKind describes how an InlineCompletionItemProvider inline completion provider was triggered. 3.18.0 @proposed. // // @since 3.18.0 proposed @@ -414,6 +429,19 @@ const ( TriggerForIncompleteCompletionsCompletionTriggerKind CompletionTriggerKind = 3 ) +// ApplyKind defines how values from a set of defaults and an individual item will be merged. +// +// @since 3.18.0 +type ApplyKind string + +const ( + // ReplaceApplyKind the value from the individual item (if provided and not `null`) will be used instead of the default. + ReplaceApplyKind ApplyKind = "replace" + + // MergeApplyKind the value from the item will be merged with the default. The specific rules for mergeing values are defined against each field that supports merging. + MergeApplyKind ApplyKind = "merge" +) + // SignatureHelpTriggerKind how a signature help was triggered. // // @since 3.15.0 @@ -856,13 +884,13 @@ type SemanticTokensLegend struct { TokenModifiers []string `json:"tokenModifiers"` } -// SemanticTokensFullDelta semantic tokens options to support deltas for full documents 3.18.0 @proposed. +// SemanticTokensFullDelta semantic tokens options to support deltas for full documents // -// @since 3.18.0 proposed +// @since 3.18.0 type SemanticTokensFullDelta struct { // Delta the server supports deltas for full documents. // - // @since 3.18.0 proposed + // @since 3.18.0 Delta bool `json:"delta,omitempty"` } @@ -1579,12 +1607,22 @@ type InlineCompletionRegistrationOptions struct { StaticRegistrationOptions } +// CodeActionTagOptions. +// +// @since 3.18.0 - proposed +type CodeActionTagOptions struct { + // ValueSet the tags supported by the client. + // + // @since 3.18.0 - proposed + ValueSet []CodeActionTag `json:"valueSet"` +} + // ServerCompletionItemOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ServerCompletionItemOptions struct { // LabelDetailsSupport the server has support for completion item label details (see also `CompletionItemLabelDetails`) when receiving a completion item in a resolve call. - // @since 3.18.0 proposed + // @since 3.18.0 LabelDetailsSupport bool `json:"labelDetailsSupport,omitempty"` } @@ -1886,19 +1924,18 @@ type CompletionItem struct { Data any `json:"data,omitempty"` } -// EditRangeWithInsertReplace edit range variant that includes ranges for insert and replace operations. 3.18.0 @proposed. +// EditRangeWithInsertReplace edit range variant that includes ranges for insert and replace operations. // -// @since 3.18.0 proposed +// @since 3.18.0 type EditRangeWithInsertReplace struct { - // @since 3.18.0 proposed + // @since 3.18.0 Insert Range `json:"insert"` - // @since 3.18.0 proposed + // @since 3.18.0 Replace Range `json:"replace"` } -// CompletionItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value the one from the item is used. Servers are only allowed to return default values if the client signals support for this via -// the `completionList.itemDefaults` capability. +// CompletionItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to "replace". Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability. // // @since 3.17.0 type CompletionItemDefaults struct { @@ -1923,15 +1960,31 @@ type CompletionItemDefaults struct { Data any `json:"data,omitempty"` } +// CompletionItemApplyKinds specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as "replace". If a field's value is "replace", the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is "merge", the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability. +// +// @since 3.18.0 +type CompletionItemApplyKinds struct { + // CommitCharacters specifies whether commitCharacters on a completion will replace or be merged with those in `completionList.itemDefaults.commitCharacters`. If "replace", the commit characters from the completion item will always be used unless not provided, in which case those from `completionList.itemDefaults.commitCharacters` will be used. An empty list can be used if a completion item does not have any commit characters and also should not use those from `completionList.itemDefaults.commitCharacters`. If "merge" the commitCharacters for the completion will be the union of all values in both `completionList.itemDefaults.commitCharacters` and the completion's own `commitCharacters`. + // @since 3.18.0 + CommitCharacters ApplyKind `json:"commitCharacters,omitempty"` + + // Data specifies whether the `data` field on a completion will replace or be merged with data from `completionList.itemDefaults.data`. If "replace", the data from the completion item will be used if provided + // (and not `null`), otherwise `completionList.itemDefaults.data` will be used. An empty object can be used if a completion item does not have any data but also should not use the value from `completionList.itemDefaults.data`. If "merge", a shallow merge will be performed between `completionList.itemDefaults.data` and the completion's own data using the following rules: - If a completion's `data` field is not provided (or `null`), the entire `data` field from `completionList.itemDefaults.data` will be used as-is. - If a completion's `data` field is provided, each field will overwrite the field of the same name in `completionList.itemDefaults.data` but no merging of nested fields within that value will occur. + // @since 3.18.0 + Data ApplyKind `json:"data,omitempty"` +} + // CompletionList represents a collection of CompletionItem completion items to be presented in the editor. type CompletionList struct { // IsIncomplete this list it not complete. Further typing results in recomputing this list. Recomputed lists have all their items replaced (not appended) in the incomplete completion sessions. IsIncomplete bool `json:"isIncomplete"` - // ItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value the one from the item is used. Servers are only allowed to return default values if the client signals support for this via - // the `completionList.itemDefaults` capability. + // ItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to "replace". Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability. ItemDefaults *CompletionItemDefaults `json:"itemDefaults,omitempty"` + // ApplyKind specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as "replace". If a field's value is "replace", the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is "merge", the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability. + ApplyKind *CompletionItemApplyKinds `json:"applyKind,omitempty"` + // Items the completion items. Items []CompletionItem `json:"items"` } @@ -2220,13 +2273,13 @@ type CodeActionParams struct { Context CodeActionContext `json:"context"` } -// CodeActionDisabled captures why the code action is currently disabled. 3.18.0 @proposed. +// CodeActionDisabled captures why the code action is currently disabled. // -// @since 3.18.0 proposed +// @since 3.18.0 type CodeActionDisabled struct { // Reason human readable description of why the code action is currently disabled. This is displayed in the code actions UI. // - // @since 3.18.0 proposed + // @since 3.18.0 Reason string `json:"reason"` } @@ -2258,6 +2311,9 @@ type CodeAction struct { // Data a data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request. Data any `json:"data,omitempty"` + + // Tags tags for this code action. 3.18.0 - proposed. + Tags []CodeActionTag `json:"tags,omitempty"` } // CodeActionRegistrationOptions registration options for a CodeActionRequest. @@ -2267,11 +2323,11 @@ type CodeActionRegistrationOptions struct { CodeActionOptions } -// LocationURIOnly location with only uri and does not include range. 3.18.0 @proposed. +// LocationURIOnly location with only uri and does not include range. // -// @since 3.18.0 proposed +// @since 3.18.0 type LocationURIOnly struct { - // @since 3.18.0 proposed + // @since 3.18.0 URI DocumentURI `json:"uri"` } @@ -2564,20 +2620,20 @@ type RelatedUnchangedDocumentDiagnosticReport struct { // PrepareRenamePlaceholder. // -// @since 3.18.0 proposed +// @since 3.18.0 type PrepareRenamePlaceholder struct { - // @since 3.18.0 proposed + // @since 3.18.0 Range Range `json:"range"` - // @since 3.18.0 proposed + // @since 3.18.0 Placeholder string `json:"placeholder"` } // PrepareRenameDefaultBehavior. // -// @since 3.18.0 proposed +// @since 3.18.0 type PrepareRenameDefaultBehavior struct { - // @since 3.18.0 proposed + // @since 3.18.0 DefaultBehavior bool `json:"defaultBehavior"` } @@ -2619,44 +2675,44 @@ type WorkspaceUnchangedDocumentDiagnosticReport struct { // TextDocumentContentChangePartial. // -// @since 3.18.0 proposed +// @since 3.18.0 type TextDocumentContentChangePartial struct { // Range the range of the document that changed. // - // @since 3.18.0 proposed + // @since 3.18.0 Range Range `json:"range"` // RangeLength the optional length of the range that got replaced. // // Deprecated: use range instead. // - // @since 3.18.0 proposed + // @since 3.18.0 RangeLength uint32 `json:"rangeLength,omitempty"` // Text the new text for the provided range. // - // @since 3.18.0 proposed + // @since 3.18.0 Text string `json:"text"` } // TextDocumentContentChangeWholeDocument. // -// @since 3.18.0 proposed +// @since 3.18.0 type TextDocumentContentChangeWholeDocument struct { // Text the new text of the whole document. // - // @since 3.18.0 proposed + // @since 3.18.0 Text string `json:"text"` } // MarkedStringWithLanguage. // -// @since 3.18.0 proposed +// @since 3.18.0 type MarkedStringWithLanguage struct { - // @since 3.18.0 proposed + // @since 3.18.0 Language string `json:"language"` - // @since 3.18.0 proposed + // @since 3.18.0 Value string `json:"value"` } @@ -2675,62 +2731,59 @@ type NotebookCellTextDocumentFilter struct { Language string `json:"language,omitempty"` } -// TextDocumentFilterLanguage a document filter where `language` is required field. 3.18.0 @proposed. +// TextDocumentFilterLanguage a document filter where `language` is required field. // -// @since 3.18.0 proposed +// @since 3.18.0 type TextDocumentFilterLanguage struct { // Language a language id, like `typescript`. // - // @since 3.18.0 proposed + // @since 3.18.0 Language string `json:"language"` // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. // - // @since 3.18.0 proposed + // @since 3.18.0 Scheme string `json:"scheme,omitempty"` - // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. - // - // @since 3.18.0 proposed - Pattern string `json:"pattern,omitempty"` + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. + // @since 3.18.0 + Pattern *GlobPattern `json:"pattern,omitempty"` } -// TextDocumentFilterScheme a document filter where `scheme` is required field. 3.18.0 @proposed. +// TextDocumentFilterScheme a document filter where `scheme` is required field. // -// @since 3.18.0 proposed +// @since 3.18.0 type TextDocumentFilterScheme struct { // Language a language id, like `typescript`. // - // @since 3.18.0 proposed + // @since 3.18.0 Language string `json:"language,omitempty"` // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. // - // @since 3.18.0 proposed + // @since 3.18.0 Scheme string `json:"scheme"` - // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. - // - // @since 3.18.0 proposed - Pattern string `json:"pattern,omitempty"` + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. + // @since 3.18.0 + Pattern *GlobPattern `json:"pattern,omitempty"` } -// TextDocumentFilterPattern a document filter where `pattern` is required field. 3.18.0 @proposed. +// TextDocumentFilterPattern a document filter where `pattern` is required field. // -// @since 3.18.0 proposed +// @since 3.18.0 type TextDocumentFilterPattern struct { // Language a language id, like `typescript`. // - // @since 3.18.0 proposed + // @since 3.18.0 Language string `json:"language,omitempty"` // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. // - // @since 3.18.0 proposed + // @since 3.18.0 Scheme string `json:"scheme,omitempty"` - // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. - // - // @since 3.18.0 proposed - Pattern string `json:"pattern"` + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. + // @since 3.18.0 + Pattern GlobPattern `json:"pattern"` } diff --git a/protocol/lifecycle.go b/protocol/lifecycle.go index df771860..5e5cf432 100644 --- a/protocol/lifecycle.go +++ b/protocol/lifecycle.go @@ -3,8 +3,6 @@ package protocol -import "bytes" - // TextDocumentSyncKind defines how the host (editor) should sync document changes to the language server. type TextDocumentSyncKind uint32 @@ -55,18 +53,18 @@ type UnregistrationParams struct { Unregisterations []Unregistration `json:"unregisterations"` } -// ClientInfo information about the client 3.15.0 3.18.0 ClientInfo type name added. @proposed. +// ClientInfo information about the client 3.15.0 3.18.0 ClientInfo type name added. // -// @since 3.18.0 ClientInfo type name added. proposed +// @since 3.18.0 ClientInfo type name added. type ClientInfo struct { // Name the name of the client as defined by the client. // - // @since 3.18.0 ClientInfo type name added. proposed + // @since 3.18.0 ClientInfo type name added. Name string `json:"name"` // Version the client's version as defined by the client. // - // @since 3.18.0 ClientInfo type name added. proposed + // @since 3.18.0 ClientInfo type name added. Version string `json:"version,omitempty"` } @@ -172,6 +170,16 @@ type FoldingRangeWorkspaceClientCapabilities struct { RefreshSupport bool `json:"refreshSupport,omitempty"` } +// TextDocumentContentClientCapabilities client capabilities for a text document content provider. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentContentClientCapabilities struct { + // DynamicRegistration text document content provider supports dynamic registration. + // + // @since 3.18.0 proposed + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + // WorkspaceClientCapabilities workspace specific client capabilities. type WorkspaceClientCapabilities struct { // ApplyEdit the client supports applying batch edits to the workspace by supporting the request 'workspace/applyEdit'. @@ -218,6 +226,9 @@ type WorkspaceClientCapabilities struct { // FoldingRange capabilities specific to the folding range requests scoped to the workspace. 3.18.0 @proposed. FoldingRange *FoldingRangeWorkspaceClientCapabilities `json:"foldingRange,omitempty"` + + // TextDocumentContent capabilities specific to the `workspace/textDocumentContent` request. 3.18.0 @proposed. + TextDocumentContent *TextDocumentContentClientCapabilities `json:"textDocumentContent,omitempty"` } type TextDocumentSyncClientCapabilities struct { @@ -236,90 +247,90 @@ type TextDocumentSyncClientCapabilities struct { // CompletionItemTagOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type CompletionItemTagOptions struct { // ValueSet the tags supported by the client. // - // @since 3.18.0 proposed + // @since 3.18.0 ValueSet []CompletionItemTag `json:"valueSet"` } // ClientCompletionItemResolveOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientCompletionItemResolveOptions struct { // Properties the properties that a client can resolve lazily. // - // @since 3.18.0 proposed + // @since 3.18.0 Properties []string `json:"properties"` } // ClientCompletionItemInsertTextModeOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientCompletionItemInsertTextModeOptions struct { - // @since 3.18.0 proposed + // @since 3.18.0 ValueSet []InsertTextMode `json:"valueSet"` } // ClientCompletionItemOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientCompletionItemOptions struct { // SnippetSupport client supports snippets as insert text. A snippet can define tab stops and placeholders with `$1`, `$2` and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Placeholders with equal identifiers are linked, that is typing in one will update others too. // - // @since 3.18.0 proposed + // @since 3.18.0 SnippetSupport bool `json:"snippetSupport,omitempty"` // CommitCharactersSupport client supports commit characters on a completion item. // - // @since 3.18.0 proposed + // @since 3.18.0 CommitCharactersSupport bool `json:"commitCharactersSupport,omitempty"` // DocumentationFormat client supports the following content formats for the documentation property. The order describes the preferred format of the client. // - // @since 3.18.0 proposed + // @since 3.18.0 DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` // DeprecatedSupport client supports the deprecated property on a completion item. // - // @since 3.18.0 proposed + // @since 3.18.0 DeprecatedSupport bool `json:"deprecatedSupport,omitempty"` // PreselectSupport client supports the preselect property on a completion item. // - // @since 3.18.0 proposed + // @since 3.18.0 PreselectSupport bool `json:"preselectSupport,omitempty"` // TagSupport client supports the tag property on a completion item. Clients supporting tags have to handle unknown tags gracefully. Clients especially need to preserve unknown tags when sending a completion item back to the server in a resolve call. - // @since 3.18.0 proposed + // @since 3.18.0 TagSupport *CompletionItemTagOptions `json:"tagSupport,omitempty"` // InsertReplaceSupport client support insert replace edit to control different behavior if a completion item is inserted in // the text or should replace text. - // @since 3.18.0 proposed + // @since 3.18.0 InsertReplaceSupport bool `json:"insertReplaceSupport,omitempty"` // ResolveSupport indicates which properties a client can resolve lazily on a completion item. Before version 3.16.0 only the predefined properties `documentation` and `details` could be resolved lazily. - // @since 3.18.0 proposed + // @since 3.18.0 ResolveSupport *ClientCompletionItemResolveOptions `json:"resolveSupport,omitempty"` // InsertTextModeSupport the client supports the `insertTextMode` property on a completion item to override the whitespace handling mode as defined by the client (see `insertTextMode`). - // @since 3.18.0 proposed + // @since 3.18.0 InsertTextModeSupport *ClientCompletionItemInsertTextModeOptions `json:"insertTextModeSupport,omitempty"` // LabelDetailsSupport the client has support for completion item label details (see also `CompletionItemLabelDetails`). - // @since 3.18.0 proposed + // @since 3.18.0 LabelDetailsSupport bool `json:"labelDetailsSupport,omitempty"` } // ClientCompletionItemOptionsKind. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientCompletionItemOptionsKind struct { // ValueSet the completion item kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. If this property is not present the client only supports the completion items kinds from `Text` to `Reference` as defined in the initial version of the protocol. // - // @since 3.18.0 proposed + // @since 3.18.0 ValueSet []CompletionItemKind `json:"valueSet,omitempty"` } @@ -330,6 +341,11 @@ type CompletionListCapabilities struct { // ItemDefaults the client supports the following itemDefaults on a completion list. The value lists the supported property names of the `CompletionList.itemDefaults` object. If omitted no properties are supported. // @since 3.17.0 ItemDefaults []string `json:"itemDefaults,omitempty"` + + // ApplyKindSupport specifies whether the client supports `CompletionList.applyKind` to indicate how supported values from `completionList.itemDefaults` and `completion` will be combined. If a client supports `applyKind` + // it must support it for all fields that it supports that are listed in `CompletionList.applyKind`. This means when clients add support for new/future fields in completion items the MUST also support merge for them if those fields are defined in `CompletionList.applyKind`. + // @since 3.17.0 + ApplyKindSupport bool `json:"applyKindSupport,omitempty"` } // CompletionClientCapabilities completion client capabilities. @@ -363,33 +379,33 @@ type HoverClientCapabilities struct { // ClientSignatureParameterInformationOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientSignatureParameterInformationOptions struct { // LabelOffsetSupport the client supports processing label offsets instead of a simple label string. - // @since 3.18.0 proposed + // @since 3.18.0 LabelOffsetSupport bool `json:"labelOffsetSupport,omitempty"` } // ClientSignatureInformationOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientSignatureInformationOptions struct { // DocumentationFormat client supports the following content formats for the documentation property. The order describes the preferred format of the client. // - // @since 3.18.0 proposed + // @since 3.18.0 DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` // ParameterInformation client capabilities specific to parameter information. // - // @since 3.18.0 proposed + // @since 3.18.0 ParameterInformation *ClientSignatureParameterInformationOptions `json:"parameterInformation,omitempty"` // ActiveParameterSupport the client supports the `activeParameter` property on `SignatureInformation` literal. - // @since 3.18.0 proposed + // @since 3.18.0 ActiveParameterSupport bool `json:"activeParameterSupport,omitempty"` // NoActiveParameterSupport the client supports the `activeParameter` property on `SignatureHelp`/`SignatureInformation` being set to `null` to indicate that no parameter should be active. 3.18.0 @proposed. - // @since 3.18.0 proposed + // @since 3.18.0 NoActiveParameterSupport bool `json:"noActiveParameterSupport,omitempty"` } @@ -484,31 +500,31 @@ type DocumentSymbolClientCapabilities struct { // ClientCodeActionKindOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientCodeActionKindOptions struct { // ValueSet the code action kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. // - // @since 3.18.0 proposed + // @since 3.18.0 ValueSet []CodeActionKind `json:"valueSet"` } // ClientCodeActionLiteralOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientCodeActionLiteralOptions struct { // CodeActionKind the code action kind is support with the following value set. // - // @since 3.18.0 proposed + // @since 3.18.0 CodeActionKind ClientCodeActionKindOptions `json:"codeActionKind"` } // ClientCodeActionResolveOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientCodeActionResolveOptions struct { // Properties the properties that a client can resolve lazily. // - // @since 3.18.0 proposed + // @since 3.18.0 Properties []string `json:"properties"` } @@ -537,12 +553,28 @@ type CodeActionClientCapabilities struct { // DocumentationSupport whether the client supports documentation for a class of code actions. 3.18.0 @proposed. DocumentationSupport bool `json:"documentationSupport,omitempty"` + + // TagSupport client supports the tag property on a code action. Clients supporting tags have to handle unknown tags gracefully. 3.18.0 - proposed. + TagSupport *CodeActionTagOptions `json:"tagSupport,omitempty"` +} + +// ClientCodeLensResolveOptions. +// +// @since 3.18.0 +type ClientCodeLensResolveOptions struct { + // Properties the properties that a client can resolve lazily. + // + // @since 3.18.0 + Properties []string `json:"properties"` } // CodeLensClientCapabilities the client capabilities of a CodeLensRequest. type CodeLensClientCapabilities struct { // DynamicRegistration whether code lens supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // ResolveSupport whether the client supports resolving additional code lens properties via a separate `codeLens/resolve` request. + ResolveSupport *ClientCodeLensResolveOptions `json:"resolveSupport,omitempty"` } // DocumentLinkClientCapabilities the client capabilities of a DocumentLinkRequest. @@ -596,20 +628,20 @@ type RenameClientCapabilities struct { // ClientFoldingRangeKindOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientFoldingRangeKindOptions struct { // ValueSet the folding range kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. // - // @since 3.18.0 proposed + // @since 3.18.0 ValueSet []FoldingRangeKind `json:"valueSet,omitempty"` } // ClientFoldingRangeOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientFoldingRangeOptions struct { // CollapsedText if set, the client signals that it supports setting collapsedText on folding ranges to display custom labels instead of the default text. - // @since 3.18.0 proposed + // @since 3.18.0 CollapsedText bool `json:"collapsedText,omitempty"` } @@ -637,25 +669,22 @@ type SelectionRangeClientCapabilities struct { // ClientDiagnosticsTagOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientDiagnosticsTagOptions struct { // ValueSet the tags supported by the client. // - // @since 3.18.0 proposed + // @since 3.18.0 ValueSet []DiagnosticTag `json:"valueSet"` } -// PublishDiagnosticsClientCapabilities the publish diagnostic client capabilities. -type PublishDiagnosticsClientCapabilities struct { +// DiagnosticsCapabilities general diagnostics capabilities for pull and push model. +type DiagnosticsCapabilities struct { // RelatedInformation whether the clients accepts diagnostics with related information. RelatedInformation bool `json:"relatedInformation,omitempty"` // TagSupport client supports the tag property to provide meta data about a diagnostic. Clients supporting tags have to handle unknown tags gracefully. TagSupport *ClientDiagnosticsTagOptions `json:"tagSupport,omitempty"` - // VersionSupport whether the client interprets the version property of the `textDocument/publishDiagnostics` notification's parameter. - VersionSupport bool `json:"versionSupport,omitempty"` - // CodeDescriptionSupport client supports a codeDescription property CodeDescriptionSupport bool `json:"codeDescriptionSupport,omitempty"` @@ -663,6 +692,15 @@ type PublishDiagnosticsClientCapabilities struct { DataSupport bool `json:"dataSupport,omitempty"` } +// PublishDiagnosticsClientCapabilities the publish diagnostic client capabilities. +type PublishDiagnosticsClientCapabilities struct { + // extends + DiagnosticsCapabilities + + // VersionSupport whether the client interprets the version property of the `textDocument/publishDiagnostics` notification's parameter. + VersionSupport bool `json:"versionSupport,omitempty"` +} + // CallHierarchyClientCapabilities. // // @since 3.16.0 @@ -675,26 +713,26 @@ type CallHierarchyClientCapabilities struct { // ClientSemanticTokensRequestFullDelta. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientSemanticTokensRequestFullDelta struct { // Delta the client will send the `textDocument/semanticTokens/full/delta` request if the server provides a corresponding handler. // - // @since 3.18.0 proposed + // @since 3.18.0 Delta bool `json:"delta,omitempty"` } // ClientSemanticTokensRequestOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientSemanticTokensRequestOptions struct { // Range the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. // - // @since 3.18.0 proposed + // @since 3.18.0 Range ClientSemanticTokensRequestOptionsRange `json:"range,omitempty"` // Full the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. // - // @since 3.18.0 proposed + // @since 3.18.0 Full ClientSemanticTokensRequestOptionsFull `json:"full,omitempty"` } @@ -789,11 +827,11 @@ type InlineValueClientCapabilities struct { // ClientInlayHintResolveOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientInlayHintResolveOptions struct { // Properties the properties that a client can resolve lazily. // - // @since 3.18.0 proposed + // @since 3.18.0 Properties []string `json:"properties"` } @@ -816,6 +854,9 @@ type InlayHintClientCapabilities struct { // // @since 3.17.0 type DiagnosticClientCapabilities struct { + // extends + DiagnosticsCapabilities + // DynamicRegistration 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. // // @since 3.17.0 @@ -959,12 +1000,12 @@ type NotebookDocumentClientCapabilities struct { // ClientShowMessageActionItemOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientShowMessageActionItemOptions struct { // AdditionalPropertiesSupport whether the client supports additional attributes which are preserved and send back to the server in // the request's response. // - // @since 3.18.0 proposed + // @since 3.18.0 AdditionalPropertiesSupport bool `json:"additionalPropertiesSupport,omitempty"` } @@ -997,16 +1038,16 @@ type WindowClientCapabilities struct { // StaleRequestSupportOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type StaleRequestSupportOptions struct { // Cancel the client will actively cancel the request. // - // @since 3.18.0 proposed + // @since 3.18.0 Cancel bool `json:"cancel"` // RetryOnContentModified the list of requests for which the client will retry the request if it receives a response with error code `ContentModified`. // - // @since 3.18.0 proposed + // @since 3.18.0 RetryOnContentModified []string `json:"retryOnContentModified"` } @@ -1166,17 +1207,21 @@ type FileOperationOptions struct { WillDelete *FileOperationRegistrationOptions `json:"willDelete,omitempty"` } -// WorkspaceOptions defines workspace specific capabilities of the server. 3.18.0 @proposed. +// WorkspaceOptions defines workspace specific capabilities of the server. // -// @since 3.18.0 proposed +// @since 3.18.0 type WorkspaceOptions struct { // WorkspaceFolders the server supports workspace folder. - // @since 3.18.0 proposed + // @since 3.18.0 WorkspaceFolders *WorkspaceFoldersServerCapabilities `json:"workspaceFolders,omitempty"` // FileOperations the server is interested in notifications/requests for operations on files. - // @since 3.18.0 proposed + // @since 3.18.0 FileOperations *FileOperationOptions `json:"fileOperations,omitempty"` + + // TextDocumentContent the server supports the `workspace/textDocumentContent` request. 3.18.0 @proposed. + // @since 3.18.0 + TextDocumentContent WorkspaceOptionsTextDocumentContent `json:"textDocumentContent,omitempty"` } // ServerCapabilities defines the capabilities provided by a language server. @@ -1291,36 +1336,18 @@ type ServerCapabilities struct { Experimental any `json:"experimental,omitempty"` } -func (t ServerCapabilities) MarshalJSON() ([]byte, error) { - var b bytes.Buffer - buf, err := t.TextDocumentSync.MarshalJSON() - if err != nil { - return nil, err - } - b.Write(buf) - - return b.Bytes(), nil -} - -func (t *ServerCapabilities) UnmarshalJSON(x []byte) error { - if err := t.TextDocumentSync.UnmarshalJSON(x); err != nil { - return err - } - return nil -} - -// ServerInfo information about the server 3.15.0 3.18.0 ServerInfo type name added. @proposed. +// ServerInfo information about the server 3.15.0 3.18.0 ServerInfo type name added. // -// @since 3.18.0 ServerInfo type name added. proposed +// @since 3.18.0 ServerInfo type name added. type ServerInfo struct { // Name the name of the server as defined by the server. // - // @since 3.18.0 ServerInfo type name added. proposed + // @since 3.18.0 ServerInfo type name added. Name string `json:"name"` // Version the server's version as defined by the server. // - // @since 3.18.0 ServerInfo type name added. proposed + // @since 3.18.0 ServerInfo type name added. Version string `json:"version,omitempty"` } diff --git a/protocol/server.go b/protocol/server.go index 1abb8464..9664d90a 100644 --- a/protocol/server.go +++ b/protocol/server.go @@ -1916,6 +1916,21 @@ func (s *server) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolPar return result, nil } +// WorkspaceTextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +func (s *server) WorkspaceTextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (_ *TextDocumentContentResult, err error) { + s.logger.Debug("call " + MethodWorkspaceTextDocumentContent) + defer s.logger.Debug("end "+MethodWorkspaceTextDocumentContent, zap.Error(err)) + + var result *TextDocumentContentResult + if err := Call(ctx, s.Conn, MethodWorkspaceTextDocumentContent, params, &result); err != nil { + return nil, err + } + + return result, nil +} + // WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. // // The request can return a WorkspaceEdit which will be applied to workspace before the files are created. diff --git a/protocol/server_interface.go b/protocol/server_interface.go index c97e0c8e..584f549a 100644 --- a/protocol/server_interface.go +++ b/protocol/server_interface.go @@ -80,6 +80,7 @@ const ( MethodWorkspaceDiagnostic ServerMethod = "workspace/diagnostic" // server request MethodWorkspaceExecuteCommand ServerMethod = "workspace/executeCommand" // server request MethodWorkspaceSymbol ServerMethod = "workspace/symbol" // server request + MethodWorkspaceTextDocumentContent ServerMethod = "workspace/textDocumentContent" // server request MethodWorkspaceWillCreateFiles ServerMethod = "workspace/willCreateFiles" // server request MethodWorkspaceWillDeleteFiles ServerMethod = "workspace/willDeleteFiles" // server request MethodWorkspaceWillRenameFiles ServerMethod = "workspace/willRenameFiles" // server request @@ -357,6 +358,11 @@ type Server interface { // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) + // WorkspaceTextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + WorkspaceTextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) + // WorkspaceWillCreateFiles the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a `WorkspaceEdit` which will be applied to workspace before the files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file to be created. // // @since 3.16.0 @@ -664,6 +670,10 @@ func (UnimplementedServer) WorkspaceSymbol(ctx context.Context, params *Workspac return nil, jsonrpc2.ErrInternal } +func (UnimplementedServer) WorkspaceTextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) { + return nil, jsonrpc2.ErrInternal +} + func (UnimplementedServer) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) { return nil, jsonrpc2.ErrInternal } diff --git a/protocol/typealias.go b/protocol/typealias.go index ca6e6a25..4e930697 100644 --- a/protocol/typealias.go +++ b/protocol/typealias.go @@ -19,43 +19,43 @@ type NotebookDocumentFilter struct { Value any `json:"value"` } -func NewNotebookDocumentFilter[T NotebookDocumentFilterNotebookType | NotebookDocumentFilterScheme | NotebookDocumentFilterPattern](x T) NotebookDocumentFilter { +func NewNotebookDocumentFilter[T NotebookDocumentFilterNotebookType | NotebookDocumentFilterScheme | NotebookDocumentFilterPattern](val T) NotebookDocumentFilter { return NotebookDocumentFilter{ - Value: x, + Value: val, } } func (t NotebookDocumentFilter) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case NotebookDocumentFilterNotebookType: - return marshal(x) + return marshal(val) case NotebookDocumentFilterScheme: - return marshal(x) + return marshal(val) case NotebookDocumentFilterPattern: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *NotebookDocumentFilter) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *NotebookDocumentFilter) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 NotebookDocumentFilterNotebookType - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 NotebookDocumentFilterScheme - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } var h2 NotebookDocumentFilterPattern - if err := unmarshal(x, &h2); err == nil { + if err := unmarshal(val, &h2); err == nil { t.Value = h2 return nil } @@ -69,43 +69,43 @@ type TextDocumentFilter struct { Value any `json:"value"` } -func NewTextDocumentFilter[T TextDocumentFilterLanguage | TextDocumentFilterScheme | TextDocumentFilterPattern](x T) TextDocumentFilter { +func NewTextDocumentFilter[T TextDocumentFilterLanguage | TextDocumentFilterScheme | TextDocumentFilterPattern](val T) TextDocumentFilter { return TextDocumentFilter{ - Value: x, + Value: val, } } func (t TextDocumentFilter) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case TextDocumentFilterLanguage: - return marshal(x) + return marshal(val) case TextDocumentFilterScheme: - return marshal(x) + return marshal(val) case TextDocumentFilterPattern: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *TextDocumentFilter) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *TextDocumentFilter) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 TextDocumentFilterLanguage - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 TextDocumentFilterScheme - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } var h2 TextDocumentFilterPattern - if err := unmarshal(x, &h2); err == nil { + if err := unmarshal(val, &h2); err == nil { t.Value = h2 return nil } @@ -119,36 +119,36 @@ type GlobPattern struct { Value any `json:"value"` } -func NewGlobPattern[T Pattern | RelativePattern](x T) GlobPattern { +func NewGlobPattern[T Pattern | RelativePattern](val T) GlobPattern { return GlobPattern{ - Value: x, + Value: val, } } func (t GlobPattern) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case Pattern: - return marshal(x) + return marshal(val) case RelativePattern: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *GlobPattern) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *GlobPattern) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 Pattern - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 RelativePattern - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } @@ -163,36 +163,36 @@ type DocumentFilter struct { Value any `json:"value"` } -func NewDocumentFilter[T TextDocumentFilter | NotebookCellTextDocumentFilter](x T) DocumentFilter { +func NewDocumentFilter[T TextDocumentFilter | NotebookCellTextDocumentFilter](val T) DocumentFilter { return DocumentFilter{ - Value: x, + Value: val, } } func (t DocumentFilter) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case TextDocumentFilter: - return marshal(x) + return marshal(val) case NotebookCellTextDocumentFilter: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *DocumentFilter) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *DocumentFilter) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 TextDocumentFilter - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 NotebookCellTextDocumentFilter - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } @@ -205,36 +205,36 @@ type MarkedString struct { Value any `json:"value"` } -func NewMarkedString[T string | MarkedStringWithLanguage](x T) MarkedString { +func NewMarkedString[T string | MarkedStringWithLanguage](val T) MarkedString { return MarkedString{ - Value: x, + Value: val, } } func (t MarkedString) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case string: - return marshal(x) + return marshal(val) case MarkedStringWithLanguage: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *MarkedString) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *MarkedString) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 MarkedStringWithLanguage - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } @@ -246,36 +246,36 @@ type TextDocumentContentChangeEvent struct { Value any `json:"value"` } -func NewTextDocumentContentChangeEvent[T TextDocumentContentChangePartial | TextDocumentContentChangeWholeDocument](x T) TextDocumentContentChangeEvent { +func NewTextDocumentContentChangeEvent[T TextDocumentContentChangePartial | TextDocumentContentChangeWholeDocument](val T) TextDocumentContentChangeEvent { return TextDocumentContentChangeEvent{ - Value: x, + Value: val, } } func (t TextDocumentContentChangeEvent) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case TextDocumentContentChangePartial: - return marshal(x) + return marshal(val) case TextDocumentContentChangeWholeDocument: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *TextDocumentContentChangeEvent) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *TextDocumentContentChangeEvent) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 TextDocumentContentChangePartial - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 TextDocumentContentChangeWholeDocument - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } @@ -289,36 +289,36 @@ type WorkspaceDocumentDiagnosticReport struct { Value any `json:"value"` } -func NewWorkspaceDocumentDiagnosticReport[T WorkspaceFullDocumentDiagnosticReport | WorkspaceUnchangedDocumentDiagnosticReport](x T) WorkspaceDocumentDiagnosticReport { +func NewWorkspaceDocumentDiagnosticReport[T WorkspaceFullDocumentDiagnosticReport | WorkspaceUnchangedDocumentDiagnosticReport](val T) WorkspaceDocumentDiagnosticReport { return WorkspaceDocumentDiagnosticReport{ - Value: x, + Value: val, } } func (t WorkspaceDocumentDiagnosticReport) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case WorkspaceFullDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case WorkspaceUnchangedDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *WorkspaceDocumentDiagnosticReport) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *WorkspaceDocumentDiagnosticReport) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 WorkspaceFullDocumentDiagnosticReport - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 WorkspaceUnchangedDocumentDiagnosticReport - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } @@ -332,36 +332,36 @@ type ProgressToken struct { Value any `json:"value"` } -func NewProgressToken[T int32 | string](x T) ProgressToken { +func NewProgressToken[T int32 | string](val T) ProgressToken { return ProgressToken{ - Value: x, + Value: val, } } func (t ProgressToken) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case int32: - return marshal(x) + return marshal(val) case string: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *ProgressToken) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *ProgressToken) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 int32 - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 string - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } @@ -377,43 +377,43 @@ type PrepareRenameResult struct { Value any `json:"value"` } -func NewPrepareRenameResult[T Range | PrepareRenamePlaceholder | PrepareRenameDefaultBehavior](x T) PrepareRenameResult { +func NewPrepareRenameResult[T Range | PrepareRenamePlaceholder | PrepareRenameDefaultBehavior](val T) PrepareRenameResult { return PrepareRenameResult{ - Value: x, + Value: val, } } func (t PrepareRenameResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case Range: - return marshal(x) + return marshal(val) case PrepareRenamePlaceholder: - return marshal(x) + return marshal(val) case PrepareRenameDefaultBehavior: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *PrepareRenameResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *PrepareRenameResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 Range - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 PrepareRenamePlaceholder - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } var h2 PrepareRenameDefaultBehavior - if err := unmarshal(x, &h2); err == nil { + if err := unmarshal(val, &h2); err == nil { t.Value = h2 return nil } @@ -427,36 +427,36 @@ type DocumentDiagnosticReport struct { Value any `json:"value"` } -func NewDocumentDiagnosticReport[T RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport](x T) DocumentDiagnosticReport { +func NewDocumentDiagnosticReport[T RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport](val T) DocumentDiagnosticReport { return DocumentDiagnosticReport{ - Value: x, + Value: val, } } func (t DocumentDiagnosticReport) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case RelatedFullDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case RelatedUnchangedDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *DocumentDiagnosticReport) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *DocumentDiagnosticReport) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 RelatedFullDocumentDiagnosticReport - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 RelatedUnchangedDocumentDiagnosticReport - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } @@ -470,43 +470,43 @@ type InlineValue struct { Value any `json:"value"` } -func NewInlineValue[T InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression](x T) InlineValue { +func NewInlineValue[T InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression](val T) InlineValue { return InlineValue{ - Value: x, + Value: val, } } func (t InlineValue) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case InlineValueText: - return marshal(x) + return marshal(val) case InlineValueVariableLookup: - return marshal(x) + return marshal(val) case InlineValueEvaluatableExpression: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *InlineValue) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *InlineValue) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 InlineValueText - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 InlineValueVariableLookup - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } var h2 InlineValueEvaluatableExpression - if err := unmarshal(x, &h2); err == nil { + if err := unmarshal(val, &h2); err == nil { t.Value = h2 return nil } @@ -521,36 +521,36 @@ type Declaration struct { Value any `json:"value"` } -func NewDeclaration[T Location | []Location](x T) Declaration { +func NewDeclaration[T Location | []Location](val T) Declaration { return Declaration{ - Value: x, + Value: val, } } func (t Declaration) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case Location: - return marshal(x) + return marshal(val) case []Location: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *Declaration) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *Declaration) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 Location - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 []Location - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } @@ -565,36 +565,36 @@ type Definition struct { Value any `json:"value"` } -func NewDefinition[T Location | []Location](x T) Definition { +func NewDefinition[T Location | []Location](val T) Definition { return Definition{ - Value: x, + Value: val, } } func (t Definition) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.Value.(type) { case Location: - return marshal(x) + return marshal(val) case []Location: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unkonwn type: %T", t) } -func (t *Definition) UnmarshalJSON(x []byte) error { - if string(x) == "null" { +func (t *Definition) UnmarshalJSON(val []byte) error { + if string(val) == "null" { t.Value = nil return nil } var h0 Location - if err := unmarshal(x, &h0); err == nil { + if err := unmarshal(val, &h0); err == nil { t.Value = h0 return nil } var h1 []Location - if err := unmarshal(x, &h1); err == nil { + if err := unmarshal(val, &h1); err == nil { t.Value = h1 return nil } diff --git a/protocol/types_generics.go b/protocol/types_generics.go index 4a63dead..732f03fb 100644 --- a/protocol/types_generics.go +++ b/protocol/types_generics.go @@ -11,40 +11,40 @@ import ( // CancelParamsID the request id to cancel. type CancelParamsID struct { - Value any `json:"value"` + value any } -func NewCancelParamsID[T int32 | string](x T) CancelParamsID { +func NewCancelParamsID[T int32 | string](val T) CancelParamsID { return CancelParamsID{ - Value: x, + value: val, } } func (t CancelParamsID) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case int32: - return marshal(x) + return marshal(val) case string: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *CancelParamsID) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *CancelParamsID) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 int32 - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 string - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [int32 string]"} @@ -52,42 +52,42 @@ func (t *CancelParamsID) UnmarshalJSON(x []byte) error { // ClientSemanticTokensRequestOptionsFull the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientSemanticTokensRequestOptionsFull struct { - Value any `json:"value"` + value any } -func NewClientSemanticTokensRequestOptionsFull[T bool | ClientSemanticTokensRequestFullDelta](x T) ClientSemanticTokensRequestOptionsFull { - return ClientSemanticTokensRequestOptionsFull{ - Value: x, +func NewClientSemanticTokensRequestOptionsFull[T bool | ClientSemanticTokensRequestFullDelta](val T) *ClientSemanticTokensRequestOptionsFull { + return &ClientSemanticTokensRequestOptionsFull{ + value: val, } } func (t ClientSemanticTokensRequestOptionsFull) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case ClientSemanticTokensRequestFullDelta: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ClientSemanticTokensRequestOptionsFull) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ClientSemanticTokensRequestOptionsFull) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 ClientSemanticTokensRequestFullDelta - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool ClientSemanticTokensRequestFullDelta]"} @@ -95,42 +95,42 @@ func (t *ClientSemanticTokensRequestOptionsFull) UnmarshalJSON(x []byte) error { // ClientSemanticTokensRequestOptionsRange the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientSemanticTokensRequestOptionsRange struct { - Value any `json:"value"` + value any } -func NewClientSemanticTokensRequestOptionsRange[T bool | Range](x T) ClientSemanticTokensRequestOptionsRange { - return ClientSemanticTokensRequestOptionsRange{ - Value: x, +func NewClientSemanticTokensRequestOptionsRange[T bool | Range](val T) *ClientSemanticTokensRequestOptionsRange { + return &ClientSemanticTokensRequestOptionsRange{ + value: val, } } func (t ClientSemanticTokensRequestOptionsRange) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case Range: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ClientSemanticTokensRequestOptionsRange) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ClientSemanticTokensRequestOptionsRange) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 Range - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool Range]"} @@ -140,40 +140,40 @@ func (t *ClientSemanticTokensRequestOptionsRange) UnmarshalJSON(x []byte) error // // @since 3.17.0 type CompletionItemDefaultsEditRange struct { - Value any `json:"value"` + value any } -func NewCompletionItemDefaultsEditRange[T Range | EditRangeWithInsertReplace](x T) CompletionItemDefaultsEditRange { - return CompletionItemDefaultsEditRange{ - Value: x, +func NewCompletionItemDefaultsEditRange[T Range | EditRangeWithInsertReplace](val T) *CompletionItemDefaultsEditRange { + return &CompletionItemDefaultsEditRange{ + value: val, } } func (t CompletionItemDefaultsEditRange) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case Range: - return marshal(x) + return marshal(val) case EditRangeWithInsertReplace: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *CompletionItemDefaultsEditRange) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *CompletionItemDefaultsEditRange) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 Range - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 EditRangeWithInsertReplace - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [Range EditRangeWithInsertReplace]"} @@ -181,40 +181,40 @@ func (t *CompletionItemDefaultsEditRange) UnmarshalJSON(x []byte) error { // CompletionItemDocumentation a human-readable string that represents a doc-comment. type CompletionItemDocumentation struct { - Value any `json:"value"` + value any } -func NewCompletionItemDocumentation[T string | MarkupContent](x T) CompletionItemDocumentation { - return CompletionItemDocumentation{ - Value: x, +func NewCompletionItemDocumentation[T string | MarkupContent](val T) *CompletionItemDocumentation { + return &CompletionItemDocumentation{ + value: val, } } func (t CompletionItemDocumentation) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case MarkupContent: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *CompletionItemDocumentation) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *CompletionItemDocumentation) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 MarkupContent - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} @@ -222,40 +222,40 @@ func (t *CompletionItemDocumentation) UnmarshalJSON(x []byte) error { // CompletionItemTextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`. type CompletionItemTextEdit struct { - Value any `json:"value"` + value any } -func NewCompletionItemTextEdit[T TextEdit | InsertReplaceEdit](x T) CompletionItemTextEdit { - return CompletionItemTextEdit{ - Value: x, +func NewCompletionItemTextEdit[T TextEdit | InsertReplaceEdit](val T) *CompletionItemTextEdit { + return &CompletionItemTextEdit{ + value: val, } } func (t CompletionItemTextEdit) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case TextEdit: - return marshal(x) + return marshal(val) case InsertReplaceEdit: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *CompletionItemTextEdit) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *CompletionItemTextEdit) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 TextEdit - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 InsertReplaceEdit - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [TextEdit InsertReplaceEdit]"} @@ -263,80 +263,80 @@ func (t *CompletionItemTextEdit) UnmarshalJSON(x []byte) error { // DiagnosticCode the diagnostic's code, which usually appear in the user interface. type DiagnosticCode struct { - Value any `json:"value"` + value any } -func NewDiagnosticCode[T int32 | string](x T) DiagnosticCode { +func NewDiagnosticCode[T int32 | string](val T) DiagnosticCode { return DiagnosticCode{ - Value: x, + value: val, } } func (t DiagnosticCode) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case int32: - return marshal(x) + return marshal(val) case string: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *DiagnosticCode) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *DiagnosticCode) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 int32 - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 string - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [int32 string]"} } type DidChangeConfigurationRegistrationOptionsSection struct { - Value any `json:"value"` + value any } -func NewDidChangeConfigurationRegistrationOptionsSection[T string | []string](x T) DidChangeConfigurationRegistrationOptionsSection { +func NewDidChangeConfigurationRegistrationOptionsSection[T string | []string](val T) DidChangeConfigurationRegistrationOptionsSection { return DidChangeConfigurationRegistrationOptionsSection{ - Value: x, + value: val, } } func (t DidChangeConfigurationRegistrationOptionsSection) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case []string: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *DidChangeConfigurationRegistrationOptionsSection) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *DidChangeConfigurationRegistrationOptionsSection) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 []string - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string []string]"} @@ -344,40 +344,40 @@ func (t *DidChangeConfigurationRegistrationOptionsSection) UnmarshalJSON(x []byt // @since 3.17.0 type DocumentDiagnosticReportPartialResultRelatedDocuments struct { - Value any `json:"value"` + value any } -func NewDocumentDiagnosticReportPartialResultRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](x T) DocumentDiagnosticReportPartialResultRelatedDocuments { - return DocumentDiagnosticReportPartialResultRelatedDocuments{ - Value: x, +func NewDocumentDiagnosticReportPartialResultRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](val T) *DocumentDiagnosticReportPartialResultRelatedDocuments { + return &DocumentDiagnosticReportPartialResultRelatedDocuments{ + value: val, } } func (t DocumentDiagnosticReportPartialResultRelatedDocuments) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case FullDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case UnchangedDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *DocumentDiagnosticReportPartialResultRelatedDocuments) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *DocumentDiagnosticReportPartialResultRelatedDocuments) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 FullDocumentDiagnosticReport - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 UnchangedDocumentDiagnosticReport - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} @@ -385,47 +385,47 @@ func (t *DocumentDiagnosticReportPartialResultRelatedDocuments) UnmarshalJSON(x // HoverContents the hover's content. type HoverContents struct { - Value any `json:"value"` + value any } -func NewHoverContents[T MarkupContent | MarkedString | []MarkedString](x T) HoverContents { - return HoverContents{ - Value: x, +func NewHoverContents[T MarkupContent | MarkedString | []MarkedString](val T) *HoverContents { + return &HoverContents{ + value: val, } } func (t HoverContents) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case MarkupContent: - return marshal(x) + return marshal(val) case MarkedString: - return marshal(x) + return marshal(val) case []MarkedString: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *HoverContents) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *HoverContents) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 MarkupContent - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 MarkedString - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 []MarkedString - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [MarkupContent MarkedString []MarkedString]"} @@ -435,40 +435,40 @@ func (t *HoverContents) UnmarshalJSON(x []byte) error { // // @since 3.17.0 type InlayHintLabel struct { - Value any `json:"value"` + value any } -func NewInlayHintLabel[T string | []InlayHintLabelPart](x T) InlayHintLabel { +func NewInlayHintLabel[T string | []InlayHintLabelPart](val T) InlayHintLabel { return InlayHintLabel{ - Value: x, + value: val, } } func (t InlayHintLabel) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case []InlayHintLabelPart: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *InlayHintLabel) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *InlayHintLabel) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 []InlayHintLabelPart - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string []InlayHintLabelPart]"} @@ -478,40 +478,40 @@ func (t *InlayHintLabel) UnmarshalJSON(x []byte) error { // // @since 3.17.0 type InlayHintLabelPartTooltip struct { - Value any `json:"value"` + value any } -func NewInlayHintLabelPartTooltip[T string | MarkupContent](x T) InlayHintLabelPartTooltip { - return InlayHintLabelPartTooltip{ - Value: x, +func NewInlayHintLabelPartTooltip[T string | MarkupContent](val T) *InlayHintLabelPartTooltip { + return &InlayHintLabelPartTooltip{ + value: val, } } func (t InlayHintLabelPartTooltip) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case MarkupContent: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *InlayHintLabelPartTooltip) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *InlayHintLabelPartTooltip) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 MarkupContent - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} @@ -521,40 +521,40 @@ func (t *InlayHintLabelPartTooltip) UnmarshalJSON(x []byte) error { // // @since 3.17.0 type InlayHintTooltip struct { - Value any `json:"value"` + value any } -func NewInlayHintTooltip[T string | MarkupContent](x T) InlayHintTooltip { - return InlayHintTooltip{ - Value: x, +func NewInlayHintTooltip[T string | MarkupContent](val T) *InlayHintTooltip { + return &InlayHintTooltip{ + value: val, } } func (t InlayHintTooltip) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case MarkupContent: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *InlayHintTooltip) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *InlayHintTooltip) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 MarkupContent - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} @@ -564,40 +564,40 @@ func (t *InlayHintTooltip) UnmarshalJSON(x []byte) error { // // @since 3.18.0 proposed type InlineCompletionItemInsertText struct { - Value any `json:"value"` + value any } -func NewInlineCompletionItemInsertText[T string | StringValue](x T) InlineCompletionItemInsertText { - return InlineCompletionItemInsertText{ - Value: x, +func NewInlineCompletionItemInsertText[T string | StringValue](val T) *InlineCompletionItemInsertText { + return &InlineCompletionItemInsertText{ + value: val, } } func (t InlineCompletionItemInsertText) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case StringValue: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *InlineCompletionItemInsertText) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *InlineCompletionItemInsertText) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 StringValue - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string StringValue]"} @@ -607,40 +607,40 @@ func (t *InlineCompletionItemInsertText) UnmarshalJSON(x []byte) error { // // @since 3.17.0 type NotebookCellTextDocumentFilterNotebook struct { - Value any `json:"value"` + value any } -func NewNotebookCellTextDocumentFilterNotebook[T string | NotebookDocumentFilter](x T) NotebookCellTextDocumentFilterNotebook { - return NotebookCellTextDocumentFilterNotebook{ - Value: x, +func NewNotebookCellTextDocumentFilterNotebook[T string | NotebookDocumentFilter](val T) *NotebookCellTextDocumentFilterNotebook { + return &NotebookCellTextDocumentFilterNotebook{ + value: val, } } func (t NotebookCellTextDocumentFilterNotebook) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case NotebookDocumentFilter: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *NotebookCellTextDocumentFilterNotebook) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *NotebookCellTextDocumentFilterNotebook) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 NotebookDocumentFilter - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} @@ -648,42 +648,42 @@ func (t *NotebookCellTextDocumentFilterNotebook) UnmarshalJSON(x []byte) error { // NotebookDocumentFilterWithCellsNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentFilterWithCellsNotebook struct { - Value any `json:"value"` + value any } -func NewNotebookDocumentFilterWithCellsNotebook[T string | NotebookDocumentFilter](x T) NotebookDocumentFilterWithCellsNotebook { - return NotebookDocumentFilterWithCellsNotebook{ - Value: x, +func NewNotebookDocumentFilterWithCellsNotebook[T string | NotebookDocumentFilter](val T) *NotebookDocumentFilterWithCellsNotebook { + return &NotebookDocumentFilterWithCellsNotebook{ + value: val, } } func (t NotebookDocumentFilterWithCellsNotebook) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case NotebookDocumentFilter: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *NotebookDocumentFilterWithCellsNotebook) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *NotebookDocumentFilterWithCellsNotebook) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 NotebookDocumentFilter - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} @@ -691,42 +691,42 @@ func (t *NotebookDocumentFilterWithCellsNotebook) UnmarshalJSON(x []byte) error // NotebookDocumentFilterWithNotebookNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. // -// @since 3.18.0 proposed +// @since 3.18.0 type NotebookDocumentFilterWithNotebookNotebook struct { - Value any `json:"value"` + value any } -func NewNotebookDocumentFilterWithNotebookNotebook[T string | NotebookDocumentFilter](x T) NotebookDocumentFilterWithNotebookNotebook { - return NotebookDocumentFilterWithNotebookNotebook{ - Value: x, +func NewNotebookDocumentFilterWithNotebookNotebook[T string | NotebookDocumentFilter](val T) *NotebookDocumentFilterWithNotebookNotebook { + return &NotebookDocumentFilterWithNotebookNotebook{ + value: val, } } func (t NotebookDocumentFilterWithNotebookNotebook) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case NotebookDocumentFilter: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *NotebookDocumentFilterWithNotebookNotebook) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *NotebookDocumentFilterWithNotebookNotebook) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 NotebookDocumentFilter - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} @@ -736,40 +736,40 @@ func (t *NotebookDocumentFilterWithNotebookNotebook) UnmarshalJSON(x []byte) err // // @since 3.17.0 type NotebookDocumentSyncOptionsNotebookSelector struct { - Value any `json:"value"` + value any } -func NewNotebookDocumentSyncOptionsNotebookSelector[T NotebookDocumentFilterWithNotebook | NotebookDocumentFilterWithCells](x T) NotebookDocumentSyncOptionsNotebookSelector { - return NotebookDocumentSyncOptionsNotebookSelector{ - Value: x, +func NewNotebookDocumentSyncOptionsNotebookSelector[T NotebookDocumentFilterWithNotebook | NotebookDocumentFilterWithCells](val T) *NotebookDocumentSyncOptionsNotebookSelector { + return &NotebookDocumentSyncOptionsNotebookSelector{ + value: val, } } func (t NotebookDocumentSyncOptionsNotebookSelector) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case NotebookDocumentFilterWithNotebook: - return marshal(x) + return marshal(val) case NotebookDocumentFilterWithCells: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *NotebookDocumentSyncOptionsNotebookSelector) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *NotebookDocumentSyncOptionsNotebookSelector) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 NotebookDocumentFilterWithNotebook - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 NotebookDocumentFilterWithCells - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [NotebookDocumentFilterWithNotebook NotebookDocumentFilterWithCells]"} @@ -777,40 +777,40 @@ func (t *NotebookDocumentSyncOptionsNotebookSelector) UnmarshalJSON(x []byte) er // ParameterInformationDocumentation the human-readable doc-comment of this parameter. Will be shown in the UI but can be omitted. type ParameterInformationDocumentation struct { - Value any `json:"value"` + value any } -func NewParameterInformationDocumentation[T string | MarkupContent](x T) ParameterInformationDocumentation { - return ParameterInformationDocumentation{ - Value: x, +func NewParameterInformationDocumentation[T string | MarkupContent](val T) *ParameterInformationDocumentation { + return &ParameterInformationDocumentation{ + value: val, } } func (t ParameterInformationDocumentation) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case MarkupContent: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ParameterInformationDocumentation) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ParameterInformationDocumentation) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 MarkupContent - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} @@ -819,40 +819,40 @@ func (t *ParameterInformationDocumentation) UnmarshalJSON(x []byte) error { // ParameterInformationLabel the label of this parameter information. Either a string or an inclusive start and exclusive end offsets within its containing signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 string representation as `Position` and `Range` does. To avoid ambiguities a server should use the [start, end] offset value instead of using a substring. Whether a client support this is controlled via `labelOffsetSupport` client capability. *Note*: a label of type string should be a substring of its containing signature label. Its intended use case is to highlight the parameter label // part in the `SignatureInformation.label`. type ParameterInformationLabel struct { - Value any `json:"value"` + value any } -func NewParameterInformationLabel[T string | uint32](x T) ParameterInformationLabel { - return ParameterInformationLabel{ - Value: x, +func NewParameterInformationLabel[T string | uint32](val T) *ParameterInformationLabel { + return &ParameterInformationLabel{ + value: val, } } func (t ParameterInformationLabel) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case uint32: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ParameterInformationLabel) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ParameterInformationLabel) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 uint32 - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string uint32]"} @@ -862,40 +862,40 @@ func (t *ParameterInformationLabel) UnmarshalJSON(x []byte) error { // // @since 3.17.0 type RelatedFullDocumentDiagnosticReportRelatedDocuments struct { - Value any `json:"value"` + value any } -func NewRelatedFullDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](x T) RelatedFullDocumentDiagnosticReportRelatedDocuments { - return RelatedFullDocumentDiagnosticReportRelatedDocuments{ - Value: x, +func NewRelatedFullDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](val T) *RelatedFullDocumentDiagnosticReportRelatedDocuments { + return &RelatedFullDocumentDiagnosticReportRelatedDocuments{ + value: val, } } func (t RelatedFullDocumentDiagnosticReportRelatedDocuments) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case FullDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case UnchangedDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *RelatedFullDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *RelatedFullDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 FullDocumentDiagnosticReport - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 UnchangedDocumentDiagnosticReport - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} @@ -905,40 +905,40 @@ func (t *RelatedFullDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(x [] // // @since 3.17.0 type RelatedUnchangedDocumentDiagnosticReportRelatedDocuments struct { - Value any `json:"value"` + value any } -func NewRelatedUnchangedDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](x T) RelatedUnchangedDocumentDiagnosticReportRelatedDocuments { - return RelatedUnchangedDocumentDiagnosticReportRelatedDocuments{ - Value: x, +func NewRelatedUnchangedDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](val T) *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments { + return &RelatedUnchangedDocumentDiagnosticReportRelatedDocuments{ + value: val, } } func (t RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case FullDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case UnchangedDocumentDiagnosticReport: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 FullDocumentDiagnosticReport - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 UnchangedDocumentDiagnosticReport - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} @@ -948,40 +948,40 @@ func (t *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON // // @since 3.17.0 type RelativePatternBaseURI struct { - Value any `json:"value"` + value any } -func NewRelativePatternBaseURI[T WorkspaceFolder | uri.URI](x T) RelativePatternBaseURI { - return RelativePatternBaseURI{ - Value: x, +func NewRelativePatternBaseURI[T WorkspaceFolder | uri.URI](val T) *RelativePatternBaseURI { + return &RelativePatternBaseURI{ + value: val, } } func (t RelativePatternBaseURI) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case WorkspaceFolder: - return marshal(x) + return marshal(val) case uri.URI: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *RelativePatternBaseURI) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *RelativePatternBaseURI) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 WorkspaceFolder - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 uri.URI - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [WorkspaceFolder uri.URI]"} @@ -991,40 +991,40 @@ func (t *RelativePatternBaseURI) UnmarshalJSON(x []byte) error { // // @since 3.16.0 type SemanticTokensOptionsFull struct { - Value any `json:"value"` + value any } -func NewSemanticTokensOptionsFull[T bool | SemanticTokensFullDelta](x T) SemanticTokensOptionsFull { - return SemanticTokensOptionsFull{ - Value: x, +func NewSemanticTokensOptionsFull[T bool | SemanticTokensFullDelta](val T) *SemanticTokensOptionsFull { + return &SemanticTokensOptionsFull{ + value: val, } } func (t SemanticTokensOptionsFull) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case SemanticTokensFullDelta: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *SemanticTokensOptionsFull) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *SemanticTokensOptionsFull) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 SemanticTokensFullDelta - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool SemanticTokensFullDelta]"} @@ -1034,40 +1034,40 @@ func (t *SemanticTokensOptionsFull) UnmarshalJSON(x []byte) error { // // @since 3.16.0 type SemanticTokensOptionsRange struct { - Value any `json:"value"` + value any } -func NewSemanticTokensOptionsRange[T bool | Range](x T) SemanticTokensOptionsRange { - return SemanticTokensOptionsRange{ - Value: x, +func NewSemanticTokensOptionsRange[T bool | Range](val T) *SemanticTokensOptionsRange { + return &SemanticTokensOptionsRange{ + value: val, } } func (t SemanticTokensOptionsRange) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case Range: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *SemanticTokensOptionsRange) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *SemanticTokensOptionsRange) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 Range - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool Range]"} @@ -1075,47 +1075,47 @@ func (t *SemanticTokensOptionsRange) UnmarshalJSON(x []byte) error { // ServerCapabilitiesCallHierarchyProvider the server provides call hierarchy support. type ServerCapabilitiesCallHierarchyProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesCallHierarchyProvider[T bool | CallHierarchyOptions | CallHierarchyRegistrationOptions](x T) ServerCapabilitiesCallHierarchyProvider { - return ServerCapabilitiesCallHierarchyProvider{ - Value: x, +func NewServerCapabilitiesCallHierarchyProvider[T bool | CallHierarchyOptions | CallHierarchyRegistrationOptions](val T) *ServerCapabilitiesCallHierarchyProvider { + return &ServerCapabilitiesCallHierarchyProvider{ + value: val, } } func (t ServerCapabilitiesCallHierarchyProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case CallHierarchyOptions: - return marshal(x) + return marshal(val) case CallHierarchyRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesCallHierarchyProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesCallHierarchyProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 CallHierarchyOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 CallHierarchyRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool CallHierarchyOptions CallHierarchyRegistrationOptions]"} @@ -1123,40 +1123,40 @@ func (t *ServerCapabilitiesCallHierarchyProvider) UnmarshalJSON(x []byte) error // ServerCapabilitiesCodeActionProvider the server provides code actions. CodeActionOptions may only be specified if the client states that it supports `codeActionLiteralSupport` in its initial `initialize` request. type ServerCapabilitiesCodeActionProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesCodeActionProvider[T bool | CodeActionOptions](x T) ServerCapabilitiesCodeActionProvider { - return ServerCapabilitiesCodeActionProvider{ - Value: x, +func NewServerCapabilitiesCodeActionProvider[T bool | CodeActionOptions](val T) *ServerCapabilitiesCodeActionProvider { + return &ServerCapabilitiesCodeActionProvider{ + value: val, } } func (t ServerCapabilitiesCodeActionProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case CodeActionOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesCodeActionProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesCodeActionProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 CodeActionOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool CodeActionOptions]"} @@ -1164,47 +1164,47 @@ func (t *ServerCapabilitiesCodeActionProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesColorProvider the server provides color provider support. type ServerCapabilitiesColorProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesColorProvider[T bool | DocumentColorOptions | DocumentColorRegistrationOptions](x T) ServerCapabilitiesColorProvider { - return ServerCapabilitiesColorProvider{ - Value: x, +func NewServerCapabilitiesColorProvider[T bool | DocumentColorOptions | DocumentColorRegistrationOptions](val T) *ServerCapabilitiesColorProvider { + return &ServerCapabilitiesColorProvider{ + value: val, } } func (t ServerCapabilitiesColorProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case DocumentColorOptions: - return marshal(x) + return marshal(val) case DocumentColorRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesColorProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesColorProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 DocumentColorOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 DocumentColorRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool DocumentColorOptions DocumentColorRegistrationOptions]"} @@ -1212,47 +1212,47 @@ func (t *ServerCapabilitiesColorProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesDeclarationProvider the server provides Goto Declaration support. type ServerCapabilitiesDeclarationProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesDeclarationProvider[T bool | DeclarationOptions | DeclarationRegistrationOptions](x T) ServerCapabilitiesDeclarationProvider { - return ServerCapabilitiesDeclarationProvider{ - Value: x, +func NewServerCapabilitiesDeclarationProvider[T bool | DeclarationOptions | DeclarationRegistrationOptions](val T) *ServerCapabilitiesDeclarationProvider { + return &ServerCapabilitiesDeclarationProvider{ + value: val, } } func (t ServerCapabilitiesDeclarationProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case DeclarationOptions: - return marshal(x) + return marshal(val) case DeclarationRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesDeclarationProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesDeclarationProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 DeclarationOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 DeclarationRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool DeclarationOptions DeclarationRegistrationOptions]"} @@ -1260,40 +1260,40 @@ func (t *ServerCapabilitiesDeclarationProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesDefinitionProvider the server provides goto definition support. type ServerCapabilitiesDefinitionProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesDefinitionProvider[T bool | DefinitionOptions](x T) ServerCapabilitiesDefinitionProvider { - return ServerCapabilitiesDefinitionProvider{ - Value: x, +func NewServerCapabilitiesDefinitionProvider[T bool | DefinitionOptions](val T) *ServerCapabilitiesDefinitionProvider { + return &ServerCapabilitiesDefinitionProvider{ + value: val, } } func (t ServerCapabilitiesDefinitionProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case DefinitionOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesDefinitionProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesDefinitionProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 DefinitionOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool DefinitionOptions]"} @@ -1301,40 +1301,40 @@ func (t *ServerCapabilitiesDefinitionProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesDiagnosticProvider the server has support for pull model diagnostics. type ServerCapabilitiesDiagnosticProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesDiagnosticProvider[T DiagnosticOptions | DiagnosticRegistrationOptions](x T) ServerCapabilitiesDiagnosticProvider { - return ServerCapabilitiesDiagnosticProvider{ - Value: x, +func NewServerCapabilitiesDiagnosticProvider[T DiagnosticOptions | DiagnosticRegistrationOptions](val T) *ServerCapabilitiesDiagnosticProvider { + return &ServerCapabilitiesDiagnosticProvider{ + value: val, } } func (t ServerCapabilitiesDiagnosticProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case DiagnosticOptions: - return marshal(x) + return marshal(val) case DiagnosticRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesDiagnosticProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesDiagnosticProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 DiagnosticOptions - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 DiagnosticRegistrationOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [DiagnosticOptions DiagnosticRegistrationOptions]"} @@ -1342,40 +1342,40 @@ func (t *ServerCapabilitiesDiagnosticProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesDocumentFormattingProvider the server provides document formatting. type ServerCapabilitiesDocumentFormattingProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesDocumentFormattingProvider[T bool | DocumentFormattingOptions](x T) ServerCapabilitiesDocumentFormattingProvider { - return ServerCapabilitiesDocumentFormattingProvider{ - Value: x, +func NewServerCapabilitiesDocumentFormattingProvider[T bool | DocumentFormattingOptions](val T) *ServerCapabilitiesDocumentFormattingProvider { + return &ServerCapabilitiesDocumentFormattingProvider{ + value: val, } } func (t ServerCapabilitiesDocumentFormattingProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case DocumentFormattingOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesDocumentFormattingProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesDocumentFormattingProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 DocumentFormattingOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool DocumentFormattingOptions]"} @@ -1383,40 +1383,40 @@ func (t *ServerCapabilitiesDocumentFormattingProvider) UnmarshalJSON(x []byte) e // ServerCapabilitiesDocumentHighlightProvider the server provides document highlight support. type ServerCapabilitiesDocumentHighlightProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesDocumentHighlightProvider[T bool | DocumentHighlightOptions](x T) ServerCapabilitiesDocumentHighlightProvider { - return ServerCapabilitiesDocumentHighlightProvider{ - Value: x, +func NewServerCapabilitiesDocumentHighlightProvider[T bool | DocumentHighlightOptions](val T) *ServerCapabilitiesDocumentHighlightProvider { + return &ServerCapabilitiesDocumentHighlightProvider{ + value: val, } } func (t ServerCapabilitiesDocumentHighlightProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case DocumentHighlightOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesDocumentHighlightProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesDocumentHighlightProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 DocumentHighlightOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool DocumentHighlightOptions]"} @@ -1424,40 +1424,40 @@ func (t *ServerCapabilitiesDocumentHighlightProvider) UnmarshalJSON(x []byte) er // ServerCapabilitiesDocumentRangeFormattingProvider the server provides document range formatting. type ServerCapabilitiesDocumentRangeFormattingProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesDocumentRangeFormattingProvider[T bool | DocumentRangeFormattingOptions](x T) ServerCapabilitiesDocumentRangeFormattingProvider { - return ServerCapabilitiesDocumentRangeFormattingProvider{ - Value: x, +func NewServerCapabilitiesDocumentRangeFormattingProvider[T bool | DocumentRangeFormattingOptions](val T) *ServerCapabilitiesDocumentRangeFormattingProvider { + return &ServerCapabilitiesDocumentRangeFormattingProvider{ + value: val, } } func (t ServerCapabilitiesDocumentRangeFormattingProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case DocumentRangeFormattingOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesDocumentRangeFormattingProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesDocumentRangeFormattingProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 DocumentRangeFormattingOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool DocumentRangeFormattingOptions]"} @@ -1465,40 +1465,40 @@ func (t *ServerCapabilitiesDocumentRangeFormattingProvider) UnmarshalJSON(x []by // ServerCapabilitiesDocumentSymbolProvider the server provides document symbol support. type ServerCapabilitiesDocumentSymbolProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesDocumentSymbolProvider[T bool | DocumentSymbolOptions](x T) ServerCapabilitiesDocumentSymbolProvider { - return ServerCapabilitiesDocumentSymbolProvider{ - Value: x, +func NewServerCapabilitiesDocumentSymbolProvider[T bool | DocumentSymbolOptions](val T) *ServerCapabilitiesDocumentSymbolProvider { + return &ServerCapabilitiesDocumentSymbolProvider{ + value: val, } } func (t ServerCapabilitiesDocumentSymbolProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case DocumentSymbolOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesDocumentSymbolProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesDocumentSymbolProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 DocumentSymbolOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool DocumentSymbolOptions]"} @@ -1506,47 +1506,47 @@ func (t *ServerCapabilitiesDocumentSymbolProvider) UnmarshalJSON(x []byte) error // ServerCapabilitiesFoldingRangeProvider the server provides folding provider support. type ServerCapabilitiesFoldingRangeProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesFoldingRangeProvider[T bool | FoldingRangeOptions | FoldingRangeRegistrationOptions](x T) ServerCapabilitiesFoldingRangeProvider { - return ServerCapabilitiesFoldingRangeProvider{ - Value: x, +func NewServerCapabilitiesFoldingRangeProvider[T bool | FoldingRangeOptions | FoldingRangeRegistrationOptions](val T) *ServerCapabilitiesFoldingRangeProvider { + return &ServerCapabilitiesFoldingRangeProvider{ + value: val, } } func (t ServerCapabilitiesFoldingRangeProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case FoldingRangeOptions: - return marshal(x) + return marshal(val) case FoldingRangeRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesFoldingRangeProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesFoldingRangeProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 FoldingRangeOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 FoldingRangeRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool FoldingRangeOptions FoldingRangeRegistrationOptions]"} @@ -1554,40 +1554,40 @@ func (t *ServerCapabilitiesFoldingRangeProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesHoverProvider the server provides hover support. type ServerCapabilitiesHoverProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesHoverProvider[T bool | HoverOptions](x T) ServerCapabilitiesHoverProvider { - return ServerCapabilitiesHoverProvider{ - Value: x, +func NewServerCapabilitiesHoverProvider[T bool | HoverOptions](val T) *ServerCapabilitiesHoverProvider { + return &ServerCapabilitiesHoverProvider{ + value: val, } } func (t ServerCapabilitiesHoverProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case HoverOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesHoverProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesHoverProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 HoverOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool HoverOptions]"} @@ -1595,47 +1595,47 @@ func (t *ServerCapabilitiesHoverProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesImplementationProvider the server provides Goto Implementation support. type ServerCapabilitiesImplementationProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesImplementationProvider[T bool | ImplementationOptions | ImplementationRegistrationOptions](x T) ServerCapabilitiesImplementationProvider { - return ServerCapabilitiesImplementationProvider{ - Value: x, +func NewServerCapabilitiesImplementationProvider[T bool | ImplementationOptions | ImplementationRegistrationOptions](val T) *ServerCapabilitiesImplementationProvider { + return &ServerCapabilitiesImplementationProvider{ + value: val, } } func (t ServerCapabilitiesImplementationProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case ImplementationOptions: - return marshal(x) + return marshal(val) case ImplementationRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesImplementationProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesImplementationProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 ImplementationOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 ImplementationRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool ImplementationOptions ImplementationRegistrationOptions]"} @@ -1643,47 +1643,47 @@ func (t *ServerCapabilitiesImplementationProvider) UnmarshalJSON(x []byte) error // ServerCapabilitiesInlayHintProvider the server provides inlay hints. type ServerCapabilitiesInlayHintProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesInlayHintProvider[T bool | InlayHintOptions | InlayHintRegistrationOptions](x T) ServerCapabilitiesInlayHintProvider { - return ServerCapabilitiesInlayHintProvider{ - Value: x, +func NewServerCapabilitiesInlayHintProvider[T bool | InlayHintOptions | InlayHintRegistrationOptions](val T) *ServerCapabilitiesInlayHintProvider { + return &ServerCapabilitiesInlayHintProvider{ + value: val, } } func (t ServerCapabilitiesInlayHintProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case InlayHintOptions: - return marshal(x) + return marshal(val) case InlayHintRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesInlayHintProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesInlayHintProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 InlayHintOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 InlayHintRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool InlayHintOptions InlayHintRegistrationOptions]"} @@ -1691,40 +1691,40 @@ func (t *ServerCapabilitiesInlayHintProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesInlineCompletionProvider inline completion options used during static registration. 3.18.0 @proposed. type ServerCapabilitiesInlineCompletionProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesInlineCompletionProvider[T bool | InlineCompletionOptions](x T) ServerCapabilitiesInlineCompletionProvider { - return ServerCapabilitiesInlineCompletionProvider{ - Value: x, +func NewServerCapabilitiesInlineCompletionProvider[T bool | InlineCompletionOptions](val T) *ServerCapabilitiesInlineCompletionProvider { + return &ServerCapabilitiesInlineCompletionProvider{ + value: val, } } func (t ServerCapabilitiesInlineCompletionProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case InlineCompletionOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesInlineCompletionProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesInlineCompletionProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 InlineCompletionOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool InlineCompletionOptions]"} @@ -1732,47 +1732,47 @@ func (t *ServerCapabilitiesInlineCompletionProvider) UnmarshalJSON(x []byte) err // ServerCapabilitiesInlineValueProvider the server provides inline values. type ServerCapabilitiesInlineValueProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesInlineValueProvider[T bool | InlineValueOptions | InlineValueRegistrationOptions](x T) ServerCapabilitiesInlineValueProvider { - return ServerCapabilitiesInlineValueProvider{ - Value: x, +func NewServerCapabilitiesInlineValueProvider[T bool | InlineValueOptions | InlineValueRegistrationOptions](val T) *ServerCapabilitiesInlineValueProvider { + return &ServerCapabilitiesInlineValueProvider{ + value: val, } } func (t ServerCapabilitiesInlineValueProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case InlineValueOptions: - return marshal(x) + return marshal(val) case InlineValueRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesInlineValueProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesInlineValueProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 InlineValueOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 InlineValueRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool InlineValueOptions InlineValueRegistrationOptions]"} @@ -1780,47 +1780,47 @@ func (t *ServerCapabilitiesInlineValueProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesLinkedEditingRangeProvider the server provides linked editing range support. type ServerCapabilitiesLinkedEditingRangeProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesLinkedEditingRangeProvider[T bool | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions](x T) ServerCapabilitiesLinkedEditingRangeProvider { - return ServerCapabilitiesLinkedEditingRangeProvider{ - Value: x, +func NewServerCapabilitiesLinkedEditingRangeProvider[T bool | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions](val T) *ServerCapabilitiesLinkedEditingRangeProvider { + return &ServerCapabilitiesLinkedEditingRangeProvider{ + value: val, } } func (t ServerCapabilitiesLinkedEditingRangeProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case LinkedEditingRangeOptions: - return marshal(x) + return marshal(val) case LinkedEditingRangeRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesLinkedEditingRangeProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesLinkedEditingRangeProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 LinkedEditingRangeOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 LinkedEditingRangeRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool LinkedEditingRangeOptions LinkedEditingRangeRegistrationOptions]"} @@ -1828,47 +1828,47 @@ func (t *ServerCapabilitiesLinkedEditingRangeProvider) UnmarshalJSON(x []byte) e // ServerCapabilitiesMonikerProvider the server provides moniker support. type ServerCapabilitiesMonikerProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesMonikerProvider[T bool | MonikerOptions | MonikerRegistrationOptions](x T) ServerCapabilitiesMonikerProvider { - return ServerCapabilitiesMonikerProvider{ - Value: x, +func NewServerCapabilitiesMonikerProvider[T bool | MonikerOptions | MonikerRegistrationOptions](val T) *ServerCapabilitiesMonikerProvider { + return &ServerCapabilitiesMonikerProvider{ + value: val, } } func (t ServerCapabilitiesMonikerProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case MonikerOptions: - return marshal(x) + return marshal(val) case MonikerRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesMonikerProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesMonikerProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 MonikerOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 MonikerRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool MonikerOptions MonikerRegistrationOptions]"} @@ -1876,40 +1876,40 @@ func (t *ServerCapabilitiesMonikerProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesNotebookDocumentSync defines how notebook documents are synced. type ServerCapabilitiesNotebookDocumentSync struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesNotebookDocumentSync[T NotebookDocumentSyncOptions | NotebookDocumentSyncRegistrationOptions](x T) ServerCapabilitiesNotebookDocumentSync { - return ServerCapabilitiesNotebookDocumentSync{ - Value: x, +func NewServerCapabilitiesNotebookDocumentSync[T NotebookDocumentSyncOptions | NotebookDocumentSyncRegistrationOptions](val T) *ServerCapabilitiesNotebookDocumentSync { + return &ServerCapabilitiesNotebookDocumentSync{ + value: val, } } func (t ServerCapabilitiesNotebookDocumentSync) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case NotebookDocumentSyncOptions: - return marshal(x) + return marshal(val) case NotebookDocumentSyncRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesNotebookDocumentSync) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesNotebookDocumentSync) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 NotebookDocumentSyncOptions - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 NotebookDocumentSyncRegistrationOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [NotebookDocumentSyncOptions NotebookDocumentSyncRegistrationOptions]"} @@ -1917,40 +1917,40 @@ func (t *ServerCapabilitiesNotebookDocumentSync) UnmarshalJSON(x []byte) error { // ServerCapabilitiesReferencesProvider the server provides find references support. type ServerCapabilitiesReferencesProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesReferencesProvider[T bool | ReferenceOptions](x T) ServerCapabilitiesReferencesProvider { - return ServerCapabilitiesReferencesProvider{ - Value: x, +func NewServerCapabilitiesReferencesProvider[T bool | ReferenceOptions](val T) *ServerCapabilitiesReferencesProvider { + return &ServerCapabilitiesReferencesProvider{ + value: val, } } func (t ServerCapabilitiesReferencesProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case ReferenceOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesReferencesProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesReferencesProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 ReferenceOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool ReferenceOptions]"} @@ -1959,40 +1959,40 @@ func (t *ServerCapabilitiesReferencesProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesRenameProvider the server provides rename support. RenameOptions may only be specified if the client states that it // supports `prepareSupport` in its initial `initialize` request. type ServerCapabilitiesRenameProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesRenameProvider[T bool | RenameOptions](x T) ServerCapabilitiesRenameProvider { - return ServerCapabilitiesRenameProvider{ - Value: x, +func NewServerCapabilitiesRenameProvider[T bool | RenameOptions](val T) *ServerCapabilitiesRenameProvider { + return &ServerCapabilitiesRenameProvider{ + value: val, } } func (t ServerCapabilitiesRenameProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case RenameOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesRenameProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesRenameProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 RenameOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool RenameOptions]"} @@ -2000,47 +2000,47 @@ func (t *ServerCapabilitiesRenameProvider) UnmarshalJSON(x []byte) error { // ServerCapabilitiesSelectionRangeProvider the server provides selection range support. type ServerCapabilitiesSelectionRangeProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesSelectionRangeProvider[T bool | SelectionRangeOptions | SelectionRangeRegistrationOptions](x T) ServerCapabilitiesSelectionRangeProvider { - return ServerCapabilitiesSelectionRangeProvider{ - Value: x, +func NewServerCapabilitiesSelectionRangeProvider[T bool | SelectionRangeOptions | SelectionRangeRegistrationOptions](val T) *ServerCapabilitiesSelectionRangeProvider { + return &ServerCapabilitiesSelectionRangeProvider{ + value: val, } } func (t ServerCapabilitiesSelectionRangeProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case SelectionRangeOptions: - return marshal(x) + return marshal(val) case SelectionRangeRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesSelectionRangeProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesSelectionRangeProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 SelectionRangeOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 SelectionRangeRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool SelectionRangeOptions SelectionRangeRegistrationOptions]"} @@ -2048,40 +2048,40 @@ func (t *ServerCapabilitiesSelectionRangeProvider) UnmarshalJSON(x []byte) error // ServerCapabilitiesSemanticTokensProvider the server provides semantic tokens support. type ServerCapabilitiesSemanticTokensProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesSemanticTokensProvider[T SemanticTokensOptions | SemanticTokensRegistrationOptions](x T) ServerCapabilitiesSemanticTokensProvider { - return ServerCapabilitiesSemanticTokensProvider{ - Value: x, +func NewServerCapabilitiesSemanticTokensProvider[T SemanticTokensOptions | SemanticTokensRegistrationOptions](val T) *ServerCapabilitiesSemanticTokensProvider { + return &ServerCapabilitiesSemanticTokensProvider{ + value: val, } } func (t ServerCapabilitiesSemanticTokensProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case SemanticTokensOptions: - return marshal(x) + return marshal(val) case SemanticTokensRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesSemanticTokensProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesSemanticTokensProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 SemanticTokensOptions - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 SemanticTokensRegistrationOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [SemanticTokensOptions SemanticTokensRegistrationOptions]"} @@ -2089,40 +2089,40 @@ func (t *ServerCapabilitiesSemanticTokensProvider) UnmarshalJSON(x []byte) error // ServerCapabilitiesTextDocumentSync defines how text documents are synced. Is either a detailed structure defining each notification or for backwards compatibility the TextDocumentSyncKind number. type ServerCapabilitiesTextDocumentSync struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesTextDocumentSync[T TextDocumentSyncOptions | TextDocumentSyncKind](x T) ServerCapabilitiesTextDocumentSync { - return ServerCapabilitiesTextDocumentSync{ - Value: x, +func NewServerCapabilitiesTextDocumentSync[T TextDocumentSyncOptions | TextDocumentSyncKind](val T) *ServerCapabilitiesTextDocumentSync { + return &ServerCapabilitiesTextDocumentSync{ + value: val, } } func (t ServerCapabilitiesTextDocumentSync) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case TextDocumentSyncOptions: - return marshal(x) + return marshal(val) case TextDocumentSyncKind: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesTextDocumentSync) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesTextDocumentSync) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 TextDocumentSyncOptions - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 TextDocumentSyncKind - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [TextDocumentSyncOptions TextDocumentSyncKind]"} @@ -2130,47 +2130,47 @@ func (t *ServerCapabilitiesTextDocumentSync) UnmarshalJSON(x []byte) error { // ServerCapabilitiesTypeDefinitionProvider the server provides Goto Type Definition support. type ServerCapabilitiesTypeDefinitionProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesTypeDefinitionProvider[T bool | TypeDefinitionOptions | TypeDefinitionRegistrationOptions](x T) ServerCapabilitiesTypeDefinitionProvider { - return ServerCapabilitiesTypeDefinitionProvider{ - Value: x, +func NewServerCapabilitiesTypeDefinitionProvider[T bool | TypeDefinitionOptions | TypeDefinitionRegistrationOptions](val T) *ServerCapabilitiesTypeDefinitionProvider { + return &ServerCapabilitiesTypeDefinitionProvider{ + value: val, } } func (t ServerCapabilitiesTypeDefinitionProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case TypeDefinitionOptions: - return marshal(x) + return marshal(val) case TypeDefinitionRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesTypeDefinitionProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesTypeDefinitionProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 TypeDefinitionOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 TypeDefinitionRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool TypeDefinitionOptions TypeDefinitionRegistrationOptions]"} @@ -2178,47 +2178,47 @@ func (t *ServerCapabilitiesTypeDefinitionProvider) UnmarshalJSON(x []byte) error // ServerCapabilitiesTypeHierarchyProvider the server provides type hierarchy support. type ServerCapabilitiesTypeHierarchyProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesTypeHierarchyProvider[T bool | TypeHierarchyOptions | TypeHierarchyRegistrationOptions](x T) ServerCapabilitiesTypeHierarchyProvider { - return ServerCapabilitiesTypeHierarchyProvider{ - Value: x, +func NewServerCapabilitiesTypeHierarchyProvider[T bool | TypeHierarchyOptions | TypeHierarchyRegistrationOptions](val T) *ServerCapabilitiesTypeHierarchyProvider { + return &ServerCapabilitiesTypeHierarchyProvider{ + value: val, } } func (t ServerCapabilitiesTypeHierarchyProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case TypeHierarchyOptions: - return marshal(x) + return marshal(val) case TypeHierarchyRegistrationOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesTypeHierarchyProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesTypeHierarchyProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 TypeHierarchyOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 TypeHierarchyRegistrationOptions - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool TypeHierarchyOptions TypeHierarchyRegistrationOptions]"} @@ -2226,40 +2226,40 @@ func (t *ServerCapabilitiesTypeHierarchyProvider) UnmarshalJSON(x []byte) error // ServerCapabilitiesWorkspaceSymbolProvider the server provides workspace symbol support. type ServerCapabilitiesWorkspaceSymbolProvider struct { - Value any `json:"value"` + value any } -func NewServerCapabilitiesWorkspaceSymbolProvider[T bool | WorkspaceSymbolOptions](x T) ServerCapabilitiesWorkspaceSymbolProvider { - return ServerCapabilitiesWorkspaceSymbolProvider{ - Value: x, +func NewServerCapabilitiesWorkspaceSymbolProvider[T bool | WorkspaceSymbolOptions](val T) *ServerCapabilitiesWorkspaceSymbolProvider { + return &ServerCapabilitiesWorkspaceSymbolProvider{ + value: val, } } func (t ServerCapabilitiesWorkspaceSymbolProvider) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case WorkspaceSymbolOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *ServerCapabilitiesWorkspaceSymbolProvider) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *ServerCapabilitiesWorkspaceSymbolProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 WorkspaceSymbolOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool WorkspaceSymbolOptions]"} @@ -2267,40 +2267,40 @@ func (t *ServerCapabilitiesWorkspaceSymbolProvider) UnmarshalJSON(x []byte) erro // SignatureInformationDocumentation the human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. type SignatureInformationDocumentation struct { - Value any `json:"value"` + value any } -func NewSignatureInformationDocumentation[T string | MarkupContent](x T) SignatureInformationDocumentation { - return SignatureInformationDocumentation{ - Value: x, +func NewSignatureInformationDocumentation[T string | MarkupContent](val T) *SignatureInformationDocumentation { + return &SignatureInformationDocumentation{ + value: val, } } func (t SignatureInformationDocumentation) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case MarkupContent: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *SignatureInformationDocumentation) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *SignatureInformationDocumentation) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 MarkupContent - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} @@ -2308,40 +2308,40 @@ func (t *SignatureInformationDocumentation) UnmarshalJSON(x []byte) error { // TextDocumentCodeActionResult a request to provide commands for the given text document and range. type TextDocumentCodeActionResult struct { - Value any `json:"value"` + value any } -func NewTextDocumentCodeActionResult[T Command | CodeAction](x T) TextDocumentCodeActionResult { - return TextDocumentCodeActionResult{ - Value: x, +func NewTextDocumentCodeActionResult[T Command | CodeAction](val T) *TextDocumentCodeActionResult { + return &TextDocumentCodeActionResult{ + value: val, } } func (t TextDocumentCodeActionResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case Command: - return marshal(x) + return marshal(val) case CodeAction: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentCodeActionResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentCodeActionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 Command - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 CodeAction - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} @@ -2350,40 +2350,40 @@ func (t *TextDocumentCodeActionResult) UnmarshalJSON(x []byte) error { // TextDocumentCompletionResult request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, // `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. type TextDocumentCompletionResult struct { - Value any `json:"value"` + value any } -func NewTextDocumentCompletionResult[T []CompletionItem | CompletionList](x T) TextDocumentCompletionResult { - return TextDocumentCompletionResult{ - Value: x, +func NewTextDocumentCompletionResult[T []CompletionItem | CompletionList](val T) *TextDocumentCompletionResult { + return &TextDocumentCompletionResult{ + value: val, } } func (t TextDocumentCompletionResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case []CompletionItem: - return marshal(x) + return marshal(val) case CompletionList: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentCompletionResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentCompletionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 []CompletionItem - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 CompletionList - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} @@ -2392,40 +2392,40 @@ func (t *TextDocumentCompletionResult) UnmarshalJSON(x []byte) error { // TextDocumentDeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a // typed array of DeclarationLink or a Thenable that resolves to such. type TextDocumentDeclarationResult struct { - Value any `json:"value"` + value any } -func NewTextDocumentDeclarationResult[T Declaration | []DeclarationLink](x T) TextDocumentDeclarationResult { - return TextDocumentDeclarationResult{ - Value: x, +func NewTextDocumentDeclarationResult[T Declaration | []DeclarationLink](val T) *TextDocumentDeclarationResult { + return &TextDocumentDeclarationResult{ + value: val, } } func (t TextDocumentDeclarationResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case Declaration: - return marshal(x) + return marshal(val) case []DeclarationLink: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentDeclarationResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentDeclarationResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 Declaration - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 []DeclarationLink - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [Declaration []DeclarationLink]"} @@ -2434,40 +2434,40 @@ func (t *TextDocumentDeclarationResult) UnmarshalJSON(x []byte) error { // TextDocumentDefinitionResult a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed // array of DefinitionLink or a Thenable that resolves to such. type TextDocumentDefinitionResult struct { - Value any `json:"value"` + value any } -func NewTextDocumentDefinitionResult[T Definition | []DefinitionLink](x T) TextDocumentDefinitionResult { - return TextDocumentDefinitionResult{ - Value: x, +func NewTextDocumentDefinitionResult[T Definition | []DefinitionLink](val T) *TextDocumentDefinitionResult { + return &TextDocumentDefinitionResult{ + value: val, } } func (t TextDocumentDefinitionResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case Definition: - return marshal(x) + return marshal(val) case []DefinitionLink: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentDefinitionResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentDefinitionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 Definition - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 []DefinitionLink - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} @@ -2476,123 +2476,130 @@ func (t *TextDocumentDefinitionResult) UnmarshalJSON(x []byte) error { // TextDocumentDocumentSymbolResult a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that // resolves to such. type TextDocumentDocumentSymbolResult struct { - Value any `json:"value"` + value any } -func NewTextDocumentDocumentSymbolResult[T []SymbolInformation | []DocumentSymbol](x T) TextDocumentDocumentSymbolResult { +func NewTextDocumentDocumentSymbolResult[T []SymbolInformation | []DocumentSymbol](val T) TextDocumentDocumentSymbolResult { return TextDocumentDocumentSymbolResult{ - Value: x, + value: val, } } func (t TextDocumentDocumentSymbolResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case []SymbolInformation: - return marshal(x) + return marshal(val) case []DocumentSymbol: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentDocumentSymbolResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentDocumentSymbolResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 []SymbolInformation - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 []DocumentSymbol - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} } -// TextDocumentEditEdits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. +// TextDocumentEditEdits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. type TextDocumentEditEdits struct { - Value any `json:"value"` + value any } -func NewTextDocumentEditEdits[T TextEdit | AnnotatedTextEdit](x T) TextDocumentEditEdits { - return TextDocumentEditEdits{ - Value: x, +func NewTextDocumentEditEdits[T TextEdit | AnnotatedTextEdit | SnippetTextEdit](val T) *TextDocumentEditEdits { + return &TextDocumentEditEdits{ + value: val, } } func (t TextDocumentEditEdits) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case TextEdit: - return marshal(x) + return marshal(val) case AnnotatedTextEdit: - return marshal(x) + return marshal(val) + case SnippetTextEdit: + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentEditEdits) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentEditEdits) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 TextEdit - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 AnnotatedTextEdit - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } - return &UnmarshalError{"unmarshal failed to match one of [TextEdit AnnotatedTextEdit]"} + var h2 SnippetTextEdit + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextEdit AnnotatedTextEdit SnippetTextEdit]"} } // TextDocumentImplementationResult a request to resolve the implementation locations of a symbol at a given text document position. The // request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. type TextDocumentImplementationResult struct { - Value any `json:"value"` + value any } -func NewTextDocumentImplementationResult[T Definition | []DefinitionLink](x T) TextDocumentImplementationResult { - return TextDocumentImplementationResult{ - Value: x, +func NewTextDocumentImplementationResult[T Definition | []DefinitionLink](val T) *TextDocumentImplementationResult { + return &TextDocumentImplementationResult{ + value: val, } } func (t TextDocumentImplementationResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case Definition: - return marshal(x) + return marshal(val) case []DefinitionLink: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentImplementationResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentImplementationResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 Definition - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 []DefinitionLink - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} @@ -2602,40 +2609,40 @@ func (t *TextDocumentImplementationResult) UnmarshalJSON(x []byte) error { // // @since 3.18.0 proposed type TextDocumentInlineCompletionResult struct { - Value any `json:"value"` + value any } -func NewTextDocumentInlineCompletionResult[T InlineCompletionList | []InlineCompletionItem](x T) TextDocumentInlineCompletionResult { - return TextDocumentInlineCompletionResult{ - Value: x, +func NewTextDocumentInlineCompletionResult[T InlineCompletionList | []InlineCompletionItem](val T) *TextDocumentInlineCompletionResult { + return &TextDocumentInlineCompletionResult{ + value: val, } } func (t TextDocumentInlineCompletionResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case InlineCompletionList: - return marshal(x) + return marshal(val) case []InlineCompletionItem: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentInlineCompletionResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentInlineCompletionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 InlineCompletionList - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 []InlineCompletionItem - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} @@ -2645,40 +2652,40 @@ func (t *TextDocumentInlineCompletionResult) UnmarshalJSON(x []byte) error { // // @since 3.16.0 type TextDocumentSemanticTokensFullDeltaResult struct { - Value any `json:"value"` + value any } -func NewTextDocumentSemanticTokensFullDeltaResult[T SemanticTokens | SemanticTokensDelta](x T) TextDocumentSemanticTokensFullDeltaResult { - return TextDocumentSemanticTokensFullDeltaResult{ - Value: x, +func NewTextDocumentSemanticTokensFullDeltaResult[T SemanticTokens | SemanticTokensDelta](val T) *TextDocumentSemanticTokensFullDeltaResult { + return &TextDocumentSemanticTokensFullDeltaResult{ + value: val, } } func (t TextDocumentSemanticTokensFullDeltaResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case SemanticTokens: - return marshal(x) + return marshal(val) case SemanticTokensDelta: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentSemanticTokensFullDeltaResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentSemanticTokensFullDeltaResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 SemanticTokens - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 SemanticTokensDelta - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} @@ -2686,40 +2693,40 @@ func (t *TextDocumentSemanticTokensFullDeltaResult) UnmarshalJSON(x []byte) erro // TextDocumentSyncOptionsSave if present save notifications are sent to the server. If omitted the notification should not be sent. type TextDocumentSyncOptionsSave struct { - Value any `json:"value"` + value any } -func NewTextDocumentSyncOptionsSave[T bool | SaveOptions](x T) TextDocumentSyncOptionsSave { - return TextDocumentSyncOptionsSave{ - Value: x, +func NewTextDocumentSyncOptionsSave[T bool | SaveOptions](val T) *TextDocumentSyncOptionsSave { + return &TextDocumentSyncOptionsSave{ + value: val, } } func (t TextDocumentSyncOptionsSave) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case bool: - return marshal(x) + return marshal(val) case SaveOptions: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentSyncOptionsSave) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentSyncOptionsSave) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 bool - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 SaveOptions - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [bool SaveOptions]"} @@ -2727,40 +2734,40 @@ func (t *TextDocumentSyncOptionsSave) UnmarshalJSON(x []byte) error { // TextDocumentTypeDefinitionResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. type TextDocumentTypeDefinitionResult struct { - Value any `json:"value"` + value any } -func NewTextDocumentTypeDefinitionResult[T Definition | []DefinitionLink](x T) TextDocumentTypeDefinitionResult { - return TextDocumentTypeDefinitionResult{ - Value: x, +func NewTextDocumentTypeDefinitionResult[T Definition | []DefinitionLink](val T) *TextDocumentTypeDefinitionResult { + return &TextDocumentTypeDefinitionResult{ + value: val, } } func (t TextDocumentTypeDefinitionResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case Definition: - return marshal(x) + return marshal(val) case []DefinitionLink: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentTypeDefinitionResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *TextDocumentTypeDefinitionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 Definition - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 []DefinitionLink - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} @@ -2769,54 +2776,54 @@ func (t *TextDocumentTypeDefinitionResult) UnmarshalJSON(x []byte) error { // WorkspaceEditDocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are // either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. type WorkspaceEditDocumentChanges struct { - Value any `json:"value"` + value any } -func NewWorkspaceEditDocumentChanges[T TextDocumentEdit | CreateFile | RenameFile | DeleteFile](x T) WorkspaceEditDocumentChanges { - return WorkspaceEditDocumentChanges{ - Value: x, +func NewWorkspaceEditDocumentChanges[T TextDocumentEdit | CreateFile | RenameFile | DeleteFile](val T) *WorkspaceEditDocumentChanges { + return &WorkspaceEditDocumentChanges{ + value: val, } } func (t WorkspaceEditDocumentChanges) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case TextDocumentEdit: - return marshal(x) + return marshal(val) case CreateFile: - return marshal(x) + return marshal(val) case RenameFile: - return marshal(x) + return marshal(val) case DeleteFile: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *WorkspaceEditDocumentChanges) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *WorkspaceEditDocumentChanges) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 TextDocumentEdit - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 CreateFile - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } var h2 RenameFile - if err := unmarshal(x, &h2); err == nil { - t.Value = h2 + if err := unmarshal(val, &h2); err == nil { + t.value = h2 return nil } var h3 DeleteFile - if err := unmarshal(x, &h3); err == nil { - t.Value = h3 + if err := unmarshal(val, &h3); err == nil { + t.value = h3 return nil } return &UnmarshalError{"unmarshal failed to match one of [TextDocumentEdit CreateFile RenameFile DeleteFile]"} @@ -2824,85 +2831,128 @@ func (t *WorkspaceEditDocumentChanges) UnmarshalJSON(x []byte) error { // WorkspaceFoldersServerCapabilitiesChangeNotifications whether the server wants to receive workspace folder change notifications. If a string is provided the string is treated as an ID under which the notification is registered on the client side. The ID can be used to unregister for these events using the `client/unregisterCapability` request. type WorkspaceFoldersServerCapabilitiesChangeNotifications struct { - Value any `json:"value"` + value any } -func NewWorkspaceFoldersServerCapabilitiesChangeNotifications[T string | bool](x T) WorkspaceFoldersServerCapabilitiesChangeNotifications { +func NewWorkspaceFoldersServerCapabilitiesChangeNotifications[T string | bool](val T) WorkspaceFoldersServerCapabilitiesChangeNotifications { return WorkspaceFoldersServerCapabilitiesChangeNotifications{ - Value: x, + value: val, } } func (t WorkspaceFoldersServerCapabilitiesChangeNotifications) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case string: - return marshal(x) + return marshal(val) case bool: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *WorkspaceFoldersServerCapabilitiesChangeNotifications) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *WorkspaceFoldersServerCapabilitiesChangeNotifications) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 string - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 bool - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [string bool]"} } +// WorkspaceOptionsTextDocumentContent the server supports the `workspace/textDocumentContent` request. 3.18.0 @proposed. +// +// @since 3.18.0 +type WorkspaceOptionsTextDocumentContent struct { + value any +} + +func NewWorkspaceOptionsTextDocumentContent[T TextDocumentContentOptions | TextDocumentContentRegistrationOptions](val T) *WorkspaceOptionsTextDocumentContent { + return &WorkspaceOptionsTextDocumentContent{ + value: val, + } +} + +func (t WorkspaceOptionsTextDocumentContent) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case TextDocumentContentOptions: + return marshal(val) + case TextDocumentContentRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceOptionsTextDocumentContent) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 TextDocumentContentOptions + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 TextDocumentContentRegistrationOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextDocumentContentOptions TextDocumentContentRegistrationOptions]"} +} + // WorkspaceSymbolLocation the location of the symbol. Whether a server is allowed to return a location without a range depends // on the client capability `workspace.symbol.resolveSupport`. See SymbolInformation#location for // more details. // // @since 3.17.0 type WorkspaceSymbolLocation struct { - Value any `json:"value"` + value any } -func NewWorkspaceSymbolLocation[T Location | LocationURIOnly](x T) WorkspaceSymbolLocation { - return WorkspaceSymbolLocation{ - Value: x, +func NewWorkspaceSymbolLocation[T Location | LocationURIOnly](val T) *WorkspaceSymbolLocation { + return &WorkspaceSymbolLocation{ + value: val, } } func (t WorkspaceSymbolLocation) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case Location: - return marshal(x) + return marshal(val) case LocationURIOnly: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *WorkspaceSymbolLocation) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *WorkspaceSymbolLocation) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 Location - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 LocationURIOnly - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [Location LocationURIOnly]"} @@ -2913,40 +2963,40 @@ func (t *WorkspaceSymbolLocation) UnmarshalJSON(x []byte) error { // // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. type WorkspaceSymbolResult struct { - Value any `json:"value"` + value any } -func NewWorkspaceSymbolResult[T []SymbolInformation | []WorkspaceSymbol](x T) WorkspaceSymbolResult { +func NewWorkspaceSymbolResult[T []SymbolInformation | []WorkspaceSymbol](val T) WorkspaceSymbolResult { return WorkspaceSymbolResult{ - Value: x, + value: val, } } func (t WorkspaceSymbolResult) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { + switch val := t.value.(type) { case []SymbolInformation: - return marshal(x) + return marshal(val) case []WorkspaceSymbol: - return marshal(x) + return marshal(val) case nil: return []byte("null"), nil } return nil, fmt.Errorf("unknown type: %T", t) } -func (t *WorkspaceSymbolResult) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil +func (t *WorkspaceSymbolResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil return nil } var h0 []SymbolInformation - if err := unmarshal(x, &h0); err == nil { - t.Value = h0 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 return nil } var h1 []WorkspaceSymbol - if err := unmarshal(x, &h1); err == nil { - t.Value = h1 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 return nil } return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []WorkspaceSymbol]"} diff --git a/protocol/workspace.go b/protocol/workspace.go index 151d1774..16a6ec18 100644 --- a/protocol/workspace.go +++ b/protocol/workspace.go @@ -294,31 +294,31 @@ type DidChangeWatchedFilesClientCapabilities struct { // ClientSymbolKindOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientSymbolKindOptions struct { // ValueSet the symbol kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. If this property is not present the client only supports the symbol kinds from `File` to `Array` as defined in the initial version of the protocol. // - // @since 3.18.0 proposed + // @since 3.18.0 ValueSet []SymbolKind `json:"valueSet,omitempty"` } // ClientSymbolTagOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientSymbolTagOptions struct { // ValueSet the tags supported by the client. // - // @since 3.18.0 proposed + // @since 3.18.0 ValueSet []SymbolTag `json:"valueSet"` } // ClientSymbolResolveOptions. // -// @since 3.18.0 proposed +// @since 3.18.0 type ClientSymbolResolveOptions struct { // Properties the properties that a client can resolve lazily. Usually `location.range`. // - // @since 3.18.0 proposed + // @since 3.18.0 Properties []string `json:"properties"` } @@ -398,7 +398,7 @@ type WorkspaceSymbolParams struct { WorkDoneProgressParams PartialResultParams - // Query a query string to filter symbols by. Clients may send an empty string here to request all symbols. + // Query a query string to filter symbols by. Clients may send an empty string here to request all symbols. The `query`-parameter should be interpreted in a *relaxed way* as editors will apply their own highlighting and scoring on the results. A good rule of thumb is to match case-insensitive and to simply check that the characters of *query* appear in their order in a candidate symbol. Servers shouldn't use prefix, substring, or similar strict matching. Query string `json:"query"` } @@ -428,6 +428,16 @@ type WorkspaceSymbolRegistrationOptions struct { WorkspaceSymbolOptions } +// WorkspaceEditMetadata additional data about a workspace edit. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type WorkspaceEditMetadata struct { + // IsRefactoring signal to the editor that this edit is a refactoring. + // + // @since 3.18.0 proposed + IsRefactoring bool `json:"isRefactoring,omitempty"` +} + // ApplyWorkspaceEditParams the parameters passed via an apply workspace edit request. type ApplyWorkspaceEditParams struct { // Label an optional label of the workspace edit. This label is presented in the user interface for example on an undo stack to undo the workspace edit. @@ -435,6 +445,9 @@ type ApplyWorkspaceEditParams struct { // Edit the edits to apply. Edit WorkspaceEdit `json:"edit"` + + // Metadata additional data about the edit. 3.18.0 @proposed. + Metadata *WorkspaceEditMetadata `json:"metadata,omitempty"` } // ApplyWorkspaceEditResult the result returned from the apply workspace edit request. 3.17 renamed from ApplyWorkspaceEditResponse. diff --git a/tools/protocol-gen/generator/enumeration.go b/tools/protocol-gen/generator/enumeration.go index 96818ec0..977514d2 100644 --- a/tools/protocol-gen/generator/enumeration.go +++ b/tools/protocol-gen/generator/enumeration.go @@ -50,6 +50,9 @@ var enumerationNames = map[string]string{ "FailureHandlingKind": "basic", "PrepareSupportDefaultBehavior": "language", "TokenFormat": "language", + + "CodeActionTag": "language", + "ApplyKind": "language", } // Enumerations generates Enumerations Go type from the metaModel schema definition. @@ -81,11 +84,15 @@ func (gen *Generator) Enumerations(enumerations []*protocol.Enumeration) error { } g.P(`type `, enumName) - switch e := enum.Type.(type) { - case protocol.BaseType: - g.P(` `, e.String()) + switch enum.Type.Name { + case protocol.EnumerationNameInteger: + g.P(` int32`) + case protocol.EnumerationNameString: + g.P(` string`) + case protocol.EnumerationNameUinteger: + g.P(` uint32`) default: - panic(fmt.Sprintf("enumerations: %#v\n", e)) + panic(fmt.Sprintf("enum: %#v\n", enum)) } g.PP("\n") diff --git a/tools/protocol-gen/generator/generics_types.go b/tools/protocol-gen/generator/generics_types.go index 9fdcdfdc..0fc4c2da 100644 --- a/tools/protocol-gen/generator/generics_types.go +++ b/tools/protocol-gen/generator/generics_types.go @@ -45,7 +45,7 @@ func (gen *Generator) GenericsTypes() error { } g.PP(`type `, generics.Name, ` struct {`) - g.PP(` Value any `, "`json:\"value\"`") + g.PP(` value any `) g.PP(`}`) g.P("\n") @@ -54,6 +54,7 @@ func (gen *Generator) GenericsTypes() error { g.P(`[T `) var typs []string seem := map[string]bool{} + isRetPointer := false for i, gt := range types { switch gt := gt.(type) { case protocol.BaseType: @@ -73,6 +74,7 @@ func (gen *Generator) GenericsTypes() error { seem[t] = true typs = append(typs, t) g.P(t) + isRetPointer = true } case *protocol.ArrayType: @@ -106,6 +108,7 @@ func (gen *Generator) GenericsTypes() error { t := name typs = append(typs, t) g.P(t) + isRetPointer = true } default: panic(fmt.Sprintf("GenericsTypes.TupleType: %[1]T = %#[1]v\n", item)) @@ -120,26 +123,35 @@ func (gen *Generator) GenericsTypes() error { g.P(` | `) } } - g.PP(`](x T) `, generics.Name, ` {`) - g.PP(` return `, generics.Name, `{`) - g.PP(` Value: x,`) + + g.P(`](val T) `) + if isRetPointer { + g.P(`*`) + } + g.P(generics.Name, ` {`, "\n") + g.P(` return `) + if isRetPointer { + g.P(`&`) + } + g.P(generics.Name, `{`, "\n") + g.PP(` value: val,`) g.PP(` }`) g.PP(`}`, "\n") g.PP(`func (t `, generics.Name, `) MarshalJSON() ([]byte, error) {`) - g.PP(` switch x := t.Value.(type) {`) + g.PP(` switch val := t.value.(type) {`) for _, gt := range types { switch gt := gt.(type) { case protocol.BaseType: g.PP(` case `, gt.String(), `:`) - g.PP(` return marshal(x)`) + g.PP(` return marshal(val)`) case *protocol.NullType: // nothing to do case *protocol.ReferenceType: g.PP(` case `, normalizeLSPTypes(strings.ReplaceAll(gt.String(), "Uri", "URI")), `:`) - g.PP(` return marshal(x)`) + g.PP(` return marshal(val)`) case *protocol.ArrayType: elem := gt.Element @@ -151,7 +163,7 @@ func (gen *Generator) GenericsTypes() error { default: panic(fmt.Sprintf("GenericsTypes.Array: %#v\n", elem)) } - g.PP(` return marshal(x)`) + g.PP(` return marshal(val)`) case *protocol.TupleType: seem := map[string]bool{} @@ -168,7 +180,7 @@ func (gen *Generator) GenericsTypes() error { panic(fmt.Sprintf("GenericsTypes.TupleType: %[1]T = %#[1]v\n", item)) } if i < len(gt.Items) { - g.PP(` return marshal(x)`) + g.PP(` return marshal(val)`) } } @@ -182,9 +194,9 @@ func (gen *Generator) GenericsTypes() error { g.PP(` return nil, fmt.Errorf("unknown type: %T", t)`) g.PP(`}`) - g.PP(`func (t *`, generics.Name, `) UnmarshalJSON(x []byte) error {`) - g.PP(`if string(x) == "null" {`) - g.PP(` t.Value = nil`) + g.PP(`func (t *`, generics.Name, `) UnmarshalJSON(val []byte) error {`) + g.PP(`if string(val) == "null" {`) + g.PP(` t.value = nil`) g.PP(` return nil`) g.PP(`}`) @@ -192,8 +204,8 @@ func (gen *Generator) GenericsTypes() error { switch gt := gt.(type) { case protocol.BaseType: g.PP(`var h`, i, ` `, gt.String()) - g.PP(`if err := unmarshal(x, &h`, i, `); err == nil {`) - g.PP(` t.Value = h`, i) + g.PP(`if err := unmarshal(val, &h`, i, `); err == nil {`) + g.PP(` t.value = h`, i) g.PP(` return nil`) g.PP(`}`) @@ -202,8 +214,8 @@ func (gen *Generator) GenericsTypes() error { case *protocol.ReferenceType: g.PP(`var h`, i, ` `, normalizeLSPTypes(strings.ReplaceAll(gt.String(), "Uri", "URI"))) - g.PP(`if err := unmarshal(x, &h`, i, `); err == nil {`) - g.PP(` t.Value = h`, i) + g.PP(`if err := unmarshal(val, &h`, i, `); err == nil {`) + g.PP(` t.value = h`, i) g.PP(` return nil`) g.PP(`}`) @@ -218,8 +230,8 @@ func (gen *Generator) GenericsTypes() error { default: panic(fmt.Sprintf("GenericsTypes.Array: %#v\n", elem)) } - g.PP(`if err := unmarshal(x, &h`, i, `); err == nil {`) - g.PP(` t.Value = h`, i) + g.PP(`if err := unmarshal(val, &h`, i, `); err == nil {`) + g.PP(` t.value = h`, i) g.PP(` return nil`) g.PP(`}`) @@ -237,8 +249,8 @@ func (gen *Generator) GenericsTypes() error { panic(fmt.Sprintf("GenericsTypes.TupleType: %[1]T = %#[1]v\n", item)) } if j < len(gt.Items)-1 { - g.PP(`if err := unmarshal(x, &h`, i+j, `); err == nil {`) - g.PP(` t.Value = h`, i+j) + g.PP(`if err := unmarshal(val, &h`, i+j, `); err == nil {`) + g.PP(` t.value = h`, i+j) g.PP(` return nil`) g.PP(`}`) } diff --git a/tools/protocol-gen/generator/structure.go b/tools/protocol-gen/generator/structure.go index ee9d4f87..e76e7089 100644 --- a/tools/protocol-gen/generator/structure.go +++ b/tools/protocol-gen/generator/structure.go @@ -387,6 +387,19 @@ var structureNames = map[string]string{ "NotebookDocumentFilterNotebookType": "document", "NotebookDocumentFilterScheme": "document", "NotebookDocumentFilterPattern": "document", + + "SnippetTextEdit": "basic", + "TextDocumentContentParams": "basic", + "TextDocumentContentResult": "basic", + "TextDocumentContentOptions": "basic", + "TextDocumentContentRegistrationOptions": "basic", + "TextDocumentContentRefreshParams": "basic", + "TextDocumentContentClientCapabilities": "lifecycle", + "ClientCodeLensResolveOptions": "lifecycle", + "DiagnosticsCapabilities": "lifecycle", + "WorkspaceEditMetadata": "workspace", + "CodeActionTagOptions": "language", + "CompletionItemApplyKinds": "language", } // Structures generates Structure Go type from the metaModel schema definition. @@ -396,7 +409,7 @@ func (gen *Generator) Structures(structures []*protocol.Structure) error { filename, ok := structureNames[structuresName] if !ok { - panic(fmt.Sprintf("not found %s enumerations file", structuresName)) + panic(fmt.Sprintf("not found %s structures file", structuresName)) } // Init structures printers diff --git a/tools/protocol-gen/generator/typealiases.go b/tools/protocol-gen/generator/typealiases.go index e087ae65..db3de520 100644 --- a/tools/protocol-gen/generator/typealiases.go +++ b/tools/protocol-gen/generator/typealiases.go @@ -130,9 +130,9 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { g.P(` | `) } } - g.PP(`](x T) `, aliasName, ` {`) + g.PP(`](val T) `, aliasName, ` {`) g.PP(` return `, aliasName, `{`) - g.PP(` Value: x,`) + g.PP(` Value: val,`) g.PP(` }`) g.PP(`}`, "\n") } @@ -140,7 +140,7 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { switch a := alias.Type.(type) { case *protocol.OrType: g.PP(`func (t `, aliasName, `) MarshalJSON() ([]byte, error) {`) - g.PP(` switch x := t.Value.(type) {`) + g.PP(` switch val := t.Value.(type) {`) for i, item := range a.Items { switch item := item.(type) { case protocol.BaseType: @@ -159,7 +159,7 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { panic(fmt.Sprintf("typealias.OrType: %#v\n", item)) } if i <= len(a.Items)-1 { - g.PP(` return marshal(x)`) + g.PP(` return marshal(val)`) } } g.PP(` case nil:`) @@ -171,8 +171,8 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { switch a := alias.Type.(type) { case *protocol.OrType: - g.PP(`func (t *`, aliasName, `) UnmarshalJSON(x []byte) error {`) - g.PP(`if string(x) == "null" {`) + g.PP(`func (t *`, aliasName, `) UnmarshalJSON(val []byte) error {`) + g.PP(`if string(val) == "null" {`) g.PP(` t.Value = nil`) g.PP(` return nil`) g.PP(`}`) @@ -194,7 +194,7 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { default: panic(fmt.Sprintf("typealias.OrType: %#v\n", item)) } - g.PP(`if err := unmarshal(x, &h`, i, `); err == nil {`) + g.PP(`if err := unmarshal(val, &h`, i, `); err == nil {`) g.PP(` t.Value = h`, i) g.PP(` return nil`) g.PP(`}`) diff --git a/tools/protocol-gen/main.go b/tools/protocol-gen/main.go index 5f81b18e..8690bb2c 100644 --- a/tools/protocol-gen/main.go +++ b/tools/protocol-gen/main.go @@ -21,9 +21,8 @@ import ( ) const ( - lspVersion = "3.17" LSPSchemaURI = "https://github.com/microsoft/lsprotocol/raw/%s/generator/lsp.json" - schemaVersion = "2024.0.0a1" + schemaVersion = "v2024.0.0b1" ) func init() { diff --git a/tools/protocol-gen/protocol/enum.go b/tools/protocol-gen/protocol/enum.go index b7148ba1..7ef00d2b 100644 --- a/tools/protocol-gen/protocol/enum.go +++ b/tools/protocol-gen/protocol/enum.go @@ -24,7 +24,7 @@ type Enumeration struct { SupportsCustomValues bool // The type of the elements. - Type Type + Type EnumerationType // The enum values. Values []*EnumerationEntry @@ -32,6 +32,22 @@ type Enumeration struct { func (Enumeration) isTypeDecl() {} +type EnumerationType struct { + // Kind corresponds to the JSON schema field "kind". + Kind string + + // Name corresponds to the JSON schema field "name". + Name EnumerationTypeName +} + +type EnumerationTypeName string + +const ( + EnumerationNameInteger EnumerationTypeName = "integer" + EnumerationNameString EnumerationTypeName = "string" + EnumerationNameUinteger EnumerationTypeName = "uinteger" +) + // EnumerationEntry defines an enumeration entry. type EnumerationEntry struct { // Whether the enum entry is deprecated or not. If deprecated the property contains the deprecation message. diff --git a/tools/protocol-gen/protocol/type.go b/tools/protocol-gen/protocol/type.go index 23f60cfc..fe34216d 100644 --- a/tools/protocol-gen/protocol/type.go +++ b/tools/protocol-gen/protocol/type.go @@ -167,7 +167,7 @@ var _ Type = (*ArrayType)(nil) func (ArrayType) isType() {} func (ArrayType) HasSubTypes() bool { return true } func (t *ArrayType) SubTypes() []Type { return []Type{t.Element} } -func (t *ArrayType) String() string { return "TODO(zchee): ArrayType" } // TODO(zchee): implements +func (t *ArrayType) String() string { return "[]" + t.Element.String() } // BooleanLiteralType represents a boolean literal type (e.g. kind: true). // kind: booleanLiteral @@ -178,7 +178,7 @@ var _ Type = BooleanLiteralType{} func (BooleanLiteralType) isType() {} func (BooleanLiteralType) HasSubTypes() bool { return false } func (BooleanLiteralType) SubTypes() []Type { return nil } -func (t BooleanLiteralType) String() string { return strconv.FormatBool(t.Value) } // TODO(zchee): implements +func (t BooleanLiteralType) String() string { return strconv.FormatBool(t.Value) } // IntegerLiteralType represents an integer literal type (e.g. kind: 1). type IntegerLiteralType struct{ Value int } @@ -188,7 +188,7 @@ var _ Type = IntegerLiteralType{} func (IntegerLiteralType) isType() {} func (IntegerLiteralType) HasSubTypes() bool { return false } func (IntegerLiteralType) SubTypes() []Type { return nil } -func (t IntegerLiteralType) String() string { return strconv.FormatInt(int64(t.Value), 10) } // TODO(zchee): implements +func (t IntegerLiteralType) String() string { return strconv.FormatInt(int64(t.Value), 10) } // MapType represents a JSON object map (e.g. interface Map { [key: K] => V; }). type MapType struct { @@ -201,7 +201,7 @@ var _ Type = (*MapType)(nil) func (MapType) isType() {} func (MapType) HasSubTypes() bool { return true } func (t *MapType) SubTypes() []Type { return []Type{t.Key, t.Value} } -func (t *MapType) String() string { return "TODO(zchee): MapType" } // TODO(zchee): implements +func (t *MapType) String() string { return "map[" + t.Key.String() + "]" + t.Value.String() } // OrType represents an or type (e.g. Location | LocationLink) type OrType struct{ Items []Type } @@ -221,7 +221,7 @@ var _ Type = (*StringLiteralType)(nil) func (StringLiteralType) isType() {} func (StringLiteralType) HasSubTypes() bool { return false } func (StringLiteralType) SubTypes() []Type { return nil } -func (t *StringLiteralType) String() string { return t.Value } // TODO(zchee): implements +func (t *StringLiteralType) String() string { return t.Value } // StructureLiteralType represents a literal structure (e.g. property: { start: uinteger; end: uinteger; }). type StructureLiteralType struct{ Value *StructureLiteral } @@ -231,7 +231,15 @@ var _ Type = (*StructureLiteralType)(nil) func (StructureLiteralType) isType() {} func (StructureLiteralType) HasSubTypes() bool { return false } func (StructureLiteralType) SubTypes() []Type { return nil } -func (t *StructureLiteralType) String() string { return "TODO(zchee): StructureLiteralType" } // TODO(zchee): implements +func (t *StructureLiteralType) String() string { + s := "struct { " + for _, prop := range t.Value.Properties { + s += prop.Name + " " + prop.Type.String() + "\n" + } + s += "}" + + return s +} // ReferenceType represents a reference to another type (e.g. TextDocument). // This is either a Structure, a Enumeration or a TypeAlias in the same meta model. @@ -252,7 +260,21 @@ type TupleType struct{ Items []Type } var _ Type = (*TupleType)(nil) +var xyz = []string{ + "x", + "y", + "z", +} + func (TupleType) isType() {} func (TupleType) HasSubTypes() bool { return true } func (t *TupleType) SubTypes() []Type { return t.Items } -func (t *TupleType) String() string { return "TODO(zchee): TupleType" } // TODO(zchee): implements +func (t *TupleType) String() string { + s := "struct { " + for i, item := range t.Items { + s += xyz[i] + " " + item.String() + ";" + } + s += "}" + + return s +} diff --git a/tools/protocol-gen/resolver/resolver.go b/tools/protocol-gen/resolver/resolver.go index edcbed34..d79d6bd8 100644 --- a/tools/protocol-gen/resolver/resolver.go +++ b/tools/protocol-gen/resolver/resolver.go @@ -107,8 +107,11 @@ func (r *resolver) enumeration(in schema.Enumeration) *protocol.Enumeration { Proposed: in.Proposed, Since: in.Since, SupportsCustomValues: in.SupportsCustomValues, - Type: r.type_(in.Type), - Values: transform(in.Values, r.enumerationEntry), + Type: protocol.EnumerationType{ + Kind: in.Type.Kind, + Name: protocol.EnumerationTypeName(in.Type.Name), + }, + Values: transform(in.Values, r.enumerationEntry), } } diff --git a/tools/protocol-gen/schema/metaModel.go b/tools/protocol-gen/schema/metaModel.go index fe88ae20..e4bdcae6 100644 --- a/tools/protocol-gen/schema/metaModel.go +++ b/tools/protocol-gen/schema/metaModel.go @@ -263,6 +263,9 @@ type StructureLiteral struct { // Whether the literal is deprecated or not. If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` } // StringLiteralType represents a string literal type (e.g. kind: 'rename') @@ -325,11 +328,17 @@ type Request struct { // Since when (release number) this request is available. Is undefined if not known. Since string `json:"since,omitempty" yaml:"since,omitempty"` + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` + // Whether this is a proposed feature. If omitted the feature is final. Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` // Whether the request is deprecated or not. If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` + + // The type name of the request if any. + TypeName string `json:"typeName,omitempty" yaml:"typeName,omitempty"` } // Notification represents a LSP notification @@ -355,12 +364,18 @@ type Notification struct { // Since when (release number) this notification is available. Is undefined if not known. Since string `json:"since,omitempty" yaml:"since,omitempty"` + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` + // Whether this is a proposed notification. If omitted the notification is final. Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` // Whether the notification is deprecated or not. // If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` + + // The type name of the request if any. + TypeName string `json:"typeName,omitempty" yaml:"typeName,omitempty"` } // Structure defines the structure of an object literal @@ -388,6 +403,9 @@ type Structure struct { // Whether the structure is deprecated or not. If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` } // Enumeration defines an enumeration. @@ -396,7 +414,7 @@ type Enumeration struct { Name string `json:"name" yaml:"name"` // The type of the elements. - Type Type `json:"type" yaml:"type"` + Type EnumerationType `json:"type" yaml:"type"` // The enum values. Values []EnumerationEntry `json:"values" yaml:"values"` @@ -410,6 +428,9 @@ type Enumeration struct { // Since when (release number) this enumeration is available. Is empty if not known. Since string `json:"since,omitempty" yaml:"since,omitempty"` + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` + // Whether this is a proposed enumeration. If omitted, the enumeration is final. Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` @@ -431,13 +452,35 @@ type EnumerationEntry struct { // Since when (release number) this enumeration entry is available. Is undefined if not known. Since string `json:"since,omitempty" yaml:"since,omitempty"` + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` + // Whether this is a proposed enumeration entry. If omitted, the enumeration entry is final. Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` // Whether the enum entry is deprecated or not. If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` + + // The type name of the request if any. + TypeName string `json:"typeName,omitempty" yaml:"typeName,omitempty"` } +type EnumerationType struct { + // Kind corresponds to the JSON schema field "kind". + Kind string `json:"kind" yaml:"kind"` + + // Name corresponds to the JSON schema field "name". + Name EnumerationName `json:"name" yaml:"name"` +} + +type EnumerationName string + +const ( + EnumerationNameInteger EnumerationName = "integer" + EnumerationNameString EnumerationName = "string" + EnumerationNameUinteger EnumerationName = "uinteger" +) + // TypeAlias defines a type alias. (e.g. type Definition = Location | LocationLink) type TypeAlias struct { // The name of the type alias. @@ -458,6 +501,9 @@ type TypeAlias struct { // Whether the type alias is deprecated or not. // If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` } // Property represents an object property @@ -482,4 +528,7 @@ type Property struct { // Whether the property is deprecated or not. If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` } From 26e06f8a9d4ec9bbc0d726a718c6c78c1cd34416 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Mon, 7 Oct 2024 12:33:39 +0900 Subject: [PATCH 09/19] WIP6 Signed-off-by: Koichi Shiraishi --- protocol/client.go | 222 +++--- protocol/client_interface.go | 162 ++-- protocol/server.go | 250 +++---- protocol/server_interface.go | 562 +++++++------- protocol/types_generics.go | 694 +++++++++--------- tools/protocol-gen/generator/client_server.go | 74 +- tools/protocol-gen/protocol/enum.go | 53 +- tools/protocol-gen/protocol/notification.go | 32 +- tools/protocol-gen/protocol/property.go | 29 +- tools/protocol-gen/protocol/request.go | 38 +- tools/protocol-gen/protocol/structure.go | 23 +- .../protocol/structure_literal.go | 15 +- tools/protocol-gen/protocol/type_alias.go | 23 +- tools/protocol-gen/resolver/resolver.go | 85 ++- tools/protocol-gen/schema/metaModel.go | 56 +- 15 files changed, 1177 insertions(+), 1141 deletions(-) diff --git a/protocol/client.go b/protocol/client.go index 23b7fe56..605cb62d 100644 --- a/protocol/client.go +++ b/protocol/client.go @@ -98,7 +98,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.TextDocumentPublishDiagnostics(ctx, ¶ms) + err := client.PublishDiagnostics(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -110,7 +110,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.WindowLogMessage(ctx, ¶ms) + err := client.LogMessage(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -122,7 +122,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.WindowShowMessage(ctx, ¶ms) + err := client.ShowMessage(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -134,7 +134,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.ClientRegisterCapability(ctx, ¶ms) + err := client.Registration(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -146,7 +146,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.ClientUnregisterCapability(ctx, ¶ms) + err := client.Unregistration(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -158,7 +158,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.WindowShowDocument(ctx, ¶ms) + resp, err := client.ShowDocument(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -170,7 +170,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.WindowShowMessageRequest(ctx, ¶ms) + resp, err := client.ShowMessageRequest(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -182,7 +182,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := client.WindowWorkDoneProgressCreate(ctx, ¶ms) + err := client.WorkDoneProgressCreate(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -194,14 +194,14 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.WorkspaceApplyEdit(ctx, ¶ms) + resp, err := client.ApplyWorkspaceEdit(ctx, ¶ms) return true, reply(ctx, resp, err) case MethodWorkspaceCodeLensRefresh: // request defer logger.Debug(MethodWorkspaceCodeLensRefresh, zap.Error(err)) - err := client.WorkspaceCodeLensRefresh(ctx) + err := client.CodeLensRefresh(ctx) return true, reply(ctx, nil, err) @@ -213,35 +213,35 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.WorkspaceConfiguration(ctx, ¶ms) + resp, err := client.Configuration(ctx, ¶ms) return true, reply(ctx, resp, err) case MethodWorkspaceDiagnosticRefresh: // request defer logger.Debug(MethodWorkspaceDiagnosticRefresh, zap.Error(err)) - err := client.WorkspaceDiagnosticRefresh(ctx) + err := client.DiagnosticRefresh(ctx) return true, reply(ctx, nil, err) case MethodWorkspaceFoldingRangeRefresh: // request defer logger.Debug(MethodWorkspaceFoldingRangeRefresh, zap.Error(err)) - err := client.WorkspaceFoldingRangeRefresh(ctx) + err := client.FoldingRangeRefresh(ctx) return true, reply(ctx, nil, err) case MethodWorkspaceInlayHintRefresh: // request defer logger.Debug(MethodWorkspaceInlayHintRefresh, zap.Error(err)) - err := client.WorkspaceInlayHintRefresh(ctx) + err := client.InlayHintRefresh(ctx) return true, reply(ctx, nil, err) case MethodWorkspaceSemanticTokensRefresh: // request defer logger.Debug(MethodWorkspaceSemanticTokensRefresh, zap.Error(err)) - err := client.WorkspaceSemanticTokensRefresh(ctx) + err := client.SemanticTokensRefresh(ctx) return true, reply(ctx, nil, err) @@ -252,7 +252,7 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) } - resp, err := client.WorkspaceWorkspaceFolders(ctx) + resp, err := client.WorkspaceFolders(ctx) return true, reply(ctx, resp, err) @@ -271,7 +271,7 @@ type client struct { // compiler time check whether the Client implements ClientInterface interface. var _ Client = (*client)(nil) -func (c *client) CancelRequest(ctx context.Context, params *CancelParams) (err error) { +func (c *client) Cancel(ctx context.Context, params *CancelParams) (err error) { c.logger.Debug("notify " + MethodClientCancelRequest) defer c.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) @@ -291,6 +291,14 @@ func (c *client) Progress(ctx context.Context, params *ProgressParams) (err erro return c.Conn.Notify(ctx, MethodClientProgress, params) } +// LogMessage sends the notification from the server to the client to ask the client to log a particular message. +func (c *client) LogMessage(ctx context.Context, params *LogMessageParams) (err error) { + c.logger.Debug("notify " + MethodWindowLogMessage) + defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodWindowLogMessage, params) +} + func (c *client) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { c.logger.Debug("notify " + MethodLogTrace) defer c.logger.Debug("end "+MethodLogTrace, zap.Error(err)) @@ -298,14 +306,6 @@ func (c *client) LogTrace(ctx context.Context, params *LogTraceParams) (err erro return c.Conn.Notify(ctx, MethodLogTrace, params) } -// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. -func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { - c.logger.Debug("notify " + MethodTelemetryEvent) - defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) - - return c.Conn.Notify(ctx, MethodTelemetryEvent, params) -} - // PublishDiagnostics sends the notification from the server to the client to signal results of validation runs. // // Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary. The following rule is used for VS Code servers that generate diagnostics: @@ -316,92 +316,32 @@ func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { // When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the client. // If the computed set is empty it has to push the empty array to clear former diagnostics. // Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side. -func (c *client) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { +func (c *client) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { c.logger.Debug("notify " + MethodTextDocumentPublishDiagnostics) defer c.logger.Debug("end "+MethodTextDocumentPublishDiagnostics, zap.Error(err)) return c.Conn.Notify(ctx, MethodTextDocumentPublishDiagnostics, params) } -// LogMessage sends the notification from the server to the client to ask the client to log a particular message. -func (c *client) WindowLogMessage(ctx context.Context, params *LogMessageParams) (err error) { - c.logger.Debug("notify " + MethodWindowLogMessage) - defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) - - return c.Conn.Notify(ctx, MethodWindowLogMessage, params) -} - // ShowMessage sends the notification from a server to a client to ask the // client to display a particular message in the user interface. -func (c *client) WindowShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { +func (c *client) ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { c.logger.Debug("notify " + MethodWindowShowMessage) defer c.logger.Debug("end "+MethodWindowShowMessage, zap.Error(err)) return c.Conn.Notify(ctx, MethodWindowShowMessage, params) } -// RegisterCapability sends the request from the server to the client to register for a new capability on the client side. -// -// Not all clients need to support dynamic capability registration. -// -// A client opts in via the dynamicRegistration property on the specific client capabilities. -// A client can even provide dynamic registration for capability A but not for capability B (see TextDocumentClientCapabilities as an example). -func (c *client) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { - c.logger.Debug("call " + MethodClientRegisterCapability) - defer c.logger.Debug("end "+MethodClientRegisterCapability, zap.Error(err)) - - return Call(ctx, c.Conn, MethodClientRegisterCapability, params, nil) -} - -// UnregisterCapability sends the request from the server to the client to unregister a previously registered capability. -func (c *client) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { - c.logger.Debug("call " + MethodClientUnregisterCapability) - defer c.logger.Debug("end "+MethodClientUnregisterCapability, zap.Error(err)) - - return Call(ctx, c.Conn, MethodClientUnregisterCapability, params, nil) -} - -// ShowMessage sends the notification from a server to a client to ask the -// client to display a particular message in the user interface. -func (c *client) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (_ *ShowDocumentResult, err error) { - c.logger.Debug("call " + MethodWindowShowDocument) - defer c.logger.Debug("end "+MethodWindowShowDocument, zap.Error(err)) - - var result *ShowDocumentResult - if err := Call(ctx, c.Conn, MethodWindowShowDocument, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. -// -// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. -func (c *client) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { - c.logger.Debug("call " + MethodWindowShowMessageRequest) - defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) - - var result *MessageActionItem - if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { - return nil, err - } - - return result, nil -} - -// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. -// -// @since 3.16.0. -func (c *client) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { - c.logger.Debug("call " + MethodWindowWorkDoneProgressCreate) - defer c.logger.Debug("end "+MethodWindowWorkDoneProgressCreate, zap.Error(err)) +// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. +func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { + c.logger.Debug("notify " + MethodTelemetryEvent) + defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) - return Call(ctx, c.Conn, MethodWindowWorkDoneProgressCreate, params, nil) + return c.Conn.Notify(ctx, MethodTelemetryEvent, params) } -// ApplyEdit sends the request from the server to the client to modify resource on the client side. -func (c *client) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResult, err error) { +// ApplyWorkspaceEdit sends the request from the server to the client to modify resource on the client side. +func (c *client) ApplyWorkspaceEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResult, err error) { c.logger.Debug("call " + MethodWorkspaceApplyEdit) defer c.logger.Debug("end "+MethodWorkspaceApplyEdit, zap.Error(err)) @@ -412,7 +352,7 @@ func (c *client) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceE return result, nil } -func (c *client) WorkspaceCodeLensRefresh(ctx context.Context) (err error) { +func (c *client) CodeLensRefresh(ctx context.Context) (err error) { return c.refresh(ctx, MethodWorkspaceCodeLensRefresh) } @@ -421,7 +361,7 @@ func (c *client) WorkspaceCodeLensRefresh(ctx context.Context) (err error) { // The request can fetch several configuration settings in one roundtrip. // The order of the returned configuration settings correspond to the order of the // passed ConfigurationItems (e.g. the first item in the response is the result for the first configuration item in the params). -func (c *client) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) (_ []any, err error) { +func (c *client) Configuration(ctx context.Context, params *ConfigurationParams) (_ []any, err error) { c.logger.Debug("call " + MethodWorkspaceConfiguration) defer c.logger.Debug("end "+MethodWorkspaceConfiguration, zap.Error(err)) @@ -433,37 +373,72 @@ func (c *client) WorkspaceConfiguration(ctx context.Context, params *Configurati return result, nil } -func (c *client) refresh(ctx context.Context, method string) (err error) { - c.logger.Debug("call " + method) - defer c.logger.Debug("end "+method, zap.Error(err)) - - return c.Conn.Notify(ctx, method, nil) -} - -func (c *client) WorkspaceDiagnosticRefresh(ctx context.Context) (err error) { +func (c *client) DiagnosticRefresh(ctx context.Context) (err error) { return c.refresh(ctx, MethodWorkspaceDiagnosticRefresh) } -func (c *client) WorkspaceFoldingRangeRefresh(ctx context.Context) (err error) { +func (c *client) FoldingRangeRefresh(ctx context.Context) (err error) { return c.refresh(ctx, MethodWorkspaceFoldingRangeRefresh) } -func (c *client) WorkspaceInlayHintRefresh(ctx context.Context) (err error) { +func (c *client) InlayHintRefresh(ctx context.Context) (err error) { return c.refresh(ctx, MethodWorkspaceInlayHintRefresh) } -func (c *client) WorkspaceInlineValueRefresh(ctx context.Context) (err error) { +func (c *client) InlineValueRefresh(ctx context.Context) (err error) { return c.refresh(ctx, MethodWorkspaceInlineValueRefresh) } -func (c *client) WorkspaceSemanticTokensRefresh(ctx context.Context) (err error) { +// Registration sends the request from the server to the client to register for a new capability on the client side. +// +// Not all clients need to support dynamic capability registration. +// +// A client opts in via the dynamicRegistration property on the specific client capabilities. +// A client can even provide dynamic registration for capability A but not for capability B (see TextDocumentClientCapabilities as an example). +func (c *client) Registration(ctx context.Context, params *RegistrationParams) (err error) { + c.logger.Debug("call " + MethodClientRegisterCapability) + defer c.logger.Debug("end "+MethodClientRegisterCapability, zap.Error(err)) + + return Call(ctx, c.Conn, MethodClientRegisterCapability, params, nil) +} + +func (c *client) SemanticTokensRefresh(ctx context.Context) (err error) { return c.refresh(ctx, MethodWorkspaceSemanticTokensRefresh) } -// WorkspaceTextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed. +// ShowDocument sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) ShowDocument(ctx context.Context, params *ShowDocumentParams) (_ *ShowDocumentResult, err error) { + c.logger.Debug("call " + MethodWindowShowDocument) + defer c.logger.Debug("end "+MethodWindowShowDocument, zap.Error(err)) + + var result *ShowDocumentResult + if err := Call(ctx, c.Conn, MethodWindowShowDocument, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. +// +// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. +func (c *client) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { + c.logger.Debug("call " + MethodWindowShowMessageRequest) + defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) + + var result *MessageActionItem + if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// TextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed. // // @since 3.18.0 proposed -func (c *client) WorkspaceTextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) (err error) { +func (c *client) TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) (err error) { c.logger.Debug("call " + MethodWorkspaceTextDocumentContentRefresh) defer c.logger.Debug("end "+MethodWorkspaceTextDocumentContentRefresh, zap.Error(err)) @@ -474,12 +449,37 @@ func (c *client) WorkspaceTextDocumentContentRefresh(ctx context.Context, params return nil } +// Unregistration sends the request from the server to the client to unregister a previously registered capability. +func (c *client) Unregistration(ctx context.Context, params *UnregistrationParams) (err error) { + c.logger.Debug("call " + MethodClientUnregisterCapability) + defer c.logger.Debug("end "+MethodClientUnregisterCapability, zap.Error(err)) + + return Call(ctx, c.Conn, MethodClientUnregisterCapability, params, nil) +} + +// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. +// +// @since 3.16.0. +func (c *client) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { + c.logger.Debug("call " + MethodWindowWorkDoneProgressCreate) + defer c.logger.Debug("end "+MethodWindowWorkDoneProgressCreate, zap.Error(err)) + + return Call(ctx, c.Conn, MethodWindowWorkDoneProgressCreate, params, nil) +} + +func (c *client) refresh(ctx context.Context, method string) (err error) { + c.logger.Debug("call " + method) + defer c.logger.Debug("end "+method, zap.Error(err)) + + return c.Conn.Notify(ctx, method, nil) +} + // WorkspaceFolders sends the request from the server to the client to fetch the current open list of workspace folders. // // Returns null in the response if only a single file is open in the tool. Returns an empty array if a workspace is open but no folders are configured. // // @since 3.6.0. -func (c *client) WorkspaceWorkspaceFolders(ctx context.Context) (result []*WorkspaceFolder, err error) { +func (c *client) WorkspaceFolders(ctx context.Context) (result []*WorkspaceFolder, err error) { c.logger.Debug("call " + MethodWorkspaceWorkspaceFolders) defer c.logger.Debug("end "+MethodWorkspaceWorkspaceFolders, zap.Error(err)) diff --git a/protocol/client_interface.go b/protocol/client_interface.go index 5ef359be..ad7989a3 100644 --- a/protocol/client_interface.go +++ b/protocol/client_interface.go @@ -12,16 +12,11 @@ import ( const ( MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification MethodClientProgress ClientMethod = "$/progress" // bidirect client notification + MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification MethodLogTrace ClientMethod = "$/logTrace" // client notification - MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification - MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification MethodWindowShowMessage ClientMethod = "window/showMessage" // client notification - MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request - MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request - MethodWindowShowDocument ClientMethod = "window/showDocument" // client request - MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request - MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request + MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request @@ -29,96 +24,101 @@ const ( MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request + MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request + MethodWindowShowDocument ClientMethod = "window/showDocument" // client request + MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request MethodWorkspaceTextDocumentContentRefresh ClientMethod = "workspace/textDocumentContent/refresh" // client request + MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request + MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request ) type Client interface { - CancelRequest(ctx context.Context, params *CancelParams) error + Cancel(ctx context.Context, params *CancelParams) error Progress(ctx context.Context, params *ProgressParams) error - LogTrace(ctx context.Context, params *LogTraceParams) error - - // TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data. - TelemetryEvent(ctx context.Context, params any) error - - // TextDocumentPublishDiagnostics diagnostics notification are sent from the server to the client to signal results of validation runs. - TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error + // LogMessage the log message notification is sent from the server to the client to ask the client to log a particular message. + LogMessage(ctx context.Context, params *LogMessageParams) error - // WindowLogMessage the log message notification is sent from the server to the client to ask the client to log a particular message. - WindowLogMessage(ctx context.Context, params *LogMessageParams) error - - // WindowShowMessage the show message notification is sent from a server to a client to ask the client to display a particular message in the user interface. - WindowShowMessage(ctx context.Context, params *ShowMessageParams) error - // ClientRegisterCapability the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side. - ClientRegisterCapability(ctx context.Context, params *RegistrationParams) error - - // ClientUnregisterCapability the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side. - ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) error - - // WindowShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser. - // - // @since 3.16.0 - WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) + LogTrace(ctx context.Context, params *LogTraceParams) error - // WindowShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user. - WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) + // PublishDiagnostics diagnostics notification are sent from the server to the client to signal results of validation runs. + PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error - // WindowWorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server. - WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error + // ShowMessage the show message notification is sent from a server to a client to ask the client to display a particular message in the user interface. + ShowMessage(ctx context.Context, params *ShowMessageParams) error - // WorkspaceApplyEdit a request sent from the server to the client to modified certain resources. - WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) + // TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data. + TelemetryEvent(ctx context.Context, params any) error + // ApplyWorkspaceEdit a request sent from the server to the client to modified certain resources. + ApplyWorkspaceEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) - // WorkspaceCodeLensRefresh a request to refresh all code actions + // CodeLensRefresh a request to refresh all code actions // // @since 3.16.0 - WorkspaceCodeLensRefresh(ctx context.Context) error + CodeLensRefresh(ctx context.Context) error - // WorkspaceConfiguration the 'workspace/configuration' request is sent from the server to the client to fetch a certain configuration setting. This pull model replaces the old push model were the client signaled configuration + // Configuration the 'workspace/configuration' request is sent from the server to the client to fetch a certain configuration setting. This pull model replaces the old push model were the client signaled configuration // change via an event. If the server still needs to react to configuration changes (since the server caches the result of `workspace/configuration` requests) the server should register for an empty configuration change event and empty the cache if such an event is received. - WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) ([]any, error) + Configuration(ctx context.Context, params *ConfigurationParams) ([]any, error) - // WorkspaceDiagnosticRefresh the diagnostic refresh request definition. + // DiagnosticRefresh the diagnostic refresh request definition. // // @since 3.17.0 - WorkspaceDiagnosticRefresh(ctx context.Context) error + DiagnosticRefresh(ctx context.Context) error - // WorkspaceFoldingRangeRefresh. + // FoldingRangeRefresh. // // @since 3.18.0 proposed - WorkspaceFoldingRangeRefresh(ctx context.Context) error + FoldingRangeRefresh(ctx context.Context) error - // WorkspaceInlayHintRefresh. + // InlayHintRefresh. // // @since 3.17.0 - WorkspaceInlayHintRefresh(ctx context.Context) error + InlayHintRefresh(ctx context.Context) error - // WorkspaceInlineValueRefresh. + // InlineValueRefresh. // // @since 3.17.0 - WorkspaceInlineValueRefresh(ctx context.Context) error + InlineValueRefresh(ctx context.Context) error - // WorkspaceSemanticTokensRefresh. + // Registration the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side. + Registration(ctx context.Context, params *RegistrationParams) error + + // SemanticTokensRefresh. // // @since 3.16.0 - WorkspaceSemanticTokensRefresh(ctx context.Context) error + SemanticTokensRefresh(ctx context.Context) error + + // ShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser. + // + // @since 3.16.0 + ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) + + // ShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user. + ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) - // WorkspaceTextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed. + // TextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed. // // @since 3.18.0 proposed - WorkspaceTextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error + TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error - // WorkspaceWorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders. - WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) + // Unregistration the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side. + Unregistration(ctx context.Context, params *UnregistrationParams) error + + // WorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server. + WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error + + // WorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders. + WorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) } // UnimplementedClient should be embedded to have forward compatible implementations. type UnimplementedClient struct{} -func (UnimplementedClient) CancelRequest(ctx context.Context, params *CancelParams) error { +func (UnimplementedClient) Cancel(ctx context.Context, params *CancelParams) error { return jsonrpc2.ErrInternal } @@ -126,82 +126,82 @@ func (UnimplementedClient) Progress(ctx context.Context, params *ProgressParams) return jsonrpc2.ErrInternal } -func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error { +func (UnimplementedClient) LogMessage(ctx context.Context, params *LogMessageParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error { +func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) TextDocumentPublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error { +func (UnimplementedClient) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) WindowLogMessage(ctx context.Context, params *LogMessageParams) error { +func (UnimplementedClient) ShowMessage(ctx context.Context, params *ShowMessageParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) WindowShowMessage(ctx context.Context, params *ShowMessageParams) error { +func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) ClientRegisterCapability(ctx context.Context, params *RegistrationParams) error { - return jsonrpc2.ErrInternal +func (UnimplementedClient) ApplyWorkspaceEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) { + return nil, jsonrpc2.ErrInternal } -func (UnimplementedClient) ClientUnregisterCapability(ctx context.Context, params *UnregistrationParams) error { +func (UnimplementedClient) CodeLensRefresh(ctx context.Context) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) WindowShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) { +func (UnimplementedClient) Configuration(ctx context.Context, params *ConfigurationParams) ([]any, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedClient) WindowShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) { - return nil, jsonrpc2.ErrInternal +func (UnimplementedClient) DiagnosticRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal } -func (UnimplementedClient) WindowWorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error { +func (UnimplementedClient) FoldingRangeRefresh(ctx context.Context) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) { - return nil, jsonrpc2.ErrInternal +func (UnimplementedClient) InlayHintRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceCodeLensRefresh(ctx context.Context) error { +func (UnimplementedClient) InlineValueRefresh(ctx context.Context) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceConfiguration(ctx context.Context, params *ConfigurationParams) ([]any, error) { - return nil, jsonrpc2.ErrInternal +func (UnimplementedClient) Registration(ctx context.Context, params *RegistrationParams) error { + return jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceDiagnosticRefresh(ctx context.Context) error { +func (UnimplementedClient) SemanticTokensRefresh(ctx context.Context) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceFoldingRangeRefresh(ctx context.Context) error { - return jsonrpc2.ErrInternal +func (UnimplementedClient) ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) { + return nil, jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceInlayHintRefresh(ctx context.Context) error { - return jsonrpc2.ErrInternal +func (UnimplementedClient) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) { + return nil, jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceInlineValueRefresh(ctx context.Context) error { +func (UnimplementedClient) TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceSemanticTokensRefresh(ctx context.Context) error { +func (UnimplementedClient) Unregistration(ctx context.Context, params *UnregistrationParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceTextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error { +func (UnimplementedClient) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) WorkspaceWorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) { +func (UnimplementedClient) WorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) { return nil, jsonrpc2.ErrInternal } diff --git a/protocol/server.go b/protocol/server.go index 9664d90a..320e8c08 100644 --- a/protocol/server.go +++ b/protocol/server.go @@ -120,7 +120,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidChange(ctx, ¶ms) + err := server.DidChangeNotebookDocument(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -132,7 +132,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidClose(ctx, ¶ms) + err := server.DidCloseNotebookDocument(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -144,7 +144,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidOpen(ctx, ¶ms) + err := server.DidOpenNotebookDocument(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -156,7 +156,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.NotebookDocumentDidSave(ctx, ¶ms) + err := server.DidSaveNotebookDocument(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -168,7 +168,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidChange(ctx, ¶ms) + err := server.DidChangeTextDocument(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -180,7 +180,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidClose(ctx, ¶ms) + err := server.DidCloseTextDocument(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -192,7 +192,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidOpen(ctx, ¶ms) + err := server.DidOpenTextDocument(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -204,7 +204,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentDidSave(ctx, ¶ms) + err := server.DidSaveTextDocument(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -216,7 +216,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.TextDocumentWillSave(ctx, ¶ms) + err := server.WillSaveTextDocument(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -228,7 +228,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WindowWorkDoneProgressCancel(ctx, ¶ms) + err := server.WorkDoneProgressCancel(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -240,7 +240,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidChangeConfiguration(ctx, ¶ms) + err := server.DidChangeConfiguration(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -252,7 +252,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidChangeWatchedFiles(ctx, ¶ms) + err := server.DidChangeWatchedFiles(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -264,7 +264,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidChangeWorkspaceFolders(ctx, ¶ms) + err := server.DidChangeWorkspaceFolders(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -276,7 +276,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidCreateFiles(ctx, ¶ms) + err := server.DidCreateFiles(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -288,7 +288,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidDeleteFiles(ctx, ¶ms) + err := server.DidDeleteFiles(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -300,7 +300,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - err := server.WorkspaceDidRenameFiles(ctx, ¶ms) + err := server.DidRenameFiles(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -360,7 +360,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.CompletionItemResolve(ctx, ¶ms) + resp, err := server.CompletionResolve(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -419,7 +419,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentCodeAction(ctx, ¶ms) + resp, err := server.CodeAction(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -431,7 +431,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentCodeLens(ctx, ¶ms) + resp, err := server.CodeLens(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -443,7 +443,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentColorPresentation(ctx, ¶ms) + resp, err := server.ColorPresentation(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -455,7 +455,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentCompletion(ctx, ¶ms) + resp, err := server.Completion(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -467,7 +467,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDeclaration(ctx, ¶ms) + resp, err := server.Declaration(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -479,7 +479,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDefinition(ctx, ¶ms) + resp, err := server.Definition(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -491,7 +491,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDiagnostic(ctx, ¶ms) + resp, err := server.DocumentDiagnostic(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -503,7 +503,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentColor(ctx, ¶ms) + resp, err := server.DocumentColor(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -515,7 +515,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentHighlight(ctx, ¶ms) + resp, err := server.DocumentHighlight(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -527,7 +527,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentLink(ctx, ¶ms) + resp, err := server.DocumentLink(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -539,7 +539,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentDocumentSymbol(ctx, ¶ms) + resp, err := server.DocumentSymbol(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -551,7 +551,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentFoldingRange(ctx, ¶ms) + resp, err := server.FoldingRange(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -563,7 +563,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentFormatting(ctx, ¶ms) + resp, err := server.DocumentFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -575,7 +575,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentHover(ctx, ¶ms) + resp, err := server.Hover(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -587,7 +587,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentImplementation(ctx, ¶ms) + resp, err := server.Implementation(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -599,7 +599,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentInlayHint(ctx, ¶ms) + resp, err := server.InlayHint(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -611,7 +611,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentInlineCompletion(ctx, ¶ms) + resp, err := server.InlineCompletion(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -623,7 +623,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentInlineValue(ctx, ¶ms) + resp, err := server.InlineValue(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -635,7 +635,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentLinkedEditingRange(ctx, ¶ms) + resp, err := server.LinkedEditingRange(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -647,7 +647,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentMoniker(ctx, ¶ms) + resp, err := server.Moniker(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -659,7 +659,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentOnTypeFormatting(ctx, ¶ms) + resp, err := server.DocumentOnTypeFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -671,7 +671,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentPrepareCallHierarchy(ctx, ¶ms) + resp, err := server.CallHierarchyPrepare(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -683,7 +683,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentPrepareRename(ctx, ¶ms) + resp, err := server.PrepareRename(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -695,7 +695,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentPrepareTypeHierarchy(ctx, ¶ms) + resp, err := server.TypeHierarchyPrepare(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -707,7 +707,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentRangeFormatting(ctx, ¶ms) + resp, err := server.DocumentRangeFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -719,7 +719,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentRangesFormatting(ctx, ¶ms) + resp, err := server.DocumentRangesFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -731,7 +731,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentReferences(ctx, ¶ms) + resp, err := server.References(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -743,7 +743,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentRename(ctx, ¶ms) + resp, err := server.Rename(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -755,7 +755,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSelectionRange(ctx, ¶ms) + resp, err := server.SelectionRange(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -767,7 +767,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSemanticTokensFull(ctx, ¶ms) + resp, err := server.SemanticTokens(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -779,7 +779,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSemanticTokensFullDelta(ctx, ¶ms) + resp, err := server.SemanticTokensDelta(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -791,7 +791,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSemanticTokensRange(ctx, ¶ms) + resp, err := server.SemanticTokensRange(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -803,7 +803,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentSignatureHelp(ctx, ¶ms) + resp, err := server.SignatureHelp(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -815,7 +815,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentTypeDefinition(ctx, ¶ms) + resp, err := server.TypeDefinition(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -827,7 +827,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.TextDocumentWillSaveWaitUntil(ctx, ¶ms) + resp, err := server.WillSaveTextDocumentWaitUntil(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -875,7 +875,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.WorkspaceExecuteCommand(ctx, ¶ms) + resp, err := server.ExecuteCommand(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -899,7 +899,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.WorkspaceWillCreateFiles(ctx, ¶ms) + resp, err := server.WillCreateFiles(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -911,7 +911,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.WorkspaceWillDeleteFiles(ctx, ¶ms) + resp, err := server.WillDeleteFiles(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -923,7 +923,7 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.WorkspaceWillRenameFiles(ctx, ¶ms) + resp, err := server.WillRenameFiles(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -953,7 +953,7 @@ type server struct { var _ Server = (*server)(nil) -func (s *server) CancelRequest(ctx context.Context, params *CancelParams) (err error) { +func (s *server) Cancel(ctx context.Context, params *CancelParams) (err error) { s.logger.Debug("notify " + MethodClientCancelRequest) defer s.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) @@ -1005,7 +1005,7 @@ func (s *server) Initialized(ctx context.Context, params *InitializedParams) (er return s.Conn.Notify(ctx, MethodInitialized, params) } -func (s *server) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) (err error) { +func (s *server) DidChangeNotebookDocument(ctx context.Context, params *DidChangeNotebookDocumentParams) (err error) { s.logger.Debug("call " + MethodNotebookDocumentDidChange) defer s.logger.Debug("end "+MethodNotebookDocumentDidChange, zap.Error(err)) @@ -1015,7 +1015,7 @@ func (s *server) NotebookDocumentDidChange(ctx context.Context, params *DidChang // NotebookDocumentDidClose a notification sent when a notebook closes. // // @since 3.17.0 -func (s *server) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) (err error) { +func (s *server) DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) (err error) { s.logger.Debug("call " + MethodNotebookDocumentDidClose) defer s.logger.Debug("end "+MethodNotebookDocumentDidClose, zap.Error(err)) @@ -1025,7 +1025,7 @@ func (s *server) NotebookDocumentDidClose(ctx context.Context, params *DidCloseN // NotebookDocumentDidOpen a notification sent when a notebook opens. // // @since 3.17.0 -func (s *server) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) (err error) { +func (s *server) DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) (err error) { s.logger.Debug("call " + MethodNotebookDocumentDidOpen) defer s.logger.Debug("end "+MethodNotebookDocumentDidOpen, zap.Error(err)) @@ -1035,7 +1035,7 @@ func (s *server) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNot // NotebookDocumentDidSave a notification sent when a notebook document is saved. // // @since 3.17.0 -func (s *server) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) (err error) { +func (s *server) DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) (err error) { s.logger.Debug("call " + MethodNotebookDocumentDidSave) defer s.logger.Debug("end "+MethodNotebookDocumentDidSave, zap.Error(err)) @@ -1045,7 +1045,7 @@ func (s *server) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNot // DidChange sends the notification from the client to the server to signal changes to a text document. // // In 2.0 the shape of the params has changed to include proper version numbers and language ids. -func (s *server) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { +func (s *server) DidChangeTextDocument(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { s.logger.Debug("notify " + MethodTextDocumentDidChange) defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) @@ -1060,7 +1060,7 @@ func (s *server) TextDocumentDidChange(ctx context.Context, params *DidChangeTex // // A close notification requires a previous open notification to be sent. // Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { +func (s *server) DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { s.logger.Debug("call " + MethodTextDocumentDidClose) defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) @@ -1075,7 +1075,7 @@ func (s *server) TextDocumentDidClose(ctx context.Context, params *DidCloseTextD // An open notification must not be sent more than once without a corresponding close notification send before. // This means open and close notification must be balanced and the max open count for a particular textDocument is one. // Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { +func (s *server) DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { s.logger.Debug("call " + MethodTextDocumentDidOpen) defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) @@ -1083,7 +1083,7 @@ func (s *server) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDoc } // DidSave sends the notification from the client to the server when the document was saved in the client. -func (s *server) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { +func (s *server) DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { s.logger.Debug("call " + MethodTextDocumentDidSave) defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) @@ -1091,7 +1091,7 @@ func (s *server) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDoc } // WillSave sends the notification from the client to the server before the document is actually saved. -func (s *server) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { +func (s *server) WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { s.logger.Debug("call " + MethodTextDocumentWillSave) defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) @@ -1100,7 +1100,7 @@ func (s *server) TextDocumentWillSave(ctx context.Context, params *WillSaveTextD // WindowWorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the // server side using the "window/workDoneProgress/create". -func (s *server) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { +func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { s.logger.Debug("call " + MethodWindowWorkDoneProgressCancel) defer s.logger.Debug("end "+MethodWindowWorkDoneProgressCancel, zap.Error(err)) @@ -1108,7 +1108,7 @@ func (s *server) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkD } // DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. -func (s *server) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { +func (s *server) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) @@ -1119,7 +1119,7 @@ func (s *server) WorkspaceDidChangeConfiguration(ctx context.Context, params *Di // // It is recommended that servers register for these file events using the registration mechanism. // In former implementations clients pushed file events without the server actively asking for it. -func (s *server) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { +func (s *server) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) @@ -1133,7 +1133,7 @@ func (s *server) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *Did // To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. // // The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). -func (s *server) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { +func (s *server) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) @@ -1143,7 +1143,7 @@ func (s *server) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params // DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. // // @since 3.16.0. -func (s *server) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { +func (s *server) DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { s.logger.Debug("call " + MethodWorkspaceDidCreateFiles) defer s.logger.Debug("end "+MethodWorkspaceDidCreateFiles, zap.Error(err)) @@ -1153,7 +1153,7 @@ func (s *server) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFile // DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. // // @since 3.16.0. -func (s *server) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { +func (s *server) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { s.logger.Debug("call " + MethodWorkspaceDidDeleteFiles) defer s.logger.Debug("end "+MethodWorkspaceDidDeleteFiles, zap.Error(err)) @@ -1163,7 +1163,7 @@ func (s *server) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFile // DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. // // @since 3.16.0. -func (s *server) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { +func (s *server) DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { s.logger.Debug("call " + MethodWorkspaceDidRenameFiles) defer s.logger.Debug("end "+MethodWorkspaceDidRenameFiles, zap.Error(err)) @@ -1230,7 +1230,7 @@ func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *Code } // CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. -func (s *server) CompletionItemResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { +func (s *server) CompletionResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { s.logger.Debug("call " + MethodCompletionItemResolve) defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) @@ -1314,11 +1314,11 @@ func (s *server) Shutdown(ctx context.Context) (err error) { // To ensure that a server is useful in many clients the commands specified in a code actions should be handled by the // server and not by the client (see `workspace/executeCommand` and `ServerCapabilities.executeCommandProvider`). // If the client supports providing edits with a code action then the mode should be used. -func (s *server) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (_ *TextDocumentCodeActionResult, err error) { +func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (_ *CodeActionRequestResult, err error) { s.logger.Debug("call " + MethodTextDocumentCodeAction) defer s.logger.Debug("end "+MethodTextDocumentCodeAction, zap.Error(err)) - var result *TextDocumentCodeActionResult + var result *CodeActionRequestResult if err := Call(ctx, s.Conn, MethodTextDocumentCodeAction, params, &result); err != nil { return nil, err } @@ -1327,7 +1327,7 @@ func (s *server) TextDocumentCodeAction(ctx context.Context, params *CodeActionP } // CodeLens sends the request from the client to the server to compute code lenses for a given text document. -func (s *server) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) (_ []*CodeLens, err error) { +func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (_ []*CodeLens, err error) { s.logger.Debug("call " + MethodTextDocumentCodeLens) defer s.logger.Debug("end "+MethodTextDocumentCodeLens, zap.Error(err)) @@ -1345,7 +1345,7 @@ func (s *server) TextDocumentCodeLens(ctx context.Context, params *CodeLensParam // // - modify a color reference. // - show in a color picker and let users pick one of the presentations. -func (s *server) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) (_ []*ColorPresentation, err error) { +func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentationParams) (_ []*ColorPresentation, err error) { s.logger.Debug("call " + MethodTextDocumentColorPresentation) defer s.logger.Debug("end "+MethodTextDocumentColorPresentation, zap.Error(err)) @@ -1370,11 +1370,11 @@ func (s *server) TextDocumentColorPresentation(ctx context.Context, params *Colo // The returned completion item should have the documentation property filled in. The request can delay the computation of // the `detail` and `documentation` properties. However, properties that are needed for the initial sorting and filtering, // like `sortText`, `filterText`, `insertText`, and `textEdit` must be provided in the `textDocument/completion` response and must not be changed during resolve. -func (s *server) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (_ *TextDocumentCompletionResult, err error) { +func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *CompletionResult, err error) { s.logger.Debug("call " + MethodTextDocumentCompletion) defer s.logger.Debug("end "+MethodTextDocumentCompletion, zap.Error(err)) - var result *TextDocumentCompletionResult + var result *CompletionResult if err := Call(ctx, s.Conn, MethodTextDocumentCompletion, params, &result); err != nil { return nil, err } @@ -1387,11 +1387,11 @@ func (s *server) TextDocumentCompletion(ctx context.Context, params *CompletionP // The result type LocationLink[] got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.declaration.linkSupport`. // // @since 3.14.0. -func (s *server) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (_ *TextDocumentDeclarationResult, err error) { +func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (_ *DeclarationResult, err error) { s.logger.Debug("call " + MethodTextDocumentDeclaration) defer s.logger.Debug("end "+MethodTextDocumentDeclaration, zap.Error(err)) - var result *TextDocumentDeclarationResult + var result *DeclarationResult if err := Call(ctx, s.Conn, MethodTextDocumentDeclaration, params, &result); err != nil { return nil, err } @@ -1404,11 +1404,11 @@ func (s *server) TextDocumentDeclaration(ctx context.Context, params *Declaratio // The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.definition.linkSupport`. // // @since 3.14.0. -func (s *server) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (_ *TextDocumentDefinitionResult, err error) { +func (s *server) Definition(ctx context.Context, params *DefinitionParams) (_ *DefinitionResult, err error) { s.logger.Debug("call " + MethodTextDocumentDefinition) defer s.logger.Debug("end "+MethodTextDocumentDefinition, zap.Error(err)) - var result *TextDocumentDefinitionResult + var result *DefinitionResult if err := Call(ctx, s.Conn, MethodTextDocumentDefinition, params, &result); err != nil { return nil, err } @@ -1416,7 +1416,7 @@ func (s *server) TextDocumentDefinition(ctx context.Context, params *DefinitionP return result, nil } -func (s *server) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (_ *DocumentDiagnosticReport, err error) { +func (s *server) DocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (_ *DocumentDiagnosticReport, err error) { s.logger.Debug("call " + MethodTextDocumentDiagnostic) defer s.logger.Debug("end "+MethodTextDocumentDiagnostic, zap.Error(err)) @@ -1437,7 +1437,7 @@ func (s *server) TextDocumentDiagnostic(ctx context.Context, params *DocumentDia // // - Color boxes showing the actual color next to the reference // - Show a color picker when a color reference is edited. -func (s *server) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) (_ []*ColorInformation, err error) { +func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) (_ []*ColorInformation, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentColor) defer s.logger.Debug("end "+MethodTextDocumentDocumentColor, zap.Error(err)) @@ -1455,7 +1455,7 @@ func (s *server) TextDocumentDocumentColor(ctx context.Context, params *Document // However we kept ‘textDocument/documentHighlight’ and ‘textDocument/references’ separate requests since the first one is allowed to be more fuzzy. // // Symbol matches usually have a `DocumentHighlightKind` of `Read` or `Write` whereas fuzzy or textual matches use `Text` as the kind. -func (s *server) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (_ []*DocumentHighlight, err error) { +func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (_ []*DocumentHighlight, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentHighlight) defer s.logger.Debug("end "+MethodTextDocumentDocumentHighlight, zap.Error(err)) @@ -1468,7 +1468,7 @@ func (s *server) TextDocumentDocumentHighlight(ctx context.Context, params *Docu } // DocumentLink sends the request from the client to the server to request the location of links in a document. -func (s *server) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) (_ []*DocumentLink, err error) { +func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) (_ []*DocumentLink, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentLink) defer s.logger.Debug("end "+MethodTextDocumentDocumentLink, zap.Error(err)) @@ -1483,11 +1483,11 @@ func (s *server) TextDocumentDocumentLink(ctx context.Context, params *DocumentL // DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. // // Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. -func (s *server) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (_ *TextDocumentDocumentSymbolResult, err error) { +func (s *server) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (_ *DocumentSymbolResult, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) - var result *TextDocumentDocumentSymbolResult + var result *DocumentSymbolResult if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { return nil, err } @@ -1498,7 +1498,7 @@ func (s *server) TextDocumentDocumentSymbol(ctx context.Context, params *Documen // FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. // // @since version 3.10.0. -func (s *server) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) (_ []*FoldingRange, err error) { +func (s *server) FoldingRange(ctx context.Context, params *FoldingRangeParams) (_ []*FoldingRange, err error) { s.logger.Debug("call " + MethodTextDocumentFoldingRange) defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) @@ -1510,8 +1510,8 @@ func (s *server) TextDocumentFoldingRange(ctx context.Context, params *FoldingRa return result, nil } -// Formatting sends the request from the client to the server to format a whole document. -func (s *server) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) (_ []*TextEdit, err error) { +// DocumentFormatting sends the request from the client to the server to format a whole document. +func (s *server) DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) (_ []*TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentFormatting) defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) @@ -1524,7 +1524,7 @@ func (s *server) TextDocumentFormatting(ctx context.Context, params *DocumentFor } // Hover sends the request is from the client to the server to request hover information at a given text document position. -func (s *server) TextDocumentHover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { +func (s *server) Hover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { s.logger.Debug("call " + MethodTextDocumentHover) defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) @@ -1539,11 +1539,11 @@ func (s *server) TextDocumentHover(ctx context.Context, params *HoverParams) (_ // Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. // // The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. -func (s *server) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (_ *TextDocumentImplementationResult, err error) { +func (s *server) Implementation(ctx context.Context, params *ImplementationParams) (_ *ImplementationResult, err error) { s.logger.Debug("call " + MethodTextDocumentImplementation) defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) - var result *TextDocumentImplementationResult + var result *ImplementationResult if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { return nil, err } @@ -1551,7 +1551,7 @@ func (s *server) TextDocumentImplementation(ctx context.Context, params *Impleme return result, nil } -func (s *server) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) (_ []*InlayHint, err error) { +func (s *server) InlayHint(ctx context.Context, params *InlayHintParams) (_ []*InlayHint, err error) { s.logger.Debug("call " + MethodTextDocumentInlayHint) defer s.logger.Debug("end "+MethodTextDocumentInlayHint, zap.Error(err)) @@ -1563,11 +1563,11 @@ func (s *server) TextDocumentInlayHint(ctx context.Context, params *InlayHintPar return result, nil } -func (s *server) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (_ *TextDocumentInlineCompletionResult, err error) { +func (s *server) InlineCompletion(ctx context.Context, params *InlineCompletionParams) (_ *InlineCompletionResult, err error) { s.logger.Debug("call " + MethodTextDocumentInlineCompletion) defer s.logger.Debug("end "+MethodTextDocumentInlineCompletion, zap.Error(err)) - var result *TextDocumentInlineCompletionResult + var result *InlineCompletionResult if err := Call(ctx, s.Conn, MethodTextDocumentInlineCompletion, params, &result); err != nil { return nil, err } @@ -1575,7 +1575,7 @@ func (s *server) TextDocumentInlineCompletion(ctx context.Context, params *Inlin return result, nil } -func (s *server) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) (_ []*InlineValue, err error) { +func (s *server) InlineValue(ctx context.Context, params *InlineValueParams) (_ []*InlineValue, err error) { s.logger.Debug("call " + MethodTextDocumentInlineValue) defer s.logger.Debug("end "+MethodTextDocumentInlineValue, zap.Error(err)) @@ -1594,7 +1594,7 @@ func (s *server) TextDocumentInlineValue(ctx context.Context, params *InlineValu // A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. // // @since 3.16.0. -func (s *server) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (_ *LinkedEditingRanges, err error) { +func (s *server) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (_ *LinkedEditingRanges, err error) { s.logger.Debug("call " + MethodTextDocumentLinkedEditingRange) defer s.logger.Debug("end "+MethodTextDocumentLinkedEditingRange, zap.Error(err)) @@ -1613,7 +1613,7 @@ func (s *server) TextDocumentLinkedEditingRange(ctx context.Context, params *Lin // If no monikers can be calculated, an empty array or null should be returned. // // @since 3.16.0. -func (s *server) TextDocumentMoniker(ctx context.Context, params *MonikerParams) (_ []*Moniker, err error) { +func (s *server) Moniker(ctx context.Context, params *MonikerParams) (_ []*Moniker, err error) { s.logger.Debug("call " + MethodTextDocumentMoniker) defer s.logger.Debug("end "+MethodTextDocumentMoniker, zap.Error(err)) @@ -1626,7 +1626,7 @@ func (s *server) TextDocumentMoniker(ctx context.Context, params *MonikerParams) } // OnTypeFormatting sends the request from the client to the server to format parts of the document during typing. -func (s *server) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (_ []*TextEdit, err error) { +func (s *server) DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (_ []*TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentOnTypeFormatting) defer s.logger.Debug("end "+MethodTextDocumentOnTypeFormatting, zap.Error(err)) @@ -1645,7 +1645,7 @@ func (s *server) TextDocumentOnTypeFormatting(ctx context.Context, params *Docum // 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. // // @since 3.16.0. -func (s *server) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (_ []*CallHierarchyItem, err error) { +func (s *server) CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) (_ []*CallHierarchyItem, err error) { s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) @@ -1660,7 +1660,7 @@ func (s *server) TextDocumentPrepareCallHierarchy(ctx context.Context, params *C // PrepareRename sends the request from the client to the server to setup and test the validity of a rename operation at a given location. // // @since version 3.12.0. -func (s *server) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (_ *PrepareRenameResult, err error) { +func (s *server) PrepareRename(ctx context.Context, params *PrepareRenameParams) (_ *PrepareRenameResult, err error) { s.logger.Debug("call " + MethodTextDocumentPrepareRename) defer s.logger.Debug("end "+MethodTextDocumentPrepareRename, zap.Error(err)) @@ -1672,7 +1672,7 @@ func (s *server) TextDocumentPrepareRename(ctx context.Context, params *PrepareR return result, nil } -func (s *server) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) (_ []*TypeHierarchyItem, err error) { +func (s *server) TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) (_ []*TypeHierarchyItem, err error) { s.logger.Debug("call " + MethodTextDocumentPrepareTypeHierarchy) defer s.logger.Debug("end "+MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) @@ -1685,7 +1685,7 @@ func (s *server) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *T } // RangeFormatting sends the request from the client to the server to format a given range in a document. -func (s *server) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (_ []*TextEdit, err error) { +func (s *server) DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (_ []*TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentRangeFormatting) defer s.logger.Debug("end "+MethodTextDocumentRangeFormatting, zap.Error(err)) @@ -1697,7 +1697,7 @@ func (s *server) TextDocumentRangeFormatting(ctx context.Context, params *Docume return result, nil } -func (s *server) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) (_ []*TextEdit, err error) { +func (s *server) DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) (_ []*TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentRangesFormatting) defer s.logger.Debug("end "+MethodTextDocumentRangesFormatting, zap.Error(err)) @@ -1710,7 +1710,7 @@ func (s *server) TextDocumentRangesFormatting(ctx context.Context, params *Docum } // References sends the request from the client to the server to resolve project-wide references for the symbol denoted by the given text document position. -func (s *server) TextDocumentReferences(ctx context.Context, params *ReferenceParams) (_ []*Location, err error) { +func (s *server) References(ctx context.Context, params *ReferenceParams) (_ []*Location, err error) { s.logger.Debug("call " + MethodTextDocumentReferences) defer s.logger.Debug("end "+MethodTextDocumentReferences, zap.Error(err)) @@ -1723,7 +1723,7 @@ func (s *server) TextDocumentReferences(ctx context.Context, params *ReferencePa } // Rename sends the request from the client to the server to perform a workspace-wide rename of a symbol. -func (s *server) TextDocumentRename(ctx context.Context, params *RenameParams) (_ *WorkspaceEdit, err error) { +func (s *server) Rename(ctx context.Context, params *RenameParams) (_ *WorkspaceEdit, err error) { s.logger.Debug("call " + MethodTextDocumentRename) defer s.logger.Debug("end "+MethodTextDocumentRename, zap.Error(err)) @@ -1735,7 +1735,7 @@ func (s *server) TextDocumentRename(ctx context.Context, params *RenameParams) ( return result, nil } -func (s *server) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) (_ []*SelectionRange, err error) { +func (s *server) SelectionRange(ctx context.Context, params *SelectionRangeParams) (_ []*SelectionRange, err error) { s.logger.Debug("call " + MethodTextDocumentSelectionRange) defer s.logger.Debug("end "+MethodTextDocumentSelectionRange, zap.Error(err)) @@ -1754,7 +1754,7 @@ func (s *server) TextDocumentSelectionRange(ctx context.Context, params *Selecti // A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. // // @since 3.16.0. -func (s *server) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (_ *SemanticTokens, err error) { +func (s *server) SemanticTokens(ctx context.Context, params *SemanticTokensParams) (_ *SemanticTokens, err error) { s.logger.Debug("call " + MethodTextDocumentSemanticTokensFull) defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFull, zap.Error(err)) @@ -1773,11 +1773,11 @@ func (s *server) TextDocumentSemanticTokensFull(ctx context.Context, params *Sem // A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. // // @since 3.16.0. -func (s *server) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (_ *TextDocumentSemanticTokensFullDeltaResult, err error) { +func (s *server) SemanticTokensDelta(ctx context.Context, params *SemanticTokensDeltaParams) (_ *SemanticTokensDeltaResult, err error) { s.logger.Debug("call " + MethodTextDocumentSemanticTokensFullDelta) defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) - var result *TextDocumentSemanticTokensFullDeltaResult + var result *SemanticTokensDeltaResult if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFullDelta, params, &result); err != nil { return nil, err } @@ -1793,7 +1793,7 @@ func (s *server) TextDocumentSemanticTokensFullDelta(ctx context.Context, params // Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. // // @since 3.16.0. -func (s *server) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (_ *SemanticTokens, err error) { +func (s *server) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (_ *SemanticTokens, err error) { s.logger.Debug("call " + MethodTextDocumentSemanticTokensRange) defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensRange, zap.Error(err)) @@ -1806,7 +1806,7 @@ func (s *server) TextDocumentSemanticTokensRange(ctx context.Context, params *Se } // SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. -func (s *server) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { +func (s *server) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { s.logger.Debug("call " + MethodTextDocumentSignatureHelp) defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) @@ -1823,11 +1823,11 @@ func (s *server) TextDocumentSignatureHelp(ctx context.Context, params *Signatur // The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. // // @since version 3.6.0. -func (s *server) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (_ *TextDocumentTypeDefinitionResult, err error) { +func (s *server) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (_ *TypeDefinitionResult, err error) { s.logger.Debug("call " + MethodTextDocumentTypeDefinition) defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) - var result *TextDocumentTypeDefinitionResult + var result *TypeDefinitionResult if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { return nil, err } @@ -1840,7 +1840,7 @@ func (s *server) TextDocumentTypeDefinition(ctx context.Context, params *TypeDef // The request can return an array of TextEdits which will be applied to the text document before it is saved. // Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. // This is done to keep the save fast and reliable. -func (s *server) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (_ []*TextEdit, err error) { +func (s *server) WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (_ []*TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) @@ -1892,7 +1892,7 @@ func (s *server) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagn // // In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the // request `workspace/applyEdit` which is sent from the server to the client. -func (s *server) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result any, err error) { +func (s *server) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result any, err error) { s.logger.Debug("call " + MethodWorkspaceExecuteCommand) defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) @@ -1916,10 +1916,10 @@ func (s *server) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolPar return result, nil } -// WorkspaceTextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. +// TextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. // // @since 3.18.0 proposed -func (s *server) WorkspaceTextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (_ *TextDocumentContentResult, err error) { +func (s *server) TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (_ *TextDocumentContentResult, err error) { s.logger.Debug("call " + MethodWorkspaceTextDocumentContent) defer s.logger.Debug("end "+MethodWorkspaceTextDocumentContent, zap.Error(err)) @@ -1938,7 +1938,7 @@ func (s *server) WorkspaceTextDocumentContent(ctx context.Context, params *TextD // Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. // // @since 3.16.0. -func (s *server) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (_ *WorkspaceEdit, err error) { +func (s *server) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (_ *WorkspaceEdit, err error) { s.logger.Debug("call " + MethodWorkspaceWillCreateFiles) defer s.logger.Debug("end "+MethodWorkspaceWillCreateFiles, zap.Error(err)) @@ -1957,7 +1957,7 @@ func (s *server) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFil // Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. // // @since 3.16.0. -func (s *server) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (_ *WorkspaceEdit, err error) { +func (s *server) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (_ *WorkspaceEdit, err error) { s.logger.Debug("call " + MethodWorkspaceWillDeleteFiles) defer s.logger.Debug("end "+MethodWorkspaceWillDeleteFiles, zap.Error(err)) @@ -1976,7 +1976,7 @@ func (s *server) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFil // Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. // // @since 3.16.0. -func (s *server) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (_ *WorkspaceEdit, err error) { +func (s *server) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (_ *WorkspaceEdit, err error) { s.logger.Debug("call " + MethodWorkspaceWillRenameFiles) defer s.logger.Debug("end "+MethodWorkspaceWillRenameFiles, zap.Error(err)) diff --git a/protocol/server_interface.go b/protocol/server_interface.go index 584f549a..12c10e7a 100644 --- a/protocol/server_interface.go +++ b/protocol/server_interface.go @@ -12,155 +12,155 @@ import ( const ( MethodServerCancelRequest ServerMethod = "$/cancelRequest" // bidirect server notification MethodServerProgress ServerMethod = "$/progress" // bidirect server notification - MethodSetTrace ServerMethod = "$/setTrace" // server notification - MethodExit ServerMethod = "exit" // server notification - MethodInitialized ServerMethod = "initialized" // server notification + MethodWorkspaceDidChangeConfiguration ServerMethod = "workspace/didChangeConfiguration" // server notification MethodNotebookDocumentDidChange ServerMethod = "notebookDocument/didChange" // server notification - MethodNotebookDocumentDidClose ServerMethod = "notebookDocument/didClose" // server notification - MethodNotebookDocumentDidOpen ServerMethod = "notebookDocument/didOpen" // server notification - MethodNotebookDocumentDidSave ServerMethod = "notebookDocument/didSave" // server notification MethodTextDocumentDidChange ServerMethod = "textDocument/didChange" // server notification - MethodTextDocumentDidClose ServerMethod = "textDocument/didClose" // server notification - MethodTextDocumentDidOpen ServerMethod = "textDocument/didOpen" // server notification - MethodTextDocumentDidSave ServerMethod = "textDocument/didSave" // server notification - MethodTextDocumentWillSave ServerMethod = "textDocument/willSave" // server notification - MethodWindowWorkDoneProgressCancel ServerMethod = "window/workDoneProgress/cancel" // server notification - MethodWorkspaceDidChangeConfiguration ServerMethod = "workspace/didChangeConfiguration" // server notification MethodWorkspaceDidChangeWatchedFiles ServerMethod = "workspace/didChangeWatchedFiles" // server notification MethodWorkspaceDidChangeWorkspaceFolders ServerMethod = "workspace/didChangeWorkspaceFolders" // server notification + MethodNotebookDocumentDidClose ServerMethod = "notebookDocument/didClose" // server notification + MethodTextDocumentDidClose ServerMethod = "textDocument/didClose" // server notification MethodWorkspaceDidCreateFiles ServerMethod = "workspace/didCreateFiles" // server notification MethodWorkspaceDidDeleteFiles ServerMethod = "workspace/didDeleteFiles" // server notification + MethodNotebookDocumentDidOpen ServerMethod = "notebookDocument/didOpen" // server notification + MethodTextDocumentDidOpen ServerMethod = "textDocument/didOpen" // server notification MethodWorkspaceDidRenameFiles ServerMethod = "workspace/didRenameFiles" // server notification + MethodNotebookDocumentDidSave ServerMethod = "notebookDocument/didSave" // server notification + MethodTextDocumentDidSave ServerMethod = "textDocument/didSave" // server notification + MethodExit ServerMethod = "exit" // server notification + MethodInitialized ServerMethod = "initialized" // server notification + MethodSetTrace ServerMethod = "$/setTrace" // server notification + MethodTextDocumentWillSave ServerMethod = "textDocument/willSave" // server notification + MethodWindowWorkDoneProgressCancel ServerMethod = "window/workDoneProgress/cancel" // server notification MethodCallHierarchyIncomingCalls ServerMethod = "callHierarchy/incomingCalls" // server request MethodCallHierarchyOutgoingCalls ServerMethod = "callHierarchy/outgoingCalls" // server request - MethodCodeActionResolve ServerMethod = "codeAction/resolve" // server request - MethodCodeLensResolve ServerMethod = "codeLens/resolve" // server request - MethodCompletionItemResolve ServerMethod = "completionItem/resolve" // server request - MethodDocumentLinkResolve ServerMethod = "documentLink/resolve" // server request - MethodInitialize ServerMethod = "initialize" // server request - MethodInlayHintResolve ServerMethod = "inlayHint/resolve" // server request - MethodShutdown ServerMethod = "shutdown" // server request + MethodTextDocumentPrepareCallHierarchy ServerMethod = "textDocument/prepareCallHierarchy" // server request MethodTextDocumentCodeAction ServerMethod = "textDocument/codeAction" // server request + MethodCodeActionResolve ServerMethod = "codeAction/resolve" // server request MethodTextDocumentCodeLens ServerMethod = "textDocument/codeLens" // server request + MethodCodeLensResolve ServerMethod = "codeLens/resolve" // server request MethodTextDocumentColorPresentation ServerMethod = "textDocument/colorPresentation" // server request MethodTextDocumentCompletion ServerMethod = "textDocument/completion" // server request + MethodCompletionItemResolve ServerMethod = "completionItem/resolve" // server request MethodTextDocumentDeclaration ServerMethod = "textDocument/declaration" // server request MethodTextDocumentDefinition ServerMethod = "textDocument/definition" // server request - MethodTextDocumentDiagnostic ServerMethod = "textDocument/diagnostic" // server request MethodTextDocumentDocumentColor ServerMethod = "textDocument/documentColor" // server request + MethodTextDocumentDiagnostic ServerMethod = "textDocument/diagnostic" // server request + MethodTextDocumentFormatting ServerMethod = "textDocument/formatting" // server request MethodTextDocumentDocumentHighlight ServerMethod = "textDocument/documentHighlight" // server request MethodTextDocumentDocumentLink ServerMethod = "textDocument/documentLink" // server request + MethodDocumentLinkResolve ServerMethod = "documentLink/resolve" // server request + MethodTextDocumentOnTypeFormatting ServerMethod = "textDocument/onTypeFormatting" // server request + MethodTextDocumentRangeFormatting ServerMethod = "textDocument/rangeFormatting" // server request + MethodTextDocumentRangesFormatting ServerMethod = "textDocument/rangesFormatting" // server request MethodTextDocumentDocumentSymbol ServerMethod = "textDocument/documentSymbol" // server request + MethodWorkspaceExecuteCommand ServerMethod = "workspace/executeCommand" // server request MethodTextDocumentFoldingRange ServerMethod = "textDocument/foldingRange" // server request - MethodTextDocumentFormatting ServerMethod = "textDocument/formatting" // server request MethodTextDocumentHover ServerMethod = "textDocument/hover" // server request MethodTextDocumentImplementation ServerMethod = "textDocument/implementation" // server request + MethodInitialize ServerMethod = "initialize" // server request MethodTextDocumentInlayHint ServerMethod = "textDocument/inlayHint" // server request + MethodInlayHintResolve ServerMethod = "inlayHint/resolve" // server request MethodTextDocumentInlineCompletion ServerMethod = "textDocument/inlineCompletion" // server request MethodTextDocumentInlineValue ServerMethod = "textDocument/inlineValue" // server request MethodTextDocumentLinkedEditingRange ServerMethod = "textDocument/linkedEditingRange" // server request MethodTextDocumentMoniker ServerMethod = "textDocument/moniker" // server request - MethodTextDocumentOnTypeFormatting ServerMethod = "textDocument/onTypeFormatting" // server request - MethodTextDocumentPrepareCallHierarchy ServerMethod = "textDocument/prepareCallHierarchy" // server request MethodTextDocumentPrepareRename ServerMethod = "textDocument/prepareRename" // server request - MethodTextDocumentPrepareTypeHierarchy ServerMethod = "textDocument/prepareTypeHierarchy" // server request - MethodTextDocumentRangeFormatting ServerMethod = "textDocument/rangeFormatting" // server request - MethodTextDocumentRangesFormatting ServerMethod = "textDocument/rangesFormatting" // server request MethodTextDocumentReferences ServerMethod = "textDocument/references" // server request MethodTextDocumentRename ServerMethod = "textDocument/rename" // server request MethodTextDocumentSelectionRange ServerMethod = "textDocument/selectionRange" // server request - MethodTextDocumentSemanticTokensFull ServerMethod = "textDocument/semanticTokens/full" // server request MethodTextDocumentSemanticTokensFullDelta ServerMethod = "textDocument/semanticTokens/full/delta" // server request MethodTextDocumentSemanticTokensRange ServerMethod = "textDocument/semanticTokens/range" // server request + MethodTextDocumentSemanticTokensFull ServerMethod = "textDocument/semanticTokens/full" // server request + MethodShutdown ServerMethod = "shutdown" // server request MethodTextDocumentSignatureHelp ServerMethod = "textDocument/signatureHelp" // server request + MethodWorkspaceTextDocumentContent ServerMethod = "workspace/textDocumentContent" // server request MethodTextDocumentTypeDefinition ServerMethod = "textDocument/typeDefinition" // server request - MethodTextDocumentWillSaveWaitUntil ServerMethod = "textDocument/willSaveWaitUntil" // server request + MethodTextDocumentPrepareTypeHierarchy ServerMethod = "textDocument/prepareTypeHierarchy" // server request MethodTypeHierarchySubtypes ServerMethod = "typeHierarchy/subtypes" // server request MethodTypeHierarchySupertypes ServerMethod = "typeHierarchy/supertypes" // server request - MethodWorkspaceDiagnostic ServerMethod = "workspace/diagnostic" // server request - MethodWorkspaceExecuteCommand ServerMethod = "workspace/executeCommand" // server request - MethodWorkspaceSymbol ServerMethod = "workspace/symbol" // server request - MethodWorkspaceTextDocumentContent ServerMethod = "workspace/textDocumentContent" // server request MethodWorkspaceWillCreateFiles ServerMethod = "workspace/willCreateFiles" // server request MethodWorkspaceWillDeleteFiles ServerMethod = "workspace/willDeleteFiles" // server request MethodWorkspaceWillRenameFiles ServerMethod = "workspace/willRenameFiles" // server request + MethodTextDocumentWillSaveWaitUntil ServerMethod = "textDocument/willSaveWaitUntil" // server request + MethodWorkspaceDiagnostic ServerMethod = "workspace/diagnostic" // server request + MethodWorkspaceSymbol ServerMethod = "workspace/symbol" // server request MethodWorkspaceSymbolResolve ServerMethod = "workspaceSymbol/resolve" // server request ) type Server interface { - CancelRequest(ctx context.Context, params *CancelParams) error + Cancel(ctx context.Context, params *CancelParams) error Progress(ctx context.Context, params *ProgressParams) error - SetTrace(ctx context.Context, params *SetTraceParams) error + // DidChangeConfiguration the configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains the changed configuration as defined by the language client. + DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error - // Exit the exit event is sent from the client to the server to ask the server to exit its process. - Exit(ctx context.Context) error + DidChangeNotebookDocument(ctx context.Context, params *DidChangeNotebookDocumentParams) error - // Initialized the initialized notification is sent from the client to the server after the client is fully initialized and the server is allowed to send requests from the server to the client. - Initialized(ctx context.Context, params *InitializedParams) error + // DidChangeTextDocument the document change notification is sent from the client to the server to signal changes to a text document. + DidChangeTextDocument(ctx context.Context, params *DidChangeTextDocumentParams) error - NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) error + // DidChangeWatchedFiles the watched files notification is sent from the client to the server when the client detects changes + // to file watched by the language client. + DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error - // NotebookDocumentDidClose a notification sent when a notebook closes. - // - // @since 3.17.0 - NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) error + // DidChangeWorkspaceFolders the `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace folder configuration changes. + DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error - // NotebookDocumentDidOpen a notification sent when a notebook opens. + // DidCloseNotebookDocument a notification sent when a notebook closes. // // @since 3.17.0 - NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) error + DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) error - // NotebookDocumentDidSave a notification sent when a notebook document is saved. - // - // @since 3.17.0 - NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) error + // DidCloseTextDocument the document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notification to be sent. + DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) error - // TextDocumentDidChange the document change notification is sent from the client to the server to signal changes to a text document. - TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) error + // DidCreateFiles the did create files notification is sent from the client to the server when files were created from + // within the client. + // + // @since 3.16.0 + DidCreateFiles(ctx context.Context, params *CreateFilesParams) error - // TextDocumentDidClose the document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notification to be sent. - TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) error + // DidDeleteFiles the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. + // + // @since 3.16.0 + DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error - // TextDocumentDidOpen the document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one. - TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) error + // DidOpenNotebookDocument a notification sent when a notebook opens. + // + // @since 3.17.0 + DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) error - // TextDocumentDidSave the document save notification is sent from the client to the server when the document got saved in the client. - TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) error + // DidOpenTextDocument the document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one. + DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) error - // TextDocumentWillSave a document will save notification is sent from the client to the server before the document is actually saved. - TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) error + // DidRenameFiles the did rename files notification is sent from the client to the server when files were renamed from + // within the client. + // + // @since 3.16.0 + DidRenameFiles(ctx context.Context, params *RenameFilesParams) error - // WindowWorkDoneProgressCancel the `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress initiated on the server side. - WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error + // DidSaveNotebookDocument a notification sent when a notebook document is saved. + // + // @since 3.17.0 + DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) error - // WorkspaceDidChangeConfiguration the configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains the changed configuration as defined by the language client. - WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error + // DidSaveTextDocument the document save notification is sent from the client to the server when the document got saved in the client. + DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) error - // WorkspaceDidChangeWatchedFiles the watched files notification is sent from the client to the server when the client detects changes - // to file watched by the language client. - WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error + // Exit the exit event is sent from the client to the server to ask the server to exit its process. + Exit(ctx context.Context) error - // WorkspaceDidChangeWorkspaceFolders the `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace folder configuration changes. - WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error + // Initialized the initialized notification is sent from the client to the server after the client is fully initialized and the server is allowed to send requests from the server to the client. + Initialized(ctx context.Context, params *InitializedParams) error - // WorkspaceDidCreateFiles the did create files notification is sent from the client to the server when files were created from - // within the client. - // - // @since 3.16.0 - WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) error + SetTrace(ctx context.Context, params *SetTraceParams) error - // WorkspaceDidDeleteFiles the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. - // - // @since 3.16.0 - WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error + // WillSaveTextDocument a document will save notification is sent from the client to the server before the document is actually saved. + WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) error - // WorkspaceDidRenameFiles the did rename files notification is sent from the client to the server when files were renamed from - // within the client. - // - // @since 3.16.0 - WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) error + // WorkDoneProgressCancel the `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress initiated on the server side. + WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error // CallHierarchyIncomingCalls a request to resolve the incoming calls for a given `CallHierarchyItem`. // // @since 3.16.0 @@ -171,168 +171,172 @@ type Server interface { // @since 3.16.0 CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) + // CallHierarchyPrepare a request to result a `CallHierarchyItem` in a document at a given position. Can be used as an input + // to an incoming or outgoing call hierarchy. + // + // @since 3.16.0 + CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) + + // CodeAction a request to provide commands for the given text document and range. + CodeAction(ctx context.Context, params *CodeActionParams) (*CodeActionRequestResult, error) + // CodeActionResolve request to resolve additional information for a given code action.The request's parameter is of type // CodeAction the response is of type CodeAction or a Thenable that resolves to such. CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) + // CodeLens a request to provide code lens for the given text document. + CodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) + // CodeLensResolve a request to resolve a command for a given code lens. CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) - // CompletionItemResolve request to resolve additional information for a given completion item.The request's parameter is of type CompletionItem the response is of type CompletionItem or a Thenable that resolves to such. - CompletionItemResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) - - // DocumentLinkResolve request to resolve additional information for a given document link. The request's parameter is of type DocumentLink the response is of type DocumentLink or a Thenable that resolves to such. - DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) + // ColorPresentation a request to list all presentation for a color. The request's parameter is of type ColorPresentationParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. + ColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) - // Initialize the initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type InitializeParams the response if of type InitializeResult of a Thenable that resolves to such. - Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) + // Completion request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, + // `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. + Completion(ctx context.Context, params *CompletionParams) (*CompletionResult, error) - // InlayHintResolve a request to resolve additional properties for an inlay hint. The request's parameter is of type InlayHint, the response is of type InlayHint or a Thenable that resolves to such. - // - // @since 3.17.0 - InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) + // CompletionResolve request to resolve additional information for a given completion item.The request's parameter is of type CompletionItem the response is of type CompletionItem or a Thenable that resolves to such. + CompletionResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) - // Shutdown a shutdown request is sent from the client to the server. It is sent once when the client decides to - // shutdown the server. The only notification that is sent after a shutdown request is the exit event. - Shutdown(ctx context.Context) error + // Declaration a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a + // typed array of DeclarationLink or a Thenable that resolves to such. + Declaration(ctx context.Context, params *DeclarationParams) (*DeclarationResult, error) - // TextDocumentCodeAction a request to provide commands for the given text document and range. - TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (*TextDocumentCodeActionResult, error) + // Definition a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed + // array of DefinitionLink or a Thenable that resolves to such. + Definition(ctx context.Context, params *DefinitionParams) (*DefinitionResult, error) - // TextDocumentCodeLens a request to provide code lens for the given text document. - TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) + // DocumentColor a request to list all color symbols found in a given text document. The request's parameter is of type DocumentColorParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. + DocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) - // TextDocumentColorPresentation a request to list all presentation for a color. The request's parameter is of type ColorPresentationParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. - TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) + // DocumentDiagnostic the document diagnostic request definition. + // + // @since 3.17.0 + DocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) - // TextDocumentCompletion request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, - // `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. - TextDocumentCompletion(ctx context.Context, params *CompletionParams) (*TextDocumentCompletionResult, error) + // DocumentFormatting a request to format a whole document. + DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) - // TextDocumentDeclaration a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a - // typed array of DeclarationLink or a Thenable that resolves to such. - TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (*TextDocumentDeclarationResult, error) + // DocumentHighlight request to resolve a DocumentHighlight for a given text document position. The request's parameter is of type TextDocumentPosition the request response is an array of type DocumentHighlight or a Thenable that resolves to such. + DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) - // TextDocumentDefinition a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed - // array of DefinitionLink or a Thenable that resolves to such. - TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (*TextDocumentDefinitionResult, error) + // DocumentLink a request to provide document links. + DocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) - // TextDocumentDiagnostic the document diagnostic request definition. - // - // @since 3.17.0 - TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) + // DocumentLinkResolve request to resolve additional information for a given document link. The request's parameter is of type DocumentLink the response is of type DocumentLink or a Thenable that resolves to such. + DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) - // TextDocumentDocumentColor a request to list all color symbols found in a given text document. The request's parameter is of type DocumentColorParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. - TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) + // DocumentOnTypeFormatting a request to format a document on type. + DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) - // TextDocumentDocumentHighlight request to resolve a DocumentHighlight for a given text document position. The request's parameter is of type TextDocumentPosition the request response is an array of type DocumentHighlight or a Thenable that resolves to such. - TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) + // DocumentRangeFormatting a request to format a range in a document. + DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) - // TextDocumentDocumentLink a request to provide document links. - TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) + // DocumentRangesFormatting a request to format ranges in a document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) - // TextDocumentDocumentSymbol a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that + // DocumentSymbol a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that // resolves to such. - TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*TextDocumentDocumentSymbolResult, error) + DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*DocumentSymbolResult, error) - // TextDocumentFoldingRange a request to provide folding ranges in a document. The request's parameter is of type FoldingRangeParams, the response is of type FoldingRangeList or a Thenable that resolves to such. - TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) + // ExecuteCommand a request send from the client to the server to execute a command. The request might return a workspace edit which the client will apply to the workspace. + ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) - // TextDocumentFormatting a request to format a whole document. - TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) + // FoldingRange a request to provide folding ranges in a document. The request's parameter is of type FoldingRangeParams, the response is of type FoldingRangeList or a Thenable that resolves to such. + FoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) - // TextDocumentHover request to request hover information at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type Hover or a Thenable that resolves to such. - TextDocumentHover(ctx context.Context, params *HoverParams) (*Hover, error) + // Hover request to request hover information at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type Hover or a Thenable that resolves to such. + Hover(ctx context.Context, params *HoverParams) (*Hover, error) - // TextDocumentImplementation a request to resolve the implementation locations of a symbol at a given text document position. The + // Implementation a request to resolve the implementation locations of a symbol at a given text document position. The // request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. - TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (*TextDocumentImplementationResult, error) + Implementation(ctx context.Context, params *ImplementationParams) (*ImplementationResult, error) + + // Initialize the initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type InitializeParams the response if of type InitializeResult of a Thenable that resolves to such. + Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) - // TextDocumentInlayHint a request to provide inlay hints in a document. The request's parameter is of type InlayHintsParams, + // InlayHint a request to provide inlay hints in a document. The request's parameter is of type InlayHintsParams, // the response is of type InlayHint InlayHint[] or a Thenable that resolves to such. // // @since 3.17.0 - TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) + InlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) - // TextDocumentInlineCompletion a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. + // InlayHintResolve a request to resolve additional properties for an inlay hint. The request's parameter is of type InlayHint, the response is of type InlayHint or a Thenable that resolves to such. + // + // @since 3.17.0 + InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) + + // InlineCompletion a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. // // @since 3.18.0 proposed - TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (*TextDocumentInlineCompletionResult, error) + InlineCompletion(ctx context.Context, params *InlineCompletionParams) (*InlineCompletionResult, error) - // TextDocumentInlineValue a request to provide inline values in a document. The request's parameter is of type InlineValueParams, the response is of type InlineValue InlineValue[] or a Thenable that resolves to such. + // InlineValue a request to provide inline values in a document. The request's parameter is of type InlineValueParams, the response is of type InlineValue InlineValue[] or a Thenable that resolves to such. // // @since 3.17.0 - TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) + InlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) - // TextDocumentLinkedEditingRange a request to provide ranges that can be edited together. + // LinkedEditingRange a request to provide ranges that can be edited together. // // @since 3.16.0 - TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) + LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) - // TextDocumentMoniker a request to get the moniker of a symbol at a given text document position. The request parameter is + // Moniker a request to get the moniker of a symbol at a given text document position. The request parameter is // of type TextDocumentPositionParams. The response is of type Moniker Moniker[] or `null`. - TextDocumentMoniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) - - // TextDocumentOnTypeFormatting a request to format a document on type. - TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) - - // TextDocumentPrepareCallHierarchy a request to result a `CallHierarchyItem` in a document at a given position. Can be used as an input - // to an incoming or outgoing call hierarchy. - // - // @since 3.16.0 - TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) + Moniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) - // TextDocumentPrepareRename a request to test and perform the setup necessary for a rename. 3.16 - support for default behavior. + // PrepareRename a request to test and perform the setup necessary for a rename. 3.16 - support for default behavior. // // @since 3.16 - support for default behavior - TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) + PrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) - // TextDocumentPrepareTypeHierarchy a request to result a `TypeHierarchyItem` in a document at a given position. Can be used as an input - // to a subtypes or supertypes type hierarchy. - // - // @since 3.17.0 - TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) - - // TextDocumentRangeFormatting a request to format a range in a document. - TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) - - // TextDocumentRangesFormatting a request to format ranges in a document. 3.18.0 @proposed. - // - // @since 3.18.0 proposed - TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) + // References a request to resolve project-wide references for the symbol denoted by the given text document position. The request's parameter is of type ReferenceParams the response is of type Location Location[] or a Thenable that resolves to such. + References(ctx context.Context, params *ReferenceParams) ([]*Location, error) - // TextDocumentReferences a request to resolve project-wide references for the symbol denoted by the given text document position. The request's parameter is of type ReferenceParams the response is of type Location Location[] or a Thenable that resolves to such. - TextDocumentReferences(ctx context.Context, params *ReferenceParams) ([]*Location, error) + // Rename a request to rename a symbol. + Rename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) - // TextDocumentRename a request to rename a symbol. - TextDocumentRename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) + // SelectionRange a request to provide selection ranges in a document. The request's parameter is of type SelectionRangeParams, the response is of type SelectionRange SelectionRange[] or a Thenable that resolves to such. + SelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) - // TextDocumentSelectionRange a request to provide selection ranges in a document. The request's parameter is of type SelectionRangeParams, the response is of type SelectionRange SelectionRange[] or a Thenable that resolves to such. - TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) - - // TextDocumentSemanticTokensFull. + // SemanticTokensDelta. // // @since 3.16.0 - TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) + SemanticTokensDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*SemanticTokensDeltaResult, error) - // TextDocumentSemanticTokensFullDelta. + // SemanticTokensRange. // // @since 3.16.0 - TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*TextDocumentSemanticTokensFullDeltaResult, error) + SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) - // TextDocumentSemanticTokensRange. + // SemanticTokens. // // @since 3.16.0 - TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) + SemanticTokens(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) - TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) + // Shutdown a shutdown request is sent from the client to the server. It is sent once when the client decides to + // shutdown the server. The only notification that is sent after a shutdown request is the exit event. + Shutdown(ctx context.Context) error - // TextDocumentTypeDefinition a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. - TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TextDocumentTypeDefinitionResult, error) + SignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) - // TextDocumentWillSaveWaitUntil a document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before - // it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable. - TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) + // TextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) + + // TypeDefinition a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. + TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TypeDefinitionResult, error) + + // TypeHierarchyPrepare a request to result a `TypeHierarchyItem` in a document at a given position. Can be used as an input + // to a subtypes or supertypes type hierarchy. + // + // @since 3.17.0 + TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) // TypeHierarchySubtypes a request to resolve the subtypes for a given `TypeHierarchyItem`. // @@ -344,40 +348,36 @@ type Server interface { // @since 3.17.0 TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) - // WorkspaceDiagnostic the workspace diagnostic request definition. - // - // @since 3.17.0 - WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) - - // WorkspaceExecuteCommand a request send from the client to the server to execute a command. The request might return a workspace edit which the client will apply to the workspace. - WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) - - // WorkspaceSymbol a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. - // The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + // WillCreateFiles the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a `WorkspaceEdit` which will be applied to workspace before the files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file to be created. // - // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. - WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) + // @since 3.16.0 + WillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) - // WorkspaceTextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. + // WillDeleteFiles the did delete files notification is sent from the client to the server when files were deleted from + // within the client. // - // @since 3.18.0 proposed - WorkspaceTextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) + // @since 3.16.0 + WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) - // WorkspaceWillCreateFiles the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a `WorkspaceEdit` which will be applied to workspace before the files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file to be created. + // WillRenameFiles the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. // // @since 3.16.0 - WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) + WillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) - // WorkspaceWillDeleteFiles the did delete files notification is sent from the client to the server when files were deleted from - // within the client. + // WillSaveTextDocumentWaitUntil a document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before + // it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable. + WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) + + // WorkspaceDiagnostic the workspace diagnostic request definition. // - // @since 3.16.0 - WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) + // @since 3.17.0 + WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) - // WorkspaceWillRenameFiles the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. + // WorkspaceSymbol a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. + // The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. // - // @since 3.16.0 - WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) + // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) // WorkspaceSymbolResolve a request to resolve the range inside the workspace symbol's location. // @@ -390,7 +390,7 @@ type Server interface { // UnimplementedServer should be embedded to have forward compatible implementations. type UnimplementedServer struct{} -func (UnimplementedServer) CancelRequest(ctx context.Context, params *CancelParams) error { +func (UnimplementedServer) Cancel(ctx context.Context, params *CancelParams) error { return jsonrpc2.ErrInternal } @@ -398,79 +398,79 @@ func (UnimplementedServer) Progress(ctx context.Context, params *ProgressParams) return jsonrpc2.ErrInternal } -func (UnimplementedServer) SetTrace(ctx context.Context, params *SetTraceParams) error { +func (UnimplementedServer) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) Exit(ctx context.Context) error { +func (UnimplementedServer) DidChangeNotebookDocument(ctx context.Context, params *DidChangeNotebookDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) Initialized(ctx context.Context, params *InitializedParams) error { +func (UnimplementedServer) DidChangeTextDocument(ctx context.Context, params *DidChangeTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) NotebookDocumentDidChange(ctx context.Context, params *DidChangeNotebookDocumentParams) error { +func (UnimplementedServer) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) NotebookDocumentDidClose(ctx context.Context, params *DidCloseNotebookDocumentParams) error { +func (UnimplementedServer) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) NotebookDocumentDidOpen(ctx context.Context, params *DidOpenNotebookDocumentParams) error { +func (UnimplementedServer) DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) NotebookDocumentDidSave(ctx context.Context, params *DidSaveNotebookDocumentParams) error { +func (UnimplementedServer) DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDidChange(ctx context.Context, params *DidChangeTextDocumentParams) error { +func (UnimplementedServer) DidCreateFiles(ctx context.Context, params *CreateFilesParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDidClose(ctx context.Context, params *DidCloseTextDocumentParams) error { +func (UnimplementedServer) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDidOpen(ctx context.Context, params *DidOpenTextDocumentParams) error { +func (UnimplementedServer) DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDidSave(ctx context.Context, params *DidSaveTextDocumentParams) error { +func (UnimplementedServer) DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentWillSave(ctx context.Context, params *WillSaveTextDocumentParams) error { +func (UnimplementedServer) DidRenameFiles(ctx context.Context, params *RenameFilesParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) WindowWorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error { +func (UnimplementedServer) DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceDidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error { +func (UnimplementedServer) DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceDidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error { +func (UnimplementedServer) Exit(ctx context.Context) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error { +func (UnimplementedServer) Initialized(ctx context.Context, params *InitializedParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceDidCreateFiles(ctx context.Context, params *CreateFilesParams) error { +func (UnimplementedServer) SetTrace(ctx context.Context, params *SetTraceParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceDidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error { +func (UnimplementedServer) WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceDidRenameFiles(ctx context.Context, params *RenameFilesParams) error { +func (UnimplementedServer) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error { return jsonrpc2.ErrInternal } @@ -482,207 +482,207 @@ func (UnimplementedServer) CallHierarchyOutgoingCalls(ctx context.Context, param return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) { +func (UnimplementedServer) CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) { +func (UnimplementedServer) CodeAction(ctx context.Context, params *CodeActionParams) (*CodeActionRequestResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) CompletionItemResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) { +func (UnimplementedServer) CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) { +func (UnimplementedServer) CodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) { +func (UnimplementedServer) CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) { +func (UnimplementedServer) ColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) Shutdown(ctx context.Context) error { - return jsonrpc2.ErrInternal +func (UnimplementedServer) Completion(ctx context.Context, params *CompletionParams) (*CompletionResult, error) { + return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentCodeAction(ctx context.Context, params *CodeActionParams) (*TextDocumentCodeActionResult, error) { +func (UnimplementedServer) CompletionResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentCodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) { +func (UnimplementedServer) Declaration(ctx context.Context, params *DeclarationParams) (*DeclarationResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) { +func (UnimplementedServer) Definition(ctx context.Context, params *DefinitionParams) (*DefinitionResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentCompletion(ctx context.Context, params *CompletionParams) (*TextDocumentCompletionResult, error) { +func (UnimplementedServer) DocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDeclaration(ctx context.Context, params *DeclarationParams) (*TextDocumentDeclarationResult, error) { +func (UnimplementedServer) DocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDefinition(ctx context.Context, params *DefinitionParams) (*TextDocumentDefinitionResult, error) { +func (UnimplementedServer) DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) { +func (UnimplementedServer) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) { +func (UnimplementedServer) DocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) { +func (UnimplementedServer) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) { +func (UnimplementedServer) DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentDocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*TextDocumentDocumentSymbolResult, error) { +func (UnimplementedServer) DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentFoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) { +func (UnimplementedServer) DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) { +func (UnimplementedServer) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*DocumentSymbolResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentHover(ctx context.Context, params *HoverParams) (*Hover, error) { +func (UnimplementedServer) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentImplementation(ctx context.Context, params *ImplementationParams) (*TextDocumentImplementationResult, error) { +func (UnimplementedServer) FoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentInlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) { +func (UnimplementedServer) Hover(ctx context.Context, params *HoverParams) (*Hover, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentInlineCompletion(ctx context.Context, params *InlineCompletionParams) (*TextDocumentInlineCompletionResult, error) { +func (UnimplementedServer) Implementation(ctx context.Context, params *ImplementationParams) (*ImplementationResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentInlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) { +func (UnimplementedServer) Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentLinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) { +func (UnimplementedServer) InlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentMoniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) { +func (UnimplementedServer) InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) { +func (UnimplementedServer) InlineCompletion(ctx context.Context, params *InlineCompletionParams) (*InlineCompletionResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentPrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) { +func (UnimplementedServer) InlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentPrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) { +func (UnimplementedServer) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentPrepareTypeHierarchy(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) { +func (UnimplementedServer) Moniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) { +func (UnimplementedServer) PrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) { +func (UnimplementedServer) References(ctx context.Context, params *ReferenceParams) ([]*Location, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentReferences(ctx context.Context, params *ReferenceParams) ([]*Location, error) { +func (UnimplementedServer) Rename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentRename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) { +func (UnimplementedServer) SelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentSelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) { +func (UnimplementedServer) SemanticTokensDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*SemanticTokensDeltaResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentSemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) { +func (UnimplementedServer) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentSemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*TextDocumentSemanticTokensFullDeltaResult, error) { +func (UnimplementedServer) SemanticTokens(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentSemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) { - return nil, jsonrpc2.ErrInternal +func (UnimplementedServer) Shutdown(ctx context.Context) error { + return jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentSignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) { +func (UnimplementedServer) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentTypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TextDocumentTypeDefinitionResult, error) { +func (UnimplementedServer) TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentWillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) { +func (UnimplementedServer) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TypeDefinitionResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) { +func (UnimplementedServer) TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) { +func (UnimplementedServer) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) { +func (UnimplementedServer) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) { +func (UnimplementedServer) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) { +func (UnimplementedServer) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceTextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) { +func (UnimplementedServer) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceWillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) { +func (UnimplementedServer) WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceWillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) { +func (UnimplementedServer) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceWillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) { +func (UnimplementedServer) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) { return nil, jsonrpc2.ErrInternal } diff --git a/protocol/types_generics.go b/protocol/types_generics.go index 732f03fb..487f36a5 100644 --- a/protocol/types_generics.go +++ b/protocol/types_generics.go @@ -136,6 +136,47 @@ func (t *ClientSemanticTokensRequestOptionsRange) UnmarshalJSON(val []byte) erro return &UnmarshalError{"unmarshal failed to match one of [bool Range]"} } +// CodeActionRequestResult a request to provide commands for the given text document and range. +type CodeActionRequestResult struct { + value any +} + +func NewCodeActionRequestResult[T Command | CodeAction](val T) *CodeActionRequestResult { + return &CodeActionRequestResult{ + value: val, + } +} + +func (t CodeActionRequestResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Command: + return marshal(val) + case CodeAction: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CodeActionRequestResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Command + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 CodeAction + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} +} + // CompletionItemDefaultsEditRange a default edit range. // // @since 3.17.0 @@ -261,6 +302,132 @@ func (t *CompletionItemTextEdit) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [TextEdit InsertReplaceEdit]"} } +// CompletionResult request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, +// `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. +type CompletionResult struct { + value any +} + +func NewCompletionResult[T []CompletionItem | CompletionList](val T) *CompletionResult { + return &CompletionResult{ + value: val, + } +} + +func (t CompletionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case []CompletionItem: + return marshal(val) + case CompletionList: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CompletionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 []CompletionItem + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 CompletionList + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} +} + +// DeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a +// typed array of DeclarationLink or a Thenable that resolves to such. +type DeclarationResult struct { + value any +} + +func NewDeclarationResult[T Declaration | []DeclarationLink](val T) *DeclarationResult { + return &DeclarationResult{ + value: val, + } +} + +func (t DeclarationResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Declaration: + return marshal(val) + case []DeclarationLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DeclarationResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Declaration + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DeclarationLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Declaration []DeclarationLink]"} +} + +// DefinitionResult a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed +// array of DefinitionLink or a Thenable that resolves to such. +type DefinitionResult struct { + value any +} + +func NewDefinitionResult[T Definition | []DefinitionLink](val T) *DefinitionResult { + return &DefinitionResult{ + value: val, + } +} + +func (t DefinitionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Definition: + return marshal(val) + case []DefinitionLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DefinitionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Definition + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + // DiagnosticCode the diagnostic's code, which usually appear in the user interface. type DiagnosticCode struct { value any @@ -383,6 +550,48 @@ func (t *DocumentDiagnosticReportPartialResultRelatedDocuments) UnmarshalJSON(va return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} } +// DocumentSymbolResult a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that +// resolves to such. +type DocumentSymbolResult struct { + value any +} + +func NewDocumentSymbolResult[T []SymbolInformation | []DocumentSymbol](val T) DocumentSymbolResult { + return DocumentSymbolResult{ + value: val, + } +} + +func (t DocumentSymbolResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case []SymbolInformation: + return marshal(val) + case []DocumentSymbol: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DocumentSymbolResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 []SymbolInformation + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DocumentSymbol + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} +} + // HoverContents the hover's content. type HoverContents struct { value any @@ -431,6 +640,48 @@ func (t *HoverContents) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [MarkupContent MarkedString []MarkedString]"} } +// ImplementationResult a request to resolve the implementation locations of a symbol at a given text document position. The +// request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. +type ImplementationResult struct { + value any +} + +func NewImplementationResult[T Definition | []DefinitionLink](val T) *ImplementationResult { + return &ImplementationResult{ + value: val, + } +} + +func (t ImplementationResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Definition: + return marshal(val) + case []DefinitionLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ImplementationResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Definition + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + // InlayHintLabel the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty. // // @since 3.17.0 @@ -603,6 +854,49 @@ func (t *InlineCompletionItemInsertText) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [string StringValue]"} } +// InlineCompletionResult a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionResult struct { + value any +} + +func NewInlineCompletionResult[T InlineCompletionList | []InlineCompletionItem](val T) *InlineCompletionResult { + return &InlineCompletionResult{ + value: val, + } +} + +func (t InlineCompletionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case InlineCompletionList: + return marshal(val) + case []InlineCompletionItem: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlineCompletionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 InlineCompletionList + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []InlineCompletionItem + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} +} + // NotebookCellTextDocumentFilterNotebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. // // @since 3.17.0 @@ -987,15 +1281,58 @@ func (t *RelativePatternBaseURI) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [WorkspaceFolder uri.URI]"} } -// SemanticTokensOptionsFull server supports providing semantic tokens for a full document. +// SemanticTokensDeltaResult. // // @since 3.16.0 -type SemanticTokensOptionsFull struct { +type SemanticTokensDeltaResult struct { value any } -func NewSemanticTokensOptionsFull[T bool | SemanticTokensFullDelta](val T) *SemanticTokensOptionsFull { - return &SemanticTokensOptionsFull{ +func NewSemanticTokensDeltaResult[T SemanticTokens | SemanticTokensDelta](val T) *SemanticTokensDeltaResult { + return &SemanticTokensDeltaResult{ + value: val, + } +} + +func (t SemanticTokensDeltaResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case SemanticTokens: + return marshal(val) + case SemanticTokensDelta: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *SemanticTokensDeltaResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 SemanticTokens + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 SemanticTokensDelta + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} +} + +// SemanticTokensOptionsFull server supports providing semantic tokens for a full document. +// +// @since 3.16.0 +type SemanticTokensOptionsFull struct { + value any +} + +func NewSemanticTokensOptionsFull[T bool | SemanticTokensFullDelta](val T) *SemanticTokensOptionsFull { + return &SemanticTokensOptionsFull{ value: val, } } @@ -2306,215 +2643,6 @@ func (t *SignatureInformationDocumentation) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} } -// TextDocumentCodeActionResult a request to provide commands for the given text document and range. -type TextDocumentCodeActionResult struct { - value any -} - -func NewTextDocumentCodeActionResult[T Command | CodeAction](val T) *TextDocumentCodeActionResult { - return &TextDocumentCodeActionResult{ - value: val, - } -} - -func (t TextDocumentCodeActionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Command: - return marshal(val) - case CodeAction: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *TextDocumentCodeActionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Command - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 CodeAction - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} -} - -// TextDocumentCompletionResult request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, -// `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. -type TextDocumentCompletionResult struct { - value any -} - -func NewTextDocumentCompletionResult[T []CompletionItem | CompletionList](val T) *TextDocumentCompletionResult { - return &TextDocumentCompletionResult{ - value: val, - } -} - -func (t TextDocumentCompletionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case []CompletionItem: - return marshal(val) - case CompletionList: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *TextDocumentCompletionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 []CompletionItem - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 CompletionList - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} -} - -// TextDocumentDeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a -// typed array of DeclarationLink or a Thenable that resolves to such. -type TextDocumentDeclarationResult struct { - value any -} - -func NewTextDocumentDeclarationResult[T Declaration | []DeclarationLink](val T) *TextDocumentDeclarationResult { - return &TextDocumentDeclarationResult{ - value: val, - } -} - -func (t TextDocumentDeclarationResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Declaration: - return marshal(val) - case []DeclarationLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *TextDocumentDeclarationResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Declaration - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DeclarationLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Declaration []DeclarationLink]"} -} - -// TextDocumentDefinitionResult a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed -// array of DefinitionLink or a Thenable that resolves to such. -type TextDocumentDefinitionResult struct { - value any -} - -func NewTextDocumentDefinitionResult[T Definition | []DefinitionLink](val T) *TextDocumentDefinitionResult { - return &TextDocumentDefinitionResult{ - value: val, - } -} - -func (t TextDocumentDefinitionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Definition: - return marshal(val) - case []DefinitionLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *TextDocumentDefinitionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Definition - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DefinitionLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} -} - -// TextDocumentDocumentSymbolResult a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that -// resolves to such. -type TextDocumentDocumentSymbolResult struct { - value any -} - -func NewTextDocumentDocumentSymbolResult[T []SymbolInformation | []DocumentSymbol](val T) TextDocumentDocumentSymbolResult { - return TextDocumentDocumentSymbolResult{ - value: val, - } -} - -func (t TextDocumentDocumentSymbolResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case []SymbolInformation: - return marshal(val) - case []DocumentSymbol: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *TextDocumentDocumentSymbolResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 []SymbolInformation - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DocumentSymbol - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} -} - // TextDocumentEditEdits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. type TextDocumentEditEdits struct { value any @@ -2563,134 +2691,6 @@ func (t *TextDocumentEditEdits) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [TextEdit AnnotatedTextEdit SnippetTextEdit]"} } -// TextDocumentImplementationResult a request to resolve the implementation locations of a symbol at a given text document position. The -// request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. -type TextDocumentImplementationResult struct { - value any -} - -func NewTextDocumentImplementationResult[T Definition | []DefinitionLink](val T) *TextDocumentImplementationResult { - return &TextDocumentImplementationResult{ - value: val, - } -} - -func (t TextDocumentImplementationResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Definition: - return marshal(val) - case []DefinitionLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *TextDocumentImplementationResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Definition - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DefinitionLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} -} - -// TextDocumentInlineCompletionResult a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. -// -// @since 3.18.0 proposed -type TextDocumentInlineCompletionResult struct { - value any -} - -func NewTextDocumentInlineCompletionResult[T InlineCompletionList | []InlineCompletionItem](val T) *TextDocumentInlineCompletionResult { - return &TextDocumentInlineCompletionResult{ - value: val, - } -} - -func (t TextDocumentInlineCompletionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case InlineCompletionList: - return marshal(val) - case []InlineCompletionItem: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *TextDocumentInlineCompletionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 InlineCompletionList - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []InlineCompletionItem - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} -} - -// TextDocumentSemanticTokensFullDeltaResult. -// -// @since 3.16.0 -type TextDocumentSemanticTokensFullDeltaResult struct { - value any -} - -func NewTextDocumentSemanticTokensFullDeltaResult[T SemanticTokens | SemanticTokensDelta](val T) *TextDocumentSemanticTokensFullDeltaResult { - return &TextDocumentSemanticTokensFullDeltaResult{ - value: val, - } -} - -func (t TextDocumentSemanticTokensFullDeltaResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case SemanticTokens: - return marshal(val) - case SemanticTokensDelta: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *TextDocumentSemanticTokensFullDeltaResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 SemanticTokens - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 SemanticTokensDelta - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} -} - // TextDocumentSyncOptionsSave if present save notifications are sent to the server. If omitted the notification should not be sent. type TextDocumentSyncOptionsSave struct { value any @@ -2732,18 +2732,18 @@ func (t *TextDocumentSyncOptionsSave) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [bool SaveOptions]"} } -// TextDocumentTypeDefinitionResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. -type TextDocumentTypeDefinitionResult struct { +// TypeDefinitionResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. +type TypeDefinitionResult struct { value any } -func NewTextDocumentTypeDefinitionResult[T Definition | []DefinitionLink](val T) *TextDocumentTypeDefinitionResult { - return &TextDocumentTypeDefinitionResult{ +func NewTypeDefinitionResult[T Definition | []DefinitionLink](val T) *TypeDefinitionResult { + return &TypeDefinitionResult{ value: val, } } -func (t TextDocumentTypeDefinitionResult) MarshalJSON() ([]byte, error) { +func (t TypeDefinitionResult) MarshalJSON() ([]byte, error) { switch val := t.value.(type) { case Definition: return marshal(val) @@ -2755,7 +2755,7 @@ func (t TextDocumentTypeDefinitionResult) MarshalJSON() ([]byte, error) { return nil, fmt.Errorf("unknown type: %T", t) } -func (t *TextDocumentTypeDefinitionResult) UnmarshalJSON(val []byte) error { +func (t *TypeDefinitionResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil return nil diff --git a/tools/protocol-gen/generator/client_server.go b/tools/protocol-gen/generator/client_server.go index 40a1b7d9..e825b8d0 100644 --- a/tools/protocol-gen/generator/client_server.go +++ b/tools/protocol-gen/generator/client_server.go @@ -20,40 +20,28 @@ func (gen *Generator) ClientToServer(clientNotifications, bidiNotifications []*p g.PP(`const (`) if len(bidiNotifications) > 0 { slices.SortFunc(bidiNotifications, func(a, b *protocol.Notification) int { - if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { - return cmp.Compare(a.Method, b.Method) - } - return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) + return cmp.Compare(strings.ToLower(a.TypeName), strings.ToLower(b.TypeName)) }) for _, meth := range bidiNotifications { g.PP(` `, `MethodClient`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect client notification`) } } slices.SortFunc(clientNotifications, func(a, b *protocol.Notification) int { - if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { - return cmp.Compare(a.Method, b.Method) - } - return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) + return cmp.Compare(strings.ToLower(a.TypeName), strings.ToLower(b.TypeName)) }) for _, meth := range clientNotifications { g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // client notification`) } if len(bidiRequests) > 0 { slices.SortFunc(bidiRequests, func(a, b *protocol.Request) int { - if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { - return cmp.Compare(a.Method, b.Method) - } - return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) + return cmp.Compare(strings.ToLower(a.TypeName), strings.ToLower(b.TypeName)) }) for _, meth := range bidiRequests { g.PP(` `, `MethodClient`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect client request`) } } slices.SortFunc(clientRequests, func(a, b *protocol.Request) int { - if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { - return cmp.Compare(a.Method, b.Method) - } - return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) + return cmp.Compare(strings.ToLower(a.TypeName), strings.ToLower(b.TypeName)) }) for _, meth := range clientRequests { g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // client request`) @@ -66,7 +54,8 @@ func (gen *Generator) ClientToServer(clientNotifications, bidiNotifications []*p reqests := append(bidiRequests, clientRequests...) for i, notify := range notifications { - meth := normalizeMethodName(notify.Method) + meth := normalizeMethodName(notify.TypeName) + meth = strings.TrimSuffix(meth, "Notification") // write Documentation if notify.Documentation != "" { g.PP(`// `, meth, normalizeDocumentation(notify.Documentation)) @@ -91,7 +80,10 @@ func (gen *Generator) ClientToServer(clientNotifications, bidiNotifications []*p } } for i, req := range reqests { - meth := normalizeMethodName(req.Method) + meth := normalizeMethodName(req.TypeName) + if meth != "ShowMessageRequest" { + meth = strings.TrimSuffix(meth, "Request") + } // write Documentation if req.Documentation != "" { g.PP(`// `, meth, normalizeDocumentation(req.Documentation)) @@ -122,7 +114,8 @@ func (gen *Generator) ClientToServer(clientNotifications, bidiNotifications []*p g.PP(`type UnimplementedClient struct {}`) g.P("\n") for i, notify := range notifications { - meth := normalizeMethodName(notify.Method) + meth := normalizeMethodName(notify.TypeName) + meth = strings.TrimSuffix(meth, "Notification") g.P(`func (UnimplementedClient) `) if err := gen.notification(g, meth, notify); err != nil { return err @@ -136,7 +129,10 @@ func (gen *Generator) ClientToServer(clientNotifications, bidiNotifications []*p } } for i, req := range reqests { - meth := normalizeMethodName(req.Method) + meth := normalizeMethodName(req.TypeName) + if meth != "ShowMessageRequest" { + meth = strings.TrimSuffix(meth, "Request") + } if meth == "" { continue } @@ -172,40 +168,28 @@ func (gen *Generator) ServerToClient(serverNotifications, bidiNotifications []*p g.PP(`const (`) if len(bidiNotifications) > 0 { slices.SortFunc(bidiNotifications, func(a, b *protocol.Notification) int { - if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { - return cmp.Compare(a.Method, b.Method) - } - return cmp.Compare(a.Method, b.Method) + return cmp.Compare(a.TypeName, b.TypeName) }) for _, meth := range bidiNotifications { g.PP(` `, `MethodServer`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect server notification`) } } slices.SortFunc(serverNotifications, func(a, b *protocol.Notification) int { - if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { - return cmp.Compare(a.Method, b.Method) - } - return cmp.Compare(a.Method, b.Method) + return cmp.Compare(a.TypeName, b.TypeName) }) for _, meth := range serverNotifications { g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // server notification`) } if len(bidiRequests) > 0 { slices.SortFunc(bidiRequests, func(a, b *protocol.Request) int { - if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { - return cmp.Compare(a.Method, b.Method) - } - return cmp.Compare(a.Method, b.Method) + return cmp.Compare(a.TypeName, b.TypeName) }) for _, meth := range bidiRequests { g.PP(` `, `MethodServer`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect server request`) } } slices.SortFunc(serverNequests, func(a, b *protocol.Request) int { - if !strings.Contains(a.Method, "/") && !strings.Contains(b.Method, "/") { - return cmp.Compare(a.Method, b.Method) - } - return cmp.Compare(a.Method, b.Method) + return cmp.Compare(a.TypeName, b.TypeName) }) for _, meth := range serverNequests { g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // server request`) @@ -218,7 +202,8 @@ func (gen *Generator) ServerToClient(serverNotifications, bidiNotifications []*p reqests := slices.Clip(serverNequests) for i, notify := range notifications { - meth := normalizeMethodName(notify.Method) + meth := normalizeMethodName(notify.TypeName) + meth = strings.TrimSuffix(meth, "Notification") // write Documentation if notify.Documentation != "" { g.PP(`// `, meth, normalizeDocumentation(notify.Documentation)) @@ -243,7 +228,10 @@ func (gen *Generator) ServerToClient(serverNotifications, bidiNotifications []*p } } for i, req := range reqests { - meth := normalizeMethodName(req.Method) + meth := normalizeMethodName(req.TypeName) + if meth != "ShowMessageRequest" { + meth = strings.TrimSuffix(meth, "Request") + } // write Documentation if req.Documentation != "" { g.PP(`// `, meth, normalizeDocumentation(req.Documentation)) @@ -276,7 +264,8 @@ func (gen *Generator) ServerToClient(serverNotifications, bidiNotifications []*p g.PP(`type UnimplementedServer struct {}`) g.P("\n") for i, notify := range notifications { - meth := normalizeMethodName(notify.Method) + meth := normalizeMethodName(notify.TypeName) + meth = strings.TrimSuffix(meth, "Notification") g.P(`func (UnimplementedServer) `) if err := gen.notification(g, meth, notify); err != nil { return err @@ -290,7 +279,10 @@ func (gen *Generator) ServerToClient(serverNotifications, bidiNotifications []*p } } for i, req := range reqests { - meth := normalizeMethodName(req.Method) + meth := normalizeMethodName(req.TypeName) + if meth != "ShowMessageRequest" { + meth = strings.TrimSuffix(meth, "Request") + } g.P(`func (UnimplementedServer) `) n, err := gen.request(g, meth, req) if err != nil { @@ -419,7 +411,7 @@ func (gen *Generator) renderRequestsArrayType(g Printer, req *protocol.Request, gen.renderRequestssOrTypeNull(g, req, elem) default: genericsType := genericsType{ - Name: normalizeMethodName(req.Method) + "Result", + Name: normalizeMethodName(req.TypeName) + "Result", Documentation: req.Documentation, Since: req.Since, Proposed: req.Proposed, diff --git a/tools/protocol-gen/protocol/enum.go b/tools/protocol-gen/protocol/enum.go index 7ef00d2b..474e9e28 100644 --- a/tools/protocol-gen/protocol/enum.go +++ b/tools/protocol-gen/protocol/enum.go @@ -5,29 +5,32 @@ package protocol // Enumeration defines an enumeration. type Enumeration struct { - // Whether the enumeration is deprecated or not. If deprecated the property contains the deprecation message. - Deprecated string - - // An optional documentation. - Documentation string - // The name of the enumeration. Name string - // Whether this is a proposed enumeration. If omitted, the enumeration is final. - Proposed bool + // The type of the elements. + Type EnumerationType - // Since when (release number) this enumeration is available. Is empty if not known. - Since string + // The enum values. + Values []*EnumerationEntry // Whether the enumeration supports custom values (e.g. values which are not part of the set defined in values). If omitted no custom values are supported. SupportsCustomValues bool - // The type of the elements. - Type EnumerationType + // An optional documentation. + Documentation string - // The enum values. - Values []*EnumerationEntry + // Since when (release number) this enumeration is available. Is empty if not known. + Since string + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string + + // Whether this is a proposed enumeration. If omitted, the enumeration is final. + Proposed bool + + // Whether the enumeration is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string } func (Enumeration) isTypeDecl() {} @@ -50,21 +53,27 @@ const ( // EnumerationEntry defines an enumeration entry. type EnumerationEntry struct { - // Whether the enum entry is deprecated or not. If deprecated the property contains the deprecation message. - Deprecated string + // The name of the enum item. + Name string + + // The value (string or number). + Value any // An optional documentation. Documentation string - // The name of the enum item. - Name string + // Since when (release number) this enumeration entry is available. Is undefined if not known. + Since string + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string // Whether this is a proposed enumeration entry. If omitted, the enumeration entry is final. Proposed bool - // Since when (release number) this enumeration entry is available. Is undefined if not known. - Since string + // Whether the enum entry is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string - // The value (string or number). - Value any + // The type name of the request if any. + TypeName string } diff --git a/tools/protocol-gen/protocol/notification.go b/tools/protocol-gen/protocol/notification.go index a0e5f440..f843dfcc 100644 --- a/tools/protocol-gen/protocol/notification.go +++ b/tools/protocol-gen/protocol/notification.go @@ -5,31 +5,37 @@ package protocol // Notification represents a LSP notification. type Notification struct { - // Whether the notification is deprecated or not. - // If deprecated the property contains the deprecation message. - Deprecated string - - // An optional documentation. - Documentation string - - // The direction in which this notification is sent in the protocol. - MessageDirection MessageDirection - // The request's method name. Method string // The parameter type(s) if any. Params []Type - // Whether this is a proposed notification. If omitted the notification is final. - Proposed bool - // Optional a dynamic registration method if it different from the request's method. RegistrationMethod string // Optional registration options if the notification supports dynamic registration. RegistrationOptions Type + // The direction in which this notification is sent in the protocol. + MessageDirection MessageDirection + + // An optional documentation. + Documentation string + // Since when (release number) this notification is available. Is undefined if not knownz. Since string + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string + + // Whether this is a proposed notification. If omitted the notification is final. + Proposed bool + + // Whether the notification is deprecated or not. + // If deprecated the property contains the deprecation message. + Deprecated string + + // The type name of the request if any. + TypeName string } diff --git a/tools/protocol-gen/protocol/property.go b/tools/protocol-gen/protocol/property.go index 37b65fd2..a464ed8b 100644 --- a/tools/protocol-gen/protocol/property.go +++ b/tools/protocol-gen/protocol/property.go @@ -5,27 +5,30 @@ package protocol // Property represents an object property. type Property struct { - // Whether the property is deprecated or not. If deprecated the property contains the deprecation message. - Deprecated string - - // An optional documentation. - Documentation string - - // The property JSON name. - JSONName string - // The property name. Name string + // The type of the property. + Type Type + // Whether the property is optional. If omitted, the property is mandatory. Optional bool - // Whether this is a proposed property. If omitted, the structure is final. - Proposed bool + // An optional documentation. + Documentation string // Since when (release number) this property is available. Is undefined if not known. Since string - // The type of the property. - Type Type + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string + + // Whether this is a proposed property. If omitted, the structure is final. + Proposed bool + + // Whether the property is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + + // The property JSON name. + JSONName string } diff --git a/tools/protocol-gen/protocol/request.go b/tools/protocol-gen/protocol/request.go index 8d280e50..ff022f12 100644 --- a/tools/protocol-gen/protocol/request.go +++ b/tools/protocol-gen/protocol/request.go @@ -5,29 +5,20 @@ package protocol // Request represents a LSP request. type Request struct { - // Whether the request is deprecated or not. If deprecated the property contains the deprecation message. - Deprecated string - - // An optional documentation. - Documentation string - - // An optional error data type. - ErrorData Type - - // The direction in which this request is sent in the protocol. - MessageDirection MessageDirection - // The request's method name. Method string // The parameter type(s) if any. Params []Type + // The result type. + Result Type + // Optional partial result type if the request supports partial result reporting. PartialResult Type - // Whether this is a proposed feature. If omitted the feature is final. - Proposed bool + // An optional error data type. + ErrorData Type // Optional a dynamic registration method if it different from the request's method. RegistrationMethod string @@ -35,9 +26,24 @@ type Request struct { // Optional registration options if the request supports dynamic registration. RegistrationOptions Type - // The result type. - Result Type + // The direction in which this request is sent in the protocol. + MessageDirection MessageDirection + + // An optional documentation. + Documentation string // Since when (release number) this request is available. Is undefined if not known. Since string + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string + + // Whether this is a proposed feature. If omitted the feature is final. + Proposed bool + + // Whether the request is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + + // The type name of the request if any. + TypeName string } diff --git a/tools/protocol-gen/protocol/structure.go b/tools/protocol-gen/protocol/structure.go index 122837de..10f13cd3 100644 --- a/tools/protocol-gen/protocol/structure.go +++ b/tools/protocol-gen/protocol/structure.go @@ -5,11 +5,8 @@ package protocol // Structure defines the structure of an object literal. type Structure struct { - // Whether the structure is deprecated or not. If deprecated the property contains the deprecation message. - Deprecated string - - // An optional documentation. - Documentation string + // The name of the structure. + Name string // Structures extended from. This structures form a polymorphic type hierarchy. Extends []Type @@ -17,18 +14,24 @@ type Structure struct { // Structures to mix in. The properties of these structures are `copied` into this structure. Mixins don't form a polymorphic type hierarchy in LSP. Mixins []Type - // The name of the structure. - Name string - // The properties. Properties []*Property - // Whether this is a proposed structure. If omitted, the structure is final. - Proposed bool + // An optional documentation. + Documentation string // Since when (release number) this structure is available. Is undefined if not known. Since string + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string + + // Whether this is a proposed structure. If omitted, the structure is final. + Proposed bool + + // Whether the structure is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + // The 'kind' property, used to identify the structure type. Kind string diff --git a/tools/protocol-gen/protocol/structure_literal.go b/tools/protocol-gen/protocol/structure_literal.go index 5bc3adcb..a57c09a0 100644 --- a/tools/protocol-gen/protocol/structure_literal.go +++ b/tools/protocol-gen/protocol/structure_literal.go @@ -5,18 +5,21 @@ package protocol // StructureLiteral defines an unnamed structure of an object literal. type StructureLiteral struct { - // Whether the literal is deprecated or not. If deprecated the property contains the deprecation message. - Deprecated string + // The properties. + Properties []*Property // An optional documentation. Documentation string - // The properties. - Properties []*Property + // Since when (release number) this structure is available. Is undefined if not known. + Since string + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string // Whether this is a proposed structure. If omitted, the structure is final. Proposed bool - // Since when (release number) this structure is available. Is undefined if not known. - Since string + // Whether the literal is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string } diff --git a/tools/protocol-gen/protocol/type_alias.go b/tools/protocol-gen/protocol/type_alias.go index 35151a86..30163fd7 100644 --- a/tools/protocol-gen/protocol/type_alias.go +++ b/tools/protocol-gen/protocol/type_alias.go @@ -5,24 +5,27 @@ package protocol // TypeAlias defines a type alias. (e.g. type Definition = Location | LocationLink). type TypeAlias struct { - // Whether the type alias is deprecated or not. - // If deprecated the property contains the deprecation message. - Deprecated string + // The name of the type alias. + Name string + + // The aliased type. + Type Type // An optional documentation. Documentation string - // The name of the type alias. - Name string + // Since when (release number) this structure is available. Is undefined if not known. + Since string + + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string // Whether this is a proposed type alias. If omitted, the type alias is final. Proposed bool - // Since when (release number) this structure is available. Is undefined if not known. - Since string - - // The aliased type. - Type Type + // Whether the type alias is deprecated or not. + // If deprecated the property contains the deprecation message. + Deprecated string } func (TypeAlias) isTypeDecl() {} diff --git a/tools/protocol-gen/resolver/resolver.go b/tools/protocol-gen/resolver/resolver.go index d79d6bd8..f1527196 100644 --- a/tools/protocol-gen/resolver/resolver.go +++ b/tools/protocol-gen/resolver/resolver.go @@ -101,29 +101,32 @@ func (r *resolver) model(in schema.MetaModel) *protocol.Protocol { func (r *resolver) enumeration(in schema.Enumeration) *protocol.Enumeration { defer r.pushScope("resolving enumeration '%v'", in.Name)() return &protocol.Enumeration{ - Deprecated: in.Deprecated, - Documentation: r.documentation(in.Documentation), - Name: r.className(in.Name), - Proposed: in.Proposed, - Since: in.Since, - SupportsCustomValues: in.SupportsCustomValues, + Name: r.className(in.Name), Type: protocol.EnumerationType{ Kind: in.Type.Kind, Name: protocol.EnumerationTypeName(in.Type.Name), }, - Values: transform(in.Values, r.enumerationEntry), + Values: transform(in.Values, r.enumerationEntry), + SupportsCustomValues: in.SupportsCustomValues, + Documentation: r.documentation(in.Documentation), + Since: in.Since, + SinceTags: in.SinceTags, + Proposed: in.Proposed, + Deprecated: in.Deprecated, } } func (r *resolver) enumerationEntry(in schema.EnumerationEntry) *protocol.EnumerationEntry { defer r.pushScope("resolving enumeration entry '%v'", in.Name)() return &protocol.EnumerationEntry{ - Deprecated: in.Deprecated, - Documentation: r.documentation(in.Documentation), Name: r.className(in.Name), - Proposed: in.Proposed, - Since: in.Since, Value: r.value(in.Value), + Documentation: r.documentation(in.Documentation), + Since: in.Since, + SinceTags: in.SinceTags, + Proposed: in.Proposed, + Deprecated: in.Deprecated, + TypeName: in.TypeName, } } @@ -135,33 +138,37 @@ func (r *resolver) metadata(in schema.MetaData) *protocol.MetaData { func (r *resolver) notification(in schema.Notification) *protocol.Notification { defer r.pushScope("resolving notification '%v'", in.Method)() return &protocol.Notification{ - Deprecated: in.Deprecated, - Documentation: r.documentation(in.Documentation), - MessageDirection: r.messageDirection(in.MessageDirection), Method: in.Method, Params: r.types(in.Params), - Proposed: in.Proposed, RegistrationMethod: in.RegistrationMethod, RegistrationOptions: r.type_(in.RegistrationOptions), + MessageDirection: r.messageDirection(in.MessageDirection), + Documentation: r.documentation(in.Documentation), Since: in.Since, + SinceTags: in.SinceTags, + Proposed: in.Proposed, + Deprecated: in.Deprecated, + TypeName: in.TypeName, } } func (r *resolver) request(in schema.Request) *protocol.Request { defer r.pushScope("resolving request '%v'", in.Method)() return &protocol.Request{ - Deprecated: in.Deprecated, - Documentation: r.documentation(in.Documentation), - ErrorData: r.type_(in.ErrorData), - MessageDirection: r.messageDirection(in.MessageDirection), Method: in.Method, Params: r.types(in.Params), + Result: r.type_(in.Result), PartialResult: r.type_(in.PartialResult), - Proposed: in.Proposed, + ErrorData: r.type_(in.ErrorData), RegistrationMethod: in.RegistrationMethod, RegistrationOptions: r.type_(in.RegistrationOptions), - Result: r.type_(in.Result), + MessageDirection: r.messageDirection(in.MessageDirection), + Documentation: r.documentation(in.Documentation), Since: in.Since, + SinceTags: in.SinceTags, + Proposed: in.Proposed, + Deprecated: in.Deprecated, + TypeName: in.TypeName, } } @@ -169,13 +176,14 @@ func (r *resolver) structure(in schema.Structure) *protocol.Structure { defer r.pushScope("resolving structure '%v'", in.Name)() name := r.className(in.Name) out := &protocol.Structure{ - Deprecated: in.Deprecated, - Documentation: r.documentation(in.Documentation), + Name: name, Extends: transform(in.Extends, r.type_), Mixins: transform(in.Mixins, r.type_), - Name: name, - Proposed: in.Proposed, + Documentation: r.documentation(in.Documentation), Since: in.Since, + SinceTags: in.SinceTags, + Proposed: in.Proposed, + Deprecated: in.Deprecated, NestedNames: []string{name}, } for _, propertyIn := range in.Properties { @@ -211,26 +219,28 @@ func (r *resolver) structure(in schema.Structure) *protocol.Structure { func (r *resolver) property(in schema.Property) *protocol.Property { defer r.pushScope("resolving property '%v'", in.Name)() return &protocol.Property{ - Deprecated: in.Deprecated, - Documentation: r.documentation(in.Documentation), - JSONName: in.Name, Name: flect.Underscore(in.Name), + Type: r.type_(in.Type), Optional: in.Optional, - Proposed: in.Proposed, + Documentation: r.documentation(in.Documentation), Since: in.Since, - Type: r.type_(in.Type), + SinceTags: in.SinceTags, + Proposed: in.Proposed, + Deprecated: in.Deprecated, + JSONName: in.Name, } } func (r *resolver) typeAlias(in schema.TypeAlias) *protocol.TypeAlias { defer r.pushScope("resolving type alias '%v'", in.Name)() return &protocol.TypeAlias{ - Deprecated: in.Deprecated, - Documentation: r.documentation(in.Documentation), Name: r.className(in.Name), - Proposed: in.Proposed, - Since: in.Since, Type: r.type_(in.Type), + Documentation: r.documentation(in.Documentation), + Since: in.Since, + SinceTags: in.SinceTags, + Proposed: in.Proposed, + Deprecated: in.Deprecated, } } @@ -310,11 +320,12 @@ func (r *resolver) typeImpl(in schema.Node) protocol.Type { func (r *resolver) structureLiteral(in schema.StructureLiteral) *protocol.StructureLiteral { defer r.pushScope("resolving structure literal")() return &protocol.StructureLiteral{ - Deprecated: in.Deprecated, - Documentation: r.documentation(in.Documentation), Properties: transform(in.Properties, r.property), - Proposed: in.Proposed, + Documentation: r.documentation(in.Documentation), Since: in.Since, + SinceTags: in.SinceTags, + Proposed: in.Proposed, + Deprecated: in.Deprecated, } } diff --git a/tools/protocol-gen/schema/metaModel.go b/tools/protocol-gen/schema/metaModel.go index e4bdcae6..c6c0802f 100644 --- a/tools/protocol-gen/schema/metaModel.go +++ b/tools/protocol-gen/schema/metaModel.go @@ -258,14 +258,14 @@ type StructureLiteral struct { // Since when (release number) this structure is available. Is undefined if not known. Since string `json:"since,omitempty" yaml:"since,omitempty"` + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` + // Whether this is a proposed structure. If omitted, the structure is final. Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` // Whether the literal is deprecated or not. If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` - - // All since tags in case there was more than one tag. Is undefined if not known. - SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` } // StringLiteralType represents a string literal type (e.g. kind: 'rename') @@ -398,14 +398,14 @@ type Structure struct { // Since when (release number) this structure is available. Is undefined if not known. Since string `json:"since,omitempty" yaml:"since,omitempty"` + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` + // Whether this is a proposed structure. If omitted, the structure is final. Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` // Whether the structure is deprecated or not. If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` - - // All since tags in case there was more than one tag. Is undefined if not known. - SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` } // Enumeration defines an enumeration. @@ -438,6 +438,22 @@ type Enumeration struct { Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` } +type EnumerationType struct { + // Kind corresponds to the JSON schema field "kind". + Kind string `json:"kind" yaml:"kind"` + + // Name corresponds to the JSON schema field "name". + Name EnumerationName `json:"name" yaml:"name"` +} + +type EnumerationName string + +const ( + EnumerationNameInteger EnumerationName = "integer" + EnumerationNameString EnumerationName = "string" + EnumerationNameUinteger EnumerationName = "uinteger" +) + // EnumerationEntry defines an enumeration entry type EnumerationEntry struct { // The name of the enum item. @@ -465,22 +481,6 @@ type EnumerationEntry struct { TypeName string `json:"typeName,omitempty" yaml:"typeName,omitempty"` } -type EnumerationType struct { - // Kind corresponds to the JSON schema field "kind". - Kind string `json:"kind" yaml:"kind"` - - // Name corresponds to the JSON schema field "name". - Name EnumerationName `json:"name" yaml:"name"` -} - -type EnumerationName string - -const ( - EnumerationNameInteger EnumerationName = "integer" - EnumerationNameString EnumerationName = "string" - EnumerationNameUinteger EnumerationName = "uinteger" -) - // TypeAlias defines a type alias. (e.g. type Definition = Location | LocationLink) type TypeAlias struct { // The name of the type alias. @@ -495,15 +495,15 @@ type TypeAlias struct { // Since when (release number) this structure is available. Is undefined if not known. Since string `json:"since,omitempty" yaml:"since,omitempty"` + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` + // Whether this is a proposed type alias. If omitted, the type alias is final. Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` // Whether the type alias is deprecated or not. // If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` - - // All since tags in case there was more than one tag. Is undefined if not known. - SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` } // Property represents an object property @@ -523,12 +523,12 @@ type Property struct { // Since when (release number) this property is available. Is undefined if not known. Since string `json:"since,omitempty" yaml:"since,omitempty"` + // All since tags in case there was more than one tag. Is undefined if not known. + SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` + // Whether this is a proposed property. If omitted, the structure is final. Proposed bool `json:"proposed,omitempty" yaml:"proposed,omitempty"` // Whether the property is deprecated or not. If deprecated the property contains the deprecation message. Deprecated string `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` - - // All since tags in case there was more than one tag. Is undefined if not known. - SinceTags []string `json:"sinceTags,omitempty" yaml:"sinceTags,omitempty"` } From dcdf970b45061b403e3058a932d16bc69f2b571f Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Mon, 7 Oct 2024 12:33:39 +0900 Subject: [PATCH 10/19] WIP7 Signed-off-by: Koichi Shiraishi --- protocol/types_generics.go | 470 +- tools/protocol-gen/generator/client_server.go | 14 +- tools/protocol-gen/generator/generator.go | 28 +- .../protocol-gen/generator/generics_types.go | 4 +- tools/protocol-gen/generator/structure.go | 36 +- tools/protocol-gen/go.mod | 4 +- tools/protocol-gen/go.sum | 2 + tools/protocol-gen/main.go | 17 +- tools/protocol-gen/resolver/resolver.go | 51 +- .../testdata/lsp.v2024.0.0b1.json | 15928 ++++++++++++++++ .../testdata/lsp.v2024.0.0b1.schema.json | 847 + 11 files changed, 17304 insertions(+), 97 deletions(-) create mode 100644 tools/protocol-gen/testdata/lsp.v2024.0.0b1.json create mode 100644 tools/protocol-gen/testdata/lsp.v2024.0.0b1.schema.json diff --git a/protocol/types_generics.go b/protocol/types_generics.go index 487f36a5..7ad1ade2 100644 --- a/protocol/types_generics.go +++ b/protocol/types_generics.go @@ -51,8 +51,6 @@ func (t *CancelParamsID) UnmarshalJSON(val []byte) error { } // ClientSemanticTokensRequestOptionsFull the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. -// -// @since 3.18.0 type ClientSemanticTokensRequestOptionsFull struct { value any } @@ -94,8 +92,6 @@ func (t *ClientSemanticTokensRequestOptionsFull) UnmarshalJSON(val []byte) error } // ClientSemanticTokensRequestOptionsRange the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. -// -// @since 3.18.0 type ClientSemanticTokensRequestOptionsRange struct { value any } @@ -177,6 +173,47 @@ func (t *CodeActionRequestResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} } +// CodeActionRequestResult a request to provide commands for the given text document and range. +type CodeActionRequestResult struct { + value any +} + +func NewCodeActionRequestResult[T Command | CodeAction](val T) *CodeActionRequestResult { + return &CodeActionRequestResult{ + value: val, + } +} + +func (t CodeActionRequestResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Command: + return marshal(val) + case CodeAction: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CodeActionRequestResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Command + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 CodeAction + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} +} + // CompletionItemDefaultsEditRange a default edit range. // // @since 3.17.0 @@ -262,6 +299,8 @@ func (t *CompletionItemDocumentation) UnmarshalJSON(val []byte) error { } // CompletionItemTextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`. +// +// @since 3.16.0 additional type `InsertReplaceEdit` type CompletionItemTextEdit struct { value any } @@ -344,6 +383,90 @@ func (t *CompletionResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} } +// CompletionResult request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, +// `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. +type CompletionResult struct { + value any +} + +func NewCompletionResult[T []CompletionItem | CompletionList](val T) *CompletionResult { + return &CompletionResult{ + value: val, + } +} + +func (t CompletionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case []CompletionItem: + return marshal(val) + case CompletionList: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CompletionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 []CompletionItem + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 CompletionList + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} +} + +// DeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a +// typed array of DeclarationLink or a Thenable that resolves to such. +type DeclarationResult struct { + value any +} + +func NewDeclarationResult[T Declaration | []DeclarationLink](val T) *DeclarationResult { + return &DeclarationResult{ + value: val, + } +} + +func (t DeclarationResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Declaration: + return marshal(val) + case []DeclarationLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DeclarationResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Declaration + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DeclarationLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Declaration []DeclarationLink]"} +} + // DeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a // typed array of DeclarationLink or a Thenable that resolves to such. type DeclarationResult struct { @@ -428,6 +551,48 @@ func (t *DefinitionResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} } +// DefinitionResult a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed +// array of DefinitionLink or a Thenable that resolves to such. +type DefinitionResult struct { + value any +} + +func NewDefinitionResult[T Definition | []DefinitionLink](val T) *DefinitionResult { + return &DefinitionResult{ + value: val, + } +} + +func (t DefinitionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Definition: + return marshal(val) + case []DefinitionLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DefinitionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Definition + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + // DiagnosticCode the diagnostic's code, which usually appear in the user interface. type DiagnosticCode struct { value any @@ -592,6 +757,48 @@ func (t *DocumentSymbolResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} } +// DocumentSymbolResult a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that +// resolves to such. +type DocumentSymbolResult struct { + value any +} + +func NewDocumentSymbolResult[T []SymbolInformation | []DocumentSymbol](val T) DocumentSymbolResult { + return DocumentSymbolResult{ + value: val, + } +} + +func (t DocumentSymbolResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case []SymbolInformation: + return marshal(val) + case []DocumentSymbol: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DocumentSymbolResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 []SymbolInformation + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DocumentSymbol + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} +} + // HoverContents the hover's content. type HoverContents struct { value any @@ -682,9 +889,49 @@ func (t *ImplementationResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} } +// ImplementationResult a request to resolve the implementation locations of a symbol at a given text document position. The +// request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. +type ImplementationResult struct { + value any +} + +func NewImplementationResult[T Definition | []DefinitionLink](val T) *ImplementationResult { + return &ImplementationResult{ + value: val, + } +} + +func (t ImplementationResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Definition: + return marshal(val) + case []DefinitionLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ImplementationResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Definition + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + // InlayHintLabel the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty. -// -// @since 3.17.0 type InlayHintLabel struct { value any } @@ -726,8 +973,6 @@ func (t *InlayHintLabel) UnmarshalJSON(val []byte) error { } // InlayHintLabelPartTooltip the tooltip text when you hover over this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. -// -// @since 3.17.0 type InlayHintLabelPartTooltip struct { value any } @@ -769,8 +1014,6 @@ func (t *InlayHintLabelPartTooltip) UnmarshalJSON(val []byte) error { } // InlayHintTooltip the tooltip text when you hover over this item. -// -// @since 3.17.0 type InlayHintTooltip struct { value any } @@ -812,8 +1055,6 @@ func (t *InlayHintTooltip) UnmarshalJSON(val []byte) error { } // InlineCompletionItemInsertText the text to replace the range with. Must be set. -// -// @since 3.18.0 proposed type InlineCompletionItemInsertText struct { value any } @@ -897,9 +1138,50 @@ func (t *InlineCompletionResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} } -// NotebookCellTextDocumentFilterNotebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. +// InlineCompletionResult a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. // -// @since 3.17.0 +// @since 3.18.0 proposed +type InlineCompletionResult struct { + value any +} + +func NewInlineCompletionResult[T InlineCompletionList | []InlineCompletionItem](val T) *InlineCompletionResult { + return &InlineCompletionResult{ + value: val, + } +} + +func (t InlineCompletionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case InlineCompletionList: + return marshal(val) + case []InlineCompletionItem: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlineCompletionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 InlineCompletionList + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []InlineCompletionItem + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} +} + +// NotebookCellTextDocumentFilterNotebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. type NotebookCellTextDocumentFilterNotebook struct { value any } @@ -941,8 +1223,6 @@ func (t *NotebookCellTextDocumentFilterNotebook) UnmarshalJSON(val []byte) error } // NotebookDocumentFilterWithCellsNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. -// -// @since 3.18.0 type NotebookDocumentFilterWithCellsNotebook struct { value any } @@ -984,8 +1264,6 @@ func (t *NotebookDocumentFilterWithCellsNotebook) UnmarshalJSON(val []byte) erro } // NotebookDocumentFilterWithNotebookNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. -// -// @since 3.18.0 type NotebookDocumentFilterWithNotebookNotebook struct { value any } @@ -1239,8 +1517,6 @@ func (t *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON } // RelativePatternBaseURI a workspace folder or a base URI to which this pattern will be matched against relatively. -// -// @since 3.17.0 type RelativePatternBaseURI struct { value any } @@ -1324,9 +1600,50 @@ func (t *SemanticTokensDeltaResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} } -// SemanticTokensOptionsFull server supports providing semantic tokens for a full document. +// SemanticTokensDeltaResult. // // @since 3.16.0 +type SemanticTokensDeltaResult struct { + value any +} + +func NewSemanticTokensDeltaResult[T SemanticTokens | SemanticTokensDelta](val T) *SemanticTokensDeltaResult { + return &SemanticTokensDeltaResult{ + value: val, + } +} + +func (t SemanticTokensDeltaResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case SemanticTokens: + return marshal(val) + case SemanticTokensDelta: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *SemanticTokensDeltaResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 SemanticTokens + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 SemanticTokensDelta + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} +} + +// SemanticTokensOptionsFull server supports providing semantic tokens for a full document. type SemanticTokensOptionsFull struct { value any } @@ -1368,8 +1685,6 @@ func (t *SemanticTokensOptionsFull) UnmarshalJSON(val []byte) error { } // SemanticTokensOptionsRange server supports providing semantic tokens for a specific range of a document. -// -// @since 3.16.0 type SemanticTokensOptionsRange struct { value any } @@ -1411,6 +1726,8 @@ func (t *SemanticTokensOptionsRange) UnmarshalJSON(val []byte) error { } // ServerCapabilitiesCallHierarchyProvider the server provides call hierarchy support. +// +// @since 3.16.0 type ServerCapabilitiesCallHierarchyProvider struct { value any } @@ -1637,6 +1954,8 @@ func (t *ServerCapabilitiesDefinitionProvider) UnmarshalJSON(val []byte) error { } // ServerCapabilitiesDiagnosticProvider the server has support for pull model diagnostics. +// +// @since 3.17.0 type ServerCapabilitiesDiagnosticProvider struct { value any } @@ -1979,6 +2298,8 @@ func (t *ServerCapabilitiesImplementationProvider) UnmarshalJSON(val []byte) err } // ServerCapabilitiesInlayHintProvider the server provides inlay hints. +// +// @since 3.17.0 type ServerCapabilitiesInlayHintProvider struct { value any } @@ -2027,6 +2348,8 @@ func (t *ServerCapabilitiesInlayHintProvider) UnmarshalJSON(val []byte) error { } // ServerCapabilitiesInlineCompletionProvider inline completion options used during static registration. 3.18.0 @proposed. +// +// @since 3.18.0 proposed type ServerCapabilitiesInlineCompletionProvider struct { value any } @@ -2068,6 +2391,8 @@ func (t *ServerCapabilitiesInlineCompletionProvider) UnmarshalJSON(val []byte) e } // ServerCapabilitiesInlineValueProvider the server provides inline values. +// +// @since 3.17.0 type ServerCapabilitiesInlineValueProvider struct { value any } @@ -2116,6 +2441,8 @@ func (t *ServerCapabilitiesInlineValueProvider) UnmarshalJSON(val []byte) error } // ServerCapabilitiesLinkedEditingRangeProvider the server provides linked editing range support. +// +// @since 3.16.0 type ServerCapabilitiesLinkedEditingRangeProvider struct { value any } @@ -2164,6 +2491,8 @@ func (t *ServerCapabilitiesLinkedEditingRangeProvider) UnmarshalJSON(val []byte) } // ServerCapabilitiesMonikerProvider the server provides moniker support. +// +// @since 3.16.0 type ServerCapabilitiesMonikerProvider struct { value any } @@ -2212,6 +2541,8 @@ func (t *ServerCapabilitiesMonikerProvider) UnmarshalJSON(val []byte) error { } // ServerCapabilitiesNotebookDocumentSync defines how notebook documents are synced. +// +// @since 3.17.0 type ServerCapabilitiesNotebookDocumentSync struct { value any } @@ -2384,6 +2715,8 @@ func (t *ServerCapabilitiesSelectionRangeProvider) UnmarshalJSON(val []byte) err } // ServerCapabilitiesSemanticTokensProvider the server provides semantic tokens support. +// +// @since 3.16.0 type ServerCapabilitiesSemanticTokensProvider struct { value any } @@ -2514,6 +2847,8 @@ func (t *ServerCapabilitiesTypeDefinitionProvider) UnmarshalJSON(val []byte) err } // ServerCapabilitiesTypeHierarchyProvider the server provides type hierarchy support. +// +// @since 3.17.0 type ServerCapabilitiesTypeHierarchyProvider struct { value any } @@ -2773,6 +3108,47 @@ func (t *TypeDefinitionResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} } +// TypeDefinitionResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. +type TypeDefinitionResult struct { + value any +} + +func NewTypeDefinitionResult[T Definition | []DefinitionLink](val T) *TypeDefinitionResult { + return &TypeDefinitionResult{ + value: val, + } +} + +func (t TypeDefinitionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Definition: + return marshal(val) + case []DefinitionLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TypeDefinitionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Definition + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + // WorkspaceEditDocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are // either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. type WorkspaceEditDocumentChanges struct { @@ -2872,7 +3248,7 @@ func (t *WorkspaceFoldersServerCapabilitiesChangeNotifications) UnmarshalJSON(va // WorkspaceOptionsTextDocumentContent the server supports the `workspace/textDocumentContent` request. 3.18.0 @proposed. // -// @since 3.18.0 +// @since 3.18.0 proposed type WorkspaceOptionsTextDocumentContent struct { value any } @@ -2916,8 +3292,6 @@ func (t *WorkspaceOptionsTextDocumentContent) UnmarshalJSON(val []byte) error { // WorkspaceSymbolLocation the location of the symbol. Whether a server is allowed to return a location without a range depends // on the client capability `workspace.symbol.resolveSupport`. See SymbolInformation#location for // more details. -// -// @since 3.17.0 type WorkspaceSymbolLocation struct { value any } @@ -3001,3 +3375,47 @@ func (t *WorkspaceSymbolResult) UnmarshalJSON(val []byte) error { } return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []WorkspaceSymbol]"} } + +// WorkspaceSymbolResult a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. +// The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. +// +// @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. +type WorkspaceSymbolResult struct { + value any +} + +func NewWorkspaceSymbolResult[T []SymbolInformation | []WorkspaceSymbol](val T) WorkspaceSymbolResult { + return WorkspaceSymbolResult{ + value: val, + } +} + +func (t WorkspaceSymbolResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case []SymbolInformation: + return marshal(val) + case []WorkspaceSymbol: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceSymbolResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 []SymbolInformation + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []WorkspaceSymbol + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []WorkspaceSymbol]"} +} diff --git a/tools/protocol-gen/generator/client_server.go b/tools/protocol-gen/generator/client_server.go index e825b8d0..3af688e8 100644 --- a/tools/protocol-gen/generator/client_server.go +++ b/tools/protocol-gen/generator/client_server.go @@ -374,13 +374,13 @@ func (gen *Generator) request(g Printer, meth string, req *protocol.Request) (nR gen.renderRequestssOrTypeNull(g, req, r) g.P(`, `) default: - genericsType := genericsType{ + genericsProp := &protocol.Property{ Name: meth + "Result", Documentation: req.Documentation, Since: req.Since, Proposed: req.Proposed, } - gen.renderRequestssOrType(g, r, genericsType) + gen.renderRequestssOrType(g, r, genericsProp) g.P(`, `) } @@ -410,13 +410,13 @@ func (gen *Generator) renderRequestsArrayType(g Printer, req *protocol.Request, g.P(`[]*`) gen.renderRequestssOrTypeNull(g, req, elem) default: - genericsType := genericsType{ + genericsProp := &protocol.Property{ Name: normalizeMethodName(req.TypeName) + "Result", Documentation: req.Documentation, Since: req.Since, Proposed: req.Proposed, } - gen.renderRequestssOrType(g, elem, genericsType) + gen.renderRequestssOrType(g, elem, genericsProp) } default: @@ -447,7 +447,7 @@ func (gen *Generator) renderRequestssOrTypeNull(g Printer, req *protocol.Request } } -func (gen *Generator) renderRequestssOrType(g Printer, or *protocol.OrType, genericsType genericsType) { - g.P(` *`, genericsType.Name) - gen.genericsTypes[genericsType] = or.Items +func (gen *Generator) renderRequestssOrType(g Printer, or *protocol.OrType, genericsProp *protocol.Property) { + g.P(` *`, genericsProp.Name) + gen.genericsTypes[genericsProp] = or.Items } diff --git a/tools/protocol-gen/generator/generator.go b/tools/protocol-gen/generator/generator.go index c985a66d..f5b9e512 100644 --- a/tools/protocol-gen/generator/generator.go +++ b/tools/protocol-gen/generator/generator.go @@ -14,8 +14,8 @@ import ( "strconv" "strings" - "github.com/davecgh/go-spew/spew" "github.com/gobuffalo/flect" + "github.com/kortschak/utter" "go.lsp.dev/protocol/tools/protocol-gen/protocol" ) @@ -25,10 +25,17 @@ var acronyms = [...]string{ } func init() { - spew.Config = spew.ConfigState{ - Indent: " ", - ContinueOnMethod: true, - SortKeys: true, + utter.Config = utter.ConfigState{ + Indent: " ", + NumericWidth: 1, + StringWidth: 1, + Quoting: utter.AvoidEscapes, + BytesWidth: 16, + CommentBytes: true, + AddressBytes: true, + CommentPointers: true, + ElideType: true, + SortKeys: true, } var buf bytes.Buffer @@ -51,13 +58,6 @@ const ( pkgJSONRPC = `"go.lsp.dev/jsonrpc2"` ) -type genericsType struct { - Name string - Documentation string - Since string - Proposed bool -} - type Generator struct { enumerations []Printer typeAliases []Printer @@ -65,13 +65,13 @@ type Generator struct { client []Printer server []Printer generics map[string]bool - genericsTypes map[genericsType][]protocol.Type + genericsTypes map[*protocol.Property][]protocol.Type files map[string]*os.File } func (gen *Generator) Init() { gen.generics = make(map[string]bool) - gen.genericsTypes = make(map[genericsType][]protocol.Type) + gen.genericsTypes = make(map[*protocol.Property][]protocol.Type) gen.files = make(map[string]*os.File) } diff --git a/tools/protocol-gen/generator/generics_types.go b/tools/protocol-gen/generator/generics_types.go index 0fc4c2da..736b9d1c 100644 --- a/tools/protocol-gen/generator/generics_types.go +++ b/tools/protocol-gen/generator/generics_types.go @@ -16,13 +16,13 @@ import ( func (gen *Generator) GenericsTypes() error { g := NewPrinter("types_generics") - sorted := make([]genericsType, len(gen.genericsTypes)) + sorted := make([]*protocol.Property, len(gen.genericsTypes)) i := 0 for generics := range gen.genericsTypes { sorted[i] = generics i++ } - slices.SortFunc(sorted, func(a, b genericsType) int { + slices.SortFunc(sorted, func(a, b *protocol.Property) int { return cmp.Compare(a.Name, b.Name) }) diff --git a/tools/protocol-gen/generator/structure.go b/tools/protocol-gen/generator/structure.go index e76e7089..04ebc8b8 100644 --- a/tools/protocol-gen/generator/structure.go +++ b/tools/protocol-gen/generator/structure.go @@ -512,23 +512,23 @@ func (gen *Generator) Structures(structures []*protocol.Structure) error { gen.renderStructuresReferenceType(g, prop, node) case *protocol.ArrayType: - genericsType := genericsType{ + genericsProp := &protocol.Property{ Name: structuresName + propName, Documentation: prop.Documentation, Since: structure.Since, Proposed: structure.Proposed, } g.P(` `) - gen.renderStructuresArrayTypeGeneric(g, node, genericsType) + gen.renderStructuresArrayTypeGeneric(g, node, genericsProp) case *protocol.MapType: - genericsType := genericsType{ + genericsProp := &protocol.Property{ Name: structuresName + propName, Documentation: prop.Documentation, Since: structure.Since, Proposed: structure.Proposed, } - gen.renderStructuresMapType(g, node, genericsType) + gen.renderStructuresMapType(g, node, genericsProp) case *protocol.OrType: switch { @@ -554,13 +554,15 @@ func (gen *Generator) Structures(structures []*protocol.Structure) error { if isNull(node.Items...) { prop.Optional = true } - genericsType := genericsType{ + genericsProp := &protocol.Property{ Name: structuresName + propName, + Optional: prop.Optional, Documentation: prop.Documentation, - Since: structure.Since, - Proposed: structure.Proposed, + Proposed: prop.Proposed, + Since: prop.Since, + Deprecated: prop.Deprecated, } - gen.renderStructuresOrType(g, node, genericsType) + gen.renderStructuresOrType(g, node, genericsProp) } default: @@ -599,7 +601,7 @@ func (gen *Generator) renderStructuresReferenceType(g Printer, prop *protocol.Pr case `LSPArray`: name = `[]any` default: - if _, ok := enumerationNames[ref.Name]; !ok && prop.Optional { + if _, ok := enumerationNames[name]; !ok && prop.Optional { g.P(`*`) } } @@ -618,7 +620,7 @@ func (gen *Generator) renderStructuresArrayType(g Printer, array *protocol.Array } } -func (gen *Generator) renderStructuresArrayTypeGeneric(g Printer, array *protocol.ArrayType, genericsType genericsType) { +func (gen *Generator) renderStructuresArrayTypeGeneric(g Printer, array *protocol.ArrayType, genericsProp *protocol.Property) { elem := array.Element switch elem := elem.(type) { case protocol.BaseType: @@ -628,14 +630,14 @@ func (gen *Generator) renderStructuresArrayTypeGeneric(g Printer, array *protoco g.P(`[]` + normalizeLSPTypes(elem.String())) case *protocol.OrType: - gen.renderStructuresOrType(g, elem, genericsType) + gen.renderStructuresOrType(g, elem, genericsProp) default: panic(fmt.Sprintf("structures.ArrayKind: %#v\n", elem)) } } -func (gen *Generator) renderStructuresMapType(g Printer, m *protocol.MapType, genericsType genericsType) { +func (gen *Generator) renderStructuresMapType(g Printer, m *protocol.MapType, genericsProp *protocol.Property) { g.P(` map`) // write map key @@ -656,17 +658,17 @@ func (gen *Generator) renderStructuresMapType(g Printer, m *protocol.MapType, ge g.P(normalizeLSPTypes(val.String())) case *protocol.ArrayType: - gen.renderStructuresArrayTypeGeneric(g, val, genericsType) + gen.renderStructuresArrayTypeGeneric(g, val, genericsProp) case *protocol.OrType: - gen.renderStructuresOrType(g, val, genericsType) + gen.renderStructuresOrType(g, val, genericsProp) default: panic(fmt.Sprintf("structures.MapType.Value: %[1]T = %#[1]v\n", m.Value)) } } -func (gen *Generator) renderStructuresOrType(g Printer, or *protocol.OrType, genericsType genericsType) { - g.P(` `, genericsType.Name) - gen.genericsTypes[genericsType] = or.Items +func (gen *Generator) renderStructuresOrType(g Printer, or *protocol.OrType, genericsProp *protocol.Property) { + g.P(` `, genericsProp.Name) + gen.genericsTypes[genericsProp] = or.Items } diff --git a/tools/protocol-gen/go.mod b/tools/protocol-gen/go.mod index 1832413f..1b1ee2e8 100644 --- a/tools/protocol-gen/go.mod +++ b/tools/protocol-gen/go.mod @@ -1,9 +1,9 @@ module go.lsp.dev/protocol/tools/protocol-gen -go 1.22.2 +go 1.23 require ( - github.com/davecgh/go-spew v1.1.1 github.com/gobuffalo/flect v1.0.2 + github.com/kortschak/utter v1.7.0 golang.org/x/text v0.14.0 ) diff --git a/tools/protocol-gen/go.sum b/tools/protocol-gen/go.sum index a855e77a..fbb0c80c 100644 --- a/tools/protocol-gen/go.sum +++ b/tools/protocol-gen/go.sum @@ -3,6 +3,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= +github.com/kortschak/utter v1.7.0 h1:6NKMynvGUyqfeMTawfah4zyInlrgwzjkDAHrT+skx/w= +github.com/kortschak/utter v1.7.0/go.mod h1:vSmSjbyrlKjjsL71193LmzBOKgwePk9DH6uFaWHIInc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/tools/protocol-gen/main.go b/tools/protocol-gen/main.go index 8690bb2c..14487481 100644 --- a/tools/protocol-gen/main.go +++ b/tools/protocol-gen/main.go @@ -13,7 +13,7 @@ import ( "os" "strings" - "github.com/davecgh/go-spew/spew" + "github.com/kortschak/utter" "go.lsp.dev/protocol/tools/protocol-gen/generator" "go.lsp.dev/protocol/tools/protocol-gen/resolver" @@ -26,10 +26,17 @@ const ( ) func init() { - spew.Config = spew.ConfigState{ - Indent: " ", - ContinueOnMethod: true, - SortKeys: true, + utter.Config = utter.ConfigState{ + Indent: " ", + NumericWidth: 1, + StringWidth: 1, + Quoting: utter.AvoidEscapes, + BytesWidth: 16, + CommentBytes: true, + AddressBytes: true, + CommentPointers: true, + ElideType: true, + SortKeys: true, } } diff --git a/tools/protocol-gen/resolver/resolver.go b/tools/protocol-gen/resolver/resolver.go index f1527196..f3037d63 100644 --- a/tools/protocol-gen/resolver/resolver.go +++ b/tools/protocol-gen/resolver/resolver.go @@ -187,31 +187,34 @@ func (r *resolver) structure(in schema.Structure) *protocol.Structure { NestedNames: []string{name}, } for _, propertyIn := range in.Properties { - defer scopedAssignment(&r.newStructureLiteralType, func(in *schema.StructureLiteralType) protocol.Type { - name := cases.Title(language.Und, cases.NoLower).String(propertyIn.Name) - out.NestedStructures = append(out.NestedStructures, - &protocol.Structure{ - Deprecated: in.Value.Deprecated, - Documentation: r.documentation(in.Value.Documentation), - Properties: transform(in.Value.Properties, r.property), - Name: name, - Proposed: in.Value.Proposed, - Since: in.Value.Since, - NestedNames: append(append([]string{}, out.NestedNames...), name), - }, - ) - ref := &protocol.ReferenceType{Name: name} - r.allReferenceTypes = append(r.allReferenceTypes, ref) - return ref - })() - propertyOut := r.property(propertyIn) - if propertyOut.JSONName == "kind" { - if lit, ok := propertyOut.Type.(*protocol.StringLiteralType); ok { - out.Kind = lit.Value - continue + func() { + defer scopedAssignment(&r.newStructureLiteralType, func(in *schema.StructureLiteralType) protocol.Type { + name := cases.Title(language.Und, cases.NoLower).String(propertyIn.Name) + out.NestedStructures = append(out.NestedStructures, + &protocol.Structure{ + Deprecated: in.Value.Deprecated, + Documentation: r.documentation(in.Value.Documentation), + Properties: transform(in.Value.Properties, r.property), + Name: name, + Proposed: in.Value.Proposed, + Since: in.Value.Since, + NestedNames: append(append([]string{}, out.NestedNames...), name), + }, + ) + ref := &protocol.ReferenceType{Name: name} + r.allReferenceTypes = append(r.allReferenceTypes, ref) + return ref + })() + + propertyOut := r.property(propertyIn) + if propertyOut.JSONName == "kind" { + if lit, ok := propertyOut.Type.(*protocol.StringLiteralType); ok { + out.Kind = lit.Value + return + } } - } - out.Properties = append(out.Properties, propertyOut) + out.Properties = append(out.Properties, propertyOut) + }() } return out } diff --git a/tools/protocol-gen/testdata/lsp.v2024.0.0b1.json b/tools/protocol-gen/testdata/lsp.v2024.0.0b1.json new file mode 100644 index 00000000..a57c37f7 --- /dev/null +++ b/tools/protocol-gen/testdata/lsp.v2024.0.0b1.json @@ -0,0 +1,15928 @@ +{ + "metaData": { + "version": "3.17.0" + }, + "requests": [ + { + "method": "textDocument/implementation", + "typeName": "ImplementationRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Definition" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DefinitionLink" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "ImplementationParams" + }, + "partialResult": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "Location" + } + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DefinitionLink" + } + } + ] + }, + "registrationOptions": { + "kind": "reference", + "name": "ImplementationRegistrationOptions" + }, + "documentation": "A request to resolve the implementation locations of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPositionParams}\nthe response is of type {@link Definition} or a Thenable that resolves to such." + }, + { + "method": "textDocument/typeDefinition", + "typeName": "TypeDefinitionRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Definition" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DefinitionLink" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "TypeDefinitionParams" + }, + "partialResult": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "Location" + } + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DefinitionLink" + } + } + ] + }, + "registrationOptions": { + "kind": "reference", + "name": "TypeDefinitionRegistrationOptions" + }, + "documentation": "A request to resolve the type definition locations of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPositionParams}\nthe response is of type {@link Definition} or a Thenable that resolves to such." + }, + { + "method": "workspace/workspaceFolders", + "typeName": "WorkspaceFoldersRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "WorkspaceFolder" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "serverToClient", + "documentation": "The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders." + }, + { + "method": "workspace/configuration", + "typeName": "ConfigurationRequest", + "result": { + "kind": "array", + "element": { + "kind": "reference", + "name": "LSPAny" + } + }, + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "ConfigurationParams" + }, + "documentation": "The 'workspace/configuration' request is sent from the server to the client to fetch a certain\nconfiguration setting.\n\nThis pull model replaces the old push model were the client signaled configuration change via an\nevent. If the server still needs to react to configuration changes (since the server caches the\nresult of `workspace/configuration` requests) the server should register for an empty configuration\nchange event and empty the cache if such an event is received." + }, + { + "method": "textDocument/documentColor", + "typeName": "DocumentColorRequest", + "result": { + "kind": "array", + "element": { + "kind": "reference", + "name": "ColorInformation" + } + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentColorParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "ColorInformation" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "DocumentColorRegistrationOptions" + }, + "documentation": "A request to list all color symbols found in a given text document. The request's\nparameter is of type {@link DocumentColorParams} the\nresponse is of type {@link ColorInformation ColorInformation[]} or a Thenable\nthat resolves to such." + }, + { + "method": "textDocument/colorPresentation", + "typeName": "ColorPresentationRequest", + "result": { + "kind": "array", + "element": { + "kind": "reference", + "name": "ColorPresentation" + } + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "ColorPresentationParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "ColorPresentation" + } + }, + "registrationOptions": { + "kind": "and", + "items": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + }, + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + } + ] + }, + "documentation": "A request to list all presentation for a color. The request's\nparameter is of type {@link ColorPresentationParams} the\nresponse is of type {@link ColorInformation ColorInformation[]} or a Thenable\nthat resolves to such." + }, + { + "method": "textDocument/foldingRange", + "typeName": "FoldingRangeRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "FoldingRange" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "FoldingRangeParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "FoldingRange" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "FoldingRangeRegistrationOptions" + }, + "documentation": "A request to provide folding ranges in a document. The request's\nparameter is of type {@link FoldingRangeParams}, the\nresponse is of type {@link FoldingRangeList} or a Thenable\nthat resolves to such." + }, + { + "method": "workspace/foldingRange/refresh", + "typeName": "FoldingRangeRefreshRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "documentation": "@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "method": "textDocument/declaration", + "typeName": "DeclarationRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Declaration" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DeclarationLink" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DeclarationParams" + }, + "partialResult": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "Location" + } + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DeclarationLink" + } + } + ] + }, + "registrationOptions": { + "kind": "reference", + "name": "DeclarationRegistrationOptions" + }, + "documentation": "A request to resolve the type definition locations of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPositionParams}\nthe response is of type {@link Declaration} or a typed array of {@link DeclarationLink}\nor a Thenable that resolves to such." + }, + { + "method": "textDocument/selectionRange", + "typeName": "SelectionRangeRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "SelectionRange" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "SelectionRangeParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SelectionRange" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "SelectionRangeRegistrationOptions" + }, + "documentation": "A request to provide selection ranges in a document. The request's\nparameter is of type {@link SelectionRangeParams}, the\nresponse is of type {@link SelectionRange SelectionRange[]} or a Thenable\nthat resolves to such." + }, + { + "method": "window/workDoneProgress/create", + "typeName": "WorkDoneProgressCreateRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "WorkDoneProgressCreateParams" + }, + "documentation": "The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress\nreporting from the server." + }, + { + "method": "textDocument/prepareCallHierarchy", + "typeName": "CallHierarchyPrepareRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "CallHierarchyItem" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CallHierarchyPrepareParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "CallHierarchyRegistrationOptions" + }, + "documentation": "A request to result a `CallHierarchyItem` in a document at a given position.\nCan be used as an input to an incoming or outgoing call hierarchy.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "callHierarchy/incomingCalls", + "typeName": "CallHierarchyIncomingCallsRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "CallHierarchyIncomingCall" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CallHierarchyIncomingCallsParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CallHierarchyIncomingCall" + } + }, + "documentation": "A request to resolve the incoming calls for a given `CallHierarchyItem`.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "callHierarchy/outgoingCalls", + "typeName": "CallHierarchyOutgoingCallsRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "CallHierarchyOutgoingCall" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CallHierarchyOutgoingCallsParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CallHierarchyOutgoingCall" + } + }, + "documentation": "A request to resolve the outgoing calls for a given `CallHierarchyItem`.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "textDocument/semanticTokens/full", + "typeName": "SemanticTokensRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "SemanticTokens" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "SemanticTokensParams" + }, + "partialResult": { + "kind": "reference", + "name": "SemanticTokensPartialResult" + }, + "registrationMethod": "textDocument/semanticTokens", + "registrationOptions": { + "kind": "reference", + "name": "SemanticTokensRegistrationOptions" + }, + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "textDocument/semanticTokens/full/delta", + "typeName": "SemanticTokensDeltaRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "SemanticTokens" + }, + { + "kind": "reference", + "name": "SemanticTokensDelta" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "SemanticTokensDeltaParams" + }, + "partialResult": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "SemanticTokensPartialResult" + }, + { + "kind": "reference", + "name": "SemanticTokensDeltaPartialResult" + } + ] + }, + "registrationMethod": "textDocument/semanticTokens", + "registrationOptions": { + "kind": "reference", + "name": "SemanticTokensRegistrationOptions" + }, + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "textDocument/semanticTokens/range", + "typeName": "SemanticTokensRangeRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "SemanticTokens" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "SemanticTokensRangeParams" + }, + "partialResult": { + "kind": "reference", + "name": "SemanticTokensPartialResult" + }, + "registrationMethod": "textDocument/semanticTokens", + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "workspace/semanticTokens/refresh", + "typeName": "SemanticTokensRefreshRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "window/showDocument", + "typeName": "ShowDocumentRequest", + "result": { + "kind": "reference", + "name": "ShowDocumentResult" + }, + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "ShowDocumentParams" + }, + "documentation": "A request to show a document. This request might open an\nexternal program depending on the value of the URI to open.\nFor example a request to open `https://code.visualstudio.com/`\nwill very likely open the URI in a WEB browser.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "textDocument/linkedEditingRange", + "typeName": "LinkedEditingRangeRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "LinkedEditingRanges" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "LinkedEditingRangeParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "LinkedEditingRangeRegistrationOptions" + }, + "documentation": "A request to provide ranges that can be edited together.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "workspace/willCreateFiles", + "typeName": "WillCreateFilesRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "WorkspaceEdit" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CreateFilesParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "documentation": "The will create files request is sent from the client to the server before files are actually\ncreated as long as the creation is triggered from within the client.\n\nThe request can return a `WorkspaceEdit` which will be applied to workspace before the\nfiles are created. Hence the `WorkspaceEdit` can not manipulate the content of the file\nto be created.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "workspace/willRenameFiles", + "typeName": "WillRenameFilesRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "WorkspaceEdit" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "RenameFilesParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "documentation": "The will rename files request is sent from the client to the server before files are actually\nrenamed as long as the rename is triggered from within the client.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "workspace/willDeleteFiles", + "typeName": "WillDeleteFilesRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "WorkspaceEdit" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DeleteFilesParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "documentation": "The did delete files notification is sent from the client to the server when\nfiles were deleted from within the client.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "textDocument/moniker", + "typeName": "MonikerRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "Moniker" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "MonikerParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Moniker" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "MonikerRegistrationOptions" + }, + "documentation": "A request to get the moniker of a symbol at a given text document position.\nThe request parameter is of type {@link TextDocumentPositionParams}.\nThe response is of type {@link Moniker Moniker[]} or `null`." + }, + { + "method": "textDocument/prepareTypeHierarchy", + "typeName": "TypeHierarchyPrepareRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "TypeHierarchyItem" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "TypeHierarchyPrepareParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "TypeHierarchyRegistrationOptions" + }, + "documentation": "A request to result a `TypeHierarchyItem` in a document at a given position.\nCan be used as an input to a subtypes or supertypes type hierarchy.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "typeHierarchy/supertypes", + "typeName": "TypeHierarchySupertypesRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "TypeHierarchyItem" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "TypeHierarchySupertypesParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TypeHierarchyItem" + } + }, + "documentation": "A request to resolve the supertypes for a given `TypeHierarchyItem`.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "typeHierarchy/subtypes", + "typeName": "TypeHierarchySubtypesRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "TypeHierarchyItem" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "TypeHierarchySubtypesParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TypeHierarchyItem" + } + }, + "documentation": "A request to resolve the subtypes for a given `TypeHierarchyItem`.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "textDocument/inlineValue", + "typeName": "InlineValueRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineValue" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InlineValueParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineValue" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "InlineValueRegistrationOptions" + }, + "documentation": "A request to provide inline values in a document. The request's parameter is of\ntype {@link InlineValueParams}, the response is of type\n{@link InlineValue InlineValue[]} or a Thenable that resolves to such.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "workspace/inlineValue/refresh", + "typeName": "InlineValueRefreshRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "documentation": "@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "textDocument/inlayHint", + "typeName": "InlayHintRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlayHint" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InlayHintParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlayHint" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "InlayHintRegistrationOptions" + }, + "documentation": "A request to provide inlay hints in a document. The request's parameter is of\ntype {@link InlayHintsParams}, the response is of type\n{@link InlayHint InlayHint[]} or a Thenable that resolves to such.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "inlayHint/resolve", + "typeName": "InlayHintResolveRequest", + "result": { + "kind": "reference", + "name": "InlayHint" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InlayHint" + }, + "documentation": "A request to resolve additional properties for an inlay hint.\nThe request's parameter is of type {@link InlayHint}, the response is\nof type {@link InlayHint} or a Thenable that resolves to such.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "workspace/inlayHint/refresh", + "typeName": "InlayHintRefreshRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "documentation": "@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "textDocument/diagnostic", + "typeName": "DocumentDiagnosticRequest", + "result": { + "kind": "reference", + "name": "DocumentDiagnosticReport" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentDiagnosticParams" + }, + "partialResult": { + "kind": "reference", + "name": "DocumentDiagnosticReportPartialResult" + }, + "errorData": { + "kind": "reference", + "name": "DiagnosticServerCancellationData" + }, + "registrationOptions": { + "kind": "reference", + "name": "DiagnosticRegistrationOptions" + }, + "documentation": "The document diagnostic request definition.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "workspace/diagnostic", + "typeName": "WorkspaceDiagnosticRequest", + "result": { + "kind": "reference", + "name": "WorkspaceDiagnosticReport" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "WorkspaceDiagnosticParams" + }, + "partialResult": { + "kind": "reference", + "name": "WorkspaceDiagnosticReportPartialResult" + }, + "errorData": { + "kind": "reference", + "name": "DiagnosticServerCancellationData" + }, + "documentation": "The workspace diagnostic request definition.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "workspace/diagnostic/refresh", + "typeName": "DiagnosticRefreshRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "documentation": "The diagnostic refresh request definition.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "textDocument/inlineCompletion", + "typeName": "InlineCompletionRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "InlineCompletionList" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InlineCompletionParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "InlineCompletionRegistrationOptions" + }, + "documentation": "A request to provide inline completions in a document. The request's parameter is of\ntype {@link InlineCompletionParams}, the response is of type\n{@link InlineCompletion InlineCompletion[]} or a Thenable that resolves to such.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "method": "workspace/textDocumentContent", + "typeName": "TextDocumentContentRequest", + "result": { + "kind": "reference", + "name": "TextDocumentContentResult" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "TextDocumentContentParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "TextDocumentContentRegistrationOptions" + }, + "documentation": "The `workspace/textDocumentContent` request is sent from the client to the\nserver to request the content of a text document.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "method": "workspace/textDocumentContent/refresh", + "typeName": "TextDocumentContentRefreshRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "TextDocumentContentRefreshParams" + }, + "documentation": "The `workspace/textDocumentContent` request is sent from the server to the client to refresh\nthe content of a specific text document.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "method": "client/registerCapability", + "typeName": "RegistrationRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "RegistrationParams" + }, + "documentation": "The `client/registerCapability` request is sent from the server to the client to register a new capability\nhandler on the client side." + }, + { + "method": "client/unregisterCapability", + "typeName": "UnregistrationRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "UnregistrationParams" + }, + "documentation": "The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability\nhandler on the client side." + }, + { + "method": "initialize", + "typeName": "InitializeRequest", + "result": { + "kind": "reference", + "name": "InitializeResult" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InitializeParams" + }, + "errorData": { + "kind": "reference", + "name": "InitializeError" + }, + "documentation": "The initialize request is sent from the client to the server.\nIt is sent once as the request after starting up the server.\nThe requests parameter is of type {@link InitializeParams}\nthe response if of type {@link InitializeResult} of a Thenable that\nresolves to such." + }, + { + "method": "shutdown", + "typeName": "ShutdownRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "clientToServer", + "documentation": "A shutdown request is sent from the client to the server.\nIt is sent once when the client decides to shutdown the\nserver. The only notification that is sent after a shutdown request\nis the exit event." + }, + { + "method": "window/showMessageRequest", + "typeName": "ShowMessageRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "MessageActionItem" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "ShowMessageRequestParams" + }, + "documentation": "The show message request is sent from the server to the client to show a message\nand a set of options actions to the user." + }, + { + "method": "textDocument/willSaveWaitUntil", + "typeName": "WillSaveTextDocumentWaitUntilRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextEdit" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "WillSaveTextDocumentParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + "documentation": "A document will save request is sent from the client to the server before\nthe document is actually saved. The request can return an array of TextEdits\nwhich will be applied to the text document before it is saved. Please note that\nclients might drop results if computing the text edits took too long or if a\nserver constantly fails on this request. This is done to keep the save fast and\nreliable." + }, + { + "method": "textDocument/completion", + "typeName": "CompletionRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "CompletionItem" + } + }, + { + "kind": "reference", + "name": "CompletionList" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CompletionParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CompletionItem" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "CompletionRegistrationOptions" + }, + "documentation": "Request to request completion at a given text document position. The request's\nparameter is of type {@link TextDocumentPosition} the response\nis of type {@link CompletionItem CompletionItem[]} or {@link CompletionList}\nor a Thenable that resolves to such.\n\nThe request can delay the computation of the {@link CompletionItem.detail `detail`}\nand {@link CompletionItem.documentation `documentation`} properties to the `completionItem/resolve`\nrequest. However, properties that are needed for the initial sorting and filtering, like `sortText`,\n`filterText`, `insertText`, and `textEdit`, must not be changed during resolve." + }, + { + "method": "completionItem/resolve", + "typeName": "CompletionResolveRequest", + "result": { + "kind": "reference", + "name": "CompletionItem" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CompletionItem" + }, + "documentation": "Request to resolve additional information for a given completion item.The request's\nparameter is of type {@link CompletionItem} the response\nis of type {@link CompletionItem} or a Thenable that resolves to such." + }, + { + "method": "textDocument/hover", + "typeName": "HoverRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Hover" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "HoverParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "HoverRegistrationOptions" + }, + "documentation": "Request to request hover information at a given text document position. The request's\nparameter is of type {@link TextDocumentPosition} the response is of\ntype {@link Hover} or a Thenable that resolves to such." + }, + { + "method": "textDocument/signatureHelp", + "typeName": "SignatureHelpRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "SignatureHelp" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "SignatureHelpParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "SignatureHelpRegistrationOptions" + } + }, + { + "method": "textDocument/definition", + "typeName": "DefinitionRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Definition" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DefinitionLink" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DefinitionParams" + }, + "partialResult": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "Location" + } + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DefinitionLink" + } + } + ] + }, + "registrationOptions": { + "kind": "reference", + "name": "DefinitionRegistrationOptions" + }, + "documentation": "A request to resolve the definition location of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPosition}\nthe response is of either type {@link Definition} or a typed array of\n{@link DefinitionLink} or a Thenable that resolves to such." + }, + { + "method": "textDocument/references", + "typeName": "ReferencesRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "Location" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "ReferenceParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Location" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "ReferenceRegistrationOptions" + }, + "documentation": "A request to resolve project-wide references for the symbol denoted\nby the given text document position. The request's parameter is of\ntype {@link ReferenceParams} the response is of type\n{@link Location Location[]} or a Thenable that resolves to such." + }, + { + "method": "textDocument/documentHighlight", + "typeName": "DocumentHighlightRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DocumentHighlight" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentHighlightParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "DocumentHighlight" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "DocumentHighlightRegistrationOptions" + }, + "documentation": "Request to resolve a {@link DocumentHighlight} for a given\ntext document position. The request's parameter is of type {@link TextDocumentPosition}\nthe request response is an array of type {@link DocumentHighlight}\nor a Thenable that resolves to such." + }, + { + "method": "textDocument/documentSymbol", + "typeName": "DocumentSymbolRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolInformation" + } + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DocumentSymbol" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentSymbolParams" + }, + "partialResult": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolInformation" + } + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DocumentSymbol" + } + } + ] + }, + "registrationOptions": { + "kind": "reference", + "name": "DocumentSymbolRegistrationOptions" + }, + "documentation": "A request to list all symbols found in a given text document. The request's\nparameter is of type {@link TextDocumentIdentifier} the\nresponse is of type {@link SymbolInformation SymbolInformation[]} or a Thenable\nthat resolves to such." + }, + { + "method": "textDocument/codeAction", + "typeName": "CodeActionRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Command" + }, + { + "kind": "reference", + "name": "CodeAction" + } + ] + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CodeActionParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Command" + }, + { + "kind": "reference", + "name": "CodeAction" + } + ] + } + }, + "registrationOptions": { + "kind": "reference", + "name": "CodeActionRegistrationOptions" + }, + "documentation": "A request to provide commands for the given text document and range." + }, + { + "method": "codeAction/resolve", + "typeName": "CodeActionResolveRequest", + "result": { + "kind": "reference", + "name": "CodeAction" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CodeAction" + }, + "documentation": "Request to resolve additional information for a given code action.The request's\nparameter is of type {@link CodeAction} the response\nis of type {@link CodeAction} or a Thenable that resolves to such." + }, + { + "method": "workspace/symbol", + "typeName": "WorkspaceSymbolRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolInformation" + } + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "WorkspaceSymbol" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "WorkspaceSymbolParams" + }, + "partialResult": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolInformation" + } + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "WorkspaceSymbol" + } + } + ] + }, + "registrationOptions": { + "kind": "reference", + "name": "WorkspaceSymbolRegistrationOptions" + }, + "documentation": "A request to list project-wide symbols matching the query string given\nby the {@link WorkspaceSymbolParams}. The response is\nof type {@link SymbolInformation SymbolInformation[]} or a Thenable that\nresolves to such.\n\n@since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients\n need to advertise support for WorkspaceSymbols via the client capability\n `workspace.symbol.resolveSupport`.\n", + "since": "3.17.0 - support for WorkspaceSymbol in the returned data. Clients\nneed to advertise support for WorkspaceSymbols via the client capability\n`workspace.symbol.resolveSupport`." + }, + { + "method": "workspaceSymbol/resolve", + "typeName": "WorkspaceSymbolResolveRequest", + "result": { + "kind": "reference", + "name": "WorkspaceSymbol" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "WorkspaceSymbol" + }, + "documentation": "A request to resolve the range inside the workspace\nsymbol's location.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "textDocument/codeLens", + "typeName": "CodeLensRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "CodeLens" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CodeLensParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CodeLens" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "CodeLensRegistrationOptions" + }, + "documentation": "A request to provide code lens for the given text document." + }, + { + "method": "codeLens/resolve", + "typeName": "CodeLensResolveRequest", + "result": { + "kind": "reference", + "name": "CodeLens" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CodeLens" + }, + "documentation": "A request to resolve a command for a given code lens." + }, + { + "method": "workspace/codeLens/refresh", + "typeName": "CodeLensRefreshRequest", + "result": { + "kind": "base", + "name": "null" + }, + "messageDirection": "serverToClient", + "documentation": "A request to refresh all code actions\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "textDocument/documentLink", + "typeName": "DocumentLinkRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "DocumentLink" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentLinkParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "DocumentLink" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "DocumentLinkRegistrationOptions" + }, + "documentation": "A request to provide document links" + }, + { + "method": "documentLink/resolve", + "typeName": "DocumentLinkResolveRequest", + "result": { + "kind": "reference", + "name": "DocumentLink" + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentLink" + }, + "documentation": "Request to resolve additional information for a given document link. The request's\nparameter is of type {@link DocumentLink} the response\nis of type {@link DocumentLink} or a Thenable that resolves to such." + }, + { + "method": "textDocument/formatting", + "typeName": "DocumentFormattingRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextEdit" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentFormattingParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "DocumentFormattingRegistrationOptions" + }, + "documentation": "A request to format a whole document." + }, + { + "method": "textDocument/rangeFormatting", + "typeName": "DocumentRangeFormattingRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextEdit" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentRangeFormattingParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "DocumentRangeFormattingRegistrationOptions" + }, + "documentation": "A request to format a range in a document." + }, + { + "method": "textDocument/rangesFormatting", + "typeName": "DocumentRangesFormattingRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextEdit" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentRangesFormattingParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "DocumentRangeFormattingRegistrationOptions" + }, + "documentation": "A request to format ranges in a document.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "method": "textDocument/onTypeFormatting", + "typeName": "DocumentOnTypeFormattingRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextEdit" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DocumentOnTypeFormattingParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "DocumentOnTypeFormattingRegistrationOptions" + }, + "documentation": "A request to format a document on type." + }, + { + "method": "textDocument/rename", + "typeName": "RenameRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "WorkspaceEdit" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "RenameParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "RenameRegistrationOptions" + }, + "documentation": "A request to rename a symbol." + }, + { + "method": "textDocument/prepareRename", + "typeName": "PrepareRenameRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "PrepareRenameResult" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "PrepareRenameParams" + }, + "documentation": "A request to test and perform the setup necessary for a rename.\n\n@since 3.16 - support for default behavior", + "since": "3.16 - support for default behavior" + }, + { + "method": "workspace/executeCommand", + "typeName": "ExecuteCommandRequest", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "LSPAny" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "ExecuteCommandParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "ExecuteCommandRegistrationOptions" + }, + "documentation": "A request send from the client to the server to execute a command. The request might return\na workspace edit which the client will apply to the workspace." + }, + { + "method": "workspace/applyEdit", + "typeName": "ApplyWorkspaceEditRequest", + "result": { + "kind": "reference", + "name": "ApplyWorkspaceEditResult" + }, + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "ApplyWorkspaceEditParams" + }, + "documentation": "A request sent from the server to the client to modified certain resources." + } + ], + "notifications": [ + { + "method": "workspace/didChangeWorkspaceFolders", + "typeName": "DidChangeWorkspaceFoldersNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidChangeWorkspaceFoldersParams" + }, + "documentation": "The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace\nfolder configuration changes." + }, + { + "method": "window/workDoneProgress/cancel", + "typeName": "WorkDoneProgressCancelNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "WorkDoneProgressCancelParams" + }, + "documentation": "The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress\ninitiated on the server side." + }, + { + "method": "workspace/didCreateFiles", + "typeName": "DidCreateFilesNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "CreateFilesParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "documentation": "The did create files notification is sent from the client to the server when\nfiles were created from within the client.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "workspace/didRenameFiles", + "typeName": "DidRenameFilesNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "RenameFilesParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "documentation": "The did rename files notification is sent from the client to the server when\nfiles were renamed from within the client.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "workspace/didDeleteFiles", + "typeName": "DidDeleteFilesNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DeleteFilesParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "documentation": "The will delete files request is sent from the client to the server before files are actually\ndeleted as long as the deletion is triggered from within the client.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "method": "notebookDocument/didOpen", + "typeName": "DidOpenNotebookDocumentNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidOpenNotebookDocumentParams" + }, + "registrationMethod": "notebookDocument/sync", + "registrationOptions": { + "kind": "reference", + "name": "NotebookDocumentSyncRegistrationOptions" + }, + "documentation": "A notification sent when a notebook opens.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "notebookDocument/didChange", + "typeName": "DidChangeNotebookDocumentNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidChangeNotebookDocumentParams" + }, + "registrationMethod": "notebookDocument/sync", + "registrationOptions": { + "kind": "reference", + "name": "NotebookDocumentSyncRegistrationOptions" + } + }, + { + "method": "notebookDocument/didSave", + "typeName": "DidSaveNotebookDocumentNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidSaveNotebookDocumentParams" + }, + "registrationMethod": "notebookDocument/sync", + "registrationOptions": { + "kind": "reference", + "name": "NotebookDocumentSyncRegistrationOptions" + }, + "documentation": "A notification sent when a notebook document is saved.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "notebookDocument/didClose", + "typeName": "DidCloseNotebookDocumentNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidCloseNotebookDocumentParams" + }, + "registrationMethod": "notebookDocument/sync", + "registrationOptions": { + "kind": "reference", + "name": "NotebookDocumentSyncRegistrationOptions" + }, + "documentation": "A notification sent when a notebook closes.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "method": "initialized", + "typeName": "InitializedNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InitializedParams" + }, + "documentation": "The initialized notification is sent from the client to the\nserver after the client is fully initialized and the server\nis allowed to send requests from the server to the client." + }, + { + "method": "exit", + "typeName": "ExitNotification", + "messageDirection": "clientToServer", + "documentation": "The exit event is sent from the client to the server to\nask the server to exit its process." + }, + { + "method": "workspace/didChangeConfiguration", + "typeName": "DidChangeConfigurationNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidChangeConfigurationParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "DidChangeConfigurationRegistrationOptions" + }, + "documentation": "The configuration change notification is sent from the client to the server\nwhen the client's configuration has changed. The notification contains\nthe changed configuration as defined by the language client." + }, + { + "method": "window/showMessage", + "typeName": "ShowMessageNotification", + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "ShowMessageParams" + }, + "documentation": "The show message notification is sent from a server to a client to ask\nthe client to display a particular message in the user interface." + }, + { + "method": "window/logMessage", + "typeName": "LogMessageNotification", + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "LogMessageParams" + }, + "documentation": "The log message notification is sent from the server to the client to ask\nthe client to log a particular message." + }, + { + "method": "telemetry/event", + "typeName": "TelemetryEventNotification", + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "LSPAny" + }, + "documentation": "The telemetry event notification is sent from the server to the client to ask\nthe client to log telemetry data." + }, + { + "method": "textDocument/didOpen", + "typeName": "DidOpenTextDocumentNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidOpenTextDocumentParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + "documentation": "The document open notification is sent from the client to the server to signal\nnewly opened text documents. The document's truth is now managed by the client\nand the server must not try to read the document's truth using the document's\nuri. Open in this sense means it is managed by the client. It doesn't necessarily\nmean that its content is presented in an editor. An open notification must not\nbe sent more than once without a corresponding close notification send before.\nThis means open and close notification must be balanced and the max open count\nis one." + }, + { + "method": "textDocument/didChange", + "typeName": "DidChangeTextDocumentNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidChangeTextDocumentParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "TextDocumentChangeRegistrationOptions" + }, + "documentation": "The document change notification is sent from the client to the server to signal\nchanges to a text document." + }, + { + "method": "textDocument/didClose", + "typeName": "DidCloseTextDocumentNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidCloseTextDocumentParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + "documentation": "The document close notification is sent from the client to the server when\nthe document got closed in the client. The document's truth now exists where\nthe document's uri points to (e.g. if the document's uri is a file uri the\ntruth now exists on disk). As with the open notification the close notification\nis about managing the document's content. Receiving a close notification\ndoesn't mean that the document was open in an editor before. A close\nnotification requires a previous open notification to be sent." + }, + { + "method": "textDocument/didSave", + "typeName": "DidSaveTextDocumentNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidSaveTextDocumentParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "TextDocumentSaveRegistrationOptions" + }, + "documentation": "The document save notification is sent from the client to the server when\nthe document got saved in the client." + }, + { + "method": "textDocument/willSave", + "typeName": "WillSaveTextDocumentNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "WillSaveTextDocumentParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + "documentation": "A document will save notification is sent from the client to the server before\nthe document is actually saved." + }, + { + "method": "workspace/didChangeWatchedFiles", + "typeName": "DidChangeWatchedFilesNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "DidChangeWatchedFilesParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "DidChangeWatchedFilesRegistrationOptions" + }, + "documentation": "The watched files notification is sent from the client to the server when\nthe client detects changes to file watched by the language client." + }, + { + "method": "textDocument/publishDiagnostics", + "typeName": "PublishDiagnosticsNotification", + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "PublishDiagnosticsParams" + }, + "documentation": "Diagnostics notification are sent from the server to the client to signal\nresults of validation runs." + }, + { + "method": "$/setTrace", + "typeName": "SetTraceNotification", + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "SetTraceParams" + } + }, + { + "method": "$/logTrace", + "typeName": "LogTraceNotification", + "messageDirection": "serverToClient", + "params": { + "kind": "reference", + "name": "LogTraceParams" + } + }, + { + "method": "$/cancelRequest", + "typeName": "CancelNotification", + "messageDirection": "both", + "params": { + "kind": "reference", + "name": "CancelParams" + } + }, + { + "method": "$/progress", + "typeName": "ProgressNotification", + "messageDirection": "both", + "params": { + "kind": "reference", + "name": "ProgressParams" + } + } + ], + "structures": [ + { + "name": "ImplementationParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ] + }, + { + "name": "Location", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + } + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + } + } + ], + "documentation": "Represents a location inside a resource, such as a line\ninside a text file." + }, + { + "name": "ImplementationRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "ImplementationOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ] + }, + { + "name": "TypeDefinitionParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ] + }, + { + "name": "TypeDefinitionRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "TypeDefinitionOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ] + }, + { + "name": "WorkspaceFolder", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "URI" + }, + "documentation": "The associated URI for this workspace folder." + }, + { + "name": "name", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The name of the workspace folder. Used to refer to this\nworkspace folder in the user interface." + } + ], + "documentation": "A workspace folder inside a client." + }, + { + "name": "DidChangeWorkspaceFoldersParams", + "properties": [ + { + "name": "event", + "type": { + "kind": "reference", + "name": "WorkspaceFoldersChangeEvent" + }, + "documentation": "The actual workspace folder change event." + } + ], + "documentation": "The parameters of a `workspace/didChangeWorkspaceFolders` notification." + }, + { + "name": "ConfigurationParams", + "properties": [ + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "ConfigurationItem" + } + } + } + ], + "documentation": "The parameters of a configuration request." + }, + { + "name": "DocumentColorParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Parameters for a {@link DocumentColorRequest}." + }, + { + "name": "ColorInformation", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range in the document where this color appears." + }, + { + "name": "color", + "type": { + "kind": "reference", + "name": "Color" + }, + "documentation": "The actual color value for this color range." + } + ], + "documentation": "Represents a color range from a document." + }, + { + "name": "DocumentColorRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "DocumentColorOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ] + }, + { + "name": "ColorPresentationParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + }, + { + "name": "color", + "type": { + "kind": "reference", + "name": "Color" + }, + "documentation": "The color to request presentations for." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range where the color would be inserted. Serves as a context." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Parameters for a {@link ColorPresentationRequest}." + }, + { + "name": "ColorPresentation", + "properties": [ + { + "name": "label", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The label of this color presentation. It will be shown on the color\npicker header. By default this is also the text that is inserted when selecting\nthis color presentation." + }, + { + "name": "textEdit", + "type": { + "kind": "reference", + "name": "TextEdit" + }, + "optional": true, + "documentation": "An {@link TextEdit edit} which is applied to a document when selecting\nthis presentation for the color. When `falsy` the {@link ColorPresentation.label label}\nis used." + }, + { + "name": "additionalTextEdits", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextEdit" + } + }, + "optional": true, + "documentation": "An optional array of additional {@link TextEdit text edits} that are applied when\nselecting this color presentation. Edits must not overlap with the main {@link ColorPresentation.textEdit edit} nor with themselves." + } + ] + }, + { + "name": "WorkDoneProgressOptions", + "properties": [ + { + "name": "workDoneProgress", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true + } + ] + }, + { + "name": "TextDocumentRegistrationOptions", + "properties": [ + { + "name": "documentSelector", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "DocumentSelector" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "documentation": "A document selector to identify the scope of the registration. If set to null\nthe document selector provided on the client side will be used." + } + ], + "documentation": "General text document registration options." + }, + { + "name": "FoldingRangeParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Parameters for a {@link FoldingRangeRequest}." + }, + { + "name": "FoldingRange", + "properties": [ + { + "name": "startLine", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "The zero-based start line of the range to fold. The folded area starts after the line's last character.\nTo be valid, the end must be zero or larger and smaller than the number of lines in the document." + }, + { + "name": "startCharacter", + "type": { + "kind": "base", + "name": "uinteger" + }, + "optional": true, + "documentation": "The zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line." + }, + { + "name": "endLine", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "The zero-based end line of the range to fold. The folded area ends with the line's last character.\nTo be valid, the end must be zero or larger and smaller than the number of lines in the document." + }, + { + "name": "endCharacter", + "type": { + "kind": "base", + "name": "uinteger" + }, + "optional": true, + "documentation": "The zero-based character offset before the folded range ends. If not defined, defaults to the length of the end line." + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "FoldingRangeKind" + }, + "optional": true, + "documentation": "Describes the kind of the folding range such as 'comment' or 'region'. The kind\nis used to categorize folding ranges and used by commands like 'Fold all comments'.\nSee {@link FoldingRangeKind} for an enumeration of standardized kinds." + }, + { + "name": "collapsedText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The text that the client should show when the specified range is\ncollapsed. If not defined or not supported by the client, a default\nwill be chosen by the client.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "Represents a folding range. To be valid, start and end line must be bigger than zero and smaller\nthan the number of lines in the document. Clients are free to ignore invalid ranges." + }, + { + "name": "FoldingRangeRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "FoldingRangeOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ] + }, + { + "name": "DeclarationParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ] + }, + { + "name": "DeclarationRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "DeclarationOptions" + }, + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ] + }, + { + "name": "SelectionRangeParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + }, + { + "name": "positions", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Position" + } + }, + "documentation": "The positions inside the text document." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "A parameter literal used in selection range requests." + }, + { + "name": "SelectionRange", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The {@link Range range} of this selection range." + }, + { + "name": "parent", + "type": { + "kind": "reference", + "name": "SelectionRange" + }, + "optional": true, + "documentation": "The parent selection range containing this range. Therefore `parent.range` must contain `this.range`." + } + ], + "documentation": "A selection range represents a part of a selection hierarchy. A selection range\nmay have a parent selection range that contains it." + }, + { + "name": "SelectionRangeRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "SelectionRangeOptions" + }, + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ] + }, + { + "name": "WorkDoneProgressCreateParams", + "properties": [ + { + "name": "token", + "type": { + "kind": "reference", + "name": "ProgressToken" + }, + "documentation": "The token to be used to report progress." + } + ] + }, + { + "name": "WorkDoneProgressCancelParams", + "properties": [ + { + "name": "token", + "type": { + "kind": "reference", + "name": "ProgressToken" + }, + "documentation": "The token to be used to report progress." + } + ] + }, + { + "name": "CallHierarchyPrepareParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "The parameter of a `textDocument/prepareCallHierarchy` request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "CallHierarchyItem", + "properties": [ + { + "name": "name", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The name of this item." + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "SymbolKind" + }, + "documentation": "The kind of this item." + }, + { + "name": "tags", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolTag" + } + }, + "optional": true, + "documentation": "Tags for this item." + }, + { + "name": "detail", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "More detail for this item, e.g. the signature of a function." + }, + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The resource identifier of this item." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code." + }, + { + "name": "selectionRange", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range that should be selected and revealed when this symbol is being picked, e.g. the name of a function.\nMust be contained by the {@link CallHierarchyItem.range `range`}." + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A data entry field that is preserved between a call hierarchy prepare and\nincoming calls or outgoing calls requests." + } + ], + "documentation": "Represents programming constructs like functions or constructors in the context\nof call hierarchy.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "CallHierarchyRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "CallHierarchyOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Call hierarchy options used during static or dynamic registration.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "CallHierarchyIncomingCallsParams", + "properties": [ + { + "name": "item", + "type": { + "kind": "reference", + "name": "CallHierarchyItem" + } + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "The parameter of a `callHierarchy/incomingCalls` request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "CallHierarchyIncomingCall", + "properties": [ + { + "name": "from", + "type": { + "kind": "reference", + "name": "CallHierarchyItem" + }, + "documentation": "The item that makes the call." + }, + { + "name": "fromRanges", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Range" + } + }, + "documentation": "The ranges at which the calls appear. This is relative to the caller\ndenoted by {@link CallHierarchyIncomingCall.from `this.from`}." + } + ], + "documentation": "Represents an incoming call, e.g. a caller of a method or constructor.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "CallHierarchyOutgoingCallsParams", + "properties": [ + { + "name": "item", + "type": { + "kind": "reference", + "name": "CallHierarchyItem" + } + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "The parameter of a `callHierarchy/outgoingCalls` request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "CallHierarchyOutgoingCall", + "properties": [ + { + "name": "to", + "type": { + "kind": "reference", + "name": "CallHierarchyItem" + }, + "documentation": "The item that is called." + }, + { + "name": "fromRanges", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Range" + } + }, + "documentation": "The range at which this item is called. This is the range relative to the caller, e.g the item\npassed to {@link CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls `provideCallHierarchyOutgoingCalls`}\nand not {@link CallHierarchyOutgoingCall.to `this.to`}." + } + ], + "documentation": "Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokens", + "properties": [ + { + "name": "resultId", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "An optional result id. If provided and clients support delta updating\nthe client will include the result id in the next semantic token request.\nA server can then instead of computing all semantic tokens again simply\nsend a delta." + }, + { + "name": "data", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "uinteger" + } + }, + "documentation": "The actual tokens." + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensPartialResult", + "properties": [ + { + "name": "data", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "uinteger" + } + } + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "SemanticTokensOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensDeltaParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + }, + { + "name": "previousResultId", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The result id of a previous response. The result Id can either point to a full response\nor a delta response depending on what was received last." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensDelta", + "properties": [ + { + "name": "resultId", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true + }, + { + "name": "edits", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SemanticTokensEdit" + } + }, + "documentation": "The semantic token edits to transform a previous result into a new result." + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensDeltaPartialResult", + "properties": [ + { + "name": "edits", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SemanticTokensEdit" + } + } + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensRangeParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range the semantic tokens are requested for." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "ShowDocumentParams", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "URI" + }, + "documentation": "The uri to show." + }, + { + "name": "external", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Indicates to show the resource in an external program.\nTo show, for example, `https://code.visualstudio.com/`\nin the default WEB browser set `external` to `true`." + }, + { + "name": "takeFocus", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "An optional property to indicate whether the editor\nshowing the document should take focus or not.\nClients might ignore this property if an external\nprogram is started." + }, + { + "name": "selection", + "type": { + "kind": "reference", + "name": "Range" + }, + "optional": true, + "documentation": "An optional selection range if the document is a text\ndocument. Clients might ignore the property if an\nexternal program is started or the file is not a text\nfile." + } + ], + "documentation": "Params to show a resource in the UI.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "ShowDocumentResult", + "properties": [ + { + "name": "success", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "A boolean indicating if the show was successful." + } + ], + "documentation": "The result of a showDocument request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "LinkedEditingRangeParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ] + }, + { + "name": "LinkedEditingRanges", + "properties": [ + { + "name": "ranges", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Range" + } + }, + "documentation": "A list of ranges that can be edited together. The ranges must have\nidentical length and contain identical text content. The ranges cannot overlap." + }, + { + "name": "wordPattern", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "An optional word pattern (regular expression) that describes valid contents for\nthe given ranges. If no pattern is provided, the client configuration's word\npattern will be used." + } + ], + "documentation": "The result of a linked editing range request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "LinkedEditingRangeRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "LinkedEditingRangeOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ] + }, + { + "name": "CreateFilesParams", + "properties": [ + { + "name": "files", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "FileCreate" + } + }, + "documentation": "An array of all files/folders created in this operation." + } + ], + "documentation": "The parameters sent in notifications/requests for user-initiated creation of\nfiles.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "WorkspaceEdit", + "properties": [ + { + "name": "changes", + "type": { + "kind": "map", + "key": { + "kind": "base", + "name": "DocumentUri" + }, + "value": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextEdit" + } + } + }, + "optional": true, + "documentation": "Holds changes to existing resources." + }, + { + "name": "documentChanges", + "type": { + "kind": "array", + "element": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "TextDocumentEdit" + }, + { + "kind": "reference", + "name": "CreateFile" + }, + { + "kind": "reference", + "name": "RenameFile" + }, + { + "kind": "reference", + "name": "DeleteFile" + } + ] + } + }, + "optional": true, + "documentation": "Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes\nare either an array of `TextDocumentEdit`s to express changes to n different text documents\nwhere each text document edit addresses a specific version of a text document. Or it can contain\nabove `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.\n\nWhether a client supports versioned document edits is expressed via\n`workspace.workspaceEdit.documentChanges` client capability.\n\nIf a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then\nonly plain `TextEdit`s using the `changes` property are supported." + }, + { + "name": "changeAnnotations", + "type": { + "kind": "map", + "key": { + "kind": "reference", + "name": "ChangeAnnotationIdentifier" + }, + "value": { + "kind": "reference", + "name": "ChangeAnnotation" + } + }, + "optional": true, + "documentation": "A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and\ndelete file / folder operations.\n\nWhether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.\n\n@since 3.16.0", + "since": "3.16.0" + } + ], + "documentation": "A workspace edit represents changes to many resources managed in the workspace. The edit\nshould either provide `changes` or `documentChanges`. If documentChanges are present\nthey are preferred over `changes` if the client can handle versioned document edits.\n\nSince version 3.13.0 a workspace edit can contain resource operations as well. If resource\noperations are present clients need to execute the operations in the order in which they\nare provided. So a workspace edit for example can consist of the following two changes:\n(1) a create file a.txt and (2) a text document edit which insert text into file a.txt.\n\nAn invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will\ncause failure of the operation. How the client recovers from the failure is described by\nthe client capability: `workspace.workspaceEdit.failureHandling`" + }, + { + "name": "FileOperationRegistrationOptions", + "properties": [ + { + "name": "filters", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "FileOperationFilter" + } + }, + "documentation": "The actual filters." + } + ], + "documentation": "The options to register for file operations.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "RenameFilesParams", + "properties": [ + { + "name": "files", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "FileRename" + } + }, + "documentation": "An array of all files/folders renamed in this operation. When a folder is renamed, only\nthe folder will be included, and not its children." + } + ], + "documentation": "The parameters sent in notifications/requests for user-initiated renames of\nfiles.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "DeleteFilesParams", + "properties": [ + { + "name": "files", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "FileDelete" + } + }, + "documentation": "An array of all files/folders deleted in this operation." + } + ], + "documentation": "The parameters sent in notifications/requests for user-initiated deletes of\nfiles.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "MonikerParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ] + }, + { + "name": "Moniker", + "properties": [ + { + "name": "scheme", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The scheme of the moniker. For example tsc or .Net" + }, + { + "name": "identifier", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The identifier of the moniker. The value is opaque in LSIF however\nschema owners are allowed to define the structure if they want." + }, + { + "name": "unique", + "type": { + "kind": "reference", + "name": "UniquenessLevel" + }, + "documentation": "The scope in which the moniker is unique" + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "MonikerKind" + }, + "optional": true, + "documentation": "The moniker kind if known." + } + ], + "documentation": "Moniker definition to match LSIF 0.5 moniker definition.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "MonikerRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "MonikerOptions" + } + ] + }, + { + "name": "TypeHierarchyPrepareParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "The parameter of a `textDocument/prepareTypeHierarchy` request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "TypeHierarchyItem", + "properties": [ + { + "name": "name", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The name of this item." + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "SymbolKind" + }, + "documentation": "The kind of this item." + }, + { + "name": "tags", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolTag" + } + }, + "optional": true, + "documentation": "Tags for this item." + }, + { + "name": "detail", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "More detail for this item, e.g. the signature of a function." + }, + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The resource identifier of this item." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range enclosing this symbol not including leading/trailing whitespace\nbut everything else, e.g. comments and code." + }, + { + "name": "selectionRange", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range that should be selected and revealed when this symbol is being\npicked, e.g. the name of a function. Must be contained by the\n{@link TypeHierarchyItem.range `range`}." + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A data entry field that is preserved between a type hierarchy prepare and\nsupertypes or subtypes requests. It could also be used to identify the\ntype hierarchy in the server, helping improve the performance on\nresolving supertypes and subtypes." + } + ], + "documentation": "@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "TypeHierarchyRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "TypeHierarchyOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Type hierarchy options used during static or dynamic registration.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "TypeHierarchySupertypesParams", + "properties": [ + { + "name": "item", + "type": { + "kind": "reference", + "name": "TypeHierarchyItem" + } + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "The parameter of a `typeHierarchy/supertypes` request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "TypeHierarchySubtypesParams", + "properties": [ + { + "name": "item", + "type": { + "kind": "reference", + "name": "TypeHierarchyItem" + } + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "The parameter of a `typeHierarchy/subtypes` request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineValueParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The document range for which inline values should be computed." + }, + { + "name": "context", + "type": { + "kind": "reference", + "name": "InlineValueContext" + }, + "documentation": "Additional information about the context in which inline values were\nrequested." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "A parameter literal used in inline value requests.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineValueRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "InlineValueOptions" + }, + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Inline value options used during static or dynamic registration.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlayHintParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The document range for which inlay hints should be computed." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "A parameter literal used in inlay hint requests.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlayHint", + "properties": [ + { + "name": "position", + "type": { + "kind": "reference", + "name": "Position" + }, + "documentation": "The position of this hint.\n\nIf multiple hints have the same position, they will be shown in the order\nthey appear in the response." + }, + { + "name": "label", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlayHintLabelPart" + } + } + ] + }, + "documentation": "The label of this hint. A human readable string or an array of\nInlayHintLabelPart label parts.\n\n*Note* that neither the string nor the label part can be empty." + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "InlayHintKind" + }, + "optional": true, + "documentation": "The kind of this hint. Can be omitted in which case the client\nshould fall back to a reasonable default." + }, + { + "name": "textEdits", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextEdit" + } + }, + "optional": true, + "documentation": "Optional text edits that are performed when accepting this inlay hint.\n\n*Note* that edits are expected to change the document so that the inlay\nhint (or its nearest variant) is now part of the document and the inlay\nhint itself is now obsolete." + }, + { + "name": "tooltip", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "MarkupContent" + } + ] + }, + "optional": true, + "documentation": "The tooltip text when you hover over this item." + }, + { + "name": "paddingLeft", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Render padding before the hint.\n\nNote: Padding should use the editor's background color, not the\nbackground color of the hint itself. That means padding can be used\nto visually align/separate an inlay hint." + }, + { + "name": "paddingRight", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Render padding after the hint.\n\nNote: Padding should use the editor's background color, not the\nbackground color of the hint itself. That means padding can be used\nto visually align/separate an inlay hint." + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A data entry field that is preserved on an inlay hint between\na `textDocument/inlayHint` and a `inlayHint/resolve` request." + } + ], + "documentation": "Inlay hint information.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlayHintRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "InlayHintOptions" + }, + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Inlay hint options used during static or dynamic registration.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DocumentDiagnosticParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + }, + { + "name": "identifier", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The additional identifier provided during registration." + }, + { + "name": "previousResultId", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The result id of a previous response if provided." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Parameters of the document diagnostic request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DocumentDiagnosticReportPartialResult", + "properties": [ + { + "name": "relatedDocuments", + "type": { + "kind": "map", + "key": { + "kind": "base", + "name": "DocumentUri" + }, + "value": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "FullDocumentDiagnosticReport" + }, + { + "kind": "reference", + "name": "UnchangedDocumentDiagnosticReport" + } + ] + } + } + } + ], + "documentation": "A partial result for a document diagnostic report.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DiagnosticServerCancellationData", + "properties": [ + { + "name": "retriggerRequest", + "type": { + "kind": "base", + "name": "boolean" + } + } + ], + "documentation": "Cancellation data returned from a diagnostic request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DiagnosticRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "DiagnosticOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Diagnostic registration options.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "WorkspaceDiagnosticParams", + "properties": [ + { + "name": "identifier", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The additional identifier provided during registration." + }, + { + "name": "previousResultIds", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "PreviousResultId" + } + }, + "documentation": "The currently known diagnostic reports with their\nprevious result ids." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Parameters of the workspace diagnostic request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "WorkspaceDiagnosticReport", + "properties": [ + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "WorkspaceDocumentDiagnosticReport" + } + } + } + ], + "documentation": "A workspace diagnostic report.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "WorkspaceDiagnosticReportPartialResult", + "properties": [ + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "WorkspaceDocumentDiagnosticReport" + } + } + } + ], + "documentation": "A partial result for a workspace diagnostic report.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DidOpenNotebookDocumentParams", + "properties": [ + { + "name": "notebookDocument", + "type": { + "kind": "reference", + "name": "NotebookDocument" + }, + "documentation": "The notebook document that got opened." + }, + { + "name": "cellTextDocuments", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextDocumentItem" + } + }, + "documentation": "The text documents that represent the content\nof a notebook cell." + } + ], + "documentation": "The params sent in an open notebook document notification.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "NotebookDocumentSyncRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "NotebookDocumentSyncOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Registration options specific to a notebook.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DidChangeNotebookDocumentParams", + "properties": [ + { + "name": "notebookDocument", + "type": { + "kind": "reference", + "name": "VersionedNotebookDocumentIdentifier" + }, + "documentation": "The notebook document that did change. The version number points\nto the version after all provided changes have been applied. If\nonly the text document content of a cell changes the notebook version\ndoesn't necessarily have to change." + }, + { + "name": "change", + "type": { + "kind": "reference", + "name": "NotebookDocumentChangeEvent" + }, + "documentation": "The actual changes to the notebook document.\n\nThe changes describe single state changes to the notebook document.\nSo if there are two changes c1 (at array index 0) and c2 (at array\nindex 1) for a notebook in state S then c1 moves the notebook from\nS to S' and c2 from S' to S''. So c1 is computed on the state S and\nc2 is computed on the state S'.\n\nTo mirror the content of a notebook using change events use the following approach:\n- start with the same initial content\n- apply the 'notebookDocument/didChange' notifications in the order you receive them.\n- apply the `NotebookChangeEvent`s in a single notification in the order\n you receive them." + } + ], + "documentation": "The params sent in a change notebook document notification.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DidSaveNotebookDocumentParams", + "properties": [ + { + "name": "notebookDocument", + "type": { + "kind": "reference", + "name": "NotebookDocumentIdentifier" + }, + "documentation": "The notebook document that got saved." + } + ], + "documentation": "The params sent in a save notebook document notification.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DidCloseNotebookDocumentParams", + "properties": [ + { + "name": "notebookDocument", + "type": { + "kind": "reference", + "name": "NotebookDocumentIdentifier" + }, + "documentation": "The notebook document that got closed." + }, + { + "name": "cellTextDocuments", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextDocumentIdentifier" + } + }, + "documentation": "The text documents that represent the content\nof a notebook cell that got closed." + } + ], + "documentation": "The params sent in a close notebook document notification.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineCompletionParams", + "properties": [ + { + "name": "context", + "type": { + "kind": "reference", + "name": "InlineCompletionContext" + }, + "documentation": "Additional information about the context in which inline completions were\nrequested." + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "A parameter literal used in inline completion requests.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "InlineCompletionList", + "properties": [ + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + "documentation": "The inline completion items" + } + ], + "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "InlineCompletionItem", + "properties": [ + { + "name": "insertText", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "StringValue" + } + ] + }, + "documentation": "The text to replace the range with. Must be set." + }, + { + "name": "filterText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "optional": true, + "documentation": "The range to replace. Must begin and end on the same line." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "optional": true, + "documentation": "An optional {@link Command} that is executed *after* inserting this completion." + } + ], + "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "InlineCompletionRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "InlineCompletionOptions" + }, + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Inline completion options used during static or dynamic registration.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "TextDocumentContentParams", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The uri of the text document." + } + ], + "documentation": "Parameters for the `workspace/textDocumentContent` request.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "TextDocumentContentResult", + "properties": [ + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text content of the text document. Please note, that the content of\nany subsequent open notifications for the text document might differ\nfrom the returned content due to whitespace and line ending\nnormalizations done on the client" + } + ], + "documentation": "Result of the `workspace/textDocumentContent` request.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "TextDocumentContentRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentContentOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Text document content provider registration options.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "TextDocumentContentRefreshParams", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The uri of the text document to refresh." + } + ], + "documentation": "Parameters for the `workspace/textDocumentContent/refresh` request.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "RegistrationParams", + "properties": [ + { + "name": "registrations", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Registration" + } + } + } + ] + }, + { + "name": "UnregistrationParams", + "properties": [ + { + "name": "unregisterations", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Unregistration" + } + } + } + ] + }, + { + "name": "InitializeParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "_InitializeParams" + }, + { + "kind": "reference", + "name": "WorkspaceFoldersInitializeParams" + } + ] + }, + { + "name": "InitializeResult", + "properties": [ + { + "name": "capabilities", + "type": { + "kind": "reference", + "name": "ServerCapabilities" + }, + "documentation": "The capabilities the language server provides." + }, + { + "name": "serverInfo", + "type": { + "kind": "reference", + "name": "ServerInfo" + }, + "optional": true, + "documentation": "Information about the server.\n\n@since 3.15.0", + "since": "3.15.0" + } + ], + "documentation": "The result returned from an initialize request." + }, + { + "name": "InitializeError", + "properties": [ + { + "name": "retry", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "Indicates whether the client execute the following retry logic:\n(1) show the message provided by the ResponseError to the user\n(2) user selects retry or cancel\n(3) if user selected retry the initialize method is sent again." + } + ], + "documentation": "The data type of the ResponseError if the\ninitialize request fails." + }, + { + "name": "InitializedParams", + "properties": [] + }, + { + "name": "DidChangeConfigurationParams", + "properties": [ + { + "name": "settings", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "documentation": "The actual changed settings" + } + ], + "documentation": "The parameters of a change configuration notification." + }, + { + "name": "DidChangeConfigurationRegistrationOptions", + "properties": [ + { + "name": "section", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + } + ] + }, + "optional": true + } + ] + }, + { + "name": "ShowMessageParams", + "properties": [ + { + "name": "type", + "type": { + "kind": "reference", + "name": "MessageType" + }, + "documentation": "The message type. See {@link MessageType}" + }, + { + "name": "message", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The actual message." + } + ], + "documentation": "The parameters of a notification message." + }, + { + "name": "ShowMessageRequestParams", + "properties": [ + { + "name": "type", + "type": { + "kind": "reference", + "name": "MessageType" + }, + "documentation": "The message type. See {@link MessageType}" + }, + { + "name": "message", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The actual message." + }, + { + "name": "actions", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "MessageActionItem" + } + }, + "optional": true, + "documentation": "The message action items to present." + } + ] + }, + { + "name": "MessageActionItem", + "properties": [ + { + "name": "title", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A short title like 'Retry', 'Open Log' etc." + } + ] + }, + { + "name": "LogMessageParams", + "properties": [ + { + "name": "type", + "type": { + "kind": "reference", + "name": "MessageType" + }, + "documentation": "The message type. See {@link MessageType}" + }, + { + "name": "message", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The actual message." + } + ], + "documentation": "The log message parameters." + }, + { + "name": "DidOpenTextDocumentParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentItem" + }, + "documentation": "The document that was opened." + } + ], + "documentation": "The parameters sent in an open text document notification" + }, + { + "name": "DidChangeTextDocumentParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "VersionedTextDocumentIdentifier" + }, + "documentation": "The document that did change. The version number points\nto the version after all provided content changes have\nbeen applied." + }, + { + "name": "contentChanges", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextDocumentContentChangeEvent" + } + }, + "documentation": "The actual content changes. The content changes describe single state changes\nto the document. So if there are two content changes c1 (at array index 0) and\nc2 (at array index 1) for a document in state S then c1 moves the document from\nS to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed\non the state S'.\n\nTo mirror the content of a document using change events use the following approach:\n- start with the same initial content\n- apply the 'textDocument/didChange' notifications in the order you receive them.\n- apply the `TextDocumentContentChangeEvent`s in a single notification in the order\n you receive them." + } + ], + "documentation": "The change text document notification's parameters." + }, + { + "name": "TextDocumentChangeRegistrationOptions", + "properties": [ + { + "name": "syncKind", + "type": { + "kind": "reference", + "name": "TextDocumentSyncKind" + }, + "documentation": "How documents are synced to the server." + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + } + ], + "documentation": "Describe options to be used when registered for text document change events." + }, + { + "name": "DidCloseTextDocumentParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document that was closed." + } + ], + "documentation": "The parameters sent in a close text document notification" + }, + { + "name": "DidSaveTextDocumentParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document that was saved." + }, + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "Optional the content when saved. Depends on the includeText value\nwhen the save notification was requested." + } + ], + "documentation": "The parameters sent in a save text document notification" + }, + { + "name": "TextDocumentSaveRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "SaveOptions" + } + ], + "documentation": "Save registration options." + }, + { + "name": "WillSaveTextDocumentParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document that will be saved." + }, + { + "name": "reason", + "type": { + "kind": "reference", + "name": "TextDocumentSaveReason" + }, + "documentation": "The 'TextDocumentSaveReason'." + } + ], + "documentation": "The parameters sent in a will save text document notification." + }, + { + "name": "TextEdit", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range of the text document to be manipulated. To insert\ntext into a document create a range where start === end." + }, + { + "name": "newText", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The string to be inserted. For delete operations use an\nempty string." + } + ], + "documentation": "A text edit applicable to a text document." + }, + { + "name": "DidChangeWatchedFilesParams", + "properties": [ + { + "name": "changes", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "FileEvent" + } + }, + "documentation": "The actual file events." + } + ], + "documentation": "The watched files change notification's parameters." + }, + { + "name": "DidChangeWatchedFilesRegistrationOptions", + "properties": [ + { + "name": "watchers", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "FileSystemWatcher" + } + }, + "documentation": "The watchers to register." + } + ], + "documentation": "Describe options to be used when registered for text document change events." + }, + { + "name": "PublishDiagnosticsParams", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The URI for which diagnostic information is reported." + }, + { + "name": "version", + "type": { + "kind": "base", + "name": "integer" + }, + "optional": true, + "documentation": "Optional the version number of the document the diagnostics are published for.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "diagnostics", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Diagnostic" + } + }, + "documentation": "An array of diagnostic information items." + } + ], + "documentation": "The publish diagnostic notification's parameters." + }, + { + "name": "CompletionParams", + "properties": [ + { + "name": "context", + "type": { + "kind": "reference", + "name": "CompletionContext" + }, + "optional": true, + "documentation": "The completion context. This is only available it the client specifies\nto send this using the client capability `textDocument.completion.contextSupport === true`" + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Completion parameters" + }, + { + "name": "CompletionItem", + "properties": [ + { + "name": "label", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The label of this completion item.\n\nThe label property is also by default the text that\nis inserted when selecting this completion.\n\nIf label details are provided the label itself should\nbe an unqualified name of the completion item." + }, + { + "name": "labelDetails", + "type": { + "kind": "reference", + "name": "CompletionItemLabelDetails" + }, + "optional": true, + "documentation": "Additional details for the label\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "CompletionItemKind" + }, + "optional": true, + "documentation": "The kind of this completion item. Based of the kind\nan icon is chosen by the editor." + }, + { + "name": "tags", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CompletionItemTag" + } + }, + "optional": true, + "documentation": "Tags for this completion item.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "detail", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A human-readable string with additional information\nabout this item, like type or symbol information." + }, + { + "name": "documentation", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "MarkupContent" + } + ] + }, + "optional": true, + "documentation": "A human-readable string that represents a doc-comment." + }, + { + "name": "deprecated", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Indicates if this item is deprecated.\n@deprecated Use `tags` instead.", + "deprecated": "Use `tags` instead." + }, + { + "name": "preselect", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Select this item when showing.\n\n*Note* that only one completion item can be selected and that the\ntool / client decides which item that is. The rule is that the *first*\nitem of those that match best is selected." + }, + { + "name": "sortText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A string that should be used when comparing this item\nwith other items. When `falsy` the {@link CompletionItem.label label}\nis used." + }, + { + "name": "filterText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A string that should be used when filtering a set of\ncompletion items. When `falsy` the {@link CompletionItem.label label}\nis used." + }, + { + "name": "insertText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A string that should be inserted into a document when selecting\nthis completion. When `falsy` the {@link CompletionItem.label label}\nis used.\n\nThe `insertText` is subject to interpretation by the client side.\nSome tools might not take the string literally. For example\nVS Code when code complete is requested in this example\n`con` and a completion item with an `insertText` of\n`console` is provided it will only insert `sole`. Therefore it is\nrecommended to use `textEdit` instead since it avoids additional client\nside interpretation." + }, + { + "name": "insertTextFormat", + "type": { + "kind": "reference", + "name": "InsertTextFormat" + }, + "optional": true, + "documentation": "The format of the insert text. The format applies to both the\n`insertText` property and the `newText` property of a provided\n`textEdit`. If omitted defaults to `InsertTextFormat.PlainText`.\n\nPlease note that the insertTextFormat doesn't apply to\n`additionalTextEdits`." + }, + { + "name": "insertTextMode", + "type": { + "kind": "reference", + "name": "InsertTextMode" + }, + "optional": true, + "documentation": "How whitespace and indentation is handled during completion\nitem insertion. If not provided the clients default value depends on\nthe `textDocument.completion.insertTextMode` client capability.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "textEdit", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "TextEdit" + }, + { + "kind": "reference", + "name": "InsertReplaceEdit" + } + ] + }, + "optional": true, + "documentation": "An {@link TextEdit edit} which is applied to a document when selecting\nthis completion. When an edit is provided the value of\n{@link CompletionItem.insertText insertText} is ignored.\n\nMost editors support two different operations when accepting a completion\nitem. One is to insert a completion text and the other is to replace an\nexisting text with a completion text. Since this can usually not be\npredetermined by a server it can report both ranges. Clients need to\nsignal support for `InsertReplaceEdits` via the\n`textDocument.completion.insertReplaceSupport` client capability\nproperty.\n\n*Note 1:* The text edit's range as well as both ranges from an insert\nreplace edit must be a [single line] and they must contain the position\nat which completion has been requested.\n*Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range\nmust be a prefix of the edit's replace range, that means it must be\ncontained and starting at the same position.\n\n@since 3.16.0 additional type `InsertReplaceEdit`", + "since": "3.16.0 additional type `InsertReplaceEdit`" + }, + { + "name": "textEditText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The edit text used if the completion item is part of a CompletionList and\nCompletionList defines an item default for the text edit range.\n\nClients will only honor this property if they opt into completion list\nitem defaults using the capability `completionList.itemDefaults`.\n\nIf not provided and a list's default range is provided the label\nproperty is used as a text.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "additionalTextEdits", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextEdit" + } + }, + "optional": true, + "documentation": "An optional array of additional {@link TextEdit text edits} that are applied when\nselecting this completion. Edits must not overlap (including the same insert position)\nwith the main {@link CompletionItem.textEdit edit} nor with themselves.\n\nAdditional text edits should be used to change text unrelated to the current cursor position\n(for example adding an import statement at the top of the file if the completion item will\ninsert an unqualified type)." + }, + { + "name": "commitCharacters", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "optional": true, + "documentation": "An optional set of characters that when pressed while this completion is active will accept it first and\nthen type that character. *Note* that all commit characters should have `length=1` and that superfluous\ncharacters will be ignored." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "optional": true, + "documentation": "An optional {@link Command command} that is executed *after* inserting this completion. *Note* that\nadditional modifications to the current document should be described with the\n{@link CompletionItem.additionalTextEdits additionalTextEdits}-property." + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A data entry field that is preserved on a completion item between a\n{@link CompletionRequest} and a {@link CompletionResolveRequest}." + } + ], + "documentation": "A completion item represents a text snippet that is\nproposed to complete text that is being typed." + }, + { + "name": "CompletionList", + "properties": [ + { + "name": "isIncomplete", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "This list it not complete. Further typing results in recomputing this list.\n\nRecomputed lists have all their items replaced (not appended) in the\nincomplete completion sessions." + }, + { + "name": "itemDefaults", + "type": { + "kind": "reference", + "name": "CompletionItemDefaults" + }, + "optional": true, + "documentation": "In many cases the items of an actual completion result share the same\nvalue for properties like `commitCharacters` or the range of a text\nedit. A completion list can therefore define item defaults which will\nbe used if a completion item itself doesn't specify the value.\n\nIf a completion list specifies a default value and a completion item\nalso specifies a corresponding value, the rules for combining these are\ndefined by `applyKinds` (if the client supports it), defaulting to\n\"replace\".\n\nServers are only allowed to return default values if the client\nsignals support for this via the `completionList.itemDefaults`\ncapability.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "applyKind", + "type": { + "kind": "reference", + "name": "CompletionItemApplyKinds" + }, + "optional": true, + "documentation": "Specifies how fields from a completion item should be combined with those\nfrom `completionList.itemDefaults`.\n\nIf unspecified, all fields will be treated as \"replace\".\n\nIf a field's value is \"replace\", the value from a completion item (if\nprovided and not `null`) will always be used instead of the value from\n`completionItem.itemDefaults`.\n\nIf a field's value is \"merge\", the values will be merged using the rules\ndefined against each field below.\n\nServers are only allowed to return `applyKind` if the client\nsignals support for this via the `completionList.applyKindSupport`\ncapability.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CompletionItem" + } + }, + "documentation": "The completion items." + } + ], + "documentation": "Represents a collection of {@link CompletionItem completion items} to be presented\nin the editor." + }, + { + "name": "CompletionRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "CompletionOptions" + } + ], + "documentation": "Registration options for a {@link CompletionRequest}." + }, + { + "name": "HoverParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "Parameters for a {@link HoverRequest}." + }, + { + "name": "Hover", + "properties": [ + { + "name": "contents", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "MarkupContent" + }, + { + "kind": "reference", + "name": "MarkedString" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "MarkedString" + } + } + ] + }, + "documentation": "The hover's content" + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "optional": true, + "documentation": "An optional range inside the text document that is used to\nvisualize the hover, e.g. by changing the background color." + } + ], + "documentation": "The result of a hover request." + }, + { + "name": "HoverRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "HoverOptions" + } + ], + "documentation": "Registration options for a {@link HoverRequest}." + }, + { + "name": "SignatureHelpParams", + "properties": [ + { + "name": "context", + "type": { + "kind": "reference", + "name": "SignatureHelpContext" + }, + "optional": true, + "documentation": "The signature help context. This is only available if the client specifies\nto send this using the client capability `textDocument.signatureHelp.contextSupport === true`\n\n@since 3.15.0", + "since": "3.15.0" + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "Parameters for a {@link SignatureHelpRequest}." + }, + { + "name": "SignatureHelp", + "properties": [ + { + "name": "signatures", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SignatureInformation" + } + }, + "documentation": "One or more signatures." + }, + { + "name": "activeSignature", + "type": { + "kind": "base", + "name": "uinteger" + }, + "optional": true, + "documentation": "The active signature. If omitted or the value lies outside the\nrange of `signatures` the value defaults to zero or is ignored if\nthe `SignatureHelp` has no signatures.\n\nWhenever possible implementors should make an active decision about\nthe active signature and shouldn't rely on a default value.\n\nIn future version of the protocol this property might become\nmandatory to better express this." + }, + { + "name": "activeParameter", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "uinteger" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "optional": true, + "documentation": "The active parameter of the active signature.\n\nIf `null`, no parameter of the signature is active (for example a named\nargument that does not match any declared parameters). This is only valid\nif the client specifies the client capability\n`textDocument.signatureHelp.noActiveParameterSupport === true`\n\nIf omitted or the value lies outside the range of\n`signatures[activeSignature].parameters` defaults to 0 if the active\nsignature has parameters.\n\nIf the active signature has no parameters it is ignored.\n\nIn future version of the protocol this property might become\nmandatory (but still nullable) to better express the active parameter if\nthe active signature does have any." + } + ], + "documentation": "Signature help represents the signature of something\ncallable. There can be multiple signature but only one\nactive and only one active parameter." + }, + { + "name": "SignatureHelpRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "SignatureHelpOptions" + } + ], + "documentation": "Registration options for a {@link SignatureHelpRequest}." + }, + { + "name": "DefinitionParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Parameters for a {@link DefinitionRequest}." + }, + { + "name": "DefinitionRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "DefinitionOptions" + } + ], + "documentation": "Registration options for a {@link DefinitionRequest}." + }, + { + "name": "ReferenceParams", + "properties": [ + { + "name": "context", + "type": { + "kind": "reference", + "name": "ReferenceContext" + } + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Parameters for a {@link ReferencesRequest}." + }, + { + "name": "ReferenceRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "ReferenceOptions" + } + ], + "documentation": "Registration options for a {@link ReferencesRequest}." + }, + { + "name": "DocumentHighlightParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Parameters for a {@link DocumentHighlightRequest}." + }, + { + "name": "DocumentHighlight", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range this highlight applies to." + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "DocumentHighlightKind" + }, + "optional": true, + "documentation": "The highlight kind, default is {@link DocumentHighlightKind.Text text}." + } + ], + "documentation": "A document highlight is a range inside a text document which deserves\nspecial attention. Usually a document highlight is visualized by changing\nthe background color of its range." + }, + { + "name": "DocumentHighlightRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "DocumentHighlightOptions" + } + ], + "documentation": "Registration options for a {@link DocumentHighlightRequest}." + }, + { + "name": "DocumentSymbolParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "Parameters for a {@link DocumentSymbolRequest}." + }, + { + "name": "SymbolInformation", + "properties": [ + { + "name": "deprecated", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Indicates if this symbol is deprecated.\n\n@deprecated Use tags instead", + "deprecated": "Use tags instead" + }, + { + "name": "location", + "type": { + "kind": "reference", + "name": "Location" + }, + "documentation": "The location of this symbol. The location's range is used by a tool\nto reveal the location in the editor. If the symbol is selected in the\ntool the range's start information is used to position the cursor. So\nthe range usually spans more than the actual symbol's name and does\nnormally include things like visibility modifiers.\n\nThe range doesn't have to denote a node range in the sense of an abstract\nsyntax tree. It can therefore not be used to re-construct a hierarchy of\nthe symbols." + } + ], + "extends": [ + { + "kind": "reference", + "name": "BaseSymbolInformation" + } + ], + "documentation": "Represents information about programming constructs like variables, classes,\ninterfaces etc." + }, + { + "name": "DocumentSymbol", + "properties": [ + { + "name": "name", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The name of this symbol. Will be displayed in the user interface and therefore must not be\nan empty string or a string only consisting of white spaces." + }, + { + "name": "detail", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "More detail for this symbol, e.g the signature of a function." + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "SymbolKind" + }, + "documentation": "The kind of this symbol." + }, + { + "name": "tags", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolTag" + } + }, + "optional": true, + "documentation": "Tags for this document symbol.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "deprecated", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Indicates if this symbol is deprecated.\n\n@deprecated Use tags instead", + "deprecated": "Use tags instead" + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range enclosing this symbol not including leading/trailing whitespace but everything else\nlike comments. This information is typically used to determine if the clients cursor is\ninside the symbol to reveal in the symbol in the UI." + }, + { + "name": "selectionRange", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.\nMust be contained by the `range`." + }, + { + "name": "children", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "DocumentSymbol" + } + }, + "optional": true, + "documentation": "Children of this symbol, e.g. properties of a class." + } + ], + "documentation": "Represents programming constructs like variables, classes, interfaces etc.\nthat appear in a document. Document symbols can be hierarchical and they\nhave two ranges: one that encloses its definition and one that points to\nits most interesting range, e.g. the range of an identifier." + }, + { + "name": "DocumentSymbolRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "DocumentSymbolOptions" + } + ], + "documentation": "Registration options for a {@link DocumentSymbolRequest}." + }, + { + "name": "CodeActionParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document in which the command was invoked." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range for which the command was invoked." + }, + { + "name": "context", + "type": { + "kind": "reference", + "name": "CodeActionContext" + }, + "documentation": "Context carrying additional information." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "The parameters of a {@link CodeActionRequest}." + }, + { + "name": "Command", + "properties": [ + { + "name": "title", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "Title of the command, like `save`." + }, + { + "name": "tooltip", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "An optional tooltip.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "command", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The identifier of the actual command handler." + }, + { + "name": "arguments", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "LSPAny" + } + }, + "optional": true, + "documentation": "Arguments that the command handler should be\ninvoked with." + } + ], + "documentation": "Represents a reference to a command. Provides a title which\nwill be used to represent a command in the UI and, optionally,\nan array of arguments which will be passed to the command handler\nfunction when invoked." + }, + { + "name": "CodeAction", + "properties": [ + { + "name": "title", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A short, human-readable, title for this code action." + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "CodeActionKind" + }, + "optional": true, + "documentation": "The kind of the code action.\n\nUsed to filter code actions." + }, + { + "name": "diagnostics", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Diagnostic" + } + }, + "optional": true, + "documentation": "The diagnostics that this code action resolves." + }, + { + "name": "isPreferred", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted\nby keybindings.\n\nA quick fix should be marked preferred if it properly addresses the underlying error.\nA refactoring should be marked preferred if it is the most reasonable choice of actions to take.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "disabled", + "type": { + "kind": "reference", + "name": "CodeActionDisabled" + }, + "optional": true, + "documentation": "Marks that the code action cannot currently be applied.\n\nClients should follow the following guidelines regarding disabled code actions:\n\n - Disabled code actions are not shown in automatic [lightbulbs](https://code.visualstudio.com/docs/editor/editingevolved#_code-action)\n code action menus.\n\n - Disabled actions are shown as faded out in the code action menu when the user requests a more specific type\n of code action, such as refactorings.\n\n - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions)\n that auto applies a code action and only disabled code actions are returned, the client should show the user an\n error message with `reason` in the editor.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "edit", + "type": { + "kind": "reference", + "name": "WorkspaceEdit" + }, + "optional": true, + "documentation": "The workspace edit this code action performs." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "optional": true, + "documentation": "A command this code action executes. If a code action\nprovides an edit and a command, first the edit is\nexecuted and then the command." + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A data entry field that is preserved on a code action between\na `textDocument/codeAction` and a `codeAction/resolve` request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "tags", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CodeActionTag" + } + }, + "optional": true, + "documentation": "Tags for this code action.\n\n@since 3.18.0 - proposed", + "since": "3.18.0 - proposed" + } + ], + "documentation": "A code action represents a change that can be performed in code, e.g. to fix a problem or\nto refactor code.\n\nA CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed." + }, + { + "name": "CodeActionRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "CodeActionOptions" + } + ], + "documentation": "Registration options for a {@link CodeActionRequest}." + }, + { + "name": "WorkspaceSymbolParams", + "properties": [ + { + "name": "query", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A query string to filter symbols by. Clients may send an empty\nstring here to request all symbols.\n\nThe `query`-parameter should be interpreted in a *relaxed way* as editors\nwill apply their own highlighting and scoring on the results. A good rule\nof thumb is to match case-insensitive and to simply check that the\ncharacters of *query* appear in their order in a candidate symbol.\nServers shouldn't use prefix, substring, or similar strict matching." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "The parameters of a {@link WorkspaceSymbolRequest}." + }, + { + "name": "WorkspaceSymbol", + "properties": [ + { + "name": "location", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Location" + }, + { + "kind": "reference", + "name": "LocationUriOnly" + } + ] + }, + "documentation": "The location of the symbol. Whether a server is allowed to\nreturn a location without a range depends on the client\ncapability `workspace.symbol.resolveSupport`.\n\nSee SymbolInformation#location for more details." + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A data entry field that is preserved on a workspace symbol between a\nworkspace symbol request and a workspace symbol resolve request." + } + ], + "extends": [ + { + "kind": "reference", + "name": "BaseSymbolInformation" + } + ], + "documentation": "A special workspace symbol that supports locations without a range.\n\nSee also SymbolInformation.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "WorkspaceSymbolRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "WorkspaceSymbolOptions" + } + ], + "documentation": "Registration options for a {@link WorkspaceSymbolRequest}." + }, + { + "name": "CodeLensParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document to request code lens for." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "The parameters of a {@link CodeLensRequest}." + }, + { + "name": "CodeLens", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range in which this code lens is valid. Should only span a single line." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "optional": true, + "documentation": "The command this code lens represents." + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A data entry field that is preserved on a code lens item between\na {@link CodeLensRequest} and a {@link CodeLensResolveRequest}" + } + ], + "documentation": "A code lens represents a {@link Command command} that should be shown along with\nsource text, like the number of references, a way to run tests, etc.\n\nA code lens is _unresolved_ when no command is associated to it. For performance\nreasons the creation of a code lens and resolving should be done in two stages." + }, + { + "name": "CodeLensRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "CodeLensOptions" + } + ], + "documentation": "Registration options for a {@link CodeLensRequest}." + }, + { + "name": "DocumentLinkParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document to provide document links for." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + }, + { + "kind": "reference", + "name": "PartialResultParams" + } + ], + "documentation": "The parameters of a {@link DocumentLinkRequest}." + }, + { + "name": "DocumentLink", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range this link applies to." + }, + { + "name": "target", + "type": { + "kind": "base", + "name": "URI" + }, + "optional": true, + "documentation": "The uri this link points to. If missing a resolve request is sent later." + }, + { + "name": "tooltip", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The tooltip text when you hover over this link.\n\nIf a tooltip is provided, is will be displayed in a string that includes instructions on how to\ntrigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS,\nuser settings, and localization.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A data entry field that is preserved on a document link between a\nDocumentLinkRequest and a DocumentLinkResolveRequest." + } + ], + "documentation": "A document link is a range in a text document that links to an internal or external resource, like another\ntext document or a web site." + }, + { + "name": "DocumentLinkRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "DocumentLinkOptions" + } + ], + "documentation": "Registration options for a {@link DocumentLinkRequest}." + }, + { + "name": "DocumentFormattingParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document to format." + }, + { + "name": "options", + "type": { + "kind": "reference", + "name": "FormattingOptions" + }, + "documentation": "The format options." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "The parameters of a {@link DocumentFormattingRequest}." + }, + { + "name": "DocumentFormattingRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "DocumentFormattingOptions" + } + ], + "documentation": "Registration options for a {@link DocumentFormattingRequest}." + }, + { + "name": "DocumentRangeFormattingParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document to format." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range to format" + }, + { + "name": "options", + "type": { + "kind": "reference", + "name": "FormattingOptions" + }, + "documentation": "The format options" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "The parameters of a {@link DocumentRangeFormattingRequest}." + }, + { + "name": "DocumentRangeFormattingRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "DocumentRangeFormattingOptions" + } + ], + "documentation": "Registration options for a {@link DocumentRangeFormattingRequest}." + }, + { + "name": "DocumentRangesFormattingParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document to format." + }, + { + "name": "ranges", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Range" + } + }, + "documentation": "The ranges to format" + }, + { + "name": "options", + "type": { + "kind": "reference", + "name": "FormattingOptions" + }, + "documentation": "The format options" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "The parameters of a {@link DocumentRangesFormattingRequest}.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "DocumentOnTypeFormattingParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document to format." + }, + { + "name": "position", + "type": { + "kind": "reference", + "name": "Position" + }, + "documentation": "The position around which the on type formatting should happen.\nThis is not necessarily the exact position where the character denoted\nby the property `ch` got typed." + }, + { + "name": "ch", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The character that has been typed that triggered the formatting\non type request. That is not necessarily the last character that\ngot inserted into the document since the client could auto insert\ncharacters as well (e.g. like automatic brace completion)." + }, + { + "name": "options", + "type": { + "kind": "reference", + "name": "FormattingOptions" + }, + "documentation": "The formatting options." + } + ], + "documentation": "The parameters of a {@link DocumentOnTypeFormattingRequest}." + }, + { + "name": "DocumentOnTypeFormattingRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "DocumentOnTypeFormattingOptions" + } + ], + "documentation": "Registration options for a {@link DocumentOnTypeFormattingRequest}." + }, + { + "name": "RenameParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The document to rename." + }, + { + "name": "position", + "type": { + "kind": "reference", + "name": "Position" + }, + "documentation": "The position at which this request was sent." + }, + { + "name": "newName", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The new name of the symbol. If the given name is not valid the\nrequest must return a {@link ResponseError} with an\nappropriate message set." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "The parameters of a {@link RenameRequest}." + }, + { + "name": "RenameRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "RenameOptions" + } + ], + "documentation": "Registration options for a {@link RenameRequest}." + }, + { + "name": "PrepareRenameParams", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ] + }, + { + "name": "ExecuteCommandParams", + "properties": [ + { + "name": "command", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The identifier of the actual command handler." + }, + { + "name": "arguments", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "LSPAny" + } + }, + "optional": true, + "documentation": "Arguments that the command should be invoked with." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "The parameters of a {@link ExecuteCommandRequest}." + }, + { + "name": "ExecuteCommandRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "ExecuteCommandOptions" + } + ], + "documentation": "Registration options for a {@link ExecuteCommandRequest}." + }, + { + "name": "ApplyWorkspaceEditParams", + "properties": [ + { + "name": "label", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "An optional label of the workspace edit. This label is\npresented in the user interface for example on an undo\nstack to undo the workspace edit." + }, + { + "name": "edit", + "type": { + "kind": "reference", + "name": "WorkspaceEdit" + }, + "documentation": "The edits to apply." + }, + { + "name": "metadata", + "type": { + "kind": "reference", + "name": "WorkspaceEditMetadata" + }, + "optional": true, + "documentation": "Additional data about the edit.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ], + "documentation": "The parameters passed via an apply workspace edit request." + }, + { + "name": "ApplyWorkspaceEditResult", + "properties": [ + { + "name": "applied", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "Indicates whether the edit was applied or not." + }, + { + "name": "failureReason", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "An optional textual description for why the edit was not applied.\nThis may be used by the server for diagnostic logging or to provide\na suitable error for a request that triggered the edit." + }, + { + "name": "failedChange", + "type": { + "kind": "base", + "name": "uinteger" + }, + "optional": true, + "documentation": "Depending on the client's failure handling strategy `failedChange` might\ncontain the index of the change that failed. This property is only available\nif the client signals a `failureHandlingStrategy` in its client capabilities." + } + ], + "documentation": "The result returned from the apply workspace edit request.\n\n@since 3.17 renamed from ApplyWorkspaceEditResponse", + "since": "3.17 renamed from ApplyWorkspaceEditResponse" + }, + { + "name": "WorkDoneProgressBegin", + "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "begin" + } + }, + { + "name": "title", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "Mandatory title of the progress operation. Used to briefly inform about\nthe kind of operation being performed.\n\nExamples: \"Indexing\" or \"Linking dependencies\"." + }, + { + "name": "cancellable", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Controls if a cancel button should show to allow the user to cancel the\nlong running operation. Clients that don't support cancellation are allowed\nto ignore the setting." + }, + { + "name": "message", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "Optional, more detailed associated progress message. Contains\ncomplementary information to the `title`.\n\nExamples: \"3/25 files\", \"project/src/module2\", \"node_modules/some_dep\".\nIf unset, the previous progress message (if any) is still valid." + }, + { + "name": "percentage", + "type": { + "kind": "base", + "name": "uinteger" + }, + "optional": true, + "documentation": "Optional progress percentage to display (value 100 is considered 100%).\nIf not provided infinite progress is assumed and clients are allowed\nto ignore the `percentage` value in subsequent in report notifications.\n\nThe value should be steadily rising. Clients are free to ignore values\nthat are not following this rule. The value range is [0, 100]." + } + ] + }, + { + "name": "WorkDoneProgressReport", + "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "report" + } + }, + { + "name": "cancellable", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Controls enablement state of a cancel button.\n\nClients that don't support cancellation or don't support controlling the button's\nenablement state are allowed to ignore the property." + }, + { + "name": "message", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "Optional, more detailed associated progress message. Contains\ncomplementary information to the `title`.\n\nExamples: \"3/25 files\", \"project/src/module2\", \"node_modules/some_dep\".\nIf unset, the previous progress message (if any) is still valid." + }, + { + "name": "percentage", + "type": { + "kind": "base", + "name": "uinteger" + }, + "optional": true, + "documentation": "Optional progress percentage to display (value 100 is considered 100%).\nIf not provided infinite progress is assumed and clients are allowed\nto ignore the `percentage` value in subsequent in report notifications.\n\nThe value should be steadily rising. Clients are free to ignore values\nthat are not following this rule. The value range is [0, 100]" + } + ] + }, + { + "name": "WorkDoneProgressEnd", + "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "end" + } + }, + { + "name": "message", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "Optional, a final message indicating to for example indicate the outcome\nof the operation." + } + ] + }, + { + "name": "SetTraceParams", + "properties": [ + { + "name": "value", + "type": { + "kind": "reference", + "name": "TraceValue" + } + } + ] + }, + { + "name": "LogTraceParams", + "properties": [ + { + "name": "message", + "type": { + "kind": "base", + "name": "string" + } + }, + { + "name": "verbose", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true + } + ] + }, + { + "name": "CancelParams", + "properties": [ + { + "name": "id", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "integer" + }, + { + "kind": "base", + "name": "string" + } + ] + }, + "documentation": "The request id to cancel." + } + ] + }, + { + "name": "ProgressParams", + "properties": [ + { + "name": "token", + "type": { + "kind": "reference", + "name": "ProgressToken" + }, + "documentation": "The progress token provided by the client or server." + }, + { + "name": "value", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "documentation": "The progress data." + } + ] + }, + { + "name": "TextDocumentPositionParams", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentIdentifier" + }, + "documentation": "The text document." + }, + { + "name": "position", + "type": { + "kind": "reference", + "name": "Position" + }, + "documentation": "The position inside the text document." + } + ], + "documentation": "A parameter literal used in requests to pass a text document and a position inside that\ndocument." + }, + { + "name": "WorkDoneProgressParams", + "properties": [ + { + "name": "workDoneToken", + "type": { + "kind": "reference", + "name": "ProgressToken" + }, + "optional": true, + "documentation": "An optional token that a server can use to report work done progress." + } + ] + }, + { + "name": "PartialResultParams", + "properties": [ + { + "name": "partialResultToken", + "type": { + "kind": "reference", + "name": "ProgressToken" + }, + "optional": true, + "documentation": "An optional token that a server can use to report partial results (e.g. streaming) to\nthe client." + } + ] + }, + { + "name": "LocationLink", + "properties": [ + { + "name": "originSelectionRange", + "type": { + "kind": "reference", + "name": "Range" + }, + "optional": true, + "documentation": "Span of the origin of this link.\n\nUsed as the underlined span for mouse interaction. Defaults to the word range at\nthe definition position." + }, + { + "name": "targetUri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The target resource identifier of this link." + }, + { + "name": "targetRange", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The full target range of this link. If the target for example is a symbol then target range is the\nrange enclosing this symbol not including leading/trailing whitespace but everything else\nlike comments. This information is typically used to highlight the range in the editor." + }, + { + "name": "targetSelectionRange", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range that should be selected and revealed when this link is being followed, e.g the name of a function.\nMust be contained by the `targetRange`. See also `DocumentSymbol#range`" + } + ], + "documentation": "Represents the connection of two locations. Provides additional metadata over normal {@link Location locations},\nincluding an origin range." + }, + { + "name": "Range", + "properties": [ + { + "name": "start", + "type": { + "kind": "reference", + "name": "Position" + }, + "documentation": "The range's start position." + }, + { + "name": "end", + "type": { + "kind": "reference", + "name": "Position" + }, + "documentation": "The range's end position." + } + ], + "documentation": "A range in a text document expressed as (zero-based) start and end positions.\n\nIf you want to specify a range that contains a line including the line ending\ncharacter(s) then use an end position denoting the start of the next line.\nFor example:\n```ts\n{\n start: { line: 5, character: 23 }\n end : { line 6, character : 0 }\n}\n```" + }, + { + "name": "ImplementationOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ] + }, + { + "name": "StaticRegistrationOptions", + "properties": [ + { + "name": "id", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The id used to register the request. The id can be used to deregister\nthe request again. See also Registration#id." + } + ], + "documentation": "Static registration options to be returned in the initialize\nrequest." + }, + { + "name": "TypeDefinitionOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ] + }, + { + "name": "WorkspaceFoldersChangeEvent", + "properties": [ + { + "name": "added", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "WorkspaceFolder" + } + }, + "documentation": "The array of added workspace folders" + }, + { + "name": "removed", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "WorkspaceFolder" + } + }, + "documentation": "The array of the removed workspace folders" + } + ], + "documentation": "The workspace folder change event." + }, + { + "name": "ConfigurationItem", + "properties": [ + { + "name": "scopeUri", + "type": { + "kind": "base", + "name": "URI" + }, + "optional": true, + "documentation": "The scope to get the configuration section for." + }, + { + "name": "section", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The configuration section asked for." + } + ] + }, + { + "name": "TextDocumentIdentifier", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The text document's uri." + } + ], + "documentation": "A literal to identify a text document in the client." + }, + { + "name": "Color", + "properties": [ + { + "name": "red", + "type": { + "kind": "base", + "name": "decimal" + }, + "documentation": "The red component of this color in the range [0-1]." + }, + { + "name": "green", + "type": { + "kind": "base", + "name": "decimal" + }, + "documentation": "The green component of this color in the range [0-1]." + }, + { + "name": "blue", + "type": { + "kind": "base", + "name": "decimal" + }, + "documentation": "The blue component of this color in the range [0-1]." + }, + { + "name": "alpha", + "type": { + "kind": "base", + "name": "decimal" + }, + "documentation": "The alpha component of this color in the range [0-1]." + } + ], + "documentation": "Represents a color in RGBA space." + }, + { + "name": "DocumentColorOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ] + }, + { + "name": "FoldingRangeOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ] + }, + { + "name": "DeclarationOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ] + }, + { + "name": "Position", + "properties": [ + { + "name": "line", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "Line position in a document (zero-based)." + }, + { + "name": "character", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "Character offset on a line in a document (zero-based).\n\nThe meaning of this offset is determined by the negotiated\n`PositionEncodingKind`." + } + ], + "documentation": "Position in a text document expressed as zero-based line and character\noffset. Prior to 3.17 the offsets were always based on a UTF-16 string\nrepresentation. So a string of the form `a𐐀b` the character offset of the\ncharacter `a` is 0, the character offset of `𐐀` is 1 and the character\noffset of b is 3 since `𐐀` is represented using two code units in UTF-16.\nSince 3.17 clients and servers can agree on a different string encoding\nrepresentation (e.g. UTF-8). The client announces it's supported encoding\nvia the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities).\nThe value is an array of position encodings the client supports, with\ndecreasing preference (e.g. the encoding at index `0` is the most preferred\none). To stay backwards compatible the only mandatory encoding is UTF-16\nrepresented via the string `utf-16`. The server can pick one of the\nencodings offered by the client and signals that encoding back to the\nclient via the initialize result's property\n[`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value\n`utf-16` is missing from the client's capability `general.positionEncodings`\nservers can safely assume that the client supports UTF-16. If the server\nomits the position encoding in its initialize result the encoding defaults\nto the string value `utf-16`. Implementation considerations: since the\nconversion from one encoding into another requires the content of the\nfile / line the conversion is best done where the file is read which is\nusually on the server side.\n\nPositions are line end character agnostic. So you can not specify a position\nthat denotes `\\r|\\n` or `\\n|` where `|` represents the character offset.\n\n@since 3.17.0 - support for negotiated position encoding.", + "since": "3.17.0 - support for negotiated position encoding." + }, + { + "name": "SelectionRangeOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ] + }, + { + "name": "CallHierarchyOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Call hierarchy options used during static registration.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensOptions", + "properties": [ + { + "name": "legend", + "type": { + "kind": "reference", + "name": "SemanticTokensLegend" + }, + "documentation": "The legend used by the server" + }, + { + "name": "range", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "literal", + "value": { + "properties": [] + } + } + ] + }, + "optional": true, + "documentation": "Server supports providing semantic tokens for a specific range\nof a document." + }, + { + "name": "full", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "SemanticTokensFullDelta" + } + ] + }, + "optional": true, + "documentation": "Server supports providing semantic tokens for a full document." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensEdit", + "properties": [ + { + "name": "start", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "The start offset of the edit." + }, + { + "name": "deleteCount", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "The count of elements to remove." + }, + { + "name": "data", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "uinteger" + } + }, + "optional": true, + "documentation": "The elements to insert." + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "LinkedEditingRangeOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ] + }, + { + "name": "FileCreate", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A file:// URI for the location of the file/folder being created." + } + ], + "documentation": "Represents information on a file/folder create.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "TextDocumentEdit", + "properties": [ + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "OptionalVersionedTextDocumentIdentifier" + }, + "documentation": "The text document to change." + }, + { + "name": "edits", + "type": { + "kind": "array", + "element": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "TextEdit" + }, + { + "kind": "reference", + "name": "AnnotatedTextEdit" + }, + { + "kind": "reference", + "name": "SnippetTextEdit" + } + ] + } + }, + "documentation": "The edits to be applied.\n\n@since 3.16.0 - support for AnnotatedTextEdit. This is guarded using a\nclient capability.\n\n@since 3.18.0 - support for SnippetTextEdit. This is guarded using a\nclient capability.", + "since": "3.18.0 - support for SnippetTextEdit. This is guarded using a\nclient capability.", + "sinceTags": [ + "3.16.0 - support for AnnotatedTextEdit. This is guarded using a\nclient capability.", + "3.18.0 - support for SnippetTextEdit. This is guarded using a\nclient capability." + ] + } + ], + "documentation": "Describes textual changes on a text document. A TextDocumentEdit describes all changes\non a document version Si and after they are applied move the document to version Si+1.\nSo the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any\nkind of ordering. However the edits must be non overlapping." + }, + { + "name": "CreateFile", + "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "create" + }, + "documentation": "A create" + }, + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The resource to create." + }, + { + "name": "options", + "type": { + "kind": "reference", + "name": "CreateFileOptions" + }, + "optional": true, + "documentation": "Additional options" + } + ], + "extends": [ + { + "kind": "reference", + "name": "ResourceOperation" + } + ], + "documentation": "Create file operation." + }, + { + "name": "RenameFile", + "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "rename" + }, + "documentation": "A rename" + }, + { + "name": "oldUri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The old (existing) location." + }, + { + "name": "newUri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The new location." + }, + { + "name": "options", + "type": { + "kind": "reference", + "name": "RenameFileOptions" + }, + "optional": true, + "documentation": "Rename options." + } + ], + "extends": [ + { + "kind": "reference", + "name": "ResourceOperation" + } + ], + "documentation": "Rename file operation" + }, + { + "name": "DeleteFile", + "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "delete" + }, + "documentation": "A delete" + }, + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The file to delete." + }, + { + "name": "options", + "type": { + "kind": "reference", + "name": "DeleteFileOptions" + }, + "optional": true, + "documentation": "Delete options." + } + ], + "extends": [ + { + "kind": "reference", + "name": "ResourceOperation" + } + ], + "documentation": "Delete file operation" + }, + { + "name": "ChangeAnnotation", + "properties": [ + { + "name": "label", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A human-readable string describing the actual change. The string\nis rendered prominent in the user interface." + }, + { + "name": "needsConfirmation", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "A flag which indicates that user confirmation is needed\nbefore applying the change." + }, + { + "name": "description", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A human-readable string which is rendered less prominent in\nthe user interface." + } + ], + "documentation": "Additional information that describes document changes.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "FileOperationFilter", + "properties": [ + { + "name": "scheme", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A Uri scheme like `file` or `untitled`." + }, + { + "name": "pattern", + "type": { + "kind": "reference", + "name": "FileOperationPattern" + }, + "documentation": "The actual file operation pattern." + } + ], + "documentation": "A filter to describe in which file operation requests or notifications\nthe server is interested in receiving.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "FileRename", + "properties": [ + { + "name": "oldUri", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A file:// URI for the original location of the file/folder being renamed." + }, + { + "name": "newUri", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A file:// URI for the new location of the file/folder being renamed." + } + ], + "documentation": "Represents information on a file/folder rename.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "FileDelete", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A file:// URI for the location of the file/folder being deleted." + } + ], + "documentation": "Represents information on a file/folder delete.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "MonikerOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ] + }, + { + "name": "TypeHierarchyOptions", + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "properties": [], + "documentation": "Type hierarchy options used during static registration.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineValueContext", + "properties": [ + { + "name": "frameId", + "type": { + "kind": "base", + "name": "integer" + }, + "documentation": "The stack frame (as a DAP Id) where the execution has stopped." + }, + { + "name": "stoppedLocation", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The document range where execution has stopped.\nTypically the end position of the range denotes the line where the inline values are shown." + } + ], + "documentation": "@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineValueText", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The document range for which the inline value applies." + }, + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text of the inline value." + } + ], + "documentation": "Provide inline value as text.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineValueVariableLookup", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The document range for which the inline value applies.\nThe range is used to extract the variable name from the underlying document." + }, + { + "name": "variableName", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "If specified the name of the variable to look up." + }, + { + "name": "caseSensitiveLookup", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "How to perform the lookup." + } + ], + "documentation": "Provide inline value through a variable lookup.\nIf only a range is specified, the variable name will be extracted from the underlying document.\nAn optional variable name can be used to override the extracted name.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineValueEvaluatableExpression", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The document range for which the inline value applies.\nThe range is used to extract the evaluatable expression from the underlying document." + }, + { + "name": "expression", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "If specified the expression overrides the extracted expression." + } + ], + "documentation": "Provide an inline value through an expression evaluation.\nIf only a range is specified, the expression will be extracted from the underlying document.\nAn optional expression can be used to override the extracted expression.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineValueOptions", + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "properties": [], + "documentation": "Inline value options used during static registration.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlayHintLabelPart", + "properties": [ + { + "name": "value", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The value of this label part." + }, + { + "name": "tooltip", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "MarkupContent" + } + ] + }, + "optional": true, + "documentation": "The tooltip text when you hover over this label part. Depending on\nthe client capability `inlayHint.resolveSupport` clients might resolve\nthis property late using the resolve request." + }, + { + "name": "location", + "type": { + "kind": "reference", + "name": "Location" + }, + "optional": true, + "documentation": "An optional source code location that represents this\nlabel part.\n\nThe editor will use this location for the hover and for code navigation\nfeatures: This part will become a clickable link that resolves to the\ndefinition of the symbol at the given location (not necessarily the\nlocation itself), it shows the hover that shows at the given location,\nand it shows a context menu with further code navigation commands.\n\nDepending on the client capability `inlayHint.resolveSupport` clients\nmight resolve this property late using the resolve request." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "optional": true, + "documentation": "An optional command for this label part.\n\nDepending on the client capability `inlayHint.resolveSupport` clients\nmight resolve this property late using the resolve request." + } + ], + "documentation": "An inlay hint label part allows for interactive and composite labels\nof inlay hints.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "MarkupContent", + "properties": [ + { + "name": "kind", + "type": { + "kind": "reference", + "name": "MarkupKind" + }, + "documentation": "The type of the Markup" + }, + { + "name": "value", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The content itself" + } + ], + "documentation": "A `MarkupContent` literal represents a string value which content is interpreted base on its\nkind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.\n\nIf the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues.\nSee https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting\n\nHere is an example how such a string can be constructed using JavaScript / TypeScript:\n```ts\nlet markdown: MarkdownContent = {\n kind: MarkupKind.Markdown,\n value: [\n '# Header',\n 'Some text',\n '```typescript',\n 'someCode();',\n '```'\n ].join('\\n')\n};\n```\n\n*Please Note* that clients might sanitize the return markdown. A client could decide to\nremove HTML from the markdown to avoid script execution." + }, + { + "name": "InlayHintOptions", + "properties": [ + { + "name": "resolveProvider", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The server provides support to resolve additional\ninformation for an inlay hint item." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Inlay hint options used during static registration.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "RelatedFullDocumentDiagnosticReport", + "properties": [ + { + "name": "relatedDocuments", + "type": { + "kind": "map", + "key": { + "kind": "base", + "name": "DocumentUri" + }, + "value": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "FullDocumentDiagnosticReport" + }, + { + "kind": "reference", + "name": "UnchangedDocumentDiagnosticReport" + } + ] + } + }, + "optional": true, + "documentation": "Diagnostics of related documents. This information is useful\nin programming languages where code in a file A can generate\ndiagnostics in a file B which A depends on. An example of\nsuch a language is C/C++ where marco definitions in a file\na.cpp and result in errors in a header file b.hpp.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "extends": [ + { + "kind": "reference", + "name": "FullDocumentDiagnosticReport" + } + ], + "documentation": "A full diagnostic report with a set of related documents.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "RelatedUnchangedDocumentDiagnosticReport", + "properties": [ + { + "name": "relatedDocuments", + "type": { + "kind": "map", + "key": { + "kind": "base", + "name": "DocumentUri" + }, + "value": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "FullDocumentDiagnosticReport" + }, + { + "kind": "reference", + "name": "UnchangedDocumentDiagnosticReport" + } + ] + } + }, + "optional": true, + "documentation": "Diagnostics of related documents. This information is useful\nin programming languages where code in a file A can generate\ndiagnostics in a file B which A depends on. An example of\nsuch a language is C/C++ where marco definitions in a file\na.cpp and result in errors in a header file b.hpp.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "extends": [ + { + "kind": "reference", + "name": "UnchangedDocumentDiagnosticReport" + } + ], + "documentation": "An unchanged diagnostic report with a set of related documents.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "FullDocumentDiagnosticReport", + "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "full" + }, + "documentation": "A full document diagnostic report." + }, + { + "name": "resultId", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "An optional result id. If provided it will\nbe sent on the next diagnostic request for the\nsame document." + }, + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Diagnostic" + } + }, + "documentation": "The actual items." + } + ], + "documentation": "A diagnostic report with a full set of problems.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "UnchangedDocumentDiagnosticReport", + "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "unchanged" + }, + "documentation": "A document diagnostic report indicating\nno changes to the last result. A server can\nonly return `unchanged` if result ids are\nprovided." + }, + { + "name": "resultId", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A result id which will be sent on the next\ndiagnostic request for the same document." + } + ], + "documentation": "A diagnostic report indicating that the last returned\nreport is still accurate.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DiagnosticOptions", + "properties": [ + { + "name": "identifier", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "An optional identifier under which the diagnostics are\nmanaged by the client." + }, + { + "name": "interFileDependencies", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "Whether the language has inter file dependencies meaning that\nediting code in one file can result in a different diagnostic\nset in another file. Inter file dependencies are common for\nmost programming languages and typically uncommon for linters." + }, + { + "name": "workspaceDiagnostics", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "The server provides support for workspace diagnostics as well." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Diagnostic options.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "PreviousResultId", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The URI for which the client knowns a\nresult id." + }, + { + "name": "value", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The value of the previous result id." + } + ], + "documentation": "A previous result id in a workspace pull request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "NotebookDocument", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "URI" + }, + "documentation": "The notebook document's uri." + }, + { + "name": "notebookType", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The type of the notebook." + }, + { + "name": "version", + "type": { + "kind": "base", + "name": "integer" + }, + "documentation": "The version number of this document (it will increase after each\nchange, including undo/redo)." + }, + { + "name": "metadata", + "type": { + "kind": "reference", + "name": "LSPObject" + }, + "optional": true, + "documentation": "Additional metadata stored with the notebook\ndocument.\n\nNote: should always be an object literal (e.g. LSPObject)" + }, + { + "name": "cells", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "NotebookCell" + } + }, + "documentation": "The cells of a notebook." + } + ], + "documentation": "A notebook document.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "TextDocumentItem", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The text document's uri." + }, + { + "name": "languageId", + "type": { + "kind": "reference", + "name": "LanguageKind" + }, + "documentation": "The text document's language identifier." + }, + { + "name": "version", + "type": { + "kind": "base", + "name": "integer" + }, + "documentation": "The version number of this document (it will increase after each\nchange, including undo/redo)." + }, + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The content of the opened text document." + } + ], + "documentation": "An item to transfer a text document from the client to the\nserver." + }, + { + "name": "NotebookDocumentSyncOptions", + "properties": [ + { + "name": "notebookSelector", + "type": { + "kind": "array", + "element": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "NotebookDocumentFilterWithNotebook" + }, + { + "kind": "reference", + "name": "NotebookDocumentFilterWithCells" + } + ] + } + }, + "documentation": "The notebooks to be synced" + }, + { + "name": "save", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether save notification should be forwarded to\nthe server. Will only be honored if mode === `notebook`." + } + ], + "documentation": "Options specific to a notebook plus its cells\nto be synced to the server.\n\nIf a selector provides a notebook document\nfilter but no cell selector all cells of a\nmatching notebook document will be synced.\n\nIf a selector provides no notebook document\nfilter but only a cell selector all notebook\ndocument that contain at least one matching\ncell will be synced.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "VersionedNotebookDocumentIdentifier", + "properties": [ + { + "name": "version", + "type": { + "kind": "base", + "name": "integer" + }, + "documentation": "The version number of this notebook document." + }, + { + "name": "uri", + "type": { + "kind": "base", + "name": "URI" + }, + "documentation": "The notebook document's uri." + } + ], + "documentation": "A versioned notebook document identifier.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "NotebookDocumentChangeEvent", + "properties": [ + { + "name": "metadata", + "type": { + "kind": "reference", + "name": "LSPObject" + }, + "optional": true, + "documentation": "The changed meta data if any.\n\nNote: should always be an object literal (e.g. LSPObject)" + }, + { + "name": "cells", + "type": { + "kind": "reference", + "name": "NotebookDocumentCellChanges" + }, + "optional": true, + "documentation": "Changes to cells" + } + ], + "documentation": "A change event for a notebook document.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "NotebookDocumentIdentifier", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "URI" + }, + "documentation": "The notebook document's uri." + } + ], + "documentation": "A literal to identify a notebook document in the client.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineCompletionContext", + "properties": [ + { + "name": "triggerKind", + "type": { + "kind": "reference", + "name": "InlineCompletionTriggerKind" + }, + "documentation": "Describes how the inline completion was triggered." + }, + { + "name": "selectedCompletionInfo", + "type": { + "kind": "reference", + "name": "SelectedCompletionInfo" + }, + "optional": true, + "documentation": "Provides information about the currently selected item in the autocomplete widget if it is visible." + } + ], + "documentation": "Provides information about the context in which an inline completion was requested.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "StringValue", + "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "snippet" + }, + "documentation": "The kind of string value." + }, + { + "name": "value", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The snippet string." + } + ], + "documentation": "A string value used as a snippet is a template which allows to insert text\nand to control the editor cursor when insertion happens.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Variables are defined with `$name` and\n`${name:default value}`.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "InlineCompletionOptions", + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "properties": [], + "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "TextDocumentContentOptions", + "properties": [ + { + "name": "schemes", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The schemes for which the server provides content." + } + ], + "documentation": "Text document content provider options.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "Registration", + "properties": [ + { + "name": "id", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The id used to register the request. The id can be used to deregister\nthe request again." + }, + { + "name": "method", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The method / capability to register for." + }, + { + "name": "registerOptions", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "Options necessary for the registration." + } + ], + "documentation": "General parameters to register for a notification or to register a provider." + }, + { + "name": "Unregistration", + "properties": [ + { + "name": "id", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The id used to unregister the request or notification. Usually an id\nprovided during the register request." + }, + { + "name": "method", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The method to unregister for." + } + ], + "documentation": "General parameters to unregister a request or notification." + }, + { + "name": "_InitializeParams", + "properties": [ + { + "name": "processId", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "integer" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "documentation": "The process Id of the parent process that started\nthe server.\n\nIs `null` if the process has not been started by another process.\nIf the parent process is not alive then the server should exit." + }, + { + "name": "clientInfo", + "type": { + "kind": "reference", + "name": "ClientInfo" + }, + "optional": true, + "documentation": "Information about the client\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "locale", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The locale the client is currently showing the user interface\nin. This must not necessarily be the locale of the operating\nsystem.\n\nUses IETF language tags as the value's syntax\n(See https://en.wikipedia.org/wiki/IETF_language_tag)\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "rootPath", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "optional": true, + "documentation": "The rootPath of the workspace. Is null\nif no folder is open.\n\n@deprecated in favour of rootUri.", + "deprecated": "in favour of rootUri." + }, + { + "name": "rootUri", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "DocumentUri" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "documentation": "The rootUri of the workspace. Is null if no\nfolder is open. If both `rootPath` and `rootUri` are set\n`rootUri` wins.\n\n@deprecated in favour of workspaceFolders.", + "deprecated": "in favour of workspaceFolders." + }, + { + "name": "capabilities", + "type": { + "kind": "reference", + "name": "ClientCapabilities" + }, + "documentation": "The capabilities provided by the client (editor or tool)" + }, + { + "name": "initializationOptions", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "User provided initialization options." + }, + { + "name": "trace", + "type": { + "kind": "reference", + "name": "TraceValue" + }, + "optional": true, + "documentation": "The initial trace setting. If omitted trace is disabled ('off')." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "The initialize parameters" + }, + { + "name": "WorkspaceFoldersInitializeParams", + "properties": [ + { + "name": "workspaceFolders", + "type": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "WorkspaceFolder" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "optional": true, + "documentation": "The workspace folders configured in the client when the server starts.\n\nThis property is only available if the client supports workspace folders.\nIt can be `null` if the client supports workspace folders but none are\nconfigured.\n\n@since 3.6.0", + "since": "3.6.0" + } + ] + }, + { + "name": "ServerCapabilities", + "properties": [ + { + "name": "positionEncoding", + "type": { + "kind": "reference", + "name": "PositionEncodingKind" + }, + "optional": true, + "documentation": "The position encoding the server picked from the encodings offered\nby the client via the client capability `general.positionEncodings`.\n\nIf the client didn't provide any position encodings the only valid\nvalue that a server can return is 'utf-16'.\n\nIf omitted it defaults to 'utf-16'.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "textDocumentSync", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "TextDocumentSyncOptions" + }, + { + "kind": "reference", + "name": "TextDocumentSyncKind" + } + ] + }, + "optional": true, + "documentation": "Defines how text documents are synced. Is either a detailed structure\ndefining each notification or for backwards compatibility the\nTextDocumentSyncKind number." + }, + { + "name": "notebookDocumentSync", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "NotebookDocumentSyncOptions" + }, + { + "kind": "reference", + "name": "NotebookDocumentSyncRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "Defines how notebook documents are synced.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "completionProvider", + "type": { + "kind": "reference", + "name": "CompletionOptions" + }, + "optional": true, + "documentation": "The server provides completion support." + }, + { + "name": "hoverProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "HoverOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides hover support." + }, + { + "name": "signatureHelpProvider", + "type": { + "kind": "reference", + "name": "SignatureHelpOptions" + }, + "optional": true, + "documentation": "The server provides signature help support." + }, + { + "name": "declarationProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "DeclarationOptions" + }, + { + "kind": "reference", + "name": "DeclarationRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides Goto Declaration support." + }, + { + "name": "definitionProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "DefinitionOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides goto definition support." + }, + { + "name": "typeDefinitionProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "TypeDefinitionOptions" + }, + { + "kind": "reference", + "name": "TypeDefinitionRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides Goto Type Definition support." + }, + { + "name": "implementationProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "ImplementationOptions" + }, + { + "kind": "reference", + "name": "ImplementationRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides Goto Implementation support." + }, + { + "name": "referencesProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "ReferenceOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides find references support." + }, + { + "name": "documentHighlightProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "DocumentHighlightOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides document highlight support." + }, + { + "name": "documentSymbolProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "DocumentSymbolOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides document symbol support." + }, + { + "name": "codeActionProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "CodeActionOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides code actions. CodeActionOptions may only be\nspecified if the client states that it supports\n`codeActionLiteralSupport` in its initial `initialize` request." + }, + { + "name": "codeLensProvider", + "type": { + "kind": "reference", + "name": "CodeLensOptions" + }, + "optional": true, + "documentation": "The server provides code lens." + }, + { + "name": "documentLinkProvider", + "type": { + "kind": "reference", + "name": "DocumentLinkOptions" + }, + "optional": true, + "documentation": "The server provides document link support." + }, + { + "name": "colorProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "DocumentColorOptions" + }, + { + "kind": "reference", + "name": "DocumentColorRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides color provider support." + }, + { + "name": "workspaceSymbolProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "WorkspaceSymbolOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides workspace symbol support." + }, + { + "name": "documentFormattingProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "DocumentFormattingOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides document formatting." + }, + { + "name": "documentRangeFormattingProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "DocumentRangeFormattingOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides document range formatting." + }, + { + "name": "documentOnTypeFormattingProvider", + "type": { + "kind": "reference", + "name": "DocumentOnTypeFormattingOptions" + }, + "optional": true, + "documentation": "The server provides document formatting on typing." + }, + { + "name": "renameProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "RenameOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides rename support. RenameOptions may only be\nspecified if the client states that it supports\n`prepareSupport` in its initial `initialize` request." + }, + { + "name": "foldingRangeProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "FoldingRangeOptions" + }, + { + "kind": "reference", + "name": "FoldingRangeRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides folding provider support." + }, + { + "name": "selectionRangeProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "SelectionRangeOptions" + }, + { + "kind": "reference", + "name": "SelectionRangeRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides selection range support." + }, + { + "name": "executeCommandProvider", + "type": { + "kind": "reference", + "name": "ExecuteCommandOptions" + }, + "optional": true, + "documentation": "The server provides execute command support." + }, + { + "name": "callHierarchyProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "CallHierarchyOptions" + }, + { + "kind": "reference", + "name": "CallHierarchyRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides call hierarchy support.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "linkedEditingRangeProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "LinkedEditingRangeOptions" + }, + { + "kind": "reference", + "name": "LinkedEditingRangeRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides linked editing range support.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "semanticTokensProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "SemanticTokensOptions" + }, + { + "kind": "reference", + "name": "SemanticTokensRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides semantic tokens support.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "monikerProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "MonikerOptions" + }, + { + "kind": "reference", + "name": "MonikerRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides moniker support.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "typeHierarchyProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "TypeHierarchyOptions" + }, + { + "kind": "reference", + "name": "TypeHierarchyRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides type hierarchy support.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "inlineValueProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "InlineValueOptions" + }, + { + "kind": "reference", + "name": "InlineValueRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides inline values.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "inlayHintProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "InlayHintOptions" + }, + { + "kind": "reference", + "name": "InlayHintRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides inlay hints.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "diagnosticProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "DiagnosticOptions" + }, + { + "kind": "reference", + "name": "DiagnosticRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server has support for pull model diagnostics.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "inlineCompletionProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "InlineCompletionOptions" + } + ] + }, + "optional": true, + "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "workspace", + "type": { + "kind": "reference", + "name": "WorkspaceOptions" + }, + "optional": true, + "documentation": "Workspace specific server capabilities." + }, + { + "name": "experimental", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "Experimental server capabilities." + } + ], + "documentation": "Defines the capabilities provided by a language\nserver." + }, + { + "name": "ServerInfo", + "properties": [ + { + "name": "name", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The name of the server as defined by the server." + }, + { + "name": "version", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The server's version as defined by the server." + } + ], + "documentation": "Information about the server\n\n@since 3.15.0\n@since 3.18.0 ServerInfo type name added.", + "since": "3.18.0 ServerInfo type name added.", + "sinceTags": [ + "3.15.0", + "3.18.0 ServerInfo type name added." + ] + }, + { + "name": "VersionedTextDocumentIdentifier", + "properties": [ + { + "name": "version", + "type": { + "kind": "base", + "name": "integer" + }, + "documentation": "The version number of this document." + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentIdentifier" + } + ], + "documentation": "A text document identifier to denote a specific version of a text document." + }, + { + "name": "SaveOptions", + "properties": [ + { + "name": "includeText", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client is supposed to include the content on save." + } + ], + "documentation": "Save options." + }, + { + "name": "FileEvent", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The file's uri." + }, + { + "name": "type", + "type": { + "kind": "reference", + "name": "FileChangeType" + }, + "documentation": "The change type." + } + ], + "documentation": "An event describing a file change." + }, + { + "name": "FileSystemWatcher", + "properties": [ + { + "name": "globPattern", + "type": { + "kind": "reference", + "name": "GlobPattern" + }, + "documentation": "The glob pattern to watch. See {@link GlobPattern glob pattern} for more detail.\n\n@since 3.17.0 support for relative patterns.", + "since": "3.17.0 support for relative patterns." + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "WatchKind" + }, + "optional": true, + "documentation": "The kind of events of interest. If omitted it defaults\nto WatchKind.Create | WatchKind.Change | WatchKind.Delete\nwhich is 7." + } + ] + }, + { + "name": "Diagnostic", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range at which the message applies" + }, + { + "name": "severity", + "type": { + "kind": "reference", + "name": "DiagnosticSeverity" + }, + "optional": true, + "documentation": "The diagnostic's severity. To avoid interpretation mismatches when a\nserver is used with different clients it is highly recommended that servers\nalways provide a severity value." + }, + { + "name": "code", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "integer" + }, + { + "kind": "base", + "name": "string" + } + ] + }, + "optional": true, + "documentation": "The diagnostic's code, which usually appear in the user interface." + }, + { + "name": "codeDescription", + "type": { + "kind": "reference", + "name": "CodeDescription" + }, + "optional": true, + "documentation": "An optional property to describe the error code.\nRequires the code field (above) to be present/not null.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "source", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A human-readable string describing the source of this\ndiagnostic, e.g. 'typescript' or 'super lint'. It usually\nappears in the user interface." + }, + { + "name": "message", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The diagnostic's message. It usually appears in the user interface" + }, + { + "name": "tags", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "DiagnosticTag" + } + }, + "optional": true, + "documentation": "Additional metadata about the diagnostic.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "relatedInformation", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "DiagnosticRelatedInformation" + } + }, + "optional": true, + "documentation": "An array of related diagnostic information, e.g. when symbol-names within\na scope collide all definitions can be marked via this property." + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A data entry field that is preserved between a `textDocument/publishDiagnostics`\nnotification and `textDocument/codeAction` request.\n\n@since 3.16.0", + "since": "3.16.0" + } + ], + "documentation": "Represents a diagnostic, such as a compiler error or warning. Diagnostic objects\nare only valid in the scope of a resource." + }, + { + "name": "CompletionContext", + "properties": [ + { + "name": "triggerKind", + "type": { + "kind": "reference", + "name": "CompletionTriggerKind" + }, + "documentation": "How the completion was triggered." + }, + { + "name": "triggerCharacter", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The trigger character (a single character) that has trigger code complete.\nIs undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`" + } + ], + "documentation": "Contains additional information about the context in which a completion request is triggered." + }, + { + "name": "CompletionItemLabelDetails", + "properties": [ + { + "name": "detail", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "An optional string which is rendered less prominently directly after {@link CompletionItem.label label},\nwithout any spacing. Should be used for function signatures and type annotations." + }, + { + "name": "description", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "An optional string which is rendered less prominently after {@link CompletionItem.detail}. Should be used\nfor fully qualified names and file paths." + } + ], + "documentation": "Additional details for a completion item label.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InsertReplaceEdit", + "properties": [ + { + "name": "newText", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The string to be inserted." + }, + { + "name": "insert", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range if the insert is requested" + }, + { + "name": "replace", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range if the replace is requested." + } + ], + "documentation": "A special text edit to provide an insert and a replace operation.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "CompletionItemDefaults", + "properties": [ + { + "name": "commitCharacters", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "optional": true, + "documentation": "A default commit character set.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "editRange", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Range" + }, + { + "kind": "reference", + "name": "EditRangeWithInsertReplace" + } + ] + }, + "optional": true, + "documentation": "A default edit range.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "insertTextFormat", + "type": { + "kind": "reference", + "name": "InsertTextFormat" + }, + "optional": true, + "documentation": "A default insert text format.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "insertTextMode", + "type": { + "kind": "reference", + "name": "InsertTextMode" + }, + "optional": true, + "documentation": "A default insert text mode.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "A default data value.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "In many cases the items of an actual completion result share the same\nvalue for properties like `commitCharacters` or the range of a text\nedit. A completion list can therefore define item defaults which will\nbe used if a completion item itself doesn't specify the value.\n\nIf a completion list specifies a default value and a completion item\nalso specifies a corresponding value, the rules for combining these are\ndefined by `applyKinds` (if the client supports it), defaulting to\n\"replace\".\n\nServers are only allowed to return default values if the client\nsignals support for this via the `completionList.itemDefaults`\ncapability.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "CompletionItemApplyKinds", + "properties": [ + { + "name": "commitCharacters", + "type": { + "kind": "reference", + "name": "ApplyKind" + }, + "optional": true, + "documentation": "Specifies whether commitCharacters on a completion will replace or be\nmerged with those in `completionList.itemDefaults.commitCharacters`.\n\nIf \"replace\", the commit characters from the completion item will\nalways be used unless not provided, in which case those from\n`completionList.itemDefaults.commitCharacters` will be used. An\nempty list can be used if a completion item does not have any commit\ncharacters and also should not use those from\n`completionList.itemDefaults.commitCharacters`.\n\nIf \"merge\" the commitCharacters for the completion will be the union\nof all values in both `completionList.itemDefaults.commitCharacters`\nand the completion's own `commitCharacters`.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "data", + "type": { + "kind": "reference", + "name": "ApplyKind" + }, + "optional": true, + "documentation": "Specifies whether the `data` field on a completion will replace or\nbe merged with data from `completionList.itemDefaults.data`.\n\nIf \"replace\", the data from the completion item will be used if\nprovided (and not `null`), otherwise\n`completionList.itemDefaults.data` will be used. An empty object can\nbe used if a completion item does not have any data but also should\nnot use the value from `completionList.itemDefaults.data`.\n\nIf \"merge\", a shallow merge will be performed between\n`completionList.itemDefaults.data` and the completion's own data\nusing the following rules:\n\n- If a completion's `data` field is not provided (or `null`), the\n entire `data` field from `completionList.itemDefaults.data` will be\n used as-is.\n- If a completion's `data` field is provided, each field will\n overwrite the field of the same name in\n `completionList.itemDefaults.data` but no merging of nested fields\n within that value will occur.\n\n@since 3.18.0", + "since": "3.18.0" + } + ], + "documentation": "Specifies how fields from a completion item should be combined with those\nfrom `completionList.itemDefaults`.\n\nIf unspecified, all fields will be treated as \"replace\".\n\nIf a field's value is \"replace\", the value from a completion item (if\nprovided and not `null`) will always be used instead of the value from\n`completionItem.itemDefaults`.\n\nIf a field's value is \"merge\", the values will be merged using the rules\ndefined against each field below.\n\nServers are only allowed to return `applyKind` if the client\nsignals support for this via the `completionList.applyKindSupport`\ncapability.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "CompletionOptions", + "properties": [ + { + "name": "triggerCharacters", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "optional": true, + "documentation": "Most tools trigger completion request automatically without explicitly requesting\nit using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user\nstarts to type an identifier. For example if the user types `c` in a JavaScript file\ncode complete will automatically pop up present `console` besides others as a\ncompletion item. Characters that make up identifiers don't need to be listed here.\n\nIf code complete should automatically be trigger on characters not being valid inside\nan identifier (for example `.` in JavaScript) list them in `triggerCharacters`." + }, + { + "name": "allCommitCharacters", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "optional": true, + "documentation": "The list of all possible characters that commit a completion. This field can be used\nif clients don't support individual commit characters per completion item. See\n`ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport`\n\nIf a server provides both `allCommitCharacters` and commit characters on an individual\ncompletion item the ones on the completion item win.\n\n@since 3.2.0", + "since": "3.2.0" + }, + { + "name": "resolveProvider", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The server provides support to resolve additional\ninformation for a completion item." + }, + { + "name": "completionItem", + "type": { + "kind": "reference", + "name": "ServerCompletionItemOptions" + }, + "optional": true, + "documentation": "The server supports the following `CompletionItem` specific\ncapabilities.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Completion options." + }, + { + "name": "HoverOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Hover options." + }, + { + "name": "SignatureHelpContext", + "properties": [ + { + "name": "triggerKind", + "type": { + "kind": "reference", + "name": "SignatureHelpTriggerKind" + }, + "documentation": "Action that caused signature help to be triggered." + }, + { + "name": "triggerCharacter", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "Character that caused signature help to be triggered.\n\nThis is undefined when `triggerKind !== SignatureHelpTriggerKind.TriggerCharacter`" + }, + { + "name": "isRetrigger", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "`true` if signature help was already showing when it was triggered.\n\nRetriggers occurs when the signature help is already active and can be caused by actions such as\ntyping a trigger character, a cursor move, or document content changes." + }, + { + "name": "activeSignatureHelp", + "type": { + "kind": "reference", + "name": "SignatureHelp" + }, + "optional": true, + "documentation": "The currently active `SignatureHelp`.\n\nThe `activeSignatureHelp` has its `SignatureHelp.activeSignature` field updated based on\nthe user navigating through available signatures." + } + ], + "documentation": "Additional information about the context in which a signature help request was triggered.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "SignatureInformation", + "properties": [ + { + "name": "label", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The label of this signature. Will be shown in\nthe UI." + }, + { + "name": "documentation", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "MarkupContent" + } + ] + }, + "optional": true, + "documentation": "The human-readable doc-comment of this signature. Will be shown\nin the UI but can be omitted." + }, + { + "name": "parameters", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "ParameterInformation" + } + }, + "optional": true, + "documentation": "The parameters of this signature." + }, + { + "name": "activeParameter", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "uinteger" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "optional": true, + "documentation": "The index of the active parameter.\n\nIf `null`, no parameter of the signature is active (for example a named\nargument that does not match any declared parameters). This is only valid\nif the client specifies the client capability\n`textDocument.signatureHelp.noActiveParameterSupport === true`\n\nIf provided (or `null`), this is used in place of\n`SignatureHelp.activeParameter`.\n\n@since 3.16.0", + "since": "3.16.0" + } + ], + "documentation": "Represents the signature of something callable. A signature\ncan have a label, like a function-name, a doc-comment, and\na set of parameters." + }, + { + "name": "SignatureHelpOptions", + "properties": [ + { + "name": "triggerCharacters", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "optional": true, + "documentation": "List of characters that trigger signature help automatically." + }, + { + "name": "retriggerCharacters", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "optional": true, + "documentation": "List of characters that re-trigger signature help.\n\nThese trigger characters are only active when signature help is already showing. All trigger characters\nare also counted as re-trigger characters.\n\n@since 3.15.0", + "since": "3.15.0" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Server Capabilities for a {@link SignatureHelpRequest}." + }, + { + "name": "DefinitionOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Server Capabilities for a {@link DefinitionRequest}." + }, + { + "name": "ReferenceContext", + "properties": [ + { + "name": "includeDeclaration", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "Include the declaration of the current symbol." + } + ], + "documentation": "Value-object that contains additional information when\nrequesting references." + }, + { + "name": "ReferenceOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Reference options." + }, + { + "name": "DocumentHighlightOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Provider options for a {@link DocumentHighlightRequest}." + }, + { + "name": "BaseSymbolInformation", + "properties": [ + { + "name": "name", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The name of this symbol." + }, + { + "name": "kind", + "type": { + "kind": "reference", + "name": "SymbolKind" + }, + "documentation": "The kind of this symbol." + }, + { + "name": "tags", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolTag" + } + }, + "optional": true, + "documentation": "Tags for this symbol.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "containerName", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The name of the symbol containing this symbol. This information is for\nuser interface purposes (e.g. to render a qualifier in the user interface\nif necessary). It can't be used to re-infer a hierarchy for the document\nsymbols." + } + ], + "documentation": "A base for all symbol information." + }, + { + "name": "DocumentSymbolOptions", + "properties": [ + { + "name": "label", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A human-readable string that is shown when multiple outlines trees\nare shown for the same document.\n\n@since 3.16.0", + "since": "3.16.0" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Provider options for a {@link DocumentSymbolRequest}." + }, + { + "name": "CodeActionContext", + "properties": [ + { + "name": "diagnostics", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "Diagnostic" + } + }, + "documentation": "An array of diagnostics known on the client side overlapping the range provided to the\n`textDocument/codeAction` request. They are provided so that the server knows which\nerrors are currently presented to the user for the given range. There is no guarantee\nthat these accurately reflect the error state of the resource. The primary parameter\nto compute code actions is the provided range." + }, + { + "name": "only", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CodeActionKind" + } + }, + "optional": true, + "documentation": "Requested kind of actions to return.\n\nActions not of this kind are filtered out by the client before being shown. So servers\ncan omit computing them." + }, + { + "name": "triggerKind", + "type": { + "kind": "reference", + "name": "CodeActionTriggerKind" + }, + "optional": true, + "documentation": "The reason why code actions were requested.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "Contains additional diagnostic information about the context in which\na {@link CodeActionProvider.provideCodeActions code action} is run." + }, + { + "name": "CodeActionDisabled", + "properties": [ + { + "name": "reason", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "Human readable description of why the code action is currently disabled.\n\nThis is displayed in the code actions UI." + } + ], + "documentation": "Captures why the code action is currently disabled.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "CodeActionOptions", + "properties": [ + { + "name": "codeActionKinds", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CodeActionKind" + } + }, + "optional": true, + "documentation": "CodeActionKinds that this server may return.\n\nThe list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server\nmay list out every specific kind they provide." + }, + { + "name": "documentation", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CodeActionKindDocumentation" + } + }, + "optional": true, + "documentation": "Static documentation for a class of code actions.\n\nDocumentation from the provider should be shown in the code actions menu if either:\n\n- Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that\n most closely matches the requested code action kind. For example, if a provider has documentation for\n both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,\n the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.\n\n- Any code actions of `kind` are returned by the provider.\n\nAt most one documentation entry should be shown per provider.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "resolveProvider", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The server provides support to resolve additional\ninformation for a code action.\n\n@since 3.16.0", + "since": "3.16.0" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Provider options for a {@link CodeActionRequest}." + }, + { + "name": "LocationUriOnly", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + } + } + ], + "documentation": "Location with only uri and does not include range.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "WorkspaceSymbolOptions", + "properties": [ + { + "name": "resolveProvider", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The server provides support to resolve additional\ninformation for a workspace symbol.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Server capabilities for a {@link WorkspaceSymbolRequest}." + }, + { + "name": "CodeLensOptions", + "properties": [ + { + "name": "resolveProvider", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Code lens has a resolve provider as well." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Code Lens provider options of a {@link CodeLensRequest}." + }, + { + "name": "DocumentLinkOptions", + "properties": [ + { + "name": "resolveProvider", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Document links have a resolve provider as well." + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Provider options for a {@link DocumentLinkRequest}." + }, + { + "name": "FormattingOptions", + "properties": [ + { + "name": "tabSize", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "Size of a tab in spaces." + }, + { + "name": "insertSpaces", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "Prefer spaces over tabs." + }, + { + "name": "trimTrailingWhitespace", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Trim trailing whitespace on a line.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "insertFinalNewline", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Insert a newline character at the end of the file if one does not exist.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "trimFinalNewlines", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Trim all newlines after the final newline at the end of the file.\n\n@since 3.15.0", + "since": "3.15.0" + } + ], + "documentation": "Value-object describing what options formatting should use." + }, + { + "name": "DocumentFormattingOptions", + "properties": [], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Provider options for a {@link DocumentFormattingRequest}." + }, + { + "name": "DocumentRangeFormattingOptions", + "properties": [ + { + "name": "rangesSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the server supports formatting multiple ranges at once.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Provider options for a {@link DocumentRangeFormattingRequest}." + }, + { + "name": "DocumentOnTypeFormattingOptions", + "properties": [ + { + "name": "firstTriggerCharacter", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A character on which formatting should be triggered, like `{`." + }, + { + "name": "moreTriggerCharacter", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "optional": true, + "documentation": "More trigger characters." + } + ], + "documentation": "Provider options for a {@link DocumentOnTypeFormattingRequest}." + }, + { + "name": "RenameOptions", + "properties": [ + { + "name": "prepareProvider", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Renames should be checked and tested before being executed.\n\n@since version 3.12.0", + "since": "version 3.12.0" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Provider options for a {@link RenameRequest}." + }, + { + "name": "PrepareRenamePlaceholder", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + } + }, + { + "name": "placeholder", + "type": { + "kind": "base", + "name": "string" + } + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "PrepareRenameDefaultBehavior", + "properties": [ + { + "name": "defaultBehavior", + "type": { + "kind": "base", + "name": "boolean" + } + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ExecuteCommandOptions", + "properties": [ + { + "name": "commands", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The commands to be executed on the server" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "The server capabilities of a {@link ExecuteCommandRequest}." + }, + { + "name": "WorkspaceEditMetadata", + "properties": [ + { + "name": "isRefactoring", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Signal to the editor that this edit is a refactoring." + } + ], + "documentation": "Additional data about a workspace edit.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "SemanticTokensLegend", + "properties": [ + { + "name": "tokenTypes", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The token types a server uses." + }, + { + "name": "tokenModifiers", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The token modifiers a server uses." + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensFullDelta", + "properties": [ + { + "name": "delta", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The server supports deltas for full documents." + } + ], + "documentation": "Semantic tokens options to support deltas for full documents\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "OptionalVersionedTextDocumentIdentifier", + "properties": [ + { + "name": "version", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "integer" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "documentation": "The version number of this document. If a versioned text document identifier\nis sent from the server to the client and the file is not open in the editor\n(the server has not received an open notification before) the server can send\n`null` to indicate that the version is unknown and the content on disk is the\ntruth (as specified with document content ownership)." + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentIdentifier" + } + ], + "documentation": "A text document identifier to optionally denote a specific version of a text document." + }, + { + "name": "AnnotatedTextEdit", + "properties": [ + { + "name": "annotationId", + "type": { + "kind": "reference", + "name": "ChangeAnnotationIdentifier" + }, + "documentation": "The actual identifier of the change annotation" + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextEdit" + } + ], + "documentation": "A special text edit with an additional change annotation.\n\n@since 3.16.0.", + "since": "3.16.0." + }, + { + "name": "SnippetTextEdit", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range of the text document to be manipulated." + }, + { + "name": "snippet", + "type": { + "kind": "reference", + "name": "StringValue" + }, + "documentation": "The snippet to be inserted." + }, + { + "name": "annotationId", + "type": { + "kind": "reference", + "name": "ChangeAnnotationIdentifier" + }, + "optional": true, + "documentation": "The actual identifier of the snippet edit." + } + ], + "documentation": "An interactive text edit.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "ResourceOperation", + "properties": [ + { + "name": "kind", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The resource operation kind." + }, + { + "name": "annotationId", + "type": { + "kind": "reference", + "name": "ChangeAnnotationIdentifier" + }, + "optional": true, + "documentation": "An optional annotation identifier describing the operation.\n\n@since 3.16.0", + "since": "3.16.0" + } + ], + "documentation": "A generic resource operation." + }, + { + "name": "CreateFileOptions", + "properties": [ + { + "name": "overwrite", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Overwrite existing file. Overwrite wins over `ignoreIfExists`" + }, + { + "name": "ignoreIfExists", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Ignore if exists." + } + ], + "documentation": "Options to create a file." + }, + { + "name": "RenameFileOptions", + "properties": [ + { + "name": "overwrite", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Overwrite target if existing. Overwrite wins over `ignoreIfExists`" + }, + { + "name": "ignoreIfExists", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Ignores if target exists." + } + ], + "documentation": "Rename file options" + }, + { + "name": "DeleteFileOptions", + "properties": [ + { + "name": "recursive", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Delete the content recursively if a folder is denoted." + }, + { + "name": "ignoreIfNotExists", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Ignore the operation if the file doesn't exist." + } + ], + "documentation": "Delete file options" + }, + { + "name": "FileOperationPattern", + "properties": [ + { + "name": "glob", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The glob pattern to match. Glob patterns can have the following syntax:\n- `*` to match one or more characters in a path segment\n- `?` to match on one character in a path segment\n- `**` to match any number of path segments, including none\n- `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)\n- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)\n- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)" + }, + { + "name": "matches", + "type": { + "kind": "reference", + "name": "FileOperationPatternKind" + }, + "optional": true, + "documentation": "Whether to match files or folders with this pattern.\n\nMatches both if undefined." + }, + { + "name": "options", + "type": { + "kind": "reference", + "name": "FileOperationPatternOptions" + }, + "optional": true, + "documentation": "Additional options used during matching." + } + ], + "documentation": "A pattern to describe in which file operation requests or notifications\nthe server is interested in receiving.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "WorkspaceFullDocumentDiagnosticReport", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The URI for which diagnostic information is reported." + }, + { + "name": "version", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "integer" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "documentation": "The version number for which the diagnostics are reported.\nIf the document is not marked as open `null` can be provided." + } + ], + "extends": [ + { + "kind": "reference", + "name": "FullDocumentDiagnosticReport" + } + ], + "documentation": "A full document diagnostic report for a workspace diagnostic result.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "WorkspaceUnchangedDocumentDiagnosticReport", + "properties": [ + { + "name": "uri", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The URI for which diagnostic information is reported." + }, + { + "name": "version", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "integer" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "documentation": "The version number for which the diagnostics are reported.\nIf the document is not marked as open `null` can be provided." + } + ], + "extends": [ + { + "kind": "reference", + "name": "UnchangedDocumentDiagnosticReport" + } + ], + "documentation": "An unchanged document diagnostic report for a workspace diagnostic result.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "NotebookCell", + "properties": [ + { + "name": "kind", + "type": { + "kind": "reference", + "name": "NotebookCellKind" + }, + "documentation": "The cell's kind" + }, + { + "name": "document", + "type": { + "kind": "base", + "name": "DocumentUri" + }, + "documentation": "The URI of the cell's text document\ncontent." + }, + { + "name": "metadata", + "type": { + "kind": "reference", + "name": "LSPObject" + }, + "optional": true, + "documentation": "Additional metadata stored with the cell.\n\nNote: should always be an object literal (e.g. LSPObject)" + }, + { + "name": "executionSummary", + "type": { + "kind": "reference", + "name": "ExecutionSummary" + }, + "optional": true, + "documentation": "Additional execution summary information\nif supported by the client." + } + ], + "documentation": "A notebook cell.\n\nA cell's document URI must be unique across ALL notebook\ncells and can therefore be used to uniquely identify a\nnotebook cell or the cell's text document.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "NotebookDocumentFilterWithNotebook", + "properties": [ + { + "name": "notebook", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "NotebookDocumentFilter" + } + ] + }, + "documentation": "The notebook to be synced If a string\nvalue is provided it matches against the\nnotebook type. '*' matches every notebook." + }, + { + "name": "cells", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "NotebookCellLanguage" + } + }, + "optional": true, + "documentation": "The cells of the matching notebook to be synced." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "NotebookDocumentFilterWithCells", + "properties": [ + { + "name": "notebook", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "NotebookDocumentFilter" + } + ] + }, + "optional": true, + "documentation": "The notebook to be synced If a string\nvalue is provided it matches against the\nnotebook type. '*' matches every notebook." + }, + { + "name": "cells", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "NotebookCellLanguage" + } + }, + "documentation": "The cells of the matching notebook to be synced." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "NotebookDocumentCellChanges", + "properties": [ + { + "name": "structure", + "type": { + "kind": "reference", + "name": "NotebookDocumentCellChangeStructure" + }, + "optional": true, + "documentation": "Changes to the cell structure to add or\nremove cells." + }, + { + "name": "data", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "NotebookCell" + } + }, + "optional": true, + "documentation": "Changes to notebook cells properties like its\nkind, execution summary or metadata." + }, + { + "name": "textContent", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "NotebookDocumentCellContentChanges" + } + }, + "optional": true, + "documentation": "Changes to the text content of notebook cells." + } + ], + "documentation": "Cell changes to a notebook document.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "SelectedCompletionInfo", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range that will be replaced if this completion item is accepted." + }, + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text the range will be replaced with if this completion is accepted." + } + ], + "documentation": "Describes the currently selected completion item.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "ClientInfo", + "properties": [ + { + "name": "name", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The name of the client as defined by the client." + }, + { + "name": "version", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The client's version as defined by the client." + } + ], + "documentation": "Information about the client\n\n@since 3.15.0\n@since 3.18.0 ClientInfo type name added.", + "since": "3.18.0 ClientInfo type name added.", + "sinceTags": [ + "3.15.0", + "3.18.0 ClientInfo type name added." + ] + }, + { + "name": "ClientCapabilities", + "properties": [ + { + "name": "workspace", + "type": { + "kind": "reference", + "name": "WorkspaceClientCapabilities" + }, + "optional": true, + "documentation": "Workspace specific client capabilities." + }, + { + "name": "textDocument", + "type": { + "kind": "reference", + "name": "TextDocumentClientCapabilities" + }, + "optional": true, + "documentation": "Text document specific client capabilities." + }, + { + "name": "notebookDocument", + "type": { + "kind": "reference", + "name": "NotebookDocumentClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the notebook document support.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "window", + "type": { + "kind": "reference", + "name": "WindowClientCapabilities" + }, + "optional": true, + "documentation": "Window specific client capabilities." + }, + { + "name": "general", + "type": { + "kind": "reference", + "name": "GeneralClientCapabilities" + }, + "optional": true, + "documentation": "General client capabilities.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "experimental", + "type": { + "kind": "reference", + "name": "LSPAny" + }, + "optional": true, + "documentation": "Experimental client capabilities." + } + ], + "documentation": "Defines the capabilities provided by the client." + }, + { + "name": "TextDocumentSyncOptions", + "properties": [ + { + "name": "openClose", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Open and close notifications are sent to the server. If omitted open close notification should not\nbe sent." + }, + { + "name": "change", + "type": { + "kind": "reference", + "name": "TextDocumentSyncKind" + }, + "optional": true, + "documentation": "Change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full\nand TextDocumentSyncKind.Incremental. If omitted it defaults to TextDocumentSyncKind.None." + }, + { + "name": "willSave", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "If present will save notifications are sent to the server. If omitted the notification should not be\nsent." + }, + { + "name": "willSaveWaitUntil", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "If present will save wait until requests are sent to the server. If omitted the request should not be\nsent." + }, + { + "name": "save", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "SaveOptions" + } + ] + }, + "optional": true, + "documentation": "If present save notifications are sent to the server. If omitted the notification should not be\nsent." + } + ] + }, + { + "name": "WorkspaceOptions", + "properties": [ + { + "name": "workspaceFolders", + "type": { + "kind": "reference", + "name": "WorkspaceFoldersServerCapabilities" + }, + "optional": true, + "documentation": "The server supports workspace folder.\n\n@since 3.6.0", + "since": "3.6.0" + }, + { + "name": "fileOperations", + "type": { + "kind": "reference", + "name": "FileOperationOptions" + }, + "optional": true, + "documentation": "The server is interested in notifications/requests for operations on files.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "textDocumentContent", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "TextDocumentContentOptions" + }, + { + "kind": "reference", + "name": "TextDocumentContentRegistrationOptions" + } + ] + }, + "optional": true, + "documentation": "The server supports the `workspace/textDocumentContent` request.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ], + "documentation": "Defines workspace specific capabilities of the server.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "TextDocumentContentChangePartial", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range of the document that changed." + }, + { + "name": "rangeLength", + "type": { + "kind": "base", + "name": "uinteger" + }, + "optional": true, + "documentation": "The optional length of the range that got replaced.\n\n@deprecated use range instead.", + "deprecated": "use range instead." + }, + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The new text for the provided range." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "TextDocumentContentChangeWholeDocument", + "properties": [ + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The new text of the whole document." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "CodeDescription", + "properties": [ + { + "name": "href", + "type": { + "kind": "base", + "name": "URI" + }, + "documentation": "An URI to open with more information about the diagnostic error." + } + ], + "documentation": "Structure to capture a description for an error code.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "DiagnosticRelatedInformation", + "properties": [ + { + "name": "location", + "type": { + "kind": "reference", + "name": "Location" + }, + "documentation": "The location of this related diagnostic information." + }, + { + "name": "message", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The message of this related diagnostic information." + } + ], + "documentation": "Represents a related message and source code location for a diagnostic. This should be\nused to point to code locations that cause or related to a diagnostics, e.g when duplicating\na symbol in a scope." + }, + { + "name": "EditRangeWithInsertReplace", + "properties": [ + { + "name": "insert", + "type": { + "kind": "reference", + "name": "Range" + } + }, + { + "name": "replace", + "type": { + "kind": "reference", + "name": "Range" + } + } + ], + "documentation": "Edit range variant that includes ranges for insert and replace operations.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ServerCompletionItemOptions", + "properties": [ + { + "name": "labelDetailsSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The server has support for completion item label\ndetails (see also `CompletionItemLabelDetails`) when\nreceiving a completion item in a resolve call.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "MarkedStringWithLanguage", + "properties": [ + { + "name": "language", + "type": { + "kind": "base", + "name": "string" + } + }, + { + "name": "value", + "type": { + "kind": "base", + "name": "string" + } + } + ], + "documentation": "@since 3.18.0\n@deprecated use MarkupContent instead.", + "since": "3.18.0", + "deprecated": "use MarkupContent instead." + }, + { + "name": "ParameterInformation", + "properties": [ + { + "name": "label", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "tuple", + "items": [ + { + "kind": "base", + "name": "uinteger" + }, + { + "kind": "base", + "name": "uinteger" + } + ] + } + ] + }, + "documentation": "The label of this parameter information.\n\nEither a string or an inclusive start and exclusive end offsets within its containing\nsignature label. (see SignatureInformation.label). The offsets are based on a UTF-16\nstring representation as `Position` and `Range` does.\n\nTo avoid ambiguities a server should use the [start, end] offset value instead of using\na substring. Whether a client support this is controlled via `labelOffsetSupport` client\ncapability.\n\n*Note*: a label of type string should be a substring of its containing signature label.\nIts intended use case is to highlight the parameter label part in the `SignatureInformation.label`." + }, + { + "name": "documentation", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "MarkupContent" + } + ] + }, + "optional": true, + "documentation": "The human-readable doc-comment of this parameter. Will be shown\nin the UI but can be omitted." + } + ], + "documentation": "Represents a parameter of a callable-signature. A parameter can\nhave a label and a doc-comment." + }, + { + "name": "CodeActionKindDocumentation", + "properties": [ + { + "name": "kind", + "type": { + "kind": "reference", + "name": "CodeActionKind" + }, + "documentation": "The kind of the code action being documented.\n\nIf the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any\nrefactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the\ndocumentation will only be shown when extract refactoring code actions are returned." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "documentation": "Command that is ued to display the documentation to the user.\n\nThe title of this documentation code action is taken from {@linkcode Command.title}" + } + ], + "documentation": "Documentation for a class of code actions.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "NotebookCellTextDocumentFilter", + "properties": [ + { + "name": "notebook", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "NotebookDocumentFilter" + } + ] + }, + "documentation": "A filter that matches against the notebook\ncontaining the notebook cell. If a string\nvalue is provided it matches against the\nnotebook type. '*' matches every notebook." + }, + { + "name": "language", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A language id like `python`.\n\nWill be matched against the language id of the\nnotebook cell document. '*' matches every language." + } + ], + "documentation": "A notebook cell text document filter denotes a cell text\ndocument by different properties.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "FileOperationPatternOptions", + "properties": [ + { + "name": "ignoreCase", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The pattern should be matched ignoring casing." + } + ], + "documentation": "Matching options for the file operation pattern.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "ExecutionSummary", + "properties": [ + { + "name": "executionOrder", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "A strict monotonically increasing value\nindicating the execution order of a cell\ninside a notebook." + }, + { + "name": "success", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the execution was successful or\nnot if known by the client." + } + ] + }, + { + "name": "NotebookCellLanguage", + "properties": [ + { + "name": "language", + "type": { + "kind": "base", + "name": "string" + } + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "NotebookDocumentCellChangeStructure", + "properties": [ + { + "name": "array", + "type": { + "kind": "reference", + "name": "NotebookCellArrayChange" + }, + "documentation": "The change to the cell array." + }, + { + "name": "didOpen", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextDocumentItem" + } + }, + "optional": true, + "documentation": "Additional opened cell text documents." + }, + { + "name": "didClose", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextDocumentIdentifier" + } + }, + "optional": true, + "documentation": "Additional closed cell text documents." + } + ], + "documentation": "Structural changes to cells in a notebook document.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "NotebookDocumentCellContentChanges", + "properties": [ + { + "name": "document", + "type": { + "kind": "reference", + "name": "VersionedTextDocumentIdentifier" + } + }, + { + "name": "changes", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TextDocumentContentChangeEvent" + } + } + } + ], + "documentation": "Content changes to a cell in a notebook document.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "WorkspaceClientCapabilities", + "properties": [ + { + "name": "applyEdit", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports applying batch edits\nto the workspace by supporting the request\n'workspace/applyEdit'" + }, + { + "name": "workspaceEdit", + "type": { + "kind": "reference", + "name": "WorkspaceEditClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to `WorkspaceEdit`s." + }, + { + "name": "didChangeConfiguration", + "type": { + "kind": "reference", + "name": "DidChangeConfigurationClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `workspace/didChangeConfiguration` notification." + }, + { + "name": "didChangeWatchedFiles", + "type": { + "kind": "reference", + "name": "DidChangeWatchedFilesClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `workspace/didChangeWatchedFiles` notification." + }, + { + "name": "symbol", + "type": { + "kind": "reference", + "name": "WorkspaceSymbolClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `workspace/symbol` request." + }, + { + "name": "executeCommand", + "type": { + "kind": "reference", + "name": "ExecuteCommandClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `workspace/executeCommand` request." + }, + { + "name": "workspaceFolders", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client has support for workspace folders.\n\n@since 3.6.0", + "since": "3.6.0" + }, + { + "name": "configuration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports `workspace/configuration` requests.\n\n@since 3.6.0", + "since": "3.6.0" + }, + { + "name": "semanticTokens", + "type": { + "kind": "reference", + "name": "SemanticTokensWorkspaceClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the semantic token requests scoped to the\nworkspace.\n\n@since 3.16.0.", + "since": "3.16.0." + }, + { + "name": "codeLens", + "type": { + "kind": "reference", + "name": "CodeLensWorkspaceClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the code lens requests scoped to the\nworkspace.\n\n@since 3.16.0.", + "since": "3.16.0." + }, + { + "name": "fileOperations", + "type": { + "kind": "reference", + "name": "FileOperationClientCapabilities" + }, + "optional": true, + "documentation": "The client has support for file notifications/requests for user operations on files.\n\nSince 3.16.0" + }, + { + "name": "inlineValue", + "type": { + "kind": "reference", + "name": "InlineValueWorkspaceClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the inline values requests scoped to the\nworkspace.\n\n@since 3.17.0.", + "since": "3.17.0." + }, + { + "name": "inlayHint", + "type": { + "kind": "reference", + "name": "InlayHintWorkspaceClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the inlay hint requests scoped to the\nworkspace.\n\n@since 3.17.0.", + "since": "3.17.0." + }, + { + "name": "diagnostics", + "type": { + "kind": "reference", + "name": "DiagnosticWorkspaceClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the diagnostic requests scoped to the\nworkspace.\n\n@since 3.17.0.", + "since": "3.17.0." + }, + { + "name": "foldingRange", + "type": { + "kind": "reference", + "name": "FoldingRangeWorkspaceClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the folding range requests scoped to the workspace.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "textDocumentContent", + "type": { + "kind": "reference", + "name": "TextDocumentContentClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `workspace/textDocumentContent` request.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ], + "documentation": "Workspace specific client capabilities." + }, + { + "name": "TextDocumentClientCapabilities", + "properties": [ + { + "name": "synchronization", + "type": { + "kind": "reference", + "name": "TextDocumentSyncClientCapabilities" + }, + "optional": true, + "documentation": "Defines which synchronization capabilities the client supports." + }, + { + "name": "completion", + "type": { + "kind": "reference", + "name": "CompletionClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/completion` request." + }, + { + "name": "hover", + "type": { + "kind": "reference", + "name": "HoverClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/hover` request." + }, + { + "name": "signatureHelp", + "type": { + "kind": "reference", + "name": "SignatureHelpClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/signatureHelp` request." + }, + { + "name": "declaration", + "type": { + "kind": "reference", + "name": "DeclarationClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/declaration` request.\n\n@since 3.14.0", + "since": "3.14.0" + }, + { + "name": "definition", + "type": { + "kind": "reference", + "name": "DefinitionClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/definition` request." + }, + { + "name": "typeDefinition", + "type": { + "kind": "reference", + "name": "TypeDefinitionClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/typeDefinition` request.\n\n@since 3.6.0", + "since": "3.6.0" + }, + { + "name": "implementation", + "type": { + "kind": "reference", + "name": "ImplementationClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/implementation` request.\n\n@since 3.6.0", + "since": "3.6.0" + }, + { + "name": "references", + "type": { + "kind": "reference", + "name": "ReferenceClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/references` request." + }, + { + "name": "documentHighlight", + "type": { + "kind": "reference", + "name": "DocumentHighlightClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/documentHighlight` request." + }, + { + "name": "documentSymbol", + "type": { + "kind": "reference", + "name": "DocumentSymbolClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/documentSymbol` request." + }, + { + "name": "codeAction", + "type": { + "kind": "reference", + "name": "CodeActionClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/codeAction` request." + }, + { + "name": "codeLens", + "type": { + "kind": "reference", + "name": "CodeLensClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/codeLens` request." + }, + { + "name": "documentLink", + "type": { + "kind": "reference", + "name": "DocumentLinkClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/documentLink` request." + }, + { + "name": "colorProvider", + "type": { + "kind": "reference", + "name": "DocumentColorClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/documentColor` and the\n`textDocument/colorPresentation` request.\n\n@since 3.6.0", + "since": "3.6.0" + }, + { + "name": "formatting", + "type": { + "kind": "reference", + "name": "DocumentFormattingClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/formatting` request." + }, + { + "name": "rangeFormatting", + "type": { + "kind": "reference", + "name": "DocumentRangeFormattingClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/rangeFormatting` request." + }, + { + "name": "onTypeFormatting", + "type": { + "kind": "reference", + "name": "DocumentOnTypeFormattingClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/onTypeFormatting` request." + }, + { + "name": "rename", + "type": { + "kind": "reference", + "name": "RenameClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/rename` request." + }, + { + "name": "foldingRange", + "type": { + "kind": "reference", + "name": "FoldingRangeClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/foldingRange` request.\n\n@since 3.10.0", + "since": "3.10.0" + }, + { + "name": "selectionRange", + "type": { + "kind": "reference", + "name": "SelectionRangeClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/selectionRange` request.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "publishDiagnostics", + "type": { + "kind": "reference", + "name": "PublishDiagnosticsClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/publishDiagnostics` notification." + }, + { + "name": "callHierarchy", + "type": { + "kind": "reference", + "name": "CallHierarchyClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the various call hierarchy requests.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "semanticTokens", + "type": { + "kind": "reference", + "name": "SemanticTokensClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the various semantic token request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "linkedEditingRange", + "type": { + "kind": "reference", + "name": "LinkedEditingRangeClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/linkedEditingRange` request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "moniker", + "type": { + "kind": "reference", + "name": "MonikerClientCapabilities" + }, + "optional": true, + "documentation": "Client capabilities specific to the `textDocument/moniker` request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "typeHierarchy", + "type": { + "kind": "reference", + "name": "TypeHierarchyClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the various type hierarchy requests.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "inlineValue", + "type": { + "kind": "reference", + "name": "InlineValueClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/inlineValue` request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "inlayHint", + "type": { + "kind": "reference", + "name": "InlayHintClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/inlayHint` request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "diagnostic", + "type": { + "kind": "reference", + "name": "DiagnosticClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the diagnostic pull model.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "inlineCompletion", + "type": { + "kind": "reference", + "name": "InlineCompletionClientCapabilities" + }, + "optional": true, + "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ], + "documentation": "Text document specific client capabilities." + }, + { + "name": "NotebookDocumentClientCapabilities", + "properties": [ + { + "name": "synchronization", + "type": { + "kind": "reference", + "name": "NotebookDocumentSyncClientCapabilities" + }, + "documentation": "Capabilities specific to notebook document synchronization\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "Capabilities specific to the notebook document support.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "WindowClientCapabilities", + "properties": [ + { + "name": "workDoneProgress", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "It indicates whether the client supports server initiated\nprogress using the `window/workDoneProgress/create` request.\n\nThe capability also controls Whether client supports handling\nof progress notifications. If set servers are allowed to report a\n`workDoneProgress` property in the request specific server\ncapabilities.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "showMessage", + "type": { + "kind": "reference", + "name": "ShowMessageRequestClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the showMessage request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "showDocument", + "type": { + "kind": "reference", + "name": "ShowDocumentClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the showDocument request.\n\n@since 3.16.0", + "since": "3.16.0" + } + ] + }, + { + "name": "GeneralClientCapabilities", + "properties": [ + { + "name": "staleRequestSupport", + "type": { + "kind": "reference", + "name": "StaleRequestSupportOptions" + }, + "optional": true, + "documentation": "Client capability that signals how the client\nhandles stale requests (e.g. a request\nfor which the client will not process the response\nanymore since the information is outdated).\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "regularExpressions", + "type": { + "kind": "reference", + "name": "RegularExpressionsClientCapabilities" + }, + "optional": true, + "documentation": "Client capabilities specific to regular expressions.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "markdown", + "type": { + "kind": "reference", + "name": "MarkdownClientCapabilities" + }, + "optional": true, + "documentation": "Client capabilities specific to the client's markdown parser.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "positionEncodings", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "PositionEncodingKind" + } + }, + "optional": true, + "documentation": "The position encodings supported by the client. Client and server\nhave to agree on the same position encoding to ensure that offsets\n(e.g. character position in a line) are interpreted the same on both\nsides.\n\nTo keep the protocol backwards compatible the following applies: if\nthe value 'utf-16' is missing from the array of position encodings\nservers can assume that the client supports UTF-16. UTF-16 is\ntherefore a mandatory encoding.\n\nIf omitted it defaults to ['utf-16'].\n\nImplementation considerations: since the conversion from one encoding\ninto another requires the content of the file / line the conversion\nis best done where the file is read which is usually on the server\nside.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "General client capabilities.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "WorkspaceFoldersServerCapabilities", + "properties": [ + { + "name": "supported", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The server has support for workspace folders" + }, + { + "name": "changeNotifications", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "base", + "name": "boolean" + } + ] + }, + "optional": true, + "documentation": "Whether the server wants to receive workspace folder\nchange notifications.\n\nIf a string is provided the string is treated as an ID\nunder which the notification is registered on the client\nside. The ID can be used to unregister for these events\nusing the `client/unregisterCapability` request." + } + ] + }, + { + "name": "FileOperationOptions", + "properties": [ + { + "name": "didCreate", + "type": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "optional": true, + "documentation": "The server is interested in receiving didCreateFiles notifications." + }, + { + "name": "willCreate", + "type": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "optional": true, + "documentation": "The server is interested in receiving willCreateFiles requests." + }, + { + "name": "didRename", + "type": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "optional": true, + "documentation": "The server is interested in receiving didRenameFiles notifications." + }, + { + "name": "willRename", + "type": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "optional": true, + "documentation": "The server is interested in receiving willRenameFiles requests." + }, + { + "name": "didDelete", + "type": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "optional": true, + "documentation": "The server is interested in receiving didDeleteFiles file notifications." + }, + { + "name": "willDelete", + "type": { + "kind": "reference", + "name": "FileOperationRegistrationOptions" + }, + "optional": true, + "documentation": "The server is interested in receiving willDeleteFiles file requests." + } + ], + "documentation": "Options for notifications/requests for user operations on files.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "RelativePattern", + "properties": [ + { + "name": "baseUri", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "WorkspaceFolder" + }, + { + "kind": "base", + "name": "URI" + } + ] + }, + "documentation": "A workspace folder or a base URI to which this pattern will be matched\nagainst relatively." + }, + { + "name": "pattern", + "type": { + "kind": "reference", + "name": "Pattern" + }, + "documentation": "The actual glob pattern;" + } + ], + "documentation": "A relative pattern is a helper to construct glob patterns that are matched\nrelatively to a base URI. The common value for a `baseUri` is a workspace\nfolder root, but it can be another absolute URI as well.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "TextDocumentFilterLanguage", + "properties": [ + { + "name": "language", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A language id, like `typescript`." + }, + { + "name": "scheme", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." + }, + { + "name": "pattern", + "type": { + "kind": "reference", + "name": "GlobPattern" + }, + "optional": true, + "documentation": "A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.\n\n@since 3.18.0 - support for relative patterns.", + "since": "3.18.0 - support for relative patterns." + } + ], + "documentation": "A document filter where `language` is required field.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "TextDocumentFilterScheme", + "properties": [ + { + "name": "language", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A language id, like `typescript`." + }, + { + "name": "scheme", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." + }, + { + "name": "pattern", + "type": { + "kind": "reference", + "name": "GlobPattern" + }, + "optional": true, + "documentation": "A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.\n\n@since 3.18.0 - support for relative patterns.", + "since": "3.18.0 - support for relative patterns." + } + ], + "documentation": "A document filter where `scheme` is required field.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "TextDocumentFilterPattern", + "properties": [ + { + "name": "language", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A language id, like `typescript`." + }, + { + "name": "scheme", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." + }, + { + "name": "pattern", + "type": { + "kind": "reference", + "name": "GlobPattern" + }, + "documentation": "A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.\n\n@since 3.18.0 - support for relative patterns.", + "since": "3.18.0 - support for relative patterns." + } + ], + "documentation": "A document filter where `pattern` is required field.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "NotebookDocumentFilterNotebookType", + "properties": [ + { + "name": "notebookType", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The type of the enclosing notebook." + }, + { + "name": "scheme", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." + }, + { + "name": "pattern", + "type": { + "kind": "reference", + "name": "GlobPattern" + }, + "optional": true, + "documentation": "A glob pattern." + } + ], + "documentation": "A notebook document filter where `notebookType` is required field.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "NotebookDocumentFilterScheme", + "properties": [ + { + "name": "notebookType", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The type of the enclosing notebook." + }, + { + "name": "scheme", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." + }, + { + "name": "pattern", + "type": { + "kind": "reference", + "name": "GlobPattern" + }, + "optional": true, + "documentation": "A glob pattern." + } + ], + "documentation": "A notebook document filter where `scheme` is required field.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "NotebookDocumentFilterPattern", + "properties": [ + { + "name": "notebookType", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The type of the enclosing notebook." + }, + { + "name": "scheme", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A Uri {@link Uri.scheme scheme}, like `file` or `untitled`." + }, + { + "name": "pattern", + "type": { + "kind": "reference", + "name": "GlobPattern" + }, + "documentation": "A glob pattern." + } + ], + "documentation": "A notebook document filter where `pattern` is required field.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "NotebookCellArrayChange", + "properties": [ + { + "name": "start", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "The start oftest of the cell that changed." + }, + { + "name": "deleteCount", + "type": { + "kind": "base", + "name": "uinteger" + }, + "documentation": "The deleted cells" + }, + { + "name": "cells", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "NotebookCell" + } + }, + "optional": true, + "documentation": "The new cells, if any" + } + ], + "documentation": "A change describing how to move a `NotebookCell`\narray from state S to S'.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "WorkspaceEditClientCapabilities", + "properties": [ + { + "name": "documentChanges", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports versioned document changes in `WorkspaceEdit`s" + }, + { + "name": "resourceOperations", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "ResourceOperationKind" + } + }, + "optional": true, + "documentation": "The resource operations the client supports. Clients should at least\nsupport 'create', 'rename' and 'delete' files and folders.\n\n@since 3.13.0", + "since": "3.13.0" + }, + { + "name": "failureHandling", + "type": { + "kind": "reference", + "name": "FailureHandlingKind" + }, + "optional": true, + "documentation": "The failure handling strategy of a client if applying the workspace edit\nfails.\n\n@since 3.13.0", + "since": "3.13.0" + }, + { + "name": "normalizesLineEndings", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client normalizes line endings to the client specific\nsetting.\nIf set to `true` the client will normalize line ending characters\nin a workspace edit to the client-specified new line\ncharacter.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "changeAnnotationSupport", + "type": { + "kind": "reference", + "name": "ChangeAnnotationsSupportOptions" + }, + "optional": true, + "documentation": "Whether the client in general supports change annotations on text edits,\ncreate file, rename file and delete file changes.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "metadataSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client supports `WorkspaceEditMetadata` in `WorkspaceEdit`s.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "snippetEditSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client supports snippets as text edits.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ] + }, + { + "name": "DidChangeConfigurationClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Did change configuration notification supports dynamic registration." + } + ] + }, + { + "name": "DidChangeWatchedFilesClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Did change watched files notification supports dynamic registration. Please note\nthat the current protocol doesn't support static configuration for file changes\nfrom the server side." + }, + { + "name": "relativePatternSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client has support for {@link RelativePattern relative pattern}\nor not.\n\n@since 3.17.0", + "since": "3.17.0" + } + ] + }, + { + "name": "WorkspaceSymbolClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Symbol request supports dynamic registration." + }, + { + "name": "symbolKind", + "type": { + "kind": "reference", + "name": "ClientSymbolKindOptions" + }, + "optional": true, + "documentation": "Specific capabilities for the `SymbolKind` in the `workspace/symbol` request." + }, + { + "name": "tagSupport", + "type": { + "kind": "reference", + "name": "ClientSymbolTagOptions" + }, + "optional": true, + "documentation": "The client supports tags on `SymbolInformation`.\nClients supporting tags have to handle unknown tags gracefully.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "resolveSupport", + "type": { + "kind": "reference", + "name": "ClientSymbolResolveOptions" + }, + "optional": true, + "documentation": "The client support partial workspace symbols. The client will send the\nrequest `workspaceSymbol/resolve` to the server to resolve additional\nproperties.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "Client capabilities for a {@link WorkspaceSymbolRequest}." + }, + { + "name": "ExecuteCommandClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Execute command supports dynamic registration." + } + ], + "documentation": "The client capabilities of a {@link ExecuteCommandRequest}." + }, + { + "name": "SemanticTokensWorkspaceClientCapabilities", + "properties": [ + { + "name": "refreshSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\nsemantic tokens currently shown. It should be used with absolute care\nand is useful for situation where a server for example detects a project\nwide change that requires such a calculation." + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "CodeLensWorkspaceClientCapabilities", + "properties": [ + { + "name": "refreshSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ncode lenses currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detect a project wide\nchange that requires such a calculation." + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "FileOperationClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client supports dynamic registration for file requests/notifications." + }, + { + "name": "didCreate", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client has support for sending didCreateFiles notifications." + }, + { + "name": "willCreate", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client has support for sending willCreateFiles requests." + }, + { + "name": "didRename", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client has support for sending didRenameFiles notifications." + }, + { + "name": "willRename", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client has support for sending willRenameFiles requests." + }, + { + "name": "didDelete", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client has support for sending didDeleteFiles notifications." + }, + { + "name": "willDelete", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client has support for sending willDeleteFiles requests." + } + ], + "documentation": "Capabilities relating to events from file operations by the user in the client.\n\nThese events do not come from the file system, they come from user operations\nlike renaming a file in the UI.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "InlineValueWorkspaceClientCapabilities", + "properties": [ + { + "name": "refreshSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ninline values currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detects a project wide\nchange that requires such a calculation." + } + ], + "documentation": "Client workspace capabilities specific to inline values.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlayHintWorkspaceClientCapabilities", + "properties": [ + { + "name": "refreshSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\ninlay hints currently shown. It should be used with absolute care and\nis useful for situation where a server for example detects a project wide\nchange that requires such a calculation." + } + ], + "documentation": "Client workspace capabilities specific to inlay hints.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DiagnosticWorkspaceClientCapabilities", + "properties": [ + { + "name": "refreshSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\npulled diagnostics currently shown. It should be used with absolute care and\nis useful for situation where a server for example detects a project wide\nchange that requires such a calculation." + } + ], + "documentation": "Workspace client capabilities specific to diagnostic pull requests.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "FoldingRangeWorkspaceClientCapabilities", + "properties": [ + { + "name": "refreshSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\nfolding ranges currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detects a project wide\nchange that requires such a calculation.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ], + "documentation": "Client workspace capabilities specific to folding ranges\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "TextDocumentContentClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Text document content provider supports dynamic registration." + } + ], + "documentation": "Client capabilities for a text document content provider.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "TextDocumentSyncClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether text document synchronization supports dynamic registration." + }, + { + "name": "willSave", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports sending will save notifications." + }, + { + "name": "willSaveWaitUntil", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports sending a will save request and\nwaits for a response providing text edits which will\nbe applied to the document before it is saved." + }, + { + "name": "didSave", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports did save notifications." + } + ] + }, + { + "name": "CompletionClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether completion supports dynamic registration." + }, + { + "name": "completionItem", + "type": { + "kind": "reference", + "name": "ClientCompletionItemOptions" + }, + "optional": true, + "documentation": "The client supports the following `CompletionItem` specific\ncapabilities." + }, + { + "name": "completionItemKind", + "type": { + "kind": "reference", + "name": "ClientCompletionItemOptionsKind" + }, + "optional": true + }, + { + "name": "insertTextMode", + "type": { + "kind": "reference", + "name": "InsertTextMode" + }, + "optional": true, + "documentation": "Defines how the client handles whitespace and indentation\nwhen accepting a completion item that uses multi line\ntext in either `insertText` or `textEdit`.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "contextSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports to send additional context information for a\n`textDocument/completion` request." + }, + { + "name": "completionList", + "type": { + "kind": "reference", + "name": "CompletionListCapabilities" + }, + "optional": true, + "documentation": "The client supports the following `CompletionList` specific\ncapabilities.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "Completion client capabilities" + }, + { + "name": "HoverClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether hover supports dynamic registration." + }, + { + "name": "contentFormat", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "MarkupKind" + } + }, + "optional": true, + "documentation": "Client supports the following content formats for the content\nproperty. The order describes the preferred format of the client." + } + ] + }, + { + "name": "SignatureHelpClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether signature help supports dynamic registration." + }, + { + "name": "signatureInformation", + "type": { + "kind": "reference", + "name": "ClientSignatureInformationOptions" + }, + "optional": true, + "documentation": "The client supports the following `SignatureInformation`\nspecific properties." + }, + { + "name": "contextSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports to send additional context information for a\n`textDocument/signatureHelp` request. A client that opts into\ncontextSupport will also support the `retriggerCharacters` on\n`SignatureHelpOptions`.\n\n@since 3.15.0", + "since": "3.15.0" + } + ], + "documentation": "Client Capabilities for a {@link SignatureHelpRequest}." + }, + { + "name": "DeclarationClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether declaration supports dynamic registration. If this is set to `true`\nthe client supports the new `DeclarationRegistrationOptions` return value\nfor the corresponding server capability as well." + }, + { + "name": "linkSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports additional metadata in the form of declaration links." + } + ], + "documentation": "@since 3.14.0", + "since": "3.14.0" + }, + { + "name": "DefinitionClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether definition supports dynamic registration." + }, + { + "name": "linkSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports additional metadata in the form of definition links.\n\n@since 3.14.0", + "since": "3.14.0" + } + ], + "documentation": "Client Capabilities for a {@link DefinitionRequest}." + }, + { + "name": "TypeDefinitionClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `TypeDefinitionRegistrationOptions` return value\nfor the corresponding server capability as well." + }, + { + "name": "linkSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports additional metadata in the form of definition links.\n\nSince 3.14.0" + } + ], + "documentation": "Since 3.6.0" + }, + { + "name": "ImplementationClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `ImplementationRegistrationOptions` return value\nfor the corresponding server capability as well." + }, + { + "name": "linkSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports additional metadata in the form of definition links.\n\n@since 3.14.0", + "since": "3.14.0" + } + ], + "documentation": "@since 3.6.0", + "since": "3.6.0" + }, + { + "name": "ReferenceClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether references supports dynamic registration." + } + ], + "documentation": "Client Capabilities for a {@link ReferencesRequest}." + }, + { + "name": "DocumentHighlightClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether document highlight supports dynamic registration." + } + ], + "documentation": "Client Capabilities for a {@link DocumentHighlightRequest}." + }, + { + "name": "DocumentSymbolClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether document symbol supports dynamic registration." + }, + { + "name": "symbolKind", + "type": { + "kind": "reference", + "name": "ClientSymbolKindOptions" + }, + "optional": true, + "documentation": "Specific capabilities for the `SymbolKind` in the\n`textDocument/documentSymbol` request." + }, + { + "name": "hierarchicalDocumentSymbolSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports hierarchical document symbols." + }, + { + "name": "tagSupport", + "type": { + "kind": "reference", + "name": "ClientSymbolTagOptions" + }, + "optional": true, + "documentation": "The client supports tags on `SymbolInformation`. Tags are supported on\n`DocumentSymbol` if `hierarchicalDocumentSymbolSupport` is set to true.\nClients supporting tags have to handle unknown tags gracefully.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "labelSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports an additional label presented in the UI when\nregistering a document symbol provider.\n\n@since 3.16.0", + "since": "3.16.0" + } + ], + "documentation": "Client Capabilities for a {@link DocumentSymbolRequest}." + }, + { + "name": "CodeActionClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether code action supports dynamic registration." + }, + { + "name": "codeActionLiteralSupport", + "type": { + "kind": "reference", + "name": "ClientCodeActionLiteralOptions" + }, + "optional": true, + "documentation": "The client support code action literals of type `CodeAction` as a valid\nresponse of the `textDocument/codeAction` request. If the property is not\nset the request can only return `Command` literals.\n\n@since 3.8.0", + "since": "3.8.0" + }, + { + "name": "isPreferredSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether code action supports the `isPreferred` property.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "disabledSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether code action supports the `disabled` property.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "dataSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether code action supports the `data` property which is\npreserved between a `textDocument/codeAction` and a\n`codeAction/resolve` request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "resolveSupport", + "type": { + "kind": "reference", + "name": "ClientCodeActionResolveOptions" + }, + "optional": true, + "documentation": "Whether the client supports resolving additional code action\nproperties via a separate `codeAction/resolve` request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "honorsChangeAnnotations", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\n`CodeAction#edit` property by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "documentationSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client supports documentation for a class of\ncode actions.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "tagSupport", + "type": { + "kind": "reference", + "name": "CodeActionTagOptions" + }, + "optional": true, + "documentation": "Client supports the tag property on a code action. Clients\nsupporting tags have to handle unknown tags gracefully.\n\n@since 3.18.0 - proposed", + "since": "3.18.0 - proposed" + } + ], + "documentation": "The Client Capabilities of a {@link CodeActionRequest}." + }, + { + "name": "CodeLensClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether code lens supports dynamic registration." + }, + { + "name": "resolveSupport", + "type": { + "kind": "reference", + "name": "ClientCodeLensResolveOptions" + }, + "optional": true, + "documentation": "Whether the client supports resolving additional code lens\nproperties via a separate `codeLens/resolve` request.\n\n@since 3.18.0", + "since": "3.18.0" + } + ], + "documentation": "The client capabilities of a {@link CodeLensRequest}." + }, + { + "name": "DocumentLinkClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether document link supports dynamic registration." + }, + { + "name": "tooltipSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client supports the `tooltip` property on `DocumentLink`.\n\n@since 3.15.0", + "since": "3.15.0" + } + ], + "documentation": "The client capabilities of a {@link DocumentLinkRequest}." + }, + { + "name": "DocumentColorClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `DocumentColorRegistrationOptions` return value\nfor the corresponding server capability as well." + } + ] + }, + { + "name": "DocumentFormattingClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether formatting supports dynamic registration." + } + ], + "documentation": "Client capabilities of a {@link DocumentFormattingRequest}." + }, + { + "name": "DocumentRangeFormattingClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether range formatting supports dynamic registration." + }, + { + "name": "rangesSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client supports formatting multiple ranges at once.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ], + "documentation": "Client capabilities of a {@link DocumentRangeFormattingRequest}." + }, + { + "name": "DocumentOnTypeFormattingClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether on type formatting supports dynamic registration." + } + ], + "documentation": "Client capabilities of a {@link DocumentOnTypeFormattingRequest}." + }, + { + "name": "RenameClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether rename supports dynamic registration." + }, + { + "name": "prepareSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Client supports testing for validity of rename operations\nbefore execution.\n\n@since 3.12.0", + "since": "3.12.0" + }, + { + "name": "prepareSupportDefaultBehavior", + "type": { + "kind": "reference", + "name": "PrepareSupportDefaultBehavior" + }, + "optional": true, + "documentation": "Client supports the default behavior result.\n\nThe value indicates the default behavior used by the\nclient.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "honorsChangeAnnotations", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\nrename request's workspace edit by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", + "since": "3.16.0" + } + ] + }, + { + "name": "FoldingRangeClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration for folding range\nproviders. If this is set to `true` the client supports the new\n`FoldingRangeRegistrationOptions` return value for the corresponding\nserver capability as well." + }, + { + "name": "rangeLimit", + "type": { + "kind": "base", + "name": "uinteger" + }, + "optional": true, + "documentation": "The maximum number of folding ranges that the client prefers to receive\nper document. The value serves as a hint, servers are free to follow the\nlimit." + }, + { + "name": "lineFoldingOnly", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "If set, the client signals that it only supports folding complete lines.\nIf set, client will ignore specified `startCharacter` and `endCharacter`\nproperties in a FoldingRange." + }, + { + "name": "foldingRangeKind", + "type": { + "kind": "reference", + "name": "ClientFoldingRangeKindOptions" + }, + "optional": true, + "documentation": "Specific options for the folding range kind.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "foldingRange", + "type": { + "kind": "reference", + "name": "ClientFoldingRangeOptions" + }, + "optional": true, + "documentation": "Specific options for the folding range.\n\n@since 3.17.0", + "since": "3.17.0" + } + ] + }, + { + "name": "SelectionRangeClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration for selection range providers. If this is set to `true`\nthe client supports the new `SelectionRangeRegistrationOptions` return value for the corresponding server\ncapability as well." + } + ] + }, + { + "name": "PublishDiagnosticsClientCapabilities", + "properties": [ + { + "name": "versionSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client interprets the version property of the\n`textDocument/publishDiagnostics` notification's parameter.\n\n@since 3.15.0", + "since": "3.15.0" + } + ], + "extends": [ + { + "kind": "reference", + "name": "DiagnosticsCapabilities" + } + ], + "documentation": "The publish diagnostic client capabilities." + }, + { + "name": "CallHierarchyClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokensClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." + }, + { + "name": "requests", + "type": { + "kind": "reference", + "name": "ClientSemanticTokensRequestOptions" + }, + "documentation": "Which requests the client supports and might send to the server\ndepending on the server's capability. Please note that clients might not\nshow semantic tokens or degrade some of the user experience if a range\nor full request is advertised by the client but not provided by the\nserver. If for example the client capability `requests.full` and\n`request.range` are both set to true but the server only provides a\nrange provider the client might not render a minimap correctly or might\neven decide to not show any semantic tokens at all." + }, + { + "name": "tokenTypes", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The token types that the client supports." + }, + { + "name": "tokenModifiers", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The token modifiers that the client supports." + }, + { + "name": "formats", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "TokenFormat" + } + }, + "documentation": "The token formats the clients supports." + }, + { + "name": "overlappingTokenSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client supports tokens that can overlap each other." + }, + { + "name": "multilineTokenSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client supports tokens that can span multiple lines." + }, + { + "name": "serverCancelSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client allows the server to actively cancel a\nsemantic token request, e.g. supports returning\nLSPErrorCodes.ServerCancelled. If a server does the client\nneeds to retrigger the request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "augmentsSyntaxTokens", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client uses semantic tokens to augment existing\nsyntax tokens. If set to `true` client side created syntax\ntokens and semantic tokens are both used for colorization. If\nset to `false` the client only uses the returned semantic tokens\nfor colorization.\n\nIf the value is `undefined` then the client behavior is not\nspecified.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "LinkedEditingRangeClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." + } + ], + "documentation": "Client capabilities for the linked editing range request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "MonikerClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether moniker supports dynamic registration. If this is set to `true`\nthe client supports the new `MonikerRegistrationOptions` return value\nfor the corresponding server capability as well." + } + ], + "documentation": "Client capabilities specific to the moniker request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "TypeHierarchyClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." + } + ], + "documentation": "@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineValueClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration for inline value providers." + } + ], + "documentation": "Client capabilities specific to inline values.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlayHintClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether inlay hints support dynamic registration." + }, + { + "name": "resolveSupport", + "type": { + "kind": "reference", + "name": "ClientInlayHintResolveOptions" + }, + "optional": true, + "documentation": "Indicates which properties a client can resolve lazily on an inlay\nhint." + } + ], + "documentation": "Inlay hint client capabilities.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DiagnosticClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration. If this is set to `true`\nthe client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." + }, + { + "name": "relatedDocumentSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the clients supports related documents for document diagnostic pulls." + } + ], + "extends": [ + { + "kind": "reference", + "name": "DiagnosticsCapabilities" + } + ], + "documentation": "Client capabilities specific to diagnostic pull requests.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "InlineCompletionClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration for inline completion providers." + } + ], + "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "NotebookDocumentSyncClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration. If this is\nset to `true` the client supports the new\n`(TextDocumentRegistrationOptions & StaticRegistrationOptions)`\nreturn value for the corresponding server capability as well." + }, + { + "name": "executionSummarySupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports sending execution summary data per cell." + } + ], + "documentation": "Notebook specific client capabilities.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "ShowMessageRequestClientCapabilities", + "properties": [ + { + "name": "messageActionItem", + "type": { + "kind": "reference", + "name": "ClientShowMessageActionItemOptions" + }, + "optional": true, + "documentation": "Capabilities specific to the `MessageActionItem` type." + } + ], + "documentation": "Show message request client capabilities" + }, + { + "name": "ShowDocumentClientCapabilities", + "properties": [ + { + "name": "support", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "The client has support for the showDocument\nrequest." + } + ], + "documentation": "Client capabilities for the showDocument request.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "StaleRequestSupportOptions", + "properties": [ + { + "name": "cancel", + "type": { + "kind": "base", + "name": "boolean" + }, + "documentation": "The client will actively cancel the request." + }, + { + "name": "retryOnContentModified", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The list of requests for which the client\nwill retry the request if it receives a\nresponse with error code `ContentModified`" + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "RegularExpressionsClientCapabilities", + "properties": [ + { + "name": "engine", + "type": { + "kind": "reference", + "name": "RegularExpressionEngineKind" + }, + "documentation": "The engine's name." + }, + { + "name": "version", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The engine's version." + } + ], + "documentation": "Client capabilities specific to regular expressions.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "MarkdownClientCapabilities", + "properties": [ + { + "name": "parser", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The name of the parser." + }, + { + "name": "version", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "The version of the parser." + }, + { + "name": "allowedTags", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "optional": true, + "documentation": "A list of HTML tags that the client allows / supports in\nMarkdown.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "Client capabilities specific to the used markdown parser.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "ChangeAnnotationsSupportOptions", + "properties": [ + { + "name": "groupsOnLabel", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client groups edits with equal labels into tree nodes,\nfor instance all edits labelled with \"Changes in Strings\" would\nbe a tree node." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientSymbolKindOptions", + "properties": [ + { + "name": "valueSet", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolKind" + } + }, + "optional": true, + "documentation": "The symbol kind values the client supports. When this\nproperty exists the client also guarantees that it will\nhandle values outside its set gracefully and falls back\nto a default value when unknown.\n\nIf this property is not present the client only supports\nthe symbol kinds from `File` to `Array` as defined in\nthe initial version of the protocol." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientSymbolTagOptions", + "properties": [ + { + "name": "valueSet", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "SymbolTag" + } + }, + "documentation": "The tags supported by the client." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientSymbolResolveOptions", + "properties": [ + { + "name": "properties", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The properties that a client can resolve lazily. Usually\n`location.range`" + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientCompletionItemOptions", + "properties": [ + { + "name": "snippetSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Client supports snippets as insert text.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too." + }, + { + "name": "commitCharactersSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Client supports commit characters on a completion item." + }, + { + "name": "documentationFormat", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "MarkupKind" + } + }, + "optional": true, + "documentation": "Client supports the following content formats for the documentation\nproperty. The order describes the preferred format of the client." + }, + { + "name": "deprecatedSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Client supports the deprecated property on a completion item." + }, + { + "name": "preselectSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Client supports the preselect property on a completion item." + }, + { + "name": "tagSupport", + "type": { + "kind": "reference", + "name": "CompletionItemTagOptions" + }, + "optional": true, + "documentation": "Client supports the tag property on a completion item. Clients supporting\ntags have to handle unknown tags gracefully. Clients especially need to\npreserve unknown tags when sending a completion item back to the server in\na resolve call.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "insertReplaceSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Client support insert replace edit to control different behavior if a\ncompletion item is inserted in the text or should replace text.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "resolveSupport", + "type": { + "kind": "reference", + "name": "ClientCompletionItemResolveOptions" + }, + "optional": true, + "documentation": "Indicates which properties a client can resolve lazily on a completion\nitem. Before version 3.16.0 only the predefined properties `documentation`\nand `details` could be resolved lazily.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "insertTextModeSupport", + "type": { + "kind": "reference", + "name": "ClientCompletionItemInsertTextModeOptions" + }, + "optional": true, + "documentation": "The client supports the `insertTextMode` property on\na completion item to override the whitespace handling mode\nas defined by the client (see `insertTextMode`).\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "labelDetailsSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client has support for completion item label\ndetails (see also `CompletionItemLabelDetails`).\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientCompletionItemOptionsKind", + "properties": [ + { + "name": "valueSet", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CompletionItemKind" + } + }, + "optional": true, + "documentation": "The completion item kind values the client supports. When this\nproperty exists the client also guarantees that it will\nhandle values outside its set gracefully and falls back\nto a default value when unknown.\n\nIf this property is not present the client only supports\nthe completion items kinds from `Text` to `Reference` as defined in\nthe initial version of the protocol." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "CompletionListCapabilities", + "properties": [ + { + "name": "itemDefaults", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "optional": true, + "documentation": "The client supports the following itemDefaults on\na completion list.\n\nThe value lists the supported property names of the\n`CompletionList.itemDefaults` object. If omitted\nno properties are supported.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "applyKindSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Specifies whether the client supports `CompletionList.applyKind` to\nindicate how supported values from `completionList.itemDefaults`\nand `completion` will be combined.\n\nIf a client supports `applyKind` it must support it for all fields\nthat it supports that are listed in `CompletionList.applyKind`. This\nmeans when clients add support for new/future fields in completion\nitems the MUST also support merge for them if those fields are\ndefined in `CompletionList.applyKind`.\n\n@since 3.18.0", + "since": "3.18.0" + } + ], + "documentation": "The client supports the following `CompletionList` specific\ncapabilities.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "ClientSignatureInformationOptions", + "properties": [ + { + "name": "documentationFormat", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "MarkupKind" + } + }, + "optional": true, + "documentation": "Client supports the following content formats for the documentation\nproperty. The order describes the preferred format of the client." + }, + { + "name": "parameterInformation", + "type": { + "kind": "reference", + "name": "ClientSignatureParameterInformationOptions" + }, + "optional": true, + "documentation": "Client capabilities specific to parameter information." + }, + { + "name": "activeParameterSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports the `activeParameter` property on `SignatureInformation`\nliteral.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "noActiveParameterSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports the `activeParameter` property on\n`SignatureHelp`/`SignatureInformation` being set to `null` to\nindicate that no parameter should be active.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientCodeActionLiteralOptions", + "properties": [ + { + "name": "codeActionKind", + "type": { + "kind": "reference", + "name": "ClientCodeActionKindOptions" + }, + "documentation": "The code action kind is support with the following value\nset." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientCodeActionResolveOptions", + "properties": [ + { + "name": "properties", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The properties that a client can resolve lazily." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "CodeActionTagOptions", + "properties": [ + { + "name": "valueSet", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CodeActionTag" + } + }, + "documentation": "The tags supported by the client." + } + ], + "documentation": "@since 3.18.0 - proposed", + "since": "3.18.0 - proposed" + }, + { + "name": "ClientCodeLensResolveOptions", + "properties": [ + { + "name": "properties", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The properties that a client can resolve lazily." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientFoldingRangeKindOptions", + "properties": [ + { + "name": "valueSet", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "FoldingRangeKind" + } + }, + "optional": true, + "documentation": "The folding range kind values the client supports. When this\nproperty exists the client also guarantees that it will\nhandle values outside its set gracefully and falls back\nto a default value when unknown." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientFoldingRangeOptions", + "properties": [ + { + "name": "collapsedText", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "If set, the client signals that it supports setting collapsedText on\nfolding ranges to display custom labels instead of the default text.\n\n@since 3.17.0", + "since": "3.17.0" + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "DiagnosticsCapabilities", + "properties": [ + { + "name": "relatedInformation", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the clients accepts diagnostics with related information." + }, + { + "name": "tagSupport", + "type": { + "kind": "reference", + "name": "ClientDiagnosticsTagOptions" + }, + "optional": true, + "documentation": "Client supports the tag property to provide meta data about a diagnostic.\nClients supporting tags have to handle unknown tags gracefully.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "codeDescriptionSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Client supports a codeDescription property\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "dataSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether code action supports the `data` property which is\npreserved between a `textDocument/publishDiagnostics` and\n`textDocument/codeAction` request.\n\n@since 3.16.0", + "since": "3.16.0" + } + ], + "documentation": "General diagnostics capabilities for pull and push model." + }, + { + "name": "ClientSemanticTokensRequestOptions", + "properties": [ + { + "name": "range", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "literal", + "value": { + "properties": [] + } + } + ] + }, + "optional": true, + "documentation": "The client will send the `textDocument/semanticTokens/range` request if\nthe server provides a corresponding handler." + }, + { + "name": "full", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "ClientSemanticTokensRequestFullDelta" + } + ] + }, + "optional": true, + "documentation": "The client will send the `textDocument/semanticTokens/full` request if\nthe server provides a corresponding handler." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientInlayHintResolveOptions", + "properties": [ + { + "name": "properties", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The properties that a client can resolve lazily." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientShowMessageActionItemOptions", + "properties": [ + { + "name": "additionalPropertiesSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether the client supports additional attributes which\nare preserved and send back to the server in the\nrequest's response." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "CompletionItemTagOptions", + "properties": [ + { + "name": "valueSet", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CompletionItemTag" + } + }, + "documentation": "The tags supported by the client." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientCompletionItemResolveOptions", + "properties": [ + { + "name": "properties", + "type": { + "kind": "array", + "element": { + "kind": "base", + "name": "string" + } + }, + "documentation": "The properties that a client can resolve lazily." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientCompletionItemInsertTextModeOptions", + "properties": [ + { + "name": "valueSet", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InsertTextMode" + } + } + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientSignatureParameterInformationOptions", + "properties": [ + { + "name": "labelOffsetSupport", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client supports processing label offsets instead of a\nsimple label string.\n\n@since 3.14.0", + "since": "3.14.0" + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientCodeActionKindOptions", + "properties": [ + { + "name": "valueSet", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "CodeActionKind" + } + }, + "documentation": "The code action kind values the client supports. When this\nproperty exists the client also guarantees that it will\nhandle values outside its set gracefully and falls back\nto a default value when unknown." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientDiagnosticsTagOptions", + "properties": [ + { + "name": "valueSet", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "DiagnosticTag" + } + }, + "documentation": "The tags supported by the client." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientSemanticTokensRequestFullDelta", + "properties": [ + { + "name": "delta", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "The client will send the `textDocument/semanticTokens/full/delta` request if\nthe server provides a corresponding handler." + } + ], + "documentation": "@since 3.18.0", + "since": "3.18.0" + } + ], + "enumerations": [ + { + "name": "SemanticTokenTypes", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "namespace", + "value": "namespace" + }, + { + "name": "type", + "value": "type", + "documentation": "Represents a generic type. Acts as a fallback for types which can't be mapped to\na specific type like class or enum." + }, + { + "name": "class", + "value": "class" + }, + { + "name": "enum", + "value": "enum" + }, + { + "name": "interface", + "value": "interface" + }, + { + "name": "struct", + "value": "struct" + }, + { + "name": "typeParameter", + "value": "typeParameter" + }, + { + "name": "parameter", + "value": "parameter" + }, + { + "name": "variable", + "value": "variable" + }, + { + "name": "property", + "value": "property" + }, + { + "name": "enumMember", + "value": "enumMember" + }, + { + "name": "event", + "value": "event" + }, + { + "name": "function", + "value": "function" + }, + { + "name": "method", + "value": "method" + }, + { + "name": "macro", + "value": "macro" + }, + { + "name": "keyword", + "value": "keyword" + }, + { + "name": "modifier", + "value": "modifier" + }, + { + "name": "comment", + "value": "comment" + }, + { + "name": "string", + "value": "string" + }, + { + "name": "number", + "value": "number" + }, + { + "name": "regexp", + "value": "regexp" + }, + { + "name": "operator", + "value": "operator" + }, + { + "name": "decorator", + "value": "decorator", + "documentation": "@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "label", + "value": "label", + "documentation": "@since 3.18.0", + "since": "3.18.0" + } + ], + "supportsCustomValues": true, + "documentation": "A set of predefined token types. This set is not fixed\nan clients can specify additional token types via the\ncorresponding client capabilities.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "SemanticTokenModifiers", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "declaration", + "value": "declaration" + }, + { + "name": "definition", + "value": "definition" + }, + { + "name": "readonly", + "value": "readonly" + }, + { + "name": "static", + "value": "static" + }, + { + "name": "deprecated", + "value": "deprecated" + }, + { + "name": "abstract", + "value": "abstract" + }, + { + "name": "async", + "value": "async" + }, + { + "name": "modification", + "value": "modification" + }, + { + "name": "documentation", + "value": "documentation" + }, + { + "name": "defaultLibrary", + "value": "defaultLibrary" + } + ], + "supportsCustomValues": true, + "documentation": "A set of predefined token modifiers. This set is not fixed\nan clients can specify additional token types via the\ncorresponding client capabilities.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "DocumentDiagnosticReportKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "Full", + "value": "full", + "documentation": "A diagnostic report with a full\nset of problems." + }, + { + "name": "Unchanged", + "value": "unchanged", + "documentation": "A report indicating that the last\nreturned report is still accurate." + } + ], + "documentation": "The document diagnostic report kinds.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "ErrorCodes", + "type": { + "kind": "base", + "name": "integer" + }, + "values": [ + { + "name": "ParseError", + "value": -32700 + }, + { + "name": "InvalidRequest", + "value": -32600 + }, + { + "name": "MethodNotFound", + "value": -32601 + }, + { + "name": "InvalidParams", + "value": -32602 + }, + { + "name": "InternalError", + "value": -32603 + }, + { + "name": "ServerNotInitialized", + "value": -32002, + "documentation": "Error code indicating that a server received a notification or\nrequest before the server has received the `initialize` request." + }, + { + "name": "UnknownErrorCode", + "value": -32001 + } + ], + "supportsCustomValues": true, + "documentation": "Predefined error codes." + }, + { + "name": "LSPErrorCodes", + "type": { + "kind": "base", + "name": "integer" + }, + "values": [ + { + "name": "RequestFailed", + "value": -32803, + "documentation": "A request failed but it was syntactically correct, e.g the\nmethod name was known and the parameters were valid. The error\nmessage should contain human readable information about why\nthe request failed.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "ServerCancelled", + "value": -32802, + "documentation": "The server cancelled the request. This error code should\nonly be used for requests that explicitly support being\nserver cancellable.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "ContentModified", + "value": -32801, + "documentation": "The server detected that the content of a document got\nmodified outside normal conditions. A server should\nNOT send this error code if it detects a content change\nin it unprocessed messages. The result even computed\non an older state might still be useful for the client.\n\nIf a client decides that a result is not of any use anymore\nthe client should cancel the request." + }, + { + "name": "RequestCancelled", + "value": -32800, + "documentation": "The client has canceled a request and a server has detected\nthe cancel." + } + ], + "supportsCustomValues": true + }, + { + "name": "FoldingRangeKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "Comment", + "value": "comment", + "documentation": "Folding range for a comment" + }, + { + "name": "Imports", + "value": "imports", + "documentation": "Folding range for an import or include" + }, + { + "name": "Region", + "value": "region", + "documentation": "Folding range for a region (e.g. `#region`)" + } + ], + "supportsCustomValues": true, + "documentation": "A set of predefined range kinds." + }, + { + "name": "SymbolKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "File", + "value": 1 + }, + { + "name": "Module", + "value": 2 + }, + { + "name": "Namespace", + "value": 3 + }, + { + "name": "Package", + "value": 4 + }, + { + "name": "Class", + "value": 5 + }, + { + "name": "Method", + "value": 6 + }, + { + "name": "Property", + "value": 7 + }, + { + "name": "Field", + "value": 8 + }, + { + "name": "Constructor", + "value": 9 + }, + { + "name": "Enum", + "value": 10 + }, + { + "name": "Interface", + "value": 11 + }, + { + "name": "Function", + "value": 12 + }, + { + "name": "Variable", + "value": 13 + }, + { + "name": "Constant", + "value": 14 + }, + { + "name": "String", + "value": 15 + }, + { + "name": "Number", + "value": 16 + }, + { + "name": "Boolean", + "value": 17 + }, + { + "name": "Array", + "value": 18 + }, + { + "name": "Object", + "value": 19 + }, + { + "name": "Key", + "value": 20 + }, + { + "name": "Null", + "value": 21 + }, + { + "name": "EnumMember", + "value": 22 + }, + { + "name": "Struct", + "value": 23 + }, + { + "name": "Event", + "value": 24 + }, + { + "name": "Operator", + "value": 25 + }, + { + "name": "TypeParameter", + "value": 26 + } + ], + "documentation": "A symbol kind." + }, + { + "name": "SymbolTag", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Deprecated", + "value": 1, + "documentation": "Render a symbol as obsolete, usually using a strike-out." + } + ], + "documentation": "Symbol tags are extra annotations that tweak the rendering of a symbol.\n\n@since 3.16", + "since": "3.16" + }, + { + "name": "UniquenessLevel", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "document", + "value": "document", + "documentation": "The moniker is only unique inside a document" + }, + { + "name": "project", + "value": "project", + "documentation": "The moniker is unique inside a project for which a dump got created" + }, + { + "name": "group", + "value": "group", + "documentation": "The moniker is unique inside the group to which a project belongs" + }, + { + "name": "scheme", + "value": "scheme", + "documentation": "The moniker is unique inside the moniker scheme." + }, + { + "name": "global", + "value": "global", + "documentation": "The moniker is globally unique" + } + ], + "documentation": "Moniker uniqueness level to define scope of the moniker.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "MonikerKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "import", + "value": "import", + "documentation": "The moniker represent a symbol that is imported into a project" + }, + { + "name": "export", + "value": "export", + "documentation": "The moniker represents a symbol that is exported from a project" + }, + { + "name": "local", + "value": "local", + "documentation": "The moniker represents a symbol that is local to a project (e.g. a local\nvariable of a function, a class not visible outside the project, ...)" + } + ], + "documentation": "The moniker kind.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "InlayHintKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Type", + "value": 1, + "documentation": "An inlay hint that for a type annotation." + }, + { + "name": "Parameter", + "value": 2, + "documentation": "An inlay hint that is for a parameter." + } + ], + "documentation": "Inlay hint kinds.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "MessageType", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Error", + "value": 1, + "documentation": "An error message." + }, + { + "name": "Warning", + "value": 2, + "documentation": "A warning message." + }, + { + "name": "Info", + "value": 3, + "documentation": "An information message." + }, + { + "name": "Log", + "value": 4, + "documentation": "A log message." + }, + { + "name": "Debug", + "value": 5, + "documentation": "A debug message.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + } + ], + "documentation": "The message type" + }, + { + "name": "TextDocumentSyncKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "None", + "value": 0, + "documentation": "Documents should not be synced at all." + }, + { + "name": "Full", + "value": 1, + "documentation": "Documents are synced by always sending the full content\nof the document." + }, + { + "name": "Incremental", + "value": 2, + "documentation": "Documents are synced by sending the full content on open.\nAfter that only incremental updates to the document are\nsend." + } + ], + "documentation": "Defines how the host (editor) should sync\ndocument changes to the language server." + }, + { + "name": "TextDocumentSaveReason", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Manual", + "value": 1, + "documentation": "Manually triggered, e.g. by the user pressing save, by starting debugging,\nor by an API call." + }, + { + "name": "AfterDelay", + "value": 2, + "documentation": "Automatic after a delay." + }, + { + "name": "FocusOut", + "value": 3, + "documentation": "When the editor lost focus." + } + ], + "documentation": "Represents reasons why a text document is saved." + }, + { + "name": "CompletionItemKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Text", + "value": 1 + }, + { + "name": "Method", + "value": 2 + }, + { + "name": "Function", + "value": 3 + }, + { + "name": "Constructor", + "value": 4 + }, + { + "name": "Field", + "value": 5 + }, + { + "name": "Variable", + "value": 6 + }, + { + "name": "Class", + "value": 7 + }, + { + "name": "Interface", + "value": 8 + }, + { + "name": "Module", + "value": 9 + }, + { + "name": "Property", + "value": 10 + }, + { + "name": "Unit", + "value": 11 + }, + { + "name": "Value", + "value": 12 + }, + { + "name": "Enum", + "value": 13 + }, + { + "name": "Keyword", + "value": 14 + }, + { + "name": "Snippet", + "value": 15 + }, + { + "name": "Color", + "value": 16 + }, + { + "name": "File", + "value": 17 + }, + { + "name": "Reference", + "value": 18 + }, + { + "name": "Folder", + "value": 19 + }, + { + "name": "EnumMember", + "value": 20 + }, + { + "name": "Constant", + "value": 21 + }, + { + "name": "Struct", + "value": 22 + }, + { + "name": "Event", + "value": 23 + }, + { + "name": "Operator", + "value": 24 + }, + { + "name": "TypeParameter", + "value": 25 + } + ], + "documentation": "The kind of a completion entry." + }, + { + "name": "CompletionItemTag", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Deprecated", + "value": 1, + "documentation": "Render a completion as obsolete, usually using a strike-out." + } + ], + "documentation": "Completion item tags are extra annotations that tweak the rendering of a completion\nitem.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "InsertTextFormat", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "PlainText", + "value": 1, + "documentation": "The primary text to be inserted is treated as a plain string." + }, + { + "name": "Snippet", + "value": 2, + "documentation": "The primary text to be inserted is treated as a snippet.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too.\n\nSee also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax" + } + ], + "documentation": "Defines whether the insert text in a completion item should be interpreted as\nplain text or a snippet." + }, + { + "name": "InsertTextMode", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "asIs", + "value": 1, + "documentation": "The insertion or replace strings is taken as it is. If the\nvalue is multi line the lines below the cursor will be\ninserted using the indentation defined in the string value.\nThe client will not apply any kind of adjustments to the\nstring." + }, + { + "name": "adjustIndentation", + "value": 2, + "documentation": "The editor adjusts leading whitespace of new lines so that\nthey match the indentation up to the cursor of the line for\nwhich the item is accepted.\n\nConsider a line like this: <2tabs><3tabs>foo. Accepting a\nmulti line completion item is indented using 2 tabs and all\nfollowing lines inserted will be indented using 2 tabs as well." + } + ], + "documentation": "How whitespace and indentation is handled during completion\nitem insertion.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "DocumentHighlightKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Text", + "value": 1, + "documentation": "A textual occurrence." + }, + { + "name": "Read", + "value": 2, + "documentation": "Read-access of a symbol, like reading a variable." + }, + { + "name": "Write", + "value": 3, + "documentation": "Write-access of a symbol, like writing to a variable." + } + ], + "documentation": "A document highlight kind." + }, + { + "name": "CodeActionKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "Empty", + "value": "", + "documentation": "Empty kind." + }, + { + "name": "QuickFix", + "value": "quickfix", + "documentation": "Base kind for quickfix actions: 'quickfix'" + }, + { + "name": "Refactor", + "value": "refactor", + "documentation": "Base kind for refactoring actions: 'refactor'" + }, + { + "name": "RefactorExtract", + "value": "refactor.extract", + "documentation": "Base kind for refactoring extraction actions: 'refactor.extract'\n\nExample extract actions:\n\n- Extract method\n- Extract function\n- Extract variable\n- Extract interface from class\n- ..." + }, + { + "name": "RefactorInline", + "value": "refactor.inline", + "documentation": "Base kind for refactoring inline actions: 'refactor.inline'\n\nExample inline actions:\n\n- Inline function\n- Inline variable\n- Inline constant\n- ..." + }, + { + "name": "RefactorMove", + "value": "refactor.move", + "documentation": "Base kind for refactoring move actions: `refactor.move`\n\nExample move actions:\n\n- Move a function to a new file\n- Move a property between classes\n- Move method to base class\n- ...\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "RefactorRewrite", + "value": "refactor.rewrite", + "documentation": "Base kind for refactoring rewrite actions: 'refactor.rewrite'\n\nExample rewrite actions:\n\n- Convert JavaScript function to class\n- Add or remove parameter\n- Encapsulate field\n- Make method static\n- Move method to base class\n- ..." + }, + { + "name": "Source", + "value": "source", + "documentation": "Base kind for source actions: `source`\n\nSource code actions apply to the entire file." + }, + { + "name": "SourceOrganizeImports", + "value": "source.organizeImports", + "documentation": "Base kind for an organize imports source action: `source.organizeImports`" + }, + { + "name": "SourceFixAll", + "value": "source.fixAll", + "documentation": "Base kind for auto-fix source actions: `source.fixAll`.\n\nFix all actions automatically fix errors that have a clear fix that do not require user input.\nThey should not suppress errors or perform unsafe fixes such as generating new types or classes.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "Notebook", + "value": "notebook", + "documentation": "Base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using\nthis should always begin with `notebook.`\n\n@since 3.18.0", + "since": "3.18.0" + } + ], + "supportsCustomValues": true, + "documentation": "A set of predefined code action kinds" + }, + { + "name": "CodeActionTag", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "LLMGenerated", + "value": 1, + "documentation": "Marks the code action as LLM-generated." + } + ], + "documentation": "Code action tags are extra annotations that tweak the behavior of a code action.\n\n@since 3.18.0 - proposed", + "since": "3.18.0 - proposed" + }, + { + "name": "TraceValue", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "Off", + "value": "off", + "documentation": "Turn tracing off." + }, + { + "name": "Messages", + "value": "messages", + "documentation": "Trace messages only." + }, + { + "name": "Verbose", + "value": "verbose", + "documentation": "Verbose message tracing." + } + ] + }, + { + "name": "MarkupKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "PlainText", + "value": "plaintext", + "documentation": "Plain text is supported as a content format" + }, + { + "name": "Markdown", + "value": "markdown", + "documentation": "Markdown is supported as a content format" + } + ], + "documentation": "Describes the content type that a client supports in various\nresult literals like `Hover`, `ParameterInfo` or `CompletionItem`.\n\nPlease note that `MarkupKinds` must not start with a `$`. This kinds\nare reserved for internal usage." + }, + { + "name": "LanguageKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "ABAP", + "value": "abap" + }, + { + "name": "WindowsBat", + "value": "bat" + }, + { + "name": "BibTeX", + "value": "bibtex" + }, + { + "name": "Clojure", + "value": "clojure" + }, + { + "name": "Coffeescript", + "value": "coffeescript" + }, + { + "name": "C", + "value": "c" + }, + { + "name": "CPP", + "value": "cpp" + }, + { + "name": "CSharp", + "value": "csharp" + }, + { + "name": "CSS", + "value": "css" + }, + { + "name": "D", + "value": "d", + "documentation": "@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "Delphi", + "value": "pascal", + "documentation": "@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "Diff", + "value": "diff" + }, + { + "name": "Dart", + "value": "dart" + }, + { + "name": "Dockerfile", + "value": "dockerfile" + }, + { + "name": "Elixir", + "value": "elixir" + }, + { + "name": "Erlang", + "value": "erlang" + }, + { + "name": "FSharp", + "value": "fsharp" + }, + { + "name": "GitCommit", + "value": "git-commit" + }, + { + "name": "GitRebase", + "value": "rebase" + }, + { + "name": "Go", + "value": "go" + }, + { + "name": "Groovy", + "value": "groovy" + }, + { + "name": "Handlebars", + "value": "handlebars" + }, + { + "name": "Haskell", + "value": "haskell" + }, + { + "name": "HTML", + "value": "html" + }, + { + "name": "Ini", + "value": "ini" + }, + { + "name": "Java", + "value": "java" + }, + { + "name": "JavaScript", + "value": "javascript" + }, + { + "name": "JavaScriptReact", + "value": "javascriptreact" + }, + { + "name": "JSON", + "value": "json" + }, + { + "name": "LaTeX", + "value": "latex" + }, + { + "name": "Less", + "value": "less" + }, + { + "name": "Lua", + "value": "lua" + }, + { + "name": "Makefile", + "value": "makefile" + }, + { + "name": "Markdown", + "value": "markdown" + }, + { + "name": "ObjectiveC", + "value": "objective-c" + }, + { + "name": "ObjectiveCPP", + "value": "objective-cpp" + }, + { + "name": "Pascal", + "value": "pascal", + "documentation": "@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "Perl", + "value": "perl" + }, + { + "name": "Perl6", + "value": "perl6" + }, + { + "name": "PHP", + "value": "php" + }, + { + "name": "Powershell", + "value": "powershell" + }, + { + "name": "Pug", + "value": "jade" + }, + { + "name": "Python", + "value": "python" + }, + { + "name": "R", + "value": "r" + }, + { + "name": "Razor", + "value": "razor" + }, + { + "name": "Ruby", + "value": "ruby" + }, + { + "name": "Rust", + "value": "rust" + }, + { + "name": "SCSS", + "value": "scss" + }, + { + "name": "SASS", + "value": "sass" + }, + { + "name": "Scala", + "value": "scala" + }, + { + "name": "ShaderLab", + "value": "shaderlab" + }, + { + "name": "ShellScript", + "value": "shellscript" + }, + { + "name": "SQL", + "value": "sql" + }, + { + "name": "Swift", + "value": "swift" + }, + { + "name": "TypeScript", + "value": "typescript" + }, + { + "name": "TypeScriptReact", + "value": "typescriptreact" + }, + { + "name": "TeX", + "value": "tex" + }, + { + "name": "VisualBasic", + "value": "vb" + }, + { + "name": "XML", + "value": "xml" + }, + { + "name": "XSL", + "value": "xsl" + }, + { + "name": "YAML", + "value": "yaml" + } + ], + "supportsCustomValues": true, + "documentation": "Predefined Language kinds\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "InlineCompletionTriggerKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Invoked", + "value": 1, + "documentation": "Completion was triggered explicitly by a user gesture." + }, + { + "name": "Automatic", + "value": 2, + "documentation": "Completion was triggered automatically while editing." + } + ], + "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true + }, + { + "name": "PositionEncodingKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "UTF8", + "value": "utf-8", + "documentation": "Character offsets count UTF-8 code units (e.g. bytes)." + }, + { + "name": "UTF16", + "value": "utf-16", + "documentation": "Character offsets count UTF-16 code units.\n\nThis is the default and must always be supported\nby servers" + }, + { + "name": "UTF32", + "value": "utf-32", + "documentation": "Character offsets count UTF-32 code units.\n\nImplementation note: these are the same as Unicode codepoints,\nso this `PositionEncodingKind` may also be used for an\nencoding-agnostic representation of character offsets." + } + ], + "supportsCustomValues": true, + "documentation": "A set of predefined position encoding kinds.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "FileChangeType", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Created", + "value": 1, + "documentation": "The file got created." + }, + { + "name": "Changed", + "value": 2, + "documentation": "The file got changed." + }, + { + "name": "Deleted", + "value": 3, + "documentation": "The file got deleted." + } + ], + "documentation": "The file event type" + }, + { + "name": "WatchKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Create", + "value": 1, + "documentation": "Interested in create events." + }, + { + "name": "Change", + "value": 2, + "documentation": "Interested in change events" + }, + { + "name": "Delete", + "value": 4, + "documentation": "Interested in delete events" + } + ], + "supportsCustomValues": true + }, + { + "name": "DiagnosticSeverity", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Error", + "value": 1, + "documentation": "Reports an error." + }, + { + "name": "Warning", + "value": 2, + "documentation": "Reports a warning." + }, + { + "name": "Information", + "value": 3, + "documentation": "Reports an information." + }, + { + "name": "Hint", + "value": 4, + "documentation": "Reports a hint." + } + ], + "documentation": "The diagnostic's severity." + }, + { + "name": "DiagnosticTag", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Unnecessary", + "value": 1, + "documentation": "Unused or unnecessary code.\n\nClients are allowed to render diagnostics with this tag faded out instead of having\nan error squiggle." + }, + { + "name": "Deprecated", + "value": 2, + "documentation": "Deprecated or obsolete code.\n\nClients are allowed to rendered diagnostics with this tag strike through." + } + ], + "documentation": "The diagnostic tags.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "CompletionTriggerKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Invoked", + "value": 1, + "documentation": "Completion was triggered by typing an identifier (24x7 code\ncomplete), manual invocation (e.g Ctrl+Space) or via API." + }, + { + "name": "TriggerCharacter", + "value": 2, + "documentation": "Completion was triggered by a trigger character specified by\nthe `triggerCharacters` properties of the `CompletionRegistrationOptions`." + }, + { + "name": "TriggerForIncompleteCompletions", + "value": 3, + "documentation": "Completion was re-triggered as current completion list is incomplete" + } + ], + "documentation": "How a completion was triggered" + }, + { + "name": "ApplyKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "Replace", + "value": "replace", + "documentation": "The value from the individual item (if provided and not `null`) will be\nused instead of the default." + }, + { + "name": "Merge", + "value": "merge", + "documentation": "The value from the item will be merged with the default.\n\nThe specific rules for mergeing values are defined against each field\nthat supports merging." + } + ], + "documentation": "Defines how values from a set of defaults and an individual item will be\nmerged.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "SignatureHelpTriggerKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Invoked", + "value": 1, + "documentation": "Signature help was invoked manually by the user or by a command." + }, + { + "name": "TriggerCharacter", + "value": 2, + "documentation": "Signature help was triggered by a trigger character." + }, + { + "name": "ContentChange", + "value": 3, + "documentation": "Signature help was triggered by the cursor moving or by the document content changing." + } + ], + "documentation": "How a signature help was triggered.\n\n@since 3.15.0", + "since": "3.15.0" + }, + { + "name": "CodeActionTriggerKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Invoked", + "value": 1, + "documentation": "Code actions were explicitly requested by the user or by an extension." + }, + { + "name": "Automatic", + "value": 2, + "documentation": "Code actions were requested automatically.\n\nThis typically happens when current selection in a file changes, but can\nalso be triggered when file content changes." + } + ], + "documentation": "The reason why code actions were requested.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "FileOperationPatternKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "file", + "value": "file", + "documentation": "The pattern matches a file only." + }, + { + "name": "folder", + "value": "folder", + "documentation": "The pattern matches a folder only." + } + ], + "documentation": "A pattern kind describing if a glob pattern matches a file a folder or\nboth.\n\n@since 3.16.0", + "since": "3.16.0" + }, + { + "name": "NotebookCellKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Markup", + "value": 1, + "documentation": "A markup-cell is formatted source that is used for display." + }, + { + "name": "Code", + "value": 2, + "documentation": "A code-cell is source code." + } + ], + "documentation": "A notebook cell kind.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "ResourceOperationKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "Create", + "value": "create", + "documentation": "Supports creating new files and folders." + }, + { + "name": "Rename", + "value": "rename", + "documentation": "Supports renaming existing files and folders." + }, + { + "name": "Delete", + "value": "delete", + "documentation": "Supports deleting existing files and folders." + } + ] + }, + { + "name": "FailureHandlingKind", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "Abort", + "value": "abort", + "documentation": "Applying the workspace change is simply aborted if one of the changes provided\nfails. All operations executed before the failing operation stay executed." + }, + { + "name": "Transactional", + "value": "transactional", + "documentation": "All operations are executed transactional. That means they either all\nsucceed or no changes at all are applied to the workspace." + }, + { + "name": "TextOnlyTransactional", + "value": "textOnlyTransactional", + "documentation": "If the workspace edit contains only textual file changes they are executed transactional.\nIf resource changes (create, rename or delete file) are part of the change the failure\nhandling strategy is abort." + }, + { + "name": "Undo", + "value": "undo", + "documentation": "The client tries to undo the operations already executed. But there is no\nguarantee that this is succeeding." + } + ] + }, + { + "name": "PrepareSupportDefaultBehavior", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Identifier", + "value": 1, + "documentation": "The client's default behavior is to select the identifier\naccording the to language's syntax rule." + } + ] + }, + { + "name": "TokenFormat", + "type": { + "kind": "base", + "name": "string" + }, + "values": [ + { + "name": "Relative", + "value": "relative" + } + ] + } + ], + "typeAliases": [ + { + "name": "Definition", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Location" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "Location" + } + } + ] + }, + "documentation": "The definition of a symbol represented as one or many {@link Location locations}.\nFor most programming languages there is only one location at which a symbol is\ndefined.\n\nServers should prefer returning `DefinitionLink` over `Definition` if supported\nby the client." + }, + { + "name": "DefinitionLink", + "type": { + "kind": "reference", + "name": "LocationLink" + }, + "documentation": "Information about where a symbol is defined.\n\nProvides additional metadata over normal {@link Location location} definitions, including the range of\nthe defining symbol" + }, + { + "name": "LSPArray", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "LSPAny" + } + }, + "documentation": "LSP arrays.\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "LSPAny", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "LSPObject" + }, + { + "kind": "reference", + "name": "LSPArray" + }, + { + "kind": "base", + "name": "string" + }, + { + "kind": "base", + "name": "integer" + }, + { + "kind": "base", + "name": "uinteger" + }, + { + "kind": "base", + "name": "decimal" + }, + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "documentation": "The LSP any type.\nPlease note that strictly speaking a property with the value `undefined`\ncan't be converted into JSON preserving the property name. However for\nconvenience it is allowed and assumed that all these properties are\noptional as well.\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "Declaration", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Location" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "Location" + } + } + ] + }, + "documentation": "The declaration of a symbol representation as one or many {@link Location locations}." + }, + { + "name": "DeclarationLink", + "type": { + "kind": "reference", + "name": "LocationLink" + }, + "documentation": "Information about where a symbol is declared.\n\nProvides additional metadata over normal {@link Location location} declarations, including the range of\nthe declaring symbol.\n\nServers should prefer returning `DeclarationLink` over `Declaration` if supported\nby the client." + }, + { + "name": "InlineValue", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "InlineValueText" + }, + { + "kind": "reference", + "name": "InlineValueVariableLookup" + }, + { + "kind": "reference", + "name": "InlineValueEvaluatableExpression" + } + ] + }, + "documentation": "Inline value information can be provided by different means:\n- directly as a text value (class InlineValueText).\n- as a name to use for a variable lookup (class InlineValueVariableLookup)\n- as an evaluatable expression (class InlineValueEvaluatableExpression)\nThe InlineValue types combines all inline value types into one type.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "DocumentDiagnosticReport", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "RelatedFullDocumentDiagnosticReport" + }, + { + "kind": "reference", + "name": "RelatedUnchangedDocumentDiagnosticReport" + } + ] + }, + "documentation": "The result of a document diagnostic pull request. A report can\neither be a full report containing all diagnostics for the\nrequested document or an unchanged report indicating that nothing\nhas changed in terms of diagnostics in comparison to the last\npull request.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "PrepareRenameResult", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Range" + }, + { + "kind": "reference", + "name": "PrepareRenamePlaceholder" + }, + { + "kind": "reference", + "name": "PrepareRenameDefaultBehavior" + } + ] + } + }, + { + "name": "DocumentSelector", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "DocumentFilter" + } + }, + "documentation": "A document selector is the combination of one or many document filters.\n\n@sample `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]`;\n\nThe use of a string as a document filter is deprecated @since 3.16.0.", + "since": "3.16.0." + }, + { + "name": "ProgressToken", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "integer" + }, + { + "kind": "base", + "name": "string" + } + ] + } + }, + { + "name": "ChangeAnnotationIdentifier", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "An identifier to refer to a change annotation stored with a workspace edit." + }, + { + "name": "WorkspaceDocumentDiagnosticReport", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "WorkspaceFullDocumentDiagnosticReport" + }, + { + "kind": "reference", + "name": "WorkspaceUnchangedDocumentDiagnosticReport" + } + ] + }, + "documentation": "A workspace diagnostic document report.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "TextDocumentContentChangeEvent", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "TextDocumentContentChangePartial" + }, + { + "kind": "reference", + "name": "TextDocumentContentChangeWholeDocument" + } + ] + }, + "documentation": "An event describing a change to a text document. If only a text is provided\nit is considered to be the full content of the document." + }, + { + "name": "MarkedString", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "MarkedStringWithLanguage" + } + ] + }, + "documentation": "MarkedString can be used to render human readable text. It is either a markdown string\nor a code-block that provides a language and a code snippet. The language identifier\nis semantically equal to the optional language identifier in fenced code blocks in GitHub\nissues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting\n\nThe pair of a language and a value is an equivalent to markdown:\n```${language}\n${value}\n```\n\nNote that markdown strings will be sanitized - that means html will be escaped.\n@deprecated use MarkupContent instead.", + "deprecated": "use MarkupContent instead." + }, + { + "name": "DocumentFilter", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "TextDocumentFilter" + }, + { + "kind": "reference", + "name": "NotebookCellTextDocumentFilter" + } + ] + }, + "documentation": "A document filter describes a top level text document or\na notebook cell document.\n\n@since 3.17.0 - proposed support for NotebookCellTextDocumentFilter.", + "since": "3.17.0 - proposed support for NotebookCellTextDocumentFilter." + }, + { + "name": "LSPObject", + "type": { + "kind": "map", + "key": { + "kind": "base", + "name": "string" + }, + "value": { + "kind": "reference", + "name": "LSPAny" + } + }, + "documentation": "LSP object definition.\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "GlobPattern", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "Pattern" + }, + { + "kind": "reference", + "name": "RelativePattern" + } + ] + }, + "documentation": "The glob pattern. Either a string pattern or a relative pattern.\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "TextDocumentFilter", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "TextDocumentFilterLanguage" + }, + { + "kind": "reference", + "name": "TextDocumentFilterScheme" + }, + { + "kind": "reference", + "name": "TextDocumentFilterPattern" + } + ] + }, + "documentation": "A document filter denotes a document by different properties like\nthe {@link TextDocument.languageId language}, the {@link Uri.scheme scheme} of\nits resource, or a glob-pattern that is applied to the {@link TextDocument.fileName path}.\n\nGlob patterns can have the following syntax:\n- `*` to match one or more characters in a path segment\n- `?` to match on one character in a path segment\n- `**` to match any number of path segments, including none\n- `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)\n- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)\n- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)\n\n@sample A language filter that applies to typescript files on disk: `{ language: 'typescript', scheme: 'file' }`\n@sample A language filter that applies to all package.json paths: `{ language: 'json', pattern: '**package.json' }`\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "NotebookDocumentFilter", + "type": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "NotebookDocumentFilterNotebookType" + }, + { + "kind": "reference", + "name": "NotebookDocumentFilterScheme" + }, + { + "kind": "reference", + "name": "NotebookDocumentFilterPattern" + } + ] + }, + "documentation": "A notebook document filter denotes a notebook document by\ndifferent properties. The properties will be match\nagainst the notebook's URI (same as with documents)\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "Pattern", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The glob pattern to watch relative to the base path. Glob patterns can have the following syntax:\n- `*` to match one or more characters in a path segment\n- `?` to match on one character in a path segment\n- `**` to match any number of path segments, including none\n- `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)\n- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)\n- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)\n\n@since 3.17.0", + "since": "3.17.0" + }, + { + "name": "RegularExpressionEngineKind", + "type": { + "kind": "base", + "name": "string" + } + } + ] +} diff --git a/tools/protocol-gen/testdata/lsp.v2024.0.0b1.schema.json b/tools/protocol-gen/testdata/lsp.v2024.0.0b1.schema.json new file mode 100644 index 00000000..d4a80dac --- /dev/null +++ b/tools/protocol-gen/testdata/lsp.v2024.0.0b1.schema.json @@ -0,0 +1,847 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "AndType": { + "additionalProperties": false, + "description": "Represents an `and`type (e.g. TextDocumentParams & WorkDoneProgressParams`).", + "properties": { + "items": { + "items": { + "$ref": "#/definitions/Type" + }, + "type": "array" + }, + "kind": { + "const": "and", + "type": "string" + } + }, + "required": [ + "kind", + "items" + ], + "type": "object" + }, + "ArrayType": { + "additionalProperties": false, + "description": "Represents an array type (e.g. `TextDocument[]`).", + "properties": { + "element": { + "$ref": "#/definitions/Type" + }, + "kind": { + "const": "array", + "type": "string" + } + }, + "required": [ + "kind", + "element" + ], + "type": "object" + }, + "BaseType": { + "additionalProperties": false, + "description": "Represents a base type like `string` or `DocumentUri`.", + "properties": { + "kind": { + "const": "base", + "type": "string" + }, + "name": { + "$ref": "#/definitions/BaseTypes" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, + "BaseTypes": { + "enum": [ + "URI", + "DocumentUri", + "integer", + "uinteger", + "decimal", + "RegExp", + "string", + "boolean", + "null" + ], + "type": "string" + }, + "BooleanLiteralType": { + "additionalProperties": false, + "description": "Represents a boolean literal type (e.g. `kind: true`).", + "properties": { + "kind": { + "const": "booleanLiteral", + "type": "string" + }, + "value": { + "type": "boolean" + } + }, + "required": [ + "kind", + "value" + ], + "type": "object" + }, + "Enumeration": { + "additionalProperties": false, + "description": "Defines an enumeration.", + "properties": { + "deprecated": { + "description": "Whether the enumeration is deprecated or not. If deprecated the property contains the deprecation message.", + "type": "string" + }, + "documentation": { + "description": "An optional documentation.", + "type": "string" + }, + "name": { + "description": "The name of the enumeration.", + "type": "string" + }, + "proposed": { + "description": "Whether this is a proposed enumeration. If omitted, the enumeration is final.", + "type": "boolean" + }, + "since": { + "description": "Since when (release number) this enumeration is available. Is undefined if not known.", + "type": "string" + }, + "sinceTags": { + "description": "All since tags in case there was more than one tag. Is undefined if not known.", + "items": { + "type": "string" + }, + "type": "array" + }, + "supportsCustomValues": { + "description": "Whether the enumeration supports custom values (e.g. values which are not part of the set defined in `values`). If omitted no custom values are supported.", + "type": "boolean" + }, + "type": { + "$ref": "#/definitions/EnumerationType", + "description": "The type of the elements." + }, + "values": { + "description": "The enum values.", + "items": { + "$ref": "#/definitions/EnumerationEntry" + }, + "type": "array" + } + }, + "required": [ + "name", + "type", + "values" + ], + "type": "object" + }, + "EnumerationEntry": { + "additionalProperties": false, + "description": "Defines an enumeration entry.", + "properties": { + "deprecated": { + "description": "Whether the enum entry is deprecated or not. If deprecated the property contains the deprecation message.", + "type": "string" + }, + "documentation": { + "description": "An optional documentation.", + "type": "string" + }, + "name": { + "description": "The name of the enum item.", + "type": "string" + }, + "proposed": { + "description": "Whether this is a proposed enumeration entry. If omitted, the enumeration entry is final.", + "type": "boolean" + }, + "since": { + "description": "Since when (release number) this enumeration entry is available. Is undefined if not known.", + "type": "string" + }, + "sinceTags": { + "description": "All since tags in case there was more than one tag. Is undefined if not known.", + "items": { + "type": "string" + }, + "type": "array" + }, + "value": { + "description": "The value.", + "type": [ + "string", + "number" + ] + } + }, + "required": [ + "name", + "value" + ], + "type": "object" + }, + "EnumerationType": { + "additionalProperties": false, + "properties": { + "kind": { + "const": "base", + "type": "string" + }, + "name": { + "enum": [ + "string", + "integer", + "uinteger" + ], + "type": "string" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, + "IntegerLiteralType": { + "additionalProperties": false, + "properties": { + "kind": { + "const": "integerLiteral", + "description": "Represents an integer literal type (e.g. `kind: 1`).", + "type": "string" + }, + "value": { + "type": "number" + } + }, + "required": [ + "kind", + "value" + ], + "type": "object" + }, + "MapKeyType": { + "anyOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "base", + "type": "string" + }, + "name": { + "enum": [ + "URI", + "DocumentUri", + "string", + "integer" + ], + "type": "string" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, + { + "$ref": "#/definitions/ReferenceType" + } + ], + "description": "Represents a type that can be used as a key in a map type. If a reference type is used then the type must either resolve to a `string` or `integer` type. (e.g. `type ChangeAnnotationIdentifier === string`)." + }, + "MapType": { + "additionalProperties": false, + "description": "Represents a JSON object map (e.g. `interface Map { [key: K] => V; }`).", + "properties": { + "key": { + "$ref": "#/definitions/MapKeyType" + }, + "kind": { + "const": "map", + "type": "string" + }, + "value": { + "$ref": "#/definitions/Type" + } + }, + "required": [ + "kind", + "key", + "value" + ], + "type": "object" + }, + "MessageDirection": { + "description": "Indicates in which direction a message is sent in the protocol.", + "enum": [ + "clientToServer", + "serverToClient", + "both" + ], + "type": "string" + }, + "MetaData": { + "additionalProperties": false, + "properties": { + "version": { + "description": "The protocol version.", + "type": "string" + } + }, + "required": [ + "version" + ], + "type": "object" + }, + "MetaModel": { + "additionalProperties": false, + "description": "The actual meta model.", + "properties": { + "enumerations": { + "description": "The enumerations.", + "items": { + "$ref": "#/definitions/Enumeration" + }, + "type": "array" + }, + "metaData": { + "$ref": "#/definitions/MetaData", + "description": "Additional meta data." + }, + "notifications": { + "description": "The notifications.", + "items": { + "$ref": "#/definitions/Notification" + }, + "type": "array" + }, + "requests": { + "description": "The requests.", + "items": { + "$ref": "#/definitions/Request" + }, + "type": "array" + }, + "structures": { + "description": "The structures.", + "items": { + "$ref": "#/definitions/Structure" + }, + "type": "array" + }, + "typeAliases": { + "description": "The type aliases.", + "items": { + "$ref": "#/definitions/TypeAlias" + }, + "type": "array" + } + }, + "required": [ + "metaData", + "requests", + "notifications", + "structures", + "enumerations", + "typeAliases" + ], + "type": "object" + }, + "Notification": { + "additionalProperties": false, + "description": "Represents a LSP notification", + "properties": { + "deprecated": { + "description": "Whether the notification is deprecated or not. If deprecated the property contains the deprecation message.", + "type": "string" + }, + "documentation": { + "description": "An optional documentation;", + "type": "string" + }, + "messageDirection": { + "$ref": "#/definitions/MessageDirection", + "description": "The direction in which this notification is sent in the protocol." + }, + "method": { + "description": "The notifications's method name.", + "type": "string" + }, + "params": { + "anyOf": [ + { + "$ref": "#/definitions/Type" + }, + { + "items": { + "$ref": "#/definitions/Type" + }, + "type": "array" + } + ], + "description": "The parameter type(s) if any." + }, + "proposed": { + "description": "Whether this is a proposed notification. If omitted the notification is final.", + "type": "boolean" + }, + "registrationMethod": { + "description": "Optional a dynamic registration method if it different from the notifications's method.", + "type": "string" + }, + "registrationOptions": { + "$ref": "#/definitions/Type", + "description": "Optional registration options if the notification supports dynamic registration." + }, + "since": { + "description": "Since when (release number) this notification is available. Is undefined if not known.", + "type": "string" + }, + "sinceTags": { + "description": "All since tags in case there was more than one tag. Is undefined if not known.", + "items": { + "type": "string" + }, + "type": "array" + }, + "typeName": { + "description": "The type name of the notifications if any.", + "type": "string" + } + }, + "required": [ + "method", + "messageDirection" + ], + "type": "object" + }, + "OrType": { + "additionalProperties": false, + "description": "Represents an `or` type (e.g. `Location | LocationLink`).", + "properties": { + "items": { + "items": { + "$ref": "#/definitions/Type" + }, + "type": "array" + }, + "kind": { + "const": "or", + "type": "string" + } + }, + "required": [ + "kind", + "items" + ], + "type": "object" + }, + "Property": { + "additionalProperties": false, + "description": "Represents an object property.", + "properties": { + "deprecated": { + "description": "Whether the property is deprecated or not. If deprecated the property contains the deprecation message.", + "type": "string" + }, + "documentation": { + "description": "An optional documentation.", + "type": "string" + }, + "name": { + "description": "The property name;", + "type": "string" + }, + "optional": { + "description": "Whether the property is optional. If omitted, the property is mandatory.", + "type": "boolean" + }, + "proposed": { + "description": "Whether this is a proposed property. If omitted, the structure is final.", + "type": "boolean" + }, + "since": { + "description": "Since when (release number) this property is available. Is undefined if not known.", + "type": "string" + }, + "sinceTags": { + "description": "All since tags in case there was more than one tag. Is undefined if not known.", + "items": { + "type": "string" + }, + "type": "array" + }, + "type": { + "$ref": "#/definitions/Type", + "description": "The type of the property" + } + }, + "required": [ + "name", + "type" + ], + "type": "object" + }, + "ReferenceType": { + "additionalProperties": false, + "description": "Represents a reference to another type (e.g. `TextDocument`). This is either a `Structure`, a `Enumeration` or a `TypeAlias` in the same meta model.", + "properties": { + "kind": { + "const": "reference", + "type": "string" + }, + "name": { + "type": "string" + } + }, + "required": [ + "kind", + "name" + ], + "type": "object" + }, + "Request": { + "additionalProperties": false, + "description": "Represents a LSP request", + "properties": { + "deprecated": { + "description": "Whether the request is deprecated or not. If deprecated the property contains the deprecation message.", + "type": "string" + }, + "documentation": { + "description": "An optional documentation;", + "type": "string" + }, + "errorData": { + "$ref": "#/definitions/Type", + "description": "An optional error data type." + }, + "messageDirection": { + "$ref": "#/definitions/MessageDirection", + "description": "The direction in which this request is sent in the protocol." + }, + "method": { + "description": "The request's method name.", + "type": "string" + }, + "params": { + "anyOf": [ + { + "$ref": "#/definitions/Type" + }, + { + "items": { + "$ref": "#/definitions/Type" + }, + "type": "array" + } + ], + "description": "The parameter type(s) if any." + }, + "partialResult": { + "$ref": "#/definitions/Type", + "description": "Optional partial result type if the request supports partial result reporting." + }, + "proposed": { + "description": "Whether this is a proposed feature. If omitted the feature is final.", + "type": "boolean" + }, + "registrationMethod": { + "description": "Optional a dynamic registration method if it different from the request's method.", + "type": "string" + }, + "registrationOptions": { + "$ref": "#/definitions/Type", + "description": "Optional registration options if the request supports dynamic registration." + }, + "result": { + "$ref": "#/definitions/Type", + "description": "The result type." + }, + "since": { + "description": "Since when (release number) this request is available. Is undefined if not known.", + "type": "string" + }, + "sinceTags": { + "description": "All since tags in case there was more than one tag. Is undefined if not known.", + "items": { + "type": "string" + }, + "type": "array" + }, + "typeName": { + "description": "The type name of the request if any.", + "type": "string" + } + }, + "required": [ + "method", + "result", + "messageDirection" + ], + "type": "object" + }, + "StringLiteralType": { + "additionalProperties": false, + "description": "Represents a string literal type (e.g. `kind: 'rename'`).", + "properties": { + "kind": { + "const": "stringLiteral", + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "kind", + "value" + ], + "type": "object" + }, + "Structure": { + "additionalProperties": false, + "description": "Defines the structure of an object literal.", + "properties": { + "deprecated": { + "description": "Whether the structure is deprecated or not. If deprecated the property contains the deprecation message.", + "type": "string" + }, + "documentation": { + "description": "An optional documentation;", + "type": "string" + }, + "extends": { + "description": "Structures extended from. This structures form a polymorphic type hierarchy.", + "items": { + "$ref": "#/definitions/Type" + }, + "type": "array" + }, + "mixins": { + "description": "Structures to mix in. The properties of these structures are `copied` into this structure. Mixins don't form a polymorphic type hierarchy in LSP.", + "items": { + "$ref": "#/definitions/Type" + }, + "type": "array" + }, + "name": { + "description": "The name of the structure.", + "type": "string" + }, + "properties": { + "description": "The properties.", + "items": { + "$ref": "#/definitions/Property" + }, + "type": "array" + }, + "proposed": { + "description": "Whether this is a proposed structure. If omitted, the structure is final.", + "type": "boolean" + }, + "since": { + "description": "Since when (release number) this structure is available. Is undefined if not known.", + "type": "string" + }, + "sinceTags": { + "description": "All since tags in case there was more than one tag. Is undefined if not known.", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "name", + "properties" + ], + "type": "object" + }, + "StructureLiteral": { + "additionalProperties": false, + "description": "Defines an unnamed structure of an object literal.", + "properties": { + "deprecated": { + "description": "Whether the literal is deprecated or not. If deprecated the property contains the deprecation message.", + "type": "string" + }, + "documentation": { + "description": "An optional documentation.", + "type": "string" + }, + "properties": { + "description": "The properties.", + "items": { + "$ref": "#/definitions/Property" + }, + "type": "array" + }, + "proposed": { + "description": "Whether this is a proposed structure. If omitted, the structure is final.", + "type": "boolean" + }, + "since": { + "description": "Since when (release number) this structure is available. Is undefined if not known.", + "type": "string" + }, + "sinceTags": { + "description": "All since tags in case there was more than one tag. Is undefined if not known.", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "properties" + ], + "type": "object" + }, + "StructureLiteralType": { + "additionalProperties": false, + "description": "Represents a literal structure (e.g. `property: { start: uinteger; end: uinteger; }`).", + "properties": { + "kind": { + "const": "literal", + "type": "string" + }, + "value": { + "$ref": "#/definitions/StructureLiteral" + } + }, + "required": [ + "kind", + "value" + ], + "type": "object" + }, + "TupleType": { + "additionalProperties": false, + "description": "Represents a `tuple` type (e.g. `[integer, integer]`).", + "properties": { + "items": { + "items": { + "$ref": "#/definitions/Type" + }, + "type": "array" + }, + "kind": { + "const": "tuple", + "type": "string" + } + }, + "required": [ + "kind", + "items" + ], + "type": "object" + }, + "Type": { + "anyOf": [ + { + "$ref": "#/definitions/BaseType" + }, + { + "$ref": "#/definitions/ReferenceType" + }, + { + "$ref": "#/definitions/ArrayType" + }, + { + "$ref": "#/definitions/MapType" + }, + { + "$ref": "#/definitions/AndType" + }, + { + "$ref": "#/definitions/OrType" + }, + { + "$ref": "#/definitions/TupleType" + }, + { + "$ref": "#/definitions/StructureLiteralType" + }, + { + "$ref": "#/definitions/StringLiteralType" + }, + { + "$ref": "#/definitions/IntegerLiteralType" + }, + { + "$ref": "#/definitions/BooleanLiteralType" + } + ] + }, + "TypeAlias": { + "additionalProperties": false, + "description": "Defines a type alias. (e.g. `type Definition = Location | LocationLink`)", + "properties": { + "deprecated": { + "description": "Whether the type alias is deprecated or not. If deprecated the property contains the deprecation message.", + "type": "string" + }, + "documentation": { + "description": "An optional documentation.", + "type": "string" + }, + "name": { + "description": "The name of the type alias.", + "type": "string" + }, + "proposed": { + "description": "Whether this is a proposed type alias. If omitted, the type alias is final.", + "type": "boolean" + }, + "since": { + "description": "Since when (release number) this structure is available. Is undefined if not known.", + "type": "string" + }, + "sinceTags": { + "description": "All since tags in case there was more than one tag. Is undefined if not known.", + "items": { + "type": "string" + }, + "type": "array" + }, + "type": { + "$ref": "#/definitions/Type", + "description": "The aliased type." + } + }, + "required": [ + "name", + "type" + ], + "type": "object" + }, + "TypeKind": { + "enum": [ + "base", + "reference", + "array", + "map", + "and", + "or", + "tuple", + "literal", + "stringLiteral", + "integerLiteral", + "booleanLiteral" + ], + "type": "string" + } + } +} From 123b56b4eb5b73144592a110dfa4c898d048cc37 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Wed, 9 Oct 2024 05:43:56 +0900 Subject: [PATCH 11/19] WIP8 Signed-off-by: Koichi Shiraishi --- protocol/basic.go | 4 +- protocol/client_interface.go | 106 ++--- protocol/document.go | 4 +- protocol/language.go | 22 +- protocol/lifecycle.go | 60 +-- protocol/server.go | 4 +- protocol/server_interface.go | 442 +++++++++--------- protocol/types_generics.go | 427 +---------------- protocol/workspace.go | 4 +- tools/protocol-gen/generator/client_server.go | 30 +- tools/protocol-gen/generator/generator.go | 27 +- .../protocol-gen/generator/generics_types.go | 4 +- tools/protocol-gen/generator/structure.go | 49 +- 13 files changed, 403 insertions(+), 780 deletions(-) diff --git a/protocol/basic.go b/protocol/basic.go index 0038cd14..93e85134 100644 --- a/protocol/basic.go +++ b/protocol/basic.go @@ -401,7 +401,7 @@ type WorkspaceEdit struct { // DocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are // either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. - DocumentChanges WorkspaceEditDocumentChanges `json:"documentChanges,omitempty"` + DocumentChanges *WorkspaceEditDocumentChanges `json:"documentChanges,omitempty"` // ChangeAnnotations a map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and delete file / folder operations. Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`. ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"` @@ -463,7 +463,7 @@ type Diagnostic struct { Severity DiagnosticSeverity `json:"severity,omitempty"` // Code the diagnostic's code, which usually appear in the user interface. - Code DiagnosticCode `json:"code,omitempty"` + Code *DiagnosticCode `json:"code,omitempty"` // CodeDescription an optional property to describe the error code. Requires the code field (above) to be present/not null. CodeDescription *CodeDescription `json:"codeDescription,omitempty"` diff --git a/protocol/client_interface.go b/protocol/client_interface.go index ad7989a3..02daa661 100644 --- a/protocol/client_interface.go +++ b/protocol/client_interface.go @@ -12,11 +12,16 @@ import ( const ( MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification MethodClientProgress ClientMethod = "$/progress" // bidirect client notification - MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification MethodLogTrace ClientMethod = "$/logTrace" // client notification + MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification + MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification MethodWindowShowMessage ClientMethod = "window/showMessage" // client notification - MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification + MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request + MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request + MethodWindowShowDocument ClientMethod = "window/showDocument" // client request + MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request + MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request @@ -24,13 +29,8 @@ const ( MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request - MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request - MethodWindowShowDocument ClientMethod = "window/showDocument" // client request - MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request MethodWorkspaceTextDocumentContentRefresh ClientMethod = "workspace/textDocumentContent/refresh" // client request - MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request - MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request ) @@ -39,19 +39,36 @@ type Client interface { Progress(ctx context.Context, params *ProgressParams) error - // LogMessage the log message notification is sent from the server to the client to ask the client to log a particular message. - LogMessage(ctx context.Context, params *LogMessageParams) error - LogTrace(ctx context.Context, params *LogTraceParams) error + // TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data. + TelemetryEvent(ctx context.Context, params any) error + // PublishDiagnostics diagnostics notification are sent from the server to the client to signal results of validation runs. PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error + // LogMessage the log message notification is sent from the server to the client to ask the client to log a particular message. + LogMessage(ctx context.Context, params *LogMessageParams) error + // ShowMessage the show message notification is sent from a server to a client to ask the client to display a particular message in the user interface. ShowMessage(ctx context.Context, params *ShowMessageParams) error + // Registration the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side. + Registration(ctx context.Context, params *RegistrationParams) error + + // Unregistration the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side. + Unregistration(ctx context.Context, params *UnregistrationParams) error + + // ShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser. + // + // @since 3.16.0 + ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) + + // ShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user. + ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) + + // WorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server. + WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error - // TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data. - TelemetryEvent(ctx context.Context, params any) error // ApplyWorkspaceEdit a request sent from the server to the client to modified certain resources. ApplyWorkspaceEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) @@ -84,33 +101,16 @@ type Client interface { // @since 3.17.0 InlineValueRefresh(ctx context.Context) error - // Registration the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side. - Registration(ctx context.Context, params *RegistrationParams) error - // SemanticTokensRefresh. // // @since 3.16.0 SemanticTokensRefresh(ctx context.Context) error - // ShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser. - // - // @since 3.16.0 - ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) - - // ShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user. - ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) - // TextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed. // // @since 3.18.0 proposed TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error - // Unregistration the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side. - Unregistration(ctx context.Context, params *UnregistrationParams) error - - // WorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server. - WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error - // WorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders. WorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) } @@ -118,6 +118,8 @@ type Client interface { // UnimplementedClient should be embedded to have forward compatible implementations. type UnimplementedClient struct{} +var _ Client = UnimplementedClient{} + func (UnimplementedClient) Cancel(ctx context.Context, params *CancelParams) error { return jsonrpc2.ErrInternal } @@ -126,11 +128,11 @@ func (UnimplementedClient) Progress(ctx context.Context, params *ProgressParams) return jsonrpc2.ErrInternal } -func (UnimplementedClient) LogMessage(ctx context.Context, params *LogMessageParams) error { +func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error { +func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error { return jsonrpc2.ErrInternal } @@ -138,11 +140,31 @@ func (UnimplementedClient) PublishDiagnostics(ctx context.Context, params *Publi return jsonrpc2.ErrInternal } +func (UnimplementedClient) LogMessage(ctx context.Context, params *LogMessageParams) error { + return jsonrpc2.ErrInternal +} + func (UnimplementedClient) ShowMessage(ctx context.Context, params *ShowMessageParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error { +func (UnimplementedClient) Registration(ctx context.Context, params *RegistrationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) Unregistration(ctx context.Context, params *UnregistrationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error { return jsonrpc2.ErrInternal } @@ -174,34 +196,14 @@ func (UnimplementedClient) InlineValueRefresh(ctx context.Context) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) Registration(ctx context.Context, params *RegistrationParams) error { - return jsonrpc2.ErrInternal -} - func (UnimplementedClient) SemanticTokensRefresh(ctx context.Context) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedClient) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) { - return nil, jsonrpc2.ErrInternal -} - func (UnimplementedClient) TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedClient) Unregistration(ctx context.Context, params *UnregistrationParams) error { - return jsonrpc2.ErrInternal -} - -func (UnimplementedClient) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error { - return jsonrpc2.ErrInternal -} - func (UnimplementedClient) WorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) { return nil, jsonrpc2.ErrInternal } diff --git a/protocol/document.go b/protocol/document.go index 8cec2854..07a8cdd6 100644 --- a/protocol/document.go +++ b/protocol/document.go @@ -128,7 +128,7 @@ type NotebookDocumentFilterWithCells struct { // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. // // @since 3.18.0 - Notebook NotebookDocumentFilterWithCellsNotebook `json:"notebook,omitempty"` + Notebook *NotebookDocumentFilterWithCellsNotebook `json:"notebook,omitempty"` // Cells the cells of the matching notebook to be synced. // @@ -349,7 +349,7 @@ type TextDocumentSyncOptions struct { WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` // Save if present save notifications are sent to the server. If omitted the notification should not be sent. - Save TextDocumentSyncOptionsSave `json:"save,omitempty"` + Save *TextDocumentSyncOptionsSave `json:"save,omitempty"` } // DidOpenTextDocumentParams the parameters sent in an open text document notification. diff --git a/protocol/language.go b/protocol/language.go index 5fcb5d16..eb59f58a 100644 --- a/protocol/language.go +++ b/protocol/language.go @@ -909,12 +909,12 @@ type SemanticTokensOptions struct { // Range server supports providing semantic tokens for a specific range of a document. // // @since 3.16.0 - Range SemanticTokensOptionsRange `json:"range,omitempty"` + Range *SemanticTokensOptionsRange `json:"range,omitempty"` // Full server supports providing semantic tokens for a full document. // // @since 3.16.0 - Full SemanticTokensOptionsFull `json:"full,omitempty"` + Full *SemanticTokensOptionsFull `json:"full,omitempty"` } // SemanticTokensRegistrationOptions. @@ -1272,7 +1272,7 @@ type InlayHintLabelPart struct { // Tooltip the tooltip text when you hover over this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. // // @since 3.17.0 - Tooltip InlayHintLabelPartTooltip `json:"tooltip,omitempty"` + Tooltip *InlayHintLabelPartTooltip `json:"tooltip,omitempty"` // Location an optional source code location that represents this label part. The editor will use this location for the hover and for code navigation features: This part will become a clickable link that resolves // to the definition of the symbol at the given location (not necessarily the location itself), it shows the hover that shows at the given location, and it shows a context menu with further code navigation commands. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. @@ -1315,7 +1315,7 @@ type InlayHint struct { // Tooltip the tooltip text when you hover over this item. // // @since 3.17.0 - Tooltip InlayHintTooltip `json:"tooltip,omitempty"` + Tooltip *InlayHintTooltip `json:"tooltip,omitempty"` // PaddingLeft render padding before the hint. Note: Padding should use the editor's background color, not the background color of the hint itself. That means padding can be used to visually align/separate an inlay hint. // @@ -1877,7 +1877,7 @@ type CompletionItem struct { Detail string `json:"detail,omitempty"` // Documentation a human-readable string that represents a doc-comment. - Documentation CompletionItemDocumentation `json:"documentation,omitempty"` + Documentation *CompletionItemDocumentation `json:"documentation,omitempty"` // Deprecated indicates if this item is deprecated. // @@ -1904,7 +1904,7 @@ type CompletionItem struct { InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"` // TextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`. - TextEdit CompletionItemTextEdit `json:"textEdit,omitempty"` + TextEdit *CompletionItemTextEdit `json:"textEdit,omitempty"` // TextEditText the edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range. Clients will only honor this property if they opt into completion list item defaults using the capability `completionList.itemDefaults`. If not provided and a list's default range is provided the label property is used as a text. TextEditText string `json:"textEditText,omitempty"` @@ -1945,7 +1945,7 @@ type CompletionItemDefaults struct { // EditRange a default edit range. // @since 3.17.0 - EditRange CompletionItemDefaultsEditRange `json:"editRange,omitempty"` + EditRange *CompletionItemDefaultsEditRange `json:"editRange,omitempty"` // InsertTextFormat a default insert text format. // @since 3.17.0 @@ -2028,7 +2028,7 @@ type ParameterInformation struct { Label ParameterInformationLabel `json:"label"` // Documentation the human-readable doc-comment of this parameter. Will be shown in the UI but can be omitted. - Documentation ParameterInformationDocumentation `json:"documentation,omitempty"` + Documentation *ParameterInformationDocumentation `json:"documentation,omitempty"` } // SignatureInformation represents the signature of something callable. A signature can have a label, like a function-name, a doc-comment, and a set of parameters. @@ -2037,7 +2037,7 @@ type SignatureInformation struct { Label string `json:"label"` // Documentation the human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. - Documentation SignatureInformationDocumentation `json:"documentation,omitempty"` + Documentation *SignatureInformationDocumentation `json:"documentation,omitempty"` // Parameters the parameters of this signature. Parameters []ParameterInformation `json:"parameters,omitempty"` @@ -2603,7 +2603,7 @@ type RelatedFullDocumentDiagnosticReport struct { // RelatedDocuments 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]RelatedFullDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` + RelatedDocuments map[DocumentURI]*RelatedFullDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` } // RelatedUnchangedDocumentDiagnosticReport an unchanged diagnostic report with a set of related documents. @@ -2615,7 +2615,7 @@ type RelatedUnchangedDocumentDiagnosticReport struct { // RelatedDocuments 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]RelatedUnchangedDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` + RelatedDocuments map[DocumentURI]*RelatedUnchangedDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` } // PrepareRenamePlaceholder. diff --git a/protocol/lifecycle.go b/protocol/lifecycle.go index 5e5cf432..01da8be9 100644 --- a/protocol/lifecycle.go +++ b/protocol/lifecycle.go @@ -728,12 +728,12 @@ type ClientSemanticTokensRequestOptions struct { // Range the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. // // @since 3.18.0 - Range ClientSemanticTokensRequestOptionsRange `json:"range,omitempty"` + Range *ClientSemanticTokensRequestOptionsRange `json:"range,omitempty"` // Full the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. // // @since 3.18.0 - Full ClientSemanticTokensRequestOptionsFull `json:"full,omitempty"` + Full *ClientSemanticTokensRequestOptionsFull `json:"full,omitempty"` } // SemanticTokensClientCapabilities. @@ -1221,7 +1221,7 @@ type WorkspaceOptions struct { // TextDocumentContent the server supports the `workspace/textDocumentContent` request. 3.18.0 @proposed. // @since 3.18.0 - TextDocumentContent WorkspaceOptionsTextDocumentContent `json:"textDocumentContent,omitempty"` + TextDocumentContent *WorkspaceOptionsTextDocumentContent `json:"textDocumentContent,omitempty"` } // ServerCapabilities defines the capabilities provided by a language server. @@ -1230,43 +1230,43 @@ type ServerCapabilities struct { PositionEncoding PositionEncodingKind `json:"positionEncoding,omitempty"` // TextDocumentSync defines how text documents are synced. Is either a detailed structure defining each notification or for backwards compatibility the TextDocumentSyncKind number. - TextDocumentSync ServerCapabilitiesTextDocumentSync `json:"textDocumentSync,omitempty"` + TextDocumentSync *ServerCapabilitiesTextDocumentSync `json:"textDocumentSync,omitempty"` // NotebookDocumentSync defines how notebook documents are synced. - NotebookDocumentSync ServerCapabilitiesNotebookDocumentSync `json:"notebookDocumentSync,omitempty"` + NotebookDocumentSync *ServerCapabilitiesNotebookDocumentSync `json:"notebookDocumentSync,omitempty"` // CompletionProvider the server provides completion support. CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"` // HoverProvider the server provides hover support. - HoverProvider ServerCapabilitiesHoverProvider `json:"hoverProvider,omitempty"` + HoverProvider *ServerCapabilitiesHoverProvider `json:"hoverProvider,omitempty"` // SignatureHelpProvider the server provides signature help support. SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` // DeclarationProvider the server provides Goto Declaration support. - DeclarationProvider ServerCapabilitiesDeclarationProvider `json:"declarationProvider,omitempty"` + DeclarationProvider *ServerCapabilitiesDeclarationProvider `json:"declarationProvider,omitempty"` // DefinitionProvider the server provides goto definition support. - DefinitionProvider ServerCapabilitiesDefinitionProvider `json:"definitionProvider,omitempty"` + DefinitionProvider *ServerCapabilitiesDefinitionProvider `json:"definitionProvider,omitempty"` // TypeDefinitionProvider the server provides Goto Type Definition support. - TypeDefinitionProvider ServerCapabilitiesTypeDefinitionProvider `json:"typeDefinitionProvider,omitempty"` + TypeDefinitionProvider *ServerCapabilitiesTypeDefinitionProvider `json:"typeDefinitionProvider,omitempty"` // ImplementationProvider the server provides Goto Implementation support. - ImplementationProvider ServerCapabilitiesImplementationProvider `json:"implementationProvider,omitempty"` + ImplementationProvider *ServerCapabilitiesImplementationProvider `json:"implementationProvider,omitempty"` // ReferencesProvider the server provides find references support. - ReferencesProvider ServerCapabilitiesReferencesProvider `json:"referencesProvider,omitempty"` + ReferencesProvider *ServerCapabilitiesReferencesProvider `json:"referencesProvider,omitempty"` // DocumentHighlightProvider the server provides document highlight support. - DocumentHighlightProvider ServerCapabilitiesDocumentHighlightProvider `json:"documentHighlightProvider,omitempty"` + DocumentHighlightProvider *ServerCapabilitiesDocumentHighlightProvider `json:"documentHighlightProvider,omitempty"` // DocumentSymbolProvider the server provides document symbol support. - DocumentSymbolProvider ServerCapabilitiesDocumentSymbolProvider `json:"documentSymbolProvider,omitempty"` + DocumentSymbolProvider *ServerCapabilitiesDocumentSymbolProvider `json:"documentSymbolProvider,omitempty"` // CodeActionProvider the server provides code actions. CodeActionOptions may only be specified if the client states that it supports `codeActionLiteralSupport` in its initial `initialize` request. - CodeActionProvider ServerCapabilitiesCodeActionProvider `json:"codeActionProvider,omitempty"` + CodeActionProvider *ServerCapabilitiesCodeActionProvider `json:"codeActionProvider,omitempty"` // CodeLensProvider the server provides code lens. CodeLensProvider *CodeLensOptions `json:"codeLensProvider,omitempty"` @@ -1275,59 +1275,59 @@ type ServerCapabilities struct { DocumentLinkProvider *DocumentLinkOptions `json:"documentLinkProvider,omitempty"` // ColorProvider the server provides color provider support. - ColorProvider ServerCapabilitiesColorProvider `json:"colorProvider,omitempty"` + ColorProvider *ServerCapabilitiesColorProvider `json:"colorProvider,omitempty"` // WorkspaceSymbolProvider the server provides workspace symbol support. - WorkspaceSymbolProvider ServerCapabilitiesWorkspaceSymbolProvider `json:"workspaceSymbolProvider,omitempty"` + WorkspaceSymbolProvider *ServerCapabilitiesWorkspaceSymbolProvider `json:"workspaceSymbolProvider,omitempty"` // DocumentFormattingProvider the server provides document formatting. - DocumentFormattingProvider ServerCapabilitiesDocumentFormattingProvider `json:"documentFormattingProvider,omitempty"` + DocumentFormattingProvider *ServerCapabilitiesDocumentFormattingProvider `json:"documentFormattingProvider,omitempty"` // DocumentRangeFormattingProvider the server provides document range formatting. - DocumentRangeFormattingProvider ServerCapabilitiesDocumentRangeFormattingProvider `json:"documentRangeFormattingProvider,omitempty"` + DocumentRangeFormattingProvider *ServerCapabilitiesDocumentRangeFormattingProvider `json:"documentRangeFormattingProvider,omitempty"` // DocumentOnTypeFormattingProvider the server provides document formatting on typing. DocumentOnTypeFormattingProvider *DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"` // RenameProvider the server provides rename support. RenameOptions may only be specified if the client states that it // supports `prepareSupport` in its initial `initialize` request. - RenameProvider ServerCapabilitiesRenameProvider `json:"renameProvider,omitempty"` + RenameProvider *ServerCapabilitiesRenameProvider `json:"renameProvider,omitempty"` // FoldingRangeProvider the server provides folding provider support. - FoldingRangeProvider ServerCapabilitiesFoldingRangeProvider `json:"foldingRangeProvider,omitempty"` + FoldingRangeProvider *ServerCapabilitiesFoldingRangeProvider `json:"foldingRangeProvider,omitempty"` // SelectionRangeProvider the server provides selection range support. - SelectionRangeProvider ServerCapabilitiesSelectionRangeProvider `json:"selectionRangeProvider,omitempty"` + SelectionRangeProvider *ServerCapabilitiesSelectionRangeProvider `json:"selectionRangeProvider,omitempty"` // ExecuteCommandProvider the server provides execute command support. ExecuteCommandProvider *ExecuteCommandOptions `json:"executeCommandProvider,omitempty"` // CallHierarchyProvider the server provides call hierarchy support. - CallHierarchyProvider ServerCapabilitiesCallHierarchyProvider `json:"callHierarchyProvider,omitempty"` + CallHierarchyProvider *ServerCapabilitiesCallHierarchyProvider `json:"callHierarchyProvider,omitempty"` // LinkedEditingRangeProvider the server provides linked editing range support. - LinkedEditingRangeProvider ServerCapabilitiesLinkedEditingRangeProvider `json:"linkedEditingRangeProvider,omitempty"` + LinkedEditingRangeProvider *ServerCapabilitiesLinkedEditingRangeProvider `json:"linkedEditingRangeProvider,omitempty"` // SemanticTokensProvider the server provides semantic tokens support. - SemanticTokensProvider ServerCapabilitiesSemanticTokensProvider `json:"semanticTokensProvider,omitempty"` + SemanticTokensProvider *ServerCapabilitiesSemanticTokensProvider `json:"semanticTokensProvider,omitempty"` // MonikerProvider the server provides moniker support. - MonikerProvider ServerCapabilitiesMonikerProvider `json:"monikerProvider,omitempty"` + MonikerProvider *ServerCapabilitiesMonikerProvider `json:"monikerProvider,omitempty"` // TypeHierarchyProvider the server provides type hierarchy support. - TypeHierarchyProvider ServerCapabilitiesTypeHierarchyProvider `json:"typeHierarchyProvider,omitempty"` + TypeHierarchyProvider *ServerCapabilitiesTypeHierarchyProvider `json:"typeHierarchyProvider,omitempty"` // InlineValueProvider the server provides inline values. - InlineValueProvider ServerCapabilitiesInlineValueProvider `json:"inlineValueProvider,omitempty"` + InlineValueProvider *ServerCapabilitiesInlineValueProvider `json:"inlineValueProvider,omitempty"` // InlayHintProvider the server provides inlay hints. - InlayHintProvider ServerCapabilitiesInlayHintProvider `json:"inlayHintProvider,omitempty"` + InlayHintProvider *ServerCapabilitiesInlayHintProvider `json:"inlayHintProvider,omitempty"` // DiagnosticProvider the server has support for pull model diagnostics. - DiagnosticProvider ServerCapabilitiesDiagnosticProvider `json:"diagnosticProvider,omitempty"` + DiagnosticProvider *ServerCapabilitiesDiagnosticProvider `json:"diagnosticProvider,omitempty"` // InlineCompletionProvider inline completion options used during static registration. 3.18.0 @proposed. - InlineCompletionProvider ServerCapabilitiesInlineCompletionProvider `json:"inlineCompletionProvider,omitempty"` + InlineCompletionProvider *ServerCapabilitiesInlineCompletionProvider `json:"inlineCompletionProvider,omitempty"` // Workspace workspace specific server capabilities. Workspace *WorkspaceOptions `json:"workspace,omitempty"` diff --git a/protocol/server.go b/protocol/server.go index 320e8c08..aa287d54 100644 --- a/protocol/server.go +++ b/protocol/server.go @@ -45,9 +45,7 @@ func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { return replyParseError(ctx, reply, err) } - resp, err := server.Request(ctx, req.Method(), params) - - return reply(ctx, resp, err) + return nil } return h diff --git a/protocol/server_interface.go b/protocol/server_interface.go index 12c10e7a..fe6567c1 100644 --- a/protocol/server_interface.go +++ b/protocol/server_interface.go @@ -12,78 +12,78 @@ import ( const ( MethodServerCancelRequest ServerMethod = "$/cancelRequest" // bidirect server notification MethodServerProgress ServerMethod = "$/progress" // bidirect server notification - MethodWorkspaceDidChangeConfiguration ServerMethod = "workspace/didChangeConfiguration" // server notification + MethodSetTrace ServerMethod = "$/setTrace" // server notification + MethodExit ServerMethod = "exit" // server notification + MethodInitialized ServerMethod = "initialized" // server notification MethodNotebookDocumentDidChange ServerMethod = "notebookDocument/didChange" // server notification - MethodTextDocumentDidChange ServerMethod = "textDocument/didChange" // server notification - MethodWorkspaceDidChangeWatchedFiles ServerMethod = "workspace/didChangeWatchedFiles" // server notification - MethodWorkspaceDidChangeWorkspaceFolders ServerMethod = "workspace/didChangeWorkspaceFolders" // server notification MethodNotebookDocumentDidClose ServerMethod = "notebookDocument/didClose" // server notification - MethodTextDocumentDidClose ServerMethod = "textDocument/didClose" // server notification - MethodWorkspaceDidCreateFiles ServerMethod = "workspace/didCreateFiles" // server notification - MethodWorkspaceDidDeleteFiles ServerMethod = "workspace/didDeleteFiles" // server notification MethodNotebookDocumentDidOpen ServerMethod = "notebookDocument/didOpen" // server notification - MethodTextDocumentDidOpen ServerMethod = "textDocument/didOpen" // server notification - MethodWorkspaceDidRenameFiles ServerMethod = "workspace/didRenameFiles" // server notification MethodNotebookDocumentDidSave ServerMethod = "notebookDocument/didSave" // server notification + MethodTextDocumentDidChange ServerMethod = "textDocument/didChange" // server notification + MethodTextDocumentDidClose ServerMethod = "textDocument/didClose" // server notification + MethodTextDocumentDidOpen ServerMethod = "textDocument/didOpen" // server notification MethodTextDocumentDidSave ServerMethod = "textDocument/didSave" // server notification - MethodExit ServerMethod = "exit" // server notification - MethodInitialized ServerMethod = "initialized" // server notification - MethodSetTrace ServerMethod = "$/setTrace" // server notification MethodTextDocumentWillSave ServerMethod = "textDocument/willSave" // server notification MethodWindowWorkDoneProgressCancel ServerMethod = "window/workDoneProgress/cancel" // server notification + MethodWorkspaceDidChangeConfiguration ServerMethod = "workspace/didChangeConfiguration" // server notification + MethodWorkspaceDidChangeWatchedFiles ServerMethod = "workspace/didChangeWatchedFiles" // server notification + MethodWorkspaceDidChangeWorkspaceFolders ServerMethod = "workspace/didChangeWorkspaceFolders" // server notification + MethodWorkspaceDidCreateFiles ServerMethod = "workspace/didCreateFiles" // server notification + MethodWorkspaceDidDeleteFiles ServerMethod = "workspace/didDeleteFiles" // server notification + MethodWorkspaceDidRenameFiles ServerMethod = "workspace/didRenameFiles" // server notification MethodCallHierarchyIncomingCalls ServerMethod = "callHierarchy/incomingCalls" // server request MethodCallHierarchyOutgoingCalls ServerMethod = "callHierarchy/outgoingCalls" // server request - MethodTextDocumentPrepareCallHierarchy ServerMethod = "textDocument/prepareCallHierarchy" // server request - MethodTextDocumentCodeAction ServerMethod = "textDocument/codeAction" // server request MethodCodeActionResolve ServerMethod = "codeAction/resolve" // server request - MethodTextDocumentCodeLens ServerMethod = "textDocument/codeLens" // server request MethodCodeLensResolve ServerMethod = "codeLens/resolve" // server request + MethodCompletionItemResolve ServerMethod = "completionItem/resolve" // server request + MethodDocumentLinkResolve ServerMethod = "documentLink/resolve" // server request + MethodInitialize ServerMethod = "initialize" // server request + MethodInlayHintResolve ServerMethod = "inlayHint/resolve" // server request + MethodShutdown ServerMethod = "shutdown" // server request + MethodTextDocumentCodeAction ServerMethod = "textDocument/codeAction" // server request + MethodTextDocumentCodeLens ServerMethod = "textDocument/codeLens" // server request MethodTextDocumentColorPresentation ServerMethod = "textDocument/colorPresentation" // server request MethodTextDocumentCompletion ServerMethod = "textDocument/completion" // server request - MethodCompletionItemResolve ServerMethod = "completionItem/resolve" // server request MethodTextDocumentDeclaration ServerMethod = "textDocument/declaration" // server request MethodTextDocumentDefinition ServerMethod = "textDocument/definition" // server request - MethodTextDocumentDocumentColor ServerMethod = "textDocument/documentColor" // server request MethodTextDocumentDiagnostic ServerMethod = "textDocument/diagnostic" // server request - MethodTextDocumentFormatting ServerMethod = "textDocument/formatting" // server request + MethodTextDocumentDocumentColor ServerMethod = "textDocument/documentColor" // server request MethodTextDocumentDocumentHighlight ServerMethod = "textDocument/documentHighlight" // server request MethodTextDocumentDocumentLink ServerMethod = "textDocument/documentLink" // server request - MethodDocumentLinkResolve ServerMethod = "documentLink/resolve" // server request - MethodTextDocumentOnTypeFormatting ServerMethod = "textDocument/onTypeFormatting" // server request - MethodTextDocumentRangeFormatting ServerMethod = "textDocument/rangeFormatting" // server request - MethodTextDocumentRangesFormatting ServerMethod = "textDocument/rangesFormatting" // server request MethodTextDocumentDocumentSymbol ServerMethod = "textDocument/documentSymbol" // server request - MethodWorkspaceExecuteCommand ServerMethod = "workspace/executeCommand" // server request MethodTextDocumentFoldingRange ServerMethod = "textDocument/foldingRange" // server request + MethodTextDocumentFormatting ServerMethod = "textDocument/formatting" // server request MethodTextDocumentHover ServerMethod = "textDocument/hover" // server request MethodTextDocumentImplementation ServerMethod = "textDocument/implementation" // server request - MethodInitialize ServerMethod = "initialize" // server request MethodTextDocumentInlayHint ServerMethod = "textDocument/inlayHint" // server request - MethodInlayHintResolve ServerMethod = "inlayHint/resolve" // server request MethodTextDocumentInlineCompletion ServerMethod = "textDocument/inlineCompletion" // server request MethodTextDocumentInlineValue ServerMethod = "textDocument/inlineValue" // server request MethodTextDocumentLinkedEditingRange ServerMethod = "textDocument/linkedEditingRange" // server request MethodTextDocumentMoniker ServerMethod = "textDocument/moniker" // server request + MethodTextDocumentOnTypeFormatting ServerMethod = "textDocument/onTypeFormatting" // server request + MethodTextDocumentPrepareCallHierarchy ServerMethod = "textDocument/prepareCallHierarchy" // server request MethodTextDocumentPrepareRename ServerMethod = "textDocument/prepareRename" // server request + MethodTextDocumentPrepareTypeHierarchy ServerMethod = "textDocument/prepareTypeHierarchy" // server request + MethodTextDocumentRangeFormatting ServerMethod = "textDocument/rangeFormatting" // server request + MethodTextDocumentRangesFormatting ServerMethod = "textDocument/rangesFormatting" // server request MethodTextDocumentReferences ServerMethod = "textDocument/references" // server request MethodTextDocumentRename ServerMethod = "textDocument/rename" // server request MethodTextDocumentSelectionRange ServerMethod = "textDocument/selectionRange" // server request + MethodTextDocumentSemanticTokensFull ServerMethod = "textDocument/semanticTokens/full" // server request MethodTextDocumentSemanticTokensFullDelta ServerMethod = "textDocument/semanticTokens/full/delta" // server request MethodTextDocumentSemanticTokensRange ServerMethod = "textDocument/semanticTokens/range" // server request - MethodTextDocumentSemanticTokensFull ServerMethod = "textDocument/semanticTokens/full" // server request - MethodShutdown ServerMethod = "shutdown" // server request MethodTextDocumentSignatureHelp ServerMethod = "textDocument/signatureHelp" // server request - MethodWorkspaceTextDocumentContent ServerMethod = "workspace/textDocumentContent" // server request MethodTextDocumentTypeDefinition ServerMethod = "textDocument/typeDefinition" // server request - MethodTextDocumentPrepareTypeHierarchy ServerMethod = "textDocument/prepareTypeHierarchy" // server request + MethodTextDocumentWillSaveWaitUntil ServerMethod = "textDocument/willSaveWaitUntil" // server request MethodTypeHierarchySubtypes ServerMethod = "typeHierarchy/subtypes" // server request MethodTypeHierarchySupertypes ServerMethod = "typeHierarchy/supertypes" // server request + MethodWorkspaceDiagnostic ServerMethod = "workspace/diagnostic" // server request + MethodWorkspaceExecuteCommand ServerMethod = "workspace/executeCommand" // server request + MethodWorkspaceSymbol ServerMethod = "workspace/symbol" // server request + MethodWorkspaceTextDocumentContent ServerMethod = "workspace/textDocumentContent" // server request MethodWorkspaceWillCreateFiles ServerMethod = "workspace/willCreateFiles" // server request MethodWorkspaceWillDeleteFiles ServerMethod = "workspace/willDeleteFiles" // server request MethodWorkspaceWillRenameFiles ServerMethod = "workspace/willRenameFiles" // server request - MethodTextDocumentWillSaveWaitUntil ServerMethod = "textDocument/willSaveWaitUntil" // server request - MethodWorkspaceDiagnostic ServerMethod = "workspace/diagnostic" // server request - MethodWorkspaceSymbol ServerMethod = "workspace/symbol" // server request MethodWorkspaceSymbolResolve ServerMethod = "workspaceSymbol/resolve" // server request ) @@ -92,14 +92,52 @@ type Server interface { Progress(ctx context.Context, params *ProgressParams) error - // DidChangeConfiguration the configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains the changed configuration as defined by the language client. - DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error + SetTrace(ctx context.Context, params *SetTraceParams) error + + // Exit the exit event is sent from the client to the server to ask the server to exit its process. + Exit(ctx context.Context) error + + // Initialized the initialized notification is sent from the client to the server after the client is fully initialized and the server is allowed to send requests from the server to the client. + Initialized(ctx context.Context, params *InitializedParams) error DidChangeNotebookDocument(ctx context.Context, params *DidChangeNotebookDocumentParams) error + // DidCloseNotebookDocument a notification sent when a notebook closes. + // + // @since 3.17.0 + DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) error + + // DidOpenNotebookDocument a notification sent when a notebook opens. + // + // @since 3.17.0 + DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) error + + // DidSaveNotebookDocument a notification sent when a notebook document is saved. + // + // @since 3.17.0 + DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) error + // DidChangeTextDocument the document change notification is sent from the client to the server to signal changes to a text document. DidChangeTextDocument(ctx context.Context, params *DidChangeTextDocumentParams) error + // DidCloseTextDocument the document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notification to be sent. + DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) error + + // DidOpenTextDocument the document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one. + DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) error + + // DidSaveTextDocument the document save notification is sent from the client to the server when the document got saved in the client. + DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) error + + // WillSaveTextDocument a document will save notification is sent from the client to the server before the document is actually saved. + WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) error + + // WorkDoneProgressCancel the `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress initiated on the server side. + WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error + + // DidChangeConfiguration the configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains the changed configuration as defined by the language client. + DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error + // DidChangeWatchedFiles the watched files notification is sent from the client to the server when the client detects changes // to file watched by the language client. DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error @@ -107,14 +145,6 @@ type Server interface { // DidChangeWorkspaceFolders the `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace folder configuration changes. DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error - // DidCloseNotebookDocument a notification sent when a notebook closes. - // - // @since 3.17.0 - DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) error - - // DidCloseTextDocument the document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notification to be sent. - DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) error - // DidCreateFiles the did create files notification is sent from the client to the server when files were created from // within the client. // @@ -126,41 +156,11 @@ type Server interface { // @since 3.16.0 DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error - // DidOpenNotebookDocument a notification sent when a notebook opens. - // - // @since 3.17.0 - DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) error - - // DidOpenTextDocument the document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one. - DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) error - // DidRenameFiles the did rename files notification is sent from the client to the server when files were renamed from // within the client. // // @since 3.16.0 DidRenameFiles(ctx context.Context, params *RenameFilesParams) error - - // DidSaveNotebookDocument a notification sent when a notebook document is saved. - // - // @since 3.17.0 - DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) error - - // DidSaveTextDocument the document save notification is sent from the client to the server when the document got saved in the client. - DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) error - - // Exit the exit event is sent from the client to the server to ask the server to exit its process. - Exit(ctx context.Context) error - - // Initialized the initialized notification is sent from the client to the server after the client is fully initialized and the server is allowed to send requests from the server to the client. - Initialized(ctx context.Context, params *InitializedParams) error - - SetTrace(ctx context.Context, params *SetTraceParams) error - - // WillSaveTextDocument a document will save notification is sent from the client to the server before the document is actually saved. - WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) error - - // WorkDoneProgressCancel the `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress initiated on the server side. - WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error // CallHierarchyIncomingCalls a request to resolve the incoming calls for a given `CallHierarchyItem`. // // @since 3.16.0 @@ -171,25 +171,37 @@ type Server interface { // @since 3.16.0 CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) - // CallHierarchyPrepare a request to result a `CallHierarchyItem` in a document at a given position. Can be used as an input - // to an incoming or outgoing call hierarchy. + // CodeActionResolve request to resolve additional information for a given code action.The request's parameter is of type + // CodeAction the response is of type CodeAction or a Thenable that resolves to such. + CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) + + // CodeLensResolve a request to resolve a command for a given code lens. + CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) + + // CompletionResolve request to resolve additional information for a given completion item.The request's parameter is of type CompletionItem the response is of type CompletionItem or a Thenable that resolves to such. + CompletionResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) + + // DocumentLinkResolve request to resolve additional information for a given document link. The request's parameter is of type DocumentLink the response is of type DocumentLink or a Thenable that resolves to such. + DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) + + // Initialize the initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type InitializeParams the response if of type InitializeResult of a Thenable that resolves to such. + Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) + + // InlayHintResolve a request to resolve additional properties for an inlay hint. The request's parameter is of type InlayHint, the response is of type InlayHint or a Thenable that resolves to such. // - // @since 3.16.0 - CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) + // @since 3.17.0 + InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) + + // Shutdown a shutdown request is sent from the client to the server. It is sent once when the client decides to + // shutdown the server. The only notification that is sent after a shutdown request is the exit event. + Shutdown(ctx context.Context) error // CodeAction a request to provide commands for the given text document and range. CodeAction(ctx context.Context, params *CodeActionParams) (*CodeActionRequestResult, error) - // CodeActionResolve request to resolve additional information for a given code action.The request's parameter is of type - // CodeAction the response is of type CodeAction or a Thenable that resolves to such. - CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) - // CodeLens a request to provide code lens for the given text document. CodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) - // CodeLensResolve a request to resolve a command for a given code lens. - CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) - // ColorPresentation a request to list all presentation for a color. The request's parameter is of type ColorPresentationParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. ColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) @@ -197,9 +209,6 @@ type Server interface { // `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. Completion(ctx context.Context, params *CompletionParams) (*CompletionResult, error) - // CompletionResolve request to resolve additional information for a given completion item.The request's parameter is of type CompletionItem the response is of type CompletionItem or a Thenable that resolves to such. - CompletionResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) - // Declaration a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a // typed array of DeclarationLink or a Thenable that resolves to such. Declaration(ctx context.Context, params *DeclarationParams) (*DeclarationResult, error) @@ -208,16 +217,13 @@ type Server interface { // array of DefinitionLink or a Thenable that resolves to such. Definition(ctx context.Context, params *DefinitionParams) (*DefinitionResult, error) - // DocumentColor a request to list all color symbols found in a given text document. The request's parameter is of type DocumentColorParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. - DocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) - // DocumentDiagnostic the document diagnostic request definition. // // @since 3.17.0 DocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) - // DocumentFormatting a request to format a whole document. - DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) + // DocumentColor a request to list all color symbols found in a given text document. The request's parameter is of type DocumentColorParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. + DocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) // DocumentHighlight request to resolve a DocumentHighlight for a given text document position. The request's parameter is of type TextDocumentPosition the request response is an array of type DocumentHighlight or a Thenable that resolves to such. DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) @@ -225,30 +231,16 @@ type Server interface { // DocumentLink a request to provide document links. DocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) - // DocumentLinkResolve request to resolve additional information for a given document link. The request's parameter is of type DocumentLink the response is of type DocumentLink or a Thenable that resolves to such. - DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) - - // DocumentOnTypeFormatting a request to format a document on type. - DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) - - // DocumentRangeFormatting a request to format a range in a document. - DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) - - // DocumentRangesFormatting a request to format ranges in a document. 3.18.0 @proposed. - // - // @since 3.18.0 proposed - DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) - // DocumentSymbol a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that // resolves to such. DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*DocumentSymbolResult, error) - // ExecuteCommand a request send from the client to the server to execute a command. The request might return a workspace edit which the client will apply to the workspace. - ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) - // FoldingRange a request to provide folding ranges in a document. The request's parameter is of type FoldingRangeParams, the response is of type FoldingRangeList or a Thenable that resolves to such. FoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) + // DocumentFormatting a request to format a whole document. + DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) + // Hover request to request hover information at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type Hover or a Thenable that resolves to such. Hover(ctx context.Context, params *HoverParams) (*Hover, error) @@ -256,20 +248,12 @@ type Server interface { // request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. Implementation(ctx context.Context, params *ImplementationParams) (*ImplementationResult, error) - // Initialize the initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type InitializeParams the response if of type InitializeResult of a Thenable that resolves to such. - Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) - // InlayHint a request to provide inlay hints in a document. The request's parameter is of type InlayHintsParams, // the response is of type InlayHint InlayHint[] or a Thenable that resolves to such. // // @since 3.17.0 InlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) - // InlayHintResolve a request to resolve additional properties for an inlay hint. The request's parameter is of type InlayHint, the response is of type InlayHint or a Thenable that resolves to such. - // - // @since 3.17.0 - InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) - // InlineCompletion a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. // // @since 3.18.0 proposed @@ -289,11 +273,34 @@ type Server interface { // of type TextDocumentPositionParams. The response is of type Moniker Moniker[] or `null`. Moniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) + // DocumentOnTypeFormatting a request to format a document on type. + DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) + + // CallHierarchyPrepare a request to result a `CallHierarchyItem` in a document at a given position. Can be used as an input + // to an incoming or outgoing call hierarchy. + // + // @since 3.16.0 + CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) + // PrepareRename a request to test and perform the setup necessary for a rename. 3.16 - support for default behavior. // // @since 3.16 - support for default behavior PrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) + // TypeHierarchyPrepare a request to result a `TypeHierarchyItem` in a document at a given position. Can be used as an input + // to a subtypes or supertypes type hierarchy. + // + // @since 3.17.0 + TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) + + // DocumentRangeFormatting a request to format a range in a document. + DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) + + // DocumentRangesFormatting a request to format ranges in a document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) + // References a request to resolve project-wide references for the symbol denoted by the given text document position. The request's parameter is of type ReferenceParams the response is of type Location Location[] or a Thenable that resolves to such. References(ctx context.Context, params *ReferenceParams) ([]*Location, error) @@ -303,6 +310,11 @@ type Server interface { // SelectionRange a request to provide selection ranges in a document. The request's parameter is of type SelectionRangeParams, the response is of type SelectionRange SelectionRange[] or a Thenable that resolves to such. SelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) + // SemanticTokens. + // + // @since 3.16.0 + SemanticTokens(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) + // SemanticTokensDelta. // // @since 3.16.0 @@ -313,30 +325,14 @@ type Server interface { // @since 3.16.0 SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) - // SemanticTokens. - // - // @since 3.16.0 - SemanticTokens(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) - - // Shutdown a shutdown request is sent from the client to the server. It is sent once when the client decides to - // shutdown the server. The only notification that is sent after a shutdown request is the exit event. - Shutdown(ctx context.Context) error - SignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) - // TextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. - // - // @since 3.18.0 proposed - TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) - // TypeDefinition a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TypeDefinitionResult, error) - // TypeHierarchyPrepare a request to result a `TypeHierarchyItem` in a document at a given position. Can be used as an input - // to a subtypes or supertypes type hierarchy. - // - // @since 3.17.0 - TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) + // WillSaveTextDocumentWaitUntil a document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before + // it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable. + WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) // TypeHierarchySubtypes a request to resolve the subtypes for a given `TypeHierarchyItem`. // @@ -348,6 +344,25 @@ type Server interface { // @since 3.17.0 TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) + // WorkspaceDiagnostic the workspace diagnostic request definition. + // + // @since 3.17.0 + WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) + + // ExecuteCommand a request send from the client to the server to execute a command. The request might return a workspace edit which the client will apply to the workspace. + ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) + + // WorkspaceSymbol a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. + // The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + // + // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) + + // TextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) + // WillCreateFiles the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a `WorkspaceEdit` which will be applied to workspace before the files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file to be created. // // @since 3.16.0 @@ -364,32 +379,17 @@ type Server interface { // @since 3.16.0 WillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) - // WillSaveTextDocumentWaitUntil a document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before - // it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable. - WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) - - // WorkspaceDiagnostic the workspace diagnostic request definition. - // - // @since 3.17.0 - WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) - - // WorkspaceSymbol a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. - // The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. - // - // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. - WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) - // WorkspaceSymbolResolve a request to resolve the range inside the workspace symbol's location. // // @since 3.17.0 WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (*WorkspaceSymbol, error) - - Request(ctx context.Context, method string, params any) (any, error) } // UnimplementedServer should be embedded to have forward compatible implementations. type UnimplementedServer struct{} +var _ Server = UnimplementedServer{} + func (UnimplementedServer) Cancel(ctx context.Context, params *CancelParams) error { return jsonrpc2.ErrInternal } @@ -398,79 +398,79 @@ func (UnimplementedServer) Progress(ctx context.Context, params *ProgressParams) return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error { +func (UnimplementedServer) SetTrace(ctx context.Context, params *SetTraceParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidChangeNotebookDocument(ctx context.Context, params *DidChangeNotebookDocumentParams) error { +func (UnimplementedServer) Exit(ctx context.Context) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidChangeTextDocument(ctx context.Context, params *DidChangeTextDocumentParams) error { +func (UnimplementedServer) Initialized(ctx context.Context, params *InitializedParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error { +func (UnimplementedServer) DidChangeNotebookDocument(ctx context.Context, params *DidChangeNotebookDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error { +func (UnimplementedServer) DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) error { +func (UnimplementedServer) DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) error { +func (UnimplementedServer) DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidCreateFiles(ctx context.Context, params *CreateFilesParams) error { +func (UnimplementedServer) DidChangeTextDocument(ctx context.Context, params *DidChangeTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error { +func (UnimplementedServer) DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) error { +func (UnimplementedServer) DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) error { +func (UnimplementedServer) DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidRenameFiles(ctx context.Context, params *RenameFilesParams) error { +func (UnimplementedServer) WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) error { +func (UnimplementedServer) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) error { +func (UnimplementedServer) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) Exit(ctx context.Context) error { +func (UnimplementedServer) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) Initialized(ctx context.Context, params *InitializedParams) error { +func (UnimplementedServer) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) SetTrace(ctx context.Context, params *SetTraceParams) error { +func (UnimplementedServer) DidCreateFiles(ctx context.Context, params *CreateFilesParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) error { +func (UnimplementedServer) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error { return jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error { +func (UnimplementedServer) DidRenameFiles(ctx context.Context, params *RenameFilesParams) error { return jsonrpc2.ErrInternal } @@ -482,79 +482,71 @@ func (UnimplementedServer) CallHierarchyOutgoingCalls(ctx context.Context, param return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) { - return nil, jsonrpc2.ErrInternal -} - -func (UnimplementedServer) CodeAction(ctx context.Context, params *CodeActionParams) (*CodeActionRequestResult, error) { - return nil, jsonrpc2.ErrInternal -} - func (UnimplementedServer) CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) CodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) { +func (UnimplementedServer) CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) { +func (UnimplementedServer) CompletionResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) ColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) { +func (UnimplementedServer) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) Completion(ctx context.Context, params *CompletionParams) (*CompletionResult, error) { +func (UnimplementedServer) Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) CompletionResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) { +func (UnimplementedServer) InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) Declaration(ctx context.Context, params *DeclarationParams) (*DeclarationResult, error) { - return nil, jsonrpc2.ErrInternal +func (UnimplementedServer) Shutdown(ctx context.Context) error { + return jsonrpc2.ErrInternal } -func (UnimplementedServer) Definition(ctx context.Context, params *DefinitionParams) (*DefinitionResult, error) { +func (UnimplementedServer) CodeAction(ctx context.Context, params *CodeActionParams) (*CodeActionRequestResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) { +func (UnimplementedServer) CodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) { +func (UnimplementedServer) ColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) { +func (UnimplementedServer) Completion(ctx context.Context, params *CompletionParams) (*CompletionResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) { +func (UnimplementedServer) Declaration(ctx context.Context, params *DeclarationParams) (*DeclarationResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) { +func (UnimplementedServer) Definition(ctx context.Context, params *DefinitionParams) (*DefinitionResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) { +func (UnimplementedServer) DocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) { +func (UnimplementedServer) DocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) { +func (UnimplementedServer) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) { +func (UnimplementedServer) DocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) { return nil, jsonrpc2.ErrInternal } @@ -562,11 +554,11 @@ func (UnimplementedServer) DocumentSymbol(ctx context.Context, params *DocumentS return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) { +func (UnimplementedServer) FoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) FoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) { +func (UnimplementedServer) DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } @@ -578,31 +570,31 @@ func (UnimplementedServer) Implementation(ctx context.Context, params *Implement return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) { +func (UnimplementedServer) InlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) InlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) { +func (UnimplementedServer) InlineCompletion(ctx context.Context, params *InlineCompletionParams) (*InlineCompletionResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) { +func (UnimplementedServer) InlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) InlineCompletion(ctx context.Context, params *InlineCompletionParams) (*InlineCompletionResult, error) { +func (UnimplementedServer) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) InlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) { +func (UnimplementedServer) Moniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) { +func (UnimplementedServer) DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) Moniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) { +func (UnimplementedServer) CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) { return nil, jsonrpc2.ErrInternal } @@ -610,23 +602,27 @@ func (UnimplementedServer) PrepareRename(ctx context.Context, params *PrepareRen return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) References(ctx context.Context, params *ReferenceParams) ([]*Location, error) { +func (UnimplementedServer) TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) Rename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) { +func (UnimplementedServer) DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) SelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) { +func (UnimplementedServer) DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) SemanticTokensDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*SemanticTokensDeltaResult, error) { +func (UnimplementedServer) References(ctx context.Context, params *ReferenceParams) ([]*Location, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) { +func (UnimplementedServer) Rename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) SelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) { return nil, jsonrpc2.ErrInternal } @@ -634,15 +630,15 @@ func (UnimplementedServer) SemanticTokens(ctx context.Context, params *SemanticT return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) Shutdown(ctx context.Context) error { - return jsonrpc2.ErrInternal +func (UnimplementedServer) SemanticTokensDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*SemanticTokensDeltaResult, error) { + return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) { +func (UnimplementedServer) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) { +func (UnimplementedServer) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) { return nil, jsonrpc2.ErrInternal } @@ -650,7 +646,7 @@ func (UnimplementedServer) TypeDefinition(ctx context.Context, params *TypeDefin return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) { +func (UnimplementedServer) WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) { return nil, jsonrpc2.ErrInternal } @@ -662,27 +658,31 @@ func (UnimplementedServer) TypeHierarchySupertypes(ctx context.Context, params * return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) { +func (UnimplementedServer) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) { +func (UnimplementedServer) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) { +func (UnimplementedServer) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) { +func (UnimplementedServer) TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) { +func (UnimplementedServer) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) { return nil, jsonrpc2.ErrInternal } -func (UnimplementedServer) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) { +func (UnimplementedServer) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) { return nil, jsonrpc2.ErrInternal } diff --git a/protocol/types_generics.go b/protocol/types_generics.go index 7ad1ade2..96a19860 100644 --- a/protocol/types_generics.go +++ b/protocol/types_generics.go @@ -173,47 +173,6 @@ func (t *CodeActionRequestResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} } -// CodeActionRequestResult a request to provide commands for the given text document and range. -type CodeActionRequestResult struct { - value any -} - -func NewCodeActionRequestResult[T Command | CodeAction](val T) *CodeActionRequestResult { - return &CodeActionRequestResult{ - value: val, - } -} - -func (t CodeActionRequestResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Command: - return marshal(val) - case CodeAction: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *CodeActionRequestResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Command - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 CodeAction - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} -} - // CompletionItemDefaultsEditRange a default edit range. // // @since 3.17.0 @@ -383,48 +342,6 @@ func (t *CompletionResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} } -// CompletionResult request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, -// `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. -type CompletionResult struct { - value any -} - -func NewCompletionResult[T []CompletionItem | CompletionList](val T) *CompletionResult { - return &CompletionResult{ - value: val, - } -} - -func (t CompletionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case []CompletionItem: - return marshal(val) - case CompletionList: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *CompletionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 []CompletionItem - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 CompletionList - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} -} - // DeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a // typed array of DeclarationLink or a Thenable that resolves to such. type DeclarationResult struct { @@ -467,90 +384,6 @@ func (t *DeclarationResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [Declaration []DeclarationLink]"} } -// DeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a -// typed array of DeclarationLink or a Thenable that resolves to such. -type DeclarationResult struct { - value any -} - -func NewDeclarationResult[T Declaration | []DeclarationLink](val T) *DeclarationResult { - return &DeclarationResult{ - value: val, - } -} - -func (t DeclarationResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Declaration: - return marshal(val) - case []DeclarationLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *DeclarationResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Declaration - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DeclarationLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Declaration []DeclarationLink]"} -} - -// DefinitionResult a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed -// array of DefinitionLink or a Thenable that resolves to such. -type DefinitionResult struct { - value any -} - -func NewDefinitionResult[T Definition | []DefinitionLink](val T) *DefinitionResult { - return &DefinitionResult{ - value: val, - } -} - -func (t DefinitionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Definition: - return marshal(val) - case []DefinitionLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *DefinitionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Definition - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DefinitionLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} -} - // DefinitionResult a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed // array of DefinitionLink or a Thenable that resolves to such. type DefinitionResult struct { @@ -674,7 +507,6 @@ func (t *DidChangeConfigurationRegistrationOptionsSection) UnmarshalJSON(val []b return &UnmarshalError{"unmarshal failed to match one of [string []string]"} } -// @since 3.17.0 type DocumentDiagnosticReportPartialResultRelatedDocuments struct { value any } @@ -757,48 +589,6 @@ func (t *DocumentSymbolResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} } -// DocumentSymbolResult a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that -// resolves to such. -type DocumentSymbolResult struct { - value any -} - -func NewDocumentSymbolResult[T []SymbolInformation | []DocumentSymbol](val T) DocumentSymbolResult { - return DocumentSymbolResult{ - value: val, - } -} - -func (t DocumentSymbolResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case []SymbolInformation: - return marshal(val) - case []DocumentSymbol: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *DocumentSymbolResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 []SymbolInformation - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DocumentSymbol - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} -} - // HoverContents the hover's content. type HoverContents struct { value any @@ -889,48 +679,6 @@ func (t *ImplementationResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} } -// ImplementationResult a request to resolve the implementation locations of a symbol at a given text document position. The -// request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. -type ImplementationResult struct { - value any -} - -func NewImplementationResult[T Definition | []DefinitionLink](val T) *ImplementationResult { - return &ImplementationResult{ - value: val, - } -} - -func (t ImplementationResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Definition: - return marshal(val) - case []DefinitionLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *ImplementationResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Definition - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DefinitionLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} -} - // InlayHintLabel the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty. type InlayHintLabel struct { value any @@ -1138,49 +886,6 @@ func (t *InlineCompletionResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} } -// InlineCompletionResult a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. -// -// @since 3.18.0 proposed -type InlineCompletionResult struct { - value any -} - -func NewInlineCompletionResult[T InlineCompletionList | []InlineCompletionItem](val T) *InlineCompletionResult { - return &InlineCompletionResult{ - value: val, - } -} - -func (t InlineCompletionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case InlineCompletionList: - return marshal(val) - case []InlineCompletionItem: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *InlineCompletionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 InlineCompletionList - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []InlineCompletionItem - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} -} - // NotebookCellTextDocumentFilterNotebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. type NotebookCellTextDocumentFilterNotebook struct { value any @@ -1305,8 +1010,6 @@ func (t *NotebookDocumentFilterWithNotebookNotebook) UnmarshalJSON(val []byte) e } // NotebookDocumentSyncOptionsNotebookSelector the notebooks to be synced. -// -// @since 3.17.0 type NotebookDocumentSyncOptionsNotebookSelector struct { value any } @@ -1600,49 +1303,6 @@ func (t *SemanticTokensDeltaResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} } -// SemanticTokensDeltaResult. -// -// @since 3.16.0 -type SemanticTokensDeltaResult struct { - value any -} - -func NewSemanticTokensDeltaResult[T SemanticTokens | SemanticTokensDelta](val T) *SemanticTokensDeltaResult { - return &SemanticTokensDeltaResult{ - value: val, - } -} - -func (t SemanticTokensDeltaResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case SemanticTokens: - return marshal(val) - case SemanticTokensDelta: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *SemanticTokensDeltaResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 SemanticTokens - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 SemanticTokensDelta - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} -} - // SemanticTokensOptionsFull server supports providing semantic tokens for a full document. type SemanticTokensOptionsFull struct { value any @@ -2979,6 +2639,8 @@ func (t *SignatureInformationDocumentation) UnmarshalJSON(val []byte) error { } // TextDocumentEditEdits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. +// +// @since 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. type TextDocumentEditEdits struct { value any } @@ -3108,47 +2770,6 @@ func (t *TypeDefinitionResult) UnmarshalJSON(val []byte) error { return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} } -// TypeDefinitionResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. -type TypeDefinitionResult struct { - value any -} - -func NewTypeDefinitionResult[T Definition | []DefinitionLink](val T) *TypeDefinitionResult { - return &TypeDefinitionResult{ - value: val, - } -} - -func (t TypeDefinitionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Definition: - return marshal(val) - case []DefinitionLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *TypeDefinitionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Definition - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DefinitionLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} -} - // WorkspaceEditDocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are // either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. type WorkspaceEditDocumentChanges struct { @@ -3375,47 +2996,3 @@ func (t *WorkspaceSymbolResult) UnmarshalJSON(val []byte) error { } return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []WorkspaceSymbol]"} } - -// WorkspaceSymbolResult a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. -// The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. -// -// @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. -type WorkspaceSymbolResult struct { - value any -} - -func NewWorkspaceSymbolResult[T []SymbolInformation | []WorkspaceSymbol](val T) WorkspaceSymbolResult { - return WorkspaceSymbolResult{ - value: val, - } -} - -func (t WorkspaceSymbolResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case []SymbolInformation: - return marshal(val) - case []WorkspaceSymbol: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} - -func (t *WorkspaceSymbolResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 []SymbolInformation - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []WorkspaceSymbol - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []WorkspaceSymbol]"} -} diff --git a/protocol/workspace.go b/protocol/workspace.go index 16a6ec18..aacd5e8a 100644 --- a/protocol/workspace.go +++ b/protocol/workspace.go @@ -349,7 +349,7 @@ type WorkspaceFoldersServerCapabilities struct { Supported bool `json:"supported,omitempty"` // ChangeNotifications whether the server wants to receive workspace folder change notifications. If a string is provided the string is treated as an ID under which the notification is registered on the client side. The ID can be used to unregister for these events using the `client/unregisterCapability` request. - ChangeNotifications WorkspaceFoldersServerCapabilitiesChangeNotifications `json:"changeNotifications,omitempty"` + ChangeNotifications *WorkspaceFoldersServerCapabilitiesChangeNotifications `json:"changeNotifications,omitempty"` } // DidChangeConfigurationParams the parameters of a change configuration notification. @@ -359,7 +359,7 @@ type DidChangeConfigurationParams struct { } type DidChangeConfigurationRegistrationOptions struct { - Section DidChangeConfigurationRegistrationOptionsSection `json:"section,omitempty"` + Section *DidChangeConfigurationRegistrationOptionsSection `json:"section,omitempty"` } // FileEvent an event describing a file change. diff --git a/tools/protocol-gen/generator/client_server.go b/tools/protocol-gen/generator/client_server.go index 3af688e8..b82a91b6 100644 --- a/tools/protocol-gen/generator/client_server.go +++ b/tools/protocol-gen/generator/client_server.go @@ -20,28 +20,28 @@ func (gen *Generator) ClientToServer(clientNotifications, bidiNotifications []*p g.PP(`const (`) if len(bidiNotifications) > 0 { slices.SortFunc(bidiNotifications, func(a, b *protocol.Notification) int { - return cmp.Compare(strings.ToLower(a.TypeName), strings.ToLower(b.TypeName)) + return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) }) for _, meth := range bidiNotifications { g.PP(` `, `MethodClient`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect client notification`) } } slices.SortFunc(clientNotifications, func(a, b *protocol.Notification) int { - return cmp.Compare(strings.ToLower(a.TypeName), strings.ToLower(b.TypeName)) + return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) }) for _, meth := range clientNotifications { g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // client notification`) } if len(bidiRequests) > 0 { slices.SortFunc(bidiRequests, func(a, b *protocol.Request) int { - return cmp.Compare(strings.ToLower(a.TypeName), strings.ToLower(b.TypeName)) + return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) }) for _, meth := range bidiRequests { g.PP(` `, `MethodClient`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect client request`) } } slices.SortFunc(clientRequests, func(a, b *protocol.Request) int { - return cmp.Compare(strings.ToLower(a.TypeName), strings.ToLower(b.TypeName)) + return cmp.Compare(strings.ToLower(a.Method), strings.ToLower(b.Method)) }) for _, meth := range clientRequests { g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ClientMethod `, ` = `, strconv.Quote(meth.Method), ` // client request`) @@ -113,6 +113,8 @@ func (gen *Generator) ClientToServer(clientNotifications, bidiNotifications []*p g.PP(`// UnimplementedClient should be embedded to have forward compatible implementations.`) g.PP(`type UnimplementedClient struct {}`) g.P("\n") + g.PP(`var _ Client = UnimplementedClient{}`) + g.P("\n") for i, notify := range notifications { meth := normalizeMethodName(notify.TypeName) meth = strings.TrimSuffix(meth, "Notification") @@ -168,28 +170,28 @@ func (gen *Generator) ServerToClient(serverNotifications, bidiNotifications []*p g.PP(`const (`) if len(bidiNotifications) > 0 { slices.SortFunc(bidiNotifications, func(a, b *protocol.Notification) int { - return cmp.Compare(a.TypeName, b.TypeName) + return cmp.Compare(a.Method, b.Method) }) for _, meth := range bidiNotifications { g.PP(` `, `MethodServer`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect server notification`) } } slices.SortFunc(serverNotifications, func(a, b *protocol.Notification) int { - return cmp.Compare(a.TypeName, b.TypeName) + return cmp.Compare(a.Method, b.Method) }) for _, meth := range serverNotifications { g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // server notification`) } if len(bidiRequests) > 0 { slices.SortFunc(bidiRequests, func(a, b *protocol.Request) int { - return cmp.Compare(a.TypeName, b.TypeName) + return cmp.Compare(a.Method, b.Method) }) for _, meth := range bidiRequests { g.PP(` `, `MethodServer`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // bidirect server request`) } } slices.SortFunc(serverNequests, func(a, b *protocol.Request) int { - return cmp.Compare(a.TypeName, b.TypeName) + return cmp.Compare(a.Method, b.Method) }) for _, meth := range serverNequests { g.PP(` `, `Method`+normalizeMethodName(meth.Method), ` ServerMethod `, ` = `, strconv.Quote(meth.Method), ` // server request`) @@ -255,14 +257,14 @@ func (gen *Generator) ServerToClient(serverNotifications, bidiNotifications []*p g.P("\n") } } - g.P("\n") - g.PP(`Request(ctx context.Context, method string, params any) (any, error)`) g.PP(`}`) g.P("\n") g.PP(`// UnimplementedServer should be embedded to have forward compatible implementations.`) g.PP(`type UnimplementedServer struct {}`) g.P("\n") + g.PP(`var _ Server = UnimplementedServer{}`) + g.P("\n") for i, notify := range notifications { meth := normalizeMethodName(notify.TypeName) meth = strings.TrimSuffix(meth, "Notification") @@ -374,11 +376,12 @@ func (gen *Generator) request(g Printer, meth string, req *protocol.Request) (nR gen.renderRequestssOrTypeNull(g, req, r) g.P(`, `) default: - genericsProp := &protocol.Property{ + genericsProp := GenericsTypes{ Name: meth + "Result", Documentation: req.Documentation, Since: req.Since, Proposed: req.Proposed, + Deprecated: req.Deprecated, } gen.renderRequestssOrType(g, r, genericsProp) g.P(`, `) @@ -410,11 +413,12 @@ func (gen *Generator) renderRequestsArrayType(g Printer, req *protocol.Request, g.P(`[]*`) gen.renderRequestssOrTypeNull(g, req, elem) default: - genericsProp := &protocol.Property{ + genericsProp := GenericsTypes{ Name: normalizeMethodName(req.TypeName) + "Result", Documentation: req.Documentation, Since: req.Since, Proposed: req.Proposed, + Deprecated: req.Deprecated, } gen.renderRequestssOrType(g, elem, genericsProp) } @@ -447,7 +451,7 @@ func (gen *Generator) renderRequestssOrTypeNull(g Printer, req *protocol.Request } } -func (gen *Generator) renderRequestssOrType(g Printer, or *protocol.OrType, genericsProp *protocol.Property) { +func (gen *Generator) renderRequestssOrType(g Printer, or *protocol.OrType, genericsProp GenericsTypes) { g.P(` *`, genericsProp.Name) gen.genericsTypes[genericsProp] = or.Items } diff --git a/tools/protocol-gen/generator/generator.go b/tools/protocol-gen/generator/generator.go index f5b9e512..39a5669b 100644 --- a/tools/protocol-gen/generator/generator.go +++ b/tools/protocol-gen/generator/generator.go @@ -58,6 +58,29 @@ const ( pkgJSONRPC = `"go.lsp.dev/jsonrpc2"` ) +type GenericsTypes struct { + // The property name. + Name string + + // Whether the property is optional. If omitted, the property is mandatory. + Optional bool + + // An optional documentation. + Documentation string + + // Since when (release number) this property is available. Is undefined if not known. + Since string + + // Whether this is a proposed property. If omitted, the structure is final. + Proposed bool + + // Whether the property is deprecated or not. If deprecated the property contains the deprecation message. + Deprecated string + + // The property JSON name. + JSONName string +} + type Generator struct { enumerations []Printer typeAliases []Printer @@ -65,13 +88,13 @@ type Generator struct { client []Printer server []Printer generics map[string]bool - genericsTypes map[*protocol.Property][]protocol.Type + genericsTypes map[GenericsTypes][]protocol.Type files map[string]*os.File } func (gen *Generator) Init() { gen.generics = make(map[string]bool) - gen.genericsTypes = make(map[*protocol.Property][]protocol.Type) + gen.genericsTypes = make(map[GenericsTypes][]protocol.Type) gen.files = make(map[string]*os.File) } diff --git a/tools/protocol-gen/generator/generics_types.go b/tools/protocol-gen/generator/generics_types.go index 736b9d1c..51a91edf 100644 --- a/tools/protocol-gen/generator/generics_types.go +++ b/tools/protocol-gen/generator/generics_types.go @@ -16,13 +16,13 @@ import ( func (gen *Generator) GenericsTypes() error { g := NewPrinter("types_generics") - sorted := make([]*protocol.Property, len(gen.genericsTypes)) + sorted := make([]GenericsTypes, len(gen.genericsTypes)) i := 0 for generics := range gen.genericsTypes { sorted[i] = generics i++ } - slices.SortFunc(sorted, func(a, b *protocol.Property) int { + slices.SortFunc(sorted, func(a, b GenericsTypes) int { return cmp.Compare(a.Name, b.Name) }) diff --git a/tools/protocol-gen/generator/structure.go b/tools/protocol-gen/generator/structure.go index 04ebc8b8..f5a5849b 100644 --- a/tools/protocol-gen/generator/structure.go +++ b/tools/protocol-gen/generator/structure.go @@ -512,23 +512,27 @@ func (gen *Generator) Structures(structures []*protocol.Structure) error { gen.renderStructuresReferenceType(g, prop, node) case *protocol.ArrayType: - genericsProp := &protocol.Property{ + prop := GenericsTypes{ Name: structuresName + propName, + Optional: prop.Optional, Documentation: prop.Documentation, - Since: structure.Since, - Proposed: structure.Proposed, + Since: prop.Since, + Proposed: prop.Proposed, + Deprecated: prop.Deprecated, } g.P(` `) - gen.renderStructuresArrayTypeGeneric(g, node, genericsProp) + gen.renderStructuresArrayTypeGeneric(g, node, prop) case *protocol.MapType: - genericsProp := &protocol.Property{ + prop := GenericsTypes{ Name: structuresName + propName, + Optional: prop.Optional, Documentation: prop.Documentation, - Since: structure.Since, - Proposed: structure.Proposed, + Since: prop.Since, + Proposed: prop.Proposed, + Deprecated: prop.Deprecated, } - gen.renderStructuresMapType(g, node, genericsProp) + gen.renderStructuresMapType(g, node, prop) case *protocol.OrType: switch { @@ -554,7 +558,7 @@ func (gen *Generator) Structures(structures []*protocol.Structure) error { if isNull(node.Items...) { prop.Optional = true } - genericsProp := &protocol.Property{ + genericsProp := GenericsTypes{ Name: structuresName + propName, Optional: prop.Optional, Documentation: prop.Documentation, @@ -562,7 +566,12 @@ func (gen *Generator) Structures(structures []*protocol.Structure) error { Since: prop.Since, Deprecated: prop.Deprecated, } - gen.renderStructuresOrType(g, node, genericsProp) + if _, ok := gen.genericsTypes[genericsProp]; !ok { + if _, ok := enumerationNames[genericsProp.Name]; !ok && genericsProp.Optional { + g.P(`*`) + } + gen.renderStructuresOrType(g, node, genericsProp) + } } default: @@ -620,7 +629,7 @@ func (gen *Generator) renderStructuresArrayType(g Printer, array *protocol.Array } } -func (gen *Generator) renderStructuresArrayTypeGeneric(g Printer, array *protocol.ArrayType, genericsProp *protocol.Property) { +func (gen *Generator) renderStructuresArrayTypeGeneric(g Printer, array *protocol.ArrayType, genericsProp GenericsTypes) { elem := array.Element switch elem := elem.(type) { case protocol.BaseType: @@ -630,14 +639,19 @@ func (gen *Generator) renderStructuresArrayTypeGeneric(g Printer, array *protoco g.P(`[]` + normalizeLSPTypes(elem.String())) case *protocol.OrType: - gen.renderStructuresOrType(g, elem, genericsProp) + if _, ok := gen.genericsTypes[genericsProp]; !ok { + if _, ok := enumerationNames[genericsProp.Name]; !ok && genericsProp.Optional { + g.P(`*`) + } + gen.renderStructuresOrType(g, elem, genericsProp) + } default: panic(fmt.Sprintf("structures.ArrayKind: %#v\n", elem)) } } -func (gen *Generator) renderStructuresMapType(g Printer, m *protocol.MapType, genericsProp *protocol.Property) { +func (gen *Generator) renderStructuresMapType(g Printer, m *protocol.MapType, genericsProp GenericsTypes) { g.P(` map`) // write map key @@ -661,14 +675,19 @@ func (gen *Generator) renderStructuresMapType(g Printer, m *protocol.MapType, ge gen.renderStructuresArrayTypeGeneric(g, val, genericsProp) case *protocol.OrType: - gen.renderStructuresOrType(g, val, genericsProp) + if _, ok := gen.genericsTypes[genericsProp]; !ok { + if _, ok := enumerationNames[genericsProp.Name]; !ok && genericsProp.Optional { + g.P(`*`) + } + gen.renderStructuresOrType(g, val, genericsProp) + } default: panic(fmt.Sprintf("structures.MapType.Value: %[1]T = %#[1]v\n", m.Value)) } } -func (gen *Generator) renderStructuresOrType(g Printer, or *protocol.OrType, genericsProp *protocol.Property) { +func (gen *Generator) renderStructuresOrType(g Printer, or *protocol.OrType, genericsProp GenericsTypes) { g.P(` `, genericsProp.Name) gen.genericsTypes[genericsProp] = or.Items } From 79f6e4308fff7e179cd3e393f3d34f6ff716ecca Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Fri, 11 Oct 2024 06:57:16 +0900 Subject: [PATCH 12/19] WIP9 Signed-off-by: Koichi Shiraishi --- base.go | 111 +- base_test.go | 23 +- basic.go | 1050 ++-- basic_test.go | 3213 ---------- callhierarchy.go | 103 - callhierarchy_test.go | 1330 ----- capabilities_client.go | 1068 ---- capabilities_client_test.go | 2787 --------- capabilities_server.go | 523 -- client.go | 353 +- client_interface.go | 209 + deprecated.go | 264 - diagnostics.go | 149 - diagnostics_test.go | 640 -- document.go | 470 ++ general.go | 461 -- general_test.go | 5205 ----------------- go.mod | 1 - go.sum | 2 - handler.go | 19 +- language.go | 3471 +++++++---- language_test.go | 5852 ------------------- lifecycle.go | 1386 +++++ lifecycle_test.go | 146 + progress.go | 119 - progress_test.go | 508 -- registration.go | 44 - registration_test.go | 579 -- selectionrange.go | 110 - semantic_token.go | 179 - server.go | 1875 +++--- server_interface.go | 691 +++ text.go | 111 - text_test.go | 930 --- tools/protocol-gen/generator/generator.go | 6 +- tools/protocol-gen/generator/typealiases.go | 14 +- tools/protocol-gen/main.go | 1 - type_alias.go | 602 ++ types.go | 20 + types_generics.go | 2998 ++++++++++ util.go | 9 - util_test.go | 33 - window.go | 155 +- window_test.go | 792 --- workspace.go | 559 +- workspace_test.go | 1696 ------ 46 files changed, 11260 insertions(+), 29607 deletions(-) delete mode 100644 basic_test.go delete mode 100644 callhierarchy.go delete mode 100644 callhierarchy_test.go delete mode 100644 capabilities_client.go delete mode 100644 capabilities_client_test.go delete mode 100644 capabilities_server.go create mode 100644 client_interface.go delete mode 100644 deprecated.go delete mode 100644 diagnostics.go delete mode 100644 diagnostics_test.go create mode 100644 document.go delete mode 100644 general.go delete mode 100644 general_test.go delete mode 100644 language_test.go create mode 100644 lifecycle.go create mode 100644 lifecycle_test.go delete mode 100644 progress.go delete mode 100644 progress_test.go delete mode 100644 registration.go delete mode 100644 registration_test.go delete mode 100644 selectionrange.go delete mode 100644 semantic_token.go create mode 100644 server_interface.go delete mode 100644 text.go delete mode 100644 text_test.go create mode 100644 type_alias.go create mode 100644 types.go create mode 100644 types_generics.go delete mode 100644 util.go delete mode 100644 util_test.go delete mode 100644 window_test.go delete mode 100644 workspace_test.go diff --git a/base.go b/base.go index 49822ee8..28c99bcd 100644 --- a/base.go +++ b/base.go @@ -1,96 +1,57 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors +// Copyright 2024 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol -import ( - "fmt" +// ErrorCodes predefined error codes. +type ErrorCodes int32 - "github.com/segmentio/encoding/json" -) +const ( + ParseErrorErrorCodes ErrorCodes = -32700 -// CancelParams params of cancelRequest. -type CancelParams struct { - // ID is the request id to cancel. - ID interface{} `json:"id"` // int32 | string -} + InvalidRequestErrorCodes ErrorCodes = -32600 -// ProgressParams params of Progress netification. -// -// @since 3.15.0. -type ProgressParams struct { - // Token is the progress token provided by the client or server. - Token ProgressToken `json:"token"` + MethodNotFoundErrorCodes ErrorCodes = -32601 - // Value is the progress data. - Value interface{} `json:"value"` -} + InvalidParamsErrorCodes ErrorCodes = -32602 -// ProgressToken is the progress token provided by the client or server. -// -// @since 3.15.0. -type ProgressToken struct { - name string - number int32 -} + InternalErrorErrorCodes ErrorCodes = -32603 + + // ServerNotInitializedErrorCodes error code indicating that a server received a notification or request before the server has received the `initialize` request. + ServerNotInitializedErrorCodes ErrorCodes = -32002 -// compile time check whether the ProgressToken implements a fmt.Formatter, fmt.Stringer, json.Marshaler and json.Unmarshaler interfaces. -var ( - _ fmt.Formatter = (*ProgressToken)(nil) - _ fmt.Stringer = (*ProgressToken)(nil) - _ json.Marshaler = (*ProgressToken)(nil) - _ json.Unmarshaler = (*ProgressToken)(nil) + UnknownErrorCodeErrorCodes ErrorCodes = -32001 ) -// NewProgressToken returns a new ProgressToken. -func NewProgressToken(s string) *ProgressToken { - return &ProgressToken{name: s} -} +type LSPErrorCodes int32 -// NewNumberProgressToken returns a new number ProgressToken. -func NewNumberProgressToken(n int32) *ProgressToken { - return &ProgressToken{number: n} -} +const ( + // RequestFailedLSPErrorCodes a request failed but it was syntactically correct, e.g the method name was known and the parameters were valid. The error message should contain human readable information about why the request failed. + // + // @since 3.17.0 + RequestFailedLSPErrorCodes LSPErrorCodes = -32803 -// Format writes the ProgressToken to the formatter. -// -// If the rune is q the representation is non ambiguous, -// string forms are quoted. -func (v ProgressToken) Format(f fmt.State, r rune) { - const numF = `%d` - strF := `%s` - if r == 'q' { - strF = `%q` - } - - switch { - case v.name != "": - fmt.Fprintf(f, strF, v.name) - default: - fmt.Fprintf(f, numF, v.number) - } -} + // ServerCancelledLSPErrorCodes the server cancelled the request. This error code should only be used for requests that explicitly support being server cancellable. + // + // @since 3.17.0 + ServerCancelledLSPErrorCodes LSPErrorCodes = -32802 -// String returns a string representation of the ProgressToken. -func (v ProgressToken) String() string { - return fmt.Sprint(v) //nolint:gocritic -} + // ContentModifiedLSPErrorCodes the server detected that the content of a document got modified outside normal conditions. A server should NOT send this error code if it detects a content change in it unprocessed messages. The result even computed on an older state might still be useful for the client. If a client decides that a result is not of any use anymore the client should cancel the request. + ContentModifiedLSPErrorCodes LSPErrorCodes = -32801 -// MarshalJSON implements json.Marshaler. -func (v *ProgressToken) MarshalJSON() ([]byte, error) { - if v.name != "" { - return json.Marshal(v.name) - } + // RequestCancelledLSPErrorCodes the client has canceled a request and a server has detected the cancel. + RequestCancelledLSPErrorCodes LSPErrorCodes = -32800 +) - return json.Marshal(v.number) +type CancelParams struct { + // ID the request id to cancel. + ID CancelParamsID `json:"id"` } -// UnmarshalJSON implements json.Unmarshaler. -func (v *ProgressToken) UnmarshalJSON(data []byte) error { - *v = ProgressToken{} - if err := json.Unmarshal(data, &v.number); err == nil { - return nil - } +type ProgressParams struct { + // Token the progress token provided by the client or server. + Token ProgressToken `json:"token"` - return json.Unmarshal(data, &v.name) + // Value the progress data. + Value any `json:"value"` } diff --git a/base_test.go b/base_test.go index c62bc33e..de5351b5 100644 --- a/base_test.go +++ b/base_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "github.com/segmentio/encoding/json" ) func TestCancelParams(t *testing.T) { @@ -17,7 +16,7 @@ func TestCancelParams(t *testing.T) { const want = `{"id":"testID"}` wantType := CancelParams{ - ID: "testID", + ID: NewCancelParamsID("testID"), } t.Run("Marshal", func(t *testing.T) { @@ -40,11 +39,10 @@ func TestCancelParams(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() - got, err := json.Marshal(&tt.field) + got, err := marshal(&tt.field) if (err != nil) != tt.wantMarshalErr { t.Fatal(err) } @@ -76,16 +74,17 @@ func TestCancelParams(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() var got CancelParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { + if err := unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { t.Fatal(err) } - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { + if diff := cmp.Diff(tt.want, got, + cmpopts.EquateComparable(CancelParams{}), + ); (diff != "") != tt.wantErr { t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) } }) @@ -101,7 +100,7 @@ func TestProgressParams(t *testing.T) { token := NewProgressToken(wantWorkDoneToken) wantType := ProgressParams{ - Token: *token, + Token: token, Value: "testValue", } @@ -125,11 +124,10 @@ func TestProgressParams(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() - got, err := json.Marshal(&tt.field) + got, err := marshal(&tt.field) if (err != nil) != tt.wantMarshalErr { t.Fatal(err) } @@ -161,12 +159,11 @@ func TestProgressParams(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() var got ProgressParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { + if err := unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { t.Fatal(err) } @@ -175,7 +172,7 @@ func TestProgressParams(t *testing.T) { } if token := got.Token; !reflect.ValueOf(token).IsZero() { - if diff := cmp.Diff(token.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { + if diff := cmp.Diff(token, wantWorkDoneToken); (diff != "") != tt.wantErr { t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) } } diff --git a/basic.go b/basic.go index ec379cf2..93e85134 100644 --- a/basic.go +++ b/basic.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// Copyright 2024 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol @@ -7,699 +7,643 @@ import ( "go.lsp.dev/uri" ) -// DocumentURI represents the URI of a document. -// -// Many of the interfaces contain fields that correspond to the URI of a document. -// For clarity, the type of such a field is declared as a DocumentURI. -// Over the wire, it will still be transferred as a string, but this guarantees -// that the contents of that string can be parsed as a valid URI. -type DocumentURI = uri.URI +type TraceValue string -// URI a tagging interface for normal non document URIs. -// -// @since 3.16.0. -type URI = uri.URI +const ( + // OffTraceValue turn tracing off. + OffTraceValue TraceValue = "off" -// EOL denotes represents the character offset. -var EOL = []string{"\n", "\r\n", "\r"} + // MessagesTraceValue trace messages only. + MessagesTraceValue TraceValue = "messages" -// Position represents a text document expressed as zero-based line and zero-based character offset. -// -// The offsets are based on a UTF-16 string representation. -// So a string of the form "a𐐀b" the character offset of the character "a" is 0, -// the character offset of "𐐀" is 1 and the character offset of "b" is 3 since 𐐀 is represented using two code -// units in UTF-16. -// -// Positions are line end character agnostic. So you can not specify a position that -// denotes "\r|\n" or "\n|" where "|" represents the character offset. -// -// Position is between two characters like an "insert" cursor in a editor. -// Special values like for example "-1" to denote the end of a line are not supported. -type Position struct { - // Line position in a document (zero-based). - // - // If a line number is greater than the number of lines in a document, it defaults back to the number of lines in - // the document. - // If a line number is negative, it defaults to 0. - Line uint32 `json:"line"` + // VerboseTraceValue verbose message tracing. + VerboseTraceValue TraceValue = "verbose" +) - // Character offset on a line in a document (zero-based). - // - // Assuming that the line is represented as a string, the Character value represents the gap between the - // "character" and "character + 1". - // - // If the character value is greater than the line length it defaults back to the line length. - // If a line number is negative, it defaults to 0. - Character uint32 `json:"character"` -} +// MarkupKind describes the content type that a client supports in various result literals like `Hover`, `ParameterInfo` or `CompletionItem`. Please note that `MarkupKinds` must not start with a `$`. This kinds are +// reserved for internal usage. +type MarkupKind string + +const ( + // PlainTextMarkupKind plain text is supported as a content format. + PlainTextMarkupKind MarkupKind = "plaintext" -// Range represents a text document expressed as (zero-based) start and end positions. + // MarkdownMarkupKind markdown is supported as a content format. + MarkdownMarkupKind MarkupKind = "markdown" +) + +// LanguageKind predefined Language kinds 3.18.0 @proposed. // -// A range is comparable to a selection in an editor. Therefore the end position is exclusive. -// If you want to specify a range that contains a line including the line ending character(s) then use an end position -// denoting the start of the next line. -type Range struct { - // Start is the range's start position. - Start Position `json:"start"` +// @since 3.18.0 proposed +type LanguageKind string - // End is the range's end position. - End Position `json:"end"` -} +const ( + AbapLanguageKind LanguageKind = "abap" -// Location represents a location inside a resource, such as a line inside a text file. -type Location struct { - URI DocumentURI `json:"uri"` - Range Range `json:"range"` -} + WindowsBatLanguageKind LanguageKind = "bat" -// LocationLink represents a link between a source and a target location. -type LocationLink struct { - // OriginSelectionRange span of the origin of this link. - // - // Used as the underlined span for mouse interaction. Defaults to the word range at the mouse position. - OriginSelectionRange *Range `json:"originSelectionRange,omitempty"` + BibTeXLanguageKind LanguageKind = "bibtex" - // TargetURI is the target resource identifier of this link. - TargetURI DocumentURI `json:"targetUri"` + ClojureLanguageKind LanguageKind = "clojure" - // TargetRange is the full target range of this link. - // - // If the target for example is a symbol then target range is the range enclosing this symbol not including - // leading/trailing whitespace but everything else like comments. + CoffeescriptLanguageKind LanguageKind = "coffeescript" + + CLanguageKind LanguageKind = "c" + + CppLanguageKind LanguageKind = "cpp" + + CsharpLanguageKind LanguageKind = "csharp" + + CssLanguageKind LanguageKind = "css" + + // DLanguageKind. // - // This information is typically used to highlight the range in the editor. - TargetRange Range `json:"targetRange"` + // @since 3.18.0 proposed + DLanguageKind LanguageKind = "d" - // TargetSelectionRange is the range that should be selected and revealed when this link is being followed, - // e.g the name of a function. + // DelphiLanguageKind. // - // Must be contained by the TargetRange. See also DocumentSymbol#range - TargetSelectionRange Range `json:"targetSelectionRange"` -} + // @since 3.18.0 proposed + DelphiLanguageKind LanguageKind = "pascal" -// Command represents a reference to a command. Provides a title which will be used to represent a command in the UI. -// -// Commands are identified by a string identifier. -// The recommended way to handle commands is to implement their execution on the server side if the client and -// server provides the corresponding capabilities. -// -// Alternatively the tool extension code could handle the command. The protocol currently doesn't specify -// a set of well-known commands. -type Command struct { - // Title of the command, like `save`. - Title string `json:"title"` + DiffLanguageKind LanguageKind = "diff" - // Command is the identifier of the actual command handler. - Command string `json:"command"` + DartLanguageKind LanguageKind = "dart" - // Arguments that the command handler should be invoked with. - Arguments []interface{} `json:"arguments,omitempty"` -} + DockerfileLanguageKind LanguageKind = "dockerfile" -// TextEdit is a textual edit applicable to a text document. -type TextEdit struct { - // Range is the range of the text document to be manipulated. - // - // To insert text into a document create a range where start == end. - Range Range `json:"range"` + ElixirLanguageKind LanguageKind = "elixir" - // NewText is the string to be inserted. For delete operations use an - // empty string. - NewText string `json:"newText"` -} + ErlangLanguageKind LanguageKind = "erlang" -// ChangeAnnotation is the additional information that describes document changes. -// -// @since 3.16.0. -type ChangeAnnotation struct { - // Label a human-readable string describing the actual change. - // The string is rendered prominent in the user interface. - Label string `json:"label"` + FsharpLanguageKind LanguageKind = "fsharp" - // NeedsConfirmation is a flag which indicates that user confirmation is needed - // before applying the change. - NeedsConfirmation bool `json:"needsConfirmation,omitempty"` + GitCommitLanguageKind LanguageKind = "git-commit" - // Description is a human-readable string which is rendered less prominent in - // the user interface. - Description string `json:"description,omitempty"` -} + GitRebaseLanguageKind LanguageKind = "rebase" -// ChangeAnnotationIdentifier an identifier referring to a change annotation managed by a workspace -// edit. -// -// @since 3.16.0. -type ChangeAnnotationIdentifier string + GoLanguageKind LanguageKind = "go" -// AnnotatedTextEdit is a special text edit with an additional change annotation. -// -// @since 3.16.0. -type AnnotatedTextEdit struct { - TextEdit + GroovyLanguageKind LanguageKind = "groovy" - // AnnotationID is the actual annotation identifier. - AnnotationID ChangeAnnotationIdentifier `json:"annotationId"` -} + HandlebarsLanguageKind LanguageKind = "handlebars" -// TextDocumentEdit describes textual changes on a single text document. -// -// The TextDocument is referred to as a OptionalVersionedTextDocumentIdentifier to allow clients to check the -// text document version before an edit is applied. -// -// TextDocumentEdit describes all changes on a version "Si" and after they are applied move the document to -// version "Si+1". -// So the creator of a TextDocumentEdit doesn't need to sort the array or do any kind of ordering. However the -// edits must be non overlapping. -type TextDocumentEdit struct { - // TextDocument is the text document to change. - TextDocument OptionalVersionedTextDocumentIdentifier `json:"textDocument"` + HaskellLanguageKind LanguageKind = "haskell" - // Edits is the edits to be applied. - // - // @since 3.16.0 - support for AnnotatedTextEdit. - // This is guarded by the client capability Workspace.WorkspaceEdit.ChangeAnnotationSupport. - Edits []TextEdit `json:"edits"` // []TextEdit | []AnnotatedTextEdit -} + HTMLLanguageKind LanguageKind = "html" -// ResourceOperationKind is the file event type. -type ResourceOperationKind string + IniLanguageKind LanguageKind = "ini" -const ( - // CreateResourceOperation supports creating new files and folders. - CreateResourceOperation ResourceOperationKind = "create" + JavaLanguageKind LanguageKind = "java" - // RenameResourceOperation supports renaming existing files and folders. - RenameResourceOperation ResourceOperationKind = "rename" + JavaScriptLanguageKind LanguageKind = "javascript" - // DeleteResourceOperation supports deleting existing files and folders. - DeleteResourceOperation ResourceOperationKind = "delete" -) + JavaScriptReactLanguageKind LanguageKind = "javascriptreact" -// CreateFileOptions represents an options to create a file. -type CreateFileOptions struct { - // Overwrite existing file. Overwrite wins over `ignoreIfExists`. - Overwrite bool `json:"overwrite,omitempty"` + JSONLanguageKind LanguageKind = "json" - // IgnoreIfExists ignore if exists. - IgnoreIfExists bool `json:"ignoreIfExists,omitempty"` -} + LaTeXLanguageKind LanguageKind = "latex" -// CreateFile represents a create file operation. -type CreateFile struct { - // Kind a create. - Kind ResourceOperationKind `json:"kind"` // should be `create` + LessLanguageKind LanguageKind = "less" - // URI is the resource to create. - URI DocumentURI `json:"uri"` + LuaLanguageKind LanguageKind = "lua" + + MakefileLanguageKind LanguageKind = "makefile" + + MarkdownLanguageKind LanguageKind = "markdown" + + ObjectiveCLanguageKind LanguageKind = "objective-c" - // Options additional options. - Options *CreateFileOptions `json:"options,omitempty"` + ObjectiveCPPLanguageKind LanguageKind = "objective-cpp" - // AnnotationID an optional annotation identifier describing the operation. + // PascalLanguageKind. // - // @since 3.16.0. - AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"` -} + // @since 3.18.0 proposed + PascalLanguageKind LanguageKind = "pascal" -// RenameFileOptions represents a rename file options. -type RenameFileOptions struct { - // Overwrite target if existing. Overwrite wins over `ignoreIfExists`. - Overwrite bool `json:"overwrite,omitempty"` + PerlLanguageKind LanguageKind = "perl" - // IgnoreIfExists ignores if target exists. - IgnoreIfExists bool `json:"ignoreIfExists,omitempty"` -} + Perl6LanguageKind LanguageKind = "perl6" -// RenameFile represents a rename file operation. -type RenameFile struct { - // Kind a rename. - Kind ResourceOperationKind `json:"kind"` // should be `rename` + PhpLanguageKind LanguageKind = "php" - // OldURI is the old (existing) location. - OldURI DocumentURI `json:"oldUri"` + PowershellLanguageKind LanguageKind = "powershell" - // NewURI is the new location. - NewURI DocumentURI `json:"newUri"` + PugLanguageKind LanguageKind = "jade" - // Options rename options. - Options *RenameFileOptions `json:"options,omitempty"` + PythonLanguageKind LanguageKind = "python" - // AnnotationID an optional annotation identifier describing the operation. - // - // @since 3.16.0. - AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"` -} + RLanguageKind LanguageKind = "r" -// DeleteFileOptions represents a delete file options. -type DeleteFileOptions struct { - // Recursive delete the content recursively if a folder is denoted. - Recursive bool `json:"recursive,omitempty"` + RazorLanguageKind LanguageKind = "razor" - // IgnoreIfNotExists ignore the operation if the file doesn't exist. - IgnoreIfNotExists bool `json:"ignoreIfNotExists,omitempty"` -} + RubyLanguageKind LanguageKind = "ruby" -// DeleteFile represents a delete file operation. -type DeleteFile struct { - // Kind is a delete. - Kind ResourceOperationKind `json:"kind"` // should be `delete` + RustLanguageKind LanguageKind = "rust" - // URI is the file to delete. - URI DocumentURI `json:"uri"` + ScssLanguageKind LanguageKind = "scss" - // Options delete options. - Options *DeleteFileOptions `json:"options,omitempty"` + SassLanguageKind LanguageKind = "sass" - // AnnotationID an optional annotation identifier describing the operation. - // - // @since 3.16.0. - AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"` -} + ScalaLanguageKind LanguageKind = "scala" + + ShaderLabLanguageKind LanguageKind = "shaderlab" + + ShellScriptLanguageKind LanguageKind = "shellscript" + + SQLLanguageKind LanguageKind = "sql" + + SwiftLanguageKind LanguageKind = "swift" + + TypeScriptLanguageKind LanguageKind = "typescript" + + TypeScriptReactLanguageKind LanguageKind = "typescriptreact" + + TeXLanguageKind LanguageKind = "tex" -// WorkspaceEdit represent a changes to many resources managed in the workspace. + VisualBasicLanguageKind LanguageKind = "vb" + + XmlLanguageKind LanguageKind = "xml" + + XslLanguageKind LanguageKind = "xsl" + + YamlLanguageKind LanguageKind = "yaml" +) + +// PositionEncodingKind a set of predefined position encoding kinds. // -// The edit should either provide changes or documentChanges. -// If the client can handle versioned document edits and if documentChanges are present, the latter are preferred over -// changes. -type WorkspaceEdit struct { - // Changes holds changes to existing resources. - Changes map[DocumentURI][]TextEdit `json:"changes,omitempty"` +// @since 3.17.0 +type PositionEncodingKind string - // DocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes - // are either an array of `TextDocumentEdit`s to express changes to n different text documents - // where each text document edit addresses a specific version of a text document. Or it can contain - // above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. - // - // Whether a client supports versioned document edits is expressed via - // `workspace.workspaceEdit.documentChanges` client capability. - // - // If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then - // only plain `TextEdit`s using the `changes` property are supported. - DocumentChanges []TextDocumentEdit `json:"documentChanges,omitempty"` +const ( + // UTF8PositionEncodingKind character offsets count UTF-8 code units (e.g. bytes). + UTF8PositionEncodingKind PositionEncodingKind = "utf-8" - // ChangeAnnotations is a map of change annotations that can be referenced in - // "AnnotatedTextEdit"s or create, rename and delete file / folder - // operations. - // - // Whether clients honor this property depends on the client capability - // "workspace.changeAnnotationSupport". - // - // @since 3.16.0. - ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"` -} + // Utf16PositionEncodingKind character offsets count UTF-16 code units. This is the default and must always be supported by servers. + Utf16PositionEncodingKind PositionEncodingKind = "utf-16" -// TextDocumentIdentifier indicates the using a URI. On the protocol level, URIs are passed as strings. -type TextDocumentIdentifier struct { - // URI is the text document's URI. - URI DocumentURI `json:"uri"` -} + // Utf32PositionEncodingKind character offsets count UTF-32 code units. Implementation note: these are the same as Unicode codepoints, so this `PositionEncodingKind` may also be used for an encoding-agnostic representation of character offsets. + Utf32PositionEncodingKind PositionEncodingKind = "utf-32" +) -// TextDocumentItem represent an item to transfer a text document from the client to the server. -type TextDocumentItem struct { - // URI is the text document's URI. - URI DocumentURI `json:"uri"` +// DiagnosticSeverity the diagnostic's severity. +type DiagnosticSeverity uint32 - // LanguageID is the text document's language identifier. - LanguageID LanguageIdentifier `json:"languageId"` +const ( + // ErrorDiagnosticSeverity reports an error. + ErrorDiagnosticSeverity DiagnosticSeverity = 1 - // Version is the version number of this document (it will increase after each - // change, including undo/redo). - Version int32 `json:"version"` + // WarningDiagnosticSeverity reports a warning. + WarningDiagnosticSeverity DiagnosticSeverity = 2 - // Text is the content of the opened text document. - Text string `json:"text"` -} + // InformationDiagnosticSeverity reports an information. + InformationDiagnosticSeverity DiagnosticSeverity = 3 + + // HintDiagnosticSeverity reports a hint. + HintDiagnosticSeverity DiagnosticSeverity = 4 +) -// LanguageIdentifier represent a text document's language identifier. -type LanguageIdentifier string +// DiagnosticTag the diagnostic tags. +// +// @since 3.15.0 +type DiagnosticTag uint32 const ( - // ABAPLanguage ABAP Language. - ABAPLanguage LanguageIdentifier = "abap" + // UnnecessaryDiagnosticTag unused or unnecessary code. Clients are allowed to render diagnostics with this tag faded out instead of having an error squiggle. + UnnecessaryDiagnosticTag DiagnosticTag = 1 - // BatLanguage Windows Bat Language. - BatLanguage LanguageIdentifier = "bat" + // DeprecatedDiagnosticTag deprecated or obsolete code. Clients are allowed to rendered diagnostics with this tag strike through. + DeprecatedDiagnosticTag DiagnosticTag = 2 +) - // BibtexLanguage BibTeX Language. - BibtexLanguage LanguageIdentifier = "bibtex" +type ResourceOperationKind string - // ClojureLanguage Clojure Language. - ClojureLanguage LanguageIdentifier = "clojure" +const ( + // CreateResourceOperationKind supports creating new files and folders. + CreateResourceOperationKind ResourceOperationKind = "create" - // CoffeeScriptLanguage CoffeeScript Language. - CoffeeScriptLanguage LanguageIdentifier = "coffeescript" + // RenameResourceOperationKind supports renaming existing files and folders. + RenameResourceOperationKind ResourceOperationKind = "rename" - // CLanguage C Language. - CLanguage LanguageIdentifier = "c" + // DeleteResourceOperationKind supports deleting existing files and folders. + DeleteResourceOperationKind ResourceOperationKind = "delete" +) - // CppLanguage C++ Language. - CppLanguage LanguageIdentifier = "cpp" +type FailureHandlingKind string - // CsharpLanguage C# Language. - CsharpLanguage LanguageIdentifier = "csharp" +const ( + // AbortFailureHandlingKind applying the workspace change is simply aborted if one of the changes provided fails. All operations + // executed before the failing operation stay executed. + AbortFailureHandlingKind FailureHandlingKind = "abort" - // CSSLanguage CSS Language. - CSSLanguage LanguageIdentifier = "css" + // TransactionalFailureHandlingKind all operations are executed transactional. That means they either all succeed or no changes at all are applied to the workspace. + TransactionalFailureHandlingKind FailureHandlingKind = "transactional" - // DiffLanguage Diff Language. - DiffLanguage LanguageIdentifier = "diff" + // TextOnlyTransactionalFailureHandlingKind if the workspace edit contains only textual file changes they are executed transactional. If resource changes (create, rename or delete file) are part of the change the failure handling strategy is abort. + TextOnlyTransactionalFailureHandlingKind FailureHandlingKind = "textOnlyTransactional" - // DartLanguage Dart Language. - DartLanguage LanguageIdentifier = "dart" + // UndoFailureHandlingKind the client tries to undo the operations already executed. But there is no guarantee that this is succeeding. + UndoFailureHandlingKind FailureHandlingKind = "undo" +) - // DockerfileLanguage Dockerfile Language. - DockerfileLanguage LanguageIdentifier = "dockerfile" +// TextDocumentIdentifier a literal to identify a text document in the client. +type TextDocumentIdentifier struct { + // URI the text document's uri. + URI DocumentURI `json:"uri"` +} - // ElixirLanguage Elixir Language. - ElixirLanguage LanguageIdentifier = "elixir" +// Position position in a text document expressed as zero-based line and character offset. Prior to 3.17 the offsets were always based on a UTF-16 string representation. So a string of the form `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀` is 1 and the character offset of b is 3 since `𐐀` is represented using two code units in UTF-16. Since 3.17 clients and servers +// can agree on a different string encoding representation (e.g. UTF-8). The client announces it's supported encoding via the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities). The value is an array of position encodings the client supports, with decreasing preference (e.g. the encoding at index `0` is the most preferred one). To stay backwards compatible the only mandatory encoding is +// UTF-16 represented via the string `utf-16`. The server can pick one of the encodings offered by the client and signals that encoding back to the client via the initialize result's property [`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value `utf-16` is missing from the client's capability `general.positionEncodings` servers can safely assume that the client supports UTF-16. If the server omits the position encoding in its initialize result the encoding defaults to the string value `utf-16`. Implementation considerations: since the conversion from one encoding into another requires the content of the file / line the conversion is best done where the file is read which is usually on the server side. Positions are line end character agnostic. So you can not specify a position that denotes `\r|\n` or `\n|` where `|` represents the character offset. 3.17.0 - support for negotiated position encoding. +// +// @since 3.17.0 - support for negotiated position encoding. +type Position struct { + // Line line position in a document (zero-based). + // + // @since 3.17.0 - support for negotiated position encoding. + Line uint32 `json:"line"` - // ErlangLanguage Erlang Language. - ErlangLanguage LanguageIdentifier = "erlang" + // Character character offset on a line in a document (zero-based). The meaning of this offset is determined by the negotiated `PositionEncodingKind`. + // + // @since 3.17.0 - support for negotiated position encoding. + Character uint32 `json:"character"` +} - // FsharpLanguage F# Language. - FsharpLanguage LanguageIdentifier = "fsharp" +// TextDocumentPositionParams a parameter literal used in requests to pass a text document and a position inside that document. +type TextDocumentPositionParams struct { + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` - // GitCommitLanguage Git Language. - GitCommitLanguage LanguageIdentifier = "git-commit" + // Position the position inside the text document. + Position Position `json:"position"` +} - // GitRebaseLanguage Git Language. - GitRebaseLanguage LanguageIdentifier = "git-rebase" +// Range a range in a text document expressed as (zero-based) start and end positions. If you want to specify +// a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line. For example: ```ts { start: { line: 5, character: 23 } end : { line 6, character : 0 } } ```. +type Range struct { + // Start the range's start position. + Start Position `json:"start"` - // GoLanguage Go Language. - GoLanguage LanguageIdentifier = "go" + // End the range's end position. + End Position `json:"end"` +} - // GroovyLanguage Groovy Language. - GroovyLanguage LanguageIdentifier = "groovy" +// Location represents a location inside a resource, such as a line inside a text file. +type Location struct { + URI DocumentURI `json:"uri"` - // HandlebarsLanguage Handlebars Language. - HandlebarsLanguage LanguageIdentifier = "handlebars" + Range Range `json:"range"` +} - // HTMLLanguage HTML Language. - HTMLLanguage LanguageIdentifier = "html" +// TextEdit a text edit applicable to a text document. +type TextEdit struct { + // Range the range of the text document to be manipulated. To insert text into a document create a range where start === end. + Range Range `json:"range"` - // IniLanguage Ini Language. - IniLanguage LanguageIdentifier = "ini" + // NewText the string to be inserted. For delete operations use an empty string. + NewText string `json:"newText"` +} - // JavaLanguage Java Language. - JavaLanguage LanguageIdentifier = "java" +type WorkDoneProgressOptions struct { + WorkDoneProgress bool `json:"workDoneProgress,omitempty"` +} - // JavaScriptLanguage JavaScript Language. - JavaScriptLanguage LanguageIdentifier = "javascript" +// OptionalVersionedTextDocumentIdentifier a text document identifier to optionally denote a specific version of a text document. +type OptionalVersionedTextDocumentIdentifier struct { + // extends + TextDocumentIdentifier - // JavaScriptReactLanguage JavaScript React Language. - JavaScriptReactLanguage LanguageIdentifier = "javascriptreact" + // Version the version number of this document. If a versioned text document identifier is sent from the server + // to the client and the file is not open in the editor (the server has not received an open notification before) the server can send `null` to indicate that the version is unknown and the content on disk is the truth (as specified with document content ownership). + Version int32 `json:"version,omitempty"` +} - // JSONLanguage JSON Language. - JSONLanguage LanguageIdentifier = "json" +// StringValue a string value used as a snippet is a template which allows to insert text and to control the editor +// cursor when insertion happens. A snippet can define tab stops and placeholders with `$1`, `$2` +// and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Variables are defined with `$name` and `${name:default value}`. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type StringValue struct { + // Value the snippet string. + // + // @since 3.18.0 proposed + Value string `json:"value"` +} - // LatexLanguage LaTeX Language. - LatexLanguage LanguageIdentifier = "latex" +// SnippetTextEdit an interactive text edit. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type SnippetTextEdit struct { + // Range the range of the text document to be manipulated. + // + // @since 3.18.0 proposed + Range Range `json:"range"` - // LessLanguage Less Language. - LessLanguage LanguageIdentifier = "less" + // Snippet the snippet to be inserted. + // + // @since 3.18.0 proposed + Snippet StringValue `json:"snippet"` - // LuaLanguage Lua Language. - LuaLanguage LanguageIdentifier = "lua" + // AnnotationID the actual identifier of the snippet edit. + // + // @since 3.18.0 proposed + AnnotationID *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` +} - // MakefileLanguage Makefile Language. - MakefileLanguage LanguageIdentifier = "makefile" +// AnnotatedTextEdit a special text edit with an additional change annotation. +// +// @since 3.16.0. +type AnnotatedTextEdit struct { + // extends + TextEdit - // MarkdownLanguage Markdown Language. - MarkdownLanguage LanguageIdentifier = "markdown" + // AnnotationID the actual identifier of the change annotation. + // + // @since 3.16.0. + AnnotationID ChangeAnnotationIdentifier `json:"annotationId"` +} - // ObjectiveCLanguage Objective-C Language. - ObjectiveCLanguage LanguageIdentifier = "objective-c" +// TextDocumentEdit describes textual changes on a text document. A TextDocumentEdit describes all changes on a document +// version Si and after they are applied move the document to version Si+1. So the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any kind of ordering. However the edits must be non overlapping. +type TextDocumentEdit struct { + // TextDocument the text document to change. + TextDocument OptionalVersionedTextDocumentIdentifier `json:"textDocument"` - // ObjectiveCppLanguage Objective-C++ Language. - ObjectiveCppLanguage LanguageIdentifier = "objective-cpp" + // Edits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. + Edits TextDocumentEditEdits `json:"edits"` +} - // PerlLanguage Perl Language. - PerlLanguage LanguageIdentifier = "perl" +// ChangeAnnotation additional information that describes document changes. +// +// @since 3.16.0 +type ChangeAnnotation struct { + // Label a human-readable string describing the actual change. The string is rendered prominent in the user interface. + // + // @since 3.16.0 + Label string `json:"label"` - // Perl6Language Perl Language. - Perl6Language LanguageIdentifier = "perl6" + // NeedsConfirmation a flag which indicates that user confirmation is needed before applying the change. + // + // @since 3.16.0 + NeedsConfirmation bool `json:"needsConfirmation,omitempty"` - // PHPLanguage PHP Language. - PHPLanguage LanguageIdentifier = "php" + // Description a human-readable string which is rendered less prominent in the user interface. + // + // @since 3.16.0 + Description string `json:"description,omitempty"` +} - // PowershellLanguage Powershell Language. - PowershellLanguage LanguageIdentifier = "powershell" +// WorkspaceEdit a workspace edit represents changes to many resources managed in the workspace. The edit should either provide `changes` or `documentChanges`. If documentChanges are present they are preferred over `changes` if the client can handle versioned document edits. Since version 3.13.0 a workspace edit can +// contain resource operations as well. If resource operations are present clients need to execute the operations in the order in which they are provided. So a workspace edit for example can consist of the following two changes: (1) a create file a.txt and (2) a text document edit which insert text into file a.txt. An invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will cause failure of the operation. How the client recovers from the failure is described by the client capability: `workspace.workspaceEdit.failureHandling`. +type WorkspaceEdit struct { + // Changes holds changes to existing resources. + Changes map[DocumentURI][]TextEdit `json:"changes,omitempty"` - // JadeLanguage Pug Language. - JadeLanguage LanguageIdentifier = "jade" + // DocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are + // either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. + DocumentChanges *WorkspaceEditDocumentChanges `json:"documentChanges,omitempty"` - // PythonLanguage Python Language. - PythonLanguage LanguageIdentifier = "python" + // ChangeAnnotations a map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and delete file / folder operations. Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`. + ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"` +} - // RLanguage R Language. - RLanguage LanguageIdentifier = "r" +// MarkupContent a `MarkupContent` literal represents a string value which content is interpreted base on its kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds. If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting Here is an example how such a +// string can be constructed using JavaScript / TypeScript: ```ts let markdown: MarkdownContent = +// { kind: MarkupKind.Markdown, value: [ '# Header', 'Some text', '```typescript', 'someCode();', +// '```' ].join('\n') }; ``` *Please Note* that clients might sanitize the return markdown. A client could decide to remove HTML from the markdown to avoid script execution. +type MarkupContent struct { + // Kind the type of the Markup. + Kind MarkupKind `json:"kind"` - // RazorLanguage Razor(cshtml) Language. - RazorLanguage LanguageIdentifier = "razor" + // Value the content itself. + Value string `json:"value"` +} - // RubyLanguage Ruby Language. - RubyLanguage LanguageIdentifier = "ruby" +// Command represents a reference to a command. Provides a title which will be used to represent a command in the UI and, optionally, an array of arguments which will be passed to the command handler function when invoked. +type Command struct { + // Title title of the command, like `save`. + Title string `json:"title"` - // RustLanguage Rust Language. - RustLanguage LanguageIdentifier = "rust" + // Tooltip an optional tooltip. 3.18.0 @proposed. + Tooltip string `json:"tooltip,omitempty"` - // SCSSLanguage SCSS Languages syntax using curly brackets. - SCSSLanguage LanguageIdentifier = "scss" + // Command the identifier of the actual command handler. + Command string `json:"command"` - // SASSLanguage SCSS Languages indented syntax. - SASSLanguage LanguageIdentifier = "sass" + // Arguments arguments that the command handler should be invoked with. + Arguments []any `json:"arguments,omitempty"` +} - // ScalaLanguage Scala Language. - ScalaLanguage LanguageIdentifier = "scala" +// CodeDescription structure to capture a description for an error code. +// +// @since 3.16.0 +type CodeDescription struct { + // Href an URI to open with more information about the diagnostic error. + // + // @since 3.16.0 + Href uri.URI `json:"href"` +} - // ShaderlabLanguage ShaderLab Language. - ShaderlabLanguage LanguageIdentifier = "shaderlab" +// DiagnosticRelatedInformation represents a related message and source code location for a diagnostic. This should be used to point +// to code locations that cause or related to a diagnostics, e.g when duplicating a symbol in a scope. +type DiagnosticRelatedInformation struct { + // Location the location of this related diagnostic information. + Location Location `json:"location"` - // ShellscriptLanguage Shell Script (Bash) Language. - ShellscriptLanguage LanguageIdentifier = "shellscript" + // Message the message of this related diagnostic information. + Message string `json:"message"` +} - // SQLLanguage SQL Language. - SQLLanguage LanguageIdentifier = "sql" +// Diagnostic represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a resource. +type Diagnostic struct { + // Range the range at which the message applies. + Range Range `json:"range"` - // SwiftLanguage Swift Language. - SwiftLanguage LanguageIdentifier = "swift" + // Severity the diagnostic's severity. To avoid interpretation mismatches when a server is used with different clients it is highly recommended that servers always provide a severity value. + Severity DiagnosticSeverity `json:"severity,omitempty"` - // TypeScriptLanguage TypeScript Language. - TypeScriptLanguage LanguageIdentifier = "typescript" + // Code the diagnostic's code, which usually appear in the user interface. + Code *DiagnosticCode `json:"code,omitempty"` - // TypeScriptReactLanguage TypeScript React Language. - TypeScriptReactLanguage LanguageIdentifier = "typescriptreact" + // CodeDescription an optional property to describe the error code. Requires the code field (above) to be present/not null. + CodeDescription *CodeDescription `json:"codeDescription,omitempty"` - // TeXLanguage TeX Language. - TeXLanguage LanguageIdentifier = "tex" + // Source a human-readable string describing the source of this diagnostic, e.g. 'typescript' or 'super lint'. + // It usually appears in the user interface. + Source string `json:"source,omitempty"` - // VBLanguage Visual Basic Language. - VBLanguage LanguageIdentifier = "vb" + // Message the diagnostic's message. It usually appears in the user interface. + Message string `json:"message"` - // XMLLanguage XML Language. - XMLLanguage LanguageIdentifier = "xml" + // Tags additional metadata about the diagnostic. + Tags []DiagnosticTag `json:"tags,omitempty"` - // XslLanguage XSL Language. - XslLanguage LanguageIdentifier = "xsl" + // RelatedInformation an array of related diagnostic information, e.g. when symbol-names within a scope collide all definitions can be marked via this property. + RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"` - // YamlLanguage YAML Language. - YamlLanguage LanguageIdentifier = "yaml" -) + // Data a data entry field that is preserved between a `textDocument/publishDiagnostics` notification and `textDocument/codeAction` request. + Data any `json:"data,omitempty"` +} -// languageIdentifierMap map of LanguageIdentifiers. -var languageIdentifierMap = map[string]LanguageIdentifier{ - "abap": ABAPLanguage, - "bat": BatLanguage, - "bibtex": BibtexLanguage, - "clojure": ClojureLanguage, - "coffeescript": CoffeeScriptLanguage, - "c": CLanguage, - "cpp": CppLanguage, - "csharp": CsharpLanguage, - "css": CSSLanguage, - "diff": DiffLanguage, - "dart": DartLanguage, - "dockerfile": DockerfileLanguage, - "elixir": ElixirLanguage, - "erlang": ErlangLanguage, - "fsharp": FsharpLanguage, - "git-commit": GitCommitLanguage, - "git-rebase": GitRebaseLanguage, - "go": GoLanguage, - "groovy": GroovyLanguage, - "handlebars": HandlebarsLanguage, - "html": HTMLLanguage, - "ini": IniLanguage, - "java": JavaLanguage, - "javascript": JavaScriptLanguage, - "javascriptreact": JavaScriptReactLanguage, - "json": JSONLanguage, - "latex": LatexLanguage, - "less": LessLanguage, - "lua": LuaLanguage, - "makefile": MakefileLanguage, - "markdown": MarkdownLanguage, - "objective-c": ObjectiveCLanguage, - "objective-cpp": ObjectiveCppLanguage, - "perl": PerlLanguage, - "perl6": Perl6Language, - "php": PHPLanguage, - "powershell": PowershellLanguage, - "jade": JadeLanguage, - "python": PythonLanguage, - "r": RLanguage, - "razor": RazorLanguage, - "ruby": RubyLanguage, - "rust": RustLanguage, - "scss": SCSSLanguage, - "sass": SASSLanguage, - "scala": ScalaLanguage, - "shaderlab": ShaderlabLanguage, - "shellscript": ShellscriptLanguage, - "sql": SQLLanguage, - "swift": SwiftLanguage, - "typescript": TypeScriptLanguage, - "typescriptreact": TypeScriptReactLanguage, - "tex": TeXLanguage, - "vb": VBLanguage, - "xml": XMLLanguage, - "xsl": XslLanguage, - "yaml": YamlLanguage, -} - -// ToLanguageIdentifier converts ft to LanguageIdentifier. -func ToLanguageIdentifier(ft string) LanguageIdentifier { - langID, ok := languageIdentifierMap[ft] - if ok { - return langID - } - - return LanguageIdentifier(ft) -} - -// VersionedTextDocumentIdentifier represents an identifier to denote a specific version of a text document. -// -// This information usually flows from the client to the server. +// TextDocumentItem an item to transfer a text document from the client to the server. +type TextDocumentItem struct { + // URI the text document's uri. + URI DocumentURI `json:"uri"` + + // LanguageID the text document's language identifier. + LanguageID LanguageKind `json:"languageId"` + + // Version the version number of this document (it will increase after each change, including undo/redo). + Version int32 `json:"version"` + + // Text the content of the opened text document. + Text string `json:"text"` +} + +// VersionedTextDocumentIdentifier a text document identifier to denote a specific version of a text document. type VersionedTextDocumentIdentifier struct { + // extends TextDocumentIdentifier - // Version is the version number of this document. - // - // The version number of a document will increase after each change, including - // undo/redo. The number doesn't need to be consecutive. + // Version the version number of this document. Version int32 `json:"version"` } -// OptionalVersionedTextDocumentIdentifier represents an identifier which optionally denotes a specific version of -// a text document. -// -// This information usually flows from the server to the client. +// TextDocumentContentParams parameters for the `workspace/textDocumentContent` request. 3.18.0 @proposed. // -// @since 3.16.0. -type OptionalVersionedTextDocumentIdentifier struct { - TextDocumentIdentifier +// @since 3.18.0 proposed +type TextDocumentContentParams struct { + // URI the uri of the text document. + // + // @since 3.18.0 proposed + URI DocumentURI `json:"uri"` +} - // Version is the version number of this document. If an optional versioned text document - // identifier is sent from the server to the client and the file is not - // open in the editor (the server has not received an open notification - // before) the server can send `null` to indicate that the version is - // known and the content on disk is the master (as specified with document - // content ownership). +// TextDocumentContentResult result of the `workspace/textDocumentContent` request. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentContentResult struct { + // Text the text content of the text document. Please note, that the content of any subsequent open notifications for the text document might differ from the returned content due to whitespace and line ending + // normalizations done on the client. // - // The version number of a document will increase after each change, - // including undo/redo. The number doesn't need to be consecutive. - Version *int32 `json:"version"` // int32 | null + // @since 3.18.0 proposed + Text string `json:"text"` } -// TextDocumentPositionParams is a parameter literal used in requests to pass a text document and a position -// inside that document. +// TextDocumentContentOptions text document content provider options. 3.18.0 @proposed. // -// It is up to the client to decide how a selection is converted into a position when issuing a request for a text -// document. +// @since 3.18.0 proposed +type TextDocumentContentOptions struct { + // Schemes the schemes for which the server provides content. + // + // @since 3.18.0 proposed + Schemes []string `json:"schemes"` +} + +// TextDocumentContentRegistrationOptions text document content provider registration options. 3.18.0 @proposed. // -// The client can for example honor or ignore the selection direction to make LSP request consistent with features -// implemented internally. -type TextDocumentPositionParams struct { - // TextDocument is the text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` +// @since 3.18.0 proposed +type TextDocumentContentRegistrationOptions struct { + // extends + TextDocumentContentOptions + // mixins + StaticRegistrationOptions +} - // Position is the position inside the text document. - Position Position `json:"position"` +// TextDocumentContentRefreshParams parameters for the `workspace/textDocumentContent/refresh` request. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentContentRefreshParams struct { + // URI the uri of the text document to refresh. + // + // @since 3.18.0 proposed + URI DocumentURI `json:"uri"` } -// DocumentFilter is a document filter denotes a document through properties like language, scheme or pattern. +// ChangeAnnotationsSupportOptions. // -// An example is a filter that applies to TypeScript files on disk. -type DocumentFilter struct { - // Language a language id, like `typescript`. - Language string `json:"language,omitempty"` +// @since 3.18.0 +type ChangeAnnotationsSupportOptions struct { + // GroupsOnLabel whether the client groups edits with equal labels into tree nodes, for instance all edits labelled with "Changes in Strings" would be a tree node. + // + // @since 3.18.0 + GroupsOnLabel bool `json:"groupsOnLabel,omitempty"` +} - // Scheme a URI scheme, like `file` or `untitled`. - Scheme string `json:"scheme,omitempty"` +type WorkspaceEditClientCapabilities struct { + // DocumentChanges the client supports versioned document changes in `WorkspaceEdit`s. + DocumentChanges bool `json:"documentChanges,omitempty"` - // Pattern a glob pattern, like `*.{ts,js}`. - // - // Glob patterns can have the following syntax: - // "*" - // "*" to match one or more characters in a path segment - // "?" - // "?" to match on one character in a path segment - // "**" - // "**" to match any number of path segments, including none - // "{}" - // "{}" to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files) - // "[]" - // "[]" to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - // "[!...]" - // "[!...]" to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) - Pattern string `json:"pattern,omitempty"` -} - -// DocumentSelector is a document selector is the combination of one or more document filters. -type DocumentSelector []*DocumentFilter - -// MarkupKind describes the content type that a client supports in various -// result literals like `Hover`, `ParameterInfo` or `CompletionItem`. -// -// Please note that `MarkupKinds` must not start with a `$`. This kinds -// are reserved for internal usage. -type MarkupKind string + // ResourceOperations the resource operations the client supports. Clients should at least support 'create', 'rename' and 'delete' files and folders. + ResourceOperations []ResourceOperationKind `json:"resourceOperations,omitempty"` -const ( - // PlainText is supported as a content format. - PlainText MarkupKind = "plaintext" + // FailureHandling the failure handling strategy of a client if applying the workspace edit fails. + FailureHandling FailureHandlingKind `json:"failureHandling,omitempty"` - // Markdown is supported as a content format. - Markdown MarkupKind = "markdown" -) + // NormalizesLineEndings whether the client normalizes line endings to the client specific setting. If set to `true` the client will normalize line ending characters in a workspace edit to the client-specified new line character. + NormalizesLineEndings bool `json:"normalizesLineEndings,omitempty"` -// MarkupContent a `MarkupContent` literal represents a string value which content is interpreted base on its -// kind flag. -// -// Currently the protocol supports `plaintext` and `markdown` as markup kinds. -// -// If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues. -// See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting -// -// Here is an example how such a string can be constructed using JavaScript / TypeScript: -// -// let markdown: MarkdownContent = { -// kind: MarkupKind.Markdown, -// value: [ -// '# Header', -// 'Some text', -// '```typescript', -// 'someCode();', -// '```' -// ].join('\n') -// }; -// -// NOTE: clients might sanitize the return markdown. A client could decide to -// remove HTML from the markdown to avoid script execution. -type MarkupContent struct { - // Kind is the type of the Markup - Kind MarkupKind `json:"kind"` + // ChangeAnnotationSupport whether the client in general supports change annotations on text edits, create file, rename file and delete file changes. + ChangeAnnotationSupport *ChangeAnnotationsSupportOptions `json:"changeAnnotationSupport,omitempty"` - // Value is the content itself - Value string `json:"value"` + // MetadataSupport whether the client supports `WorkspaceEditMetadata` in `WorkspaceEdit`s. 3.18.0 @proposed. + MetadataSupport bool `json:"metadataSupport,omitempty"` + + // SnippetEditSupport whether the client supports snippets as text edits. 3.18.0 @proposed. + SnippetEditSupport bool `json:"snippetEditSupport,omitempty"` +} + +type WorkDoneProgressBegin struct { + // Title mandatory title of the progress operation. Used to briefly inform about the kind of operation being performed. Examples: "Indexing" or "Linking dependencies". + Title string `json:"title"` + + // Cancellable controls if a cancel button should show to allow the user to cancel the long running operation. Clients that don't support cancellation are allowed to ignore the setting. + Cancellable bool `json:"cancellable,omitempty"` + + // Message optional, more detailed associated progress message. Contains complementary information to the `title`. Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". If unset, the previous progress message (if any) is still valid. + Message string `json:"message,omitempty"` + + // Percentage optional progress percentage to display (value 100 is considered 100%). If not provided infinite progress is assumed and clients are allowed to ignore the `percentage` value in subsequent in report notifications. The value should be steadily rising. Clients are free to ignore values that are not following this rule. The value range is [0, 100]. + Percentage uint32 `json:"percentage,omitempty"` +} + +type WorkDoneProgressReport struct { + // Cancellable controls enablement state of a cancel button. Clients that don't support cancellation or don't support controlling the button's enablement state are allowed to ignore the property. + Cancellable bool `json:"cancellable,omitempty"` + + // Message optional, more detailed associated progress message. Contains complementary information to the `title`. Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". If unset, the previous progress message (if any) is still valid. + Message string `json:"message,omitempty"` + + // Percentage optional progress percentage to display (value 100 is considered 100%). If not provided infinite progress is assumed and clients are allowed to ignore the `percentage` value in subsequent in report notifications. The value should be steadily rising. Clients are free to ignore values that are not following this rule. The value range is [0, 100]. + Percentage uint32 `json:"percentage,omitempty"` +} + +type WorkDoneProgressEnd struct { + // Message optional, a final message indicating to for example indicate the outcome of the operation. + Message string `json:"message,omitempty"` +} + +type WorkDoneProgressParams struct { + // WorkDoneToken an optional token that a server can use to report work done progress. + WorkDoneToken *ProgressToken `json:"workDoneToken,omitempty"` +} + +type PartialResultParams struct { + // PartialResultToken an optional token that a server can use to report partial results (e.g. streaming) to the client. + PartialResultToken *ProgressToken `json:"partialResultToken,omitempty"` +} + +// LocationLink represents the connection of two locations. Provides additional metadata over normal Location locations, including an origin range. +type LocationLink struct { + // OriginSelectionRange span of the origin of this link. Used as the underlined span for mouse interaction. Defaults to the word range at the definition position. + OriginSelectionRange *Range `json:"originSelectionRange,omitempty"` + + // TargetURI the target resource identifier of this link. + TargetURI DocumentURI `json:"targetUri"` + + // TargetRange the full target range of this link. If the target for example is a symbol then target range is the range enclosing this symbol not including leading/trailing whitespace but everything else like comments. This information is typically used to highlight the range in the editor. + TargetRange Range `json:"targetRange"` + + // TargetSelectionRange the range that should be selected and revealed when this link is being followed, e.g the name of a function. Must be contained by the `targetRange`. See also `DocumentSymbol#range`. + TargetSelectionRange Range `json:"targetSelectionRange"` } diff --git a/basic_test.go b/basic_test.go deleted file mode 100644 index fa215d3b..00000000 --- a/basic_test.go +++ /dev/null @@ -1,3213 +0,0 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/segmentio/encoding/json" - - "go.lsp.dev/uri" -) - -func TestPosition(t *testing.T) { - t.Parallel() - - const ( - want = `{"line":25,"character":1}` - wantInvalid = `{"line":2,"character":0}` - ) - wantType := Position{ - Line: 25, - Character: 1, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field Position - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want Position - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got Position - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestRange(t *testing.T) { - t.Parallel() - - const ( - want = `{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}` - wantInvalid = `{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}` - ) - wantType := Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field Range - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want Range - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got Range - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestLocation(t *testing.T) { - t.Parallel() - - const ( - want = `{"uri":"file:///Users/gopher/go/src/go.lsp.dev/protocol/basic_test.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}` - wantInvalid = `{"uri":"file:///Users/gopher/go/src/go.lsp.dev/protocol/basic_test.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}}` - ) - wantType := Location{ - URI: uri.File("/Users/gopher/go/src/go.lsp.dev/protocol/basic_test.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field Location - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want Location - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got Location - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestLocationLink(t *testing.T) { - t.Parallel() - - const ( - want = `{"originSelectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"targetUri":"file:///path/to/test.go","targetRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"targetSelectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}` - wantNil = `{"targetUri":"file:///path/to/test.go","targetRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"targetSelectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}` - wantInvalid = `{"originSelectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"targetUri":"file:///path/to/test.go","targetRange":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"targetSelectionRange":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}}` - ) - wantType := LocationLink{ - OriginSelectionRange: &Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - TargetURI: uri.File("/path/to/test.go"), - TargetRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - TargetSelectionRange: Range{ - Start: Position{ - Line: 25, Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - } - wantTypeNil := LocationLink{ - TargetURI: uri.File("/path/to/test.go"), - TargetRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - TargetSelectionRange: Range{ - Start: Position{ - Line: 25, Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field LocationLink - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOriginSelectionRange", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want LocationLink - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOriginSelectionRange", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got LocationLink - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCodeDescription(t *testing.T) { - t.Parallel() - - const ( - want = `{"href":"file:///path/to/test.go"}` - wantInvalid = `{"href":"file:///path/to/invalid.go"}` - ) - wantType := CodeDescription{ - Href: uri.File("/path/to/test.go"), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CodeDescription - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CodeDescription - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeDescription - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCommand(t *testing.T) { - t.Parallel() - - const ( - want = `{"title":"exec echo","command":"echo","arguments":["hello"]}` - wantNilArguments = `{"title":"exec echo","command":"echo"}` - wantInvalid = `{"title":"exec echo","command":"true","arguments":["hello"]}` - ) - wantType := Command{ - Title: "exec echo", - Command: "echo", - Arguments: []interface{}{"hello"}, - } - wantTypeNilArguments := Command{ - Title: "exec echo", - Command: "echo", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field Command - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilArguments", - field: wantTypeNilArguments, - want: wantNilArguments, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want Command - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilArguments", - field: wantNilArguments, - want: wantTypeNilArguments, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got Command - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestChangeAnnotation(t *testing.T) { - t.Parallel() - - const ( - want = `{"label":"testLabel","needsConfirmation":true,"description":"testDescription"}` - wantNilAll = `{"label":"testLabel"}` - wantInvalid = `{"label":"invalidLabel","needsConfirmation":false,"description":"invalidDescription"}` - ) - wantType := ChangeAnnotation{ - Label: "testLabel", - NeedsConfirmation: true, - Description: "testDescription", - } - wantTypeNilAll := ChangeAnnotation{ - Label: "testLabel", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ChangeAnnotation - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilArguments", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ChangeAnnotation - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilArguments", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ChangeAnnotation - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestAnnotatedTextEdit(t *testing.T) { - t.Parallel() - - const ( - want = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar","annotationId":"testAnnotationIdentifier"}` - wantInvalid = `{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"newText":"foo bar","annotationId":"invalidAnnotationIdentifier"}` - ) - wantType := AnnotatedTextEdit{ - TextEdit: TextEdit{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - AnnotationID: ChangeAnnotationIdentifier("testAnnotationIdentifier"), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field AnnotatedTextEdit - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want AnnotatedTextEdit - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got AnnotatedTextEdit - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextEdit(t *testing.T) { - t.Parallel() - - const ( - want = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}` - wantInvalid = `{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"newText":"foo bar"}` - ) - wantType := TextEdit{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - } - wantInvalidType := TextEdit{ - Range: Range{ - Start: Position{ - Line: 2, - Character: 1, - }, - End: Position{ - Line: 3, - Character: 2, - }, - }, - NewText: "foo bar", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TextEdit - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: TextEdit{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TextEdit - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: want, - want: wantInvalidType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextEdit - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentEdit(t *testing.T) { - t.Parallel() - - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go","version":10},"edits":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go","version":10},"edits":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"newText":"foo bar"}]}` - ) - wantType := TextDocumentEdit{ - TextDocument: OptionalVersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: "file:///path/to/basic.go", - }, - Version: NewVersion(int32(10)), - }, - Edits: []TextEdit{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - } - wantInvalidType := TextDocumentEdit{ - TextDocument: OptionalVersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: "file:///path/to/basic.go", - }, - Version: NewVersion(int32(10)), - }, - Edits: []TextEdit{ - { - Range: Range{ - Start: Position{ - Line: 2, - Character: 1, - }, - End: Position{ - Line: 3, - Character: 2, - }, - }, - NewText: "foo bar", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TextDocumentEdit - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TextDocumentEdit - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: want, - want: wantInvalidType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentEdit - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCreateFileOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"overwrite":true,"ignoreIfExists":true}` - wantNilIgnoreIfExists = `{"overwrite":true}` - wantNilOverwrite = `{"ignoreIfExists":true}` - wantValidNilAll = `{}` - wantInvalid = `{"overwrite":false,"ignoreIfExists":false}` - ) - wantType := CreateFileOptions{ - Overwrite: true, - IgnoreIfExists: true, - } - wantTypeNilOverwrite := CreateFileOptions{ - IgnoreIfExists: true, - } - wantTypeNilIgnoreIfExists := CreateFileOptions{ - Overwrite: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CreateFileOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOverwrite", - field: wantTypeNilIgnoreIfExists, - want: wantNilIgnoreIfExists, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilIgnoreIfExists", - field: wantTypeNilOverwrite, - want: wantNilOverwrite, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: CreateFileOptions{}, - want: wantValidNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CreateFileOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: `{"overwrite":true,"ignoreIfExists":true}`, - want: CreateFileOptions{ - Overwrite: true, - IgnoreIfExists: true, - }, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOverwrite", - field: `{"ignoreIfExists":true}`, - want: CreateFileOptions{ - IgnoreIfExists: true, - }, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilIgnoreIfExists", - field: `{"overwrite":true}`, - want: CreateFileOptions{ - Overwrite: true, - }, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: `{}`, - want: CreateFileOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: `{"overwrite":true,"ignoreIfExists":true}`, - want: CreateFileOptions{ - Overwrite: false, - IgnoreIfExists: false, - }, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CreateFileOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCreateFile(t *testing.T) { - t.Parallel() - - const ( - want = `{"kind":"create","uri":"file:///path/to/basic.go","options":{"overwrite":true,"ignoreIfExists":true},"annotationId":"testAnnotationIdentifier"}` - wantNilOptions = `{"kind":"create","uri":"file:///path/to/basic.go"}` - wantInvalid = `{"kind":"create","uri":"file:///path/to/basic_gen.go","options":{"overwrite":false,"ignoreIfExists":false},"annotationId":"invalidAnnotationIdentifier"}` - ) - wantType := CreateFile{ - Kind: "create", - URI: uri.File("/path/to/basic.go"), - Options: &CreateFileOptions{ - Overwrite: true, - IgnoreIfExists: true, - }, - AnnotationID: ChangeAnnotationIdentifier("testAnnotationIdentifier"), - } - wantTypeNilOptions := CreateFile{ - Kind: "create", - URI: uri.File("/path/to/basic.go"), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CreateFile - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOptions", - field: wantTypeNilOptions, - want: wantNilOptions, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CreateFile - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOptions", - field: wantNilOptions, - want: wantTypeNilOptions, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CreateFile - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestRenameFileOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"overwrite":true,"ignoreIfExists":true}` - wantNilOverwrite = `{"ignoreIfExists":true}` - wantNilIgnoreIfExists = `{"overwrite":true}` - wantNilAll = `{}` - wantInvalid = `{"overwrite":false,"ignoreIfExists":false}` - ) - wantType := RenameFileOptions{ - Overwrite: true, - IgnoreIfExists: true, - } - wantTypeNilOverwrite := RenameFileOptions{ - IgnoreIfExists: true, - } - wantTypeNilIgnoreIfExists := RenameFileOptions{ - Overwrite: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field RenameFileOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOverwrite", - field: wantTypeNilOverwrite, - want: wantNilOverwrite, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilIgnoreIfExists", - field: wantTypeNilIgnoreIfExists, - want: wantNilIgnoreIfExists, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: RenameFileOptions{}, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want RenameFileOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: `{"overwrite":true,"ignoreIfExists":true}`, - want: RenameFileOptions{ - Overwrite: true, - IgnoreIfExists: true, - }, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOverwrite", - field: `{"ignoreIfExists":true}`, - want: RenameFileOptions{ - IgnoreIfExists: true, - }, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilIgnoreIfExists", - field: `{"overwrite":true}`, - want: RenameFileOptions{ - Overwrite: true, - }, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: `{}`, - want: RenameFileOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: `{"overwrite":true,"ignoreIfExists":true}`, - want: RenameFileOptions{ - Overwrite: false, - IgnoreIfExists: false, - }, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got RenameFileOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestRenameFile(t *testing.T) { - t.Parallel() - - const ( - want = `{"kind":"rename","oldUri":"file:///path/to/old.go","newUri":"file:///path/to/new.go","options":{"overwrite":true,"ignoreIfExists":true},"annotationId":"testAnnotationIdentifier"}` - wantNilOptions = `{"kind":"rename","oldUri":"file:///path/to/old.go","newUri":"file:///path/to/new.go"}` - wantInvalid = `{"kind":"rename","oldUri":"file:///path/to/old2.go","newUri":"file:///path/to/new2.go","options":{"overwrite":false,"ignoreIfExists":false},"annotationId":"invalidAnnotationIdentifier"}` - ) - wantType := RenameFile{ - Kind: "rename", - OldURI: uri.File("/path/to/old.go"), - NewURI: uri.File("/path/to/new.go"), - Options: &RenameFileOptions{ - Overwrite: true, - IgnoreIfExists: true, - }, - AnnotationID: ChangeAnnotationIdentifier("testAnnotationIdentifier"), - } - wantTypeNilOptions := RenameFile{ - Kind: "rename", - OldURI: uri.File("/path/to/old.go"), - NewURI: uri.File("/path/to/new.go"), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field RenameFile - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOptions", - field: wantTypeNilOptions, - want: wantNilOptions, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want RenameFile - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOptions", - field: wantNilOptions, - want: wantTypeNilOptions, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got RenameFile - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDeleteFileOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"recursive":true,"ignoreIfNotExists":true}` - wantNilRecursive = `{"ignoreIfNotExists":true}` - wantNiIgnoreIfNotExists = `{"recursive":true}` - wantNilAll = `{}` - wantInvalid = `{"recursive":false,"ignoreIfNotExists":false}` - ) - wantType := DeleteFileOptions{ - Recursive: true, - IgnoreIfNotExists: true, - } - wantTypeNilRecursive := DeleteFileOptions{ - IgnoreIfNotExists: true, - } - wantTypeNiIgnoreIfNotExists := DeleteFileOptions{ - Recursive: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DeleteFileOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilRecursive", - field: wantTypeNilRecursive, - want: wantNilRecursive, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNiIgnoreIfNotExists", - field: wantTypeNiIgnoreIfNotExists, - want: wantNiIgnoreIfNotExists, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DeleteFileOptions{}, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DeleteFileOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilRecursive", - field: wantNilRecursive, - want: wantTypeNilRecursive, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilIgnoreIfNotExists", - field: wantNiIgnoreIfNotExists, - want: wantTypeNiIgnoreIfNotExists, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: DeleteFileOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DeleteFileOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDeleteFile(t *testing.T) { - t.Parallel() - - const ( - want = `{"kind":"delete","uri":"file:///path/to/delete.go","options":{"recursive":true,"ignoreIfNotExists":true},"annotationId":"testAnnotationIdentifier"}` - wantNilOptions = `{"kind":"delete","uri":"file:///path/to/delete.go"}` - wantInvalid = `{"kind":"delete","uri":"file:///path/to/delete2.go","options":{"recursive":false,"ignoreIfNotExists":false},"annotationId":"invalidAnnotationIdentifier"}` - ) - wantType := DeleteFile{ - Kind: "delete", - URI: uri.File("/path/to/delete.go"), - Options: &DeleteFileOptions{ - Recursive: true, - IgnoreIfNotExists: true, - }, - AnnotationID: ChangeAnnotationIdentifier("testAnnotationIdentifier"), - } - wantTypeNilOptions := DeleteFile{ - Kind: "delete", - URI: uri.File("/path/to/delete.go"), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DeleteFile - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOptions", - field: wantTypeNilOptions, - want: wantNilOptions, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DeleteFile - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilOptions", - field: wantNilOptions, - want: wantTypeNilOptions, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DeleteFile - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkspaceEdit(t *testing.T) { - t.Parallel() - - const ( - want = `{"changes":{"file:///path/to/basic.go":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]},"documentChanges":[{"textDocument":{"uri":"file:///path/to/basic.go","version":10},"edits":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]}],"changeAnnotations":{"testAnnotationIdentifier":{"label":"testLabel","needsConfirmation":true,"description":"testDescription"}}}` - wantNilChanges = `{"documentChanges":[{"textDocument":{"uri":"file:///path/to/basic.go","version":10},"edits":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]}]}` - wantNilDocumentChanges = `{"changes":{"file:///path/to/basic.go":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]}}` - wantInvalid = `{"changes":{"file:///path/to/basic_gen.go":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"newText":"foo bar"}]},"documentChanges":[{"textDocument":{"uri":"file:///path/to/basic_gen.go","version":10},"edits":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"newText":"foo bar"}]}]}` - ) - wantType := WorkspaceEdit{ - Changes: map[uri.URI][]TextEdit{ - uri.File("/path/to/basic.go"): { - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - DocumentChanges: []TextDocumentEdit{ - { - TextDocument: OptionalVersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Version: NewVersion(int32(10)), - }, - Edits: []TextEdit{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - }, - ChangeAnnotations: map[ChangeAnnotationIdentifier]ChangeAnnotation{ - ChangeAnnotationIdentifier("testAnnotationIdentifier"): { - Label: "testLabel", - NeedsConfirmation: true, - Description: "testDescription", - }, - }, - } - wantTypeNilChanges := WorkspaceEdit{ - DocumentChanges: []TextDocumentEdit{ - { - TextDocument: OptionalVersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Version: NewVersion(int32(10)), - }, - Edits: []TextEdit{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - }, - } - wantTypeNilDocumentChanges := WorkspaceEdit{ - Changes: map[uri.URI][]TextEdit{ - uri.File("/path/to/basic.go"): { - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field WorkspaceEdit - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilChanges", - field: wantTypeNilChanges, - want: wantNilChanges, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilDocumentChanges", - field: wantTypeNilDocumentChanges, - want: wantNilDocumentChanges, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want WorkspaceEdit - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilChanges", - field: wantNilChanges, - want: wantTypeNilChanges, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilDocumentChanges", - field: wantNilDocumentChanges, - want: wantTypeNilDocumentChanges, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkspaceEdit - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentIdentifier(t *testing.T) { - t.Parallel() - - const ( - want = `{"uri":"file:///path/to/basic.go"}` - wantInvalid = `{"uri":"file:///path/to/unknown.go"}` - wantInvalidEmpty = `{}` - ) - wantType := TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TextDocumentIdentifier - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - { - name: "InvalidEmpty", - field: TextDocumentIdentifier{}, - want: wantInvalidEmpty, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TextDocumentIdentifier - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentIdentifier - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentItem(t *testing.T) { - t.Parallel() - - const ( - want = `{"uri":"file:///path/to/basic.go","languageId":"go","version":10,"text":"Go Language"}` - wantInvalid = `{"uri":"file:///path/to/basic_gen.go","languageId":"cpp","version":10,"text":"C++ Language"}` - ) - wantType := TextDocumentItem{ - URI: uri.File("/path/to/basic.go"), - LanguageID: GoLanguage, - Version: int32(10), - Text: "Go Language", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TextDocumentItem - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TextDocumentItem - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Valid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentItem - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestToLanguageIdentifier(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - ft string - want LanguageIdentifier - }{ - { - name: "Go", - ft: "go", - want: GoLanguage, - }, - { - name: "C", - ft: "c", - want: CLanguage, - }, - { - name: "lsif", - ft: "lsif", - want: LanguageIdentifier("lsif"), - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := ToLanguageIdentifier(tt.ft); got != tt.want { - t.Errorf("ToLanguageIdentifier(%v) = %v, want %v", tt.ft, tt.want, got) - } - }) - } -} - -func TestVersionedTextDocumentIdentifier(t *testing.T) { - t.Parallel() - - const ( - want = `{"uri":"file:///path/to/basic.go","version":10}` - wantZeroVersion = `{"uri":"file:///path/to/basic.go","version":0}` - wantInvalid = `{"uri":"file:///path/to/basic_gen.go","version":50}` - ) - wantType := VersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Version: int32(10), - } - wantTypeNullVersion := VersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field VersionedTextDocumentIdentifier - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNullVersion", - field: wantTypeNullVersion, - want: wantZeroVersion, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want VersionedTextDocumentIdentifier - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNullVersion", - field: wantZeroVersion, - want: wantTypeNullVersion, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got VersionedTextDocumentIdentifier - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestOptionalVersionedTextDocumentIdentifier(t *testing.T) { - t.Parallel() - - const ( - want = `{"uri":"file:///path/to/basic.go","version":10}` - wantNullVersion = `{"uri":"file:///path/to/basic.go","version":null}` - wantInvalid = `{"uri":"file:///path/to/basic_gen.go","version":50}` - ) - wantType := OptionalVersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Version: NewVersion(10), - } - wantTypeNullVersion := OptionalVersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field OptionalVersionedTextDocumentIdentifier - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNullVersion", - field: wantTypeNullVersion, - want: wantNullVersion, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want OptionalVersionedTextDocumentIdentifier - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNullVersion", - field: wantNullVersion, - want: wantTypeNullVersion, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got OptionalVersionedTextDocumentIdentifier - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentPositionParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1}}` - ) - wantType := TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TextDocumentPositionParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TextDocumentPositionParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentPositionParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentFilter(t *testing.T) { - t.Parallel() - - const ( - want = `{"language":"go","scheme":"file","pattern":"*"}` - wantNilLanguage = `{"scheme":"file","pattern":"*"}` - wantNilScheme = `{"language":"go","pattern":"*"}` - wantNilPattern = `{"language":"go","scheme":"file"}` - wantNilAll = `{}` - wantInvalid = `{"language":"typescript","scheme":"file","pattern":"?"}` - ) - wantType := DocumentFilter{ - Language: "go", - Scheme: "file", - Pattern: "*", - } - wantTypeNilLanguage := DocumentFilter{ - Scheme: "file", - Pattern: "*", - } - wantTypeNilScheme := DocumentFilter{ - Language: "go", - Pattern: "*", - } - wantTypeNilPattern := DocumentFilter{ - Language: "go", - Scheme: "file", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentFilter - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilLanguage", - field: wantTypeNilLanguage, - want: wantNilLanguage, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilScheme", - field: wantTypeNilScheme, - want: wantNilScheme, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilPattern", - field: wantTypeNilPattern, - want: wantNilPattern, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentFilter{}, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentFilter - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilLanguage", - field: wantNilLanguage, - want: wantTypeNilLanguage, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilScheme", - field: wantNilScheme, - want: wantTypeNilScheme, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilPattern", - field: wantNilPattern, - want: wantTypeNilPattern, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: DocumentFilter{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentFilter - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentSelector(t *testing.T) { - t.Parallel() - - const ( - want = `[{"language":"go","scheme":"file","pattern":"*.go"},{"language":"cpp","scheme":"untitled","pattern":"*.{cpp,hpp}"}]` - wantInvalid = `[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"},{"language":"c","scheme":"untitled","pattern":"*.{c,h}"}]` - ) - wantType := DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - { - Language: "cpp", - Scheme: "untitled", - Pattern: "*.{cpp,hpp}", - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentSelector - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentSelector - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentSelector - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestMarkupContent(t *testing.T) { - t.Parallel() - - const ( - want = "{\"kind\":\"markdown\",\"value\":\"# Header\\nSome text\\n```typescript\\nsomeCode();\\n'```\\n\"}" - wantInvalid = "{\"kind\":\"plaintext\",\"value\":\"Header\\nSome text\\ntypescript\\nsomeCode();\\n\"}" - ) - wantType := MarkupContent{ - Kind: Markdown, - Value: "# Header\nSome text\n```typescript\nsomeCode();\n'```\n", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field MarkupContent - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want MarkupContent - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got MarkupContent - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} diff --git a/callhierarchy.go b/callhierarchy.go deleted file mode 100644 index eebb9e39..00000000 --- a/callhierarchy.go +++ /dev/null @@ -1,103 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -// CallHierarchy capabilities specific to the "textDocument/callHierarchy". -// -// @since 3.16.0. -type CallHierarchy struct { - // DynamicRegistration 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,omitempty"` -} - -// CallHierarchyPrepareParams params of CallHierarchyPrepare. -// -// @since 3.16.0. -type CallHierarchyPrepareParams struct { - TextDocumentPositionParams - WorkDoneProgressParams -} - -// CallHierarchyItem is the result of a "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -type CallHierarchyItem struct { - // name is the name of this item. - Name string `json:"name"` - - // Kind is the kind of this item. - Kind SymbolKind `json:"kind"` - - // Tags for this item. - Tags []SymbolTag `json:"tags,omitempty"` - - // Detail more detail for this item, e.g. the signature of a function. - Detail string `json:"detail,omitempty"` - - // URI is the resource identifier of this item. - URI DocumentURI `json:"uri"` - - // Range is the range enclosing this symbol not including leading/trailing whitespace - // but everything else, e.g. comments and code. - Range Range `json:"range"` - - // SelectionRange is the range that should be selected and revealed when this symbol is being - // picked, e.g. the name of a function. Must be contained by the - // Range. - SelectionRange Range `json:"selectionRange"` - - // Data is a data entry field that is preserved between a call hierarchy prepare and - // incoming calls or outgoing calls requests. - Data interface{} `json:"data,omitempty"` -} - -// CallHierarchyIncomingCallsParams params of CallHierarchyIncomingCalls. -// -// @since 3.16.0. -type CallHierarchyIncomingCallsParams struct { - WorkDoneProgressParams - PartialResultParams - - // Item is the IncomingCalls item. - Item CallHierarchyItem `json:"item"` -} - -// CallHierarchyIncomingCall is the result of a "callHierarchy/incomingCalls" request. -// -// @since 3.16.0. -type CallHierarchyIncomingCall struct { - // From is the item that makes the call. - From CallHierarchyItem `json:"from"` - - // FromRanges is the ranges at which the calls appear. This is relative to the caller - // denoted by From. - FromRanges []Range `json:"fromRanges"` -} - -// CallHierarchyOutgoingCallsParams params of CallHierarchyOutgoingCalls. -// -// @since 3.16.0. -type CallHierarchyOutgoingCallsParams struct { - WorkDoneProgressParams - PartialResultParams - - // Item is the OutgoingCalls item. - Item CallHierarchyItem `json:"item"` -} - -// CallHierarchyOutgoingCall is the result of a "callHierarchy/outgoingCalls" request. -// -// @since 3.16.0. -type CallHierarchyOutgoingCall struct { - // To is the item that is called. - To CallHierarchyItem `json:"to"` - - // FromRanges is the range at which this item is called. This is the range relative to - // the caller, e.g the item passed to "callHierarchy/outgoingCalls" request. - FromRanges []Range `json:"fromRanges"` -} diff --git a/callhierarchy_test.go b/callhierarchy_test.go deleted file mode 100644 index 8c185001..00000000 --- a/callhierarchy_test.go +++ /dev/null @@ -1,1330 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/segmentio/encoding/json" - - "go.lsp.dev/uri" -) - -func TestCallHierarchy(t *testing.T) { - const ( - want = `{"dynamicRegistration":true}` - wantNil = `{}` - wantInvalid = `{"dynamicRegistration":false}` - ) - wantType := CallHierarchy{ - DynamicRegistration: true, - } - wantTypeNil := CallHierarchy{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CallHierarchy - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CallHierarchy - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Valid", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CallHierarchy - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCallHierarchyOptions(t *testing.T) { - const ( - want = `{"workDoneProgress":true}` - wantNil = `{}` - wantInvalid = `{"workDoneProgress":false}` - ) - wantType := CallHierarchyOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - wantTypeNil := CallHierarchyOptions{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CallHierarchyOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CallHierarchyOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Valid", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CallHierarchyOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCallHierarchyRegistrationOptions(t *testing.T) { - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"}],"workDoneProgress":true,"id":"testID"}` - wantNil = `{"documentSelector":[]}` - wantInvalid = `{"workDoneProgress":false}` - ) - wantType := CallHierarchyRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - }, - }, - CallHierarchyOptions: CallHierarchyOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - }, - StaticRegistrationOptions: StaticRegistrationOptions{ - ID: "testID", - }, - } - wantTypeNil := CallHierarchyRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{}, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CallHierarchyRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CallHierarchyRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Valid", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CallHierarchyRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCallHierarchyPrepareParams(t *testing.T) { - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - invalidWorkDoneToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `"}` - wantNil = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1},"workDoneToken":"` + invalidWorkDoneToken + `"}` - ) - wantType := CallHierarchyPrepareParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - } - wantTypeNil := CallHierarchyPrepareParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CallHierarchyPrepareParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CallHierarchyPrepareParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Valid", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CallHierarchyPrepareParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestCallHierarchyItem(t *testing.T) { - const ( - want = `{"name":"testName","kind":1,"tags":[1],"detail":"testDetail","uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"selectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"data":"testData"}` - wantNil = `{"name":"testName","kind":1,"uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"selectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}` - wantInvalid = `{"name":"invalidName","kind":0,"tags":[0],"detail":"invalidDetail","uri":"file:///path/to/invalid.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"selectionRange":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"data":"invalidData"}` - ) - wantType := CallHierarchyItem{ - Name: "testName", - Kind: SymbolKindFile, - Tags: []SymbolTag{ - SymbolTagDeprecated, - }, - Detail: "testDetail", - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Data: "testData", - } - wantTypeNil := CallHierarchyItem{ - Name: "testName", - Kind: SymbolKindFile, - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CallHierarchyItem - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CallHierarchyItem - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Valid", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CallHierarchyItem - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCallHierarchyIncomingCallsParams(t *testing.T) { - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","item":{"name":"testName","kind":1,"tags":[1],"detail":"testDetail","uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"selectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"data":"testData"}}` - wantNil = `{"item":{"name":"testName","kind":1,"uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"selectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}}` - wantInvalid = `{"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","item":{"name":"invalidName","kind":0,"tags":[0],"detail":"invalidDetail","uri":"file:///path/to/invalid.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"selectionRange":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"data":"invalidData"}}` - ) - wantType := CallHierarchyIncomingCallsParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - Item: CallHierarchyItem{ - Name: "testName", - Kind: SymbolKindFile, - Tags: []SymbolTag{ - SymbolTagDeprecated, - }, - Detail: "testDetail", - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Data: "testData", - }, - } - wantTypeNil := CallHierarchyIncomingCallsParams{ - Item: CallHierarchyItem{ - Name: "testName", - Kind: SymbolKindFile, - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CallHierarchyIncomingCallsParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CallHierarchyIncomingCallsParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CallHierarchyIncomingCallsParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestCallHierarchyIncomingCall(t *testing.T) { - const ( - want = `{"from":{"name":"testName","kind":1,"tags":[1],"detail":"testDetail","uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"selectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"data":"testData"},"fromRanges":[{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}]}` - wantInvalid = `{"from":{"name":"invalidName","kind":0,"tags":[0],"detail":"invalidDetail","uri":"file:///path/to/invalid.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"selectionRange":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"data":"invalidData"},"fromRanges":[{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}]}` - ) - wantType := CallHierarchyIncomingCall{ - From: CallHierarchyItem{ - Name: "testName", - Kind: SymbolKindFile, - Tags: []SymbolTag{ - SymbolTagDeprecated, - }, - Detail: "testDetail", - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Data: "testData", - }, - FromRanges: []Range{ - { - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CallHierarchyIncomingCall - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CallHierarchyIncomingCall - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CallHierarchyIncomingCall - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCallHierarchyOutgoingCallsParams(t *testing.T) { - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","item":{"name":"testName","kind":1,"tags":[1],"detail":"testDetail","uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"selectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"data":"testData"}}` - wantNil = `{"item":{"name":"testName","kind":1,"uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"selectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}}` - wantInvalid = `{"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","item":{"name":"invalidName","kind":0,"tags":[0],"detail":"invalidDetail","uri":"file:///path/to/invalid.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"selectionRange":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"data":"invalidData"}}` - ) - wantType := CallHierarchyOutgoingCallsParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - Item: CallHierarchyItem{ - Name: "testName", - Kind: SymbolKindFile, - Tags: []SymbolTag{ - SymbolTagDeprecated, - }, - Detail: "testDetail", - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Data: "testData", - }, - } - wantTypeNil := CallHierarchyOutgoingCallsParams{ - Item: CallHierarchyItem{ - Name: "testName", - Kind: SymbolKindFile, - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CallHierarchyOutgoingCallsParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CallHierarchyOutgoingCallsParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CallHierarchyOutgoingCallsParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestCallHierarchyOutgoingCall(t *testing.T) { - const ( - want = `{"to":{"name":"testName","kind":1,"tags":[1],"detail":"testDetail","uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"selectionRange":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"data":"testData"},"fromRanges":[{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}]}` - wantInvalid = `{"to":{"name":"invalidName","kind":0,"tags":[0],"detail":"invalidDetail","uri":"file:///path/to/invalid.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"selectionRange":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"data":"invalidData"},"fromRanges":[{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}]}` - ) - wantType := CallHierarchyOutgoingCall{ - To: CallHierarchyItem{ - Name: "testName", - Kind: SymbolKindFile, - Tags: []SymbolTag{ - SymbolTagDeprecated, - }, - Detail: "testDetail", - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Data: "testData", - }, - FromRanges: []Range{ - { - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CallHierarchyOutgoingCall - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CallHierarchyOutgoingCall - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CallHierarchyOutgoingCall - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} diff --git a/capabilities_client.go b/capabilities_client.go deleted file mode 100644 index 9f02a11a..00000000 --- a/capabilities_client.go +++ /dev/null @@ -1,1068 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import "strconv" - -// ClientCapabilities now define capabilities for dynamic registration, workspace and text document features -// the client supports. -// -// The experimental can be used to pass experimental capabilities under development. -// -// For future compatibility a ClientCapabilities object literal can have more properties set than currently defined. -// Servers receiving a ClientCapabilities object literal with unknown properties should ignore these properties. -// -// A missing property should be interpreted as an absence of the capability. -// If a missing property normally defines sub properties, all missing sub properties should be interpreted -// as an absence of the corresponding capability. -type ClientCapabilities struct { - // Workspace specific client capabilities. - Workspace *WorkspaceClientCapabilities `json:"workspace,omitempty"` - - // TextDocument specific client capabilities. - TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"` - - // Window specific client capabilities. - Window *WindowClientCapabilities `json:"window,omitempty"` - - // General client capabilities. - // - // @since 3.16.0. - General *GeneralClientCapabilities `json:"general,omitempty"` - - // Experimental client capabilities. - Experimental interface{} `json:"experimental,omitempty"` -} - -// WorkspaceClientCapabilities Workspace specific client capabilities. -type WorkspaceClientCapabilities struct { - // The client supports applying batch edits to the workspace by supporting - // the request "workspace/applyEdit". - ApplyEdit bool `json:"applyEdit,omitempty"` - - // WorkspaceEdit capabilities specific to `WorkspaceEdit`s. - WorkspaceEdit *WorkspaceClientCapabilitiesWorkspaceEdit `json:"workspaceEdit,omitempty"` - - // DidChangeConfiguration capabilities specific to the `workspace/didChangeConfiguration` notification. - DidChangeConfiguration *DidChangeConfigurationWorkspaceClientCapabilities `json:"didChangeConfiguration,omitempty"` - - // DidChangeWatchedFiles capabilities specific to the `workspace/didChangeWatchedFiles` notification. - DidChangeWatchedFiles *DidChangeWatchedFilesWorkspaceClientCapabilities `json:"didChangeWatchedFiles,omitempty"` - - // Symbol capabilities specific to the "workspace/symbol" request. - Symbol *WorkspaceSymbolClientCapabilities `json:"symbol,omitempty"` - - // ExecuteCommand capabilities specific to the "workspace/executeCommand" request. - ExecuteCommand *ExecuteCommandClientCapabilities `json:"executeCommand,omitempty"` - - // WorkspaceFolders is the client has support for workspace folders. - // - // @since 3.6.0. - WorkspaceFolders bool `json:"workspaceFolders,omitempty"` - - // Configuration is the client supports "workspace/configuration" requests. - // - // @since 3.6.0. - Configuration bool `json:"configuration,omitempty"` - - // SemanticTokens is the capabilities specific to the semantic token requests scoped to the - // workspace. - // - // @since 3.16.0. - SemanticTokens *SemanticTokensWorkspaceClientCapabilities `json:"semanticTokens,omitempty"` - - // CodeLens is the Capabilities specific to the code lens requests scoped to the - // workspace. - // - // @since 3.16.0. - CodeLens *CodeLensWorkspaceClientCapabilities `json:"codeLens,omitempty"` - - // FileOperations is the client has support for file requests/notifications. - // - // @since 3.16.0. - FileOperations *WorkspaceClientCapabilitiesFileOperations `json:"fileOperations,omitempty"` -} - -// WorkspaceClientCapabilitiesWorkspaceEdit capabilities specific to "WorkspaceEdit"s. -type WorkspaceClientCapabilitiesWorkspaceEdit struct { - // DocumentChanges is the client supports versioned document changes in `WorkspaceEdit`s - DocumentChanges bool `json:"documentChanges,omitempty"` - - // FailureHandling is the failure handling strategy of a client if applying the workspace edit - // fails. - // - // Mostly FailureHandlingKind. - FailureHandling string `json:"failureHandling,omitempty"` - - // ResourceOperations is the resource operations the client supports. Clients should at least - // support "create", "rename" and "delete" files and folders. - ResourceOperations []string `json:"resourceOperations,omitempty"` - - // NormalizesLineEndings whether the client normalizes line endings to the client specific - // setting. - // If set to `true` the client will normalize line ending characters - // in a workspace edit to the client specific new line character(s). - // - // @since 3.16.0. - NormalizesLineEndings bool `json:"normalizesLineEndings,omitempty"` - - // ChangeAnnotationSupport whether the client in general supports change annotations on text edits, - // create file, rename file and delete file changes. - // - // @since 3.16.0. - ChangeAnnotationSupport *WorkspaceClientCapabilitiesWorkspaceEditChangeAnnotationSupport `json:"changeAnnotationSupport,omitempty"` -} - -// FailureHandlingKind is the kind of failure handling . -type FailureHandlingKind string - -const ( - // FailureHandlingKindAbort applying the workspace change is simply aborted if one of the changes provided - // fails. All operations executed before the failing operation stay executed. - FailureHandlingKindAbort FailureHandlingKind = "abort" - - // FailureHandlingKindTransactional all operations are executed transactional. That means they either all - // succeed or no changes at all are applied to the workspace. - FailureHandlingKindTransactional FailureHandlingKind = "transactional" - - // FailureHandlingKindTextOnlyTransactional if the workspace edit contains only textual file changes they are executed transactional. - // If resource changes (create, rename or delete file) are part of the change the failure - // handling strategy is abort. - FailureHandlingKindTextOnlyTransactional FailureHandlingKind = "textOnlyTransactional" - - // FailureHandlingKindUndo the client tries to undo the operations already executed. But there is no - // guarantee that this is succeeding. - FailureHandlingKindUndo FailureHandlingKind = "undo" -) - -// WorkspaceClientCapabilitiesWorkspaceEditChangeAnnotationSupport is the ChangeAnnotationSupport of WorkspaceClientCapabilitiesWorkspaceEdit. -// -// @since 3.16.0. -type WorkspaceClientCapabilitiesWorkspaceEditChangeAnnotationSupport struct { - // GroupsOnLabel whether the client groups edits with equal labels into tree nodes, - // for instance all edits labeled with "Changes in Strings" would - // be a tree node. - GroupsOnLabel bool `json:"groupsOnLabel,omitempty"` -} - -// DidChangeConfigurationWorkspaceClientCapabilities capabilities specific to the "workspace/didChangeConfiguration" notification. -// -// @since 3.16.0. -type DidChangeConfigurationWorkspaceClientCapabilities struct { - // DynamicRegistration whether the did change configuration notification supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// DidChangeWatchedFilesWorkspaceClientCapabilities capabilities specific to the "workspace/didChangeWatchedFiles" notification. -// -// @since 3.16.0. -type DidChangeWatchedFilesWorkspaceClientCapabilities struct { - // Did change watched files notification supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// WorkspaceSymbolClientCapabilities capabilities specific to the `workspace/symbol` request. -// -// WorkspaceSymbolClientCapabilities is the workspace symbol request is sent from the client to the server to -// list project-wide symbols matching the query string. -type WorkspaceSymbolClientCapabilities struct { - // DynamicRegistration is the Symbol request supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // SymbolKindCapabilities is the specific capabilities for the SymbolKindCapabilities in the "workspace/symbol" request. - SymbolKind *SymbolKindCapabilities `json:"symbolKind,omitempty"` - - // TagSupport is the client supports tags on `SymbolInformation`. - // Clients supporting tags have to handle unknown tags gracefully. - // - // @since 3.16.0 - TagSupport *TagSupportCapabilities `json:"tagSupport,omitempty"` -} - -type SymbolKindCapabilities struct { - // ValueSet is the symbol kind values the client supports. When this - // property exists the client also guarantees that it will - // handle values outside its set gracefully and falls back - // to a default value when unknown. - // - // If this property is not present the client only supports - // the symbol kinds from `File` to `Array` as defined in - // the initial version of the protocol. - ValueSet []SymbolKind `json:"valueSet,omitempty"` -} - -type TagSupportCapabilities struct { - // ValueSet is the tags supported by the client. - ValueSet []SymbolTag `json:"valueSet,omitempty"` -} - -// ExecuteCommandClientCapabilities capabilities specific to the "workspace/executeCommand" request. -type ExecuteCommandClientCapabilities struct { - // DynamicRegistration Execute command supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// SemanticTokensWorkspaceClientCapabilities capabilities specific to the "workspace/semanticToken" request. -// -// @since 3.16.0. -type SemanticTokensWorkspaceClientCapabilities struct { - // RefreshSupport whether the client implementation supports a refresh request sent from - // the server to the client. - // - // Note that this event is global and will force the client to refresh all - // semantic tokens currently shown. It should be used with absolute care - // and is useful for situation where a server for example detect a project - // wide change that requires such a calculation. - RefreshSupport bool `json:"refreshSupport,omitempty"` -} - -// CodeLensWorkspaceClientCapabilities capabilities specific to the "workspace/codeLens" request. -// -// @since 3.16.0. -type CodeLensWorkspaceClientCapabilities struct { - // RefreshSupport whether the client implementation supports a refresh request sent from the - // server to the client. - // - // Note that this event is global and will force the client to refresh all - // code lenses currently shown. It should be used with absolute care and is - // useful for situation where a server for example detect a project wide - // change that requires such a calculation. - RefreshSupport bool `json:"refreshSupport,omitempty"` -} - -// WorkspaceClientCapabilitiesFileOperations capabilities specific to the fileOperations. -// -// @since 3.16.0. -type WorkspaceClientCapabilitiesFileOperations struct { - // DynamicRegistration whether the client supports dynamic registration for file - // requests/notifications. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // DidCreate is the client has support for sending didCreateFiles notifications. - DidCreate bool `json:"didCreate,omitempty"` - - // WillCreate is the client has support for sending willCreateFiles requests. - WillCreate bool `json:"willCreate,omitempty"` - - // DidRename is the client has support for sending didRenameFiles notifications. - DidRename bool `json:"didRename,omitempty"` - - // WillRename is the client has support for sending willRenameFiles requests. - WillRename bool `json:"willRename,omitempty"` - - // DidDelete is the client has support for sending didDeleteFiles notifications. - DidDelete bool `json:"didDelete,omitempty"` - - // WillDelete is the client has support for sending willDeleteFiles requests. - WillDelete bool `json:"willDelete,omitempty"` -} - -// TextDocumentClientCapabilities Text document specific client capabilities. -type TextDocumentClientCapabilities struct { - // Synchronization defines which synchronization capabilities the client supports. - Synchronization *TextDocumentSyncClientCapabilities `json:"synchronization,omitempty"` - - // Completion Capabilities specific to the "textDocument/completion". - Completion *CompletionTextDocumentClientCapabilities `json:"completion,omitempty"` - - // Hover capabilities specific to the "textDocument/hover". - Hover *HoverTextDocumentClientCapabilities `json:"hover,omitempty"` - - // SignatureHelp capabilities specific to the "textDocument/signatureHelp". - SignatureHelp *SignatureHelpTextDocumentClientCapabilities `json:"signatureHelp,omitempty"` - - // Declaration capabilities specific to the "textDocument/declaration". - Declaration *DeclarationTextDocumentClientCapabilities `json:"declaration,omitempty"` - - // Definition capabilities specific to the "textDocument/definition". - // - // @since 3.14.0. - Definition *DefinitionTextDocumentClientCapabilities `json:"definition,omitempty"` - - // TypeDefinition capabilities specific to the "textDocument/typeDefinition". - // - // @since 3.6.0. - TypeDefinition *TypeDefinitionTextDocumentClientCapabilities `json:"typeDefinition,omitempty"` - - // Implementation capabilities specific to the "textDocument/implementation". - // - // @since 3.6.0. - Implementation *ImplementationTextDocumentClientCapabilities `json:"implementation,omitempty"` - - // References capabilities specific to the "textDocument/references". - References *ReferencesTextDocumentClientCapabilities `json:"references,omitempty"` - - // DocumentHighlight capabilities specific to the "textDocument/documentHighlight". - DocumentHighlight *DocumentHighlightClientCapabilities `json:"documentHighlight,omitempty"` - - // DocumentSymbol capabilities specific to the "textDocument/documentSymbol". - DocumentSymbol *DocumentSymbolClientCapabilities `json:"documentSymbol,omitempty"` - - // CodeAction capabilities specific to the "textDocument/codeAction". - CodeAction *CodeActionClientCapabilities `json:"codeAction,omitempty"` - - // CodeLens capabilities specific to the "textDocument/codeLens". - CodeLens *CodeLensClientCapabilities `json:"codeLens,omitempty"` - - // DocumentLink capabilities specific to the "textDocument/documentLink". - DocumentLink *DocumentLinkClientCapabilities `json:"documentLink,omitempty"` - - // ColorProvider capabilities specific to the "textDocument/documentColor" and the - // "textDocument/colorPresentation" request. - // - // @since 3.6.0. - ColorProvider *DocumentColorClientCapabilities `json:"colorProvider,omitempty"` - - // Formatting Capabilities specific to the "textDocument/formatting" request. - Formatting *DocumentFormattingClientCapabilities `json:"formatting,omitempty"` - - // RangeFormatting Capabilities specific to the "textDocument/rangeFormatting" request. - RangeFormatting *DocumentRangeFormattingClientCapabilities `json:"rangeFormatting,omitempty"` - - // OnTypeFormatting Capabilities specific to the "textDocument/onTypeFormatting" request. - OnTypeFormatting *DocumentOnTypeFormattingClientCapabilities `json:"onTypeFormatting,omitempty"` - - // PublishDiagnostics capabilities specific to "textDocument/publishDiagnostics". - PublishDiagnostics *PublishDiagnosticsClientCapabilities `json:"publishDiagnostics,omitempty"` - - // Rename capabilities specific to the "textDocument/rename". - Rename *RenameClientCapabilities `json:"rename,omitempty"` - - // FoldingRange capabilities specific to "textDocument/foldingRange" requests. - // - // @since 3.10.0. - FoldingRange *FoldingRangeClientCapabilities `json:"foldingRange,omitempty"` - - // SelectionRange capabilities specific to "textDocument/selectionRange" requests. - // - // @since 3.15.0. - SelectionRange *SelectionRangeClientCapabilities `json:"selectionRange,omitempty"` - - // CallHierarchy capabilities specific to the various call hierarchy requests. - // - // @since 3.16.0. - CallHierarchy *CallHierarchyClientCapabilities `json:"callHierarchy,omitempty"` - - // SemanticTokens capabilities specific to the various semantic token requests. - // - // @since 3.16.0. - SemanticTokens *SemanticTokensClientCapabilities `json:"semanticTokens,omitempty"` - - // LinkedEditingRange capabilities specific to the "textDocument/linkedEditingRange" request. - // - // @since 3.16.0. - LinkedEditingRange *LinkedEditingRangeClientCapabilities `json:"linkedEditingRange,omitempty"` - - // Moniker capabilities specific to the "textDocument/moniker" request. - // - // @since 3.16.0. - Moniker *MonikerClientCapabilities `json:"moniker,omitempty"` -} - -// TextDocumentSyncClientCapabilities defines which synchronization capabilities the client supports. -type TextDocumentSyncClientCapabilities struct { - // DynamicRegistration whether text document synchronization supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // WillSave is the client supports sending will save notifications. - WillSave bool `json:"willSave,omitempty"` - - // WillSaveWaitUntil is the client supports sending a will save request and - // waits for a response providing text edits which will - // be applied to the document before it is saved. - WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` - - // DidSave is the client supports did save notifications. - DidSave bool `json:"didSave,omitempty"` -} - -// CompletionTextDocumentClientCapabilities Capabilities specific to the "textDocument/completion". -type CompletionTextDocumentClientCapabilities struct { - // Whether completion supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // The client supports the following `CompletionItem` specific - // capabilities. - CompletionItem *CompletionTextDocumentClientCapabilitiesItem `json:"completionItem,omitempty"` - - CompletionItemKind *CompletionTextDocumentClientCapabilitiesItemKind `json:"completionItemKind,omitempty"` - - // ContextSupport is the client supports to send additional context information for a - // `textDocument/completion` request. - ContextSupport bool `json:"contextSupport,omitempty"` -} - -// CompletionTextDocumentClientCapabilitiesItem is the client supports the following "CompletionItem" specific -// capabilities. -type CompletionTextDocumentClientCapabilitiesItem struct { - // SnippetSupport client supports snippets as insert text. - // - // A snippet can define tab stops and placeholders with `$1`, `$2` - // and `${3:foo}`. `$0` defines the final tab stop, it defaults to - // the end of the snippet. Placeholders with equal identifiers are linked, - // that is typing in one will update others too. - SnippetSupport bool `json:"snippetSupport,omitempty"` - - // CommitCharactersSupport client supports commit characters on a completion item. - CommitCharactersSupport bool `json:"commitCharactersSupport,omitempty"` - - // DocumentationFormat client supports the follow content formats for the documentation - // property. The order describes the preferred format of the client. - DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` - - // DeprecatedSupport client supports the deprecated property on a completion item. - DeprecatedSupport bool `json:"deprecatedSupport,omitempty"` - - // PreselectSupport client supports the preselect property on a completion item. - PreselectSupport bool `json:"preselectSupport,omitempty"` - - // TagSupport is the client supports the tag property on a completion item. - // - // Clients supporting tags have to handle unknown tags gracefully. - // Clients especially need to preserve unknown tags when sending - // a completion item back to the server in a resolve call. - // - // @since 3.15.0. - TagSupport *CompletionTextDocumentClientCapabilitiesItemTagSupport `json:"tagSupport,omitempty"` - - // InsertReplaceSupport client supports insert replace edit to control different behavior if - // a completion item is inserted in the text or should replace text. - // - // @since 3.16.0. - InsertReplaceSupport bool `json:"insertReplaceSupport,omitempty"` - - // ResolveSupport indicates which properties a client can resolve lazily on a - // completion item. Before version 3.16.0 only the predefined properties - // `documentation` and `details` could be resolved lazily. - // - // @since 3.16.0. - ResolveSupport *CompletionTextDocumentClientCapabilitiesItemResolveSupport `json:"resolveSupport,omitempty"` - - // InsertTextModeSupport is the client supports the `insertTextMode` property on - // a completion item to override the whitespace handling mode - // as defined by the client (see `insertTextMode`). - // - // @since 3.16.0. - InsertTextModeSupport *CompletionTextDocumentClientCapabilitiesItemInsertTextModeSupport `json:"insertTextModeSupport,omitempty"` -} - -// CompletionTextDocumentClientCapabilitiesItemTagSupport specific capabilities for the "TagSupport" in the "textDocument/completion" request. -// -// @since 3.15.0. -type CompletionTextDocumentClientCapabilitiesItemTagSupport struct { - // ValueSet is the tags supported by the client. - // - // @since 3.15.0. - ValueSet []CompletionItemTag `json:"valueSet,omitempty"` -} - -// CompletionTextDocumentClientCapabilitiesItemResolveSupport specific capabilities for the ResolveSupport in the CompletionTextDocumentClientCapabilitiesItem. -// -// @since 3.16.0. -type CompletionTextDocumentClientCapabilitiesItemResolveSupport struct { - // Properties is the properties that a client can resolve lazily. - Properties []string `json:"properties"` -} - -// CompletionTextDocumentClientCapabilitiesItemInsertTextModeSupport specific capabilities for the InsertTextModeSupport in the CompletionTextDocumentClientCapabilitiesItem. -// -// @since 3.16.0. -type CompletionTextDocumentClientCapabilitiesItemInsertTextModeSupport struct { - // ValueSet is the tags supported by the client. - // - // @since 3.16.0. - ValueSet []InsertTextMode `json:"valueSet,omitempty"` -} - -// CompletionTextDocumentClientCapabilitiesItemKind specific capabilities for the "CompletionItemKind" in the "textDocument/completion" request. -type CompletionTextDocumentClientCapabilitiesItemKind struct { - // The completion item kind values the client supports. When this - // property exists the client also guarantees that it will - // handle values outside its set gracefully and falls back - // to a default value when unknown. - // - // If this property is not present the client only supports - // the completion items kinds from `Text` to `Reference` as defined in - // the initial version of the protocol. - // - ValueSet []CompletionItemKind `json:"valueSet,omitempty"` -} - -// HoverTextDocumentClientCapabilities capabilities specific to the "textDocument/hover". -type HoverTextDocumentClientCapabilities struct { - // DynamicRegistration whether hover supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // ContentFormat is the client supports the follow content formats for the content - // property. The order describes the preferred format of the client. - ContentFormat []MarkupKind `json:"contentFormat,omitempty"` -} - -// SignatureHelpTextDocumentClientCapabilities capabilities specific to the "textDocument/signatureHelp". -type SignatureHelpTextDocumentClientCapabilities struct { - // DynamicRegistration whether signature help supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // SignatureInformation is the client supports the following "SignatureInformation" - // specific properties. - SignatureInformation *TextDocumentClientCapabilitiesSignatureInformation `json:"signatureInformation,omitempty"` - - // ContextSupport is the client supports to send additional context information for a "textDocument/signatureHelp" request. - // - // A client that opts into contextSupport will also support the "retriggerCharacters" on "SignatureHelpOptions". - // - // @since 3.15.0. - ContextSupport bool `json:"contextSupport,omitempty"` -} - -// TextDocumentClientCapabilitiesSignatureInformation is the client supports the following "SignatureInformation" -// specific properties. -type TextDocumentClientCapabilitiesSignatureInformation struct { - // DocumentationFormat is the client supports the follow content formats for the documentation - // property. The order describes the preferred format of the client. - DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` - - // ParameterInformation is the Client capabilities specific to parameter information. - ParameterInformation *TextDocumentClientCapabilitiesParameterInformation `json:"parameterInformation,omitempty"` - - // ActiveParameterSupport is the client supports the `activeParameter` property on - // `SignatureInformation` literal. - // - // @since 3.16.0. - ActiveParameterSupport bool `json:"activeParameterSupport,omitempty"` -} - -// TextDocumentClientCapabilitiesParameterInformation is the client capabilities specific to parameter information. -type TextDocumentClientCapabilitiesParameterInformation struct { - // LabelOffsetSupport is the client supports processing label offsets instead of a - // simple label string. - // - // @since 3.14.0. - LabelOffsetSupport bool `json:"labelOffsetSupport,omitempty"` -} - -// DeclarationTextDocumentClientCapabilities capabilities specific to the "textDocument/declaration". -type DeclarationTextDocumentClientCapabilities struct { - // DynamicRegistration whether declaration 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,omitempty"` - - // LinkSupport is the client supports additional metadata in the form of declaration links. - // - // @since 3.14.0. - LinkSupport bool `json:"linkSupport,omitempty"` -} - -// DefinitionTextDocumentClientCapabilities capabilities specific to the "textDocument/definition". -// -// @since 3.14.0. -type DefinitionTextDocumentClientCapabilities struct { - // DynamicRegistration whether definition supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // LinkSupport is the client supports additional metadata in the form of definition links. - LinkSupport bool `json:"linkSupport,omitempty"` -} - -// TypeDefinitionTextDocumentClientCapabilities capabilities specific to the "textDocument/typeDefinition". -// -// @since 3.6.0. -type TypeDefinitionTextDocumentClientCapabilities struct { - // DynamicRegistration whether typeDefinition 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,omitempty"` - - // LinkSupport is the client supports additional metadata in the form of definition links. - // - // @since 3.14.0 - LinkSupport bool `json:"linkSupport,omitempty"` -} - -// ImplementationTextDocumentClientCapabilities capabilities specific to the "textDocument/implementation". -// -// @since 3.6.0. -type ImplementationTextDocumentClientCapabilities struct { - // DynamicRegistration 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,omitempty"` - - // LinkSupport is the client supports additional metadata in the form of definition links. - // - // @since 3.14.0 - LinkSupport bool `json:"linkSupport,omitempty"` -} - -// ReferencesTextDocumentClientCapabilities capabilities specific to the "textDocument/references". -type ReferencesTextDocumentClientCapabilities struct { - // DynamicRegistration whether references supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// DocumentHighlightClientCapabilities capabilities specific to the "textDocument/documentHighlight". -type DocumentHighlightClientCapabilities struct { - // DynamicRegistration Whether document highlight supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// DocumentSymbolClientCapabilities capabilities specific to the "textDocument/documentSymbol". -type DocumentSymbolClientCapabilities struct { - // DynamicRegistration whether document symbol supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // SymbolKind specific capabilities for the "SymbolKindCapabilities". - SymbolKind *SymbolKindCapabilities `json:"symbolKind,omitempty"` - - // HierarchicalDocumentSymbolSupport is the client support hierarchical document symbols. - HierarchicalDocumentSymbolSupport bool `json:"hierarchicalDocumentSymbolSupport,omitempty"` - - // TagSupport is the client supports tags on "SymbolInformation". Tags are supported on - // "DocumentSymbol" if "HierarchicalDocumentSymbolSupport" is set to true. - // Clients supporting tags have to handle unknown tags gracefully. - // - // @since 3.16.0. - TagSupport *DocumentSymbolClientCapabilitiesTagSupport `json:"tagSupport,omitempty"` - - // LabelSupport is the client supports an additional label presented in the UI when - // registering a document symbol provider. - // - // @since 3.16.0. - LabelSupport bool `json:"labelSupport,omitempty"` -} - -// DocumentSymbolClientCapabilitiesTagSupport TagSupport in the DocumentSymbolClientCapabilities. -// -// @since 3.16.0. -type DocumentSymbolClientCapabilitiesTagSupport struct { - // ValueSet is the tags supported by the client. - ValueSet []SymbolTag `json:"valueSet"` -} - -// CodeActionClientCapabilities capabilities specific to the "textDocument/codeAction". -type CodeActionClientCapabilities struct { - // DynamicRegistration whether code action supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // CodeActionLiteralSupport is the client support code action literals as a valid - // response of the "textDocument/codeAction" request. - // - // @since 3.8.0 - CodeActionLiteralSupport *CodeActionClientCapabilitiesLiteralSupport `json:"codeActionLiteralSupport,omitempty"` - - // IsPreferredSupport whether code action supports the "isPreferred" property. - // - // @since 3.15.0. - IsPreferredSupport bool `json:"isPreferredSupport,omitempty"` - - // DisabledSupport whether code action supports the `disabled` property. - // - // @since 3.16.0. - DisabledSupport bool `json:"disabledSupport,omitempty"` - - // DataSupport whether code action supports the `data` property which is - // preserved between a `textDocument/codeAction` and a - // `codeAction/resolve` request. - // - // @since 3.16.0. - DataSupport bool `json:"dataSupport,omitempty"` - - // ResolveSupport whether the client supports resolving additional code action - // properties via a separate `codeAction/resolve` request. - // - // @since 3.16.0. - ResolveSupport *CodeActionClientCapabilitiesResolveSupport `json:"resolveSupport,omitempty"` - - // HonorsChangeAnnotations whether the client honors the change annotations in - // text edits and resource operations returned via the - // `CodeAction#edit` property by for example presenting - // the workspace edit in the user interface and asking - // for confirmation. - // - // @since 3.16.0. - HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitempty"` -} - -// CodeActionClientCapabilitiesLiteralSupport is the client support code action literals as a valid response of the "textDocument/codeAction" request. -type CodeActionClientCapabilitiesLiteralSupport struct { - // CodeActionKind is the code action kind is support with the following value - // set. - CodeActionKind *CodeActionClientCapabilitiesKind `json:"codeActionKind"` -} - -// CodeActionClientCapabilitiesKind is the code action kind is support with the following value set. -type CodeActionClientCapabilitiesKind struct { - // ValueSet is the code action kind values the client supports. When this - // property exists the client also guarantees that it will - // handle values outside its set gracefully and falls back - // to a default value when unknown. - ValueSet []CodeActionKind `json:"valueSet"` -} - -// CodeActionClientCapabilitiesResolveSupport ResolveSupport in the CodeActionClientCapabilities. -// -// @since 3.16.0. -type CodeActionClientCapabilitiesResolveSupport struct { - // Properties is the properties that a client can resolve lazily. - Properties []string `json:"properties"` -} - -// CodeLensClientCapabilities capabilities specific to the "textDocument/codeLens". -type CodeLensClientCapabilities struct { - // DynamicRegistration Whether code lens supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// DocumentLinkClientCapabilities capabilities specific to the "textDocument/documentLink". -type DocumentLinkClientCapabilities struct { - // DynamicRegistration whether document link supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // TooltipSupport whether the client supports the "tooltip" property on "DocumentLink". - // - // @since 3.15.0. - TooltipSupport bool `json:"tooltipSupport,omitempty"` -} - -// DocumentColorClientCapabilities capabilities specific to the "textDocument/documentColor" and the -// "textDocument/colorPresentation" request. -// -// @since 3.6.0. -type DocumentColorClientCapabilities struct { - // DynamicRegistration whether colorProvider supports dynamic registration. If this is set to `true` - // the client supports the new "(ColorProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions)" - // return value for the corresponding server capability as well. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// DocumentFormattingClientCapabilities capabilities specific to the "textDocument/formatting". -type DocumentFormattingClientCapabilities struct { - // DynamicRegistration whether code lens supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// DocumentRangeFormattingClientCapabilities capabilities specific to the "textDocument/rangeFormatting". -type DocumentRangeFormattingClientCapabilities struct { - // DynamicRegistration whether code lens supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// DocumentOnTypeFormattingClientCapabilities capabilities specific to the "textDocument/onTypeFormatting". -type DocumentOnTypeFormattingClientCapabilities struct { - // DynamicRegistration whether code lens supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// PublishDiagnosticsClientCapabilities capabilities specific to "textDocument/publishDiagnostics". -type PublishDiagnosticsClientCapabilities struct { - // RelatedInformation whether the clients accepts diagnostics with related information. - RelatedInformation bool `json:"relatedInformation,omitempty"` - - // TagSupport clients supporting tags have to handle unknown tags gracefully. - // - // @since 3.15.0. - TagSupport *PublishDiagnosticsClientCapabilitiesTagSupport `json:"tagSupport,omitempty"` - - // VersionSupport whether the client interprets the version property of the - // "textDocument/publishDiagnostics" notification`s parameter. - // - // @since 3.15.0. - VersionSupport bool `json:"versionSupport,omitempty"` - - // CodeDescriptionSupport client supports a codeDescription property - // - // @since 3.16.0. - CodeDescriptionSupport bool `json:"codeDescriptionSupport,omitempty"` - - // DataSupport whether code action supports the `data` property which is - // preserved between a `textDocument/publishDiagnostics` and - // `textDocument/codeAction` request. - // - // @since 3.16.0. - DataSupport bool `json:"dataSupport,omitempty"` -} - -// PublishDiagnosticsClientCapabilitiesTagSupport is the client capacity of TagSupport. -// -// @since 3.15.0. -type PublishDiagnosticsClientCapabilitiesTagSupport struct { - // ValueSet is the tags supported by the client. - ValueSet []DiagnosticTag `json:"valueSet"` -} - -// RenameClientCapabilities capabilities specific to the "textDocument/rename". -type RenameClientCapabilities struct { - // DynamicRegistration whether rename supports dynamic registration. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // PrepareSupport is the client supports testing for validity of rename operations - // before execution. - PrepareSupport bool `json:"prepareSupport,omitempty"` - - // PrepareSupportDefaultBehavior client supports the default behavior result - // (`{ defaultBehavior: boolean }`). - // - // The value indicates the default behavior used by the - // client. - // - // @since 3.16.0. - PrepareSupportDefaultBehavior PrepareSupportDefaultBehavior `json:"prepareSupportDefaultBehavior,omitempty"` - - // HonorsChangeAnnotations whether th client honors the change annotations in - // text edits and resource operations returned via the - // rename request's workspace edit by for example presenting - // the workspace edit in the user interface and asking - // for confirmation. - // - // @since 3.16.0. - HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitempty"` -} - -// PrepareSupportDefaultBehavior default behavior of PrepareSupport. -// -// @since 3.16.0. -type PrepareSupportDefaultBehavior float64 - -// list of PrepareSupportDefaultBehavior. -const ( - // PrepareSupportDefaultBehaviorIdentifier is the client's default behavior is to select the identifier - // according the to language's syntax rule. - PrepareSupportDefaultBehaviorIdentifier PrepareSupportDefaultBehavior = 1 -) - -// String returns a string representation of the PrepareSupportDefaultBehavior. -func (k PrepareSupportDefaultBehavior) String() string { - switch k { - case PrepareSupportDefaultBehaviorIdentifier: - return "Identifier" - default: - return strconv.FormatFloat(float64(k), 'f', -10, 64) - } -} - -// FoldingRangeClientCapabilities capabilities specific to "textDocument/foldingRange" requests. -// -// @since 3.10.0. -type FoldingRangeClientCapabilities struct { - // DynamicRegistration whether implementation supports dynamic registration for folding range providers. If this is set to `true` - // the client supports the new "(FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions)" - // return value for the corresponding server capability as well. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` - - // RangeLimit is the maximum number of folding ranges that the client prefers to receive per document. The value serves as a - // hint, servers are free to follow the limit. - RangeLimit uint32 `json:"rangeLimit,omitempty"` - - // LineFoldingOnly if set, the client signals that it only supports folding complete lines. If set, client will - // ignore specified "startCharacter" and "endCharacter" properties in a FoldingRange. - LineFoldingOnly bool `json:"lineFoldingOnly,omitempty"` -} - -// SelectionRangeClientCapabilities capabilities specific to "textDocument/selectionRange" requests. -// -// @since 3.16.0. -type SelectionRangeClientCapabilities struct { - // DynamicRegistration whether implementation supports dynamic registration for selection range providers. If this is set to `true` - // the client supports the new "(SelectionRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions)" - // return value for the corresponding server capability as well. - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// CallHierarchyClientCapabilities capabilities specific to "textDocument/callHierarchy" requests. -// -// @since 3.16.0. -type CallHierarchyClientCapabilities struct { - // DynamicRegistration 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,omitempty"` -} - -// SemanticTokensClientCapabilities capabilities specific to the "textDocument.semanticTokens" request. -// -// @since 3.16.0. -type SemanticTokensClientCapabilities struct { - // DynamicRegistration 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,omitempty"` - - // Requests which requests the client supports and might send to the server - // depending on the server's capability. Please note that clients might not - // show semantic tokens or degrade some of the user experience if a range - // or full request is advertised by the client but not provided by the - // server. If for example the client capability `requests.full` and - // `request.range` are both set to true but the server only provides a - // range provider the client might not render a minimap correctly or might - // even decide to not show any semantic tokens at all. - Requests SemanticTokensWorkspaceClientCapabilitiesRequests `json:"requests"` - - // TokenTypes is the token types that the client supports. - TokenTypes []string `json:"tokenTypes"` - - // TokenModifiers is the token modifiers that the client supports. - TokenModifiers []string `json:"tokenModifiers"` - - // Formats is the formats the clients supports. - Formats []TokenFormat `json:"formats"` - - // OverlappingTokenSupport whether the client supports tokens that can overlap each other. - OverlappingTokenSupport bool `json:"overlappingTokenSupport,omitempty"` - - // MultilineTokenSupport whether the client supports tokens that can span multiple lines. - MultilineTokenSupport bool `json:"multilineTokenSupport,omitempty"` -} - -// SemanticTokensWorkspaceClientCapabilitiesRequests capabilities specific to the "textDocument/semanticTokens/xxx" request. -// -// @since 3.16.0. -type SemanticTokensWorkspaceClientCapabilitiesRequests struct { - // Range is the client will send the "textDocument/semanticTokens/range" request - // if the server provides a corresponding handler. - Range bool `json:"range,omitempty"` - - // Full is the client will send the "textDocument/semanticTokens/full" request - // if the server provides a corresponding handler. The client will send the - // `textDocument/semanticTokens/full/delta` request if the server provides a - // corresponding handler. - Full interface{} `json:"full,omitempty"` -} - -// LinkedEditingRangeClientCapabilities capabilities specific to "textDocument/linkedEditingRange" requests. -// -// @since 3.16.0. -type LinkedEditingRangeClientCapabilities struct { - // DynamicRegistration 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,omitempty"` -} - -// MonikerClientCapabilities capabilities specific to the "textDocument/moniker" request. -// -// @since 3.16.0. -type MonikerClientCapabilities struct { - // DynamicRegistration 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 whether implementation supports dynamic registration. If this is set to - DynamicRegistration bool `json:"dynamicRegistration,omitempty"` -} - -// WindowClientCapabilities represents a WindowClientCapabilities specific client capabilities. -// -// @since 3.15.0. -type WindowClientCapabilities struct { - // WorkDoneProgress whether client supports handling progress notifications. If set servers are allowed to - // report in "workDoneProgress" property in the request specific server capabilities. - // - // @since 3.15.0. - WorkDoneProgress bool `json:"workDoneProgress,omitempty"` - - // ShowMessage capabilities specific to the showMessage request. - // - // @since 3.16.0. - ShowMessage *ShowMessageRequestClientCapabilities `json:"showMessage,omitempty"` - - // ShowDocument client capabilities for the show document request. - // - // @since 3.16.0. - ShowDocument *ShowDocumentClientCapabilities `json:"showDocument,omitempty"` -} - -// ShowMessageRequestClientCapabilities show message request client capabilities. -// -// @since 3.16.0. -type ShowMessageRequestClientCapabilities struct { - // MessageActionItem capabilities specific to the "MessageActionItem" type. - MessageActionItem *ShowMessageRequestClientCapabilitiesMessageActionItem `json:"messageActionItem,omitempty"` -} - -// ShowMessageRequestClientCapabilitiesMessageActionItem capabilities specific to the "MessageActionItem" type. -// -// @since 3.16.0. -type ShowMessageRequestClientCapabilitiesMessageActionItem struct { - // AdditionalPropertiesSupport whether the client supports additional attributes which - // are preserved and sent back to the server in the - // request's response. - AdditionalPropertiesSupport bool `json:"additionalPropertiesSupport,omitempty"` -} - -// ShowDocumentClientCapabilities client capabilities for the show document request. -// -// @since 3.16.0. -type ShowDocumentClientCapabilities struct { - // Support is the client has support for the show document - // request. - Support bool `json:"support"` -} - -// GeneralClientCapabilities represents a General specific client capabilities. -// -// @since 3.16.0. -type GeneralClientCapabilities struct { - // RegularExpressions is the client capabilities specific to regular expressions. - // - // @since 3.16.0. - RegularExpressions *RegularExpressionsClientCapabilities `json:"regularExpressions,omitempty"` - - // Markdown client capabilities specific to the client's markdown parser. - // - // @since 3.16.0. - Markdown *MarkdownClientCapabilities `json:"markdown,omitempty"` -} - -// RegularExpressionsClientCapabilities represents a client capabilities specific to regular expressions. -// -// The following features from the ECMAScript 2020 regular expression specification are NOT mandatory for a client: -// -// Assertions -// -// Lookahead assertion, Negative lookahead assertion, lookbehind assertion, negative lookbehind assertion. -// -// Character classes -// -// Matching control characters using caret notation (e.g. "\cX") and matching UTF-16 code units (e.g. "\uhhhh"). -// -// Group and ranges -// -// Named capturing groups. -// -// Unicode property escapes -// -// None of the features needs to be supported. -// -// The only regular expression flag that a client needs to support is "i" to specify a case insensitive search. -// -// @since 3.16.0. -type RegularExpressionsClientCapabilities struct { - // Engine is the engine's name. - // - // Well known engine name is "ECMAScript". - // https://tc39.es/ecma262/#sec-regexp-regular-expression-objects - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions - Engine string `json:"engine"` - - // Version is the engine's version. - // - // Well known engine version is "ES2020". - // https://tc39.es/ecma262/#sec-regexp-regular-expression-objects - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions - Version string `json:"version,omitempty"` -} - -// MarkdownClientCapabilities represents a client capabilities specific to the used markdown parser. -// -// @since 3.16.0. -type MarkdownClientCapabilities struct { - // Parser is the name of the parser. - Parser string `json:"parser"` - - // version is the version of the parser. - Version string `json:"version,omitempty"` -} diff --git a/capabilities_client_test.go b/capabilities_client_test.go deleted file mode 100644 index bbb55e94..00000000 --- a/capabilities_client_test.go +++ /dev/null @@ -1,2787 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/segmentio/encoding/json" -) - -func TestClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"failureHandling":"FailureHandling","resourceOperations":["ResourceOperations"]},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6]}},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true,"configuration":true},"textDocument":{"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["plaintext","markdown"],"deprecatedSupport":true,"preselectSupport":true},"completionItemKind":{"valueSet":[1]},"contextSupport":true},"hover":{"dynamicRegistration":true,"contentFormat":["plaintext","markdown"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["plaintext","markdown"]}},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"relatedInformation":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5,"lineFoldingOnly":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"requests":{"range":true,"full":true},"tokenTypes":["test","tokenTypes"],"tokenModifiers":["test","tokenModifiers"],"formats":["relative"],"overlappingTokenSupport":true,"multilineTokenSupport":true},"linkedEditingRange":{"dynamicRegistration":true},"moniker":{"dynamicRegistration":true}},"window":{"workDoneProgress":true,"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"showDocument":{"support":true}},"general":{"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"markdown":{"parser":"marked","version":"1.1.0"}},"experimental":"testExperimental"}` - wantNil = `{}` - ) - wantType := ClientCapabilities{ - Workspace: &WorkspaceClientCapabilities{ - ApplyEdit: true, - WorkspaceEdit: &WorkspaceClientCapabilitiesWorkspaceEdit{ - DocumentChanges: true, - FailureHandling: "FailureHandling", - ResourceOperations: []string{"ResourceOperations"}, - }, - DidChangeConfiguration: &DidChangeConfigurationWorkspaceClientCapabilities{ - DynamicRegistration: true, - }, - DidChangeWatchedFiles: &DidChangeWatchedFilesWorkspaceClientCapabilities{ - DynamicRegistration: true, - }, - Symbol: &WorkspaceSymbolClientCapabilities{ - DynamicRegistration: true, - SymbolKind: &SymbolKindCapabilities{ - ValueSet: []SymbolKind{ - SymbolKindFile, - SymbolKindModule, - SymbolKindNamespace, - SymbolKindPackage, - SymbolKindClass, - SymbolKindMethod, - }, - }, - }, - ExecuteCommand: &ExecuteCommandClientCapabilities{ - DynamicRegistration: true, - }, - WorkspaceFolders: true, - Configuration: true, - }, - TextDocument: &TextDocumentClientCapabilities{ - Synchronization: &TextDocumentSyncClientCapabilities{ - DynamicRegistration: true, - WillSave: true, - WillSaveWaitUntil: true, - DidSave: true, - }, - Completion: &CompletionTextDocumentClientCapabilities{ - DynamicRegistration: true, - CompletionItem: &CompletionTextDocumentClientCapabilitiesItem{ - SnippetSupport: true, - CommitCharactersSupport: true, - DocumentationFormat: []MarkupKind{ - PlainText, - Markdown, - }, - DeprecatedSupport: true, - PreselectSupport: true, - }, - CompletionItemKind: &CompletionTextDocumentClientCapabilitiesItemKind{ - ValueSet: []CompletionItemKind{CompletionItemKindText}, - }, - ContextSupport: true, - }, - Hover: &HoverTextDocumentClientCapabilities{ - DynamicRegistration: true, - ContentFormat: []MarkupKind{ - PlainText, - Markdown, - }, - }, - SignatureHelp: &SignatureHelpTextDocumentClientCapabilities{ - DynamicRegistration: true, - SignatureInformation: &TextDocumentClientCapabilitiesSignatureInformation{ - DocumentationFormat: []MarkupKind{ - PlainText, - Markdown, - }, - }, - }, - Declaration: &DeclarationTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - }, - Definition: &DefinitionTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - }, - TypeDefinition: &TypeDefinitionTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - }, - Implementation: &ImplementationTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - }, - References: &ReferencesTextDocumentClientCapabilities{ - DynamicRegistration: true, - }, - DocumentHighlight: &DocumentHighlightClientCapabilities{ - DynamicRegistration: true, - }, - DocumentSymbol: &DocumentSymbolClientCapabilities{ - DynamicRegistration: true, - SymbolKind: &SymbolKindCapabilities{ - ValueSet: []SymbolKind{ - SymbolKindFile, - SymbolKindModule, - SymbolKindNamespace, - SymbolKindPackage, - SymbolKindClass, - SymbolKindMethod, - }, - }, - HierarchicalDocumentSymbolSupport: true, - }, - CodeAction: &CodeActionClientCapabilities{ - DynamicRegistration: true, - CodeActionLiteralSupport: &CodeActionClientCapabilitiesLiteralSupport{ - CodeActionKind: &CodeActionClientCapabilitiesKind{ - ValueSet: []CodeActionKind{ - QuickFix, - Refactor, - RefactorExtract, - RefactorRewrite, - Source, - SourceOrganizeImports, - }, - }, - }, - }, - CodeLens: &CodeLensClientCapabilities{ - DynamicRegistration: true, - }, - DocumentLink: &DocumentLinkClientCapabilities{ - DynamicRegistration: true, - }, - ColorProvider: &DocumentColorClientCapabilities{ - DynamicRegistration: true, - }, - Formatting: &DocumentFormattingClientCapabilities{ - DynamicRegistration: true, - }, - RangeFormatting: &DocumentRangeFormattingClientCapabilities{ - DynamicRegistration: true, - }, - OnTypeFormatting: &DocumentOnTypeFormattingClientCapabilities{ - DynamicRegistration: true, - }, - PublishDiagnostics: &PublishDiagnosticsClientCapabilities{ - RelatedInformation: true, - }, - Rename: &RenameClientCapabilities{ - DynamicRegistration: true, - PrepareSupport: true, - }, - FoldingRange: &FoldingRangeClientCapabilities{ - DynamicRegistration: true, - RangeLimit: uint32(5), - LineFoldingOnly: true, - }, - SelectionRange: &SelectionRangeClientCapabilities{ - DynamicRegistration: true, - }, - CallHierarchy: &CallHierarchyClientCapabilities{ - DynamicRegistration: true, - }, - SemanticTokens: &SemanticTokensClientCapabilities{ - DynamicRegistration: true, - Requests: SemanticTokensWorkspaceClientCapabilitiesRequests{ - Range: true, - Full: true, - }, - TokenTypes: []string{"test", "tokenTypes"}, - TokenModifiers: []string{"test", "tokenModifiers"}, - Formats: []TokenFormat{ - TokenFormatRelative, - }, - OverlappingTokenSupport: true, - MultilineTokenSupport: true, - }, - LinkedEditingRange: &LinkedEditingRangeClientCapabilities{ - DynamicRegistration: true, - }, - Moniker: &MonikerClientCapabilities{ - DynamicRegistration: true, - }, - }, - Window: &WindowClientCapabilities{ - WorkDoneProgress: true, - ShowMessage: &ShowMessageRequestClientCapabilities{ - MessageActionItem: &ShowMessageRequestClientCapabilitiesMessageActionItem{ - AdditionalPropertiesSupport: true, - }, - }, - ShowDocument: &ShowDocumentClientCapabilities{ - Support: true, - }, - }, - General: &GeneralClientCapabilities{ - RegularExpressions: &RegularExpressionsClientCapabilities{ - Engine: "ECMAScript", - Version: "ES2020", - }, - Markdown: &MarkdownClientCapabilities{ - Parser: "marked", - Version: "1.1.0", - }, - }, - Experimental: "testExperimental", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: ClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: ClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkspaceClientCapabilities(t *testing.T) { - t.Parallel() - - const want = `{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"failureHandling":"FailureHandling","resourceOperations":["ResourceOperations"],"normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6]}},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true,"configuration":true,"semanticTokens":{"refreshSupport":true},"codeLens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"willCreate":true,"didRename":true,"willRename":true,"didDelete":true,"willDelete":true}}` - wantType := WorkspaceClientCapabilities{ - ApplyEdit: true, - WorkspaceEdit: &WorkspaceClientCapabilitiesWorkspaceEdit{ - DocumentChanges: true, - FailureHandling: "FailureHandling", - ResourceOperations: []string{"ResourceOperations"}, - NormalizesLineEndings: true, - ChangeAnnotationSupport: &WorkspaceClientCapabilitiesWorkspaceEditChangeAnnotationSupport{ - GroupsOnLabel: true, - }, - }, - DidChangeConfiguration: &DidChangeConfigurationWorkspaceClientCapabilities{ - DynamicRegistration: true, - }, - DidChangeWatchedFiles: &DidChangeWatchedFilesWorkspaceClientCapabilities{ - DynamicRegistration: true, - }, - Symbol: &WorkspaceSymbolClientCapabilities{ - DynamicRegistration: true, - SymbolKind: &SymbolKindCapabilities{ - ValueSet: []SymbolKind{ - SymbolKindFile, - SymbolKindModule, - SymbolKindNamespace, - SymbolKindPackage, - SymbolKindClass, - SymbolKindMethod, - }, - }, - }, - ExecuteCommand: &ExecuteCommandClientCapabilities{ - DynamicRegistration: true, - }, - WorkspaceFolders: true, - Configuration: true, - SemanticTokens: &SemanticTokensWorkspaceClientCapabilities{ - RefreshSupport: true, - }, - CodeLens: &CodeLensWorkspaceClientCapabilities{ - RefreshSupport: true, - }, - FileOperations: &WorkspaceClientCapabilitiesFileOperations{ - DynamicRegistration: true, - DidCreate: true, - WillCreate: true, - DidRename: true, - WillRename: true, - DidDelete: true, - WillDelete: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field WorkspaceClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want WorkspaceClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkspaceClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkspaceClientCapabilitiesWorkspaceEdit(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentChanges":true,"failureHandling":"abort","resourceOperations":["create"],"normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}}` - wantNil = `{}` - ) - wantType := WorkspaceClientCapabilitiesWorkspaceEdit{ - DocumentChanges: true, - FailureHandling: string(FailureHandlingKindAbort), - ResourceOperations: []string{ - "create", - }, - NormalizesLineEndings: true, - ChangeAnnotationSupport: &WorkspaceClientCapabilitiesWorkspaceEditChangeAnnotationSupport{ - GroupsOnLabel: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field WorkspaceClientCapabilitiesWorkspaceEdit - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: WorkspaceClientCapabilitiesWorkspaceEdit{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want WorkspaceClientCapabilitiesWorkspaceEdit - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: WorkspaceClientCapabilitiesWorkspaceEdit{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkspaceClientCapabilitiesWorkspaceEdit - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["plaintext","markdown"],"deprecatedSupport":true,"preselectSupport":true},"completionItemKind":{"valueSet":[1]},"contextSupport":true},"hover":{"dynamicRegistration":true,"contentFormat":["plaintext","markdown"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["plaintext","markdown"]}},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"relatedInformation":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5,"lineFoldingOnly":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"requests":{"range":true,"full":true},"tokenTypes":["test","tokenTypes"],"tokenModifiers":["test","tokenModifiers"],"formats":["relative"],"overlappingTokenSupport":true,"multilineTokenSupport":true},"linkedEditingRange":{"dynamicRegistration":true},"moniker":{"dynamicRegistration":true}}` - wantNil = `{}` - ) - wantType := TextDocumentClientCapabilities{ - Synchronization: &TextDocumentSyncClientCapabilities{ - DynamicRegistration: true, - WillSave: true, - WillSaveWaitUntil: true, - DidSave: true, - }, - Completion: &CompletionTextDocumentClientCapabilities{ - DynamicRegistration: true, - CompletionItem: &CompletionTextDocumentClientCapabilitiesItem{ - SnippetSupport: true, - CommitCharactersSupport: true, - DocumentationFormat: []MarkupKind{ - PlainText, - Markdown, - }, - DeprecatedSupport: true, - PreselectSupport: true, - }, - CompletionItemKind: &CompletionTextDocumentClientCapabilitiesItemKind{ - ValueSet: []CompletionItemKind{CompletionItemKindText}, - }, - ContextSupport: true, - }, - Hover: &HoverTextDocumentClientCapabilities{ - DynamicRegistration: true, - ContentFormat: []MarkupKind{ - PlainText, - Markdown, - }, - }, - SignatureHelp: &SignatureHelpTextDocumentClientCapabilities{ - DynamicRegistration: true, - SignatureInformation: &TextDocumentClientCapabilitiesSignatureInformation{ - DocumentationFormat: []MarkupKind{ - PlainText, - Markdown, - }, - }, - }, - Declaration: &DeclarationTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - }, - Definition: &DefinitionTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - }, - TypeDefinition: &TypeDefinitionTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - }, - Implementation: &ImplementationTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - }, - References: &ReferencesTextDocumentClientCapabilities{ - DynamicRegistration: true, - }, - DocumentHighlight: &DocumentHighlightClientCapabilities{ - DynamicRegistration: true, - }, - DocumentSymbol: &DocumentSymbolClientCapabilities{ - DynamicRegistration: true, - SymbolKind: &SymbolKindCapabilities{ - ValueSet: []SymbolKind{ - SymbolKindFile, - SymbolKindModule, - SymbolKindNamespace, - SymbolKindPackage, - SymbolKindClass, - SymbolKindMethod, - }, - }, - HierarchicalDocumentSymbolSupport: true, - }, - CodeAction: &CodeActionClientCapabilities{ - DynamicRegistration: true, - CodeActionLiteralSupport: &CodeActionClientCapabilitiesLiteralSupport{ - CodeActionKind: &CodeActionClientCapabilitiesKind{ - ValueSet: []CodeActionKind{ - QuickFix, - Refactor, - RefactorExtract, - RefactorRewrite, - Source, - SourceOrganizeImports, - }, - }, - }, - }, - CodeLens: &CodeLensClientCapabilities{ - DynamicRegistration: true, - }, - DocumentLink: &DocumentLinkClientCapabilities{ - DynamicRegistration: true, - }, - ColorProvider: &DocumentColorClientCapabilities{ - DynamicRegistration: true, - }, - Formatting: &DocumentFormattingClientCapabilities{ - DynamicRegistration: true, - }, - RangeFormatting: &DocumentRangeFormattingClientCapabilities{ - DynamicRegistration: true, - }, - OnTypeFormatting: &DocumentOnTypeFormattingClientCapabilities{ - DynamicRegistration: true, - }, - PublishDiagnostics: &PublishDiagnosticsClientCapabilities{ - RelatedInformation: true, - }, - Rename: &RenameClientCapabilities{ - DynamicRegistration: true, - PrepareSupport: true, - }, - FoldingRange: &FoldingRangeClientCapabilities{ - DynamicRegistration: true, - RangeLimit: uint32(5), - LineFoldingOnly: true, - }, - SelectionRange: &SelectionRangeClientCapabilities{ - DynamicRegistration: true, - }, - CallHierarchy: &CallHierarchyClientCapabilities{ - DynamicRegistration: true, - }, - SemanticTokens: &SemanticTokensClientCapabilities{ - DynamicRegistration: true, - Requests: SemanticTokensWorkspaceClientCapabilitiesRequests{ - Range: true, - Full: true, - }, - TokenTypes: []string{"test", "tokenTypes"}, - TokenModifiers: []string{"test", "tokenModifiers"}, - Formats: []TokenFormat{ - TokenFormatRelative, - }, - OverlappingTokenSupport: true, - MultilineTokenSupport: true, - }, - LinkedEditingRange: &LinkedEditingRangeClientCapabilities{ - DynamicRegistration: true, - }, - Moniker: &MonikerClientCapabilities{ - DynamicRegistration: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TextDocumentClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: TextDocumentClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TextDocumentClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: TextDocumentClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentSyncClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true}` - wantNil = `{}` - ) - wantType := TextDocumentSyncClientCapabilities{ - DynamicRegistration: true, - WillSave: true, - WillSaveWaitUntil: true, - DidSave: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TextDocumentSyncClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: TextDocumentSyncClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TextDocumentSyncClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: TextDocumentSyncClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentSyncClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCompletionTextDocumentClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["plaintext","markdown"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["test","properties"]},"insertTextModeSupport":{"valueSet":[1,2]}},"completionItemKind":{"valueSet":[1]},"contextSupport":true}` - wantNil = `{}` - ) - wantType := CompletionTextDocumentClientCapabilities{ - DynamicRegistration: true, - CompletionItem: &CompletionTextDocumentClientCapabilitiesItem{ - SnippetSupport: true, - CommitCharactersSupport: true, - DocumentationFormat: []MarkupKind{ - PlainText, - Markdown, - }, - DeprecatedSupport: true, - PreselectSupport: true, - TagSupport: &CompletionTextDocumentClientCapabilitiesItemTagSupport{ - ValueSet: []CompletionItemTag{ - CompletionItemTagDeprecated, - }, - }, - InsertReplaceSupport: true, - ResolveSupport: &CompletionTextDocumentClientCapabilitiesItemResolveSupport{ - Properties: []string{"test", "properties"}, - }, - InsertTextModeSupport: &CompletionTextDocumentClientCapabilitiesItemInsertTextModeSupport{ - ValueSet: []InsertTextMode{ - InsertTextModeAsIs, - InsertTextModeAdjustIndentation, - }, - }, - }, - CompletionItemKind: &CompletionTextDocumentClientCapabilitiesItemKind{ - ValueSet: []CompletionItemKind{CompletionItemKindText}, - }, - ContextSupport: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CompletionTextDocumentClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: CompletionTextDocumentClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CompletionTextDocumentClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: CompletionTextDocumentClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CompletionTextDocumentClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestHoverTextDocumentClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"contentFormat":["plaintext","markdown"]}` - wantNil = `{}` - ) - wantType := HoverTextDocumentClientCapabilities{ - DynamicRegistration: true, - ContentFormat: []MarkupKind{ - PlainText, - Markdown, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field HoverTextDocumentClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: HoverTextDocumentClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want HoverTextDocumentClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: HoverTextDocumentClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got HoverTextDocumentClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestSignatureHelpTextDocumentClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["plaintext","markdown"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true},"contextSupport":true}` - wantNil = `{}` - ) - wantType := SignatureHelpTextDocumentClientCapabilities{ - DynamicRegistration: true, - SignatureInformation: &TextDocumentClientCapabilitiesSignatureInformation{ - DocumentationFormat: []MarkupKind{ - PlainText, - Markdown, - }, - ParameterInformation: &TextDocumentClientCapabilitiesParameterInformation{ - LabelOffsetSupport: true, - }, - ActiveParameterSupport: true, - }, - ContextSupport: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field SignatureHelpTextDocumentClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: SignatureHelpTextDocumentClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want SignatureHelpTextDocumentClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: SignatureHelpTextDocumentClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got SignatureHelpTextDocumentClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDeclarationTextDocumentClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"linkSupport":true}` - wantNil = `{}` - ) - wantType := DeclarationTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DeclarationTextDocumentClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DeclarationTextDocumentClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DeclarationTextDocumentClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DeclarationTextDocumentClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DeclarationTextDocumentClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDefinitionTextDocumentClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"linkSupport":true}` - wantNil = `{}` - ) - wantType := DefinitionTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DefinitionTextDocumentClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DefinitionTextDocumentClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DefinitionTextDocumentClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DefinitionTextDocumentClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DefinitionTextDocumentClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTypeDefinitionTextDocumentClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"linkSupport":true}` - wantNil = `{}` - ) - wantType := TypeDefinitionTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TypeDefinitionTextDocumentClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: TypeDefinitionTextDocumentClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TypeDefinitionTextDocumentClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: TypeDefinitionTextDocumentClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TypeDefinitionTextDocumentClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestImplementationTextDocumentClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"linkSupport":true}` - wantNil = `{}` - ) - wantType := ImplementationTextDocumentClientCapabilities{ - DynamicRegistration: true, - LinkSupport: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ImplementationTextDocumentClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: ImplementationTextDocumentClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ImplementationTextDocumentClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: ImplementationTextDocumentClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ImplementationTextDocumentClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestReferencesTextDocumentClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true}` - wantNil = `{}` - ) - wantType := ReferencesTextDocumentClientCapabilities{ - DynamicRegistration: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ReferencesTextDocumentClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: ReferencesTextDocumentClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ReferencesTextDocumentClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: ReferencesTextDocumentClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ReferencesTextDocumentClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentHighlightClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true}` - wantNil = `{}` - ) - wantType := DocumentHighlightClientCapabilities{ - DynamicRegistration: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentHighlightClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentHighlightClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentHighlightClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DocumentHighlightClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentHighlightClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentSymbolClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]},"labelSupport":true}` - wantNil = `{}` - ) - wantType := DocumentSymbolClientCapabilities{ - DynamicRegistration: true, - SymbolKind: &SymbolKindCapabilities{ - ValueSet: []SymbolKind{ - SymbolKindFile, - SymbolKindModule, - SymbolKindNamespace, - SymbolKindPackage, - SymbolKindClass, - SymbolKindMethod, - }, - }, - HierarchicalDocumentSymbolSupport: true, - TagSupport: &DocumentSymbolClientCapabilitiesTagSupport{ - ValueSet: []SymbolTag{ - SymbolTagDeprecated, - }, - }, - LabelSupport: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentSymbolClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentSymbolClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentSymbolClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DocumentSymbolClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentSymbolClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCodeActionClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.rewrite","source","source.organizeImports"]}},"isPreferredSupport":true,"disabledSupport":true,"dataSupport":true,"resolveSupport":{"properties":["testProperties"]},"honorsChangeAnnotations":true}` - wantNil = `{}` - ) - wantType := CodeActionClientCapabilities{ - DynamicRegistration: true, - CodeActionLiteralSupport: &CodeActionClientCapabilitiesLiteralSupport{ - CodeActionKind: &CodeActionClientCapabilitiesKind{ - ValueSet: []CodeActionKind{ - QuickFix, - Refactor, - RefactorExtract, - RefactorRewrite, - Source, - SourceOrganizeImports, - }, - }, - }, - IsPreferredSupport: true, - DisabledSupport: true, - DataSupport: true, - ResolveSupport: &CodeActionClientCapabilitiesResolveSupport{ - Properties: []string{"testProperties"}, - }, - HonorsChangeAnnotations: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CodeActionClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: CodeActionClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CodeActionClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: CodeActionClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeActionClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCodeLensClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true}` - wantNil = `{}` - ) - wantType := CodeLensClientCapabilities{ - DynamicRegistration: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CodeLensClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: CodeLensClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CodeLensClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: CodeLensClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeLensClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentLinkClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"tooltipSupport":true}` - wantNil = `{}` - ) - wantType := DocumentLinkClientCapabilities{ - DynamicRegistration: true, - TooltipSupport: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentLinkClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentLinkClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentLinkClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DocumentLinkClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentLinkClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentColorClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true}` - wantNil = `{}` - ) - wantType := DocumentColorClientCapabilities{ - DynamicRegistration: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentColorClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentColorClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentColorClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DocumentColorClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentColorClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestPublishDiagnosticsClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"relatedInformation":true,"tagSupport":{"valueSet":[2,1]},"versionSupport":true,"codeDescriptionSupport":true,"dataSupport":true}` - wantNil = `{}` - ) - wantType := PublishDiagnosticsClientCapabilities{ - RelatedInformation: true, - TagSupport: &PublishDiagnosticsClientCapabilitiesTagSupport{ - ValueSet: []DiagnosticTag{ - DiagnosticTagDeprecated, - DiagnosticTagUnnecessary, - }, - }, - VersionSupport: true, - CodeDescriptionSupport: true, - DataSupport: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field PublishDiagnosticsClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: PublishDiagnosticsClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want PublishDiagnosticsClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: PublishDiagnosticsClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got PublishDiagnosticsClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestRenameClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1,"honorsChangeAnnotations":true}` - wantNil = `{}` - ) - wantType := RenameClientCapabilities{ - DynamicRegistration: true, - PrepareSupport: true, - PrepareSupportDefaultBehavior: PrepareSupportDefaultBehaviorIdentifier, - HonorsChangeAnnotations: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field RenameClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: RenameClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want RenameClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: RenameClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got RenameClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestFoldingRangeClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"rangeLimit":5,"lineFoldingOnly":true}` - wantNil = `{}` - ) - wantType := FoldingRangeClientCapabilities{ - DynamicRegistration: true, - RangeLimit: uint32(5), - LineFoldingOnly: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field FoldingRangeClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: FoldingRangeClientCapabilities{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want FoldingRangeClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: FoldingRangeClientCapabilities{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got FoldingRangeClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestSemanticTokensClientCapabilities(t *testing.T) { - t.Parallel() - - const ( - want = `{"dynamicRegistration":true,"requests":{"range":true,"full":true},"tokenTypes":["namespace","type","class"],"tokenModifiers":["declaration","definition","readonly"],"formats":["relative"],"overlappingTokenSupport":true,"multilineTokenSupport":true}` - wantNil = `{"requests":{},"tokenTypes":["namespace","type","class"],"tokenModifiers":["declaration","definition","readonly"],"formats":["relative"]}` - ) - wantType := SemanticTokensClientCapabilities{ - DynamicRegistration: true, - Requests: SemanticTokensWorkspaceClientCapabilitiesRequests{ - Range: true, - Full: true, - }, - TokenTypes: []string{ - string(SemanticTokenNamespace), - string(SemanticTokenType), - string(SemanticTokenClass), - }, - TokenModifiers: []string{ - string(SemanticTokenModifierDeclaration), - string(SemanticTokenModifierDefinition), - string(SemanticTokenModifierReadonly), - }, - Formats: []TokenFormat{ - TokenFormatRelative, - }, - OverlappingTokenSupport: true, - MultilineTokenSupport: true, - } - wantTypeNil := SemanticTokensClientCapabilities{ - Requests: SemanticTokensWorkspaceClientCapabilitiesRequests{}, - TokenTypes: []string{ - string(SemanticTokenNamespace), - string(SemanticTokenType), - string(SemanticTokenClass), - }, - TokenModifiers: []string{ - string(SemanticTokenModifierDeclaration), - string(SemanticTokenModifierDefinition), - string(SemanticTokenModifierReadonly), - }, - Formats: []TokenFormat{ - TokenFormatRelative, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field SemanticTokensClientCapabilities - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want SemanticTokensClientCapabilities - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got SemanticTokensClientCapabilities - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} diff --git a/capabilities_server.go b/capabilities_server.go deleted file mode 100644 index 40ae88a6..00000000 --- a/capabilities_server.go +++ /dev/null @@ -1,523 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "strconv" -) - -// ServerCapabilities efines the capabilities provided by a language server. -type ServerCapabilities struct { - // TextDocumentSync defines how text documents are synced. Is either a detailed structure defining each notification - // or for backwards compatibility the TextDocumentSyncKind number. - // - // If omitted it defaults to TextDocumentSyncKind.None` - TextDocumentSync interface{} `json:"textDocumentSync,omitempty"` // *TextDocumentSyncOptions | TextDocumentSyncKind - - // CompletionProvider is The server provides completion support. - CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"` - - // HoverProvider is the server provides hover support. - HoverProvider interface{} `json:"hoverProvider,omitempty"` // TODO(zchee): bool | *HoverOptions - - // SignatureHelpProvider is the server provides signature help support. - SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` - - // DeclarationProvider is the server provides Goto Declaration support. - // - // @since 3.14.0. - DeclarationProvider interface{} `json:"declarationProvider,omitempty"` // TODO(zchee): bool | *DeclarationOptions | *DeclarationRegistrationOptions - - // DefinitionProvider is the server provides Goto definition support. - DefinitionProvider interface{} `json:"definitionProvider,omitempty"` // TODO(zchee): bool | *DefinitionOptions - - // TypeDefinitionProvider is the provides Goto Type Definition support. - // - // @since 3.6.0. - TypeDefinitionProvider interface{} `json:"typeDefinitionProvider,omitempty"` // TODO(zchee): bool | *TypeDefinitionOptions | *TypeDefinitionRegistrationOptions - - // ImplementationProvider is the provides Goto Implementation support. - // - // @since 3.6.0. - ImplementationProvider interface{} `json:"implementationProvider,omitempty"` // TODO(zchee): bool | *ImplementationOptions | *ImplementationRegistrationOptions - - // ReferencesProvider is the server provides find references support. - ReferencesProvider interface{} `json:"referencesProvider,omitempty"` // TODO(zchee): bool | *ReferenceOptions - - // DocumentHighlightProvider is the server provides document highlight support. - DocumentHighlightProvider interface{} `json:"documentHighlightProvider,omitempty"` // TODO(zchee): bool | *DocumentHighlightOptions - - // DocumentSymbolProvider is the server provides document symbol support. - DocumentSymbolProvider interface{} `json:"documentSymbolProvider,omitempty"` // TODO(zchee): bool | *DocumentSymbolOptions - - // CodeActionProvider is the server provides code actions. - // - // CodeActionOptions may only be specified if the client states that it supports CodeActionLiteralSupport in its - // initial Initialize request. - CodeActionProvider interface{} `json:"codeActionProvider,omitempty"` // TODO(zchee): bool | *CodeActionOptions - - // CodeLensProvider is the server provides code lens. - CodeLensProvider *CodeLensOptions `json:"codeLensProvider,omitempty"` - - // The server provides document link support. - DocumentLinkProvider *DocumentLinkOptions `json:"documentLinkProvider,omitempty"` - - // ColorProvider is the server provides color provider support. - // - // @since 3.6.0. - ColorProvider interface{} `json:"colorProvider,omitempty"` // TODO(zchee): bool | *DocumentColorOptions | *DocumentColorRegistrationOptions - - // WorkspaceSymbolProvider is the server provides workspace symbol support. - WorkspaceSymbolProvider interface{} `json:"workspaceSymbolProvider,omitempty"` // TODO(zchee): bool | *WorkspaceSymbolOptions - - // DocumentFormattingProvider is the server provides document formatting. - DocumentFormattingProvider interface{} `json:"documentFormattingProvider,omitempty"` // TODO(zchee): bool | *DocumentFormattingOptions - - // DocumentRangeFormattingProvider is the server provides document range formatting. - DocumentRangeFormattingProvider interface{} `json:"documentRangeFormattingProvider,omitempty"` // TODO(zchee): bool | *DocumentRangeFormattingOptions - - // DocumentOnTypeFormattingProvider is the server provides document formatting on typing. - DocumentOnTypeFormattingProvider *DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"` - - // RenameProvider is the server provides rename support. - // - // RenameOptions may only be specified if the client states that it supports PrepareSupport in its - // initial Initialize request. - RenameProvider interface{} `json:"renameProvider,omitempty"` // TODO(zchee): bool | *RenameOptions - - // FoldingRangeProvider is the server provides folding provider support. - // - // @since 3.10.0. - FoldingRangeProvider interface{} `json:"foldingRangeProvider,omitempty"` // TODO(zchee): bool | *FoldingRangeOptions | *FoldingRangeRegistrationOptions - - // SelectionRangeProvider is the server provides selection range support. - // - // @since 3.15.0. - SelectionRangeProvider interface{} `json:"selectionRangeProvider,omitempty"` // TODO(zchee): bool | *SelectionRangeOptions | *SelectionRangeRegistrationOptions - - // ExecuteCommandProvider is the server provides execute command support. - ExecuteCommandProvider *ExecuteCommandOptions `json:"executeCommandProvider,omitempty"` - - // CallHierarchyProvider is the server provides call hierarchy support. - // - // @since 3.16.0. - CallHierarchyProvider interface{} `json:"callHierarchyProvider,omitempty"` // TODO(zchee): bool | *CallHierarchyOptions | *CallHierarchyRegistrationOptions - - // LinkedEditingRangeProvider is the server provides linked editing range support. - // - // @since 3.16.0. - LinkedEditingRangeProvider interface{} `json:"linkedEditingRangeProvider,omitempty"` // TODO(zchee): bool | *LinkedEditingRangeOptions | *LinkedEditingRangeRegistrationOptions - - // SemanticTokensProvider is the server provides semantic tokens support. - // - // @since 3.16.0. - SemanticTokensProvider interface{} `json:"semanticTokensProvider,omitempty"` // TODO(zchee): *SemanticTokensOptions | *SemanticTokensRegistrationOptions - - // Workspace is the window specific server capabilities. - Workspace *ServerCapabilitiesWorkspace `json:"workspace,omitempty"` - - // MonikerProvider is the server provides moniker support. - // - // @since 3.16.0. - MonikerProvider interface{} `json:"monikerProvider,omitempty"` // TODO(zchee): bool | *MonikerOptions | *MonikerRegistrationOptions - - // Experimental server capabilities. - Experimental interface{} `json:"experimental,omitempty"` -} - -// TextDocumentSyncOptions TextDocumentSync options. -type TextDocumentSyncOptions struct { - // OpenClose open and close notifications are sent to the server. - OpenClose bool `json:"openClose,omitempty"` - - // Change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full - // and TextDocumentSyncKind.Incremental. If omitted it defaults to TextDocumentSyncKind.None. - Change TextDocumentSyncKind `json:"change,omitempty"` - - // WillSave notifications are sent to the server. - WillSave bool `json:"willSave,omitempty"` - - // WillSaveWaitUntil will save wait until requests are sent to the server. - WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` - - // Save notifications are sent to the server. - Save *SaveOptions `json:"save,omitempty"` -} - -// SaveOptions save options. -type SaveOptions struct { - // IncludeText is the client is supposed to include the content on save. - IncludeText bool `json:"includeText,omitempty"` -} - -// TextDocumentSyncKind defines how the host (editor) should sync document changes to the language server. -type TextDocumentSyncKind float64 - -const ( - // TextDocumentSyncKindNone documents should not be synced at all. - TextDocumentSyncKindNone TextDocumentSyncKind = 0 - - // TextDocumentSyncKindFull documents are synced by always sending the full content - // of the document. - TextDocumentSyncKindFull TextDocumentSyncKind = 1 - - // TextDocumentSyncKindIncremental documents are synced by sending the full content on open. - // After that only incremental updates to the document are - // send. - TextDocumentSyncKindIncremental TextDocumentSyncKind = 2 -) - -// String implements fmt.Stringer. -func (k TextDocumentSyncKind) String() string { - switch k { - case TextDocumentSyncKindNone: - return "None" - case TextDocumentSyncKindFull: - return "Full" - case TextDocumentSyncKindIncremental: - return "Incremental" - default: - return strconv.FormatFloat(float64(k), 'f', -10, 64) - } -} - -// CompletionOptions Completion options. -type CompletionOptions struct { - // The server provides support to resolve additional - // information for a completion item. - ResolveProvider bool `json:"resolveProvider,omitempty"` - - // The characters that trigger completion automatically. - TriggerCharacters []string `json:"triggerCharacters,omitempty"` -} - -// HoverOptions option of hover provider server capabilities. -type HoverOptions struct { - WorkDoneProgressOptions -} - -// SignatureHelpOptions SignatureHelp options. -type SignatureHelpOptions struct { - // The characters that trigger signature help - // automatically. - TriggerCharacters []string `json:"triggerCharacters,omitempty"` - - // RetriggerCharacters is the slist of characters that re-trigger signature help. - // - // These trigger characters are only active when signature help is already - // showing. - // All trigger characters are also counted as re-trigger characters. - // - // @since 3.15.0. - RetriggerCharacters []string `json:"retriggerCharacters,omitempty"` -} - -// DeclarationOptions registration option of Declaration server capability. -// -// @since 3.15.0. -type DeclarationOptions struct { - WorkDoneProgressOptions -} - -// DeclarationRegistrationOptions registration option of Declaration server capability. -// -// @since 3.15.0. -type DeclarationRegistrationOptions struct { - DeclarationOptions - TextDocumentRegistrationOptions - StaticRegistrationOptions -} - -// DefinitionOptions registration option of Definition server capability. -// -// @since 3.15.0. -type DefinitionOptions struct { - WorkDoneProgressOptions -} - -// TypeDefinitionOptions registration option of TypeDefinition server capability. -// -// @since 3.15.0. -type TypeDefinitionOptions struct { - WorkDoneProgressOptions -} - -// TypeDefinitionRegistrationOptions registration option of TypeDefinition server capability. -// -// @since 3.15.0. -type TypeDefinitionRegistrationOptions struct { - TextDocumentRegistrationOptions - TypeDefinitionOptions - StaticRegistrationOptions -} - -// ImplementationOptions registration option of Implementation server capability. -// -// @since 3.15.0. -type ImplementationOptions struct { - WorkDoneProgressOptions -} - -// ImplementationRegistrationOptions registration option of Implementation server capability. -// -// @since 3.15.0. -type ImplementationRegistrationOptions struct { - TextDocumentRegistrationOptions - ImplementationOptions - StaticRegistrationOptions -} - -// ReferenceOptions registration option of Reference server capability. -type ReferenceOptions struct { - WorkDoneProgressOptions -} - -// DocumentHighlightOptions registration option of DocumentHighlight server capability. -// -// @since 3.15.0. -type DocumentHighlightOptions struct { - WorkDoneProgressOptions -} - -// DocumentSymbolOptions registration option of DocumentSymbol server capability. -// -// @since 3.15.0. -type DocumentSymbolOptions struct { - WorkDoneProgressOptions - - // Label a human-readable string that is shown when multiple outlines trees - // are shown for the same document. - // - // @since 3.16.0. - Label string `json:"label,omitempty"` -} - -// CodeActionOptions CodeAction options. -type CodeActionOptions struct { - // CodeActionKinds that this server may return. - // - // The list of kinds may be generic, such as "CodeActionKind.Refactor", or the server - // may list out every specific kind they provide. - CodeActionKinds []CodeActionKind `json:"codeActionKinds,omitempty"` - - // ResolveProvider is the server provides support to resolve additional - // information for a code action. - // - // @since 3.16.0. - ResolveProvider bool `json:"resolveProvider,omitempty"` -} - -// CodeLensOptions CodeLens options. -type CodeLensOptions struct { - // Code lens has a resolve provider as well. - ResolveProvider bool `json:"resolveProvider,omitempty"` -} - -// DocumentLinkOptions document link options. -type DocumentLinkOptions struct { - // ResolveProvider document links have a resolve provider as well. - ResolveProvider bool `json:"resolveProvider,omitempty"` -} - -// DocumentColorOptions registration option of DocumentColor server capability. -// -// @since 3.15.0. -type DocumentColorOptions struct { - WorkDoneProgressOptions -} - -// DocumentColorRegistrationOptions registration option of DocumentColor server capability. -// -// @since 3.15.0. -type DocumentColorRegistrationOptions struct { - TextDocumentRegistrationOptions - StaticRegistrationOptions - DocumentColorOptions -} - -// WorkspaceSymbolOptions registration option of WorkspaceSymbol server capability. -// -// @since 3.15.0. -type WorkspaceSymbolOptions struct { - WorkDoneProgressOptions -} - -// DocumentFormattingOptions registration option of DocumentFormatting server capability. -// -// @since 3.15.0. -type DocumentFormattingOptions struct { - WorkDoneProgressOptions -} - -// DocumentRangeFormattingOptions registration option of DocumentRangeFormatting server capability. -// -// @since 3.15.0. -type DocumentRangeFormattingOptions struct { - WorkDoneProgressOptions -} - -// DocumentOnTypeFormattingOptions format document on type options. -type DocumentOnTypeFormattingOptions struct { - // FirstTriggerCharacter a character on which formatting should be triggered, like "}". - FirstTriggerCharacter string `json:"firstTriggerCharacter"` - - // MoreTriggerCharacter more trigger characters. - MoreTriggerCharacter []string `json:"moreTriggerCharacter,omitempty"` -} - -// RenameOptions rename options. -type RenameOptions struct { - // PrepareProvider renames should be checked and tested before being executed. - PrepareProvider bool `json:"prepareProvider,omitempty"` -} - -// FoldingRangeOptions registration option of FoldingRange server capability. -// -// @since 3.15.0. -type FoldingRangeOptions struct { - WorkDoneProgressOptions -} - -// FoldingRangeRegistrationOptions registration option of FoldingRange server capability. -// -// @since 3.15.0. -type FoldingRangeRegistrationOptions struct { - TextDocumentRegistrationOptions - FoldingRangeOptions - StaticRegistrationOptions -} - -// ExecuteCommandOptions execute command options. -type ExecuteCommandOptions struct { - // Commands is the commands to be executed on the server - Commands []string `json:"commands"` -} - -// CallHierarchyOptions option of CallHierarchy. -// -// @since 3.16.0. -type CallHierarchyOptions struct { - WorkDoneProgressOptions -} - -// CallHierarchyRegistrationOptions registration options of CallHierarchy. -// -// @since 3.16.0. -type CallHierarchyRegistrationOptions struct { - TextDocumentRegistrationOptions - CallHierarchyOptions - StaticRegistrationOptions -} - -// LinkedEditingRangeOptions option of linked editing range provider server capabilities. -// -// @since 3.16.0. -type LinkedEditingRangeOptions struct { - WorkDoneProgressOptions -} - -// LinkedEditingRangeRegistrationOptions registration option of linked editing range provider server capabilities. -// -// @since 3.16.0. -type LinkedEditingRangeRegistrationOptions struct { - TextDocumentRegistrationOptions - LinkedEditingRangeOptions - StaticRegistrationOptions -} - -// SemanticTokensOptions option of semantic tokens provider server capabilities. -// -// @since 3.16.0. -type SemanticTokensOptions struct { - WorkDoneProgressOptions -} - -// SemanticTokensRegistrationOptions registration option of semantic tokens provider server capabilities. -// -// @since 3.16.0. -type SemanticTokensRegistrationOptions struct { - TextDocumentRegistrationOptions - SemanticTokensOptions - StaticRegistrationOptions -} - -// ServerCapabilitiesWorkspace specific server capabilities. -type ServerCapabilitiesWorkspace struct { - // WorkspaceFolders is the server supports workspace folder. - // - // @since 3.6.0. - WorkspaceFolders *ServerCapabilitiesWorkspaceFolders `json:"workspaceFolders,omitempty"` - - // FileOperations is the server is interested in file notifications/requests. - // - // @since 3.16.0. - FileOperations *ServerCapabilitiesWorkspaceFileOperations `json:"fileOperations,omitempty"` -} - -// ServerCapabilitiesWorkspaceFolders is the server supports workspace folder. -// -// @since 3.6.0. -type ServerCapabilitiesWorkspaceFolders struct { - // Supported is the server has support for workspace folders - Supported bool `json:"supported,omitempty"` - - // ChangeNotifications whether the server wants to receive workspace folder - // change notifications. - // - // If a strings is provided the string is treated as a ID - // under which the notification is registered on the client - // side. The ID can be used to unregister for these events - // using the `client/unregisterCapability` request. - ChangeNotifications interface{} `json:"changeNotifications,omitempty"` // string | boolean -} - -// ServerCapabilitiesWorkspaceFileOperations is the server is interested in file notifications/requests. -// -// @since 3.16.0. -type ServerCapabilitiesWorkspaceFileOperations struct { - // DidCreate is the server is interested in receiving didCreateFiles - // notifications. - DidCreate *FileOperationRegistrationOptions `json:"didCreate,omitempty"` - - // WillCreate is the server is interested in receiving willCreateFiles requests. - WillCreate *FileOperationRegistrationOptions `json:"willCreate,omitempty"` - - // DidRename is the server is interested in receiving didRenameFiles - // notifications. - DidRename *FileOperationRegistrationOptions `json:"didRename,omitempty"` - - // WillRename is the server is interested in receiving willRenameFiles requests. - WillRename *FileOperationRegistrationOptions `json:"willRename,omitempty"` - - // DidDelete is the server is interested in receiving didDeleteFiles file - // notifications. - DidDelete *FileOperationRegistrationOptions `json:"didDelete,omitempty"` - - // WillDelete is the server is interested in receiving willDeleteFiles file - // requests. - WillDelete *FileOperationRegistrationOptions `json:"willDelete,omitempty"` -} - -// FileOperationRegistrationOptions is the options to register for file operations. -// -// @since 3.16.0. -type FileOperationRegistrationOptions struct { - // filters is the actual filters. - Filters []FileOperationFilter `json:"filters"` -} - -// MonikerOptions option of moniker provider server capabilities. -// -// @since 3.16.0. -type MonikerOptions struct { - WorkDoneProgressOptions -} - -// MonikerRegistrationOptions registration option of moniker provider server capabilities. -// -// @since 3.16.0. -type MonikerRegistrationOptions struct { - TextDocumentRegistrationOptions - MonikerOptions -} diff --git a/client.go b/client.go index 1f9817bb..605cb62d 100644 --- a/client.go +++ b/client.go @@ -8,11 +8,9 @@ import ( "context" "fmt" - "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" - "go.lsp.dev/pkg/xcontext" ) // ClientDispatcher returns a Client that dispatches LSP requests across the @@ -28,7 +26,7 @@ func ClientDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Client { func ClientHandler(client Client, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := xcontext.Detach(ctx) + xctx := context.WithoutCancel(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -52,12 +50,12 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := json.NewDecoder(bytes.NewReader(req.Params())) + dec := newDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodProgress: // notification - defer logger.Debug(MethodProgress, zap.Error(err)) + case MethodClientProgress: // notification + defer logger.Debug(MethodClientProgress, zap.Error(err)) var params ProgressParams if err := dec.Decode(¶ms); err != nil { @@ -68,27 +66,27 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodWorkDoneProgressCreate: // request - defer logger.Debug(MethodWorkDoneProgressCreate, zap.Error(err)) + case MethodLogTrace: // notification + defer logger.Debug(MethodLogTrace, zap.Error(err)) - var params WorkDoneProgressCreateParams + var params LogTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.WorkDoneProgressCreate(ctx, ¶ms) + err := client.LogTrace(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodWindowLogMessage: // notification - defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) + case MethodTelemetryEvent: // notification + defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) - var params LogMessageParams + var params any if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.LogMessage(ctx, ¶ms) + err := client.TelemetryEvent(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -104,6 +102,18 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) + case MethodWindowLogMessage: // notification + defer logger.Debug(MethodWindowLogMessage, zap.Error(err)) + + var params LogMessageParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + err := client.LogMessage(ctx, ¶ms) + + return true, reply(ctx, nil, err) + case MethodWindowShowMessage: // notification defer logger.Debug(MethodWindowShowMessage, zap.Error(err)) @@ -116,51 +126,63 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodWindowShowMessageRequest: // request - defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) + case MethodClientRegisterCapability: // request + defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) - var params ShowMessageRequestParams + var params RegistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := client.ShowMessageRequest(ctx, ¶ms) + err := client.Registration(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTelemetryEvent: // notification - defer logger.Debug(MethodTelemetryEvent, zap.Error(err)) + case MethodClientUnregisterCapability: // request + defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) - var params interface{} + var params UnregistrationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.Telemetry(ctx, ¶ms) + err := client.Unregistration(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodClientRegisterCapability: // request - defer logger.Debug(MethodClientRegisterCapability, zap.Error(err)) + case MethodWindowShowDocument: // request + defer logger.Debug(MethodWindowShowDocument, zap.Error(err)) - var params RegistrationParams + var params ShowDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.RegisterCapability(ctx, ¶ms) + resp, err := client.ShowDocument(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodClientUnregisterCapability: // request - defer logger.Debug(MethodClientUnregisterCapability, zap.Error(err)) + case MethodWindowShowMessageRequest: // request + defer logger.Debug(MethodWindowShowMessageRequest, zap.Error(err)) - var params UnregistrationParams + var params ShowMessageRequestParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := client.ShowMessageRequest(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWindowWorkDoneProgressCreate: // request + defer logger.Debug(MethodWindowWorkDoneProgressCreate, zap.Error(err)) + + var params WorkDoneProgressCreateParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := client.UnregisterCapability(ctx, ¶ms) + err := client.WorkDoneProgressCreate(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -172,10 +194,17 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := client.ApplyEdit(ctx, ¶ms) + resp, err := client.ApplyWorkspaceEdit(ctx, ¶ms) return true, reply(ctx, resp, err) + case MethodWorkspaceCodeLensRefresh: // request + defer logger.Debug(MethodWorkspaceCodeLensRefresh, zap.Error(err)) + + err := client.CodeLensRefresh(ctx) + + return true, reply(ctx, nil, err) + case MethodWorkspaceConfiguration: // request defer logger.Debug(MethodWorkspaceConfiguration, zap.Error(err)) @@ -188,76 +217,49 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, return true, reply(ctx, resp, err) - case MethodWorkspaceWorkspaceFolders: // request - defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) + case MethodWorkspaceDiagnosticRefresh: // request + defer logger.Debug(MethodWorkspaceDiagnosticRefresh, zap.Error(err)) - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) - } + err := client.DiagnosticRefresh(ctx) - resp, err := client.WorkspaceFolders(ctx) + return true, reply(ctx, nil, err) - return true, reply(ctx, resp, err) + case MethodWorkspaceFoldingRangeRefresh: // request + defer logger.Debug(MethodWorkspaceFoldingRangeRefresh, zap.Error(err)) - default: - return false, nil - } -} - -// Client represents a Language Server Protocol client. -type Client interface { - Progress(ctx context.Context, params *ProgressParams) (err error) - WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) - LogMessage(ctx context.Context, params *LogMessageParams) (err error) - PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) - ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) - ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (result *MessageActionItem, err error) - Telemetry(ctx context.Context, params interface{}) (err error) - RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) - UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) - ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) - Configuration(ctx context.Context, params *ConfigurationParams) (result []interface{}, err error) - WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) -} + err := client.FoldingRangeRefresh(ctx) -// list of client methods. -const ( - // MethodProgress method name of "$/progress". - MethodProgress = "$/progress" + return true, reply(ctx, nil, err) - // MethodWorkDoneProgressCreate method name of "window/workDoneProgress/create". - MethodWorkDoneProgressCreate = "window/workDoneProgress/create" + case MethodWorkspaceInlayHintRefresh: // request + defer logger.Debug(MethodWorkspaceInlayHintRefresh, zap.Error(err)) - // MethodWindowShowMessage method name of "window/showMessage". - MethodWindowShowMessage = "window/showMessage" + err := client.InlayHintRefresh(ctx) - // MethodWindowShowMessageRequest method name of "window/showMessageRequest. - MethodWindowShowMessageRequest = "window/showMessageRequest" + return true, reply(ctx, nil, err) - // MethodWindowLogMessage method name of "window/logMessage. - MethodWindowLogMessage = "window/logMessage" + case MethodWorkspaceSemanticTokensRefresh: // request + defer logger.Debug(MethodWorkspaceSemanticTokensRefresh, zap.Error(err)) - // MethodTelemetryEvent method name of "telemetry/event. - MethodTelemetryEvent = "telemetry/event" + err := client.SemanticTokensRefresh(ctx) - // MethodClientRegisterCapability method name of "client/registerCapability. - MethodClientRegisterCapability = "client/registerCapability" + return true, reply(ctx, nil, err) - // MethodClientUnregisterCapability method name of "client/unregisterCapability. - MethodClientUnregisterCapability = "client/unregisterCapability" + case MethodWorkspaceWorkspaceFolders: // request + defer logger.Debug(MethodWorkspaceWorkspaceFolders, zap.Error(err)) - // MethodTextDocumentPublishDiagnostics method name of "textDocument/publishDiagnostics. - MethodTextDocumentPublishDiagnostics = "textDocument/publishDiagnostics" + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + } - // MethodWorkspaceApplyEdit method name of "workspace/applyEdit. - MethodWorkspaceApplyEdit = "workspace/applyEdit" + resp, err := client.WorkspaceFolders(ctx) - // MethodWorkspaceConfiguration method name of "workspace/configuration. - MethodWorkspaceConfiguration = "workspace/configuration" + return true, reply(ctx, resp, err) - // MethodWorkspaceWorkspaceFolders method name of "workspace/workspaceFolders". - MethodWorkspaceWorkspaceFolders = "workspace/workspaceFolders" -) + default: + return false, nil + } +} // client implements a Language Server Protocol client. type client struct { @@ -269,6 +271,13 @@ type client struct { // compiler time check whether the Client implements ClientInterface interface. var _ Client = (*client)(nil) +func (c *client) Cancel(ctx context.Context, params *CancelParams) (err error) { + c.logger.Debug("notify " + MethodClientCancelRequest) + defer c.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodClientCancelRequest, params) +} + // Progress is the base protocol offers also support to report progress in a generic fashion. // // This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and @@ -276,30 +285,27 @@ var _ Client = (*client)(nil) // // @since 3.16.0. func (c *client) Progress(ctx context.Context, params *ProgressParams) (err error) { - c.logger.Debug("call " + MethodProgress) - defer c.logger.Debug("end "+MethodProgress, zap.Error(err)) - - return c.Conn.Notify(ctx, MethodProgress, params) -} + c.logger.Debug("notify " + MethodClientProgress) + defer c.logger.Debug("end "+MethodClientProgress, zap.Error(err)) -// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. -// -// @since 3.16.0. -func (c *client) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { - c.logger.Debug("call " + MethodWorkDoneProgressCreate) - defer c.logger.Debug("end "+MethodWorkDoneProgressCreate, zap.Error(err)) - - return Call(ctx, c.Conn, MethodWorkDoneProgressCreate, params, nil) + return c.Conn.Notify(ctx, MethodClientProgress, params) } // LogMessage sends the notification from the server to the client to ask the client to log a particular message. func (c *client) LogMessage(ctx context.Context, params *LogMessageParams) (err error) { - c.logger.Debug("call " + MethodWindowLogMessage) + c.logger.Debug("notify " + MethodWindowLogMessage) defer c.logger.Debug("end "+MethodWindowLogMessage, zap.Error(err)) return c.Conn.Notify(ctx, MethodWindowLogMessage, params) } +func (c *client) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { + c.logger.Debug("notify " + MethodLogTrace) + defer c.logger.Debug("end "+MethodLogTrace, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodLogTrace, params) +} + // PublishDiagnostics sends the notification from the server to the client to signal results of validation runs. // // Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary. The following rule is used for VS Code servers that generate diagnostics: @@ -311,7 +317,7 @@ func (c *client) LogMessage(ctx context.Context, params *LogMessageParams) (err // If the computed set is empty it has to push the empty array to clear former diagnostics. // Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side. func (c *client) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) (err error) { - c.logger.Debug("call " + MethodTextDocumentPublishDiagnostics) + c.logger.Debug("notify " + MethodTextDocumentPublishDiagnostics) defer c.logger.Debug("end "+MethodTextDocumentPublishDiagnostics, zap.Error(err)) return c.Conn.Notify(ctx, MethodTextDocumentPublishDiagnostics, params) @@ -320,88 +326,160 @@ func (c *client) PublishDiagnostics(ctx context.Context, params *PublishDiagnost // ShowMessage sends the notification from a server to a client to ask the // client to display a particular message in the user interface. func (c *client) ShowMessage(ctx context.Context, params *ShowMessageParams) (err error) { + c.logger.Debug("notify " + MethodWindowShowMessage) + defer c.logger.Debug("end "+MethodWindowShowMessage, zap.Error(err)) + return c.Conn.Notify(ctx, MethodWindowShowMessage, params) } -// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. +// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. +func (c *client) TelemetryEvent(ctx context.Context, params any) (err error) { + c.logger.Debug("notify " + MethodTelemetryEvent) + defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) + + return c.Conn.Notify(ctx, MethodTelemetryEvent, params) +} + +// ApplyWorkspaceEdit sends the request from the server to the client to modify resource on the client side. +func (c *client) ApplyWorkspaceEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResult, err error) { + c.logger.Debug("call " + MethodWorkspaceApplyEdit) + defer c.logger.Debug("end "+MethodWorkspaceApplyEdit, zap.Error(err)) + + if err := Call(ctx, c.Conn, MethodWorkspaceApplyEdit, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +func (c *client) CodeLensRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceCodeLensRefresh) +} + +// Configuration sends the request from the server to the client to fetch configuration settings from the client. // -// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. -func (c *client) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { - c.logger.Debug("call " + MethodWindowShowMessageRequest) - defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) +// The request can fetch several configuration settings in one roundtrip. +// The order of the returned configuration settings correspond to the order of the +// passed ConfigurationItems (e.g. the first item in the response is the result for the first configuration item in the params). +func (c *client) Configuration(ctx context.Context, params *ConfigurationParams) (_ []any, err error) { + c.logger.Debug("call " + MethodWorkspaceConfiguration) + defer c.logger.Debug("end "+MethodWorkspaceConfiguration, zap.Error(err)) - var result *MessageActionItem - if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { + var result []any + if err := Call(ctx, c.Conn, MethodWorkspaceConfiguration, params, &result); err != nil { return nil, err } return result, nil } -// Telemetry sends the notification from the server to the client to ask the client to log a telemetry event. -func (c *client) Telemetry(ctx context.Context, params interface{}) (err error) { - c.logger.Debug("call " + MethodTelemetryEvent) - defer c.logger.Debug("end "+MethodTelemetryEvent, zap.Error(err)) +func (c *client) DiagnosticRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceDiagnosticRefresh) +} - return c.Conn.Notify(ctx, MethodTelemetryEvent, params) +func (c *client) FoldingRangeRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceFoldingRangeRefresh) +} + +func (c *client) InlayHintRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceInlayHintRefresh) } -// RegisterCapability sends the request from the server to the client to register for a new capability on the client side. +func (c *client) InlineValueRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceInlineValueRefresh) +} + +// Registration sends the request from the server to the client to register for a new capability on the client side. // // Not all clients need to support dynamic capability registration. // // A client opts in via the dynamicRegistration property on the specific client capabilities. // A client can even provide dynamic registration for capability A but not for capability B (see TextDocumentClientCapabilities as an example). -func (c *client) RegisterCapability(ctx context.Context, params *RegistrationParams) (err error) { +func (c *client) Registration(ctx context.Context, params *RegistrationParams) (err error) { c.logger.Debug("call " + MethodClientRegisterCapability) defer c.logger.Debug("end "+MethodClientRegisterCapability, zap.Error(err)) return Call(ctx, c.Conn, MethodClientRegisterCapability, params, nil) } -// UnregisterCapability sends the request from the server to the client to unregister a previously registered capability. -func (c *client) UnregisterCapability(ctx context.Context, params *UnregistrationParams) (err error) { - c.logger.Debug("call " + MethodClientUnregisterCapability) - defer c.logger.Debug("end "+MethodClientUnregisterCapability, zap.Error(err)) - - return Call(ctx, c.Conn, MethodClientUnregisterCapability, params, nil) +func (c *client) SemanticTokensRefresh(ctx context.Context) (err error) { + return c.refresh(ctx, MethodWorkspaceSemanticTokensRefresh) } -// ApplyEdit sends the request from the server to the client to modify resource on the client side. -func (c *client) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (result *ApplyWorkspaceEditResponse, err error) { - c.logger.Debug("call " + MethodWorkspaceApplyEdit) - defer c.logger.Debug("end "+MethodWorkspaceApplyEdit, zap.Error(err)) +// ShowDocument sends the notification from a server to a client to ask the +// client to display a particular message in the user interface. +func (c *client) ShowDocument(ctx context.Context, params *ShowDocumentParams) (_ *ShowDocumentResult, err error) { + c.logger.Debug("call " + MethodWindowShowDocument) + defer c.logger.Debug("end "+MethodWindowShowDocument, zap.Error(err)) - if err := Call(ctx, c.Conn, MethodWorkspaceApplyEdit, params, &result); err != nil { + var result *ShowDocumentResult + if err := Call(ctx, c.Conn, MethodWindowShowDocument, params, &result); err != nil { return nil, err } return result, nil } -// Configuration sends the request from the server to the client to fetch configuration settings from the client. +// ShowMessageRequest sends the request from a server to a client to ask the client to display a particular message in the user interface. // -// The request can fetch several configuration settings in one roundtrip. -// The order of the returned configuration settings correspond to the order of the -// passed ConfigurationItems (e.g. the first item in the response is the result for the first configuration item in the params). -func (c *client) Configuration(ctx context.Context, params *ConfigurationParams) (_ []interface{}, err error) { - c.logger.Debug("call " + MethodWorkspaceConfiguration) - defer c.logger.Debug("end "+MethodWorkspaceConfiguration, zap.Error(err)) +// In addition to the show message notification the request allows to pass actions and to wait for an answer from the client. +func (c *client) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (_ *MessageActionItem, err error) { + c.logger.Debug("call " + MethodWindowShowMessageRequest) + defer c.logger.Debug("end "+MethodWindowShowMessageRequest, zap.Error(err)) - var result []interface{} - if err := Call(ctx, c.Conn, MethodWorkspaceConfiguration, params, &result); err != nil { + var result *MessageActionItem + if err := Call(ctx, c.Conn, MethodWindowShowMessageRequest, params, &result); err != nil { return nil, err } return result, nil } +// TextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +func (c *client) TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) (err error) { + c.logger.Debug("call " + MethodWorkspaceTextDocumentContentRefresh) + defer c.logger.Debug("end "+MethodWorkspaceTextDocumentContentRefresh, zap.Error(err)) + + if err := Call(ctx, c.Conn, MethodWorkspaceTextDocumentContentRefresh, params, nil); err != nil { + return err + } + + return nil +} + +// Unregistration sends the request from the server to the client to unregister a previously registered capability. +func (c *client) Unregistration(ctx context.Context, params *UnregistrationParams) (err error) { + c.logger.Debug("call " + MethodClientUnregisterCapability) + defer c.logger.Debug("end "+MethodClientUnregisterCapability, zap.Error(err)) + + return Call(ctx, c.Conn, MethodClientUnregisterCapability, params, nil) +} + +// WorkDoneProgressCreate sends the request is sent from the server to the client to ask the client to create a work done progress. +// +// @since 3.16.0. +func (c *client) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) (err error) { + c.logger.Debug("call " + MethodWindowWorkDoneProgressCreate) + defer c.logger.Debug("end "+MethodWindowWorkDoneProgressCreate, zap.Error(err)) + + return Call(ctx, c.Conn, MethodWindowWorkDoneProgressCreate, params, nil) +} + +func (c *client) refresh(ctx context.Context, method string) (err error) { + c.logger.Debug("call " + method) + defer c.logger.Debug("end "+method, zap.Error(err)) + + return c.Conn.Notify(ctx, method, nil) +} + // WorkspaceFolders sends the request from the server to the client to fetch the current open list of workspace folders. // // Returns null in the response if only a single file is open in the tool. Returns an empty array if a workspace is open but no folders are configured. // // @since 3.6.0. -func (c *client) WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder, err error) { +func (c *client) WorkspaceFolders(ctx context.Context) (result []*WorkspaceFolder, err error) { c.logger.Debug("call " + MethodWorkspaceWorkspaceFolders) defer c.logger.Debug("end "+MethodWorkspaceWorkspaceFolders, zap.Error(err)) @@ -411,4 +489,3 @@ func (c *client) WorkspaceFolders(ctx context.Context) (result []WorkspaceFolder return result, nil } - diff --git a/client_interface.go b/client_interface.go new file mode 100644 index 00000000..02daa661 --- /dev/null +++ b/client_interface.go @@ -0,0 +1,209 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "context" + + "go.lsp.dev/jsonrpc2" +) + +const ( + MethodClientCancelRequest ClientMethod = "$/cancelRequest" // bidirect client notification + MethodClientProgress ClientMethod = "$/progress" // bidirect client notification + MethodLogTrace ClientMethod = "$/logTrace" // client notification + MethodTelemetryEvent ClientMethod = "telemetry/event" // client notification + MethodTextDocumentPublishDiagnostics ClientMethod = "textDocument/publishDiagnostics" // client notification + MethodWindowLogMessage ClientMethod = "window/logMessage" // client notification + MethodWindowShowMessage ClientMethod = "window/showMessage" // client notification + MethodClientRegisterCapability ClientMethod = "client/registerCapability" // client request + MethodClientUnregisterCapability ClientMethod = "client/unregisterCapability" // client request + MethodWindowShowDocument ClientMethod = "window/showDocument" // client request + MethodWindowShowMessageRequest ClientMethod = "window/showMessageRequest" // client request + MethodWindowWorkDoneProgressCreate ClientMethod = "window/workDoneProgress/create" // client request + MethodWorkspaceApplyEdit ClientMethod = "workspace/applyEdit" // client request + MethodWorkspaceCodeLensRefresh ClientMethod = "workspace/codeLens/refresh" // client request + MethodWorkspaceConfiguration ClientMethod = "workspace/configuration" // client request + MethodWorkspaceDiagnosticRefresh ClientMethod = "workspace/diagnostic/refresh" // client request + MethodWorkspaceFoldingRangeRefresh ClientMethod = "workspace/foldingRange/refresh" // client request + MethodWorkspaceInlayHintRefresh ClientMethod = "workspace/inlayHint/refresh" // client request + MethodWorkspaceInlineValueRefresh ClientMethod = "workspace/inlineValue/refresh" // client request + MethodWorkspaceSemanticTokensRefresh ClientMethod = "workspace/semanticTokens/refresh" // client request + MethodWorkspaceTextDocumentContentRefresh ClientMethod = "workspace/textDocumentContent/refresh" // client request + MethodWorkspaceWorkspaceFolders ClientMethod = "workspace/workspaceFolders" // client request +) + +type Client interface { + Cancel(ctx context.Context, params *CancelParams) error + + Progress(ctx context.Context, params *ProgressParams) error + + LogTrace(ctx context.Context, params *LogTraceParams) error + + // TelemetryEvent the telemetry event notification is sent from the server to the client to ask the client to log telemetry data. + TelemetryEvent(ctx context.Context, params any) error + + // PublishDiagnostics diagnostics notification are sent from the server to the client to signal results of validation runs. + PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error + + // LogMessage the log message notification is sent from the server to the client to ask the client to log a particular message. + LogMessage(ctx context.Context, params *LogMessageParams) error + + // ShowMessage the show message notification is sent from a server to a client to ask the client to display a particular message in the user interface. + ShowMessage(ctx context.Context, params *ShowMessageParams) error + // Registration the `client/registerCapability` request is sent from the server to the client to register a new capability handler on the client side. + Registration(ctx context.Context, params *RegistrationParams) error + + // Unregistration the `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability handler on the client side. + Unregistration(ctx context.Context, params *UnregistrationParams) error + + // ShowDocument a request to show a document. This request might open an external program depending on the value of the URI to open. For example a request to open `https://code.visualstudio.com/` will very likely open the URI in a WEB browser. + // + // @since 3.16.0 + ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) + + // ShowMessageRequest the show message request is sent from the server to the client to show a message and a set of options actions to the user. + ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) + + // WorkDoneProgressCreate the `window/workDoneProgress/create` request is sent from the server to the client to initiate progress reporting from the server. + WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error + + // ApplyWorkspaceEdit a request sent from the server to the client to modified certain resources. + ApplyWorkspaceEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) + + // CodeLensRefresh a request to refresh all code actions + // + // @since 3.16.0 + CodeLensRefresh(ctx context.Context) error + + // Configuration the 'workspace/configuration' request is sent from the server to the client to fetch a certain configuration setting. This pull model replaces the old push model were the client signaled configuration + // change via an event. If the server still needs to react to configuration changes (since the server caches the result of `workspace/configuration` requests) the server should register for an empty configuration change event and empty the cache if such an event is received. + Configuration(ctx context.Context, params *ConfigurationParams) ([]any, error) + + // DiagnosticRefresh the diagnostic refresh request definition. + // + // @since 3.17.0 + DiagnosticRefresh(ctx context.Context) error + + // FoldingRangeRefresh. + // + // @since 3.18.0 proposed + FoldingRangeRefresh(ctx context.Context) error + + // InlayHintRefresh. + // + // @since 3.17.0 + InlayHintRefresh(ctx context.Context) error + + // InlineValueRefresh. + // + // @since 3.17.0 + InlineValueRefresh(ctx context.Context) error + + // SemanticTokensRefresh. + // + // @since 3.16.0 + SemanticTokensRefresh(ctx context.Context) error + + // TextDocumentContentRefresh the `workspace/textDocumentContent` request is sent from the server to the client to refresh the content of a specific text document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error + + // WorkspaceFolders the `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders. + WorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) +} + +// UnimplementedClient should be embedded to have forward compatible implementations. +type UnimplementedClient struct{} + +var _ Client = UnimplementedClient{} + +func (UnimplementedClient) Cancel(ctx context.Context, params *CancelParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) Progress(ctx context.Context, params *ProgressParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) LogTrace(ctx context.Context, params *LogTraceParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) TelemetryEvent(ctx context.Context, params any) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) LogMessage(ctx context.Context, params *LogMessageParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ShowMessage(ctx context.Context, params *ShowMessageParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) Registration(ctx context.Context, params *RegistrationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) Unregistration(ctx context.Context, params *UnregistrationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) ApplyWorkspaceEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) CodeLensRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) Configuration(ctx context.Context, params *ConfigurationParams) ([]any, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedClient) DiagnosticRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) FoldingRangeRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) InlayHintRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) InlineValueRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) SemanticTokensRefresh(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) TextDocumentContentRefresh(ctx context.Context, params *TextDocumentContentRefreshParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedClient) WorkspaceFolders(ctx context.Context) ([]*WorkspaceFolder, error) { + return nil, jsonrpc2.ErrInternal +} diff --git a/deprecated.go b/deprecated.go deleted file mode 100644 index fa4b2160..00000000 --- a/deprecated.go +++ /dev/null @@ -1,264 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -// ClientCapabilitiesShowDocument alias of ShowDocumentClientCapabilities. -// -// Deprecated: Use ShowDocumentClientCapabilities instead. -type ClientCapabilitiesShowDocument = ShowDocumentClientCapabilities - -// ClientCapabilitiesShowMessageRequest alias of ShowMessageRequestClientCapabilities. -// -// Deprecated: Use ShowMessageRequestClientCapabilities instead. -type ClientCapabilitiesShowMessageRequest = ShowMessageRequestClientCapabilities - -// ClientCapabilitiesShowMessageRequestMessageActionItem alias of ShowMessageRequestClientCapabilitiesMessageActionItem. -// -// Deprecated: Use ShowMessageRequestClientCapabilitiesMessageActionItem instead. -type ClientCapabilitiesShowMessageRequestMessageActionItem = ShowMessageRequestClientCapabilitiesMessageActionItem - -// ReferencesParams alias of ReferenceParams. -// -// Deprecated: Use ReferenceParams instead. -type ReferencesParams = ReferenceParams - -// TextDocumentClientCapabilitiesCallHierarchy alias of CallHierarchyClientCapabilities. -// -// Deprecated: Use CallHierarchyClientCapabilities instead. -type TextDocumentClientCapabilitiesCallHierarchy = CallHierarchyClientCapabilities - -// TextDocumentClientCapabilitiesCodeAction alias of CodeActionClientCapabilities. -// -// Deprecated: Use CodeActionClientCapabilities instead. -type TextDocumentClientCapabilitiesCodeAction = CodeActionClientCapabilities - -// TextDocumentClientCapabilitiesCodeActionKind alias of CodeActionClientCapabilitiesKind. -// -// Deprecated: Use CodeActionClientCapabilitiesKind instead. -type TextDocumentClientCapabilitiesCodeActionKind = CodeActionClientCapabilitiesKind - -// TextDocumentClientCapabilitiesCodeActionLiteralSupport alias of CodeActionClientCapabilitiesLiteralSupport. -// -// Deprecated: Use CodeActionClientCapabilitiesLiteralSupport instead. -type TextDocumentClientCapabilitiesCodeActionLiteralSupport = CodeActionClientCapabilitiesLiteralSupport - -// TextDocumentClientCapabilitiesCodeActionResolveSupport alias of CodeActionClientCapabilitiesResolveSupport. -// -// Deprecated: Use CodeActionClientCapabilitiesResolveSupport instead. -type TextDocumentClientCapabilitiesCodeActionResolveSupport = CodeActionClientCapabilitiesResolveSupport - -// TextDocumentClientCapabilitiesCodeLens alias of CodeLensClientCapabilities. -// -// Deprecated: Use CodeLensClientCapabilities instead. -type TextDocumentClientCapabilitiesCodeLens = CodeLensClientCapabilities - -// TextDocumentClientCapabilitiesColorProvider alias of DocumentColorClientCapabilities. -// -// Deprecated: Use DocumentColorClientCapabilities instead. -type TextDocumentClientCapabilitiesColorProvider = DocumentColorClientCapabilities - -// TextDocumentClientCapabilitiesCompletion alias of CompletionTextDocumentClientCapabilities. -// -// Deprecated: Use CompletionTextDocumentClientCapabilities instead. -type TextDocumentClientCapabilitiesCompletion = CompletionTextDocumentClientCapabilities - -// TextDocumentClientCapabilitiesCompletionItem alias of CompletionTextDocumentClientCapabilitiesItem. -// -// Deprecated: Use CompletionTextDocumentClientCapabilitiesItem instead. -type TextDocumentClientCapabilitiesCompletionItem = CompletionTextDocumentClientCapabilitiesItem - -// TextDocumentClientCapabilitiesCompletionItemInsertTextModeSupport alias of CompletionTextDocumentClientCapabilitiesItemInsertTextModeSupport. -// -// Deprecated: Use CompletionTextDocumentClientCapabilitiesItemInsertTextModeSupport instead. -type TextDocumentClientCapabilitiesCompletionItemInsertTextModeSupport = CompletionTextDocumentClientCapabilitiesItemInsertTextModeSupport - -// TextDocumentClientCapabilitiesCompletionItemKind alias of CompletionTextDocumentClientCapabilitiesItemKind. -// -// Deprecated: Use CompletionTextDocumentClientCapabilitiesItemKind instead. -type TextDocumentClientCapabilitiesCompletionItemKind = CompletionTextDocumentClientCapabilitiesItemKind - -// TextDocumentClientCapabilitiesCompletionItemResolveSupport alias of CompletionTextDocumentClientCapabilitiesItemResolveSupport. -// -// Deprecated: Use CompletionTextDocumentClientCapabilitiesItemResolveSupport instead. -type TextDocumentClientCapabilitiesCompletionItemResolveSupport = CompletionTextDocumentClientCapabilitiesItemResolveSupport - -// TextDocumentClientCapabilitiesCompletionItemTagSupport alias of CompletionTextDocumentClientCapabilitiesItemTagSupport. -// -// Deprecated: Use CompletionTextDocumentClientCapabilitiesItemTagSupport instead. -type TextDocumentClientCapabilitiesCompletionItemTagSupport = CompletionTextDocumentClientCapabilitiesItemTagSupport - -// TextDocumentClientCapabilitiesDeclaration alias of DeclarationTextDocumentClientCapabilities. -// -// Deprecated: Use DeclarationTextDocumentClientCapabilities instead. -type TextDocumentClientCapabilitiesDeclaration = DeclarationTextDocumentClientCapabilities - -// TextDocumentClientCapabilitiesDefinition alias of DefinitionTextDocumentClientCapabilities. -// -// Deprecated: Use DefinitionTextDocumentClientCapabilities instead. -type TextDocumentClientCapabilitiesDefinition = DefinitionTextDocumentClientCapabilities - -// TextDocumentClientCapabilitiesDocumentHighlight alias of DocumentHighlightClientCapabilities. -// -// Deprecated: Use DocumentHighlightClientCapabilities instead. -type TextDocumentClientCapabilitiesDocumentHighlight = DocumentHighlightClientCapabilities - -// TextDocumentClientCapabilitiesDocumentLink alias of DocumentLinkClientCapabilities. -// -// Deprecated: Use DocumentLinkClientCapabilities instead. -type TextDocumentClientCapabilitiesDocumentLink = DocumentLinkClientCapabilities - -// TextDocumentClientCapabilitiesDocumentSymbol alias of DocumentSymbolClientCapabilities. -// -// Deprecated: Use DocumentSymbolClientCapabilities instead. -type TextDocumentClientCapabilitiesDocumentSymbol = DocumentSymbolClientCapabilities - -// TextDocumentClientCapabilitiesDocumentSymbolTagSupport alias of DocumentSymbolClientCapabilitiesTagSupport. -// -// Deprecated: Use DocumentSymbolClientCapabilitiesTagSupport instead. -type TextDocumentClientCapabilitiesDocumentSymbolTagSupport = DocumentSymbolClientCapabilitiesTagSupport - -// TextDocumentClientCapabilitiesFoldingRange alias of FoldingRangeClientCapabilities. -// -// Deprecated: Use FoldingRangeClientCapabilities instead. -type TextDocumentClientCapabilitiesFoldingRange = FoldingRangeClientCapabilities - -// TextDocumentClientCapabilitiesFormatting alias of DocumentFormattingClientCapabilities. -// -// Deprecated: Use DocumentFormattingClientCapabilities instead. -type TextDocumentClientCapabilitiesFormatting = DocumentFormattingClientCapabilities - -// TextDocumentClientCapabilitiesHover alias of HoverTextDocumentClientCapabilities. -// -// Deprecated: Use HoverTextDocumentClientCapabilities instead. -type TextDocumentClientCapabilitiesHover = HoverTextDocumentClientCapabilities - -// TextDocumentClientCapabilitiesImplementation alias of ImplementationTextDocumentClientCapabilities. -// -// Deprecated: Use ImplementationTextDocumentClientCapabilities instead. -type TextDocumentClientCapabilitiesImplementation = ImplementationTextDocumentClientCapabilities - -// TextDocumentClientCapabilitiesLinkedEditingRange alias of LinkedEditingRangeClientCapabilities. -// -// Deprecated: Use LinkedEditingRangeClientCapabilities instead. -type TextDocumentClientCapabilitiesLinkedEditingRange = LinkedEditingRangeClientCapabilities - -// TextDocumentClientCapabilitiesMoniker of MonikerClientCapabilities. -// -// Deprecated: Use MonikerClientCapabilities instead. -type TextDocumentClientCapabilitiesMoniker = MonikerClientCapabilities - -// TextDocumentClientCapabilitiesOnTypeFormatting of DocumentOnTypeFormattingClientCapabilities. -// -// Deprecated: Use DocumentOnTypeFormattingClientCapabilities instead. -type TextDocumentClientCapabilitiesOnTypeFormatting = DocumentOnTypeFormattingClientCapabilities - -// TextDocumentClientCapabilitiesPublishDiagnostics of PublishDiagnosticsClientCapabilities. -// -// Deprecated: Use PublishDiagnosticsClientCapabilities instead. -type TextDocumentClientCapabilitiesPublishDiagnostics = PublishDiagnosticsClientCapabilities - -// TextDocumentClientCapabilitiesPublishDiagnosticsTagSupport of PublishDiagnosticsClientCapabilitiesTagSupport. -// -// Deprecated: Use PublishDiagnosticsClientCapabilitiesTagSupport instead. -type TextDocumentClientCapabilitiesPublishDiagnosticsTagSupport = PublishDiagnosticsClientCapabilitiesTagSupport - -// TextDocumentClientCapabilitiesRangeFormatting of DocumentRangeFormattingClientCapabilities. -// -// Deprecated: Use DocumentRangeFormattingClientCapabilities instead. -type TextDocumentClientCapabilitiesRangeFormatting = DocumentRangeFormattingClientCapabilities - -// TextDocumentClientCapabilitiesReferences of ReferencesTextDocumentClientCapabilities. -// -// Deprecated: Use ReferencesTextDocumentClientCapabilities instead. -type TextDocumentClientCapabilitiesReferences = ReferencesTextDocumentClientCapabilities - -// TextDocumentClientCapabilitiesRename of RenameClientCapabilities. -// -// Deprecated: Use RenameClientCapabilities instead. -type TextDocumentClientCapabilitiesRename = RenameClientCapabilities - -// TextDocumentClientCapabilitiesSelectionRange of SelectionRangeClientCapabilities. -// -// Deprecated: Use SelectionRangeClientCapabilities instead. -type TextDocumentClientCapabilitiesSelectionRange = SelectionRangeClientCapabilities - -// TextDocumentClientCapabilitiesSemanticTokens of SemanticTokensClientCapabilities. -// -// Deprecated: Use SemanticTokensClientCapabilities instead. -type TextDocumentClientCapabilitiesSemanticTokens = SemanticTokensClientCapabilities - -// TextDocumentClientCapabilitiesSignatureHelp of SignatureHelpTextDocumentClientCapabilities. -// -// Deprecated: Use SignatureHelpTextDocumentClientCapabilities instead. -type TextDocumentClientCapabilitiesSignatureHelp = SignatureHelpTextDocumentClientCapabilities - -// TextDocumentClientCapabilitiesSynchronization of TextDocumentSyncClientCapabilities. -// -// Deprecated: Use TextDocumentSyncClientCapabilities instead. -type TextDocumentClientCapabilitiesSynchronization = TextDocumentSyncClientCapabilities - -// TextDocumentClientCapabilitiesTypeDefinition of TypeDefinitionTextDocumentClientCapabilities. -// -// Deprecated: Use TypeDefinitionTextDocumentClientCapabilities instead. -type TextDocumentClientCapabilitiesTypeDefinition = TypeDefinitionTextDocumentClientCapabilities - -// Abort alias of FailureHandlingKindAbort. -// -// Deprecated: Use FailureHandlingKindAbort instead. -const Abort = FailureHandlingKindAbort - -// TextOnlyTransactional alias of FailureHandlingKindTextOnlyTransactional. -// -// Deprecated: Use FailureHandlingKindTextOnlyTransactional instead. -const TextOnlyTransactional = FailureHandlingKindTextOnlyTransactional - -// Transactional alias of FailureHandlingKindTransactional. -// -// Deprecated: Use FailureHandlingKindTransactional instead. -const Transactional = FailureHandlingKindTransactional - -// Undo alias of FailureHandlingKindUndo. -// -// Deprecated: Use FailureHandlingKindUndo instead. -const Undo = FailureHandlingKindUndo - -// WorkspaceClientCapabilitiesSymbol alias of WorkspaceSymbolClientCapabilities. -// -// Deprecated: Use WorkspaceSymbolClientCapabilities instead. -type WorkspaceClientCapabilitiesSymbol = WorkspaceSymbolClientCapabilities - -// WorkspaceClientCapabilitiesSymbolKind alias of SymbolKindCapabilities. -// -// Deprecated: Use SymbolKindCapabilities instead. -type WorkspaceClientCapabilitiesSymbolKind = SymbolKindCapabilities - -// WorkspaceClientCapabilitiesCodeLens alias of CodeLensWorkspaceClientCapabilities. -// -// Deprecated: Use CodeLensWorkspaceClientCapabilities instead. -type WorkspaceClientCapabilitiesCodeLens = CodeLensWorkspaceClientCapabilities - -// WorkspaceClientCapabilitiesDidChangeConfiguration alias of DidChangeConfigurationWorkspaceClientCapabilities. -// -// Deprecated: Use DidChangeConfigurationWorkspaceClientCapabilities instead. -type WorkspaceClientCapabilitiesDidChangeConfiguration = DidChangeConfigurationWorkspaceClientCapabilities - -// WorkspaceClientCapabilitiesDidChangeWatchedFiles alias of DidChangeWatchedFilesWorkspaceClientCapabilities. -// -// Deprecated: Use DidChangeWatchedFilesWorkspaceClientCapabilities instead. -type WorkspaceClientCapabilitiesDidChangeWatchedFiles = DidChangeWatchedFilesWorkspaceClientCapabilities - -// WorkspaceClientCapabilitiesExecuteCommand alias of ExecuteCommandClientCapabilities. -// -// Deprecated: Use ExecuteCommandClientCapabilities instead. -type WorkspaceClientCapabilitiesExecuteCommand = ExecuteCommandClientCapabilities - -// WorkspaceClientCapabilitiesSemanticTokens alias of SemanticTokensWorkspaceClientCapabilities. -// -// Deprecated: Use SemanticTokensWorkspaceClientCapabilities instead. -type WorkspaceClientCapabilitiesSemanticTokens = SemanticTokensWorkspaceClientCapabilities - -// WorkspaceClientCapabilitiesSemanticTokensRequests alias of SemanticTokensWorkspaceClientCapabilitiesRequests. -// -// Deprecated: Use SemanticTokensWorkspaceClientCapabilitiesRequests instead. -type WorkspaceClientCapabilitiesSemanticTokensRequests = SemanticTokensWorkspaceClientCapabilitiesRequests diff --git a/diagnostics.go b/diagnostics.go deleted file mode 100644 index 6097f466..00000000 --- a/diagnostics.go +++ /dev/null @@ -1,149 +0,0 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "strconv" -) - -// Diagnostic represents a diagnostic, such as a compiler error or warning. -// -// Diagnostic objects are only valid in the scope of a resource. -type Diagnostic struct { - // Range is the range at which the message applies. - Range Range `json:"range"` - - // Severity is the diagnostic's severity. Can be omitted. If omitted it is up to the - // client to interpret diagnostics as error, warning, info or hint. - Severity DiagnosticSeverity `json:"severity,omitempty"` - - // Code is the diagnostic's code, which might appear in the user interface. - Code interface{} `json:"code,omitempty"` // int32 | string; - - // CodeDescription an optional property to describe the error code. - // - // @since 3.16.0. - CodeDescription *CodeDescription `json:"codeDescription,omitempty"` - - // Source a human-readable string describing the source of this - // diagnostic, e.g. 'typescript' or 'super lint'. - Source string `json:"source,omitempty"` - - // Message is the diagnostic's message. - Message string `json:"message"` - - // Tags is the additional metadata about the diagnostic. - // - // @since 3.15.0. - Tags []DiagnosticTag `json:"tags,omitempty"` - - // RelatedInformation an array of related diagnostic information, e.g. when symbol-names within - // a scope collide all definitions can be marked via this property. - RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"` - - // Data is a data entry field that is preserved between a - // "textDocument/publishDiagnostics" notification and - // "textDocument/codeAction" request. - // - // @since 3.16.0. - Data interface{} `json:"data,omitempty"` -} - -// DiagnosticSeverity indicates the severity of a Diagnostic message. -type DiagnosticSeverity float64 - -const ( - // DiagnosticSeverityError reports an error. - DiagnosticSeverityError DiagnosticSeverity = 1 - - // DiagnosticSeverityWarning reports a warning. - DiagnosticSeverityWarning DiagnosticSeverity = 2 - - // DiagnosticSeverityInformation reports an information. - DiagnosticSeverityInformation DiagnosticSeverity = 3 - - // DiagnosticSeverityHint reports a hint. - DiagnosticSeverityHint DiagnosticSeverity = 4 -) - -// String implements fmt.Stringer. -func (d DiagnosticSeverity) String() string { - switch d { - case DiagnosticSeverityError: - return "Error" - case DiagnosticSeverityWarning: - return "Warning" - case DiagnosticSeverityInformation: - return "Information" - case DiagnosticSeverityHint: - return "Hint" - default: - return strconv.FormatFloat(float64(d), 'f', -10, 64) - } -} - -// CodeDescription is the structure to capture a description for an error code. -// -// @since 3.16.0. -type CodeDescription struct { - // Href an URI to open with more information about the diagnostic error. - Href URI `json:"href"` -} - -// DiagnosticTag is the diagnostic tags. -// -// @since 3.15.0. -type DiagnosticTag float64 - -// list of DiagnosticTag. -const ( - // DiagnosticTagUnnecessary unused or unnecessary code. - // - // Clients are allowed to render diagnostics with this tag faded out instead of having - // an error squiggle. - DiagnosticTagUnnecessary DiagnosticTag = 1 - - // DiagnosticTagDeprecated deprecated or obsolete code. - // - // Clients are allowed to rendered diagnostics with this tag strike through. - DiagnosticTagDeprecated DiagnosticTag = 2 -) - -// String implements fmt.Stringer. -func (d DiagnosticTag) String() string { - switch d { - case DiagnosticTagUnnecessary: - return "Unnecessary" - case DiagnosticTagDeprecated: - return "Deprecated" - default: - return strconv.FormatFloat(float64(d), 'f', -10, 64) - } -} - -// DiagnosticRelatedInformation represents a related message and source code location for a diagnostic. -// -// This should be used to point to code locations that cause or related to a diagnostics, e.g when duplicating -// a symbol in a scope. -type DiagnosticRelatedInformation struct { - // Location is the location of this related diagnostic information. - Location Location `json:"location"` - - // Message is the message of this related diagnostic information. - Message string `json:"message"` -} - -// PublishDiagnosticsParams represents a params of PublishDiagnostics notification. -type PublishDiagnosticsParams struct { - // URI is the URI for which diagnostic information is reported. - URI DocumentURI `json:"uri"` - - // Version optional the version number of the document the diagnostics are published for. - // - // @since 3.15 - Version uint32 `json:"version,omitempty"` - - // Diagnostics an array of diagnostic information items. - Diagnostics []Diagnostic `json:"diagnostics"` -} diff --git a/diagnostics_test.go b/diagnostics_test.go deleted file mode 100644 index 71ef5c2b..00000000 --- a/diagnostics_test.go +++ /dev/null @@ -1,640 +0,0 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/segmentio/encoding/json" - - "go.lsp.dev/uri" -) - -func TestDiagnostic(t *testing.T) { - t.Parallel() - - const ( - want = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"severity":1,"code":"foo/bar","codeDescription":{"href":"file:///path/to/test.go"},"source":"test foo bar","message":"foo bar","tags":[1,2],"relatedInformation":[{"location":{"uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"basic_gen.go"}],"data":"testData"}` - wantNilSeverity = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"code":"foo/bar","codeDescription":{"href":"file:///path/to/test.go"},"source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"basic_gen.go"}],"data":"testData"}` - wantNilCode = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"severity":1,"codeDescription":{"href":"file:///path/to/test.go"},"source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"basic_gen.go"}],"data":"testData"}` - wantNilRelatedInformation = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"severity":1,"code":"foo/bar","codeDescription":{"href":"file:///path/to/test.go"},"source":"test foo bar","message":"foo bar","data":"testData"}` - wantNilAll = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"message":"foo bar"}` - wantInvalid = `{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"severity":1,"code":"foo/bar","codeDescription":{"href":"file:///path/to/test.go"},"source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/basic.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}},"message":"basic_gen.go"}],"data":"invalidData"}` - ) - wantType := Diagnostic{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Severity: DiagnosticSeverityError, - Code: "foo/bar", - CodeDescription: &CodeDescription{ - Href: uri.File("/path/to/test.go"), - }, - Source: "test foo bar", - Message: "foo bar", - Tags: []DiagnosticTag{ - DiagnosticTagUnnecessary, - DiagnosticTagDeprecated, - }, - RelatedInformation: []DiagnosticRelatedInformation{ - { - Location: Location{ - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - Message: "basic_gen.go", - }, - }, - Data: "testData", - } - wantTypeNilSeverity := Diagnostic{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Code: "foo/bar", - CodeDescription: &CodeDescription{ - Href: uri.File("/path/to/test.go"), - }, - Source: "test foo bar", - Message: "foo bar", - RelatedInformation: []DiagnosticRelatedInformation{ - { - Location: Location{ - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - Message: "basic_gen.go", - }, - }, - Data: "testData", - } - wantTypeNilCode := Diagnostic{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Severity: DiagnosticSeverityError, - CodeDescription: &CodeDescription{ - Href: uri.File("/path/to/test.go"), - }, - Source: "test foo bar", - Message: "foo bar", - RelatedInformation: []DiagnosticRelatedInformation{ - { - Location: Location{ - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - Message: "basic_gen.go", - }, - }, - Data: "testData", - } - wantTypeNilRelatedInformation := Diagnostic{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Severity: DiagnosticSeverityError, - Code: "foo/bar", - CodeDescription: &CodeDescription{ - Href: uri.File("/path/to/test.go"), - }, - Source: "test foo bar", - Message: "foo bar", - Data: "testData", - } - wantTypeNilAll := Diagnostic{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Message: "foo bar", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field Diagnostic - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilSeverity", - field: wantTypeNilSeverity, - want: wantNilSeverity, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilCode", - field: wantTypeNilCode, - want: wantNilCode, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilRelatedInformation", - field: wantTypeNilRelatedInformation, - want: wantNilRelatedInformation, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want Diagnostic - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilSeverity", - field: wantNilSeverity, - want: wantTypeNilSeverity, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilCode", - field: wantNilCode, - want: wantTypeNilCode, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilRelatedInformation", - field: wantNilRelatedInformation, - want: wantTypeNilRelatedInformation, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got Diagnostic - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDiagnosticSeverity_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - d DiagnosticSeverity - want string - }{ - { - name: "Error", - d: DiagnosticSeverityError, - want: "Error", - }, - { - name: "Warning", - d: DiagnosticSeverityWarning, - want: "Warning", - }, - { - name: "Information", - d: DiagnosticSeverityInformation, - want: "Information", - }, - { - name: "Hint", - d: DiagnosticSeverityHint, - want: "Hint", - }, - { - name: "Unknown", - d: DiagnosticSeverity(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.d.String(); got != tt.want { - t.Errorf("DiagnosticSeverity.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestDiagnosticTag_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - d DiagnosticTag - want string - }{ - { - name: "Unnecessary", - d: DiagnosticTagUnnecessary, - want: "Unnecessary", - }, - { - name: "Deprecated", - d: DiagnosticTagDeprecated, - want: "Deprecated", - }, - { - name: "Unknown", - d: DiagnosticTag(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.d.String(); got != tt.want { - t.Errorf("DiagnosticSeverity.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestDiagnosticRelatedInformation(t *testing.T) { - t.Parallel() - - const ( - want = `{"location":{"uri":"file:///path/to/basic.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"basic_gen.go"}` - wantInvalid = `{"location":{"uri":"file:///path/to/basic.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}},"message":"basic_gen.go"}` - ) - wantType := DiagnosticRelatedInformation{ - Location: Location{ - URI: uri.File("/path/to/basic.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - Message: "basic_gen.go", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DiagnosticRelatedInformation - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DiagnosticRelatedInformation - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DiagnosticRelatedInformation - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestPublishDiagnosticsParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"uri":"file:///path/to/diagnostics.go","version":1,"diagnostics":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"severity":1,"code":"foo/bar","source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/diagnostics.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"diagnostics.go"}]}]}` - wantInvalid = `{"uri":"file:///path/to/diagnostics_gen.go","version":2,"diagnostics":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"severity":1,"code":"foo/bar","source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/diagnostics_gen.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}},"message":"diagnostics_gen.go"}]}]}` - ) - wantType := PublishDiagnosticsParams{ - URI: DocumentURI("file:///path/to/diagnostics.go"), - Version: 1, - Diagnostics: []Diagnostic{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Severity: DiagnosticSeverityError, - Code: "foo/bar", - Source: "test foo bar", - Message: "foo bar", - RelatedInformation: []DiagnosticRelatedInformation{ - { - Location: Location{ - URI: uri.File("/path/to/diagnostics.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - Message: "diagnostics.go", - }, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field PublishDiagnosticsParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want PublishDiagnosticsParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got PublishDiagnosticsParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} diff --git a/document.go b/document.go new file mode 100644 index 00000000..07a8cdd6 --- /dev/null +++ b/document.go @@ -0,0 +1,470 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "go.lsp.dev/uri" +) + +// TextDocumentSaveReason represents reasons why a text document is saved. +type TextDocumentSaveReason uint32 + +const ( + // ManualTextDocumentSaveReason manually triggered, e.g. by the user pressing save, by starting debugging, or by an API call. + ManualTextDocumentSaveReason TextDocumentSaveReason = 1 + + // AfterDelayTextDocumentSaveReason automatic after a delay. + AfterDelayTextDocumentSaveReason TextDocumentSaveReason = 2 + + // FocusOutTextDocumentSaveReason when the editor lost focus. + FocusOutTextDocumentSaveReason TextDocumentSaveReason = 3 +) + +// NotebookCellKind a notebook cell kind. +// +// @since 3.17.0 +type NotebookCellKind uint32 + +const ( + // MarkupNotebookCellKind a markup-cell is formatted source that is used for display. + MarkupNotebookCellKind NotebookCellKind = 1 + + // CodeNotebookCellKind a code-cell is source code. + CodeNotebookCellKind NotebookCellKind = 2 +) + +type ExecutionSummary struct { + // ExecutionOrder a strict monotonically increasing value indicating the execution order of a cell inside a notebook. + ExecutionOrder uint32 `json:"executionOrder"` + + // Success whether the execution was successful or not if known by the client. + Success bool `json:"success,omitempty"` +} + +// NotebookCell a notebook cell. A cell's document URI must be unique across ALL notebook cells and can therefore be +// used to uniquely identify a notebook cell or the cell's text document. +// +// @since 3.17.0 +type NotebookCell struct { + // Kind the cell's kind. + // + // @since 3.17.0 + Kind NotebookCellKind `json:"kind"` + + // Document the URI of the cell's text document content. + // + // @since 3.17.0 + Document DocumentURI `json:"document"` + + // Metadata additional metadata stored with the cell. Note: should always be an object literal (e.g. LSPObject). + // + // @since 3.17.0 + Metadata map[string]any `json:"metadata,omitempty"` + + // ExecutionSummary additional execution summary information if supported by the client. + // + // @since 3.17.0 + ExecutionSummary *ExecutionSummary `json:"executionSummary,omitempty"` +} + +// NotebookDocument a notebook document. +// +// @since 3.17.0 +type NotebookDocument struct { + // URI the notebook document's uri. + // + // @since 3.17.0 + URI uri.URI `json:"uri"` + + // NotebookType the type of the notebook. + // + // @since 3.17.0 + NotebookType string `json:"notebookType"` + + // Version the version number of this document (it will increase after each change, including undo/redo). + // + // @since 3.17.0 + Version int32 `json:"version"` + + // Metadata additional metadata stored with the notebook document. Note: should always be an object literal (e.g. LSPObject). + // + // @since 3.17.0 + Metadata map[string]any `json:"metadata,omitempty"` + + // Cells the cells of a notebook. + // + // @since 3.17.0 + Cells []NotebookCell `json:"cells"` +} + +// DidOpenNotebookDocumentParams the params sent in an open notebook document notification. +// +// @since 3.17.0 +type DidOpenNotebookDocumentParams struct { + // NotebookDocument the notebook document that got opened. + // + // @since 3.17.0 + NotebookDocument NotebookDocument `json:"notebookDocument"` + + // CellTextDocuments the text documents that represent the content of a notebook cell. + // + // @since 3.17.0 + CellTextDocuments []TextDocumentItem `json:"cellTextDocuments"` +} + +// NotebookCellLanguage. +// +// @since 3.18.0 +type NotebookCellLanguage struct { + // @since 3.18.0 + Language string `json:"language"` +} + +// NotebookDocumentFilterWithCells. +// +// @since 3.18.0 +type NotebookDocumentFilterWithCells struct { + // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. + // + // @since 3.18.0 + Notebook *NotebookDocumentFilterWithCellsNotebook `json:"notebook,omitempty"` + + // Cells the cells of the matching notebook to be synced. + // + // @since 3.18.0 + Cells []NotebookCellLanguage `json:"cells"` +} + +// NotebookDocumentFilterWithNotebook. +// +// @since 3.18.0 +type NotebookDocumentFilterWithNotebook struct { + // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. + // + // @since 3.18.0 + Notebook NotebookDocumentFilterWithNotebookNotebook `json:"notebook"` + + // Cells the cells of the matching notebook to be synced. + // + // @since 3.18.0 + Cells []NotebookCellLanguage `json:"cells,omitempty"` +} + +// NotebookDocumentSyncOptions options specific to a notebook plus its cells to be synced to the server. If a selector provides a notebook document filter but no cell selector all cells of a matching notebook document will be synced. If a selector provides no notebook document filter but only a cell selector all notebook document +// that contain at least one matching cell will be synced. +// +// @since 3.17.0 +type NotebookDocumentSyncOptions struct { + // NotebookSelector the notebooks to be synced. + // + // @since 3.17.0 + NotebookSelector NotebookDocumentSyncOptionsNotebookSelector `json:"notebookSelector"` + + // Save whether save notification should be forwarded to the server. Will only be honored if mode === `notebook`. + // + // @since 3.17.0 + Save bool `json:"save,omitempty"` +} + +// NotebookDocumentSyncRegistrationOptions registration options specific to a notebook. +// +// @since 3.17.0 +type NotebookDocumentSyncRegistrationOptions struct { + // extends + NotebookDocumentSyncOptions + // mixins + StaticRegistrationOptions +} + +// VersionedNotebookDocumentIdentifier a versioned notebook document identifier. +// +// @since 3.17.0 +type VersionedNotebookDocumentIdentifier struct { + // Version the version number of this notebook document. + // + // @since 3.17.0 + Version int32 `json:"version"` + + // URI the notebook document's uri. + // + // @since 3.17.0 + URI uri.URI `json:"uri"` +} + +// NotebookCellArrayChange a change describing how to move a `NotebookCell` array from state S to S'. +// +// @since 3.17.0 +type NotebookCellArrayChange struct { + // Start the start oftest of the cell that changed. + // + // @since 3.17.0 + Start uint32 `json:"start"` + + // DeleteCount the deleted cells. + // + // @since 3.17.0 + DeleteCount uint32 `json:"deleteCount"` + + // Cells the new cells, if any. + // + // @since 3.17.0 + Cells []NotebookCell `json:"cells,omitempty"` +} + +// NotebookDocumentCellChangeStructure structural changes to cells in a notebook document. +// +// @since 3.18.0 +type NotebookDocumentCellChangeStructure struct { + // Array the change to the cell array. + // + // @since 3.18.0 + Array NotebookCellArrayChange `json:"array"` + + // DidOpen additional opened cell text documents. + // + // @since 3.18.0 + DidOpen []TextDocumentItem `json:"didOpen,omitempty"` + + // DidClose additional closed cell text documents. + // + // @since 3.18.0 + DidClose []TextDocumentIdentifier `json:"didClose,omitempty"` +} + +// NotebookDocumentCellContentChanges content changes to a cell in a notebook document. +// +// @since 3.18.0 +type NotebookDocumentCellContentChanges struct { + // @since 3.18.0 + Document VersionedTextDocumentIdentifier `json:"document"` + + // @since 3.18.0 + Changes []TextDocumentContentChangeEvent `json:"changes"` +} + +// NotebookDocumentCellChanges cell changes to a notebook document. +// +// @since 3.18.0 +type NotebookDocumentCellChanges struct { + // Structure changes to the cell structure to add or remove cells. + // + // @since 3.18.0 + Structure *NotebookDocumentCellChangeStructure `json:"structure,omitempty"` + + // Data changes to notebook cells properties like its kind, execution summary or metadata. + // + // @since 3.18.0 + Data []NotebookCell `json:"data,omitempty"` + + // TextContent changes to the text content of notebook cells. + // + // @since 3.18.0 + TextContent []NotebookDocumentCellContentChanges `json:"textContent,omitempty"` +} + +// NotebookDocumentChangeEvent a change event for a notebook document. +// +// @since 3.17.0 +type NotebookDocumentChangeEvent struct { + // Metadata the changed meta data if any. Note: should always be an object literal (e.g. LSPObject). + // + // @since 3.17.0 + Metadata map[string]any `json:"metadata,omitempty"` + + // Cells changes to cells. + // + // @since 3.17.0 + Cells *NotebookDocumentCellChanges `json:"cells,omitempty"` +} + +// DidChangeNotebookDocumentParams the params sent in a change notebook document notification. +// +// @since 3.17.0 +type DidChangeNotebookDocumentParams struct { + // NotebookDocument the notebook document that did change. The version number points to the version after all provided changes have been applied. If only the text document content of a cell changes the notebook version doesn't necessarily have to change. + // + // @since 3.17.0 + NotebookDocument VersionedNotebookDocumentIdentifier `json:"notebookDocument"` + + // Change the actual changes to the notebook document. The changes describe single state changes to the notebook document. So if there are two changes c1 (at array index 0) and c2 (at array index 1) for a notebook in state S then c1 moves the notebook from S to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed on the state S'. To mirror the content of a notebook using change events use the following approach: - start with the same initial content - apply the 'notebookDocument/didChange' notifications in the order you receive them. - apply the `NotebookChangeEvent`s in a single notification in the order you receive them. + // + // @since 3.17.0 + Change NotebookDocumentChangeEvent `json:"change"` +} + +// NotebookDocumentIdentifier a literal to identify a notebook document in the client. +// +// @since 3.17.0 +type NotebookDocumentIdentifier struct { + // URI the notebook document's uri. + // + // @since 3.17.0 + URI uri.URI `json:"uri"` +} + +// DidSaveNotebookDocumentParams the params sent in a save notebook document notification. +// +// @since 3.17.0 +type DidSaveNotebookDocumentParams struct { + // NotebookDocument the notebook document that got saved. + // + // @since 3.17.0 + NotebookDocument NotebookDocumentIdentifier `json:"notebookDocument"` +} + +// DidCloseNotebookDocumentParams the params sent in a close notebook document notification. +// +// @since 3.17.0 +type DidCloseNotebookDocumentParams struct { + // NotebookDocument the notebook document that got closed. + // + // @since 3.17.0 + NotebookDocument NotebookDocumentIdentifier `json:"notebookDocument"` + + // CellTextDocuments the text documents that represent the content of a notebook cell that got closed. + // + // @since 3.17.0 + CellTextDocuments []TextDocumentIdentifier `json:"cellTextDocuments"` +} + +// SaveOptions save options. +type SaveOptions struct { + // IncludeText the client is supposed to include the content on save. + IncludeText bool `json:"includeText,omitempty"` +} + +type TextDocumentSyncOptions struct { + // OpenClose open and close notifications are sent to the server. If omitted open close notification should not be sent. + OpenClose bool `json:"openClose,omitempty"` + + // Change change notifications are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full and TextDocumentSyncKind.Incremental. If omitted it defaults to TextDocumentSyncKind.None. + Change TextDocumentSyncKind `json:"change,omitempty"` + + // WillSave if present will save notifications are sent to the server. If omitted the notification should not be + // sent. + WillSave bool `json:"willSave,omitempty"` + + // WillSaveWaitUntil if present will save wait until requests are sent to the server. If omitted the request should not be sent. + WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` + + // Save if present save notifications are sent to the server. If omitted the notification should not be sent. + Save *TextDocumentSyncOptionsSave `json:"save,omitempty"` +} + +// DidOpenTextDocumentParams the parameters sent in an open text document notification. +type DidOpenTextDocumentParams struct { + // TextDocument the document that was opened. + TextDocument TextDocumentItem `json:"textDocument"` +} + +// DidChangeTextDocumentParams the change text document notification's parameters. +type DidChangeTextDocumentParams struct { + // TextDocument the document that did change. The version number points to the version after all provided content changes have been applied. + TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` + + // ContentChanges the actual content changes. The content changes describe single state changes to the document. So if + // there are two content changes c1 (at array index 0) and c2 (at array index 1) for a document in state S then c1 moves the document from S to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed on the state S'. To mirror the content of a document using change events use the following approach: - start with the same initial content - apply the 'textDocument/didChange' + // notifications in the order you receive them. - apply the `TextDocumentContentChangeEvent`s in a single notification in the order you receive them. + ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` +} + +// TextDocumentChangeRegistrationOptions describe options to be used when registered for text document change events. +type TextDocumentChangeRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + + // SyncKind how documents are synced to the server. + SyncKind TextDocumentSyncKind `json:"syncKind"` +} + +// DidCloseTextDocumentParams the parameters sent in a close text document notification. +type DidCloseTextDocumentParams struct { + // TextDocument the document that was closed. + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// DidSaveTextDocumentParams the parameters sent in a save text document notification. +type DidSaveTextDocumentParams struct { + // TextDocument the document that was saved. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Text optional the content when saved. Depends on the includeText value when the save notification was requested. + Text string `json:"text,omitempty"` +} + +// TextDocumentSaveRegistrationOptions save registration options. +type TextDocumentSaveRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + SaveOptions +} + +// WillSaveTextDocumentParams the parameters sent in a will save text document notification. +type WillSaveTextDocumentParams struct { + // TextDocument the document that will be saved. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Reason the 'TextDocumentSaveReason'. + Reason TextDocumentSaveReason `json:"reason"` +} + +// NotebookDocumentFilterNotebookType a notebook document filter where `notebookType` is required field. +// +// @since 3.18.0 +type NotebookDocumentFilterNotebookType struct { + // NotebookType the type of the enclosing notebook. + // + // @since 3.18.0 + NotebookType string `json:"notebookType"` + + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 + Scheme string `json:"scheme,omitempty"` + + // Pattern a glob pattern. + // + // @since 3.18.0 + Pattern *GlobPattern `json:"pattern,omitempty"` +} + +// NotebookDocumentFilterScheme a notebook document filter where `scheme` is required field. +// +// @since 3.18.0 +type NotebookDocumentFilterScheme struct { + // NotebookType the type of the enclosing notebook. + // + // @since 3.18.0 + NotebookType string `json:"notebookType,omitempty"` + + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 + Scheme string `json:"scheme"` + + // Pattern a glob pattern. + // + // @since 3.18.0 + Pattern *GlobPattern `json:"pattern,omitempty"` +} + +// NotebookDocumentFilterPattern a notebook document filter where `pattern` is required field. +// +// @since 3.18.0 +type NotebookDocumentFilterPattern struct { + // NotebookType the type of the enclosing notebook. + // + // @since 3.18.0 + NotebookType string `json:"notebookType,omitempty"` + + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 + Scheme string `json:"scheme,omitempty"` + + // Pattern a glob pattern. + // + // @since 3.18.0 + Pattern GlobPattern `json:"pattern"` +} diff --git a/general.go b/general.go deleted file mode 100644 index 1693b0cc..00000000 --- a/general.go +++ /dev/null @@ -1,461 +0,0 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -// TraceValue represents a InitializeParams Trace mode. -type TraceValue string - -// list of TraceValue. -const ( - // TraceOff disable tracing. - TraceOff TraceValue = "off" - - // TraceMessage normal tracing mode. - TraceMessage TraceValue = "message" - - // TraceVerbose verbose tracing mode. - TraceVerbose TraceValue = "verbose" -) - -// ClientInfo information about the client. -// -// @since 3.15.0. -type ClientInfo struct { - // Name is the name of the client as defined by the client. - Name string `json:"name"` - - // Version is the client's version as defined by the client. - Version string `json:"version,omitempty"` -} - -// InitializeParams params of Initialize request. -type InitializeParams struct { - WorkDoneProgressParams - - // ProcessID is the process Id of the parent process that started - // the server. Is null if the process has not been started by another process. - // If the parent process is not alive then the server should exit (see exit notification) its process. - ProcessID int32 `json:"processId"` - - // ClientInfo is the information about the client. - // - // @since 3.15.0 - ClientInfo *ClientInfo `json:"clientInfo,omitempty"` - - // Locale is the locale the client is currently showing the user interface - // in. This must not necessarily be the locale of the operating - // system. - // - // Uses IETF language tags as the value's syntax - // (See https://en.wikipedia.org/wiki/IETF_language_tag) - // - // @since 3.16.0. - Locale string `json:"locale,omitempty"` - - // RootPath is the rootPath of the workspace. Is null - // if no folder is open. - // - // Deprecated: Use RootURI instead. - RootPath string `json:"rootPath,omitempty"` - - // RootURI is the rootUri of the workspace. Is null if no - // folder is open. If both `rootPath` and "rootUri" are set - // "rootUri" wins. - // - // Deprecated: Use WorkspaceFolders instead. - RootURI DocumentURI `json:"rootUri,omitempty"` - - // InitializationOptions user provided initialization options. - InitializationOptions interface{} `json:"initializationOptions,omitempty"` - - // Capabilities is the capabilities provided by the client (editor or tool) - Capabilities ClientCapabilities `json:"capabilities"` - - // Trace is the initial trace setting. If omitted trace is disabled ('off'). - Trace TraceValue `json:"trace,omitempty"` - - // WorkspaceFolders is the workspace folders configured in the client when the server starts. - // This property is only available if the client supports workspace folders. - // It can be `null` if the client supports workspace folders but none are - // configured. - // - // @since 3.6.0. - WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders,omitempty"` -} - -// InitializeResult result of ClientCapabilities. -type InitializeResult struct { - // Capabilities is the capabilities the language server provides. - Capabilities ServerCapabilities `json:"capabilities"` - - // ServerInfo Information about the server. - // - // @since 3.15.0. - ServerInfo *ServerInfo `json:"serverInfo,omitempty"` -} - -// LogTraceParams params of LogTrace notification. -// -// @since 3.16.0. -type LogTraceParams struct { - // Message is the message to be logged. - Message string `json:"message"` - - // Verbose is the additional information that can be computed if the "trace" configuration - // is set to "verbose". - Verbose TraceValue `json:"verbose,omitempty"` -} - -// SetTraceParams params of SetTrace notification. -// -// @since 3.16.0. -type SetTraceParams struct { - // Value is the new value that should be assigned to the trace setting. - Value TraceValue `json:"value"` -} - -// FileOperationPatternKind is a pattern kind describing if a glob pattern matches a file a folder or -// both. -// -// @since 3.16.0. -type FileOperationPatternKind string - -// list of FileOperationPatternKind. -const ( - // FileOperationPatternKindFile is the pattern matches a file only. - FileOperationPatternKindFile FileOperationPatternKind = "file" - - // FileOperationPatternKindFolder is the pattern matches a folder only. - FileOperationPatternKindFolder FileOperationPatternKind = "folder" -) - -// FileOperationPatternOptions matching options for the file operation pattern. -// -// @since 3.16.0. -type FileOperationPatternOptions struct { - // IgnoreCase is The pattern should be matched ignoring casing. - IgnoreCase bool `json:"ignoreCase,omitempty"` -} - -// FileOperationPattern a pattern to describe in which file operation requests or notifications -// the server is interested in. -// -// @since 3.16.0. -type FileOperationPattern struct { - // The glob pattern to match. Glob patterns can have the following syntax: - // - `*` to match one or more characters in a path segment - // - `?` to match on one character in a path segment - // - `**` to match any number of path segments, including none - // - `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript - // and JavaScript files) - // - `[]` to declare a range of characters to match in a path segment - // (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - // - `[!...]` to negate a range of characters to match in a path segment - // (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but - // not `example.0`) - Glob string `json:"glob"` - - // Matches whether to match files or folders with this pattern. - // - // Matches both if undefined. - Matches FileOperationPatternKind `json:"matches,omitempty"` - - // Options additional options used during matching. - Options FileOperationPatternOptions `json:"options,omitempty"` -} - -// FileOperationFilter is a filter to describe in which file operation requests or notifications -// the server is interested in. -// -// @since 3.16.0. -type FileOperationFilter struct { - // Scheme is a URI like "file" or "untitled". - Scheme string `json:"scheme,omitempty"` - - // Pattern is the actual file operation pattern. - Pattern FileOperationPattern `json:"pattern"` -} - -// CreateFilesParams is the parameters sent in notifications/requests for user-initiated creation -// of files. -// -// @since 3.16.0. -type CreateFilesParams struct { - // Files an array of all files/folders created in this operation. - Files []FileCreate `json:"files"` -} - -// FileCreate nepresents information on a file/folder create. -// -// @since 3.16.0. -type FileCreate struct { - // URI is a file:// URI for the location of the file/folder being created. - URI string `json:"uri"` -} - -// RenameFilesParams is the parameters sent in notifications/requests for user-initiated renames -// of files. -// -// @since 3.16.0. -type RenameFilesParams struct { - // Files an array of all files/folders renamed in this operation. When a folder - // is renamed, only the folder will be included, and not its children. - Files []FileRename `json:"files"` -} - -// FileRename represents information on a file/folder rename. -// -// @since 3.16.0. -type FileRename struct { - // OldURI is a file:// URI for the original location of the file/folder being renamed. - OldURI string `json:"oldUri"` - - // NewURI is a file:// URI for the new location of the file/folder being renamed. - NewURI string `json:"newUri"` -} - -// DeleteFilesParams is the parameters sent in notifications/requests for user-initiated deletes -// of files. -// -// @since 3.16.0. -type DeleteFilesParams struct { - // Files an array of all files/folders deleted in this operation. - Files []FileDelete `json:"files"` -} - -// FileDelete represents information on a file/folder delete. -// -// @since 3.16.0. -type FileDelete struct { - // URI is a file:// URI for the location of the file/folder being deleted. - URI string `json:"uri"` -} - -// DocumentHighlightParams params of DocumentHighlight request. -// -// @since 3.15.0. -type DocumentHighlightParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} - -// DeclarationParams params of Declaration request. -// -// @since 3.15.0. -type DeclarationParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} - -// DefinitionParams params of Definition request. -// -// @since 3.15.0. -type DefinitionParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} - -// TypeDefinitionParams params of TypeDefinition request. -// -// @since 3.15.0. -type TypeDefinitionParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} - -// ImplementationParams params of Implementation request. -// -// @since 3.15.0. -type ImplementationParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} - -// ShowDocumentParams params to show a document. -// -// @since 3.16.0. -type ShowDocumentParams struct { - // URI is the document uri to show. - URI URI `json:"uri"` - - // External indicates to show the resource in an external program. - // To show for example `https://code.visualstudio.com/` - // in the default WEB browser set `external` to `true`. - External bool `json:"external,omitempty"` - - // TakeFocus an optional property to indicate whether the editor - // showing the document should take focus or not. - // Clients might ignore this property if an external - // program is started. - TakeFocus bool `json:"takeFocus,omitempty"` - - // Selection an optional selection range if the document is a text - // document. Clients might ignore the property if an - // external program is started or the file is not a text - // file. - Selection *Range `json:"selection,omitempty"` -} - -// ShowDocumentResult is the result of an show document request. -// -// @since 3.16.0. -type ShowDocumentResult struct { - // Success a boolean indicating if the show was successful. - Success bool `json:"success"` -} - -// ServerInfo Information about the server. -// -// @since 3.15.0. -type ServerInfo struct { - // Name is the name of the server as defined by the server. - Name string `json:"name"` - - // Version is the server's version as defined by the server. - Version string `json:"version,omitempty"` -} - -// InitializeError known error codes for an "InitializeError". -type InitializeError struct { - // Retry indicates whether the client execute the following retry logic: - // (1) show the message provided by the ResponseError to the user - // (2) user selects retry or cancel - // (3) if user selected retry the initialize method is sent again. - Retry bool `json:"retry,omitempty"` -} - -// ReferencesOptions ReferencesProvider options. -// -// @since 3.15.0. -type ReferencesOptions struct { - WorkDoneProgressOptions -} - -// WorkDoneProgressOptions WorkDoneProgress options. -// -// @since 3.15.0. -type WorkDoneProgressOptions struct { - WorkDoneProgress bool `json:"workDoneProgress,omitempty"` -} - -// LinkedEditingRangeParams params for the LinkedEditingRange request. -// -// @since 3.16.0. -type LinkedEditingRangeParams struct { - TextDocumentPositionParams - WorkDoneProgressParams -} - -// LinkedEditingRanges result of LinkedEditingRange request. -// -// @since 3.16.0. -type LinkedEditingRanges struct { - // Ranges a list of ranges that can be renamed together. - // - // The ranges must have identical length and contain identical text content. - // - // The ranges cannot overlap. - Ranges []Range `json:"ranges"` - - // WordPattern an optional word pattern (regular expression) that describes valid contents for - // the given ranges. - // - // If no pattern is provided, the client configuration's word pattern will be used. - WordPattern string `json:"wordPattern,omitempty"` -} - -// MonikerParams params for the Moniker request. -// -// @since 3.16.0. -type MonikerParams struct { - TextDocumentPositionParams - WorkDoneProgressParams - PartialResultParams -} - -// UniquenessLevel is the Moniker uniqueness level to define scope of the moniker. -// -// @since 3.16.0. -type UniquenessLevel string - -// list of UniquenessLevel. -const ( - // UniquenessLevelDocument is the moniker is only unique inside a document. - UniquenessLevelDocument UniquenessLevel = "document" - - // UniquenessLevelProject is the moniker is unique inside a project for which a dump got created. - UniquenessLevelProject UniquenessLevel = "project" - - // UniquenessLevelGroup is the moniker is unique inside the group to which a project belongs. - UniquenessLevelGroup UniquenessLevel = "group" - - // UniquenessLevelScheme is the moniker is unique inside the moniker scheme. - UniquenessLevelScheme UniquenessLevel = "scheme" - - // UniquenessLevelGlobal is the moniker is globally unique. - UniquenessLevelGlobal UniquenessLevel = "global" -) - -// MonikerKind is the moniker kind. -// -// @since 3.16.0. -type MonikerKind string - -// list of MonikerKind. -const ( - // MonikerKindImport is the moniker represent a symbol that is imported into a project. - MonikerKindImport MonikerKind = "import" - - // MonikerKindExport is the moniker represents a symbol that is exported from a project. - MonikerKindExport MonikerKind = "export" - - // MonikerKindLocal is the moniker represents a symbol that is local to a project (e.g. a local - // variable of a function, a class not visible outside the project, ...). - MonikerKindLocal MonikerKind = "local" -) - -// Moniker definition to match LSIF 0.5 moniker definition. -// -// @since 3.16.0. -type Moniker struct { - // Scheme is the scheme of the moniker. For example tsc or .Net. - Scheme string `json:"scheme"` - - // Identifier is the identifier of the moniker. - // - // The value is opaque in LSIF however schema owners are allowed to define the structure if they want. - Identifier string `json:"identifier"` - - // Unique is the scope in which the moniker is unique. - Unique UniquenessLevel `json:"unique"` - - // Kind is the moniker kind if known. - Kind MonikerKind `json:"kind,omitempty"` -} - -// StaticRegistrationOptions staticRegistration options to be returned in the initialize request. -type StaticRegistrationOptions struct { - // ID is the id used to register the request. The id can be used to deregister - // the request again. See also Registration#id. - ID string `json:"id,omitempty"` -} - -// DocumentLinkRegistrationOptions DocumentLinkRegistration options. -type DocumentLinkRegistrationOptions struct { - TextDocumentRegistrationOptions - - // ResolveProvider document links have a resolve provider as well. - ResolveProvider bool `json:"resolveProvider,omitempty"` -} - -// InitializedParams params of Initialized notification. -type InitializedParams struct{} - -// WorkspaceFolders represents a slice of WorkspaceFolder. -type WorkspaceFolders []WorkspaceFolder diff --git a/general_test.go b/general_test.go deleted file mode 100644 index f62b772b..00000000 --- a/general_test.go +++ /dev/null @@ -1,5205 +0,0 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "path/filepath" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/segmentio/encoding/json" - - "go.lsp.dev/uri" -) - -func TestWorkspaceFolders(t *testing.T) { - t.Parallel() - - const want = `[{"uri":"file:///Users/zchee/go/src/go.lsp.dev/protocol","name":"protocol"},{"uri":"file:///Users/zchee/go/src/go.lsp.dev/jsonrpc2","name":"jsonrpc2"}]` - wantType := WorkspaceFolders{ - { - URI: string(uri.File("/Users/zchee/go/src/go.lsp.dev/protocol")), - Name: "protocol", - }, - { - URI: string(uri.File("/Users/zchee/go/src/go.lsp.dev/jsonrpc2")), - Name: "jsonrpc2", - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field WorkspaceFolders - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want WorkspaceFolders - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkspaceFolders - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestClientInfo(t *testing.T) { - t.Parallel() - - const ( - want = `{"name":"testClient","version":"v0.0.0"}` - wantNilAll = `{"name":"testClient"}` - ) - wantType := ClientInfo{ - Name: "testClient", - Version: "v0.0.0", - } - wantTypeNilAll := ClientInfo{ - Name: "testClient", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ClientInfo - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ClientInfo - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ClientInfo - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestInitializeParams(t *testing.T) { - t.Parallel() - - const wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","processId":25556,"clientInfo":{"name":"testClient","version":"v0.0.0"},"locale":"en-US","rootPath":"~/go/src/go.lsp.dev/protocol","rootUri":"file:///Users/zchee/go/src/go.lsp.dev/protocol","initializationOptions":"testdata","capabilities":{},"trace":"on","workspaceFolders":[{"uri":"file:///Users/zchee/go/src/go.lsp.dev/protocol","name":"protocol"},{"uri":"file:///Users/zchee/go/src/go.lsp.dev/jsonrpc2","name":"jsonrpc2"}]}` - wantNil = `{"processId":25556,"rootUri":"file:///Users/zchee/go/src/go.lsp.dev/protocol","capabilities":{}}` - ) - wantType := InitializeParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - ProcessID: 25556, - ClientInfo: &ClientInfo{ - Name: "testClient", - Version: "v0.0.0", - }, - Locale: "en-US", - RootPath: "~/go/src/go.lsp.dev/protocol", - RootURI: uri.File("/Users/zchee/go/src/go.lsp.dev/protocol"), - InitializationOptions: "testdata", - Capabilities: ClientCapabilities{}, - Trace: "on", - WorkspaceFolders: []WorkspaceFolder{ - { - Name: filepath.Base("/Users/zchee/go/src/go.lsp.dev/protocol"), - URI: string(uri.File("/Users/zchee/go/src/go.lsp.dev/protocol")), - }, - { - Name: filepath.Base("/Users/zchee/go/src/go.lsp.dev/jsonrpc2"), - URI: string(uri.File("/Users/zchee/go/src/go.lsp.dev/jsonrpc2")), - }, - }, - } - wantTypeNilAll := InitializeParams{ - ProcessID: 25556, - RootURI: uri.File("//Users/zchee/go/src/go.lsp.dev/protocol"), - Capabilities: ClientCapabilities{}, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field InitializeParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want InitializeParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got InitializeParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if token := got.WorkDoneToken; token != nil { - if diff := cmp.Diff(token.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestLogTraceParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"message":"testMessage","verbose":"verbose"}` - wantNil = `{"message":"testMessage"}` - ) - wantType := LogTraceParams{ - Message: "testMessage", - Verbose: TraceVerbose, - } - wantTypeNil := LogTraceParams{ - Message: "testMessage", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field LogTraceParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want LogTraceParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got LogTraceParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestSetTraceParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"value":"verbose"}` - wantInvalid = `{"value":"invalid"}` - ) - wantType := SetTraceParams{ - Value: TraceVerbose, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field SetTraceParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want SetTraceParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got SetTraceParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCreateFilesParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"files":[{"uri":"file:///path/to/basic.go"}]}` - wantInvalid = `{"files":[{"uri":"file:///path/to/invalid.go"}]}` - ) - wantType := CreateFilesParams{ - Files: []FileCreate{ - { - URI: "file:///path/to/basic.go", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CreateFilesParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CreateFilesParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CreateFilesParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestRenameFilesParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"files":[{"oldUri":"file:///path/to/old.go","newUri":"file:///path/to/new.go"}]}` - wantInvalid = `{"files":[{"oldUri":"file:///path/to/invalidOld.go","newUri":"file:///path/to/invalidNew.go"}]}` - ) - wantType := RenameFilesParams{ - Files: []FileRename{ - { - OldURI: "file:///path/to/old.go", - NewURI: "file:///path/to/new.go", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field RenameFilesParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want RenameFilesParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got RenameFilesParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDeleteFilesParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"files":[{"uri":"file:///path/to/basic.go"}]}` - wantInvalid = `{"files":[{"uri":"file:///path/to/invalid.go"}]}` - ) - wantType := DeleteFilesParams{ - Files: []FileDelete{ - { - URI: "file:///path/to/basic.go", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DeleteFilesParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DeleteFilesParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DeleteFilesParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestReferencesParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","context":{"includeDeclaration":true}}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"context":{"includeDeclaration":true}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1},"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","context":{"includeDeclaration":false}}` - ) - wantType := ReferenceParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - Context: ReferenceContext{ - IncludeDeclaration: true, - }, - } - wantTypeNilAll := ReferenceParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - Context: ReferenceContext{ - IncludeDeclaration: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ReferenceParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ReferenceParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ReferenceParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestDocumentHighlightOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantNil = `{}` - wantInvalid = `{"workDoneProgress":false}` - ) - wantType := DocumentHighlightOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentHighlightOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentHighlightOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentHighlightOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DocumentHighlightOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentHighlightOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentHighlightParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `"}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1},"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `"}` - ) - wantType := DocumentHighlightParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - } - wantTypeNilAll := DocumentHighlightParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentHighlightParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentHighlightParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentHighlightParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestDocumentSymbolOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true,"label":"testLabel"}` - wantInvalid = `{"workDoneProgress":false}` - wantNil = `{}` - ) - wantType := DocumentSymbolOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - Label: "testLabel", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentSymbolOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentSymbolOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentSymbolOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DocumentSymbolOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentSymbolOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkspaceSymbolOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantInvalid = `{"workDoneProgress":false}` - wantNil = `{}` - ) - wantType := WorkspaceSymbolOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field WorkspaceSymbolOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: WorkspaceSymbolOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want WorkspaceSymbolOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: WorkspaceSymbolOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkspaceSymbolOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentFormattingOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantInvalid = `{"workDoneProgress":false}` - wantNil = `{}` - ) - wantType := DocumentFormattingOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentFormattingOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentFormattingOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentFormattingOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DocumentFormattingOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentFormattingOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentRangeFormattingOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantNil = `{}` - wantInvalid = `{"workDoneProgress":false}` - ) - wantType := DocumentRangeFormattingOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentRangeFormattingOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentRangeFormattingOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentRangeFormattingOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DocumentRangeFormattingOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentRangeFormattingOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDeclarationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantNil = `{}` - wantInvalid = `{"workDoneProgress":false}` - ) - wantType := DeclarationOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DeclarationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DeclarationOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DeclarationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DeclarationOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DeclarationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDeclarationRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true,"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}],"id":"1"}` - wantNil = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}]}` - wantInvalid = `{"workDoneProgress":false,"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"}],"id":"0"}` - ) - wantType := DeclarationRegistrationOptions{ - DeclarationOptions: DeclarationOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - }, - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - StaticRegistrationOptions: StaticRegistrationOptions{ - ID: "1", - }, - } - wantTypeNil := DeclarationRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DeclarationRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DeclarationRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DeclarationRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDeclarationParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `"}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1},"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `"}` - ) - wantType := DeclarationParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - } - wantTypeNilAll := DeclarationParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DeclarationParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DeclarationParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DeclarationParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestDefinitionOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantNil = `{}` - wantInvalid = `{"workDoneProgress":false}` - ) - wantType := DefinitionOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DefinitionOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DefinitionOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DefinitionOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DefinitionOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DefinitionOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDefinitionParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `"}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1},"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `"}` - ) - wantType := DefinitionParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - } - wantTypeNilAll := DefinitionParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DefinitionParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DefinitionParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DefinitionParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestTypeDefinitionOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantNil = `{}` - wantInvalid = `{"workDoneProgress":false}` - ) - wantType := TypeDefinitionOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TypeDefinitionOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: TypeDefinitionOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TypeDefinitionOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: TypeDefinitionOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TypeDefinitionOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTypeDefinitionRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}],"workDoneProgress":true,"id":"1"}` - wantNil = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"}],"workDoneProgress":false,"id":"0"}` - ) - wantType := TypeDefinitionRegistrationOptions{ - TypeDefinitionOptions: TypeDefinitionOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - }, - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - StaticRegistrationOptions: StaticRegistrationOptions{ - ID: "1", - }, - } - wantTypeNil := TypeDefinitionRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TypeDefinitionRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TypeDefinitionRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TypeDefinitionRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTypeDefinitionParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `"}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1},"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `"}` - ) - wantType := TypeDefinitionParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - } - wantTypeNilAll := TypeDefinitionParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TypeDefinitionParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TypeDefinitionParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TypeDefinitionParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestImplementationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantNilAll = `{}` - ) - wantType := ImplementationOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - wantTypeNilAll := ImplementationOptions{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ImplementationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ImplementationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ImplementationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestImplementationRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}],"workDoneProgress":true,"id":"1"}` - wantNilAll = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"}],"workDoneProgress":false,"id":"0"}` - ) - wantType := ImplementationRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - ImplementationOptions: ImplementationOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - }, - StaticRegistrationOptions: StaticRegistrationOptions{ - ID: "1", - }, - } - wantTypeNilAll := ImplementationRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ImplementationRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ImplementationRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ImplementationRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestImplementationParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `"}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1},"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `"}` - ) - wantType := ImplementationParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - } - wantTypeNilAll := ImplementationParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ImplementationParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ImplementationParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ImplementationParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestDocumentColorOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantNil = `{}` - wantInvalid = `{"workDoneProgress":false}` - ) - wantType := DocumentColorOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentColorOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: DocumentColorOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentColorOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: DocumentColorOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentColorOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentColorRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}],"id":"1","workDoneProgress":true}` - wantNil = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"}],"id":"0","workDoneProgress":false}` - ) - wantType := DocumentColorRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - StaticRegistrationOptions: StaticRegistrationOptions{ - ID: "1", - }, - DocumentColorOptions: DocumentColorOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - }, - } - wantTypeNil := DocumentColorRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentColorRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentColorRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentColorRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestPrepareSupportDefaultBehavior_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k PrepareSupportDefaultBehavior - want string - }{ - { - name: "Identifier", - k: PrepareSupportDefaultBehaviorIdentifier, - want: "Identifier", - }, - { - name: "UnknownKind", - k: PrepareSupportDefaultBehavior(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("PrepareSupportDefaultBehavior.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestFoldingRangeOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantNil = `{}` - wantInvalid = `{"workDoneProgress":false}` - ) - wantType := FoldingRangeOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field FoldingRangeOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: FoldingRangeOptions{}, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want FoldingRangeOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: FoldingRangeOptions{}, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got FoldingRangeOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestFoldingRangeRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}],"workDoneProgress":true,"id":"1"}` - wantNil = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"}],"workDoneProgress":false,"id":"0"}` - ) - wantType := FoldingRangeRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - FoldingRangeOptions: FoldingRangeOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - }, - StaticRegistrationOptions: StaticRegistrationOptions{ - ID: "1", - }, - } - wantTypeNil := FoldingRangeRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field FoldingRangeRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want FoldingRangeRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got FoldingRangeRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestInitializeResult(t *testing.T) { - t.Parallel() - - const ( - want = `{"capabilities":{"textDocumentSync":1,"completionProvider":{"resolveProvider":true,"triggerCharacters":["Tab"]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["C-K"],"retriggerCharacters":["."]},"declarationProvider":true,"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":true,"codeLensProvider":{"resolveProvider":true},"documentLinkProvider":{"resolveProvider":true},"colorProvider":true,"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":".","moreTriggerCharacter":["f"]},"renameProvider":true,"foldingRangeProvider":true,"selectionRangeProvider":true,"executeCommandProvider":{"commands":["test","command"]},"callHierarchyProvider":true,"linkedEditingRangeProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"testNotifications"},"fileOperations":{"didCreate":{"filters":[{"scheme":"file","pattern":{"glob":"*","matches":"file","options":{"ignoreCase":true}}}]},"willCreate":{"filters":[{"scheme":"file","pattern":{"glob":"*","matches":"folder","options":{"ignoreCase":true}}}]},"didRename":{"filters":[{"scheme":"file","pattern":{"glob":"*","matches":"file","options":{"ignoreCase":true}}}]},"willRename":{"filters":[{"scheme":"file","pattern":{"glob":"*","matches":"folder","options":{"ignoreCase":true}}}]},"didDelete":{"filters":[{"scheme":"file","pattern":{"glob":"*","matches":"file","options":{"ignoreCase":true}}}]},"willDelete":{"filters":[{"scheme":"file","pattern":{"glob":"*","matches":"folder","options":{"ignoreCase":true}}}]}}},"monikerProvider":true,"experimental":"Awesome Experimentals"},"serverInfo":{"name":"testServer","version":"v0.0.0"}}` - wantNil = `{"capabilities":{}}` - ) - wantType := InitializeResult{ - Capabilities: ServerCapabilities{ - TextDocumentSync: float64(1), - CompletionProvider: &CompletionOptions{ - ResolveProvider: true, - TriggerCharacters: []string{"Tab"}, - }, - HoverProvider: true, - SignatureHelpProvider: &SignatureHelpOptions{ - TriggerCharacters: []string{"C-K"}, - RetriggerCharacters: []string{"."}, - }, - DeclarationProvider: true, - DefinitionProvider: true, - TypeDefinitionProvider: true, - ImplementationProvider: true, - ReferencesProvider: true, - DocumentHighlightProvider: true, - DocumentSymbolProvider: true, - WorkspaceSymbolProvider: true, - CodeActionProvider: true, - CodeLensProvider: &CodeLensOptions{ - ResolveProvider: true, - }, - DocumentFormattingProvider: true, - DocumentRangeFormattingProvider: true, - DocumentOnTypeFormattingProvider: &DocumentOnTypeFormattingOptions{ - FirstTriggerCharacter: ".", - MoreTriggerCharacter: []string{"f"}, - }, - RenameProvider: true, - DocumentLinkProvider: &DocumentLinkOptions{ - ResolveProvider: true, - }, - ColorProvider: true, - FoldingRangeProvider: true, - SelectionRangeProvider: true, - ExecuteCommandProvider: &ExecuteCommandOptions{ - Commands: []string{"test", "command"}, - }, - Workspace: &ServerCapabilitiesWorkspace{ - WorkspaceFolders: &ServerCapabilitiesWorkspaceFolders{ - Supported: true, - ChangeNotifications: "testNotifications", - }, - FileOperations: &ServerCapabilitiesWorkspaceFileOperations{ - DidCreate: &FileOperationRegistrationOptions{ - Filters: []FileOperationFilter{ - { - Scheme: "file", - Pattern: FileOperationPattern{ - Glob: "*", - Matches: FileOperationPatternKindFile, - Options: FileOperationPatternOptions{ - IgnoreCase: true, - }, - }, - }, - }, - }, - WillCreate: &FileOperationRegistrationOptions{ - Filters: []FileOperationFilter{ - { - Scheme: "file", - Pattern: FileOperationPattern{ - Glob: "*", - Matches: FileOperationPatternKindFolder, - Options: FileOperationPatternOptions{ - IgnoreCase: true, - }, - }, - }, - }, - }, - DidRename: &FileOperationRegistrationOptions{ - Filters: []FileOperationFilter{ - { - Scheme: "file", - Pattern: FileOperationPattern{ - Glob: "*", - Matches: FileOperationPatternKindFile, - Options: FileOperationPatternOptions{ - IgnoreCase: true, - }, - }, - }, - }, - }, - WillRename: &FileOperationRegistrationOptions{ - Filters: []FileOperationFilter{ - { - Scheme: "file", - Pattern: FileOperationPattern{ - Glob: "*", - Matches: FileOperationPatternKindFolder, - Options: FileOperationPatternOptions{ - IgnoreCase: true, - }, - }, - }, - }, - }, - DidDelete: &FileOperationRegistrationOptions{ - Filters: []FileOperationFilter{ - { - Scheme: "file", - Pattern: FileOperationPattern{ - Glob: "*", - Matches: FileOperationPatternKindFile, - Options: FileOperationPatternOptions{ - IgnoreCase: true, - }, - }, - }, - }, - }, - WillDelete: &FileOperationRegistrationOptions{ - Filters: []FileOperationFilter{ - { - Scheme: "file", - Pattern: FileOperationPattern{ - Glob: "*", - Matches: FileOperationPatternKindFolder, - Options: FileOperationPatternOptions{ - IgnoreCase: true, - }, - }, - }, - }, - }, - }, - }, - LinkedEditingRangeProvider: true, - CallHierarchyProvider: true, - SemanticTokensProvider: nil, - MonikerProvider: true, - Experimental: "Awesome Experimentals", - }, - ServerInfo: &ServerInfo{ - Name: "testServer", - Version: "v0.0.0", - }, - } - wantTypeNil := InitializeResult{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field InitializeResult - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Logf("got: %s", string(got)) - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want InitializeResult - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got InitializeResult - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - // cmpOpts := cmpopts.IgnoreFields(ServerCapabilities{}, "SelectionRangeProvider") // ignore SelectionRangeProvider field but assert below - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - // if srp := got.Capabilities.SelectionRangeProvider; srp != nil { - // switch srp := srp.(type) { - // case bool: // EnableSelectionRange - // if diff := cmp.Diff(EnableSelectionRange(srp), enableSelectionRange); (diff != "") != tt.wantErr { - // t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - // } - // default: - // t.Fatalf("srp type is %[1]T, not bool: %#[1]v\n", srp) - // } - // } - }) - } - }) -} - -func TestInitializeError(t *testing.T) { - t.Parallel() - - const want = `{"retry":true}` - wantType := InitializeError{ - Retry: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field InitializeError - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want InitializeError - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got InitializeError - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestShowDocumentParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"uri":"file:///path/to/basic.go","external":true,"takeFocus":true,"selection":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}}}` - wantNil = `{"uri":"file:///path/to/basic.go"}` - ) - wantType := ShowDocumentParams{ - URI: uri.File("/path/to/basic.go"), - External: true, - TakeFocus: true, - Selection: &Range{ - Start: Position{ - Line: 255, - Character: 4, - }, - End: Position{ - Line: 255, - Character: 10, - }, - }, - } - wantTypeNilAll := ShowDocumentParams{ - URI: uri.File("/path/to/basic.go"), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ShowDocumentParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ShowDocumentParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ShowDocumentParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestShowDocumentResult(t *testing.T) { - t.Parallel() - - const want = `{"success":true}` - wantType := ShowDocumentResult{ - Success: true, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ShowDocumentResult - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ShowDocumentResult - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ShowDocumentResult - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentSyncKind_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k TextDocumentSyncKind - want string - }{ - { - name: "NoneKind", - k: TextDocumentSyncKindNone, - want: "None", - }, - { - name: "FullKind", - k: TextDocumentSyncKindFull, - want: "Full", - }, - { - name: "IncrementalKind", - k: TextDocumentSyncKindIncremental, - want: "Incremental", - }, - { - name: "UnknownKind", - k: TextDocumentSyncKind(99), - want: "99", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("TextDocumentSyncKind.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestReferencesOptions(t *testing.T) { - t.Parallel() - - const want = `{"workDoneProgress":true}` - wantType := ReferencesOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ReferencesOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ReferencesOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ReferencesOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCodeActionOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"codeActionKinds":["quickfix","refactor"],"resolveProvider":true}` - wantNil = `{}` - ) - wantType := CodeActionOptions{ - CodeActionKinds: []CodeActionKind{ - QuickFix, - Refactor, - }, - ResolveProvider: true, - } - wantTypeNil := CodeActionOptions{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field CodeActionOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want CodeActionOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeActionOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestRenameOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"prepareProvider":true}` - wantNil = `{}` - ) - wantType := RenameOptions{ - PrepareProvider: true, - } - wantTypeNil := RenameOptions{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field RenameOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want RenameOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got RenameOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestSaveOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"includeText":true}` - wantNil = `{}` - ) - wantType := SaveOptions{ - IncludeText: true, - } - wantTypeNil := SaveOptions{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field SaveOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want SaveOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got SaveOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentSyncOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"openClose":true,"change":1,"willSave":true,"willSaveWaitUntil":true,"save":{"includeText":true}}` - wantNil = `{}` - ) - wantType := TextDocumentSyncOptions{ - OpenClose: true, - Change: TextDocumentSyncKindFull, - WillSave: true, - WillSaveWaitUntil: true, - Save: &SaveOptions{ - IncludeText: true, - }, - } - wantTypeNil := TextDocumentSyncOptions{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field TextDocumentSyncOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want TextDocumentSyncOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentSyncOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestHoverOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"workDoneProgress":true}` - wantNil = `{}` - ) - wantType := HoverOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: true, - }, - } - wantTypeNil := HoverOptions{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field HoverOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want HoverOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got HoverOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestStaticRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"id":"testID"}` - wantNil = `{}` - ) - wantType := StaticRegistrationOptions{ - ID: "testID", - } - wantTypeNil := StaticRegistrationOptions{} - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field StaticRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want StaticRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got StaticRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentLinkRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*"}],"resolveProvider":true}` - wantNil = `{"documentSelector":[]}` - ) - wantType := DocumentLinkRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: `*`, - }, - }, - }, - ResolveProvider: true, - } - wantTypeNilAll := DocumentLinkRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{}, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field DocumentLinkRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want DocumentLinkRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentLinkRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestInitializedParams(t *testing.T) { - t.Parallel() - - const want = `{}` - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field InitializedParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: InitializedParams{}, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want InitializedParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: InitializedParams{}, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got InitializedParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} diff --git a/go.mod b/go.mod index 68663a43..87901a24 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/google/go-cmp v0.6.0 github.com/segmentio/encoding v0.4.0 go.lsp.dev/jsonrpc2 v0.10.0 - go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 go.lsp.dev/uri v0.3.0 go.uber.org/zap v1.27.0 ) diff --git a/go.sum b/go.sum index b092fc5d..4241d3ae 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,6 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= go.lsp.dev/jsonrpc2 v0.10.0 h1:Pr/YcXJoEOTMc/b6OTmcR1DPJ3mSWl/SWiU1Cct6VmI= go.lsp.dev/jsonrpc2 v0.10.0/go.mod h1:fmEzIdXPi/rf6d4uFcayi8HpFP1nBF99ERP1htC72Ac= -go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 h1:hCzQgh6UcwbKgNSRurYWSqh8MufqRRPODRBblutn4TE= -go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2/go.mod h1:gtSHRuYfbCT0qnbLnovpie/WEmqyJ7T4n6VXiFMBtcw= go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo= go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= diff --git a/handler.go b/handler.go index a871f1c3..df4dea48 100644 --- a/handler.go +++ b/handler.go @@ -7,10 +7,7 @@ import ( "context" "fmt" - "github.com/segmentio/encoding/json" - "go.lsp.dev/jsonrpc2" - "go.lsp.dev/pkg/xcontext" ) // CancelHandler handler of cancelling. @@ -18,7 +15,7 @@ func CancelHandler(handler jsonrpc2.Handler) jsonrpc2.Handler { handler, canceller := jsonrpc2.CancelHandler(handler) h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { - if req.Method() != MethodCancelRequest { + if req.Method() != "$/cancelRequest" { // TODO(iancottrell): See if we can generate a reply for the request to be cancelled // at the point of cancellation rather than waiting for gopls to naturally reply. // To do that, we need to keep track of whether a reply has been sent already and @@ -30,7 +27,7 @@ func CancelHandler(handler jsonrpc2.Handler) jsonrpc2.Handler { if ctx.Err() != nil && err == nil { err = ErrRequestCancelled } - ctx = xcontext.Detach(ctx) + ctx = context.WithoutCancel(ctx) return reply(ctx, resp, err) } @@ -39,11 +36,11 @@ func CancelHandler(handler jsonrpc2.Handler) jsonrpc2.Handler { } var params CancelParams - if err := json.Unmarshal(req.Params(), ¶ms); err != nil { + if err := unmarshal(req.Params(), ¶ms); err != nil { return replyParseError(ctx, reply, err) } - switch id := params.ID.(type) { + switch id := params.ID.value.(type) { case int32: canceller(jsonrpc2.NewNumberID(id)) case string: @@ -69,18 +66,18 @@ func Handlers(handler jsonrpc2.Handler) jsonrpc2.Handler { // Call calls method to params and result. func Call(ctx context.Context, conn jsonrpc2.Conn, method string, params, result interface{}) error { - id, err := conn.Call(ctx, method, params, result) + _, err := conn.Call(ctx, method, params, result) if ctx.Err() != nil { - notifyCancel(ctx, conn, id) } return err } func notifyCancel(ctx context.Context, conn jsonrpc2.Conn, id jsonrpc2.ID) { - ctx = xcontext.Detach(ctx) + ctx = context.WithoutCancel(ctx) // Note that only *jsonrpc2.ID implements json.Marshaler. - conn.Notify(ctx, MethodCancelRequest, &CancelParams{ID: &id}) + cid := NewCancelParamsID(fmt.Sprint(id)) + conn.Notify(ctx, "$/cancelRequest", &CancelParams{ID: cid}) } func replyParseError(ctx context.Context, reply jsonrpc2.Replier, err error) error { diff --git a/language.go b/language.go index 0184c49b..eb59f58a 100644 --- a/language.go +++ b/language.go @@ -1,1318 +1,2789 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// Copyright 2024 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol import ( - "strconv" + "go.lsp.dev/uri" ) -// CompletionParams params of Completion request. -type CompletionParams struct { +// SemanticTokenTypes a set of predefined token types. This set is not fixed an clients can specify additional token types +// via the corresponding client capabilities. +// +// @since 3.16.0 +type SemanticTokenTypes string + +const ( + NamespaceSemanticTokenTypes SemanticTokenTypes = "namespace" + + // TypeSemanticTokenTypes represents a generic type. Acts as a fallback for types which can't be mapped to a specific type like class or enum. + TypeSemanticTokenTypes SemanticTokenTypes = "type" + + ClassSemanticTokenTypes SemanticTokenTypes = "class" + + EnumSemanticTokenTypes SemanticTokenTypes = "enum" + + InterfaceSemanticTokenTypes SemanticTokenTypes = "interface" + + StructSemanticTokenTypes SemanticTokenTypes = "struct" + + TypeParameterSemanticTokenTypes SemanticTokenTypes = "typeParameter" + + ParameterSemanticTokenTypes SemanticTokenTypes = "parameter" + + VariableSemanticTokenTypes SemanticTokenTypes = "variable" + + PropertySemanticTokenTypes SemanticTokenTypes = "property" + + EnumMemberSemanticTokenTypes SemanticTokenTypes = "enumMember" + + EventSemanticTokenTypes SemanticTokenTypes = "event" + + FunctionSemanticTokenTypes SemanticTokenTypes = "function" + + MethodSemanticTokenTypes SemanticTokenTypes = "method" + + MacroSemanticTokenTypes SemanticTokenTypes = "macro" + + KeywordSemanticTokenTypes SemanticTokenTypes = "keyword" + + ModifierSemanticTokenTypes SemanticTokenTypes = "modifier" + + CommentSemanticTokenTypes SemanticTokenTypes = "comment" + + StringSemanticTokenTypes SemanticTokenTypes = "string" + + NumberSemanticTokenTypes SemanticTokenTypes = "number" + + RegexpSemanticTokenTypes SemanticTokenTypes = "regexp" + + OperatorSemanticTokenTypes SemanticTokenTypes = "operator" + + // DecoratorSemanticTokenTypes. + // + // @since 3.17.0 + DecoratorSemanticTokenTypes SemanticTokenTypes = "decorator" + + // LabelSemanticTokenTypes. + // + // @since 3.18.0 + LabelSemanticTokenTypes SemanticTokenTypes = "label" +) + +// SemanticTokenModifiers a set of predefined token modifiers. This set is not fixed an clients can specify additional token types via the corresponding client capabilities. +// +// @since 3.16.0 +type SemanticTokenModifiers string + +const ( + DeclarationSemanticTokenModifiers SemanticTokenModifiers = "declaration" + + DefinitionSemanticTokenModifiers SemanticTokenModifiers = "definition" + + ReadonlySemanticTokenModifiers SemanticTokenModifiers = "readonly" + + StaticSemanticTokenModifiers SemanticTokenModifiers = "static" + + DeprecatedSemanticTokenModifiers SemanticTokenModifiers = "deprecated" + + AbstractSemanticTokenModifiers SemanticTokenModifiers = "abstract" + + AsyncSemanticTokenModifiers SemanticTokenModifiers = "async" + + ModificationSemanticTokenModifiers SemanticTokenModifiers = "modification" + + DocumentationSemanticTokenModifiers SemanticTokenModifiers = "documentation" + + DefaultLibrarySemanticTokenModifiers SemanticTokenModifiers = "defaultLibrary" +) + +// DocumentDiagnosticReportKind the document diagnostic report kinds. +// +// @since 3.17.0 +type DocumentDiagnosticReportKind string + +const ( + // FullDocumentDiagnosticReportKind a diagnostic report with a full set of problems. + FullDocumentDiagnosticReportKind DocumentDiagnosticReportKind = "full" + + // UnchangedDocumentDiagnosticReportKind a report indicating that the last returned report is still accurate. + UnchangedDocumentDiagnosticReportKind DocumentDiagnosticReportKind = "unchanged" +) + +// FoldingRangeKind a set of predefined range kinds. +type FoldingRangeKind string + +const ( + // CommentFoldingRangeKind folding range for a comment. + CommentFoldingRangeKind FoldingRangeKind = "comment" + + // ImportsFoldingRangeKind folding range for an import or include. + ImportsFoldingRangeKind FoldingRangeKind = "imports" + + // RegionFoldingRangeKind folding range for a region (e.g. `#region`). + RegionFoldingRangeKind FoldingRangeKind = "region" +) + +// SymbolKind a symbol kind. +type SymbolKind uint32 + +const ( + FileSymbolKind SymbolKind = 1 + + ModuleSymbolKind SymbolKind = 2 + + NamespaceSymbolKind SymbolKind = 3 + + PackageSymbolKind SymbolKind = 4 + + ClassSymbolKind SymbolKind = 5 + + MethodSymbolKind SymbolKind = 6 + + PropertySymbolKind SymbolKind = 7 + + FieldSymbolKind SymbolKind = 8 + + ConstructorSymbolKind SymbolKind = 9 + + EnumSymbolKind SymbolKind = 10 + + InterfaceSymbolKind SymbolKind = 11 + + FunctionSymbolKind SymbolKind = 12 + + VariableSymbolKind SymbolKind = 13 + + ConstantSymbolKind SymbolKind = 14 + + StringSymbolKind SymbolKind = 15 + + NumberSymbolKind SymbolKind = 16 + + BooleanSymbolKind SymbolKind = 17 + + ArraySymbolKind SymbolKind = 18 + + ObjectSymbolKind SymbolKind = 19 + + KeySymbolKind SymbolKind = 20 + + NullSymbolKind SymbolKind = 21 + + EnumMemberSymbolKind SymbolKind = 22 + + StructSymbolKind SymbolKind = 23 + + EventSymbolKind SymbolKind = 24 + + OperatorSymbolKind SymbolKind = 25 + + TypeParameterSymbolKind SymbolKind = 26 +) + +// SymbolTag symbol tags are extra annotations that tweak the rendering of a symbol. +// +// @since 3.16 +type SymbolTag uint32 + +const ( + // DeprecatedSymbolTag render a symbol as obsolete, usually using a strike-out. + DeprecatedSymbolTag SymbolTag = 1 +) + +// UniquenessLevel moniker uniqueness level to define scope of the moniker. +// +// @since 3.16.0 +type UniquenessLevel string + +const ( + // DocumentUniquenessLevel the moniker is only unique inside a document. + DocumentUniquenessLevel UniquenessLevel = "document" + + // ProjectUniquenessLevel the moniker is unique inside a project for which a dump got created. + ProjectUniquenessLevel UniquenessLevel = "project" + + // GroupUniquenessLevel the moniker is unique inside the group to which a project belongs. + GroupUniquenessLevel UniquenessLevel = "group" + + // SchemeUniquenessLevel the moniker is unique inside the moniker scheme. + SchemeUniquenessLevel UniquenessLevel = "scheme" + + // GlobalUniquenessLevel the moniker is globally unique. + GlobalUniquenessLevel UniquenessLevel = "global" +) + +// MonikerKind the moniker kind. +// +// @since 3.16.0 +type MonikerKind string + +const ( + // ImportMonikerKind the moniker represent a symbol that is imported into a project. + ImportMonikerKind MonikerKind = "import" + + // ExportMonikerKind the moniker represents a symbol that is exported from a project. + ExportMonikerKind MonikerKind = "export" + + // LocalMonikerKind the moniker represents a symbol that is local to a project (e.g. a local variable of a function, a class not visible outside the project, ...). + LocalMonikerKind MonikerKind = "local" +) + +// InlayHintKind inlay hint kinds. +// +// @since 3.17.0 +type InlayHintKind uint32 + +const ( + // TypeInlayHintKind an inlay hint that for a type annotation. + TypeInlayHintKind InlayHintKind = 1 + + // ParameterInlayHintKind an inlay hint that is for a parameter. + ParameterInlayHintKind InlayHintKind = 2 +) + +// CompletionItemKind the kind of a completion entry. +type CompletionItemKind uint32 + +const ( + TextCompletionItemKind CompletionItemKind = 1 + + MethodCompletionItemKind CompletionItemKind = 2 + + FunctionCompletionItemKind CompletionItemKind = 3 + + ConstructorCompletionItemKind CompletionItemKind = 4 + + FieldCompletionItemKind CompletionItemKind = 5 + + VariableCompletionItemKind CompletionItemKind = 6 + + ClassCompletionItemKind CompletionItemKind = 7 + + InterfaceCompletionItemKind CompletionItemKind = 8 + + ModuleCompletionItemKind CompletionItemKind = 9 + + PropertyCompletionItemKind CompletionItemKind = 10 + + UnitCompletionItemKind CompletionItemKind = 11 + + ValueCompletionItemKind CompletionItemKind = 12 + + EnumCompletionItemKind CompletionItemKind = 13 + + KeywordCompletionItemKind CompletionItemKind = 14 + + SnippetCompletionItemKind CompletionItemKind = 15 + + ColorCompletionItemKind CompletionItemKind = 16 + + FileCompletionItemKind CompletionItemKind = 17 + + ReferenceCompletionItemKind CompletionItemKind = 18 + + FolderCompletionItemKind CompletionItemKind = 19 + + EnumMemberCompletionItemKind CompletionItemKind = 20 + + ConstantCompletionItemKind CompletionItemKind = 21 + + StructCompletionItemKind CompletionItemKind = 22 + + EventCompletionItemKind CompletionItemKind = 23 + + OperatorCompletionItemKind CompletionItemKind = 24 + + TypeParameterCompletionItemKind CompletionItemKind = 25 +) + +// CompletionItemTag completion item tags are extra annotations that tweak the rendering of a completion item. +// +// @since 3.15.0 +type CompletionItemTag uint32 + +const ( + // DeprecatedCompletionItemTag render a completion as obsolete, usually using a strike-out. + DeprecatedCompletionItemTag CompletionItemTag = 1 +) + +// InsertTextFormat defines whether the insert text in a completion item should be interpreted as plain text or a snippet. +type InsertTextFormat uint32 + +const ( + // PlainTextInsertTextFormat the primary text to be inserted is treated as a plain string. + PlainTextInsertTextFormat InsertTextFormat = 1 + + // SnippetInsertTextFormat the primary text to be inserted is treated as a snippet. A snippet can define tab stops and placeholders with `$1`, `$2` and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Placeholders with equal identifiers are linked, that is typing in one will update others too. See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax. + SnippetInsertTextFormat InsertTextFormat = 2 +) + +// InsertTextMode how whitespace and indentation is handled during completion item insertion. +// +// @since 3.16.0 +type InsertTextMode uint32 + +const ( + // AsIsInsertTextMode the insertion or replace strings is taken as it is. If the value is multi line the lines below the cursor will be inserted using the indentation defined in the string value. The client will not apply any kind of adjustments to the string. + AsIsInsertTextMode InsertTextMode = 1 + + // AdjustIndentationInsertTextMode the editor adjusts leading whitespace of new lines so that they match the indentation up to the cursor of the line for which the item is accepted. Consider a line like this: <2tabs><3tabs>foo. + // Accepting a multi line completion item is indented using 2 tabs and all following lines inserted will be indented using 2 tabs as well. + AdjustIndentationInsertTextMode InsertTextMode = 2 +) + +// DocumentHighlightKind a document highlight kind. +type DocumentHighlightKind uint32 + +const ( + // TextDocumentHighlightKind a textual occurrence. + TextDocumentHighlightKind DocumentHighlightKind = 1 + + // ReadDocumentHighlightKind read-access of a symbol, like reading a variable. + ReadDocumentHighlightKind DocumentHighlightKind = 2 + + // WriteDocumentHighlightKind write-access of a symbol, like writing to a variable. + WriteDocumentHighlightKind DocumentHighlightKind = 3 +) + +// CodeActionKind a set of predefined code action kinds. +type CodeActionKind string + +const ( + // EmptyCodeActionKind empty kind. + EmptyCodeActionKind CodeActionKind = "" + + // QuickFixCodeActionKind base kind for quickfix actions: 'quickfix'. + QuickFixCodeActionKind CodeActionKind = "quickfix" + + // RefactorCodeActionKind base kind for refactoring actions: 'refactor'. + RefactorCodeActionKind CodeActionKind = "refactor" + + // RefactorExtractCodeActionKind base kind for refactoring extraction actions: 'refactor.extract' Example extract actions: - Extract method - Extract function - Extract variable - Extract interface from class - . + RefactorExtractCodeActionKind CodeActionKind = "refactor.extract" + + // RefactorInlineCodeActionKind base kind for refactoring inline actions: 'refactor.inline' Example inline actions: - Inline function - Inline variable - Inline constant - . + RefactorInlineCodeActionKind CodeActionKind = "refactor.inline" + + // RefactorMoveCodeActionKind base kind for refactoring move actions: `refactor.move` Example move actions: - Move a function to a + // new file - Move a property between classes - Move method to base class - ... 3.18.0 @proposed. + // + // @since 3.18.0 proposed + RefactorMoveCodeActionKind CodeActionKind = "refactor.move" + + // RefactorRewriteCodeActionKind base kind for refactoring rewrite actions: 'refactor.rewrite' Example rewrite actions: - Convert JavaScript function to class - Add or remove parameter - Encapsulate field - Make method static - Move method to base class - . + RefactorRewriteCodeActionKind CodeActionKind = "refactor.rewrite" + + // SourceCodeActionKind base kind for source actions: `source` Source code actions apply to the entire file. + SourceCodeActionKind CodeActionKind = "source" + + // SourceOrganizeImportsCodeActionKind base kind for an organize imports source action: `source.organizeImports`. + SourceOrganizeImportsCodeActionKind CodeActionKind = "source.organizeImports" + + // SourceFixAllCodeActionKind base kind for auto-fix source actions: `source.fixAll`. Fix all actions automatically fix errors that have a clear fix that do not require user input. They should not suppress errors or perform unsafe + // fixes such as generating new types or classes. + // + // @since 3.15.0 + SourceFixAllCodeActionKind CodeActionKind = "source.fixAll" + + // NotebookCodeActionKind base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using this should always begin with `notebook.` + // + // @since 3.18.0 + NotebookCodeActionKind CodeActionKind = "notebook" +) + +// CodeActionTag code action tags are extra annotations that tweak the behavior of a code action. 3.18.0 - proposed. +// +// @since 3.18.0 - proposed +type CodeActionTag uint32 + +const ( + // LlmgeneratedCodeActionTag marks the code action as LLM-generated. + LlmgeneratedCodeActionTag CodeActionTag = 1 +) + +// InlineCompletionTriggerKind describes how an InlineCompletionItemProvider inline completion provider was triggered. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionTriggerKind uint32 + +const ( + // InvokedInlineCompletionTriggerKind completion was triggered explicitly by a user gesture. + InvokedInlineCompletionTriggerKind InlineCompletionTriggerKind = 1 + + // AutomaticInlineCompletionTriggerKind completion was triggered automatically while editing. + AutomaticInlineCompletionTriggerKind InlineCompletionTriggerKind = 2 +) + +// CompletionTriggerKind how a completion was triggered. +type CompletionTriggerKind uint32 + +const ( + // InvokedCompletionTriggerKind completion was triggered by typing an identifier (24x7 code complete), manual invocation (e.g Ctrl+Space) or via API. + InvokedCompletionTriggerKind CompletionTriggerKind = 1 + + // TriggerCharacterCompletionTriggerKind completion was triggered by a trigger character specified by the `triggerCharacters` properties of the `CompletionRegistrationOptions`. + TriggerCharacterCompletionTriggerKind CompletionTriggerKind = 2 + + // TriggerForIncompleteCompletionsCompletionTriggerKind completion was re-triggered as current completion list is incomplete. + TriggerForIncompleteCompletionsCompletionTriggerKind CompletionTriggerKind = 3 +) + +// ApplyKind defines how values from a set of defaults and an individual item will be merged. +// +// @since 3.18.0 +type ApplyKind string + +const ( + // ReplaceApplyKind the value from the individual item (if provided and not `null`) will be used instead of the default. + ReplaceApplyKind ApplyKind = "replace" + + // MergeApplyKind the value from the item will be merged with the default. The specific rules for mergeing values are defined against each field that supports merging. + MergeApplyKind ApplyKind = "merge" +) + +// SignatureHelpTriggerKind how a signature help was triggered. +// +// @since 3.15.0 +type SignatureHelpTriggerKind uint32 + +const ( + // InvokedSignatureHelpTriggerKind signature help was invoked manually by the user or by a command. + InvokedSignatureHelpTriggerKind SignatureHelpTriggerKind = 1 + + // TriggerCharacterSignatureHelpTriggerKind signature help was triggered by a trigger character. + TriggerCharacterSignatureHelpTriggerKind SignatureHelpTriggerKind = 2 + + // ContentChangeSignatureHelpTriggerKind signature help was triggered by the cursor moving or by the document content changing. + ContentChangeSignatureHelpTriggerKind SignatureHelpTriggerKind = 3 +) + +// CodeActionTriggerKind the reason why code actions were requested. +// +// @since 3.17.0 +type CodeActionTriggerKind uint32 + +const ( + // InvokedCodeActionTriggerKind code actions were explicitly requested by the user or by an extension. + InvokedCodeActionTriggerKind CodeActionTriggerKind = 1 + + // AutomaticCodeActionTriggerKind code actions were requested automatically. This typically happens when current selection in a file changes, but can also be triggered when file content changes. + AutomaticCodeActionTriggerKind CodeActionTriggerKind = 2 +) + +type PrepareSupportDefaultBehavior uint32 + +const ( + // IdentifierPrepareSupportDefaultBehavior the client's default behavior is to select the identifier according the to language's syntax rule. + IdentifierPrepareSupportDefaultBehavior PrepareSupportDefaultBehavior = 1 +) + +type TokenFormat string + +const ( + RelativeTokenFormat TokenFormat = "relative" +) + +type ImplementationParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +type ImplementationOptions struct { + // mixins + WorkDoneProgressOptions +} + +type ImplementationRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + ImplementationOptions + // mixins + StaticRegistrationOptions +} + +type TypeDefinitionParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +type TypeDefinitionOptions struct { + // mixins + WorkDoneProgressOptions +} + +type TypeDefinitionRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + TypeDefinitionOptions + // mixins + StaticRegistrationOptions +} + +// DocumentColorParams parameters for a DocumentColorRequest. +type DocumentColorParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// Color represents a color in RGBA space. +type Color struct { + // Red the red component of this color in the range [0-1]. + Red float64 `json:"red"` + + // Green the green component of this color in the range [0-1]. + Green float64 `json:"green"` + + // Blue the blue component of this color in the range [0-1]. + Blue float64 `json:"blue"` + + // Alpha the alpha component of this color in the range [0-1]. + Alpha float64 `json:"alpha"` +} + +// ColorInformation represents a color range from a document. +type ColorInformation struct { + // Range the range in the document where this color appears. + Range Range `json:"range"` + + // Color the actual color value for this color range. + Color Color `json:"color"` +} + +type DocumentColorOptions struct { + // mixins + WorkDoneProgressOptions +} + +type DocumentColorRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentColorOptions + // mixins + StaticRegistrationOptions +} + +// ColorPresentationParams parameters for a ColorPresentationRequest. +type ColorPresentationParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Color the color to request presentations for. + Color Color `json:"color"` + + // Range the range where the color would be inserted. Serves as a context. + Range Range `json:"range"` +} + +type ColorPresentation struct { + // Label the label of this color presentation. It will be shown on the color picker header. By default this is also the text that is inserted when selecting this color presentation. + Label string `json:"label"` + + // TextEdit an TextEdit edit which is applied to a document when selecting this presentation for the color. When + // `falsy` the ColorPresentation.label label is used. + TextEdit *TextEdit `json:"textEdit,omitempty"` + + // AdditionalTextEdits an optional array of additional TextEdit text edits that are applied when selecting this color presentation. Edits must not overlap with the main ColorPresentation.textEdit edit nor with themselves. + AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"` +} + +// FoldingRangeParams parameters for a FoldingRangeRequest. +type FoldingRangeParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// FoldingRange represents a folding range. To be valid, start and end line must be bigger than zero and smaller than the number of lines in the document. Clients are free to ignore invalid ranges. +type FoldingRange struct { + // StartLine the zero-based start line of the range to fold. The folded area starts after the line's last character. To be valid, the end must be zero or larger and smaller than the number of lines in the document. + StartLine uint32 `json:"startLine"` + + // StartCharacter the zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line. + StartCharacter uint32 `json:"startCharacter,omitempty"` + + // EndLine the zero-based end line of the range to fold. The folded area ends with the line's last character. To be valid, the end must be zero or larger and smaller than the number of lines in the document. + EndLine uint32 `json:"endLine"` + + // EndCharacter the zero-based character offset before the folded range ends. If not defined, defaults to the length + // of the end line. + EndCharacter uint32 `json:"endCharacter,omitempty"` + + // Kind describes the kind of the folding range such as 'comment' or 'region'. The kind is used to categorize folding ranges and used by commands like 'Fold all comments'. See FoldingRangeKind for an enumeration of standardized kinds. + Kind FoldingRangeKind `json:"kind,omitempty"` + + // CollapsedText the text that the client should show when the specified range is collapsed. If not defined or not supported by the client, a default will be chosen by the client. + CollapsedText string `json:"collapsedText,omitempty"` +} + +type FoldingRangeOptions struct { + // mixins + WorkDoneProgressOptions +} + +type FoldingRangeRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + FoldingRangeOptions + // mixins + StaticRegistrationOptions +} + +type DeclarationParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +type DeclarationOptions struct { + // mixins + WorkDoneProgressOptions +} + +type DeclarationRegistrationOptions struct { + // extends + DeclarationOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// SelectionRangeParams a parameter literal used in selection range requests. +type SelectionRangeParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Positions the positions inside the text document. + Positions []Position `json:"positions"` +} + +// SelectionRange a selection range represents a part of a selection hierarchy. A selection range may have a parent selection range that contains it. +type SelectionRange struct { + // Range the Range range of this selection range. + Range Range `json:"range"` + + // Parent the parent selection range containing this range. Therefore `parent.range` must contain `this.range`. + Parent *SelectionRange `json:"parent,omitempty"` +} + +type SelectionRangeOptions struct { + // mixins + WorkDoneProgressOptions +} + +type SelectionRangeRegistrationOptions struct { + // extends + SelectionRangeOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// CallHierarchyPrepareParams the parameter of a `textDocument/prepareCallHierarchy` request. +// +// @since 3.16.0 +type CallHierarchyPrepareParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams +} + +// CallHierarchyItem represents programming constructs like functions or constructors in the context of call hierarchy. +// +// @since 3.16.0 +type CallHierarchyItem struct { + // Name the name of this item. + // + // @since 3.16.0 + Name string `json:"name"` + + // Kind the kind of this item. + // + // @since 3.16.0 + Kind SymbolKind `json:"kind"` + + // Tags tags for this item. + // + // @since 3.16.0 + Tags []SymbolTag `json:"tags,omitempty"` + + // Detail more detail for this item, e.g. the signature of a function. + // + // @since 3.16.0 + Detail string `json:"detail,omitempty"` + + // URI the resource identifier of this item. + // + // @since 3.16.0 + URI DocumentURI `json:"uri"` + + // Range the range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code. + // + // @since 3.16.0 + Range Range `json:"range"` + + // SelectionRange the range that should be selected and revealed when this symbol is being picked, e.g. the name of a function. Must be contained by the CallHierarchyItem.range `range`. + // + // @since 3.16.0 + SelectionRange Range `json:"selectionRange"` + + // Data a data entry field that is preserved between a call hierarchy prepare and incoming calls or outgoing + // calls requests. + // + // @since 3.16.0 + Data any `json:"data,omitempty"` +} + +// CallHierarchyOptions call hierarchy options used during static registration. +// +// @since 3.16.0 +type CallHierarchyOptions struct { + // mixins + WorkDoneProgressOptions +} + +// CallHierarchyRegistrationOptions call hierarchy options used during static or dynamic registration. +// +// @since 3.16.0 +type CallHierarchyRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + CallHierarchyOptions + // mixins + StaticRegistrationOptions +} + +// CallHierarchyIncomingCallsParams the parameter of a `callHierarchy/incomingCalls` request. +// +// @since 3.16.0 +type CallHierarchyIncomingCallsParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // @since 3.16.0 + Item CallHierarchyItem `json:"item"` +} + +// CallHierarchyIncomingCall represents an incoming call, e.g. a caller of a method or constructor. +// +// @since 3.16.0 +type CallHierarchyIncomingCall struct { + // From the item that makes the call. + // + // @since 3.16.0 + From CallHierarchyItem `json:"from"` + + // FromRanges the ranges at which the calls appear. This is relative to the caller denoted by CallHierarchyIncomingCall.from `this.from`. + // + // @since 3.16.0 + FromRanges []Range `json:"fromRanges"` +} + +// CallHierarchyOutgoingCallsParams the parameter of a `callHierarchy/outgoingCalls` request. +// +// @since 3.16.0 +type CallHierarchyOutgoingCallsParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // @since 3.16.0 + Item CallHierarchyItem `json:"item"` +} + +// CallHierarchyOutgoingCall represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc. +// +// @since 3.16.0 +type CallHierarchyOutgoingCall struct { + // To the item that is called. + // + // @since 3.16.0 + To CallHierarchyItem `json:"to"` + + // FromRanges the range at which this item is called. This is the range relative to the caller, e.g the item passed to CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls `provideCallHierarchyOutgoingCalls` + // and not CallHierarchyOutgoingCall.to `this.to`. + // + // @since 3.16.0 + FromRanges []Range `json:"fromRanges"` +} + +// SemanticTokensParams. +// +// @since 3.16.0 +type SemanticTokensParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + // + // @since 3.16.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` +} + +// SemanticTokens. +// +// @since 3.16.0 +type SemanticTokens struct { + // ResultID an optional result id. If provided and clients support delta updating the client will include the result id in the next semantic token request. A server can then instead of computing all semantic tokens again simply send a delta. + // + // @since 3.16.0 + ResultID string `json:"resultId,omitempty"` + + // Data the actual tokens. + // + // @since 3.16.0 + Data []uint32 `json:"data"` +} + +// SemanticTokensPartialResult. +// +// @since 3.16.0 +type SemanticTokensPartialResult struct { + // @since 3.16.0 + Data []uint32 `json:"data"` +} + +// SemanticTokensLegend. +// +// @since 3.16.0 +type SemanticTokensLegend struct { + // TokenTypes the token types a server uses. + // + // @since 3.16.0 + TokenTypes []string `json:"tokenTypes"` + + // TokenModifiers the token modifiers a server uses. + // + // @since 3.16.0 + TokenModifiers []string `json:"tokenModifiers"` +} + +// SemanticTokensFullDelta semantic tokens options to support deltas for full documents +// +// @since 3.18.0 +type SemanticTokensFullDelta struct { + // Delta the server supports deltas for full documents. + // + // @since 3.18.0 + Delta bool `json:"delta,omitempty"` +} + +// SemanticTokensOptions. +// +// @since 3.16.0 +type SemanticTokensOptions struct { + // mixins + WorkDoneProgressOptions + + // Legend the legend used by the server. + // + // @since 3.16.0 + Legend SemanticTokensLegend `json:"legend"` + + // Range server supports providing semantic tokens for a specific range of a document. + // + // @since 3.16.0 + Range *SemanticTokensOptionsRange `json:"range,omitempty"` + + // Full server supports providing semantic tokens for a full document. + // + // @since 3.16.0 + Full *SemanticTokensOptionsFull `json:"full,omitempty"` +} + +// SemanticTokensRegistrationOptions. +// +// @since 3.16.0 +type SemanticTokensRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + SemanticTokensOptions + // mixins + StaticRegistrationOptions +} + +// SemanticTokensDeltaParams. +// +// @since 3.16.0 +type SemanticTokensDeltaParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + // + // @since 3.16.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // PreviousResultID the result id of a previous response. The result Id can either point to a full response or a delta response depending on what was received last. + // + // @since 3.16.0 + PreviousResultID string `json:"previousResultId"` +} + +// SemanticTokensEdit. +// +// @since 3.16.0 +type SemanticTokensEdit struct { + // Start the start offset of the edit. + // + // @since 3.16.0 + Start uint32 `json:"start"` + + // DeleteCount the count of elements to remove. + // + // @since 3.16.0 + DeleteCount uint32 `json:"deleteCount"` + + // Data the elements to insert. + // + // @since 3.16.0 + Data []uint32 `json:"data,omitempty"` +} + +// SemanticTokensDelta. +// +// @since 3.16.0 +type SemanticTokensDelta struct { + // @since 3.16.0 + ResultID string `json:"resultId,omitempty"` + + // Edits the semantic token edits to transform a previous result into a new result. + // + // @since 3.16.0 + Edits []SemanticTokensEdit `json:"edits"` +} + +// SemanticTokensDeltaPartialResult. +// +// @since 3.16.0 +type SemanticTokensDeltaPartialResult struct { + // @since 3.16.0 + Edits []SemanticTokensEdit `json:"edits"` +} + +// SemanticTokensRangeParams. +// +// @since 3.16.0 +type SemanticTokensRangeParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + // + // @since 3.16.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Range the range the semantic tokens are requested for. + // + // @since 3.16.0 + Range Range `json:"range"` +} + +type LinkedEditingRangeParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams +} + +// LinkedEditingRanges the result of a linked editing range request. +// +// @since 3.16.0 +type LinkedEditingRanges struct { + // Ranges a list of ranges that can be edited together. The ranges must have identical length and contain identical text content. The ranges cannot overlap. + // + // @since 3.16.0 + Ranges []Range `json:"ranges"` + + // WordPattern an optional word pattern (regular expression) that describes valid contents for the given ranges. If + // no pattern is provided, the client configuration's word pattern will be used. + // + // @since 3.16.0 + WordPattern string `json:"wordPattern,omitempty"` +} + +type LinkedEditingRangeOptions struct { + // mixins + WorkDoneProgressOptions +} + +type LinkedEditingRangeRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + LinkedEditingRangeOptions + // mixins + StaticRegistrationOptions +} + +type MonikerParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} + +// Moniker moniker definition to match LSIF 0.5 moniker definition. +// +// @since 3.16.0 +type Moniker struct { + // Scheme the scheme of the moniker. For example tsc or .Net. + // + // @since 3.16.0 + Scheme string `json:"scheme"` + + // Identifier the identifier of the moniker. The value is opaque in LSIF however schema owners are allowed to define the structure if they want. + // + // @since 3.16.0 + Identifier string `json:"identifier"` + + // Unique the scope in which the moniker is unique. + // + // @since 3.16.0 + Unique UniquenessLevel `json:"unique"` + + // Kind the moniker kind if known. + // + // @since 3.16.0 + Kind MonikerKind `json:"kind,omitempty"` +} + +type MonikerOptions struct { + // mixins + WorkDoneProgressOptions +} + +type MonikerRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + MonikerOptions +} + +// TypeHierarchyPrepareParams the parameter of a `textDocument/prepareTypeHierarchy` request. +// +// @since 3.17.0 +type TypeHierarchyPrepareParams struct { + // extends TextDocumentPositionParams + // mixins + WorkDoneProgressParams +} + +// TypeHierarchyItem. +// +// @since 3.17.0 +type TypeHierarchyItem struct { + // Name the name of this item. + // + // @since 3.17.0 + Name string `json:"name"` + + // Kind the kind of this item. + // + // @since 3.17.0 + Kind SymbolKind `json:"kind"` + + // Tags tags for this item. + // + // @since 3.17.0 + Tags []SymbolTag `json:"tags,omitempty"` + + // Detail more detail for this item, e.g. the signature of a function. + // + // @since 3.17.0 + Detail string `json:"detail,omitempty"` + + // URI the resource identifier of this item. + // + // @since 3.17.0 + URI DocumentURI `json:"uri"` + + // Range the range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code. + // + // @since 3.17.0 + Range Range `json:"range"` + + // SelectionRange the range that should be selected and revealed when this symbol is being picked, e.g. the name of a function. Must be contained by the TypeHierarchyItem.range `range`. + // + // @since 3.17.0 + SelectionRange Range `json:"selectionRange"` + + // Data a data entry field that is preserved between a type hierarchy prepare and supertypes or subtypes requests. It could also be used to identify the type hierarchy in the server, helping improve the performance on resolving supertypes and subtypes. + // + // @since 3.17.0 + Data any `json:"data,omitempty"` +} + +// TypeHierarchyOptions type hierarchy options used during static registration. +// +// @since 3.17.0 +type TypeHierarchyOptions struct { + // mixins + WorkDoneProgressOptions +} + +// TypeHierarchyRegistrationOptions type hierarchy options used during static or dynamic registration. +// +// @since 3.17.0 +type TypeHierarchyRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + TypeHierarchyOptions + // mixins + StaticRegistrationOptions +} + +// TypeHierarchySupertypesParams the parameter of a `typeHierarchy/supertypes` request. +// +// @since 3.17.0 +type TypeHierarchySupertypesParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // @since 3.17.0 + Item TypeHierarchyItem `json:"item"` +} + +// TypeHierarchySubtypesParams the parameter of a `typeHierarchy/subtypes` request. +// +// @since 3.17.0 +type TypeHierarchySubtypesParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // @since 3.17.0 + Item TypeHierarchyItem `json:"item"` +} + +// InlineValueContext. +// +// @since 3.17.0 +type InlineValueContext struct { + // FrameID the stack frame (as a DAP Id) where the execution has stopped. + // + // @since 3.17.0 + FrameID int32 `json:"frameId"` + + // StoppedLocation the document range where execution has stopped. Typically the end position of the range denotes the line where the inline values are shown. + // + // @since 3.17.0 + StoppedLocation Range `json:"stoppedLocation"` +} + +// InlineValueParams a parameter literal used in inline value requests. +// +// @since 3.17.0 +type InlineValueParams struct { + // mixins + WorkDoneProgressParams + + // TextDocument the text document. + // + // @since 3.17.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Range the document range for which inline values should be computed. + // + // @since 3.17.0 + Range Range `json:"range"` + + // Context additional information about the context in which inline values were requested. + // + // @since 3.17.0 + Context InlineValueContext `json:"context"` +} + +// InlineValueOptions inline value options used during static registration. +// +// @since 3.17.0 +type InlineValueOptions struct { + // mixins + WorkDoneProgressOptions +} + +// InlineValueRegistrationOptions inline value options used during static or dynamic registration. +// +// @since 3.17.0 +type InlineValueRegistrationOptions struct { + // extends + InlineValueOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// InlayHintParams a parameter literal used in inlay hint requests. +// +// @since 3.17.0 +type InlayHintParams struct { + // mixins + WorkDoneProgressParams + + // TextDocument the text document. + // + // @since 3.17.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Range the document range for which inlay hints should be computed. + // + // @since 3.17.0 + Range Range `json:"range"` +} + +// InlayHintLabelPart an inlay hint label part allows for interactive and composite labels of inlay hints. +// +// @since 3.17.0 +type InlayHintLabelPart struct { + // Value the value of this label part. + // + // @since 3.17.0 + Value string `json:"value"` + + // Tooltip the tooltip text when you hover over this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. + // + // @since 3.17.0 + Tooltip *InlayHintLabelPartTooltip `json:"tooltip,omitempty"` + + // Location an optional source code location that represents this label part. The editor will use this location for the hover and for code navigation features: This part will become a clickable link that resolves + // to the definition of the symbol at the given location (not necessarily the location itself), it shows the hover that shows at the given location, and it shows a context menu with further code navigation commands. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. + // + // @since 3.17.0 + Location *Location `json:"location,omitempty"` + + // Command an optional command for this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. + // + // @since 3.17.0 + Command *Command `json:"command,omitempty"` +} + +// InlayHint inlay hint information. +// +// @since 3.17.0 +type InlayHint struct { + // Position the position of this hint. If multiple hints have the same position, they will be shown in the order + // they appear in the response. + // + // @since 3.17.0 + Position Position `json:"position"` + + // Label the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty. + // + // @since 3.17.0 + Label InlayHintLabel `json:"label"` + + // Kind the kind of this hint. Can be omitted in which case the client should fall back to a reasonable default. + // + // @since 3.17.0 + Kind InlayHintKind `json:"kind,omitempty"` + + // TextEdits optional text edits that are performed when accepting this inlay hint. *Note* that edits are expected to change the document so that the inlay hint (or its nearest variant) is now part of the document + // and the inlay hint itself is now obsolete. + // + // @since 3.17.0 + TextEdits []TextEdit `json:"textEdits,omitempty"` + + // Tooltip the tooltip text when you hover over this item. + // + // @since 3.17.0 + Tooltip *InlayHintTooltip `json:"tooltip,omitempty"` + + // PaddingLeft render padding before the hint. Note: Padding should use the editor's background color, not the background color of the hint itself. That means padding can be used to visually align/separate an inlay hint. + // + // @since 3.17.0 + PaddingLeft bool `json:"paddingLeft,omitempty"` + + // PaddingRight render padding after the hint. Note: Padding should use the editor's background color, not the background color of the hint itself. That means padding can be used to visually align/separate an inlay hint. + // + // @since 3.17.0 + PaddingRight bool `json:"paddingRight,omitempty"` + + // Data a data entry field that is preserved on an inlay hint between a `textDocument/inlayHint` and a `inlayHint/resolve` request. + // + // @since 3.17.0 + Data any `json:"data,omitempty"` +} + +// InlayHintOptions inlay hint options used during static registration. +// +// @since 3.17.0 +type InlayHintOptions struct { + // mixins + WorkDoneProgressOptions + + // ResolveProvider the server provides support to resolve additional information for an inlay hint item. + // + // @since 3.17.0 + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// InlayHintRegistrationOptions inlay hint options used during static or dynamic registration. +// +// @since 3.17.0 +type InlayHintRegistrationOptions struct { + // extends + InlayHintOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// DocumentDiagnosticParams parameters of the document diagnostic request. +// +// @since 3.17.0 +type DocumentDiagnosticParams struct { + // mixins + WorkDoneProgressParams + PartialResultParams + + // TextDocument the text document. + // + // @since 3.17.0 + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Identifier the additional identifier provided during registration. + // + // @since 3.17.0 + Identifier string `json:"identifier,omitempty"` + + // PreviousResultID the result id of a previous response if provided. + // + // @since 3.17.0 + PreviousResultID string `json:"previousResultId,omitempty"` +} + +// UnchangedDocumentDiagnosticReport a diagnostic report indicating that the last returned report is still accurate. +// +// @since 3.17.0 +type UnchangedDocumentDiagnosticReport struct { + // ResultID a result id which will be sent on the next diagnostic request for the same document. + // + // @since 3.17.0 + ResultID string `json:"resultId"` +} + +// FullDocumentDiagnosticReport a diagnostic report with a full set of problems. +// +// @since 3.17.0 +type FullDocumentDiagnosticReport struct { + // ResultID an optional result id. If provided it will be sent on the next diagnostic request for the same document. + // + // @since 3.17.0 + ResultID string `json:"resultId,omitempty"` + + // Items the actual items. + // + // @since 3.17.0 + Items []Diagnostic `json:"items"` +} + +// DocumentDiagnosticReportPartialResult a partial result for a document diagnostic report. +// +// @since 3.17.0 +type DocumentDiagnosticReportPartialResult struct { + // @since 3.17.0 + RelatedDocuments map[DocumentURI]DocumentDiagnosticReportPartialResultRelatedDocuments `json:"relatedDocuments"` +} + +// DiagnosticServerCancellationData cancellation data returned from a diagnostic request. +// +// @since 3.17.0 +type DiagnosticServerCancellationData struct { + // @since 3.17.0 + RetriggerRequest bool `json:"retriggerRequest"` +} + +// DiagnosticOptions diagnostic options. +// +// @since 3.17.0 +type DiagnosticOptions struct { + // mixins + WorkDoneProgressOptions + + // Identifier an optional identifier under which the diagnostics are managed by the client. + // + // @since 3.17.0 + Identifier string `json:"identifier,omitempty"` + + // InterFileDependencies 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. + // + // @since 3.17.0 + InterFileDependencies bool `json:"interFileDependencies"` + + // WorkspaceDiagnostics the server provides support for workspace diagnostics as well. + // + // @since 3.17.0 + WorkspaceDiagnostics bool `json:"workspaceDiagnostics"` +} + +// DiagnosticRegistrationOptions diagnostic registration options. +// +// @since 3.17.0 +type DiagnosticRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DiagnosticOptions + // mixins + StaticRegistrationOptions +} + +// PreviousResultID a previous result id in a workspace pull request. +// +// @since 3.17.0 +type PreviousResultID struct { + // URI the URI for which the client knowns a result id. + // + // @since 3.17.0 + URI DocumentURI `json:"uri"` + + // Value the value of the previous result id. + // + // @since 3.17.0 + Value string `json:"value"` +} + +// WorkspaceDiagnosticParams parameters of the workspace diagnostic request. +// +// @since 3.17.0 +type WorkspaceDiagnosticParams struct { + // mixins WorkDoneProgressParams PartialResultParams - // Context is the completion context. This is only available if the client specifies - // to send this using `ClientCapabilities.textDocument.completion.contextSupport === true` - Context *CompletionContext `json:"context,omitempty"` + // Identifier the additional identifier provided during registration. + // + // @since 3.17.0 + Identifier string `json:"identifier,omitempty"` + + // PreviousResultIDS the currently known diagnostic reports with their previous result ids. + // + // @since 3.17.0 + PreviousResultIDS []PreviousResultID `json:"previousResultIds"` +} + +// WorkspaceDiagnosticReport a workspace diagnostic report. +// +// @since 3.17.0 +type WorkspaceDiagnosticReport struct { + // @since 3.17.0 + Items []WorkspaceDocumentDiagnosticReport `json:"items"` +} + +// WorkspaceDiagnosticReportPartialResult a partial result for a workspace diagnostic report. +// +// @since 3.17.0 +type WorkspaceDiagnosticReportPartialResult struct { + // @since 3.17.0 + Items []WorkspaceDocumentDiagnosticReport `json:"items"` +} + +// SelectedCompletionInfo describes the currently selected completion item. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type SelectedCompletionInfo struct { + // Range the range that will be replaced if this completion item is accepted. + // + // @since 3.18.0 proposed + Range Range `json:"range"` + + // Text the text the range will be replaced with if this completion is accepted. + // + // @since 3.18.0 proposed + Text string `json:"text"` +} + +// InlineCompletionContext provides information about the context in which an inline completion was requested. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionContext struct { + // TriggerKind describes how the inline completion was triggered. + // + // @since 3.18.0 proposed + TriggerKind InlineCompletionTriggerKind `json:"triggerKind"` + + // SelectedCompletionInfo provides information about the currently selected item in the autocomplete widget if it is visible. + // + // @since 3.18.0 proposed + SelectedCompletionInfo *SelectedCompletionInfo `json:"selectedCompletionInfo,omitempty"` +} + +// InlineCompletionParams a parameter literal used in inline completion requests. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + + // Context additional information about the context in which inline completions were requested. + // + // @since 3.18.0 proposed + Context InlineCompletionContext `json:"context"` +} + +// InlineCompletionItem an inline completion item represents a text snippet that is proposed inline to complete text that is +// being typed. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionItem struct { + // InsertText the text to replace the range with. Must be set. + // + // @since 3.18.0 proposed + InsertText InlineCompletionItemInsertText `json:"insertText"` + + // FilterText a text that is used to decide if this inline completion should be shown. When `falsy` the InlineCompletionItem.insertText is used. + // + // @since 3.18.0 proposed + FilterText string `json:"filterText,omitempty"` + + // Range the range to replace. Must begin and end on the same line. + // + // @since 3.18.0 proposed + Range *Range `json:"range,omitempty"` + + // Command an optional Command that is executed *after* inserting this completion. + // + // @since 3.18.0 proposed + Command *Command `json:"command,omitempty"` +} + +// InlineCompletionList represents a collection of InlineCompletionItem inline completion items to be presented in the editor. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionList struct { + // Items the inline completion items. + // + // @since 3.18.0 proposed + Items []InlineCompletionItem `json:"items"` +} + +// InlineCompletionOptions inline completion options used during static registration. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionOptions struct { + // mixins + WorkDoneProgressOptions +} + +// InlineCompletionRegistrationOptions inline completion options used during static or dynamic registration. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionRegistrationOptions struct { + // extends + InlineCompletionOptions + TextDocumentRegistrationOptions + // mixins + StaticRegistrationOptions +} + +// CodeActionTagOptions. +// +// @since 3.18.0 - proposed +type CodeActionTagOptions struct { + // ValueSet the tags supported by the client. + // + // @since 3.18.0 - proposed + ValueSet []CodeActionTag `json:"valueSet"` +} + +// ServerCompletionItemOptions. +// +// @since 3.18.0 +type ServerCompletionItemOptions struct { + // LabelDetailsSupport the server has support for completion item label details (see also `CompletionItemLabelDetails`) when receiving a completion item in a resolve call. + // @since 3.18.0 + LabelDetailsSupport bool `json:"labelDetailsSupport,omitempty"` } -// CompletionTriggerKind how a completion was triggered. -type CompletionTriggerKind float64 +// CompletionOptions completion options. +type CompletionOptions struct { + // mixins + WorkDoneProgressOptions -const ( - // CompletionTriggerKindInvoked completion was triggered by typing an identifier (24x7 code - // complete), manual invocation (e.g Ctrl+Space) or via API. - CompletionTriggerKindInvoked CompletionTriggerKind = 1 + // TriggerCharacters most tools trigger completion request automatically without explicitly requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user starts to type an identifier. For example if the user types `c` in a JavaScript file code complete will automatically pop up present `console` besides others as a completion item. Characters that make up identifiers don't need to be listed here. If code complete should automatically be trigger on characters not being valid inside an identifier (for example `.` in JavaScript) list them in `triggerCharacters`. + TriggerCharacters []string `json:"triggerCharacters,omitempty"` - // CompletionTriggerKindTriggerCharacter completion was triggered by a trigger character specified by - // the `triggerCharacters` properties of the `CompletionRegistrationOptions`. - CompletionTriggerKindTriggerCharacter CompletionTriggerKind = 2 + // AllCommitCharacters the list of all possible characters that commit a completion. This field can be used if clients don't support individual commit characters per completion item. See `ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport` If a server provides both `allCommitCharacters` and commit characters on an individual completion item the ones on the completion item win. + AllCommitCharacters []string `json:"allCommitCharacters,omitempty"` - // CompletionTriggerKindTriggerForIncompleteCompletions completion was re-triggered as the current completion list is incomplete. - CompletionTriggerKindTriggerForIncompleteCompletions CompletionTriggerKind = 3 -) + // ResolveProvider the server provides support to resolve additional information for a completion item. + ResolveProvider bool `json:"resolveProvider,omitempty"` + + // CompletionItem the server supports the following `CompletionItem` specific capabilities. + CompletionItem *ServerCompletionItemOptions `json:"completionItem,omitempty"` +} + +// HoverOptions hover options. +type HoverOptions struct { + // mixins + WorkDoneProgressOptions +} + +// SignatureHelpOptions server Capabilities for a SignatureHelpRequest. +type SignatureHelpOptions struct { + // mixins + WorkDoneProgressOptions + + // TriggerCharacters list of characters that trigger signature help automatically. + TriggerCharacters []string `json:"triggerCharacters,omitempty"` + + // RetriggerCharacters list of characters that re-trigger signature help. These trigger characters are only active when signature help is already showing. All trigger characters are also counted as re-trigger characters. + RetriggerCharacters []string `json:"retriggerCharacters,omitempty"` +} + +// DefinitionOptions server Capabilities for a DefinitionRequest. +type DefinitionOptions struct { + // mixins + WorkDoneProgressOptions +} + +// ReferenceOptions reference options. +type ReferenceOptions struct { + // mixins + WorkDoneProgressOptions +} + +// DocumentHighlightOptions provider options for a DocumentHighlightRequest. +type DocumentHighlightOptions struct { + // mixins + WorkDoneProgressOptions +} + +// DocumentSymbolOptions provider options for a DocumentSymbolRequest. +type DocumentSymbolOptions struct { + // mixins + WorkDoneProgressOptions + + // Label a human-readable string that is shown when multiple outlines trees are shown for the same document. + Label string `json:"label,omitempty"` +} + +// CodeActionKindDocumentation documentation for a class of code actions. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type CodeActionKindDocumentation struct { + // Kind the kind of the code action being documented. If the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any refactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the documentation will only be shown when extract refactoring code actions are returned. + // + // @since 3.18.0 proposed + Kind CodeActionKind `json:"kind"` + + // Command command that is ued to display the documentation to the user. The title of this documentation code action is taken from {@linkcode Command.title}. + // + // @since 3.18.0 proposed + Command Command `json:"command"` +} + +// CodeActionOptions provider options for a CodeActionRequest. +type CodeActionOptions struct { + // mixins + WorkDoneProgressOptions + + // CodeActionKinds codeActionKinds that this server may return. The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server may list out every specific kind they provide. + CodeActionKinds []CodeActionKind `json:"codeActionKinds,omitempty"` + + // Documentation static documentation for a class of code actions. Documentation from the provider should be shown in + // the code actions menu if either: - Code actions of `kind` are requested by the editor. In this + // case, the editor will show the documentation that most closely matches the requested code action kind. For example, if a provider has documentation for both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`, the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`. - Any code actions of `kind` are returned by the provider. At most one documentation entry should be shown per provider. 3.18.0 @proposed. + Documentation []CodeActionKindDocumentation `json:"documentation,omitempty"` + + // ResolveProvider the server provides support to resolve additional information for a code action. + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// CodeLensOptions code Lens provider options of a CodeLensRequest. +type CodeLensOptions struct { + // mixins + WorkDoneProgressOptions + + // ResolveProvider code lens has a resolve provider as well. + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// DocumentLinkOptions provider options for a DocumentLinkRequest. +type DocumentLinkOptions struct { + // mixins + WorkDoneProgressOptions + + // ResolveProvider document links have a resolve provider as well. + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// WorkspaceSymbolOptions server capabilities for a WorkspaceSymbolRequest. +type WorkspaceSymbolOptions struct { + // mixins + WorkDoneProgressOptions + + // ResolveProvider the server provides support to resolve additional information for a workspace symbol. + ResolveProvider bool `json:"resolveProvider,omitempty"` +} + +// DocumentFormattingOptions provider options for a DocumentFormattingRequest. +type DocumentFormattingOptions struct { + // mixins + WorkDoneProgressOptions +} + +// DocumentRangeFormattingOptions provider options for a DocumentRangeFormattingRequest. +type DocumentRangeFormattingOptions struct { + // mixins + WorkDoneProgressOptions + + // RangesSupport whether the server supports formatting multiple ranges at once. 3.18.0 @proposed. + RangesSupport bool `json:"rangesSupport,omitempty"` +} + +// DocumentOnTypeFormattingOptions provider options for a DocumentOnTypeFormattingRequest. +type DocumentOnTypeFormattingOptions struct { + // FirstTriggerCharacter a character on which formatting should be triggered, like `{`. + FirstTriggerCharacter string `json:"firstTriggerCharacter"` + + // MoreTriggerCharacter more trigger characters. + MoreTriggerCharacter []string `json:"moreTriggerCharacter,omitempty"` +} + +// RenameOptions provider options for a RenameRequest. +type RenameOptions struct { + // mixins + WorkDoneProgressOptions + + // PrepareProvider renames should be checked and tested before being executed. version . + PrepareProvider bool `json:"prepareProvider,omitempty"` +} + +// ExecuteCommandOptions the server capabilities of a ExecuteCommandRequest. +type ExecuteCommandOptions struct { + // mixins + WorkDoneProgressOptions -// String implements fmt.Stringer. -func (k CompletionTriggerKind) String() string { - switch k { - case CompletionTriggerKindInvoked: - return "Invoked" - case CompletionTriggerKindTriggerCharacter: - return "TriggerCharacter" - case CompletionTriggerKindTriggerForIncompleteCompletions: - return "TriggerForIncompleteCompletions" - default: - return strconv.FormatFloat(float64(k), 'f', -10, 64) - } + // Commands the commands to be executed on the server. + Commands []string `json:"commands"` +} + +// PublishDiagnosticsParams the publish diagnostic notification's parameters. +type PublishDiagnosticsParams struct { + // URI the URI for which diagnostic information is reported. + URI DocumentURI `json:"uri"` + + // Version optional the version number of the document the diagnostics are published for. + Version int32 `json:"version,omitempty"` + + // Diagnostics an array of diagnostic information items. + Diagnostics []Diagnostic `json:"diagnostics"` } // CompletionContext contains additional information about the context in which a completion request is triggered. type CompletionContext struct { - // TriggerCharacter is the trigger character (a single character) that has trigger code complete. - // Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter` - TriggerCharacter string `json:"triggerCharacter,omitempty"` - // TriggerKind how the completion was triggered. TriggerKind CompletionTriggerKind `json:"triggerKind"` -} -// CompletionList represents a collection of [completion items](#CompletionItem) to be presented -// in the editor. -type CompletionList struct { - // IsIncomplete this list it not complete. Further typing should result in recomputing - // this list. - IsIncomplete bool `json:"isIncomplete"` - - // Items is the completion items. - Items []CompletionItem `json:"items"` + // TriggerCharacter the trigger character (a single character) that has trigger code complete. Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`. + TriggerCharacter string `json:"triggerCharacter,omitempty"` } -// InsertTextFormat defines whether the insert text in a completion item should be interpreted as -// plain text or a snippet. -type InsertTextFormat float64 +// CompletionParams completion parameters. +type CompletionParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams -const ( - // InsertTextFormatPlainText is the primary text to be inserted is treated as a plain string. - InsertTextFormatPlainText InsertTextFormat = 1 + // Context the completion context. This is only available it the client specifies to send this using the client + // capability `textDocument.completion.contextSupport === true`. + Context *CompletionContext `json:"context,omitempty"` +} - // InsertTextFormatSnippet is the primary text to be inserted is treated as a snippet. +// CompletionItemLabelDetails additional details for a completion item label. +// +// @since 3.17.0 +type CompletionItemLabelDetails struct { + // Detail an optional string which is rendered less prominently directly after CompletionItem.label label, without any spacing. Should be used for function signatures and type annotations. // - // A snippet can define tab stops and placeholders with `$1`, `$2` - // and `${3:foo}`. `$0` defines the final tab stop, it defaults to - // the end of the snippet. Placeholders with equal identifiers are linked, - // that is typing in one will update others too. - InsertTextFormatSnippet InsertTextFormat = 2 -) + // @since 3.17.0 + Detail string `json:"detail,omitempty"` -// String implements fmt.Stringer. -func (tf InsertTextFormat) String() string { - switch tf { - case InsertTextFormatPlainText: - return "PlainText" - case InsertTextFormatSnippet: - return "Snippet" - default: - return strconv.FormatFloat(float64(tf), 'f', -10, 64) - } + // Description an optional string which is rendered less prominently after CompletionItem.detail. Should be used for fully qualified names and file paths. + // + // @since 3.17.0 + Description string `json:"description,omitempty"` } -// InsertReplaceEdit is a special text edit to provide an insert and a replace operation. +// InsertReplaceEdit a special text edit to provide an insert and a replace operation. // -// @since 3.16.0. +// @since 3.16.0 type InsertReplaceEdit struct { - // NewText is the string to be inserted. + // NewText the string to be inserted. + // + // @since 3.16.0 NewText string `json:"newText"` - // Insert is the range if the insert is requested. + // Insert the range if the insert is requested. + // + // @since 3.16.0 Insert Range `json:"insert"` - // Replace is the range if the replace is requested. + // Replace the range if the replace is requested. + // + // @since 3.16.0 Replace Range `json:"replace"` } -// InsertTextMode how whitespace and indentation is handled during completion -// item insertion. -// -// @since 3.16.0. -type InsertTextMode float64 - -const ( - // InsertTextModeAsIs is the insertion or replace strings is taken as it is. If the - // value is multi line the lines below the cursor will be - // inserted using the indentation defined in the string value. - // The client will not apply any kind of adjustments to the - // string. - InsertTextModeAsIs InsertTextMode = 1 - - // InsertTextModeAdjustIndentation is the editor adjusts leading whitespace of new lines so that - // they match the indentation up to the cursor of the line for - // which the item is accepted. - // - // Consider a line like this: <2tabs><3tabs>foo. Accepting a - // multi line completion item is indented using 2 tabs and all - // following lines inserted will be indented using 2 tabs as well. - InsertTextModeAdjustIndentation InsertTextMode = 2 -) - -// String returns a string representation of the InsertTextMode. -func (k InsertTextMode) String() string { - switch k { - case InsertTextModeAsIs: - return "AsIs" - case InsertTextModeAdjustIndentation: - return "AdjustIndentation" - default: - return strconv.FormatFloat(float64(k), 'f', -10, 64) - } -} - -// CompletionItem item of CompletionList. +// CompletionItem a completion item represents a text snippet that is proposed to complete text that is being typed. type CompletionItem struct { - // AdditionalTextEdits an optional array of additional text edits that are applied when - // selecting this completion. Edits must not overlap (including the same insert position) - // with the main edit nor with themselves. - // - // Additional text edits should be used to change text unrelated to the current cursor position - // (for example adding an import statement at the top of the file if the completion item will - // insert an unqualified type). - AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"` + // Label the label of this completion item. The label property is also by default the text that is inserted when selecting this completion. If label details are provided the label itself should be an unqualified name of the completion item. + Label string `json:"label"` - // Command an optional command that is executed *after* inserting this completion. *Note* that - // additional modifications to the current document should be described with the - // additionalTextEdits-property. - Command *Command `json:"command,omitempty"` + // LabelDetails additional details for the label + LabelDetails *CompletionItemLabelDetails `json:"labelDetails,omitempty"` - // CommitCharacters an optional set of characters that when pressed while this completion is active will accept it first and - // then type that character. *Note* that all commit characters should have `length=1` and that superfluous - // characters will be ignored. - CommitCharacters []string `json:"commitCharacters,omitempty"` + // Kind the kind of this completion item. Based of the kind an icon is chosen by the editor. + Kind CompletionItemKind `json:"kind,omitempty"` - // Tags is the tag for this completion item. - // - // @since 3.15.0. + // Tags tags for this completion item. Tags []CompletionItemTag `json:"tags,omitempty"` - // Data an data entry field that is preserved on a completion item between - // a completion and a completion resolve request. - Data interface{} `json:"data,omitempty"` + // Detail a human-readable string with additional information about this item, like type or symbol information. + Detail string `json:"detail,omitempty"` + + // Documentation a human-readable string that represents a doc-comment. + Documentation *CompletionItemDocumentation `json:"documentation,omitempty"` // Deprecated indicates if this item is deprecated. + // + // Deprecated: Use `tags` instead. Deprecated bool `json:"deprecated,omitempty"` - // Detail a human-readable string with additional information - // about this item, like type or symbol information. - Detail string `json:"detail,omitempty"` + // Preselect select this item when showing. *Note* that only one completion item can be selected and that the tool / client decides which item that is. The rule is that the *first* item of those that match best is + // selected. + Preselect bool `json:"preselect,omitempty"` - // Documentation a human-readable string that represents a doc-comment. - Documentation interface{} `json:"documentation,omitempty"` + // SortText a string that should be used when comparing this item with other items. When `falsy` the CompletionItem.label label is used. + SortText string `json:"sortText,omitempty"` - // FilterText a string that should be used when filtering a set of - // completion items. When `falsy` the label is used. + // FilterText a string that should be used when filtering a set of completion items. When `falsy` the CompletionItem.label label is used. FilterText string `json:"filterText,omitempty"` - // InsertText a string that should be inserted into a document when selecting - // this completion. When `falsy` the label is used. - // - // The `insertText` is subject to interpretation by the client side. - // Some tools might not take the string literally. For example - // VS Code when code complete is requested in this example `con` - // and a completion item with an `insertText` of `console` is provided it - // will only insert `sole`. Therefore it is recommended to use `textEdit` instead - // since it avoids additional client side interpretation. + // InsertText a string that should be inserted into a document when selecting this completion. When `falsy` the CompletionItem.label label is used. The `insertText` is subject to interpretation by the client side. Some tools might not take the string literally. For example VS Code when code complete is requested in this example `con` and a completion item with an `insertText` of `console` is provided it will only insert `sole`. Therefore it is recommended to use `textEdit` instead since it avoids additional client side interpretation. InsertText string `json:"insertText,omitempty"` - // InsertTextFormat is the format of the insert text. The format applies to both the `insertText` property - // and the `newText` property of a provided `textEdit`. + // InsertTextFormat the format of the insert text. The format applies to both the `insertText` property and the `newText` property of a provided `textEdit`. If omitted defaults to `InsertTextFormat.PlainText`. Please note that the insertTextFormat doesn't apply to `additionalTextEdits`. InsertTextFormat InsertTextFormat `json:"insertTextFormat,omitempty"` - // InsertTextMode how whitespace and indentation is handled during completion - // item insertion. If not provided the client's default value depends on - // the `textDocument.completion.insertTextMode` client capability. - // - // @since 3.16.0. + // InsertTextMode how whitespace and indentation is handled during completion item insertion. If not provided the clients default value depends on the `textDocument.completion.insertTextMode` client capability. InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"` - // Kind is the kind of this completion item. Based of the kind - // an icon is chosen by the editor. - Kind CompletionItemKind `json:"kind,omitempty"` + // TextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`. + TextEdit *CompletionItemTextEdit `json:"textEdit,omitempty"` - // Label is the label of this completion item. By default - // also the text that is inserted when selecting - // this completion. - Label string `json:"label"` + // TextEditText the edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range. Clients will only honor this property if they opt into completion list item defaults using the capability `completionList.itemDefaults`. If not provided and a list's default range is provided the label property is used as a text. + TextEditText string `json:"textEditText,omitempty"` - // Preselect select this item when showing. - // - // *Note* that only one completion item can be selected and that the - // tool / client decides which item that is. The rule is that the *first* - // item of those that match best is selected. - Preselect bool `json:"preselect,omitempty"` + // AdditionalTextEdits an optional array of additional TextEdit text edits that are applied when selecting this completion. + // Edits must not overlap (including the same insert position) with the main CompletionItem.textEdit edit nor with themselves. Additional text edits should be used to change text unrelated to the current cursor position (for example adding an import statement at the top of the file if the completion item will insert an unqualified type). + AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"` - // SortText a string that should be used when comparing this item - // with other items. When `falsy` the label is used. - SortText string `json:"sortText,omitempty"` + // CommitCharacters an optional set of characters that when pressed while this completion is active will accept it first + // and then type that character. *Note* that all commit characters should have `length=1` and that superfluous characters will be ignored. + CommitCharacters []string `json:"commitCharacters,omitempty"` - // TextEdit an edit which is applied to a document when selecting this completion. When an edit is provided the value of - // `insertText` is ignored. - // - // NOTE: The range of the edit must be a single line range and it must contain the position at which completion - // has been requested. - // - // Most editors support two different operations when accepting a completion - // item. One is to insert a completion text and the other is to replace an - // existing text with a completion text. Since this can usually not be - // predetermined by a server it can report both ranges. Clients need to - // signal support for `InsertReplaceEdits` via the - // "textDocument.completion.insertReplaceSupport" client capability - // property. - // - // NOTE 1: The text edit's range as well as both ranges from an insert - // replace edit must be a [single line] and they must contain the position - // at which completion has been requested. - // - // NOTE 2: If an "InsertReplaceEdit" is returned the edit's insert range - // must be a prefix of the edit's replace range, that means it must be - // contained and starting at the same position. - // - // @since 3.16.0 additional type "InsertReplaceEdit". - TextEdit *TextEdit `json:"textEdit,omitempty"` // *TextEdit | *InsertReplaceEdit + // Command an optional Command command that is executed *after* inserting this completion. *Note* that additional modifications to the current document should be described with the CompletionItem.additionalTextEdits additionalTextEdits-property. + Command *Command `json:"command,omitempty"` + + // Data a data entry field that is preserved on a completion item between a CompletionRequest and a CompletionResolveRequest. + Data any `json:"data,omitempty"` } -// CompletionItemKind is the completion item kind values the client supports. When this -// property exists the client also guarantees that it will -// handle values outside its set gracefully and falls back -// to a default value when unknown. +// EditRangeWithInsertReplace edit range variant that includes ranges for insert and replace operations. // -// If this property is not present the client only supports -// the completion items kinds from `Text` to `Reference` as defined in -// the initial version of the protocol. -type CompletionItemKind float64 +// @since 3.18.0 +type EditRangeWithInsertReplace struct { + // @since 3.18.0 + Insert Range `json:"insert"` -const ( - // CompletionItemKindText text completion kind. - CompletionItemKindText CompletionItemKind = 1 - // CompletionItemKindMethod method completion kind. - CompletionItemKindMethod CompletionItemKind = 2 - // CompletionItemKindFunction function completion kind. - CompletionItemKindFunction CompletionItemKind = 3 - // CompletionItemKindConstructor constructor completion kind. - CompletionItemKindConstructor CompletionItemKind = 4 - // CompletionItemKindField field completion kind. - CompletionItemKindField CompletionItemKind = 5 - // CompletionItemKindVariable variable completion kind. - CompletionItemKindVariable CompletionItemKind = 6 - // CompletionItemKindClass class completion kind. - CompletionItemKindClass CompletionItemKind = 7 - // CompletionItemKindInterface interface completion kind. - CompletionItemKindInterface CompletionItemKind = 8 - // CompletionItemKindModule module completion kind. - CompletionItemKindModule CompletionItemKind = 9 - // CompletionItemKindProperty property completion kind. - CompletionItemKindProperty CompletionItemKind = 10 - // CompletionItemKindUnit unit completion kind. - CompletionItemKindUnit CompletionItemKind = 11 - // CompletionItemKindValue value completion kind. - CompletionItemKindValue CompletionItemKind = 12 - // CompletionItemKindEnum enum completion kind. - CompletionItemKindEnum CompletionItemKind = 13 - // CompletionItemKindKeyword keyword completion kind. - CompletionItemKindKeyword CompletionItemKind = 14 - // CompletionItemKindSnippet snippet completion kind. - CompletionItemKindSnippet CompletionItemKind = 15 - // CompletionItemKindColor color completion kind. - CompletionItemKindColor CompletionItemKind = 16 - // CompletionItemKindFile file completion kind. - CompletionItemKindFile CompletionItemKind = 17 - // CompletionItemKindReference reference completion kind. - CompletionItemKindReference CompletionItemKind = 18 - // CompletionItemKindFolder folder completion kind. - CompletionItemKindFolder CompletionItemKind = 19 - // CompletionItemKindEnumMember enum member completion kind. - CompletionItemKindEnumMember CompletionItemKind = 20 - // CompletionItemKindConstant constant completion kind. - CompletionItemKindConstant CompletionItemKind = 21 - // CompletionItemKindStruct struct completion kind. - CompletionItemKindStruct CompletionItemKind = 22 - // CompletionItemKindEvent event completion kind. - CompletionItemKindEvent CompletionItemKind = 23 - // CompletionItemKindOperator operator completion kind. - CompletionItemKindOperator CompletionItemKind = 24 - // CompletionItemKindTypeParameter type parameter completion kind. - CompletionItemKindTypeParameter CompletionItemKind = 25 -) + // @since 3.18.0 + Replace Range `json:"replace"` +} -// String implements fmt.Stringer. -// -//nolint:cyclop -func (k CompletionItemKind) String() string { - switch k { - case CompletionItemKindText: - return "Text" - case CompletionItemKindMethod: - return "Method" - case CompletionItemKindFunction: - return "Function" - case CompletionItemKindConstructor: - return "Constructor" - case CompletionItemKindField: - return "Field" - case CompletionItemKindVariable: - return "Variable" - case CompletionItemKindClass: - return "Class" - case CompletionItemKindInterface: - return "Interface" - case CompletionItemKindModule: - return "Module" - case CompletionItemKindProperty: - return "Property" - case CompletionItemKindUnit: - return "Unit" - case CompletionItemKindValue: - return "Value" - case CompletionItemKindEnum: - return "Enum" - case CompletionItemKindKeyword: - return "Keyword" - case CompletionItemKindSnippet: - return "Snippet" - case CompletionItemKindColor: - return "Color" - case CompletionItemKindFile: - return "File" - case CompletionItemKindReference: - return "Reference" - case CompletionItemKindFolder: - return "Folder" - case CompletionItemKindEnumMember: - return "EnumMember" - case CompletionItemKindConstant: - return "Constant" - case CompletionItemKindStruct: - return "Struct" - case CompletionItemKindEvent: - return "Event" - case CompletionItemKindOperator: - return "Operator" - case CompletionItemKindTypeParameter: - return "TypeParameter" - default: - return strconv.FormatFloat(float64(k), 'f', -10, 64) - } -} - -// CompletionItemTag completion item tags are extra annotations that tweak the rendering of a completion -// item. -// -// @since 3.15.0. -type CompletionItemTag float64 - -// list of CompletionItemTag. -const ( - // CompletionItemTagDeprecated is the render a completion as obsolete, usually using a strike-out. - CompletionItemTagDeprecated CompletionItemTag = 1 -) +// CompletionItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to "replace". Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability. +// +// @since 3.17.0 +type CompletionItemDefaults struct { + // CommitCharacters a default commit character set. + // @since 3.17.0 + CommitCharacters []string `json:"commitCharacters,omitempty"` -// String returns a string representation of the type. -func (c CompletionItemTag) String() string { - switch c { - case CompletionItemTagDeprecated: - return "Deprecated" - default: - return strconv.FormatFloat(float64(c), 'f', -10, 64) - } -} + // EditRange a default edit range. + // @since 3.17.0 + EditRange *CompletionItemDefaultsEditRange `json:"editRange,omitempty"` -// CompletionRegistrationOptions CompletionRegistration options. -type CompletionRegistrationOptions struct { - TextDocumentRegistrationOptions + // InsertTextFormat a default insert text format. + // @since 3.17.0 + InsertTextFormat InsertTextFormat `json:"insertTextFormat,omitempty"` - // TriggerCharacters most tools trigger completion request automatically without explicitly requesting - // it using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user - // starts to type an identifier. For example if the user types `c` in a JavaScript file - // code complete will automatically pop up present `console` besides others as a - // completion item. Characters that make up identifiers don't need to be listed here. - // - // If code complete should automatically be trigger on characters not being valid inside - // an identifier (for example `.` in JavaScript) list them in `triggerCharacters`. - TriggerCharacters []string `json:"triggerCharacters,omitempty"` + // InsertTextMode a default insert text mode. + // @since 3.17.0 + InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"` - // ResolveProvider is the server provides support to resolve additional - // information for a completion item. - ResolveProvider bool `json:"resolveProvider,omitempty"` + // Data a default data value. + // @since 3.17.0 + Data any `json:"data,omitempty"` } -// HoverParams params of Hover request. +// CompletionItemApplyKinds specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as "replace". If a field's value is "replace", the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is "merge", the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability. // -// @since 3.15.0. -type HoverParams struct { - TextDocumentPositionParams - WorkDoneProgressParams +// @since 3.18.0 +type CompletionItemApplyKinds struct { + // CommitCharacters specifies whether commitCharacters on a completion will replace or be merged with those in `completionList.itemDefaults.commitCharacters`. If "replace", the commit characters from the completion item will always be used unless not provided, in which case those from `completionList.itemDefaults.commitCharacters` will be used. An empty list can be used if a completion item does not have any commit characters and also should not use those from `completionList.itemDefaults.commitCharacters`. If "merge" the commitCharacters for the completion will be the union of all values in both `completionList.itemDefaults.commitCharacters` and the completion's own `commitCharacters`. + // @since 3.18.0 + CommitCharacters ApplyKind `json:"commitCharacters,omitempty"` + + // Data specifies whether the `data` field on a completion will replace or be merged with data from `completionList.itemDefaults.data`. If "replace", the data from the completion item will be used if provided + // (and not `null`), otherwise `completionList.itemDefaults.data` will be used. An empty object can be used if a completion item does not have any data but also should not use the value from `completionList.itemDefaults.data`. If "merge", a shallow merge will be performed between `completionList.itemDefaults.data` and the completion's own data using the following rules: - If a completion's `data` field is not provided (or `null`), the entire `data` field from `completionList.itemDefaults.data` will be used as-is. - If a completion's `data` field is provided, each field will overwrite the field of the same name in `completionList.itemDefaults.data` but no merging of nested fields within that value will occur. + // @since 3.18.0 + Data ApplyKind `json:"data,omitempty"` } -// Hover is the result of a hover request. -type Hover struct { - // Contents is the hover's content - Contents MarkupContent `json:"contents"` +// CompletionList represents a collection of CompletionItem completion items to be presented in the editor. +type CompletionList struct { + // IsIncomplete this list it not complete. Further typing results in recomputing this list. Recomputed lists have all their items replaced (not appended) in the incomplete completion sessions. + IsIncomplete bool `json:"isIncomplete"` - // Range an optional range is a range inside a text document - // that is used to visualize a hover, e.g. by changing the background color. - Range *Range `json:"range,omitempty"` + // ItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to "replace". Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability. + ItemDefaults *CompletionItemDefaults `json:"itemDefaults,omitempty"` + + // ApplyKind specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as "replace". If a field's value is "replace", the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is "merge", the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability. + ApplyKind *CompletionItemApplyKinds `json:"applyKind,omitempty"` + + // Items the completion items. + Items []CompletionItem `json:"items"` } -// SignatureHelpParams params of SignatureHelp request. -// -// @since 3.15.0. -type SignatureHelpParams struct { +// CompletionRegistrationOptions registration options for a CompletionRequest. +type CompletionRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + CompletionOptions +} + +// HoverParams parameters for a HoverRequest. +type HoverParams struct { + // extends TextDocumentPositionParams + // mixins WorkDoneProgressParams - - // context is the signature help context. - // - // This is only available if the client specifies to send this using the - // client capability `textDocument.signatureHelp.contextSupport === true`. - // - // @since 3.15.0. - Context *SignatureHelpContext `json:"context,omitempty"` } -// SignatureHelpTriggerKind is the how a signature help was triggered. -// -// @since 3.15.0. -type SignatureHelpTriggerKind float64 +// Hover the result of a hover request. +type Hover struct { + // Contents the hover's content. + Contents HoverContents `json:"contents"` -// list of SignatureHelpTriggerKind. -const ( - // SignatureHelpTriggerKindInvoked is the signature help was invoked manually by the user or by a command. - SignatureHelpTriggerKindInvoked SignatureHelpTriggerKind = 1 + // Range an optional range inside the text document that is used to visualize the hover, e.g. by changing the + // background color. + Range *Range `json:"range,omitempty"` +} - // SignatureHelpTriggerKindTriggerCharacter is the signature help was triggered by a trigger character. - SignatureHelpTriggerKindTriggerCharacter SignatureHelpTriggerKind = 2 +// HoverRegistrationOptions registration options for a HoverRequest. +type HoverRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + HoverOptions +} - // SignatureHelpTriggerKindContentChange is the signature help was triggered by the cursor moving or - // by the document content changing. - SignatureHelpTriggerKindContentChange SignatureHelpTriggerKind = 3 -) +// ParameterInformation represents a parameter of a callable-signature. A parameter can have a label and a doc-comment. +type ParameterInformation struct { + // Label the label of this parameter information. Either a string or an inclusive start and exclusive end offsets within its containing signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 string representation as `Position` and `Range` does. To avoid ambiguities a server should use the [start, end] offset value instead of using a substring. Whether a client support this is controlled via `labelOffsetSupport` client capability. *Note*: a label of type string should be a substring of its containing signature label. Its intended use case is to highlight the parameter label + // part in the `SignatureInformation.label`. + Label ParameterInformationLabel `json:"label"` -// String returns a string representation of the type. -func (s SignatureHelpTriggerKind) String() string { - switch s { - case SignatureHelpTriggerKindInvoked: - return "Invoked" - case SignatureHelpTriggerKindTriggerCharacter: - return "TriggerCharacter" - case SignatureHelpTriggerKindContentChange: - return "ContentChange" - default: - return strconv.FormatFloat(float64(s), 'f', -10, 64) - } + // Documentation the human-readable doc-comment of this parameter. Will be shown in the UI but can be omitted. + Documentation *ParameterInformationDocumentation `json:"documentation,omitempty"` } -// SignatureHelpContext is the additional information about the context in which a -// signature help request was triggered. -// -// @since 3.15.0. -type SignatureHelpContext struct { - // TriggerKind is the action that caused signature help to be triggered. - TriggerKind SignatureHelpTriggerKind `json:"triggerKind"` +// SignatureInformation represents the signature of something callable. A signature can have a label, like a function-name, a doc-comment, and a set of parameters. +type SignatureInformation struct { + // Label the label of this signature. Will be shown in the UI. + Label string `json:"label"` - // Character that caused signature help to be triggered. - // - // This is undefined when - // TriggerKind != SignatureHelpTriggerKindTriggerCharacter - TriggerCharacter string `json:"triggerCharacter,omitempty"` + // Documentation the human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. + Documentation *SignatureInformationDocumentation `json:"documentation,omitempty"` - // IsRetrigger is the `true` if signature help was already showing when it was triggered. - // - // Retriggers occur when the signature help is already active and can be - // caused by actions such as typing a trigger character, a cursor move, - // or document content changes. - IsRetrigger bool `json:"isRetrigger"` + // Parameters the parameters of this signature. + Parameters []ParameterInformation `json:"parameters,omitempty"` - // ActiveSignatureHelp is the currently active SignatureHelp. - // - // The `activeSignatureHelp` has its `SignatureHelp.activeSignature` field - // updated based on the user navigating through available signatures. - ActiveSignatureHelp *SignatureHelp `json:"activeSignatureHelp,omitempty"` + // ActiveParameter the index of the active parameter. If `null`, no parameter of the signature is active (for example a + // named argument that does not match any declared parameters). This is only valid if the client specifies the client capability `textDocument.signatureHelp.noActiveParameterSupport === true` If provided (or `null`), this is used in place of `SignatureHelp.activeParameter`. + ActiveParameter uint32 `json:"activeParameter,omitempty"` } -// SignatureHelp signature help represents the signature of something -// callable. There can be multiple signature but only one -// active and only one active parameter. +// SignatureHelp signature help represents the signature of something callable. There can be multiple signature but only one active and only one active parameter. type SignatureHelp struct { // Signatures one or more signatures. Signatures []SignatureInformation `json:"signatures"` - // ActiveParameter is the active parameter of the active signature. If omitted or the value - // lies outside the range of `signatures[activeSignature].parameters` - // defaults to 0 if the active signature has parameters. If - // the active signature has no parameters it is ignored. - // In future version of the protocol this property might become - // mandatory to better express the active parameter if the - // active signature does have any. - ActiveParameter uint32 `json:"activeParameter,omitempty"` - - // ActiveSignature is the active signature. If omitted or the value lies outside the - // range of `signatures` the value defaults to zero or is ignored if - // `signatures.length === 0`. Whenever possible implementors should - // make an active decision about the active signature and shouldn't - // rely on a default value. - // In future version of the protocol this property might become - // mandatory to better express this. + // ActiveSignature the active signature. If omitted or the value lies outside the range of `signatures` the value defaults to zero or is ignored if the `SignatureHelp` has no signatures. Whenever possible implementors should make an active decision about the active signature and shouldn't rely on a default value. In future version of the protocol this property might become mandatory to better express this. ActiveSignature uint32 `json:"activeSignature,omitempty"` + + // ActiveParameter the active parameter of the active signature. If `null`, no parameter of the signature is active (for example a named argument that does not match any declared parameters). This is only valid if the client specifies the client capability `textDocument.signatureHelp.noActiveParameterSupport === true` + // If omitted or the value lies outside the range of `signatures[activeSignature].parameters` defaults to 0 if the active signature has parameters. If the active signature has no parameters it is ignored. In future version of the protocol this property might become mandatory (but still nullable) to better express the active parameter if the active signature does have any. + ActiveParameter uint32 `json:"activeParameter,omitempty"` } -// SignatureInformation is the client supports the following `SignatureInformation` -// specific properties. -type SignatureInformation struct { - // Label is the label of this signature. Will be shown in - // the UI. +// SignatureHelpContext additional information about the context in which a signature help request was triggered. +// +// @since 3.15.0 +type SignatureHelpContext struct { + // TriggerKind action that caused signature help to be triggered. // - // @since 3.16.0. - Label string `json:"label"` + // @since 3.15.0 + TriggerKind SignatureHelpTriggerKind `json:"triggerKind"` - // Documentation is the human-readable doc-comment of this signature. Will be shown - // in the UI but can be omitted. + // TriggerCharacter character that caused signature help to be triggered. This is undefined when `triggerKind !== SignatureHelpTriggerKind.TriggerCharacter`. // - // @since 3.16.0. - Documentation interface{} `json:"documentation,omitempty"` // string | *MarkupContent + // @since 3.15.0 + TriggerCharacter string `json:"triggerCharacter,omitempty"` - // Parameters is the parameters of this signature. + // IsRetrigger `true` if signature help was already showing when it was triggered. Retriggers occurs when the signature help is already active and can be caused by actions such as typing a trigger character, a cursor move, or document content changes. // - // @since 3.16.0. - Parameters []ParameterInformation `json:"parameters,omitempty"` + // @since 3.15.0 + IsRetrigger bool `json:"isRetrigger"` - // ActiveParameterSupport is the client supports the `activeParameter` property on - // `SignatureInformation` literal. + // ActiveSignatureHelp the currently active `SignatureHelp`. The `activeSignatureHelp` has its `SignatureHelp.activeSignature` field updated based on the user navigating through available signatures. // - // @since 3.16.0. - ActiveParameter uint32 `json:"activeParameter,omitempty"` + // @since 3.15.0 + ActiveSignatureHelp *SignatureHelp `json:"activeSignatureHelp,omitempty"` } -// ParameterInformation represents a parameter of a callable-signature. A parameter can -// have a label and a doc-comment. -type ParameterInformation struct { - // Label is the label of this parameter information. - // - // Either a string or an inclusive start and exclusive end offsets within its containing - // signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 - // string representation as "Position" and "Range" does. - // - // *Note*: a label of type string should be a substring of its containing signature label. - // Its intended use case is to highlight the parameter label part in the "SignatureInformation.label". - Label string `json:"label"` // string | [uint32, uint32] +// SignatureHelpParams parameters for a SignatureHelpRequest. +type SignatureHelpParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams - // Documentation is the human-readable doc-comment of this parameter. Will be shown - // in the UI but can be omitted. - Documentation interface{} `json:"documentation,omitempty"` // string | MarkupContent + // Context the signature help context. This is only available if the client specifies to send this using the client capability `textDocument.signatureHelp.contextSupport === true` + Context *SignatureHelpContext `json:"context,omitempty"` } -// SignatureHelpRegistrationOptions SignatureHelp Registration options. +// SignatureHelpRegistrationOptions registration options for a SignatureHelpRequest. type SignatureHelpRegistrationOptions struct { + // extends TextDocumentRegistrationOptions - - // TriggerCharacters is the characters that trigger signature help - // automatically. - TriggerCharacters []string `json:"triggerCharacters,omitempty"` + SignatureHelpOptions } -// ReferenceParams params of References request. -// -// @since 3.15.0. -type ReferenceParams struct { +// DefinitionParams parameters for a DefinitionRequest. +type DefinitionParams struct { + // extends TextDocumentPositionParams + // mixins WorkDoneProgressParams PartialResultParams +} - // Context is the ReferenceParams context. - Context ReferenceContext `json:"context"` +// DefinitionRegistrationOptions registration options for a DefinitionRequest. +type DefinitionRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DefinitionOptions } -// ReferenceContext context of ReferenceParams. +// ReferenceContext value-object that contains additional information when requesting references. type ReferenceContext struct { // IncludeDeclaration include the declaration of the current symbol. IncludeDeclaration bool `json:"includeDeclaration"` } -// DocumentHighlight a document highlight is a range inside a text document which deserves -// special attention. Usually a document highlight is visualized by changing -// the background color of its range. -type DocumentHighlight struct { - // Range is the range this highlight applies to. - Range Range `json:"range"` +// ReferenceParams parameters for a ReferencesRequest. +type ReferenceParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams - // Kind is the highlight kind, default is DocumentHighlightKind.Text. - Kind DocumentHighlightKind `json:"kind,omitempty"` + Context ReferenceContext `json:"context"` } -// DocumentHighlightKind a document highlight kind. -type DocumentHighlightKind float64 +// ReferenceRegistrationOptions registration options for a ReferencesRequest. +type ReferenceRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + ReferenceOptions +} -const ( - // DocumentHighlightKindText a textual occurrence. - DocumentHighlightKindText DocumentHighlightKind = 1 +// DocumentHighlightParams parameters for a DocumentHighlightRequest. +type DocumentHighlightParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams + PartialResultParams +} - // DocumentHighlightKindRead read-access of a symbol, like reading a variable. - DocumentHighlightKindRead DocumentHighlightKind = 2 +// DocumentHighlight a document highlight is a range inside a text document which deserves special attention. Usually a document highlight is visualized by changing the background color of its range. +type DocumentHighlight struct { + // Range the range this highlight applies to. + Range Range `json:"range"` - // DocumentHighlightKindWrite write-access of a symbol, like writing to a variable. - DocumentHighlightKindWrite DocumentHighlightKind = 3 -) + // Kind the highlight kind, default is DocumentHighlightKind.Text text. + Kind DocumentHighlightKind `json:"kind,omitempty"` +} + +// DocumentHighlightRegistrationOptions registration options for a DocumentHighlightRequest. +type DocumentHighlightRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentHighlightOptions +} -// String implements fmt.Stringer. -func (k DocumentHighlightKind) String() string { - switch k { - case DocumentHighlightKindText: - return "Text" - case DocumentHighlightKindRead: - return "Read" - case DocumentHighlightKindWrite: - return "Write" - default: - return strconv.FormatFloat(float64(k), 'f', -10, 64) - } -} - -// DocumentSymbolParams params of Document Symbols request. +// DocumentSymbolParams parameters for a DocumentSymbolRequest. type DocumentSymbolParams struct { + // mixins WorkDoneProgressParams PartialResultParams - // TextDocument is the text document. + // TextDocument the text document. TextDocument TextDocumentIdentifier `json:"textDocument"` } -// SymbolKind specific capabilities for the `SymbolKind`. -// The symbol kind values the client supports. When this -// property exists the client also guarantees that it will -// handle values outside its set gracefully and falls back -// to a default value when unknown. -// -// If this property is not present the client only supports -// the symbol kinds from `File` to `Array` as defined in -// the initial version of the protocol. -type SymbolKind float64 +// BaseSymbolInformation a base for all symbol information. +type BaseSymbolInformation struct { + // Name the name of this symbol. + Name string `json:"name"` -const ( - // SymbolKindFile symbol of file. - SymbolKindFile SymbolKind = 1 - // SymbolKindModule symbol of module. - SymbolKindModule SymbolKind = 2 - // SymbolKindNamespace symbol of namespace. - SymbolKindNamespace SymbolKind = 3 - // SymbolKindPackage symbol of package. - SymbolKindPackage SymbolKind = 4 - // SymbolKindClass symbol of class. - SymbolKindClass SymbolKind = 5 - // SymbolKindMethod symbol of method. - SymbolKindMethod SymbolKind = 6 - // SymbolKindProperty symbol of property. - SymbolKindProperty SymbolKind = 7 - // SymbolKindField symbol of field. - SymbolKindField SymbolKind = 8 - // SymbolKindConstructor symbol of constructor. - SymbolKindConstructor SymbolKind = 9 - // SymbolKindEnum symbol of enum. - SymbolKindEnum SymbolKind = 10 - // SymbolKindInterface symbol of interface. - SymbolKindInterface SymbolKind = 11 - // SymbolKindFunction symbol of function. - SymbolKindFunction SymbolKind = 12 - // SymbolKindVariable symbol of variable. - SymbolKindVariable SymbolKind = 13 - // SymbolKindConstant symbol of constant. - SymbolKindConstant SymbolKind = 14 - // SymbolKindString symbol of string. - SymbolKindString SymbolKind = 15 - // SymbolKindNumber symbol of number. - SymbolKindNumber SymbolKind = 16 - // SymbolKindBoolean symbol of boolean. - SymbolKindBoolean SymbolKind = 17 - // SymbolKindArray symbol of array. - SymbolKindArray SymbolKind = 18 - // SymbolKindObject symbol of object. - SymbolKindObject SymbolKind = 19 - // SymbolKindKey symbol of key. - SymbolKindKey SymbolKind = 20 - // SymbolKindNull symbol of null. - SymbolKindNull SymbolKind = 21 - // SymbolKindEnumMember symbol of enum member. - SymbolKindEnumMember SymbolKind = 22 - // SymbolKindStruct symbol of struct. - SymbolKindStruct SymbolKind = 23 - // SymbolKindEvent symbol of event. - SymbolKindEvent SymbolKind = 24 - // SymbolKindOperator symbol of operator. - SymbolKindOperator SymbolKind = 25 - // SymbolKindTypeParameter symbol of type parameter. - SymbolKindTypeParameter SymbolKind = 26 -) + // Kind the kind of this symbol. + Kind SymbolKind `json:"kind"` + + // Tags tags for this symbol. + Tags []SymbolTag `json:"tags,omitempty"` -// String implements fmt.Stringer. -// -//nolint:cyclop -func (k SymbolKind) String() string { - switch k { - case SymbolKindFile: - return "File" - case SymbolKindModule: - return "Module" - case SymbolKindNamespace: - return "Namespace" - case SymbolKindPackage: - return "Package" - case SymbolKindClass: - return "Class" - case SymbolKindMethod: - return "Method" - case SymbolKindProperty: - return "Property" - case SymbolKindField: - return "Field" - case SymbolKindConstructor: - return "Constructor" - case SymbolKindEnum: - return "Enum" - case SymbolKindInterface: - return "Interface" - case SymbolKindFunction: - return "Function" - case SymbolKindVariable: - return "Variable" - case SymbolKindConstant: - return "Constant" - case SymbolKindString: - return "String" - case SymbolKindNumber: - return "Number" - case SymbolKindBoolean: - return "Boolean" - case SymbolKindArray: - return "Array" - case SymbolKindObject: - return "Object" - case SymbolKindKey: - return "Key" - case SymbolKindNull: - return "Null" - case SymbolKindEnumMember: - return "EnumMember" - case SymbolKindStruct: - return "Struct" - case SymbolKindEvent: - return "Event" - case SymbolKindOperator: - return "Operator" - case SymbolKindTypeParameter: - return "TypeParameter" - default: - return strconv.FormatFloat(float64(k), 'f', -10, 64) - } + // ContainerName the name of the symbol containing this symbol. This information is for user interface purposes (e.g. + // to render a qualifier in the user interface if necessary). It can't be used to re-infer a hierarchy for the document symbols. + ContainerName string `json:"containerName,omitempty"` } -// SymbolTag symbol tags are extra annotations that tweak the rendering of a symbol. -// -// @since 3.16.0. -type SymbolTag float64 +// SymbolInformation represents information about programming constructs like variables, classes, interfaces etc. +type SymbolInformation struct { + // extends + BaseSymbolInformation -// list of SymbolTag. -const ( - // SymbolTagDeprecated render a symbol as obsolete, usually using a strike-out. - SymbolTagDeprecated SymbolTag = 1 -) + // Deprecated indicates if this symbol is deprecated. + // + // Deprecated: Use tags instead. + Deprecated bool `json:"deprecated,omitempty"` -// String returns a string representation of the SymbolTag. -func (k SymbolTag) String() string { - switch k { - case SymbolTagDeprecated: - return "Deprecated" - default: - return strconv.FormatFloat(float64(k), 'f', -10, 64) - } + // Location the location of this symbol. The location's range is used by a tool to reveal the location in the editor. If the symbol is selected in the tool the range's start information is used to position the cursor. So the range usually spans more than the actual symbol's name and does normally include things + // like visibility modifiers. The range doesn't have to denote a node range in the sense of an abstract syntax tree. It can therefore not be used to re-construct a hierarchy of the symbols. + Location Location `json:"location"` } -// DocumentSymbol represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document symbols can be -// hierarchical and they have two ranges: one that encloses its definition and one that points to its most interesting range, -// e.g. the range of an identifier. +// DocumentSymbol represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document symbols can be hierarchical and they have two ranges: one that encloses its definition and one that points to its most interesting range, e.g. the range of an identifier. type DocumentSymbol struct { - // Name is the name of this symbol. Will be displayed in the user interface and therefore must not be - // an empty string or a string only consisting of white spaces. + // Name the name of this symbol. Will be displayed in the user interface and therefore must not be an empty string or a string only consisting of white spaces. Name string `json:"name"` - // Detail is the more detail for this symbol, e.g the signature of a function. + // Detail more detail for this symbol, e.g the signature of a function. Detail string `json:"detail,omitempty"` - // Kind is the kind of this symbol. + // Kind the kind of this symbol. Kind SymbolKind `json:"kind"` - // Tags for this document symbol. - // - // @since 3.16.0. + // Tags tags for this document symbol. Tags []SymbolTag `json:"tags,omitempty"` // Deprecated indicates if this symbol is deprecated. + // + // Deprecated: Use tags instead. Deprecated bool `json:"deprecated,omitempty"` - // Range is the range enclosing this symbol not including leading/trailing whitespace but everything else - // like comments. This information is typically used to determine if the clients cursor is - // inside the symbol to reveal in the symbol in the UI. + // Range the range enclosing this symbol not including leading/trailing whitespace but everything else like comments. This information is typically used to determine if the clients cursor is inside the symbol to reveal in the symbol in the UI. Range Range `json:"range"` - // SelectionRange is the range that should be selected and revealed when this symbol is being picked, e.g the name of a function. - // Must be contained by the `range`. + // SelectionRange the range that should be selected and revealed when this symbol is being picked, e.g the name of a function. Must be contained by the `range`. SelectionRange Range `json:"selectionRange"` // Children children of this symbol, e.g. properties of a class. Children []DocumentSymbol `json:"children,omitempty"` } -// SymbolInformation represents information about programming constructs like variables, classes, -// interfaces etc. -type SymbolInformation struct { - // Name is the name of this symbol. - Name string `json:"name"` - - // Kind is the kind of this symbol. - Kind SymbolKind `json:"kind"` - - // Tags for this completion item. - // - // @since 3.16.0. - Tags []SymbolTag `json:"tags,omitempty"` +// DocumentSymbolRegistrationOptions registration options for a DocumentSymbolRequest. +type DocumentSymbolRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentSymbolOptions +} - // Deprecated indicates if this symbol is deprecated. - Deprecated bool `json:"deprecated,omitempty"` +// CodeActionContext contains additional diagnostic information about the context in which a CodeActionProvider.provideCodeActions code action is run. +type CodeActionContext struct { + // Diagnostics an array of diagnostics known on the client side overlapping the range provided to the `textDocument/codeAction` request. They are provided so that the server knows which errors are currently presented to the user for the given range. There is no guarantee that these accurately reflect the error state of the resource. The primary parameter to compute code actions is the provided range. + Diagnostics []Diagnostic `json:"diagnostics"` - // Location is the location of this symbol. The location's range is used by a tool - // to reveal the location in the editor. If the symbol is selected in the - // tool the range's start information is used to position the cursor. So - // the range usually spans more then the actual symbol's name and does - // normally include things like visibility modifiers. - // - // The range doesn't have to denote a node range in the sense of a abstract - // syntax tree. It can therefore not be used to re-construct a hierarchy of - // the symbols. - Location Location `json:"location"` + // Only requested kind of actions to return. Actions not of this kind are filtered out by the client before being shown. So servers can omit computing them. + Only []CodeActionKind `json:"only,omitempty"` - // ContainerName is the name of the symbol containing this symbol. This information is for - // user interface purposes (e.g. to render a qualifier in the user interface - // if necessary). It can't be used to re-infer a hierarchy for the document - // symbols. - ContainerName string `json:"containerName,omitempty"` + // TriggerKind the reason why code actions were requested. + TriggerKind CodeActionTriggerKind `json:"triggerKind,omitempty"` } -// CodeActionParams params for the CodeActionRequest. +// CodeActionParams the parameters of a CodeActionRequest. type CodeActionParams struct { + // mixins WorkDoneProgressParams PartialResultParams - // TextDocument is the document in which the command was invoked. + // TextDocument the document in which the command was invoked. TextDocument TextDocumentIdentifier `json:"textDocument"` - // Context carrying additional information. - Context CodeActionContext `json:"context"` - - // Range is the range for which the command was invoked. + // Range the range for which the command was invoked. Range Range `json:"range"` -} - -// CodeActionKind is the code action kind values the client supports. When this -// property exists the client also guarantees that it will -// handle values outside its set gracefully and falls back -// to a default value when unknown. -type CodeActionKind string - -// A set of predefined code action kinds. -const ( - // QuickFix base kind for quickfix actions: 'quickfix'. - QuickFix CodeActionKind = "quickfix" - - // Refactor base kind for refactoring actions: 'refactor'. - Refactor CodeActionKind = "refactor" - - // RefactorExtract base kind for refactoring extraction actions: 'refactor.extract' - // - // Example extract actions: - // - // - Extract method - // - Extract function - // - Extract variable - // - Extract interface from class - // - ... - RefactorExtract CodeActionKind = "refactor.extract" - // RefactorInline base kind for refactoring inline actions: 'refactor.inline' - // - // Example inline actions: - // - // - Inline function - // - Inline variable - // - Inline constant - // - ... - RefactorInline CodeActionKind = "refactor.inline" - - // RefactorRewrite base kind for refactoring rewrite actions: 'refactor.rewrite' - // - // Example rewrite actions: - // - // - Convert JavaScript function to class - // - Add or remove parameter - // - Encapsulate field - // - Make method static - // - Move method to base class - // - ... - RefactorRewrite CodeActionKind = "refactor.rewrite" - - // Source base kind for source actions: `source` - // - // Source code actions apply to the entire file. - Source CodeActionKind = "source" - - // SourceOrganizeImports base kind for an organize imports source action: `source.organizeImports`. - SourceOrganizeImports CodeActionKind = "source.organizeImports" -) - -// CodeActionContext contains additional diagnostic information about the context in which -// a code action is run. -type CodeActionContext struct { - // Diagnostics is an array of diagnostics. - Diagnostics []Diagnostic `json:"diagnostics"` + // Context context carrying additional information. + Context CodeActionContext `json:"context"` +} - // Only requested kind of actions to return. +// CodeActionDisabled captures why the code action is currently disabled. +// +// @since 3.18.0 +type CodeActionDisabled struct { + // Reason human readable description of why the code action is currently disabled. This is displayed in the code actions UI. // - // Actions not of this kind are filtered out by the client before being shown. So servers - // can omit computing them. - Only []CodeActionKind `json:"only,omitempty"` + // @since 3.18.0 + Reason string `json:"reason"` } -// CodeAction capabilities specific to the `textDocument/codeAction`. +// CodeAction a code action represents a change that can be performed in code, e.g. to fix a problem or to refactor code. A CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed. type CodeAction struct { - // Title is a short, human-readable, title for this code action. + // Title a short, human-readable, title for this code action. Title string `json:"title"` - // Kind is the kind of the code action. - // - // Used to filter code actions. + // Kind the kind of the code action. Used to filter code actions. Kind CodeActionKind `json:"kind,omitempty"` - // Diagnostics is the diagnostics that this code action resolves. + // Diagnostics the diagnostics that this code action resolves. Diagnostics []Diagnostic `json:"diagnostics,omitempty"` - // IsPreferred marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted - // by keybindings. - // - // A quick fix should be marked preferred if it properly addresses the underlying error. - // A refactoring should be marked preferred if it is the most reasonable choice of actions to take. - // - // @since 3.15.0. + // IsPreferred marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted by keybindings. A quick fix should be marked preferred if it properly addresses the underlying error. A refactoring should be marked preferred if it is the most reasonable choice of actions to take. IsPreferred bool `json:"isPreferred,omitempty"` - // Disabled marks that the code action cannot currently be applied. - // - // Clients should follow the following guidelines regarding disabled code - // actions: - // - // - Disabled code actions are not shown in automatic lightbulbs code - // action menus. - // - // - Disabled actions are shown as faded out in the code action menu when - // the user request a more specific type of code action, such as - // refactorings. - // - // - If the user has a keybinding that auto applies a code action and only - // a disabled code actions are returned, the client should show the user - // an error message with `reason` in the editor. - // - // @since 3.16.0. - Disabled *CodeActionDisable `json:"disabled,omitempty"` + // Disabled marks that the code action cannot currently be applied. Clients should follow the following guidelines regarding disabled code actions: - Disabled code actions are not shown in automatic [lightbulbs](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) code action menus. - Disabled + // actions are shown as faded out in the code action menu when the user requests a more specific type of code action, such as refactorings. - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions) that auto applies a code action and only disabled code actions are returned, the client should show the user an error message with `reason` + // in the editor. + Disabled *CodeActionDisabled `json:"disabled,omitempty"` - // Edit is the workspace edit this code action performs. + // Edit the workspace edit this code action performs. Edit *WorkspaceEdit `json:"edit,omitempty"` - // Command is a command this code action executes. If a code action - // provides an edit and a command, first the edit is - // executed and then the command. + // Command a command this code action executes. If a code action provides an edit and a command, first the edit + // is executed and then the command. Command *Command `json:"command,omitempty"` - // Data is a data entry field that is preserved on a code action between - // a "textDocument/codeAction" and a "codeAction/resolve" request. - // - // @since 3.16.0. - Data interface{} `json:"data,omitempty"` -} + // Data a data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request. + Data any `json:"data,omitempty"` -// CodeActionDisable Disable in CodeAction. -// -// @since 3.16.0. -type CodeActionDisable struct { - // Reason human readable description of why the code action is currently - // disabled. - // - // This is displayed in the code actions UI. - Reason string `json:"reason"` + // Tags tags for this code action. 3.18.0 - proposed. + Tags []CodeActionTag `json:"tags,omitempty"` } -// CodeActionRegistrationOptions CodeAction Registrationi options. +// CodeActionRegistrationOptions registration options for a CodeActionRequest. type CodeActionRegistrationOptions struct { + // extends TextDocumentRegistrationOptions - CodeActionOptions } -// CodeLensParams params of Code Lens request. +// LocationURIOnly location with only uri and does not include range. +// +// @since 3.18.0 +type LocationURIOnly struct { + // @since 3.18.0 + URI DocumentURI `json:"uri"` +} + +// CodeLensParams the parameters of a CodeLensRequest. type CodeLensParams struct { + // mixins WorkDoneProgressParams PartialResultParams - // TextDocument is the document to request code lens for. + // TextDocument the document to request code lens for. TextDocument TextDocumentIdentifier `json:"textDocument"` } -// CodeLens is a code lens represents a command that should be shown along with -// source text, like the number of references, a way to run tests, etc. -// -// A code lens is _unresolved_ when no command is associated to it. For performance -// reasons the creation of a code lens and resolving should be done in two stages. +// CodeLens a code lens represents a Command command that should be shown along with source text, like the number of references, a way to run tests, etc. A code lens is _unresolved_ when no command is associated to it. For performance reasons the creation of a code lens and resolving should be done in two stages. type CodeLens struct { - // Range is the range in which this code lens is valid. Should only span a single line. + // Range the range in which this code lens is valid. Should only span a single line. Range Range `json:"range"` - // Command is the command this code lens represents. + // Command the command this code lens represents. Command *Command `json:"command,omitempty"` - // Data is a data entry field that is preserved on a code lens item between - // a code lens and a code lens resolve request. - Data interface{} `json:"data,omitempty"` + // Data a data entry field that is preserved on a code lens item between a CodeLensRequest and a CodeLensResolveRequest. + Data any `json:"data,omitempty"` } -// CodeLensRegistrationOptions CodeLens Registration options. +// CodeLensRegistrationOptions registration options for a CodeLensRequest. type CodeLensRegistrationOptions struct { + // extends TextDocumentRegistrationOptions - - // ResolveProvider code lens has a resolve provider as well. - ResolveProvider bool `json:"resolveProvider,omitempty"` + CodeLensOptions } -// DocumentLinkParams params of Document Link request. +// DocumentLinkParams the parameters of a DocumentLinkRequest. type DocumentLinkParams struct { + // mixins WorkDoneProgressParams PartialResultParams - // TextDocument is the document to provide document links for. + // TextDocument the document to provide document links for. TextDocument TextDocumentIdentifier `json:"textDocument"` } -// DocumentLink is a document link is a range in a text document that links to an internal or external resource, like another -// text document or a web site. +// DocumentLink a document link is a range in a text document that links to an internal or external resource, like another text document or a web site. type DocumentLink struct { - // Range is the range this link applies to. + // Range the range this link applies to. Range Range `json:"range"` - // Target is the uri this link points to. If missing a resolve request is sent later. - Target DocumentURI `json:"target,omitempty"` + // Target the uri this link points to. If missing a resolve request is sent later. + Target uri.URI `json:"target,omitempty"` - // Tooltip is the tooltip text when you hover over this link. - // - // If a tooltip is provided, is will be displayed in a string that includes instructions on how to - // trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS, - // user settings, and localization. - // - // @since 3.15.0. + // Tooltip the tooltip text when you hover over this link. If a tooltip is provided, is will be displayed in a string that includes instructions on how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS, user settings, and localization. Tooltip string `json:"tooltip,omitempty"` - // Data is a data entry field that is preserved on a document link between a - // DocumentLinkRequest and a DocumentLinkResolveRequest. - Data interface{} `json:"data,omitempty"` + // Data a data entry field that is preserved on a document link between a DocumentLinkRequest and a DocumentLinkResolveRequest. + Data any `json:"data,omitempty"` } -// DocumentColorParams params of Document Color request. -type DocumentColorParams struct { +// DocumentLinkRegistrationOptions registration options for a DocumentLinkRequest. +type DocumentLinkRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentLinkOptions +} + +// FormattingOptions value-object describing what options formatting should use. +type FormattingOptions struct { + // TabSize size of a tab in spaces. + TabSize uint32 `json:"tabSize"` + + // InsertSpaces prefer spaces over tabs. + InsertSpaces bool `json:"insertSpaces"` + + // TrimTrailingWhitespace trim trailing whitespace on a line. + TrimTrailingWhitespace bool `json:"trimTrailingWhitespace,omitempty"` + + // InsertFinalNewline insert a newline character at the end of the file if one does not exist. + InsertFinalNewline bool `json:"insertFinalNewline,omitempty"` + + // TrimFinalNewlines trim all newlines after the final newline at the end of the file. + TrimFinalNewlines bool `json:"trimFinalNewlines,omitempty"` +} + +// DocumentFormattingParams the parameters of a DocumentFormattingRequest. +type DocumentFormattingParams struct { + // mixins WorkDoneProgressParams - PartialResultParams - // TextDocument is the document to format. + // TextDocument the document to format. TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Options the format options. + Options FormattingOptions `json:"options"` } -// ColorInformation response of Document Color request. -type ColorInformation struct { - // Range is the range in the document where this color appears. +// DocumentFormattingRegistrationOptions registration options for a DocumentFormattingRequest. +type DocumentFormattingRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentFormattingOptions +} + +// DocumentRangeFormattingParams the parameters of a DocumentRangeFormattingRequest. +type DocumentRangeFormattingParams struct { + // mixins + WorkDoneProgressParams + + // TextDocument the document to format. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Range the range to format. Range Range `json:"range"` - // Color is the actual color value for this color range. - Color Color `json:"color"` + // Options the format options. + Options FormattingOptions `json:"options"` } -// Color represents a color in RGBA space. -type Color struct { - // Alpha is the alpha component of this color in the range [0-1]. - Alpha float64 `json:"alpha"` +// DocumentRangeFormattingRegistrationOptions registration options for a DocumentRangeFormattingRequest. +type DocumentRangeFormattingRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentRangeFormattingOptions +} - // Blue is the blue component of this color in the range [0-1]. - Blue float64 `json:"blue"` +// DocumentRangesFormattingParams the parameters of a DocumentRangesFormattingRequest. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type DocumentRangesFormattingParams struct { + // mixins + WorkDoneProgressParams - // Green is the green component of this color in the range [0-1]. - Green float64 `json:"green"` + // TextDocument the document to format. + // + // @since 3.18.0 proposed + TextDocument TextDocumentIdentifier `json:"textDocument"` - // Red is the red component of this color in the range [0-1]. - Red float64 `json:"red"` + // Ranges the ranges to format. + // + // @since 3.18.0 proposed + Ranges []Range `json:"ranges"` + + // Options the format options. + // + // @since 3.18.0 proposed + Options FormattingOptions `json:"options"` } -// ColorPresentationParams params of Color Presentation request. -type ColorPresentationParams struct { +// DocumentOnTypeFormattingParams the parameters of a DocumentOnTypeFormattingRequest. +type DocumentOnTypeFormattingParams struct { + // TextDocument the document to format. + TextDocument TextDocumentIdentifier `json:"textDocument"` + + // Position the position around which the on type formatting should happen. This is not necessarily the exact position where the character denoted by the property `ch` got typed. + Position Position `json:"position"` + + // Ch the character that has been typed that triggered the formatting on type request. That is not necessarily the last character that got inserted into the document since the client could auto insert characters as well (e.g. like automatic brace completion). + Ch string `json:"ch"` + + // Options the formatting options. + Options FormattingOptions `json:"options"` +} + +// DocumentOnTypeFormattingRegistrationOptions registration options for a DocumentOnTypeFormattingRequest. +type DocumentOnTypeFormattingRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + DocumentOnTypeFormattingOptions +} + +// RenameParams the parameters of a RenameRequest. +type RenameParams struct { + // mixins WorkDoneProgressParams - PartialResultParams - // TextDocument is the text document. + // TextDocument the document to rename. TextDocument TextDocumentIdentifier `json:"textDocument"` - // Color is the color information to request presentations for. - Color Color `json:"color"` + // Position the position at which this request was sent. + Position Position `json:"position"` - // Range is the range where the color would be inserted. Serves as a context. - Range Range `json:"range"` + // NewName the new name of the symbol. If the given name is not valid the request must return a ResponseError with an appropriate message set. + NewName string `json:"newName"` } -// ColorPresentation response of Color Presentation request. -type ColorPresentation struct { - // Label is the label of this color presentation. It will be shown on the color - // picker header. By default this is also the text that is inserted when selecting - // this color presentation. - Label string `json:"label"` - - // TextEdit an edit which is applied to a document when selecting - // this presentation for the color. When `falsy` the label is used. - TextEdit *TextEdit `json:"textEdit,omitempty"` +// RenameRegistrationOptions registration options for a RenameRequest. +type RenameRegistrationOptions struct { + // extends + TextDocumentRegistrationOptions + RenameOptions +} - // AdditionalTextEdits an optional array of additional [text edits](#TextEdit) that are applied when - // selecting this color presentation. Edits must not overlap with the main [edit](#ColorPresentation.textEdit) nor with themselves. - AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"` +type PrepareRenameParams struct { + // extends + TextDocumentPositionParams + // mixins + WorkDoneProgressParams } -// DocumentFormattingParams params of Document Formatting request. -type DocumentFormattingParams struct { +// ExecuteCommandParams the parameters of a ExecuteCommandRequest. +type ExecuteCommandParams struct { + // mixins WorkDoneProgressParams - // Options is the format options. - Options FormattingOptions `json:"options"` + // Command the identifier of the actual command handler. + Command string `json:"command"` - // TextDocument is the document to format. - TextDocument TextDocumentIdentifier `json:"textDocument"` + // Arguments arguments that the command should be invoked with. + Arguments []any `json:"arguments,omitempty"` } -// FormattingOptions value-object describing what options formatting should use. -type FormattingOptions struct { - // InsertSpaces prefer spaces over tabs. - InsertSpaces bool `json:"insertSpaces"` +// ExecuteCommandRegistrationOptions registration options for a ExecuteCommandRequest. +type ExecuteCommandRegistrationOptions struct { + // extends + ExecuteCommandOptions +} - // TabSize size of a tab in spaces. - TabSize uint32 `json:"tabSize"` +// InlineValueText provide inline value as text. +// +// @since 3.17.0 +type InlineValueText struct { + // Range the document range for which the inline value applies. + // + // @since 3.17.0 + Range Range `json:"range"` - // TrimTrailingWhitespace trim trailing whitespaces on a line. + // Text the text of the inline value. // - // @since 3.15.0. - TrimTrailingWhitespace bool `json:"trimTrailingWhitespace,omitempty"` + // @since 3.17.0 + Text string `json:"text"` +} - // InsertFinalNewlines insert a newline character at the end of the file if one does not exist. +// InlineValueVariableLookup provide inline value through a variable lookup. If only a range is specified, the variable name will +// be extracted from the underlying document. An optional variable name can be used to override the extracted name. +// +// @since 3.17.0 +type InlineValueVariableLookup struct { + // Range the document range for which the inline value applies. The range is used to extract the variable name from the underlying document. // - // @since 3.15.0. - InsertFinalNewline bool `json:"insertFinalNewline,omitempty"` + // @since 3.17.0 + Range Range `json:"range"` - // TrimFinalNewlines trim all newlines after the final newline at the end of the file. + // VariableName if specified the name of the variable to look up. // - // @since 3.15.0. - TrimFinalNewlines bool `json:"trimFinalNewlines,omitempty"` + // @since 3.17.0 + VariableName string `json:"variableName,omitempty"` - // Key is the signature for further properties. - Key map[string]interface{} `json:"key,omitempty"` // bool | int32 | string + // CaseSensitiveLookup how to perform the lookup. + // + // @since 3.17.0 + CaseSensitiveLookup bool `json:"caseSensitiveLookup"` } -// DocumentRangeFormattingParams params of Document Range Formatting request. -type DocumentRangeFormattingParams struct { - WorkDoneProgressParams - - // TextDocument is the document to format. - TextDocument TextDocumentIdentifier `json:"textDocument"` - - // Range is the range to format +// InlineValueEvaluatableExpression provide an inline value through an expression evaluation. If only a range is specified, the expression will be extracted from the underlying document. An optional expression can be used to override the extracted expression. +// +// @since 3.17.0 +type InlineValueEvaluatableExpression struct { + // Range the document range for which the inline value applies. The range is used to extract the evaluatable expression from the underlying document. + // + // @since 3.17.0 Range Range `json:"range"` - // Options is the format options. - Options FormattingOptions `json:"options"` + // Expression if specified the expression overrides the extracted expression. + // + // @since 3.17.0 + Expression string `json:"expression,omitempty"` } -// DocumentOnTypeFormattingParams params of Document on Type Formatting request. -type DocumentOnTypeFormattingParams struct { - // TextDocument is the document to format. - TextDocument TextDocumentIdentifier `json:"textDocument"` +// RelatedFullDocumentDiagnosticReport a full diagnostic report with a set of related documents. +// +// @since 3.17.0 +type RelatedFullDocumentDiagnosticReport struct { + // extends + FullDocumentDiagnosticReport + + // RelatedDocuments 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]*RelatedFullDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` +} - // Position is the position at which this request was sent. - Position Position `json:"position"` +// RelatedUnchangedDocumentDiagnosticReport an unchanged diagnostic report with a set of related documents. +// +// @since 3.17.0 +type RelatedUnchangedDocumentDiagnosticReport struct { + // extends + UnchangedDocumentDiagnosticReport + + // RelatedDocuments 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]*RelatedUnchangedDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` +} - // Ch is the character that has been typed. - Ch string `json:"ch"` +// PrepareRenamePlaceholder. +// +// @since 3.18.0 +type PrepareRenamePlaceholder struct { + // @since 3.18.0 + Range Range `json:"range"` - // Options is the format options. - Options FormattingOptions `json:"options"` + // @since 3.18.0 + Placeholder string `json:"placeholder"` } -// DocumentOnTypeFormattingRegistrationOptions DocumentOnTypeFormatting Registration options. -type DocumentOnTypeFormattingRegistrationOptions struct { - TextDocumentRegistrationOptions +// PrepareRenameDefaultBehavior. +// +// @since 3.18.0 +type PrepareRenameDefaultBehavior struct { + // @since 3.18.0 + DefaultBehavior bool `json:"defaultBehavior"` +} - // FirstTriggerCharacter a character on which formatting should be triggered, like `}`. - FirstTriggerCharacter string `json:"firstTriggerCharacter"` +// WorkspaceFullDocumentDiagnosticReport a full document diagnostic report for a workspace diagnostic result. +// +// @since 3.17.0 +type WorkspaceFullDocumentDiagnosticReport struct { + // extends + FullDocumentDiagnosticReport + + // URI the URI for which diagnostic information is reported. + // + // @since 3.17.0 + URI DocumentURI `json:"uri"` - // MoreTriggerCharacter a More trigger characters. - MoreTriggerCharacter []string `json:"moreTriggerCharacter"` + // Version the version number for which the diagnostics are reported. If the document is not marked as open `null` can be provided. + // + // @since 3.17.0 + Version int32 `json:"version,omitempty"` } -// RenameParams params of Rename request. -type RenameParams struct { - TextDocumentPositionParams - PartialResultParams +// WorkspaceUnchangedDocumentDiagnosticReport an unchanged document diagnostic report for a workspace diagnostic result. +// +// @since 3.17.0 +type WorkspaceUnchangedDocumentDiagnosticReport struct { + // extends + UnchangedDocumentDiagnosticReport - // NewName is the new name of the symbol. If the given name is not valid the - // request must return a [ResponseError](#ResponseError) with an - // appropriate message set. - NewName string `json:"newName"` + // URI the URI for which diagnostic information is reported. + // + // @since 3.17.0 + URI DocumentURI `json:"uri"` + + // Version the version number for which the diagnostics are reported. If the document is not marked as open `null` can be provided. + // + // @since 3.17.0 + Version int32 `json:"version,omitempty"` } -// RenameRegistrationOptions Rename Registration options. -type RenameRegistrationOptions struct { - TextDocumentRegistrationOptions +// TextDocumentContentChangePartial. +// +// @since 3.18.0 +type TextDocumentContentChangePartial struct { + // Range the range of the document that changed. + // + // @since 3.18.0 + Range Range `json:"range"` - // PrepareProvider is the renames should be checked and tested for validity before being executed. - PrepareProvider bool `json:"prepareProvider,omitempty"` + // RangeLength the optional length of the range that got replaced. + // + // Deprecated: use range instead. + // + // @since 3.18.0 + RangeLength uint32 `json:"rangeLength,omitempty"` + + // Text the new text for the provided range. + // + // @since 3.18.0 + Text string `json:"text"` } -// PrepareRenameParams params of PrepareRenameParams request. +// TextDocumentContentChangeWholeDocument. // -// @since 3.15.0. -type PrepareRenameParams struct { - TextDocumentPositionParams +// @since 3.18.0 +type TextDocumentContentChangeWholeDocument struct { + // Text the new text of the whole document. + // + // @since 3.18.0 + Text string `json:"text"` } -// FoldingRangeParams params of Folding Range request. -type FoldingRangeParams struct { - TextDocumentPositionParams - PartialResultParams +// MarkedStringWithLanguage. +// +// @since 3.18.0 +type MarkedStringWithLanguage struct { + // @since 3.18.0 + Language string `json:"language"` + + // @since 3.18.0 + Value string `json:"value"` } -// FoldingRangeKind is the enum of known range kinds. -type FoldingRangeKind string +// NotebookCellTextDocumentFilter a notebook cell text document filter denotes a cell text document by different properties. +// +// @since 3.17.0 +type NotebookCellTextDocumentFilter struct { + // Notebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. + // + // @since 3.17.0 + Notebook NotebookCellTextDocumentFilterNotebook `json:"notebook"` -const ( - // CommentFoldingRange is the folding range for a comment. - CommentFoldingRange FoldingRangeKind = "comment" + // Language a language id like `python`. Will be matched against the language id of the notebook cell document. '*' matches every language. + // + // @since 3.17.0 + Language string `json:"language,omitempty"` +} - // ImportsFoldingRange is the folding range for a imports or includes. - ImportsFoldingRange FoldingRangeKind = "imports" +// TextDocumentFilterLanguage a document filter where `language` is required field. +// +// @since 3.18.0 +type TextDocumentFilterLanguage struct { + // Language a language id, like `typescript`. + // + // @since 3.18.0 + Language string `json:"language"` - // RegionFoldingRange is the folding range for a region (e.g. `#region`). - RegionFoldingRange FoldingRangeKind = "region" -) + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 + Scheme string `json:"scheme,omitempty"` + + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. + // @since 3.18.0 + Pattern *GlobPattern `json:"pattern,omitempty"` +} -// FoldingRange capabilities specific to `textDocument/foldingRange` requests. +// TextDocumentFilterScheme a document filter where `scheme` is required field. // -// @since 3.10.0. -type FoldingRange struct { - // StartLine is the zero-based line number from where the folded range starts. - StartLine uint32 `json:"startLine"` +// @since 3.18.0 +type TextDocumentFilterScheme struct { + // Language a language id, like `typescript`. + // + // @since 3.18.0 + Language string `json:"language,omitempty"` - // StartCharacter is the zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line. - StartCharacter uint32 `json:"startCharacter,omitempty"` + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 + Scheme string `json:"scheme"` - // EndLine is the zero-based line number where the folded range ends. - EndLine uint32 `json:"endLine"` + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. + // @since 3.18.0 + Pattern *GlobPattern `json:"pattern,omitempty"` +} - // EndCharacter is the zero-based character offset before the folded range ends. If not defined, defaults to the length of the end line. - EndCharacter uint32 `json:"endCharacter,omitempty"` +// TextDocumentFilterPattern a document filter where `pattern` is required field. +// +// @since 3.18.0 +type TextDocumentFilterPattern struct { + // Language a language id, like `typescript`. + // + // @since 3.18.0 + Language string `json:"language,omitempty"` - // Kind describes the kind of the folding range such as `comment' or 'region'. The kind - // is used to categorize folding ranges and used by commands like 'Fold all comments'. - // See FoldingRangeKind for an enumeration of standardized kinds. - Kind FoldingRangeKind `json:"kind,omitempty"` + // Scheme a Uri Uri.scheme scheme, like `file` or `untitled`. + // + // @since 3.18.0 + Scheme string `json:"scheme,omitempty"` + + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. + // @since 3.18.0 + Pattern GlobPattern `json:"pattern"` } diff --git a/language_test.go b/language_test.go deleted file mode 100644 index 4bc95ec0..00000000 --- a/language_test.go +++ /dev/null @@ -1,5852 +0,0 @@ -// SPDX-FileCopyrightText: 2020 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "strings" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/segmentio/encoding/json" - - "go.lsp.dev/uri" -) - -func TestCompletionParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/test.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","context":{"triggerCharacter":".","triggerKind":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/test.go"},"position":{"line":2,"character":0},"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","context":{"triggerCharacter":".","triggerKind":1}}` - ) - wantType := CompletionParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - Context: &CompletionContext{ - TriggerCharacter: ".", - TriggerKind: CompletionTriggerKindInvoked, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CompletionParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CompletionParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CompletionParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestCompletionTriggerKind_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k CompletionTriggerKind - want string - }{ - { - name: "Invoked", - k: CompletionTriggerKindInvoked, - want: "Invoked", - }, - { - name: "TriggerCharacter", - k: CompletionTriggerKindTriggerCharacter, - want: "TriggerCharacter", - }, - { - name: "TriggerForIncompleteCompletions", - k: CompletionTriggerKindTriggerForIncompleteCompletions, - want: "TriggerForIncompleteCompletions", - }, - { - name: "Unknown", - k: CompletionTriggerKind(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("CompletionTriggerKind.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestCompletionContext(t *testing.T) { - t.Parallel() - - const ( - want = `{"triggerCharacter":".","triggerKind":1}` - wantInvalid = `{"triggerCharacter":" ","triggerKind":0}` - ) - wantType := CompletionContext{ - TriggerCharacter: ".", - TriggerKind: CompletionTriggerKindInvoked, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CompletionContext - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CompletionContext - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CompletionContext - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCompletionList(t *testing.T) { - t.Parallel() - - const ( - want = `{"isIncomplete":true,"items":[{"tags":[1],"detail":"string","documentation":"Detail a human-readable string with additional information about this item, like type or symbol information.","filterText":"Detail","insertTextFormat":2,"kind":5,"label":"Detail","preselect":true,"sortText":"00000","textEdit":{"range":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}},"newText":"Detail: ${1:},"}}]}` - wantInvalid = `{"isIncomplete":false,"items":[]}` - ) - wantType := CompletionList{ - IsIncomplete: true, - Items: []CompletionItem{ - { - AdditionalTextEdits: nil, - Command: nil, - CommitCharacters: nil, - Tags: []CompletionItemTag{ - CompletionItemTagDeprecated, - }, - Deprecated: false, - Detail: "string", - Documentation: "Detail a human-readable string with additional information about this item, like type or symbol information.", - FilterText: "Detail", - InsertText: "", - InsertTextFormat: InsertTextFormatSnippet, - Kind: CompletionItemKindField, - Label: "Detail", - Preselect: true, - SortText: "00000", - TextEdit: &TextEdit{ - Range: Range{ - Start: Position{ - Line: 255, - Character: 4, - }, - End: Position{ - Line: 255, - Character: 10, - }, - }, - NewText: "Detail: ${1:},", - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CompletionList - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CompletionList - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CompletionList - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestInsertTextFormat_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k InsertTextFormat - want string - }{ - { - name: "PlainText", - k: InsertTextFormatPlainText, - want: "PlainText", - }, - { - name: "Snippet", - k: InsertTextFormatSnippet, - want: "Snippet", - }, - { - name: "Unknown", - k: InsertTextFormat(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("InsertTextFormat.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestInsertReplaceEdit(t *testing.T) { - t.Parallel() - - const ( - want = `{"newText":"testNewText","insert":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}},"replace":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}}}` - ) - wantType := InsertReplaceEdit{ - NewText: "testNewText", - Insert: Range{ - Start: Position{ - Line: 255, - Character: 4, - }, - End: Position{ - Line: 255, - Character: 10, - }, - }, - Replace: Range{ - Start: Position{ - Line: 255, - Character: 4, - }, - End: Position{ - Line: 255, - Character: 10, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field InsertReplaceEdit - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want InsertReplaceEdit - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got InsertReplaceEdit - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestInsertTextMode_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k InsertTextMode - want string - }{ - { - name: "AsIs", - k: InsertTextModeAsIs, - want: "AsIs", - }, - { - name: "AdjustIndentation", - k: InsertTextModeAdjustIndentation, - want: "AdjustIndentation", - }, - { - name: "Unknown", - k: InsertTextMode(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("InsertTextMode.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestCompletionItem(t *testing.T) { - t.Parallel() - - const ( - want = `{"additionalTextEdits":[{"range":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}},"newText":"Detail: ${1:},"}],"command":{"title":"exec echo","command":"echo","arguments":["hello"]},"commitCharacters":["a"],"tags":[1],"data":"testData","deprecated":true,"detail":"string","documentation":"Detail a human-readable string with additional information about this item, like type or symbol information.","filterText":"Detail","insertText":"testInsert","insertTextFormat":2,"insertTextMode":1,"kind":5,"label":"Detail","preselect":true,"sortText":"00000","textEdit":{"range":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}},"newText":"Detail: ${1:},"}}` - wantNilAll = `{"label":"Detail"}` - wantInvalid = `{"items":[]}` - ) - wantType := CompletionItem{ - AdditionalTextEdits: []TextEdit{ - { - Range: Range{ - Start: Position{ - Line: 255, - Character: 4, - }, - End: Position{ - Line: 255, - Character: 10, - }, - }, - NewText: "Detail: ${1:},", - }, - }, - Command: &Command{ - Title: "exec echo", - Command: "echo", - Arguments: []interface{}{"hello"}, - }, - CommitCharacters: []string{"a"}, - Tags: []CompletionItemTag{ - CompletionItemTagDeprecated, - }, - Data: "testData", - Deprecated: true, - Detail: "string", - Documentation: "Detail a human-readable string with additional information about this item, like type or symbol information.", - FilterText: "Detail", - InsertText: "testInsert", - InsertTextFormat: InsertTextFormatSnippet, - InsertTextMode: InsertTextModeAsIs, - Kind: CompletionItemKindField, - Label: "Detail", - Preselect: true, - SortText: "00000", - TextEdit: &TextEdit{ - Range: Range{ - Start: Position{ - Line: 255, - Character: 4, - }, - End: Position{ - Line: 255, - Character: 10, - }, - }, - NewText: "Detail: ${1:},", - }, - } - wantTypeNilAll := CompletionItem{ - Label: "Detail", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CompletionItem - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CompletionItem - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CompletionItem - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCompletionItemKind_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k CompletionItemKind - want string - }{ - { - name: "Text", - k: CompletionItemKindText, - want: "Text", - }, - { - name: "Method", - k: CompletionItemKindMethod, - want: "Method", - }, - { - name: "Function", - k: CompletionItemKindFunction, - want: "Function", - }, - { - name: "Constructor", - k: CompletionItemKindConstructor, - want: "Constructor", - }, - { - name: "Field", - k: CompletionItemKindField, - want: "Field", - }, - { - name: "Variable", - k: CompletionItemKindVariable, - want: "Variable", - }, - { - name: "Class", - k: CompletionItemKindClass, - want: "Class", - }, - { - name: "Interface", - k: CompletionItemKindInterface, - want: "Interface", - }, - { - name: "Module", - k: CompletionItemKindModule, - want: "Module", - }, - { - name: "Property", - k: CompletionItemKindProperty, - want: "Property", - }, - { - name: "Unit", - k: CompletionItemKindUnit, - want: "Unit", - }, - { - name: "Value", - k: CompletionItemKindValue, - want: "Value", - }, - { - name: "Enum", - k: CompletionItemKindEnum, - want: "Enum", - }, - { - name: "Keyword", - k: CompletionItemKindKeyword, - want: "Keyword", - }, - { - name: "Snippet", - k: CompletionItemKindSnippet, - want: "Snippet", - }, - { - name: "Color", - k: CompletionItemKindColor, - want: "Color", - }, - { - name: "File", - k: CompletionItemKindFile, - want: "File", - }, - { - name: "Reference", - k: CompletionItemKindReference, - want: "Reference", - }, - { - name: "Folder", - k: CompletionItemKindFolder, - want: "Folder", - }, - { - name: "EnumMember", - k: CompletionItemKindEnumMember, - want: "EnumMember", - }, - { - name: "Constant", - k: CompletionItemKindConstant, - want: "Constant", - }, - { - name: "Struct", - k: CompletionItemKindStruct, - want: "Struct", - }, - { - name: "Event", - k: CompletionItemKindEvent, - want: "Event", - }, - { - name: "Operator", - k: CompletionItemKindOperator, - want: "Operator", - }, - { - name: "TypeParameter", - k: CompletionItemKindTypeParameter, - want: "TypeParameter", - }, - { - name: "Unknown", - k: CompletionItemKind(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("CompletionItemKind.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestCompletionItemTag_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k CompletionItemTag - want string - }{ - { - name: "Deprecated", - k: CompletionItemTagDeprecated, - want: "Deprecated", - }, - { - name: "Unknown", - k: CompletionItemTag(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("CompletionItemTag.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestCompletionRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"}],"triggerCharacters":["."],"resolveProvider":true}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"}],"triggerCharacters":[" "],"resolveProvider":true}` - ) - wantType := CompletionRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - }, - }, - TriggerCharacters: []string{"."}, - ResolveProvider: true, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CompletionRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CompletionRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CompletionRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestHoverParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - invalidWorkDoneToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `"}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1},"workDoneToken":"` + invalidWorkDoneToken + `"}` - ) - wantType := HoverParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - } - wantTypeNilAll := HoverParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field HoverParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want HoverParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got HoverParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestHover(t *testing.T) { - t.Parallel() - - const ( - want = `{"contents":{"kind":"markdown","value":"example value"},"range":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}}}` - wantInvalid = `{"contents":{"kind":"markdown","value":"example value"},"range":{"start":{"line":25,"character":2},"end":{"line":25,"character":5}}}` - ) - wantType := Hover{ - Contents: MarkupContent{ - Kind: Markdown, - Value: "example value", - }, - Range: &Range{ - Start: Position{ - Line: 255, - Character: 4, - }, - End: Position{ - Line: 255, - Character: 10, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field Hover - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want Hover - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got Hover - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestSignatureHelpParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - invalidWorkDoneToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1},"workDoneToken":"` + wantWorkDoneToken + `","context":{"triggerKind":1,"triggerCharacter":".","isRetrigger":true,"activeSignatureHelp":{"signatures":[{"label":"testLabel","documentation":"testDocumentation","parameters":[{"label":"test label","documentation":"test documentation"}]}],"activeParameter":10,"activeSignature":5}}}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/basic.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go"},"position":{"line":2,"character":1},"workDoneToken":"` + invalidWorkDoneToken + `","context":{"triggerKind":0,"triggerCharacter":"aaa","isRetrigger":false,"activeSignatureHelp":{"signatures":[{"documentationFormat":["markdown"],"parameterInformation":{"label":"test label","documentation":"test documentation"}}],"activeParameter":1,"activeSignature":0}}}` - ) - wantType := SignatureHelpParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - Context: &SignatureHelpContext{ - TriggerKind: SignatureHelpTriggerKindInvoked, - TriggerCharacter: ".", - IsRetrigger: true, - ActiveSignatureHelp: &SignatureHelp{ - Signatures: []SignatureInformation{ - { - Label: "testLabel", - Documentation: "testDocumentation", - Parameters: []ParameterInformation{ - { - Label: "test label", - Documentation: "test documentation", - }, - }, - }, - }, - ActiveParameter: 10, - ActiveSignature: 5, - }, - }, - } - wantTypeNilAll := SignatureHelpParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field SignatureHelpParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want SignatureHelpParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got SignatureHelpParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestSignatureHelpTriggerKind_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k SignatureHelpTriggerKind - want string - }{ - { - name: "Invoked", - k: SignatureHelpTriggerKindInvoked, - want: "Invoked", - }, - { - name: "TriggerCharacter", - k: SignatureHelpTriggerKindTriggerCharacter, - want: "TriggerCharacter", - }, - { - name: "ContentChange", - k: SignatureHelpTriggerKindContentChange, - want: "ContentChange", - }, - { - name: "Unknown", - k: SignatureHelpTriggerKind(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("SignatureHelpTriggerKind.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestSignatureHelp(t *testing.T) { - t.Parallel() - - const ( - want = `{"signatures":[{"label":"testLabel","documentation":"testDocumentation","parameters":[{"label":"test label","documentation":"test documentation"}]}],"activeParameter":10,"activeSignature":5}` - wantNilAll = `{"signatures":[]}` - wantInvalid = `{"signatures":[{"label":"invalidLabel","documentation":"invalidDocumentation","parameters":[{"label":"test label","documentation":"test documentation"}]}],"activeParameter":1,"activeSignature":0}` - ) - wantType := SignatureHelp{ - Signatures: []SignatureInformation{ - { - Label: "testLabel", - Documentation: "testDocumentation", - Parameters: []ParameterInformation{ - { - Label: "test label", - Documentation: "test documentation", - }, - }, - }, - }, - ActiveParameter: 10, - ActiveSignature: 5, - } - wantTypeNilAll := SignatureHelp{ - Signatures: []SignatureInformation{}, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field SignatureHelp - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want SignatureHelp - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got SignatureHelp - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestSignatureInformation(t *testing.T) { - t.Parallel() - - const ( - want = `{"label":"testLabel","documentation":"testDocumentation","parameters":[{"label":"test label","documentation":"test documentation"}],"activeParameter":5}` - wantInvalid = `{"label":"testLabel","documentation":"invalidDocumentation","parameters":[{"label":"test label","documentation":"test documentation"}],"activeParameter":50}` - ) - wantType := SignatureInformation{ - Label: "testLabel", - Documentation: "testDocumentation", - Parameters: []ParameterInformation{ - { - Label: "test label", - Documentation: "test documentation", - }, - }, - ActiveParameter: uint32(5), - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field SignatureInformation - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want SignatureInformation - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got SignatureInformation - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestParameterInformation(t *testing.T) { - t.Parallel() - - const ( - want = `{"label":"test label","documentation":"test documentation"}` - wantInvalid = `{"label":"invalid","documentation":"invalid"}` - ) - wantType := ParameterInformation{ - Label: "test label", - Documentation: "test documentation", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ParameterInformation - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ParameterInformation - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ParameterInformation - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestSignatureHelpRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"}],"triggerCharacters":["."]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"}],"triggerCharacters":[" "]}` - ) - wantType := SignatureHelpRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - }, - }, - TriggerCharacters: []string{"."}, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field SignatureHelpRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want SignatureHelpRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got SignatureHelpRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestReferenceParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"textDocument":{"uri":"file:///path/to/test.go"},"position":{"line":25,"character":1},"context":{"includeDeclaration":true}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/test.go"},"position":{"line":2,"character":0},"context":{"includeDeclaration":false}}` - ) - wantType := ReferenceParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - Context: ReferenceContext{ - IncludeDeclaration: true, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ReferenceParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ReferenceParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ReferenceParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestReferenceContext(t *testing.T) { - t.Parallel() - - const ( - want = `{"includeDeclaration":true}` - wantInvalid = `{"includeDeclaration":false}` - ) - wantType := ReferenceContext{ - IncludeDeclaration: true, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ReferenceContext - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ReferenceContext - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ReferenceContext - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentHighlight(t *testing.T) { - t.Parallel() - - const ( - want = `{"range":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}},"kind":1}` - wantInvalid = `{"range":{"start":{"line":25,"character":2},"end":{"line":25,"character":5}},"kind":1}` - ) - wantType := DocumentHighlight{ - Range: Range{ - Start: Position{ - Line: 255, - Character: 4, - }, - End: Position{ - Line: 255, - Character: 10, - }, - }, - Kind: DocumentHighlightKindText, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentHighlight - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentHighlight - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentHighlight - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentHighlightKind_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k DocumentHighlightKind - want string - }{ - { - name: "Text", - k: DocumentHighlightKindText, - want: "Text", - }, - { - name: "Read", - k: DocumentHighlightKindRead, - want: "Read", - }, - { - name: "Write", - k: DocumentHighlightKindWrite, - want: "Write", - }, - { - name: "Unknown", - k: DocumentHighlightKind(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("DocumentHighlightKind.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestDocumentSymbolParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - wantType := DocumentSymbolParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - } - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","textDocument":{"uri":"file:///path/to/test.go"}}` - wantInvalid = `{"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","textDocument":{"uri":"file:///path/to/nottest.go"}}` - ) - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentSymbolParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentSymbolParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentSymbolParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestSymbolKind_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k SymbolKind - want string - }{ - { - name: "File", - k: SymbolKindFile, - want: "File", - }, - { - name: "Module", - k: SymbolKindModule, - want: "Module", - }, - { - name: "Namespace", - k: SymbolKindNamespace, - want: "Namespace", - }, - { - name: "Package", - k: SymbolKindPackage, - want: "Package", - }, - { - name: "Class", - k: SymbolKindClass, - want: "Class", - }, - { - name: "Method", - k: SymbolKindMethod, - want: "Method", - }, - { - name: "Property", - k: SymbolKindProperty, - want: "Property", - }, - { - name: "Field", - k: SymbolKindField, - want: "Field", - }, - { - name: "Constructor", - k: SymbolKindConstructor, - want: "Constructor", - }, - { - name: "Enum", - k: SymbolKindEnum, - want: "Enum", - }, - { - name: "Interface", - k: SymbolKindInterface, - want: "Interface", - }, - { - name: "Function", - k: SymbolKindFunction, - want: "Function", - }, - { - name: "Variable", - k: SymbolKindVariable, - want: "Variable", - }, - { - name: "Constant", - k: SymbolKindConstant, - want: "Constant", - }, - { - name: "String", - k: SymbolKindString, - want: "String", - }, - { - name: "Number", - k: SymbolKindNumber, - want: "Number", - }, - { - name: "Boolean", - k: SymbolKindBoolean, - want: "Boolean", - }, - { - name: "Array", - k: SymbolKindArray, - want: "Array", - }, - { - name: "Object", - k: SymbolKindObject, - want: "Object", - }, - { - name: "Key", - k: SymbolKindKey, - want: "Key", - }, - { - name: "Null", - k: SymbolKindNull, - want: "Null", - }, - { - name: "EnumMember", - k: SymbolKindEnumMember, - want: "EnumMember", - }, - { - name: "Struct", - k: SymbolKindStruct, - want: "Struct", - }, - { - name: "Event", - k: SymbolKindEvent, - want: "Event", - }, - { - name: "Operator", - k: SymbolKindOperator, - want: "Operator", - }, - { - name: "TypeParameter", - k: SymbolKindTypeParameter, - want: "TypeParameter", - }, - { - name: "Unknown", - k: SymbolKind(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("SymbolKind.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestSymbolTag_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k SymbolTag - want string - }{ - { - name: "Deprecated", - k: SymbolTagDeprecated, - want: "Deprecated", - }, - { - name: "Unknown", - k: SymbolTag(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("SymbolTag.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestDocumentSymbol(t *testing.T) { - t.Parallel() - - const ( - want = `{"name":"test symbol","detail":"test detail","kind":1,"tags":[1],"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":6}},"selectionRange":{"start":{"line":25,"character":3},"end":{"line":26,"character":10}},"children":[{"name":"child symbol","detail":"child detail","kind":11,"deprecated":true,"range":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}},"selectionRange":{"start":{"line":255,"character":5},"end":{"line":255,"character":8}}}]}` - wantInvalid = `{"name":"invalid symbol","detail":"invalid detail","kind":1,"tags":[0],"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"selectionRange":{"start":{"line":2,"character":5},"end":{"line":3,"character":1}},"children":[{"name":"invalid child symbol","kind":1,"detail":"invalid child detail","range":{"start":{"line":255,"character":4},"end":{"line":255,"character":10}},"selectionRange":{"start":{"line":255,"character":5},"end":{"line":255,"character":8}}}]}` - ) - wantType := DocumentSymbol{ - Name: "test symbol", - Detail: "test detail", - Kind: SymbolKindFile, - Tags: []SymbolTag{ - SymbolTagDeprecated, - }, - Deprecated: false, - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 6, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 25, - Character: 3, - }, - End: Position{ - Line: 26, - Character: 10, - }, - }, - Children: []DocumentSymbol{ - { - Name: "child symbol", - Detail: "child detail", - Kind: SymbolKindInterface, - Deprecated: true, - Range: Range{ - Start: Position{ - Line: 255, - Character: 4, - }, - End: Position{ - Line: 255, - Character: 10, - }, - }, - SelectionRange: Range{ - Start: Position{ - Line: 255, - Character: 5, - }, - End: Position{ - Line: 255, - Character: 8, - }, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentSymbol - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentSymbol - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentSymbol - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestSymbolInformation(t *testing.T) { - t.Parallel() - - const ( - want = `{"name":"test symbol","kind":1,"tags":[1],"deprecated":true,"location":{"uri":"file:///path/to/test.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"containerName":"testContainerName"}` - wantNilAll = `{"name":"test symbol","kind":1,"location":{"uri":"file:///path/to/test.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}}` - wantInvalid = `{"name":"invalid symbol","kind":1,"tags":[0],"deprecated":false,"location":{"uri":"file:///path/to/test_test.go","range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}},"containerName":"invalidContainerName"}` - ) - wantType := SymbolInformation{ - Name: "test symbol", - Kind: 1, - Tags: []SymbolTag{ - SymbolTagDeprecated, - }, - Deprecated: true, - Location: Location{ - URI: uri.File("/path/to/test.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - ContainerName: "testContainerName", - } - wantTypeNilAll := SymbolInformation{ - Name: "test symbol", - Kind: 1, - Deprecated: false, - Location: Location{ - URI: uri.File("/path/to/test.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field SymbolInformation - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want SymbolInformation - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got SymbolInformation - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCodeActionParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","textDocument":{"uri":"file:///path/to/test.go"},"context":{"diagnostics":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"severity":1,"code":"foo/bar","source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/test.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"test.go"}]}],"only":["quickfix"]},"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":6}}}` - wantInvalid = `{"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","textDocument":{"uri":"file:///path/to/test.go"},"context":{"diagnostics":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"severity":1,"code":"foo/bar","source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/test.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"test.go"}]}],"only":["quickfix"]},"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}}` - ) - wantType := CodeActionParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Context: CodeActionContext{ - Diagnostics: []Diagnostic{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Severity: DiagnosticSeverityError, - Code: "foo/bar", - Source: "test foo bar", - Message: "foo bar", - RelatedInformation: []DiagnosticRelatedInformation{ - { - Location: Location{ - URI: uri.File("/path/to/test.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - Message: "test.go", - }, - }, - }, - }, - Only: []CodeActionKind{ - QuickFix, - }, - }, - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 6, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CodeActionParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CodeActionParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeActionParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestCodeActionKind_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k CodeActionKind - want string - }{ - { - name: "QuickFix", - k: QuickFix, - want: "quickfix", - }, - { - name: "Refactor", - k: Refactor, - want: "refactor", - }, - { - name: "RefactorExtract", - k: RefactorExtract, - want: "refactor.extract", - }, - { - name: "RefactorInline", - k: RefactorInline, - want: "refactor.inline", - }, - { - name: "RefactorRewrite", - k: RefactorRewrite, - want: "refactor.rewrite", - }, - { - name: "Source", - k: Source, - want: "source", - }, - { - name: "SourceOrganizeImports", - k: SourceOrganizeImports, - want: "source.organizeImports", - }, - { - name: "Unknown", - k: CodeActionKind(""), - want: "", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k; got != CodeActionKind(tt.want) { - t.Errorf("CodeActionKind = %v, want %v", tt.want, got) - } - }) - } -} - -func TestCodeActionContext(t *testing.T) { - t.Parallel() - - const ( - want = `{"diagnostics":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"severity":1,"code":"foo/bar","source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/test.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"test.go"}]}],"only":["quickfix"]}` - wantInvalid = `{"diagnostics":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"severity":1,"code":"foo/bar","source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/test.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"test.go"}]}],"only":["quickfix"]}` - ) - wantType := CodeActionContext{ - Diagnostics: []Diagnostic{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Severity: DiagnosticSeverityError, - Code: "foo/bar", - Source: "test foo bar", - Message: "foo bar", - RelatedInformation: []DiagnosticRelatedInformation{ - { - Location: Location{ - URI: uri.File("/path/to/test.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - Message: "test.go", - }, - }, - }, - }, - Only: []CodeActionKind{ - QuickFix, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CodeActionContext - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CodeActionContext - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeActionContext - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCodeAction(t *testing.T) { - t.Parallel() - - const ( - want = `{"title":"Refactoring","kind":"refactor.rewrite","diagnostics":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"severity":1,"code":"foo/bar","source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/test.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"test.go"}]}],"isPreferred":true,"disabled":{"reason":"testReason"},"edit":{"changes":{"file:///path/to/test.go":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]},"documentChanges":[{"textDocument":{"uri":"file:///path/to/test.go","version":10},"edits":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]}]},"command":{"title":"rewrite","command":"rewriter","arguments":["-w"]},"data":"testData"}` - wantInvalid = `{"title":"Refactoring","kind":"refactor","diagnostics":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"severity":1,"code":"foo/bar","source":"test foo bar","message":"foo bar","relatedInformation":[{"location":{"uri":"file:///path/to/test.go","range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}},"message":"test.go"}]}],"isPreferred":false,"disabled":{"reason":"invalidReason"},"edit":{"changes":{"file:///path/to/test.go":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"newText":"foo bar"}]},"documentChanges":[{"textDocument":{"uri":"file:///path/to/test.go","version":10},"edits":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]}]},"command":{"title":"rewrite","command":"rewriter","arguments":["-w"]}}` - ) - wantType := CodeAction{ - Title: "Refactoring", - Kind: RefactorRewrite, - Diagnostics: []Diagnostic{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Severity: DiagnosticSeverityError, - Code: "foo/bar", - Source: "test foo bar", - Message: "foo bar", - RelatedInformation: []DiagnosticRelatedInformation{ - { - Location: Location{ - URI: uri.File("/path/to/test.go"), - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - }, - Message: "test.go", - }, - }, - }, - }, - IsPreferred: true, - Disabled: &CodeActionDisable{ - Reason: "testReason", - }, - Edit: &WorkspaceEdit{ - Changes: map[uri.URI][]TextEdit{ - uri.File("/path/to/test.go"): { - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - DocumentChanges: []TextDocumentEdit{ - { - TextDocument: OptionalVersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Version: NewVersion(int32(10)), - }, - Edits: []TextEdit{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - }, - }, - Command: &Command{ - Title: "rewrite", - Command: "rewriter", - Arguments: []interface{}{"-w"}, - }, - Data: "testData", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CodeAction - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CodeAction - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeAction - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCodeActionRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"},{"language":"cpp","scheme":"untitled","pattern":"*.{cpp,hpp}"}],"codeActionKinds":["quickfix","refactor"]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"},{"language":"c","scheme":"untitled","pattern":"*.{c,h}"}],"codeActionKinds":["quickfix","refactor"]}` - ) - wantType := CodeActionRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - { - Language: "cpp", - Scheme: "untitled", - Pattern: "*.{cpp,hpp}", - }, - }, - }, - CodeActionOptions: CodeActionOptions{ - CodeActionKinds: []CodeActionKind{ - QuickFix, - Refactor, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CodeActionRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CodeActionRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeActionRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCodeLensParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","textDocument":{"uri":"file:///path/to/test.go"}}` - wantInvalid = `{"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","textDocument":{"uri":"file:///path/to/invalid.go"}}` - ) - wantType := CodeLensParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CodeLensParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CodeLensParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeLensParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestCodeLens(t *testing.T) { - t.Parallel() - - const ( - want = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"command":{"title":"rewrite","command":"rewriter","arguments":["-w"]},"data":"testData"}` - wantNilAll = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}` - wantInvalid = `{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"command":{"title":"rewrite","command":"rewriter","arguments":["-w"]},"data":"invalidData"}` - ) - wantType := CodeLens{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Command: &Command{ - Title: "rewrite", - Command: "rewriter", - Arguments: []interface{}{"-w"}, - }, - Data: "testData", - } - wantTypeNilAll := CodeLens{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CodeLens - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CodeLens - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeLens - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestCodeLensRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"},{"language":"cpp","scheme":"untitled","pattern":"*.{cpp,hpp}"}],"resolveProvider":true}` - wantNilAll = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"},{"language":"cpp","scheme":"untitled","pattern":"*.{cpp,hpp}"}]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"},{"language":"c","scheme":"untitled","pattern":"*.{c,h}"}],"resolveProvider":false}` - ) - wantType := CodeLensRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - { - Language: "cpp", - Scheme: "untitled", - Pattern: "*.{cpp,hpp}", - }, - }, - }, - ResolveProvider: true, - } - wantTypeNilAll := CodeLensRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - { - Language: "cpp", - Scheme: "untitled", - Pattern: "*.{cpp,hpp}", - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field CodeLensRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want CodeLensRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got CodeLensRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentLinkParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","textDocument":{"uri":"file:///path/to/test.go"}}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/test.go"}}` - wantInvalid = `{"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","textDocument":{"uri":"file:///path/to/invalid.go"}}` - ) - wantType := DocumentLinkParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentLinkParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentLinkParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentLinkParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestDocumentLink(t *testing.T) { - t.Parallel() - - const ( - want = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"target":"file:///path/to/test.go","tooltip":"testTooltip","data":"testData"}` - wantNilAll = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}` - wantInvalid = `{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"target":"file:///path/to/test.go","tooltip":"invalidTooltip","data":"testData"}` - ) - wantType := DocumentLink{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Target: uri.File("/path/to/test.go"), - Tooltip: "testTooltip", - Data: "testData", - } - wantTypeNilAll := DocumentLink{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentLink - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentLink - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentLink - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentColorParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","textDocument":{"uri":"file:///path/to/test.go"}}` - wantInvalid = `{"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","textDocument":{"uri":"file:///path/to/invalid.go"}}` - ) - wantType := DocumentColorParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentColorParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentColorParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentColorParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestColorInformation(t *testing.T) { - t.Parallel() - - const ( - want = `{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"color":{"alpha":1,"blue":0.2,"green":0.3,"red":0.4}}` - wantInvalid = `{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"color":{"alpha":0,"blue":0.4,"green":0.3,"red":0.2}}` - ) - wantType := ColorInformation{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Color: Color{ - Alpha: 1, - Blue: 0.2, - Green: 0.3, - Red: 0.4, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ColorInformation - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ColorInformation - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ColorInformation - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestColor(t *testing.T) { - t.Parallel() - - const ( - want = `{"alpha":1,"blue":0.2,"green":0.3,"red":0.4}` - wantInvalid = `{"alpha":0,"blue":0.4,"green":0.3,"red":0.2}` - ) - wantType := Color{ - Alpha: 1, - Blue: 0.2, - Green: 0.3, - Red: 0.4, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field Color - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want Color - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got Color - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestColorPresentationParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","textDocument":{"uri":"file:///path/to/test.go"},"color":{"alpha":1,"blue":0.2,"green":0.3,"red":0.4},"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}}}` - wantInvalid = `{"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","textDocument":{"uri":"file:///path/to/test.go"},"color":{"alpha":0,"blue":0.4,"green":0.3,"red":0.2},"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}}}` - ) - wantType := ColorPresentationParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Color: Color{ - Alpha: 1, - Blue: 0.2, - Green: 0.3, - Red: 0.4, - }, - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ColorPresentationParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ColorPresentationParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ColorPresentationParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestColorPresentation(t *testing.T) { - t.Parallel() - - const ( - want = `{"label":"testLabel","textEdit":{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"},"additionalTextEdits":[{"range":{"start":{"line":100,"character":10},"end":{"line":102,"character":15}},"newText":"baz qux"}]}` - wantNilAll = `{"label":"testLabel"}` - wantInvalid = `{"label":"invalidLabel","textEdit":{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"newText":"quux quuz"},"additionalTextEdits":[{"range":{"start":{"line":105,"character":15},"end":{"line":107,"character":20}},"newText":"corge grault"}]}` - ) - wantType := ColorPresentation{ - Label: "testLabel", - TextEdit: &TextEdit{ - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - AdditionalTextEdits: []TextEdit{ - { - Range: Range{ - Start: Position{ - Line: 100, - Character: 10, - }, - End: Position{ - Line: 102, - Character: 15, - }, - }, - NewText: "baz qux", - }, - }, - } - wantTypeNilAll := ColorPresentation{ - Label: "testLabel", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ColorPresentation - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ColorPresentation - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ColorPresentation - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentFormattingParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - invalidWorkDoneToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","options":{"insertSpaces":true,"tabSize":4},"textDocument":{"uri":"file:///path/to/test.go"}}` - wantInvalid = `{"workDoneToken":"` + invalidWorkDoneToken + `","options":{"insertSpaces":false,"tabSize":2},"textDocument":{"uri":"file:///path/to/invalid.go"}}` - ) - wantType := DocumentFormattingParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - Options: FormattingOptions{ - InsertSpaces: true, - TabSize: 4, - }, - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentFormattingParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentFormattingParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentFormattingParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestFormattingOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"insertSpaces":true,"tabSize":4,"trimTrailingWhitespace":true,"insertFinalNewline":true,"trimFinalNewlines":true,"key":{"test":"key"}}` - wantInvalid = `{"insertSpaces":false,"tabSize":2,"trimTrailingWhitespace":false,"insertFinalNewline":false,"trimFinalNewlines":false}` - ) - wantType := FormattingOptions{ - InsertSpaces: true, - TabSize: 4, - TrimTrailingWhitespace: true, - InsertFinalNewline: true, - TrimFinalNewlines: true, - Key: map[string]interface{}{ - "test": "key", - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field FormattingOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want FormattingOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got FormattingOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentRangeFormattingParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - invalidWorkDoneToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","textDocument":{"uri":"file:///path/to/test.go"},"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"options":{"insertSpaces":true,"tabSize":4}}` - wantInvalid = `{"workDoneToken":"` + invalidWorkDoneToken + `","textDocument":{"uri":"file:///path/to/invalid.go"},"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"options":{"insertSpaces":false,"tabSize":2}}` - ) - wantType := DocumentRangeFormattingParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - Options: FormattingOptions{ - InsertSpaces: true, - TabSize: 4, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentRangeFormattingParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentRangeFormattingParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentRangeFormattingParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestDocumentOnTypeFormattingParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"textDocument":{"uri":"file:///path/to/test.go"},"position":{"line":25,"character":1},"ch":"character","options":{"insertSpaces":true,"tabSize":4}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/invalid.go"},"position":{"line":2,"character":1},"ch":"invalidChar","options":{"insertSpaces":false,"tabSize":2}}` - ) - wantType := DocumentOnTypeFormattingParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - Ch: "character", - Options: FormattingOptions{ - InsertSpaces: true, - TabSize: 4, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentOnTypeFormattingParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentOnTypeFormattingParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentOnTypeFormattingParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDocumentOnTypeFormattingRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"},{"language":"cpp","scheme":"untitled","pattern":"*.{cpp,hpp}"}],"firstTriggerCharacter":"}","moreTriggerCharacter":[".","{"]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"},{"language":"c","scheme":"untitled","pattern":"*.{c,h}"}],"firstTriggerCharacter":"{","moreTriggerCharacter":[" ","("]}` - ) - wantType := DocumentOnTypeFormattingRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - { - Language: "cpp", - Scheme: "untitled", - Pattern: "*.{cpp,hpp}", - }, - }, - }, - FirstTriggerCharacter: "}", - MoreTriggerCharacter: []string{".", "{"}, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DocumentOnTypeFormattingRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DocumentOnTypeFormattingRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DocumentOnTypeFormattingRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestRenameParams(t *testing.T) { - t.Parallel() - - const ( - wantPartialResultToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - invalidPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/test.go"},"position":{"line":25,"character":1},"partialResultToken":"` + wantPartialResultToken + `","newName":"newNameSymbol"}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/invalid.go"},"position":{"line":2,"character":1},"partialResultToken":"` + invalidPartialResultToken + `","newName":"invalidSymbol"}` - ) - wantType := RenameParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - NewName: "newNameSymbol", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field RenameParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want RenameParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got RenameParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestRenameRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"},{"language":"cpp","scheme":"untitled","pattern":"*.{cpp,hpp}"}],"prepareProvider":true}` - wantNilAll = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"},{"language":"cpp","scheme":"untitled","pattern":"*.{cpp,hpp}"}]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"},{"language":"c","scheme":"untitled","pattern":"*.{c,h}"}],"prepareProvider":false}` - ) - wantType := RenameRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - { - Language: "cpp", - Scheme: "untitled", - Pattern: "*.{cpp,hpp}", - }, - }, - }, - PrepareProvider: true, - } - wantTypeNilAll := RenameRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - { - Language: "cpp", - Scheme: "untitled", - Pattern: "*.{cpp,hpp}", - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field RenameRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want RenameRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got RenameRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestPrepareRenameParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"textDocument":{"uri":"file:///path/to/test.go"},"position":{"line":25,"character":1}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/invalid.go"},"position":{"line":2,"character":0}}` - ) - wantType := PrepareRenameParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field PrepareRenameParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want PrepareRenameParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got PrepareRenameParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestFoldingRangeParams(t *testing.T) { - t.Parallel() - - const ( - wantPartialResultToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - invalidPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"textDocument":{"uri":"file:///path/to/test.go"},"position":{"line":25,"character":1},"partialResultToken":"` + wantPartialResultToken + `"}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/invalid.go"},"position":{"line":2,"character":0},"partialResultToken":"` + invalidPartialResultToken + `"}` - ) - wantType := FoldingRangeParams{ - TextDocumentPositionParams: TextDocumentPositionParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Position: Position{ - Line: 25, - Character: 1, - }, - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field FoldingRangeParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want FoldingRangeParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got FoldingRangeParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestFoldingRangeKind_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - s FoldingRangeKind - want string - }{ - { - name: "Comment", - s: CommentFoldingRange, - want: "comment", - }, - { - name: "Imports", - s: ImportsFoldingRange, - want: "imports", - }, - { - name: "Region", - s: RegionFoldingRange, - want: "region", - }, - { - name: "Unknown", - s: FoldingRangeKind(""), - want: "", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.s; !strings.EqualFold(tt.want, string(got)) { - t.Errorf("FoldingRangeKind(%v), want %v", tt.want, got) - } - }) - } -} - -func TestFoldingRange(t *testing.T) { - t.Parallel() - - const ( - want = `{"startLine":10,"startCharacter":1,"endLine":10,"endCharacter":8,"kind":"imports"}` - wantNilAll = `{"startLine":10,"endLine":10}` - wantInvalid = `{"startLine":0,"startCharacter":1,"endLine":0,"endCharacter":8,"kind":"comment"}` - ) - wantType := FoldingRange{ - StartLine: 10, - StartCharacter: 1, - EndLine: 10, - EndCharacter: 8, - Kind: ImportsFoldingRange, - } - wantTypeNilAll := FoldingRange{ - StartLine: 10, - EndLine: 10, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field FoldingRange - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want FoldingRange - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got FoldingRange - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} diff --git a/lifecycle.go b/lifecycle.go new file mode 100644 index 00000000..01da8be9 --- /dev/null +++ b/lifecycle.go @@ -0,0 +1,1386 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +// TextDocumentSyncKind defines how the host (editor) should sync document changes to the language server. +type TextDocumentSyncKind uint32 + +const ( + // NoneTextDocumentSyncKind documents should not be synced at all. + NoneTextDocumentSyncKind TextDocumentSyncKind = 0 + + // FullTextDocumentSyncKind documents are synced by always sending the full content of the document. + FullTextDocumentSyncKind TextDocumentSyncKind = 1 + + // IncrementalTextDocumentSyncKind documents are synced by sending the full content on open. After that only incremental updates to the + // document are send. + IncrementalTextDocumentSyncKind TextDocumentSyncKind = 2 +) + +// TextDocumentRegistrationOptions general text document registration options. +type TextDocumentRegistrationOptions struct { + // DocumentSelector a document selector to identify the scope of the registration. If set to null the document selector provided on the client side will be used. + DocumentSelector *DocumentSelector `json:"documentSelector,omitempty"` +} + +// Registration general parameters to register for a notification or to register a provider. +type Registration struct { + // ID the id used to register the request. The id can be used to deregister the request again. + ID string `json:"id"` + + // Method the method / capability to register for. + Method string `json:"method"` + + // RegisterOptions options necessary for the registration. + RegisterOptions any `json:"registerOptions,omitempty"` +} + +type RegistrationParams struct { + Registrations []Registration `json:"registrations"` +} + +// Unregistration general parameters to unregister a request or notification. +type Unregistration struct { + // ID the id used to unregister the request or notification. Usually an id provided during the register request. + ID string `json:"id"` + + // Method the method to unregister for. + Method string `json:"method"` +} + +type UnregistrationParams struct { + Unregisterations []Unregistration `json:"unregisterations"` +} + +// ClientInfo information about the client 3.15.0 3.18.0 ClientInfo type name added. +// +// @since 3.18.0 ClientInfo type name added. +type ClientInfo struct { + // Name the name of the client as defined by the client. + // + // @since 3.18.0 ClientInfo type name added. + Name string `json:"name"` + + // Version the client's version as defined by the client. + // + // @since 3.18.0 ClientInfo type name added. + Version string `json:"version,omitempty"` +} + +// SemanticTokensWorkspaceClientCapabilities. +// +// @since 3.16.0 +type SemanticTokensWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all semantic tokens currently shown. It should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. + // + // @since 3.16.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// CodeLensWorkspaceClientCapabilities. +// +// @since 3.16.0 +type CodeLensWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all code lenses currently shown. It + // should be used with absolute care and is useful for situation where a server for example detect a project wide change that requires such a calculation. + // + // @since 3.16.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// FileOperationClientCapabilities capabilities relating to events from file operations by the user in the client. These events do not come from the file system, they come from user operations like renaming a file in the UI. +// +// @since 3.16.0 +type FileOperationClientCapabilities struct { + // DynamicRegistration whether the client supports dynamic registration for file requests/notifications. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // DidCreate the client has support for sending didCreateFiles notifications. + // + // @since 3.16.0 + DidCreate bool `json:"didCreate,omitempty"` + + // WillCreate the client has support for sending willCreateFiles requests. + // + // @since 3.16.0 + WillCreate bool `json:"willCreate,omitempty"` + + // DidRename the client has support for sending didRenameFiles notifications. + // + // @since 3.16.0 + DidRename bool `json:"didRename,omitempty"` + + // WillRename the client has support for sending willRenameFiles requests. + // + // @since 3.16.0 + WillRename bool `json:"willRename,omitempty"` + + // DidDelete the client has support for sending didDeleteFiles notifications. + // + // @since 3.16.0 + DidDelete bool `json:"didDelete,omitempty"` + + // WillDelete the client has support for sending willDeleteFiles requests. + // + // @since 3.16.0 + WillDelete bool `json:"willDelete,omitempty"` +} + +// InlineValueWorkspaceClientCapabilities client workspace capabilities specific to inline values. +// +// @since 3.17.0 +type InlineValueWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all inline values currently shown. It should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. + // + // @since 3.17.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// InlayHintWorkspaceClientCapabilities client workspace capabilities specific to inlay hints. +// +// @since 3.17.0 +type InlayHintWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all inlay hints currently shown. It + // should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. + // + // @since 3.17.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// DiagnosticWorkspaceClientCapabilities workspace client capabilities specific to diagnostic pull requests. +// +// @since 3.17.0 +type DiagnosticWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all pulled diagnostics currently shown. It should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. + // + // @since 3.17.0 + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// FoldingRangeWorkspaceClientCapabilities client workspace capabilities specific to folding ranges 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type FoldingRangeWorkspaceClientCapabilities struct { + // RefreshSupport whether the client implementation supports a refresh request sent from the server to the client. Note that this event is global and will force the client to refresh all folding ranges currently shown. + // It should be used with absolute care and is useful for situation where a server for example detects a project wide change that requires such a calculation. 3.18.0 @proposed. + // @since 3.18.0 proposed + RefreshSupport bool `json:"refreshSupport,omitempty"` +} + +// TextDocumentContentClientCapabilities client capabilities for a text document content provider. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type TextDocumentContentClientCapabilities struct { + // DynamicRegistration text document content provider supports dynamic registration. + // + // @since 3.18.0 proposed + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// WorkspaceClientCapabilities workspace specific client capabilities. +type WorkspaceClientCapabilities struct { + // ApplyEdit the client supports applying batch edits to the workspace by supporting the request 'workspace/applyEdit'. + ApplyEdit bool `json:"applyEdit,omitempty"` + + // WorkspaceEdit capabilities specific to `WorkspaceEdit`s. + WorkspaceEdit *WorkspaceEditClientCapabilities `json:"workspaceEdit,omitempty"` + + // DidChangeConfiguration capabilities specific to the `workspace/didChangeConfiguration` notification. + DidChangeConfiguration *DidChangeConfigurationClientCapabilities `json:"didChangeConfiguration,omitempty"` + + // DidChangeWatchedFiles capabilities specific to the `workspace/didChangeWatchedFiles` notification. + DidChangeWatchedFiles *DidChangeWatchedFilesClientCapabilities `json:"didChangeWatchedFiles,omitempty"` + + // Symbol capabilities specific to the `workspace/symbol` request. + Symbol *WorkspaceSymbolClientCapabilities `json:"symbol,omitempty"` + + // ExecuteCommand capabilities specific to the `workspace/executeCommand` request. + ExecuteCommand *ExecuteCommandClientCapabilities `json:"executeCommand,omitempty"` + + // WorkspaceFolders the client has support for workspace folders. + WorkspaceFolders bool `json:"workspaceFolders,omitempty"` + + // Configuration the client supports `workspace/configuration` requests. + Configuration bool `json:"configuration,omitempty"` + + // SemanticTokens capabilities specific to the semantic token requests scoped to the workspace. + SemanticTokens *SemanticTokensWorkspaceClientCapabilities `json:"semanticTokens,omitempty"` + + // CodeLens capabilities specific to the code lens requests scoped to the workspace. + CodeLens *CodeLensWorkspaceClientCapabilities `json:"codeLens,omitempty"` + + // FileOperations the client has support for file notifications/requests for user operations on files. Since . + FileOperations *FileOperationClientCapabilities `json:"fileOperations,omitempty"` + + // InlineValue capabilities specific to the inline values requests scoped to the workspace. + InlineValue *InlineValueWorkspaceClientCapabilities `json:"inlineValue,omitempty"` + + // InlayHint capabilities specific to the inlay hint requests scoped to the workspace. + InlayHint *InlayHintWorkspaceClientCapabilities `json:"inlayHint,omitempty"` + + // Diagnostics capabilities specific to the diagnostic requests scoped to the workspace. + Diagnostics *DiagnosticWorkspaceClientCapabilities `json:"diagnostics,omitempty"` + + // FoldingRange capabilities specific to the folding range requests scoped to the workspace. 3.18.0 @proposed. + FoldingRange *FoldingRangeWorkspaceClientCapabilities `json:"foldingRange,omitempty"` + + // TextDocumentContent capabilities specific to the `workspace/textDocumentContent` request. 3.18.0 @proposed. + TextDocumentContent *TextDocumentContentClientCapabilities `json:"textDocumentContent,omitempty"` +} + +type TextDocumentSyncClientCapabilities struct { + // DynamicRegistration whether text document synchronization supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // WillSave the client supports sending will save notifications. + WillSave bool `json:"willSave,omitempty"` + + // WillSaveWaitUntil the client supports sending a will save request and waits for a response providing text edits which will be applied to the document before it is saved. + WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` + + // DidSave the client supports did save notifications. + DidSave bool `json:"didSave,omitempty"` +} + +// CompletionItemTagOptions. +// +// @since 3.18.0 +type CompletionItemTagOptions struct { + // ValueSet the tags supported by the client. + // + // @since 3.18.0 + ValueSet []CompletionItemTag `json:"valueSet"` +} + +// ClientCompletionItemResolveOptions. +// +// @since 3.18.0 +type ClientCompletionItemResolveOptions struct { + // Properties the properties that a client can resolve lazily. + // + // @since 3.18.0 + Properties []string `json:"properties"` +} + +// ClientCompletionItemInsertTextModeOptions. +// +// @since 3.18.0 +type ClientCompletionItemInsertTextModeOptions struct { + // @since 3.18.0 + ValueSet []InsertTextMode `json:"valueSet"` +} + +// ClientCompletionItemOptions. +// +// @since 3.18.0 +type ClientCompletionItemOptions struct { + // SnippetSupport client supports snippets as insert text. A snippet can define tab stops and placeholders with `$1`, `$2` and `${3:foo}`. `$0` defines the final tab stop, it defaults to the end of the snippet. Placeholders with equal identifiers are linked, that is typing in one will update others too. + // + // @since 3.18.0 + SnippetSupport bool `json:"snippetSupport,omitempty"` + + // CommitCharactersSupport client supports commit characters on a completion item. + // + // @since 3.18.0 + CommitCharactersSupport bool `json:"commitCharactersSupport,omitempty"` + + // DocumentationFormat client supports the following content formats for the documentation property. The order describes the preferred format of the client. + // + // @since 3.18.0 + DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` + + // DeprecatedSupport client supports the deprecated property on a completion item. + // + // @since 3.18.0 + DeprecatedSupport bool `json:"deprecatedSupport,omitempty"` + + // PreselectSupport client supports the preselect property on a completion item. + // + // @since 3.18.0 + PreselectSupport bool `json:"preselectSupport,omitempty"` + + // TagSupport client supports the tag property on a completion item. Clients supporting tags have to handle unknown tags gracefully. Clients especially need to preserve unknown tags when sending a completion item back to the server in a resolve call. + // @since 3.18.0 + TagSupport *CompletionItemTagOptions `json:"tagSupport,omitempty"` + + // InsertReplaceSupport client support insert replace edit to control different behavior if a completion item is inserted in + // the text or should replace text. + // @since 3.18.0 + InsertReplaceSupport bool `json:"insertReplaceSupport,omitempty"` + + // ResolveSupport indicates which properties a client can resolve lazily on a completion item. Before version 3.16.0 only the predefined properties `documentation` and `details` could be resolved lazily. + // @since 3.18.0 + ResolveSupport *ClientCompletionItemResolveOptions `json:"resolveSupport,omitempty"` + + // InsertTextModeSupport the client supports the `insertTextMode` property on a completion item to override the whitespace handling mode as defined by the client (see `insertTextMode`). + // @since 3.18.0 + InsertTextModeSupport *ClientCompletionItemInsertTextModeOptions `json:"insertTextModeSupport,omitempty"` + + // LabelDetailsSupport the client has support for completion item label details (see also `CompletionItemLabelDetails`). + // @since 3.18.0 + LabelDetailsSupport bool `json:"labelDetailsSupport,omitempty"` +} + +// ClientCompletionItemOptionsKind. +// +// @since 3.18.0 +type ClientCompletionItemOptionsKind struct { + // ValueSet the completion item kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. If this property is not present the client only supports the completion items kinds from `Text` to `Reference` as defined in the initial version of the protocol. + // + // @since 3.18.0 + ValueSet []CompletionItemKind `json:"valueSet,omitempty"` +} + +// CompletionListCapabilities the client supports the following `CompletionList` specific capabilities. +// +// @since 3.17.0 +type CompletionListCapabilities struct { + // ItemDefaults the client supports the following itemDefaults on a completion list. The value lists the supported property names of the `CompletionList.itemDefaults` object. If omitted no properties are supported. + // @since 3.17.0 + ItemDefaults []string `json:"itemDefaults,omitempty"` + + // ApplyKindSupport specifies whether the client supports `CompletionList.applyKind` to indicate how supported values from `completionList.itemDefaults` and `completion` will be combined. If a client supports `applyKind` + // it must support it for all fields that it supports that are listed in `CompletionList.applyKind`. This means when clients add support for new/future fields in completion items the MUST also support merge for them if those fields are defined in `CompletionList.applyKind`. + // @since 3.17.0 + ApplyKindSupport bool `json:"applyKindSupport,omitempty"` +} + +// CompletionClientCapabilities completion client capabilities. +type CompletionClientCapabilities struct { + // DynamicRegistration whether completion supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // CompletionItem the client supports the following `CompletionItem` specific capabilities. + CompletionItem *ClientCompletionItemOptions `json:"completionItem,omitempty"` + + CompletionItemKind *ClientCompletionItemOptionsKind `json:"completionItemKind,omitempty"` + + // InsertTextMode defines how the client handles whitespace and indentation when accepting a completion item that uses + // multi line text in either `insertText` or `textEdit`. + InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"` + + // ContextSupport the client supports to send additional context information for a `textDocument/completion` request. + ContextSupport bool `json:"contextSupport,omitempty"` + + // CompletionList the client supports the following `CompletionList` specific capabilities. + CompletionList *CompletionListCapabilities `json:"completionList,omitempty"` +} + +type HoverClientCapabilities struct { + // DynamicRegistration whether hover supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // ContentFormat client supports the following content formats for the content property. The order describes the preferred format of the client. + ContentFormat []MarkupKind `json:"contentFormat,omitempty"` +} + +// ClientSignatureParameterInformationOptions. +// +// @since 3.18.0 +type ClientSignatureParameterInformationOptions struct { + // LabelOffsetSupport the client supports processing label offsets instead of a simple label string. + // @since 3.18.0 + LabelOffsetSupport bool `json:"labelOffsetSupport,omitempty"` +} + +// ClientSignatureInformationOptions. +// +// @since 3.18.0 +type ClientSignatureInformationOptions struct { + // DocumentationFormat client supports the following content formats for the documentation property. The order describes the preferred format of the client. + // + // @since 3.18.0 + DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` + + // ParameterInformation client capabilities specific to parameter information. + // + // @since 3.18.0 + ParameterInformation *ClientSignatureParameterInformationOptions `json:"parameterInformation,omitempty"` + + // ActiveParameterSupport the client supports the `activeParameter` property on `SignatureInformation` literal. + // @since 3.18.0 + ActiveParameterSupport bool `json:"activeParameterSupport,omitempty"` + + // NoActiveParameterSupport the client supports the `activeParameter` property on `SignatureHelp`/`SignatureInformation` being set to `null` to indicate that no parameter should be active. 3.18.0 @proposed. + // @since 3.18.0 + NoActiveParameterSupport bool `json:"noActiveParameterSupport,omitempty"` +} + +// SignatureHelpClientCapabilities client Capabilities for a SignatureHelpRequest. +type SignatureHelpClientCapabilities struct { + // DynamicRegistration whether signature help supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // SignatureInformation the client supports the following `SignatureInformation` specific properties. + SignatureInformation *ClientSignatureInformationOptions `json:"signatureInformation,omitempty"` + + // ContextSupport the client supports to send additional context information for a `textDocument/signatureHelp` request. A client that opts into contextSupport will also support the `retriggerCharacters` on `SignatureHelpOptions`. + ContextSupport bool `json:"contextSupport,omitempty"` +} + +// DeclarationClientCapabilities. +// +// @since 3.14.0 +type DeclarationClientCapabilities struct { + // DynamicRegistration whether declaration supports dynamic registration. If this is set to `true` the client supports the new `DeclarationRegistrationOptions` return value for the corresponding server capability as well. + // + // @since 3.14.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // LinkSupport the client supports additional metadata in the form of declaration links. + // + // @since 3.14.0 + LinkSupport bool `json:"linkSupport,omitempty"` +} + +// DefinitionClientCapabilities client Capabilities for a DefinitionRequest. +type DefinitionClientCapabilities struct { + // DynamicRegistration whether definition supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // LinkSupport the client supports additional metadata in the form of definition links. + LinkSupport bool `json:"linkSupport,omitempty"` +} + +// TypeDefinitionClientCapabilities since . +type TypeDefinitionClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration. If this is set to `true` the client supports the new `TypeDefinitionRegistrationOptions` return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // LinkSupport the client supports additional metadata in the form of definition links. Since . + LinkSupport bool `json:"linkSupport,omitempty"` +} + +// ImplementationClientCapabilities. +// +// @since 3.6.0 +type ImplementationClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration. If this is set to `true` the client supports the new `ImplementationRegistrationOptions` return value for the corresponding server capability as well. + // + // @since 3.6.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // LinkSupport the client supports additional metadata in the form of definition links. + // @since 3.6.0 + LinkSupport bool `json:"linkSupport,omitempty"` +} + +// ReferenceClientCapabilities client Capabilities for a ReferencesRequest. +type ReferenceClientCapabilities struct { + // DynamicRegistration whether references supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// DocumentHighlightClientCapabilities client Capabilities for a DocumentHighlightRequest. +type DocumentHighlightClientCapabilities struct { + // DynamicRegistration whether document highlight supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// DocumentSymbolClientCapabilities client Capabilities for a DocumentSymbolRequest. +type DocumentSymbolClientCapabilities struct { + // DynamicRegistration whether document symbol supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // SymbolKind specific capabilities for the `SymbolKind` in the `textDocument/documentSymbol` request. + SymbolKind *ClientSymbolKindOptions `json:"symbolKind,omitempty"` + + // HierarchicalDocumentSymbolSupport the client supports hierarchical document symbols. + HierarchicalDocumentSymbolSupport bool `json:"hierarchicalDocumentSymbolSupport,omitempty"` + + // TagSupport the client supports tags on `SymbolInformation`. Tags are supported on `DocumentSymbol` if `hierarchicalDocumentSymbolSupport` is set to true. Clients supporting tags have to handle unknown tags gracefully. + TagSupport *ClientSymbolTagOptions `json:"tagSupport,omitempty"` + + // LabelSupport the client supports an additional label presented in the UI when registering a document symbol provider. + LabelSupport bool `json:"labelSupport,omitempty"` +} + +// ClientCodeActionKindOptions. +// +// @since 3.18.0 +type ClientCodeActionKindOptions struct { + // ValueSet the code action kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. + // + // @since 3.18.0 + ValueSet []CodeActionKind `json:"valueSet"` +} + +// ClientCodeActionLiteralOptions. +// +// @since 3.18.0 +type ClientCodeActionLiteralOptions struct { + // CodeActionKind the code action kind is support with the following value set. + // + // @since 3.18.0 + CodeActionKind ClientCodeActionKindOptions `json:"codeActionKind"` +} + +// ClientCodeActionResolveOptions. +// +// @since 3.18.0 +type ClientCodeActionResolveOptions struct { + // Properties the properties that a client can resolve lazily. + // + // @since 3.18.0 + Properties []string `json:"properties"` +} + +// CodeActionClientCapabilities the Client Capabilities of a CodeActionRequest. +type CodeActionClientCapabilities struct { + // DynamicRegistration whether code action supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // CodeActionLiteralSupport the client support code action literals of type `CodeAction` as a valid response of the `textDocument/codeAction` request. If the property is not set the request can only return `Command` literals. + CodeActionLiteralSupport *ClientCodeActionLiteralOptions `json:"codeActionLiteralSupport,omitempty"` + + // IsPreferredSupport whether code action supports the `isPreferred` property. + IsPreferredSupport bool `json:"isPreferredSupport,omitempty"` + + // DisabledSupport whether code action supports the `disabled` property. + DisabledSupport bool `json:"disabledSupport,omitempty"` + + // DataSupport whether code action supports the `data` property which is preserved between a `textDocument/codeAction` and a `codeAction/resolve` request. + DataSupport bool `json:"dataSupport,omitempty"` + + // ResolveSupport whether the client supports resolving additional code action properties via a separate `codeAction/resolve` request. + ResolveSupport *ClientCodeActionResolveOptions `json:"resolveSupport,omitempty"` + + // HonorsChangeAnnotations whether the client honors the change annotations in text edits and resource operations returned via the `CodeAction#edit` property by for example presenting the workspace edit in the user interface and asking for confirmation. + HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitempty"` + + // DocumentationSupport whether the client supports documentation for a class of code actions. 3.18.0 @proposed. + DocumentationSupport bool `json:"documentationSupport,omitempty"` + + // TagSupport client supports the tag property on a code action. Clients supporting tags have to handle unknown tags gracefully. 3.18.0 - proposed. + TagSupport *CodeActionTagOptions `json:"tagSupport,omitempty"` +} + +// ClientCodeLensResolveOptions. +// +// @since 3.18.0 +type ClientCodeLensResolveOptions struct { + // Properties the properties that a client can resolve lazily. + // + // @since 3.18.0 + Properties []string `json:"properties"` +} + +// CodeLensClientCapabilities the client capabilities of a CodeLensRequest. +type CodeLensClientCapabilities struct { + // DynamicRegistration whether code lens supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // ResolveSupport whether the client supports resolving additional code lens properties via a separate `codeLens/resolve` request. + ResolveSupport *ClientCodeLensResolveOptions `json:"resolveSupport,omitempty"` +} + +// DocumentLinkClientCapabilities the client capabilities of a DocumentLinkRequest. +type DocumentLinkClientCapabilities struct { + // DynamicRegistration whether document link supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // TooltipSupport whether the client supports the `tooltip` property on `DocumentLink`. + TooltipSupport bool `json:"tooltipSupport,omitempty"` +} + +type DocumentColorClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration. If this is set to `true` the client supports the new `DocumentColorRegistrationOptions` return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// DocumentFormattingClientCapabilities client capabilities of a DocumentFormattingRequest. +type DocumentFormattingClientCapabilities struct { + // DynamicRegistration whether formatting supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// DocumentRangeFormattingClientCapabilities client capabilities of a DocumentRangeFormattingRequest. +type DocumentRangeFormattingClientCapabilities struct { + // DynamicRegistration whether range formatting supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // RangesSupport whether the client supports formatting multiple ranges at once. 3.18.0 @proposed. + RangesSupport bool `json:"rangesSupport,omitempty"` +} + +// DocumentOnTypeFormattingClientCapabilities client capabilities of a DocumentOnTypeFormattingRequest. +type DocumentOnTypeFormattingClientCapabilities struct { + // DynamicRegistration whether on type formatting supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +type RenameClientCapabilities struct { + // DynamicRegistration whether rename supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // PrepareSupport client supports testing for validity of rename operations before execution. + PrepareSupport bool `json:"prepareSupport,omitempty"` + + // PrepareSupportDefaultBehavior client supports the default behavior result. The value indicates the default behavior used by the client. + PrepareSupportDefaultBehavior PrepareSupportDefaultBehavior `json:"prepareSupportDefaultBehavior,omitempty"` + + // HonorsChangeAnnotations whether the client honors the change annotations in text edits and resource operations returned via the rename request's workspace edit by for example presenting the workspace edit in the user interface and asking for confirmation. + HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitempty"` +} + +// ClientFoldingRangeKindOptions. +// +// @since 3.18.0 +type ClientFoldingRangeKindOptions struct { + // ValueSet the folding range kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. + // + // @since 3.18.0 + ValueSet []FoldingRangeKind `json:"valueSet,omitempty"` +} + +// ClientFoldingRangeOptions. +// +// @since 3.18.0 +type ClientFoldingRangeOptions struct { + // CollapsedText if set, the client signals that it supports setting collapsedText on folding ranges to display custom labels instead of the default text. + // @since 3.18.0 + CollapsedText bool `json:"collapsedText,omitempty"` +} + +type FoldingRangeClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration for folding range providers. If this is set to `true` the client supports the new `FoldingRangeRegistrationOptions` return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // RangeLimit the maximum number of folding ranges that the client prefers to receive per document. The value serves as a hint, servers are free to follow the limit. + RangeLimit uint32 `json:"rangeLimit,omitempty"` + + // LineFoldingOnly if set, the client signals that it only supports folding complete lines. If set, client will ignore specified `startCharacter` and `endCharacter` properties in a FoldingRange. + LineFoldingOnly bool `json:"lineFoldingOnly,omitempty"` + + // FoldingRangeKind specific options for the folding range kind. + FoldingRangeKind *ClientFoldingRangeKindOptions `json:"foldingRangeKind,omitempty"` + + // FoldingRange specific options for the folding range. + FoldingRange *ClientFoldingRangeOptions `json:"foldingRange,omitempty"` +} + +type SelectionRangeClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration for selection range providers. If this is set to `true` the client supports the new `SelectionRangeRegistrationOptions` return value for the corresponding server capability as well. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// ClientDiagnosticsTagOptions. +// +// @since 3.18.0 +type ClientDiagnosticsTagOptions struct { + // ValueSet the tags supported by the client. + // + // @since 3.18.0 + ValueSet []DiagnosticTag `json:"valueSet"` +} + +// DiagnosticsCapabilities general diagnostics capabilities for pull and push model. +type DiagnosticsCapabilities struct { + // RelatedInformation whether the clients accepts diagnostics with related information. + RelatedInformation bool `json:"relatedInformation,omitempty"` + + // TagSupport client supports the tag property to provide meta data about a diagnostic. Clients supporting tags have to handle unknown tags gracefully. + TagSupport *ClientDiagnosticsTagOptions `json:"tagSupport,omitempty"` + + // CodeDescriptionSupport client supports a codeDescription property + CodeDescriptionSupport bool `json:"codeDescriptionSupport,omitempty"` + + // DataSupport whether code action supports the `data` property which is preserved between a `textDocument/publishDiagnostics` and `textDocument/codeAction` request. + DataSupport bool `json:"dataSupport,omitempty"` +} + +// PublishDiagnosticsClientCapabilities the publish diagnostic client capabilities. +type PublishDiagnosticsClientCapabilities struct { + // extends + DiagnosticsCapabilities + + // VersionSupport whether the client interprets the version property of the `textDocument/publishDiagnostics` notification's parameter. + VersionSupport bool `json:"versionSupport,omitempty"` +} + +// CallHierarchyClientCapabilities. +// +// @since 3.16.0 +type CallHierarchyClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// ClientSemanticTokensRequestFullDelta. +// +// @since 3.18.0 +type ClientSemanticTokensRequestFullDelta struct { + // Delta the client will send the `textDocument/semanticTokens/full/delta` request if the server provides a corresponding handler. + // + // @since 3.18.0 + Delta bool `json:"delta,omitempty"` +} + +// ClientSemanticTokensRequestOptions. +// +// @since 3.18.0 +type ClientSemanticTokensRequestOptions struct { + // Range the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. + // + // @since 3.18.0 + Range *ClientSemanticTokensRequestOptionsRange `json:"range,omitempty"` + + // Full the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. + // + // @since 3.18.0 + Full *ClientSemanticTokensRequestOptionsFull `json:"full,omitempty"` +} + +// SemanticTokensClientCapabilities. +// +// @since 3.16.0 +type SemanticTokensClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // Requests which requests the client supports and might send to the server depending on the server's capability. Please note that clients might not show semantic tokens or degrade some of the user experience if a range or full request is advertised by the client but not provided by the server. If for example the client capability `requests.full` and `request.range` are both set to true but the server only provides a range provider the client might not render a minimap correctly or might even decide to not show any semantic tokens at all. + // + // @since 3.16.0 + Requests ClientSemanticTokensRequestOptions `json:"requests"` + + // TokenTypes the token types that the client supports. + // + // @since 3.16.0 + TokenTypes []string `json:"tokenTypes"` + + // TokenModifiers the token modifiers that the client supports. + // + // @since 3.16.0 + TokenModifiers []string `json:"tokenModifiers"` + + // Formats the token formats the clients supports. + // + // @since 3.16.0 + Formats []TokenFormat `json:"formats"` + + // OverlappingTokenSupport whether the client supports tokens that can overlap each other. + // + // @since 3.16.0 + OverlappingTokenSupport bool `json:"overlappingTokenSupport,omitempty"` + + // MultilineTokenSupport whether the client supports tokens that can span multiple lines. + // + // @since 3.16.0 + MultilineTokenSupport bool `json:"multilineTokenSupport,omitempty"` + + // ServerCancelSupport whether the client allows the server to actively cancel a semantic token request, e.g. supports returning LSPErrorCodes.ServerCancelled. If a server does the client needs to retrigger the request. + // @since 3.16.0 + ServerCancelSupport bool `json:"serverCancelSupport,omitempty"` + + // AugmentsSyntaxTokens whether the client uses semantic tokens to augment existing syntax tokens. If set to `true` client side created syntax tokens and semantic tokens are both used for colorization. If set to `false` the client only uses the returned semantic tokens for colorization. If the value is `undefined` then the + // client behavior is not specified. + // @since 3.16.0 + AugmentsSyntaxTokens bool `json:"augmentsSyntaxTokens,omitempty"` +} + +// LinkedEditingRangeClientCapabilities client capabilities for the linked editing range request. +// +// @since 3.16.0 +type LinkedEditingRangeClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// MonikerClientCapabilities client capabilities specific to the moniker request. +// +// @since 3.16.0 +type MonikerClientCapabilities struct { + // DynamicRegistration whether moniker supports dynamic registration. If this is set to `true` the client supports the new `MonikerRegistrationOptions` return value for the corresponding server capability as well. + // + // @since 3.16.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// TypeHierarchyClientCapabilities. +// +// @since 3.17.0 +type TypeHierarchyClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// InlineValueClientCapabilities client capabilities specific to inline values. +// +// @since 3.17.0 +type InlineValueClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration for inline value providers. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// ClientInlayHintResolveOptions. +// +// @since 3.18.0 +type ClientInlayHintResolveOptions struct { + // Properties the properties that a client can resolve lazily. + // + // @since 3.18.0 + Properties []string `json:"properties"` +} + +// InlayHintClientCapabilities inlay hint client capabilities. +// +// @since 3.17.0 +type InlayHintClientCapabilities struct { + // DynamicRegistration whether inlay hints support dynamic registration. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // ResolveSupport indicates which properties a client can resolve lazily on an inlay hint. + // + // @since 3.17.0 + ResolveSupport *ClientInlayHintResolveOptions `json:"resolveSupport,omitempty"` +} + +// DiagnosticClientCapabilities client capabilities specific to diagnostic pull requests. +// +// @since 3.17.0 +type DiagnosticClientCapabilities struct { + // extends + DiagnosticsCapabilities + + // DynamicRegistration 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. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // RelatedDocumentSupport whether the clients supports related documents for document diagnostic pulls. + // + // @since 3.17.0 + RelatedDocumentSupport bool `json:"relatedDocumentSupport,omitempty"` +} + +// InlineCompletionClientCapabilities client capabilities specific to inline completions. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionClientCapabilities struct { + // DynamicRegistration whether implementation supports dynamic registration for inline completion providers. + // + // @since 3.18.0 proposed + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +// TextDocumentClientCapabilities text document specific client capabilities. +type TextDocumentClientCapabilities struct { + // Synchronization defines which synchronization capabilities the client supports. + Synchronization *TextDocumentSyncClientCapabilities `json:"synchronization,omitempty"` + + // Completion capabilities specific to the `textDocument/completion` request. + Completion *CompletionClientCapabilities `json:"completion,omitempty"` + + // Hover capabilities specific to the `textDocument/hover` request. + Hover *HoverClientCapabilities `json:"hover,omitempty"` + + // SignatureHelp capabilities specific to the `textDocument/signatureHelp` request. + SignatureHelp *SignatureHelpClientCapabilities `json:"signatureHelp,omitempty"` + + // Declaration capabilities specific to the `textDocument/declaration` request. + Declaration *DeclarationClientCapabilities `json:"declaration,omitempty"` + + // Definition capabilities specific to the `textDocument/definition` request. + Definition *DefinitionClientCapabilities `json:"definition,omitempty"` + + // TypeDefinition capabilities specific to the `textDocument/typeDefinition` request. + TypeDefinition *TypeDefinitionClientCapabilities `json:"typeDefinition,omitempty"` + + // Implementation capabilities specific to the `textDocument/implementation` request. + Implementation *ImplementationClientCapabilities `json:"implementation,omitempty"` + + // References capabilities specific to the `textDocument/references` request. + References *ReferenceClientCapabilities `json:"references,omitempty"` + + // DocumentHighlight capabilities specific to the `textDocument/documentHighlight` request. + DocumentHighlight *DocumentHighlightClientCapabilities `json:"documentHighlight,omitempty"` + + // DocumentSymbol capabilities specific to the `textDocument/documentSymbol` request. + DocumentSymbol *DocumentSymbolClientCapabilities `json:"documentSymbol,omitempty"` + + // CodeAction capabilities specific to the `textDocument/codeAction` request. + CodeAction *CodeActionClientCapabilities `json:"codeAction,omitempty"` + + // CodeLens capabilities specific to the `textDocument/codeLens` request. + CodeLens *CodeLensClientCapabilities `json:"codeLens,omitempty"` + + // DocumentLink capabilities specific to the `textDocument/documentLink` request. + DocumentLink *DocumentLinkClientCapabilities `json:"documentLink,omitempty"` + + // ColorProvider capabilities specific to the `textDocument/documentColor` and the `textDocument/colorPresentation` request. + ColorProvider *DocumentColorClientCapabilities `json:"colorProvider,omitempty"` + + // Formatting capabilities specific to the `textDocument/formatting` request. + Formatting *DocumentFormattingClientCapabilities `json:"formatting,omitempty"` + + // RangeFormatting capabilities specific to the `textDocument/rangeFormatting` request. + RangeFormatting *DocumentRangeFormattingClientCapabilities `json:"rangeFormatting,omitempty"` + + // OnTypeFormatting capabilities specific to the `textDocument/onTypeFormatting` request. + OnTypeFormatting *DocumentOnTypeFormattingClientCapabilities `json:"onTypeFormatting,omitempty"` + + // Rename capabilities specific to the `textDocument/rename` request. + Rename *RenameClientCapabilities `json:"rename,omitempty"` + + // FoldingRange capabilities specific to the `textDocument/foldingRange` request. + FoldingRange *FoldingRangeClientCapabilities `json:"foldingRange,omitempty"` + + // SelectionRange capabilities specific to the `textDocument/selectionRange` request. + SelectionRange *SelectionRangeClientCapabilities `json:"selectionRange,omitempty"` + + // PublishDiagnostics capabilities specific to the `textDocument/publishDiagnostics` notification. + PublishDiagnostics *PublishDiagnosticsClientCapabilities `json:"publishDiagnostics,omitempty"` + + // CallHierarchy capabilities specific to the various call hierarchy requests. + CallHierarchy *CallHierarchyClientCapabilities `json:"callHierarchy,omitempty"` + + // SemanticTokens capabilities specific to the various semantic token request. + SemanticTokens *SemanticTokensClientCapabilities `json:"semanticTokens,omitempty"` + + // LinkedEditingRange capabilities specific to the `textDocument/linkedEditingRange` request. + LinkedEditingRange *LinkedEditingRangeClientCapabilities `json:"linkedEditingRange,omitempty"` + + // Moniker client capabilities specific to the `textDocument/moniker` request. + Moniker *MonikerClientCapabilities `json:"moniker,omitempty"` + + // TypeHierarchy capabilities specific to the various type hierarchy requests. + TypeHierarchy *TypeHierarchyClientCapabilities `json:"typeHierarchy,omitempty"` + + // InlineValue capabilities specific to the `textDocument/inlineValue` request. + InlineValue *InlineValueClientCapabilities `json:"inlineValue,omitempty"` + + // InlayHint capabilities specific to the `textDocument/inlayHint` request. + InlayHint *InlayHintClientCapabilities `json:"inlayHint,omitempty"` + + // Diagnostic capabilities specific to the diagnostic pull model. + Diagnostic *DiagnosticClientCapabilities `json:"diagnostic,omitempty"` + + // InlineCompletion client capabilities specific to inline completions. 3.18.0 @proposed. + InlineCompletion *InlineCompletionClientCapabilities `json:"inlineCompletion,omitempty"` +} + +// NotebookDocumentSyncClientCapabilities notebook specific client capabilities. +// +// @since 3.17.0 +type NotebookDocumentSyncClientCapabilities struct { + // DynamicRegistration 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. + // + // @since 3.17.0 + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // ExecutionSummarySupport the client supports sending execution summary data per cell. + // + // @since 3.17.0 + ExecutionSummarySupport bool `json:"executionSummarySupport,omitempty"` +} + +// NotebookDocumentClientCapabilities capabilities specific to the notebook document support. +// +// @since 3.17.0 +type NotebookDocumentClientCapabilities struct { + // Synchronization capabilities specific to notebook document synchronization + // @since 3.17.0 + Synchronization NotebookDocumentSyncClientCapabilities `json:"synchronization"` +} + +// ClientShowMessageActionItemOptions. +// +// @since 3.18.0 +type ClientShowMessageActionItemOptions struct { + // AdditionalPropertiesSupport whether the client supports additional attributes which are preserved and send back to the server in + // the request's response. + // + // @since 3.18.0 + AdditionalPropertiesSupport bool `json:"additionalPropertiesSupport,omitempty"` +} + +// ShowMessageRequestClientCapabilities show message request client capabilities. +type ShowMessageRequestClientCapabilities struct { + // MessageActionItem capabilities specific to the `MessageActionItem` type. + MessageActionItem *ClientShowMessageActionItemOptions `json:"messageActionItem,omitempty"` +} + +// ShowDocumentClientCapabilities client capabilities for the showDocument request. +// +// @since 3.16.0 +type ShowDocumentClientCapabilities struct { + // Support the client has support for the showDocument request. + // + // @since 3.16.0 + Support bool `json:"support"` +} + +type WindowClientCapabilities struct { + // WorkDoneProgress it indicates whether the client supports server initiated progress using the `window/workDoneProgress/create` request. The capability also controls Whether client supports handling of progress notifications. If set servers are allowed to report a `workDoneProgress` property in the request specific server capabilities. + WorkDoneProgress bool `json:"workDoneProgress,omitempty"` + + // ShowMessage capabilities specific to the showMessage request. + ShowMessage *ShowMessageRequestClientCapabilities `json:"showMessage,omitempty"` + + // ShowDocument capabilities specific to the showDocument request. + ShowDocument *ShowDocumentClientCapabilities `json:"showDocument,omitempty"` +} + +// StaleRequestSupportOptions. +// +// @since 3.18.0 +type StaleRequestSupportOptions struct { + // Cancel the client will actively cancel the request. + // + // @since 3.18.0 + Cancel bool `json:"cancel"` + + // RetryOnContentModified the list of requests for which the client will retry the request if it receives a response with error code `ContentModified`. + // + // @since 3.18.0 + RetryOnContentModified []string `json:"retryOnContentModified"` +} + +// RegularExpressionsClientCapabilities client capabilities specific to regular expressions. +// +// @since 3.16.0 +type RegularExpressionsClientCapabilities struct { + // Engine the engine's name. + // + // @since 3.16.0 + Engine RegularExpressionEngineKind `json:"engine"` + + // Version the engine's version. + // + // @since 3.16.0 + Version string `json:"version,omitempty"` +} + +// MarkdownClientCapabilities client capabilities specific to the used markdown parser. +// +// @since 3.16.0 +type MarkdownClientCapabilities struct { + // Parser the name of the parser. + // + // @since 3.16.0 + Parser string `json:"parser"` + + // Version the version of the parser. + // + // @since 3.16.0 + Version string `json:"version,omitempty"` + + // AllowedTags a list of HTML tags that the client allows / supports in Markdown. + // @since 3.16.0 + AllowedTags []string `json:"allowedTags,omitempty"` +} + +// GeneralClientCapabilities general client capabilities. +// +// @since 3.16.0 +type GeneralClientCapabilities struct { + // StaleRequestSupport client capability that signals how the client handles stale requests (e.g. a request for which the client will not process the response anymore since the information is outdated). + // @since 3.16.0 + StaleRequestSupport *StaleRequestSupportOptions `json:"staleRequestSupport,omitempty"` + + // RegularExpressions client capabilities specific to regular expressions. + // @since 3.16.0 + RegularExpressions *RegularExpressionsClientCapabilities `json:"regularExpressions,omitempty"` + + // Markdown client capabilities specific to the client's markdown parser. + // @since 3.16.0 + Markdown *MarkdownClientCapabilities `json:"markdown,omitempty"` + + // PositionEncodings the position encodings supported by the client. Client and server have to agree on the same position + // encoding to ensure that offsets (e.g. character position in a line) are interpreted the same on both sides. To keep the protocol backwards compatible the following applies: if the value 'utf-16' + // is missing from the array of position encodings servers can assume that the client supports UTF-16. UTF-16 is therefore a mandatory encoding. If omitted it defaults to ['utf-16']. Implementation + // considerations: since the conversion from one encoding into another requires the content of the file / line the conversion is best done where the file is read which is usually on the server side. + // @since 3.16.0 + PositionEncodings []PositionEncodingKind `json:"positionEncodings,omitempty"` +} + +// ClientCapabilities defines the capabilities provided by the client. +type ClientCapabilities struct { + // Workspace workspace specific client capabilities. + Workspace *WorkspaceClientCapabilities `json:"workspace,omitempty"` + + // TextDocument text document specific client capabilities. + TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"` + + // NotebookDocument capabilities specific to the notebook document support. + NotebookDocument *NotebookDocumentClientCapabilities `json:"notebookDocument,omitempty"` + + // Window window specific client capabilities. + Window *WindowClientCapabilities `json:"window,omitempty"` + + // General general client capabilities. + General *GeneralClientCapabilities `json:"general,omitempty"` + + // Experimental experimental client capabilities. + Experimental any `json:"experimental,omitempty"` +} + +// InitializeParamsBase the initialize parameters. +type InitializeParamsBase struct { + // mixins + WorkDoneProgressParams + + // ProcessID the process Id of the parent process that started the server. Is `null` if the process has not been started by another process. If the parent process is not alive then the server should exit. + ProcessID int32 `json:"processId,omitempty"` + + // ClientInfo information about the client + ClientInfo *ClientInfo `json:"clientInfo,omitempty"` + + // Locale the locale the client is currently showing the user interface in. This must not necessarily be the locale of the operating system. Uses IETF language tags as the value's syntax (See https://en.wikipedia.org/wiki/IETF_language_tag) + Locale string `json:"locale,omitempty"` + + // RootPath the rootPath of the workspace. Is null if no folder is open. // // Deprecated: in favour of rootUri. + RootPath string `json:"rootPath,omitempty"` + + // RootURI the rootUri of the workspace. Is null if no folder is open. If both `rootPath` and `rootUri` are set + // `rootUri` wins. // // Deprecated: in favour of workspaceFolders. + RootURI DocumentURI `json:"rootUri,omitempty"` + + // Capabilities the capabilities provided by the client (editor or tool). + Capabilities ClientCapabilities `json:"capabilities"` + + // InitializationOptions user provided initialization options. + InitializationOptions any `json:"initializationOptions,omitempty"` + + // Trace the initial trace setting. If omitted trace is disabled ('off'). + Trace TraceValue `json:"trace,omitempty"` +} + +type WorkspaceFoldersInitializeParams struct { + // WorkspaceFolders the workspace folders configured in the client when the server starts. This property is only available if the client supports workspace folders. It can be `null` if the client supports workspace folders but none are configured. + WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders,omitempty"` +} + +type InitializeParams struct { + // extends + InitializeParamsBase + WorkspaceFoldersInitializeParams +} + +// FileOperationOptions options for notifications/requests for user operations on files. +// +// @since 3.16.0 +type FileOperationOptions struct { + // DidCreate the server is interested in receiving didCreateFiles notifications. + // + // @since 3.16.0 + DidCreate *FileOperationRegistrationOptions `json:"didCreate,omitempty"` + + // WillCreate the server is interested in receiving willCreateFiles requests. + // + // @since 3.16.0 + WillCreate *FileOperationRegistrationOptions `json:"willCreate,omitempty"` + + // DidRename the server is interested in receiving didRenameFiles notifications. + // + // @since 3.16.0 + DidRename *FileOperationRegistrationOptions `json:"didRename,omitempty"` + + // WillRename the server is interested in receiving willRenameFiles requests. + // + // @since 3.16.0 + WillRename *FileOperationRegistrationOptions `json:"willRename,omitempty"` + + // DidDelete the server is interested in receiving didDeleteFiles file notifications. + // + // @since 3.16.0 + DidDelete *FileOperationRegistrationOptions `json:"didDelete,omitempty"` + + // WillDelete the server is interested in receiving willDeleteFiles file requests. + // + // @since 3.16.0 + WillDelete *FileOperationRegistrationOptions `json:"willDelete,omitempty"` +} + +// WorkspaceOptions defines workspace specific capabilities of the server. +// +// @since 3.18.0 +type WorkspaceOptions struct { + // WorkspaceFolders the server supports workspace folder. + // @since 3.18.0 + WorkspaceFolders *WorkspaceFoldersServerCapabilities `json:"workspaceFolders,omitempty"` + + // FileOperations the server is interested in notifications/requests for operations on files. + // @since 3.18.0 + FileOperations *FileOperationOptions `json:"fileOperations,omitempty"` + + // TextDocumentContent the server supports the `workspace/textDocumentContent` request. 3.18.0 @proposed. + // @since 3.18.0 + TextDocumentContent *WorkspaceOptionsTextDocumentContent `json:"textDocumentContent,omitempty"` +} + +// ServerCapabilities defines the capabilities provided by a language server. +type ServerCapabilities struct { + // PositionEncoding the position encoding the server picked from the encodings offered by the client via the client capability `general.positionEncodings`. If the client didn't provide any position encodings the only valid value that a server can return is 'utf-16'. If omitted it defaults to 'utf-16'. + PositionEncoding PositionEncodingKind `json:"positionEncoding,omitempty"` + + // TextDocumentSync defines how text documents are synced. Is either a detailed structure defining each notification or for backwards compatibility the TextDocumentSyncKind number. + TextDocumentSync *ServerCapabilitiesTextDocumentSync `json:"textDocumentSync,omitempty"` + + // NotebookDocumentSync defines how notebook documents are synced. + NotebookDocumentSync *ServerCapabilitiesNotebookDocumentSync `json:"notebookDocumentSync,omitempty"` + + // CompletionProvider the server provides completion support. + CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"` + + // HoverProvider the server provides hover support. + HoverProvider *ServerCapabilitiesHoverProvider `json:"hoverProvider,omitempty"` + + // SignatureHelpProvider the server provides signature help support. + SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` + + // DeclarationProvider the server provides Goto Declaration support. + DeclarationProvider *ServerCapabilitiesDeclarationProvider `json:"declarationProvider,omitempty"` + + // DefinitionProvider the server provides goto definition support. + DefinitionProvider *ServerCapabilitiesDefinitionProvider `json:"definitionProvider,omitempty"` + + // TypeDefinitionProvider the server provides Goto Type Definition support. + TypeDefinitionProvider *ServerCapabilitiesTypeDefinitionProvider `json:"typeDefinitionProvider,omitempty"` + + // ImplementationProvider the server provides Goto Implementation support. + ImplementationProvider *ServerCapabilitiesImplementationProvider `json:"implementationProvider,omitempty"` + + // ReferencesProvider the server provides find references support. + ReferencesProvider *ServerCapabilitiesReferencesProvider `json:"referencesProvider,omitempty"` + + // DocumentHighlightProvider the server provides document highlight support. + DocumentHighlightProvider *ServerCapabilitiesDocumentHighlightProvider `json:"documentHighlightProvider,omitempty"` + + // DocumentSymbolProvider the server provides document symbol support. + DocumentSymbolProvider *ServerCapabilitiesDocumentSymbolProvider `json:"documentSymbolProvider,omitempty"` + + // CodeActionProvider the server provides code actions. CodeActionOptions may only be specified if the client states that it supports `codeActionLiteralSupport` in its initial `initialize` request. + CodeActionProvider *ServerCapabilitiesCodeActionProvider `json:"codeActionProvider,omitempty"` + + // CodeLensProvider the server provides code lens. + CodeLensProvider *CodeLensOptions `json:"codeLensProvider,omitempty"` + + // DocumentLinkProvider the server provides document link support. + DocumentLinkProvider *DocumentLinkOptions `json:"documentLinkProvider,omitempty"` + + // ColorProvider the server provides color provider support. + ColorProvider *ServerCapabilitiesColorProvider `json:"colorProvider,omitempty"` + + // WorkspaceSymbolProvider the server provides workspace symbol support. + WorkspaceSymbolProvider *ServerCapabilitiesWorkspaceSymbolProvider `json:"workspaceSymbolProvider,omitempty"` + + // DocumentFormattingProvider the server provides document formatting. + DocumentFormattingProvider *ServerCapabilitiesDocumentFormattingProvider `json:"documentFormattingProvider,omitempty"` + + // DocumentRangeFormattingProvider the server provides document range formatting. + DocumentRangeFormattingProvider *ServerCapabilitiesDocumentRangeFormattingProvider `json:"documentRangeFormattingProvider,omitempty"` + + // DocumentOnTypeFormattingProvider the server provides document formatting on typing. + DocumentOnTypeFormattingProvider *DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"` + + // RenameProvider the server provides rename support. RenameOptions may only be specified if the client states that it + // supports `prepareSupport` in its initial `initialize` request. + RenameProvider *ServerCapabilitiesRenameProvider `json:"renameProvider,omitempty"` + + // FoldingRangeProvider the server provides folding provider support. + FoldingRangeProvider *ServerCapabilitiesFoldingRangeProvider `json:"foldingRangeProvider,omitempty"` + + // SelectionRangeProvider the server provides selection range support. + SelectionRangeProvider *ServerCapabilitiesSelectionRangeProvider `json:"selectionRangeProvider,omitempty"` + + // ExecuteCommandProvider the server provides execute command support. + ExecuteCommandProvider *ExecuteCommandOptions `json:"executeCommandProvider,omitempty"` + + // CallHierarchyProvider the server provides call hierarchy support. + CallHierarchyProvider *ServerCapabilitiesCallHierarchyProvider `json:"callHierarchyProvider,omitempty"` + + // LinkedEditingRangeProvider the server provides linked editing range support. + LinkedEditingRangeProvider *ServerCapabilitiesLinkedEditingRangeProvider `json:"linkedEditingRangeProvider,omitempty"` + + // SemanticTokensProvider the server provides semantic tokens support. + SemanticTokensProvider *ServerCapabilitiesSemanticTokensProvider `json:"semanticTokensProvider,omitempty"` + + // MonikerProvider the server provides moniker support. + MonikerProvider *ServerCapabilitiesMonikerProvider `json:"monikerProvider,omitempty"` + + // TypeHierarchyProvider the server provides type hierarchy support. + TypeHierarchyProvider *ServerCapabilitiesTypeHierarchyProvider `json:"typeHierarchyProvider,omitempty"` + + // InlineValueProvider the server provides inline values. + InlineValueProvider *ServerCapabilitiesInlineValueProvider `json:"inlineValueProvider,omitempty"` + + // InlayHintProvider the server provides inlay hints. + InlayHintProvider *ServerCapabilitiesInlayHintProvider `json:"inlayHintProvider,omitempty"` + + // DiagnosticProvider the server has support for pull model diagnostics. + DiagnosticProvider *ServerCapabilitiesDiagnosticProvider `json:"diagnosticProvider,omitempty"` + + // InlineCompletionProvider inline completion options used during static registration. 3.18.0 @proposed. + InlineCompletionProvider *ServerCapabilitiesInlineCompletionProvider `json:"inlineCompletionProvider,omitempty"` + + // Workspace workspace specific server capabilities. + Workspace *WorkspaceOptions `json:"workspace,omitempty"` + + // Experimental experimental server capabilities. + Experimental any `json:"experimental,omitempty"` +} + +// ServerInfo information about the server 3.15.0 3.18.0 ServerInfo type name added. +// +// @since 3.18.0 ServerInfo type name added. +type ServerInfo struct { + // Name the name of the server as defined by the server. + // + // @since 3.18.0 ServerInfo type name added. + Name string `json:"name"` + + // Version the server's version as defined by the server. + // + // @since 3.18.0 ServerInfo type name added. + Version string `json:"version,omitempty"` +} + +// InitializeResult the result returned from an initialize request. +type InitializeResult struct { + // Capabilities the capabilities the language server provides. + Capabilities ServerCapabilities `json:"capabilities"` + + // ServerInfo information about the server. + ServerInfo *ServerInfo `json:"serverInfo,omitempty"` +} + +// InitializeError the data type of the ResponseError if the initialize request fails. +type InitializeError struct { + // Retry indicates whether the client execute the following retry logic: (1) show the message provided by the + // ResponseError to the user (2) user selects retry or cancel (3) if user selected retry the initialize method is sent again. + Retry bool `json:"retry"` +} + +type InitializedParams struct{} + +type SetTraceParams struct { + Value TraceValue `json:"value"` +} + +type LogTraceParams struct { + Message string `json:"message"` + + Verbose string `json:"verbose,omitempty"` +} + +// StaticRegistrationOptions static registration options to be returned in the initialize request. +type StaticRegistrationOptions struct { + // ID the id used to register the request. The id can be used to deregister the request again. See also Registration#id. + ID string `json:"id,omitempty"` +} diff --git a/lifecycle_test.go b/lifecycle_test.go new file mode 100644 index 00000000..3b59cc56 --- /dev/null +++ b/lifecycle_test.go @@ -0,0 +1,146 @@ +package protocol + +import ( + "path/filepath" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + + "go.lsp.dev/uri" +) + +func TestInitializeParams(t *testing.T) { + t.Parallel() + + const wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" + const ( + want = `{"workDoneToken":"` + wantWorkDoneToken + `","processId":25556,"clientInfo":{"name":"testClient","version":"v0.0.0"},"locale":"en-US","initializationOptions":"testdata","capabilities":{},"trace":"on","workspaceFolders":[{"uri":"file:///Users/zchee/go/src/go.lsp.dev/protocol","name":"protocol"},{"uri":"file:///Users/zchee/go/src/go.lsp.dev/jsonrpc2","name":"jsonrpc2"}]}` + wantNil = `{"processId":25556,"capabilities":{}}` + ) + ptoken := NewProgressToken(wantWorkDoneToken) + wantType := InitializeParams{ + InitializeParamsBase: InitializeParamsBase{ + WorkDoneProgressParams: WorkDoneProgressParams{ + WorkDoneToken: &ptoken, + }, + ProcessID: 25556, + ClientInfo: &ClientInfo{ + Name: "testClient", + Version: "v0.0.0", + }, + Locale: "en-US", + InitializationOptions: "testdata", + Capabilities: ClientCapabilities{}, + Trace: "on", + }, + WorkspaceFoldersInitializeParams: WorkspaceFoldersInitializeParams{ + WorkspaceFolders: []WorkspaceFolder{ + { + Name: filepath.Base("/Users/zchee/go/src/go.lsp.dev/protocol"), + URI: uri.File("/Users/zchee/go/src/go.lsp.dev/protocol"), + }, + { + Name: filepath.Base("/Users/zchee/go/src/go.lsp.dev/jsonrpc2"), + URI: uri.File("/Users/zchee/go/src/go.lsp.dev/jsonrpc2"), + }, + }, + }, + } + wantTypeNilAll := InitializeParams{ + InitializeParamsBase: InitializeParamsBase{ + ProcessID: 25556, + Capabilities: ClientCapabilities{}, + }, + } + + t.Run("Marshal", func(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + field InitializeParams + want string + wantMarshalErr bool + wantErr bool + }{ + { + name: "Valid", + field: wantType, + want: want, + wantMarshalErr: false, + wantErr: false, + }, + { + name: "ValidNilAll", + field: wantTypeNilAll, + want: wantNil, + wantMarshalErr: false, + wantErr: false, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + + got, err := marshal(&tt.field) + if (err != nil) != tt.wantMarshalErr { + t.Fatal(err) + } + + if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { + t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) + } + }) + } + }) + + t.Run("Unmarshal", func(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + field string + want InitializeParams + wantUnmarshalErr bool + wantErr bool + }{ + { + name: "Valid", + field: want, + want: wantType, + wantUnmarshalErr: false, + wantErr: false, + }, + { + name: "ValidNilAll", + field: wantNil, + want: wantTypeNilAll, + wantUnmarshalErr: false, + wantErr: false, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + + var got InitializeParams + if err := unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { + t.Fatal(err) + } + + if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{})); (diff != "") != tt.wantErr { + t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) + } + + if diff := cmp.Diff(got.WorkDoneToken, wantWorkDoneToken); (diff != "") != tt.wantErr { + t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) + } + }) + } + }) +} diff --git a/progress.go b/progress.go deleted file mode 100644 index d1a2e9f6..00000000 --- a/progress.go +++ /dev/null @@ -1,119 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -// WorkDoneProgressKind kind of WorkDoneProgress. -// -// @since 3.15.0. -type WorkDoneProgressKind string - -// list of WorkDoneProgressKind. -const ( - // WorkDoneProgressKindBegin kind of WorkDoneProgressBegin. - WorkDoneProgressKindBegin WorkDoneProgressKind = "begin" - - // WorkDoneProgressKindReport kind of WorkDoneProgressReport. - WorkDoneProgressKindReport WorkDoneProgressKind = "report" - - // WorkDoneProgressKindEnd kind of WorkDoneProgressEnd. - WorkDoneProgressKindEnd WorkDoneProgressKind = "end" -) - -// WorkDoneProgressBegin is the to start progress reporting a "$/progress" notification. -// -// @since 3.15.0. -type WorkDoneProgressBegin struct { - // Kind is the kind of WorkDoneProgressBegin. - // - // It must be WorkDoneProgressKindBegin. - Kind WorkDoneProgressKind `json:"kind"` - - // Title mandatory title of the progress operation. Used to briefly inform about - // the kind of operation being performed. - // - // Examples: "Indexing" or "Linking dependencies". - Title string `json:"title"` - - // Cancellable controls if a cancel button should show to allow the user to cancel the - // long running operation. Clients that don't support cancellation are allowed - // to ignore the setting. - Cancellable bool `json:"cancellable,omitempty"` - - // Message is optional, more detailed associated progress message. Contains - // complementary information to the `title`. - // - // Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". - // If unset, the previous progress message (if any) is still valid. - Message string `json:"message,omitempty"` - - // Percentage is optional progress percentage to display (value 100 is considered 100%). - // If not provided infinite progress is assumed and clients are allowed - // to ignore the `percentage` value in subsequent in report notifications. - // - // The value should be steadily rising. Clients are free to ignore values - // that are not following this rule. - Percentage uint32 `json:"percentage,omitempty"` -} - -// WorkDoneProgressReport is the reporting progress is done. -// -// @since 3.15.0. -type WorkDoneProgressReport struct { - // Kind is the kind of WorkDoneProgressReport. - // - // It must be WorkDoneProgressKindReport. - Kind WorkDoneProgressKind `json:"kind"` - - // Cancellable controls enablement state of a cancel button. - // - // Clients that don't support cancellation or don't support controlling the button's - // enablement state are allowed to ignore the property. - Cancellable bool `json:"cancellable,omitempty"` - - // Message is optional, more detailed associated progress message. Contains - // complementary information to the `title`. - // - // Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". - // If unset, the previous progress message (if any) is still valid. - Message string `json:"message,omitempty"` - - // Percentage is optional progress percentage to display (value 100 is considered 100%). - // If not provided infinite progress is assumed and clients are allowed - // to ignore the `percentage` value in subsequent in report notifications. - // - // The value should be steadily rising. Clients are free to ignore values - // that are not following this rule. - Percentage uint32 `json:"percentage,omitempty"` -} - -// WorkDoneProgressEnd is the signaling the end of a progress reporting is done. -// -// @since 3.15.0. -type WorkDoneProgressEnd struct { - // Kind is the kind of WorkDoneProgressEnd. - // - // It must be WorkDoneProgressKindEnd. - Kind WorkDoneProgressKind `json:"kind"` - - // Message is optional, a final message indicating to for example indicate the outcome - // of the operation. - Message string `json:"message,omitempty"` -} - -// WorkDoneProgressParams is a parameter property of report work done progress. -// -// @since 3.15.0. -type WorkDoneProgressParams struct { - // WorkDoneToken an optional token that a server can use to report work done progress. - WorkDoneToken *ProgressToken `json:"workDoneToken,omitempty"` -} - -// PartialResultParams is the parameter literal used to pass a partial result token. -// -// @since 3.15.0. -type PartialResultParams struct { - // PartialResultToken an optional token that a server can use to report partial results - // (for example, streaming) to the client. - PartialResultToken *ProgressToken `json:"partialResultToken,omitempty"` -} diff --git a/progress_test.go b/progress_test.go deleted file mode 100644 index 4bd80633..00000000 --- a/progress_test.go +++ /dev/null @@ -1,508 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/segmentio/encoding/json" -) - -func TestWorkDoneProgressBegin(t *testing.T) { - t.Parallel() - - const ( - want = `{"kind":"begin","title":"testTitle","cancellable":true,"message":"testMessage","percentage":30}` - wantNil = `{"kind":"begin","title":"testTitle"}` - wantInvalid = `{"kind":"invalid","title":"invalidTitle","cancellable":false,"message":"invalidMessage","percentage":0}` - ) - wantType := WorkDoneProgressBegin{ - Kind: WorkDoneProgressKindBegin, - Title: "testTitle", - Cancellable: true, - Message: "testMessage", - Percentage: uint32(30), - } - wantTypeNil := WorkDoneProgressBegin{ - Kind: WorkDoneProgressKindBegin, - Title: "testTitle", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WorkDoneProgressBegin - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WorkDoneProgressBegin - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkDoneProgressBegin - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkDoneProgressReport(t *testing.T) { - t.Parallel() - - const ( - want = `{"kind":"report","cancellable":true,"message":"testMessage","percentage":30}` - wantNil = `{"kind":"report"}` - wantInvalid = `{"kind":"invalid","cancellable":false,"message":"invalidMessage","percentage":0}` - ) - wantType := WorkDoneProgressReport{ - Kind: WorkDoneProgressKindReport, - Cancellable: true, - Message: "testMessage", - Percentage: uint32(30), - } - wantTypeNil := WorkDoneProgressReport{ - Kind: WorkDoneProgressKindReport, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WorkDoneProgressReport - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WorkDoneProgressReport - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkDoneProgressReport - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkDoneProgressEnd(t *testing.T) { - t.Parallel() - - const ( - want = `{"kind":"end","message":"testMessage"}` - wantNil = `{"kind":"end"}` - wantInvalid = `{"kind":"invalid","message":"invalidMessage"}` - ) - wantType := WorkDoneProgressEnd{ - Kind: WorkDoneProgressKindEnd, - Message: "testMessage", - } - wantTypeNil := WorkDoneProgressEnd{ - Kind: WorkDoneProgressKindEnd, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WorkDoneProgressEnd - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WorkDoneProgressEnd - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Nil", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkDoneProgressEnd - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkDoneProgressParams(t *testing.T) { - t.Parallel() - - const wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - const want = `{"workDoneToken":"` + wantWorkDoneToken + `"}` - - wantType := WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WorkDoneProgressParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WorkDoneProgressParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkDoneProgressParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestPartialResultParams(t *testing.T) { - t.Parallel() - - const wantPartialResultParams = "156edea9-9d8d-422f-b7ee-81a84594afbb" - const want = `{"partialResultToken":"` + wantPartialResultParams + `"}` - - wantType := PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultParams), - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field PartialResultParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want PartialResultParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got PartialResultParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultParams); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} diff --git a/registration.go b/registration.go deleted file mode 100644 index a2abb438..00000000 --- a/registration.go +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -// Registration general parameters to register for a capability. -type Registration struct { - // ID is the id used to register the request. The id can be used to deregister - // the request again. - ID string `json:"id"` - - // Method is the method / capability to register for. - Method string `json:"method"` - - // RegisterOptions options necessary for the registration. - RegisterOptions interface{} `json:"registerOptions,omitempty"` -} - -// RegistrationParams params of Register Capability. -type RegistrationParams struct { - Registrations []Registration `json:"registrations"` -} - -// TextDocumentRegistrationOptions TextDocumentRegistration options. -type TextDocumentRegistrationOptions struct { - // DocumentSelector a document selector to identify the scope of the registration. If set to null - // the document selector provided on the client side will be used. - DocumentSelector DocumentSelector `json:"documentSelector"` -} - -// Unregistration general parameters to unregister a capability. -type Unregistration struct { - // ID is the id used to unregister the request or notification. Usually an id - // provided during the register request. - ID string `json:"id"` - - // Method is the method / capability to unregister for. - Method string `json:"method"` -} - -// UnregistrationParams params of Unregistration. -type UnregistrationParams struct { - Unregisterations []Unregistration `json:"unregisterations"` -} diff --git a/registration_test.go b/registration_test.go deleted file mode 100644 index 4258d75d..00000000 --- a/registration_test.go +++ /dev/null @@ -1,579 +0,0 @@ -// SPDX-FileCopyrightText: 2020 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/segmentio/encoding/json" -) - -func TestRegistration(t *testing.T) { - t.Parallel() - - const ( - want = `{"id":"1","method":"testMethod","registerOptions":{"foo":"bar"}}` - wantInterfaces = `{"id":"1","method":"testMethod","registerOptions":["foo","bar"]}` - wantNil = `{"id":"1","method":"testMethod"}` - wantInvalid = `{"id":"2","method":"invalidMethod","registerOptions":{"baz":"qux"}}` - ) - wantTypeStringInterface := Registration{ - ID: "1", - Method: "testMethod", - RegisterOptions: map[string]interface{}{ - "foo": "bar", - }, - } - wantTypeStringString := Registration{ - ID: "1", - Method: "testMethod", - RegisterOptions: map[string]string{ - "foo": "bar", - }, - } - wantTypeInterfaces := Registration{ - ID: "1", - Method: "testMethod", - RegisterOptions: []interface{}{ - "foo", - "bar", - }, - } - wantTypeNil := Registration{ - ID: "1", - Method: "testMethod", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field Registration - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "ValidStringInterface", - field: wantTypeStringInterface, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidStringString", - field: wantTypeStringString, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidInterfaces", - field: wantTypeInterfaces, - want: wantInterfaces, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantTypeStringInterface, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want Registration - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "ValidStringInterface", - field: want, - want: wantTypeStringInterface, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidInterfaces", - field: wantInterfaces, - want: wantTypeInterfaces, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantTypeStringInterface, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got Registration - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestRegistrationParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"registrations":[{"id":"1","method":"testMethod","registerOptions":{"foo":"bar"}}]}` - wantNil = `{"registrations":[{"id":"1","method":"testMethod"}]}` - wantInvalid = `{"registrations":[{"id":"2","method":"invalidMethod","registerOptions":{"baz":"qux"}}]}` - ) - wantType := RegistrationParams{ - Registrations: []Registration{ - { - ID: "1", - Method: "testMethod", - RegisterOptions: map[string]interface{}{ - "foo": "bar", - }, - }, - }, - } - wantTypeNil := RegistrationParams{ - Registrations: []Registration{ - { - ID: "1", - Method: "testMethod", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field RegistrationParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNil, - want: wantNil, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want RegistrationParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNil, - want: wantTypeNil, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got RegistrationParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"},{"language":"cpp","scheme":"untitled","pattern":"*.{cpp,hpp}"}]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"},{"language":"c","scheme":"untitled","pattern":"*.{c,h}"}]}` - ) - wantType := TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - { - Language: "cpp", - Scheme: "untitled", - Pattern: "*.{cpp,hpp}", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field TextDocumentRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want TextDocumentRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestUnregistration(t *testing.T) { - t.Parallel() - - const ( - want = `{"id":"1","method":"testMethod"}` - wantInvalid = `{"id":"2","method":"invalidMethod"}` - ) - wantType := Unregistration{ - ID: "1", - Method: "testMethod", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field Unregistration - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want Unregistration - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got Unregistration - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestUnregistrationParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"unregisterations":[{"id":"1","method":"testMethod"}]}` - wantInvalid = `{"unregisterations":[{"id":"2","method":"invalidMethod"}]}` - ) - wantType := UnregistrationParams{ - Unregisterations: []Unregistration{ - { - ID: "1", - Method: "testMethod", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field UnregistrationParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want UnregistrationParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got UnregistrationParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} diff --git a/selectionrange.go b/selectionrange.go deleted file mode 100644 index c4cd1691..00000000 --- a/selectionrange.go +++ /dev/null @@ -1,110 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -// SelectionRangeProviderOptions selection range provider options interface. -type SelectionRangeProviderOptions interface{} - -// SelectionRange represents a selection range represents a part of a selection hierarchy. -// -// A selection range may have a parent selection range that contains it. -// -// @since 3.15.0. -type SelectionRange struct { - // Range is the Range of this selection range. - Range Range `json:"range"` - - // Parent is the parent selection range containing this range. Therefore `parent.range` must contain this Range. - Parent *SelectionRange `json:"parent,omitempty"` -} - -// EnableSelectionRange is the whether the selection range. -type EnableSelectionRange bool - -// compile time check whether the EnableSelectionRange implements a SelectionRangeProviderOptions interface. -var _ SelectionRangeProviderOptions = (*EnableSelectionRange)(nil) - -// Value implements SelectionRangeProviderOptions interface. -func (v EnableSelectionRange) Value() interface{} { - return bool(v) -} - -// NewEnableSelectionRange returns the new EnableSelectionRange underlying types SelectionRangeProviderOptions. -func NewEnableSelectionRange(enable bool) SelectionRangeProviderOptions { - v := EnableSelectionRange(enable) - - return &v -} - -// SelectionRangeOptions is the server capability of selection range. -type SelectionRangeOptions struct { - WorkDoneProgressOptions -} - -// compile time check whether the EnableSelectionRange implements a SelectionRangeProviderOptions interface. -var _ SelectionRangeProviderOptions = (*EnableSelectionRange)(nil) - -// Value implements SelectionRangeProviderOptions interface. -func (v *SelectionRangeOptions) Value() interface{} { - return v -} - -// NewSelectionRangeOptions returns the new SelectionRangeOptions underlying types SelectionRangeProviderOptions. -func NewSelectionRangeOptions(enableWorkDoneProgress bool) SelectionRangeProviderOptions { - v := SelectionRangeOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: enableWorkDoneProgress, - }, - } - - return &v -} - -// SelectionRangeRegistrationOptions is the server capability of selection range registration. -type SelectionRangeRegistrationOptions struct { - SelectionRangeOptions - TextDocumentRegistrationOptions - StaticRegistrationOptions -} - -// compile time check whether the SelectionRangeRegistrationOptions implements a SelectionRangeProviderOptions interface. -var _ SelectionRangeProviderOptions = (*SelectionRangeRegistrationOptions)(nil) - -// Value implements SelectionRangeProviderOptions interface. -func (v *SelectionRangeRegistrationOptions) Value() interface{} { - return v -} - -// NewSelectionRangeRegistrationOptions returns the new SelectionRangeRegistrationOptions underlying types SelectionRangeProviderOptions. -func NewSelectionRangeRegistrationOptions(enableWorkDoneProgress bool, selector DocumentSelector, id string) SelectionRangeProviderOptions { - v := SelectionRangeRegistrationOptions{ - SelectionRangeOptions: SelectionRangeOptions{ - WorkDoneProgressOptions: WorkDoneProgressOptions{ - WorkDoneProgress: enableWorkDoneProgress, - }, - }, - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: selector, - }, - StaticRegistrationOptions: StaticRegistrationOptions{ - ID: id, - }, - } - - return &v -} - -// SelectionRangeParams represents a parameter literal used in selection range requests. -// -// @since 3.15.0. -type SelectionRangeParams struct { - WorkDoneProgressParams - PartialResultParams - - // TextDocument is the text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` - - // Positions is the positions inside the text document. - Positions []Position `json:"positions"` -} diff --git a/semantic_token.go b/semantic_token.go deleted file mode 100644 index c2d1f3a4..00000000 --- a/semantic_token.go +++ /dev/null @@ -1,179 +0,0 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -// SemanticTokenTypes represents a type of semantic token. -// -// @since 3.16.0. -type SemanticTokenTypes string - -// list of SemanticTokenTypes. -const ( - SemanticTokenNamespace SemanticTokenTypes = "namespace" - - // Represents a generic type. Acts as a fallback for types which - // can't be mapped to a specific type like class or enum. - SemanticTokenType SemanticTokenTypes = "type" - SemanticTokenClass SemanticTokenTypes = "class" - SemanticTokenEnum SemanticTokenTypes = "enum" - SemanticTokenInterface SemanticTokenTypes = "interface" - SemanticTokenStruct SemanticTokenTypes = "struct" - SemanticTokenTypeParameter SemanticTokenTypes = "typeParameter" - SemanticTokenParameter SemanticTokenTypes = "parameter" - SemanticTokenVariable SemanticTokenTypes = "variable" - SemanticTokenProperty SemanticTokenTypes = "property" - SemanticTokenEnumMember SemanticTokenTypes = "enumMember" - SemanticTokenEvent SemanticTokenTypes = "event" - SemanticTokenFunction SemanticTokenTypes = "function" - SemanticTokenMethod SemanticTokenTypes = "method" - SemanticTokenMacro SemanticTokenTypes = "macro" - SemanticTokenKeyword SemanticTokenTypes = "keyword" - SemanticTokenModifier SemanticTokenTypes = "modifier" - SemanticTokenComment SemanticTokenTypes = "comment" - SemanticTokenString SemanticTokenTypes = "string" - SemanticTokenNumber SemanticTokenTypes = "number" - SemanticTokenRegexp SemanticTokenTypes = "regexp" - SemanticTokenOperator SemanticTokenTypes = "operator" -) - -// SemanticTokenModifiers represents a modifiers of semantic token. -// -// @since 3.16.0. -type SemanticTokenModifiers string - -// list of SemanticTokenModifiers. -const ( - SemanticTokenModifierDeclaration SemanticTokenModifiers = "declaration" - SemanticTokenModifierDefinition SemanticTokenModifiers = "definition" - SemanticTokenModifierReadonly SemanticTokenModifiers = "readonly" - SemanticTokenModifierStatic SemanticTokenModifiers = "static" - SemanticTokenModifierDeprecated SemanticTokenModifiers = "deprecated" - SemanticTokenModifierAbstract SemanticTokenModifiers = "abstract" - SemanticTokenModifierAsync SemanticTokenModifiers = "async" - SemanticTokenModifierModification SemanticTokenModifiers = "modification" - SemanticTokenModifierDocumentation SemanticTokenModifiers = "documentation" - SemanticTokenModifierDefaultLibrary SemanticTokenModifiers = "defaultLibrary" -) - -// TokenFormat is an additional token format capability to allow future extensions of the format. -// -// @since 3.16.0. -type TokenFormat string - -// TokenFormatRelative described using relative positions. -const TokenFormatRelative TokenFormat = "relative" - -// SemanticTokensLegend is the on the capability level types and modifiers are defined using strings. -// -// However the real encoding happens using numbers. -// -// The server therefore needs to let the client know which numbers it is using for which types and modifiers. -// -// @since 3.16.0. -type SemanticTokensLegend struct { - // TokenTypes is the token types a server uses. - TokenTypes []SemanticTokenTypes `json:"tokenTypes"` - - // TokenModifiers is the token modifiers a server uses. - TokenModifiers []SemanticTokenModifiers `json:"tokenModifiers"` -} - -// SemanticTokensParams params for the SemanticTokensFull request. -// -// @since 3.16.0. -type SemanticTokensParams struct { - WorkDoneProgressParams - PartialResultParams - - // TextDocument is the text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` -} - -// SemanticTokens is the result of SemanticTokensFull request. -// -// @since 3.16.0. -type SemanticTokens struct { - // ResultID an optional result id. If provided and clients support delta updating - // the client will include the result id in the next semantic token request. - // - // A server can then instead of computing all semantic tokens again simply - // send a delta. - ResultID string `json:"resultId,omitempty"` - - // Data is the actual tokens. - Data []uint32 `json:"data"` -} - -// SemanticTokensPartialResult is the partial result of SemanticTokensFull request. -// -// @since 3.16.0. -type SemanticTokensPartialResult struct { - // Data is the actual tokens. - Data []uint32 `json:"data"` -} - -// SemanticTokensDeltaParams params for the SemanticTokensFullDelta request. -// -// @since 3.16.0. -type SemanticTokensDeltaParams struct { - WorkDoneProgressParams - PartialResultParams - - // TextDocument is the text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` - - // PreviousResultID is the result id of a previous response. - // - // The result Id can either point to a full response or a delta response depending on what was received last. - PreviousResultID string `json:"previousResultId"` -} - -// SemanticTokensDelta result of SemanticTokensFullDelta request. -// -// @since 3.16.0. -type SemanticTokensDelta struct { - // ResultID is the result id. - // - // This field is readonly. - ResultID string `json:"resultId,omitempty"` - - // Edits is the semantic token edits to transform a previous result into a new - // result. - Edits []SemanticTokensEdit `json:"edits"` -} - -// SemanticTokensDeltaPartialResult is the partial result of SemanticTokensFullDelta request. -// -// @since 3.16.0. -type SemanticTokensDeltaPartialResult struct { - Edits []SemanticTokensEdit `json:"edits"` -} - -// SemanticTokensEdit is the semantic token edit. -// -// @since 3.16.0. -type SemanticTokensEdit struct { - // Start is the start offset of the edit. - Start uint32 `json:"start"` - - // DeleteCount is the count of elements to remove. - DeleteCount uint32 `json:"deleteCount"` - - // Data is the elements to insert. - Data []uint32 `json:"data,omitempty"` -} - -// SemanticTokensRangeParams params for the SemanticTokensRange request. -// -// @since 3.16.0. -type SemanticTokensRangeParams struct { - WorkDoneProgressParams - PartialResultParams - - // TextDocument is the text document. - TextDocument TextDocumentIdentifier `json:"textDocument"` - - // Range is the range the semantic tokens are requested for. - Range Range `json:"range"` -} diff --git a/server.go b/server.go index fb7e693e..aa287d54 100644 --- a/server.go +++ b/server.go @@ -8,11 +8,9 @@ import ( "context" "fmt" - "github.com/segmentio/encoding/json" "go.uber.org/zap" "go.lsp.dev/jsonrpc2" - "go.lsp.dev/pkg/xcontext" ) // ServerDispatcher returns a Server that dispatches LSP requests across the @@ -30,7 +28,7 @@ func ServerDispatcher(conn jsonrpc2.Conn, logger *zap.Logger) Server { func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { h := func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { if ctx.Err() != nil { - xctx := xcontext.Detach(ctx) + xctx := context.WithoutCancel(ctx) return reply(xctx, nil, ErrRequestCancelled) } @@ -42,14 +40,12 @@ func ServerHandler(server Server, handler jsonrpc2.Handler) jsonrpc2.Handler { // TODO: This code is wrong, it ignores handler and assumes non standard // request handles everything // non standard request should just be a layered handler. - var params interface{} - if err := json.Unmarshal(req.Params(), ¶ms); err != nil { + var params any + if err := unmarshal(req.Params(), ¶ms); err != nil { return replyParseError(ctx, reply, err) } - resp, err := server.Request(ctx, req.Method(), params) - - return reply(ctx, resp, err) + return nil } return h @@ -63,42 +59,31 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, ErrRequestCancelled) } - dec := json.NewDecoder(bytes.NewReader(req.Params())) + dec := newDecoder(bytes.NewReader(req.Params())) logger := LoggerFromContext(ctx) switch req.Method() { - case MethodInitialize: // request - defer logger.Debug(MethodInitialize, zap.Error(err)) + case MethodServerProgress: // notification + defer logger.Debug(MethodServerProgress, zap.Error(err)) - var params InitializeParams + var params ProgressParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Initialize(ctx, ¶ms) + err := server.Progress(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodInitialized: // notification - defer logger.Debug(MethodInitialized, zap.Error(err)) + case MethodSetTrace: // notification + defer logger.Debug(MethodSetTrace, zap.Error(err)) - var params InitializedParams + var params SetTraceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.Initialized(ctx, ¶ms) - - return true, reply(ctx, nil, err) - - case MethodShutdown: // request - defer logger.Debug(MethodShutdown, zap.Error(err)) - - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) - } - - err := server.Shutdown(ctx) + err := server.SetTrace(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -113,147 +98,135 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodWorkDoneProgressCancel: // notification - defer logger.Debug(MethodWorkDoneProgressCancel, zap.Error(err)) + case MethodInitialized: // notification + defer logger.Debug(MethodInitialized, zap.Error(err)) - var params WorkDoneProgressCancelParams + var params InitializedParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WorkDoneProgressCancel(ctx, ¶ms) + err := server.Initialized(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodLogTrace: // notification - defer logger.Debug(MethodLogTrace, zap.Error(err)) + case MethodNotebookDocumentDidChange: // notification + defer logger.Debug(MethodNotebookDocumentDidChange, zap.Error(err)) - var params LogTraceParams + var params DidChangeNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.LogTrace(ctx, ¶ms) + err := server.DidChangeNotebookDocument(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodSetTrace: // notification - defer logger.Debug(MethodSetTrace, zap.Error(err)) + case MethodNotebookDocumentDidClose: // notification + defer logger.Debug(MethodNotebookDocumentDidClose, zap.Error(err)) - var params SetTraceParams + var params DidCloseNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.SetTrace(ctx, ¶ms) + err := server.DidCloseNotebookDocument(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentCodeAction: // request - defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) - - var params CodeActionParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) - } - - resp, err := server.CodeAction(ctx, ¶ms) - - return true, reply(ctx, resp, err) - - case MethodTextDocumentCodeLens: // request - defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) + case MethodNotebookDocumentDidOpen: // notification + defer logger.Debug(MethodNotebookDocumentDidOpen, zap.Error(err)) - var params CodeLensParams + var params DidOpenNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeLens(ctx, ¶ms) + err := server.DidOpenNotebookDocument(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodCodeLensResolve: // request - defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) + case MethodNotebookDocumentDidSave: // notification + defer logger.Debug(MethodNotebookDocumentDidSave, zap.Error(err)) - var params CodeLens + var params DidSaveNotebookDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CodeLensResolve(ctx, ¶ms) + err := server.DidSaveNotebookDocument(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentColorPresentation: // request - defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) + case MethodTextDocumentDidChange: // notification + defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) - var params ColorPresentationParams + var params DidChangeTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.ColorPresentation(ctx, ¶ms) + err := server.DidChangeTextDocument(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentCompletion: // request - defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) + case MethodTextDocumentDidClose: // notification + defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) - var params CompletionParams + var params DidCloseTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Completion(ctx, ¶ms) + err := server.DidCloseTextDocument(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodCompletionItemResolve: // request - defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) + case MethodTextDocumentDidOpen: // notification + defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) - var params CompletionItem + var params DidOpenTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.CompletionResolve(ctx, ¶ms) + err := server.DidOpenTextDocument(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDeclaration: // request - defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) + case MethodTextDocumentDidSave: // notification + defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) - var params DeclarationParams + var params DidSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Declaration(ctx, ¶ms) + err := server.DidSaveTextDocument(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDefinition: // request - defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) + case MethodTextDocumentWillSave: // notification + defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) - var params DefinitionParams + var params WillSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Definition(ctx, ¶ms) + err := server.WillSaveTextDocument(ctx, ¶ms) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentDidChange: // notification - defer logger.Debug(MethodTextDocumentDidChange, zap.Error(err)) + case MethodWindowWorkDoneProgressCancel: // notification + defer logger.Debug(MethodWindowWorkDoneProgressCancel, zap.Error(err)) - var params DidChangeTextDocumentParams + var params WorkDoneProgressCancelParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidChange(ctx, ¶ms) + err := server.WorkDoneProgressCancel(ctx, ¶ms) return true, reply(ctx, nil, err) @@ -293,376 +266,400 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, nil, err) - case MethodTextDocumentDidClose: // notification - defer logger.Debug(MethodTextDocumentDidClose, zap.Error(err)) + case MethodWorkspaceDidCreateFiles: // notification + defer logger.Debug(MethodWorkspaceDidCreateFiles, zap.Error(err)) - var params DidCloseTextDocumentParams + var params CreateFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidClose(ctx, ¶ms) + err := server.DidCreateFiles(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDidOpen: // notification - defer logger.Debug(MethodTextDocumentDidOpen, zap.Error(err)) + case MethodWorkspaceDidDeleteFiles: // notification + defer logger.Debug(MethodWorkspaceDidDeleteFiles, zap.Error(err)) - var params DidOpenTextDocumentParams + var params DeleteFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidOpen(ctx, ¶ms) + err := server.DidDeleteFiles(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDidSave: // notification - defer logger.Debug(MethodTextDocumentDidSave, zap.Error(err)) + case MethodWorkspaceDidRenameFiles: // notification + defer logger.Debug(MethodWorkspaceDidRenameFiles, zap.Error(err)) - var params DidSaveTextDocumentParams + var params RenameFilesParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidSave(ctx, ¶ms) + err := server.DidRenameFiles(ctx, ¶ms) return true, reply(ctx, nil, err) - case MethodTextDocumentDocumentColor: // request - defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) + case MethodCallHierarchyIncomingCalls: // request + defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) - var params DocumentColorParams + var params CallHierarchyIncomingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentColor(ctx, ¶ms) + resp, err := server.CallHierarchyIncomingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentHighlight: // request - defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) + case MethodCallHierarchyOutgoingCalls: // request + defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) - var params DocumentHighlightParams + var params CallHierarchyOutgoingCallsParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentHighlight(ctx, ¶ms) + resp, err := server.CallHierarchyOutgoingCalls(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentLink: // request - defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) + case MethodCodeActionResolve: // request + defer logger.Debug(MethodCodeActionResolve, zap.Error(err)) - var params DocumentLinkParams + var params CodeAction if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentLink(ctx, ¶ms) + resp, err := server.CodeActionResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDocumentLinkResolve: // request - defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) + case MethodCodeLensResolve: // request + defer logger.Debug(MethodCodeLensResolve, zap.Error(err)) - var params DocumentLink + var params CodeLens if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentLinkResolve(ctx, ¶ms) + resp, err := server.CodeLensResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentDocumentSymbol: // request - defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) + case MethodCompletionItemResolve: // request + defer logger.Debug(MethodCompletionItemResolve, zap.Error(err)) - var params DocumentSymbolParams + var params CompletionItem if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.DocumentSymbol(ctx, ¶ms) + resp, err := server.CompletionResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceExecuteCommand: // request - defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) + case MethodDocumentLinkResolve: // request + defer logger.Debug(MethodDocumentLinkResolve, zap.Error(err)) - var params ExecuteCommandParams + var params DocumentLink if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.ExecuteCommand(ctx, ¶ms) + resp, err := server.DocumentLinkResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFoldingRange: // request - defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) + case MethodInitialize: // request + defer logger.Debug(MethodInitialize, zap.Error(err)) - var params FoldingRangeParams + var params InitializeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.FoldingRanges(ctx, ¶ms) + resp, err := server.Initialize(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentFormatting: // request - defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) + case MethodInlayHintResolve: // request + defer logger.Debug(MethodInlayHintResolve, zap.Error(err)) - var params DocumentFormattingParams + var params InlayHint if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Formatting(ctx, ¶ms) + resp, err := server.InlayHintResolve(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentHover: // request - defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) + case MethodShutdown: // request + defer logger.Debug(MethodShutdown, zap.Error(err)) - var params HoverParams - if err := dec.Decode(¶ms); err != nil { - return true, replyParseError(ctx, reply, err) + if len(req.Params()) > 0 { + return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) } - resp, err := server.Hover(ctx, ¶ms) + err := server.Shutdown(ctx) - return true, reply(ctx, resp, err) + return true, reply(ctx, nil, err) - case MethodTextDocumentImplementation: // request - defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) + case MethodTextDocumentCodeAction: // request + defer logger.Debug(MethodTextDocumentCodeAction, zap.Error(err)) - var params ImplementationParams + var params CodeActionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Implementation(ctx, ¶ms) + resp, err := server.CodeAction(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentOnTypeFormatting: // request - defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) + case MethodTextDocumentCodeLens: // request + defer logger.Debug(MethodTextDocumentCodeLens, zap.Error(err)) - var params DocumentOnTypeFormattingParams + var params CodeLensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.OnTypeFormatting(ctx, ¶ms) + resp, err := server.CodeLens(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentPrepareRename: // request - defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) + case MethodTextDocumentColorPresentation: // request + defer logger.Debug(MethodTextDocumentColorPresentation, zap.Error(err)) - var params PrepareRenameParams + var params ColorPresentationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.PrepareRename(ctx, ¶ms) + resp, err := server.ColorPresentation(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentRangeFormatting: // request - defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) + case MethodTextDocumentCompletion: // request + defer logger.Debug(MethodTextDocumentCompletion, zap.Error(err)) - var params DocumentRangeFormattingParams + var params CompletionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.RangeFormatting(ctx, ¶ms) + resp, err := server.Completion(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentReferences: // request - defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) + case MethodTextDocumentDeclaration: // request + defer logger.Debug(MethodTextDocumentDeclaration, zap.Error(err)) - var params ReferenceParams + var params DeclarationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.References(ctx, ¶ms) + resp, err := server.Declaration(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentRename: // request - defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) + case MethodTextDocumentDefinition: // request + defer logger.Debug(MethodTextDocumentDefinition, zap.Error(err)) - var params RenameParams + var params DefinitionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Rename(ctx, ¶ms) + resp, err := server.Definition(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentSignatureHelp: // request - defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) + case MethodTextDocumentDiagnostic: // request + defer logger.Debug(MethodTextDocumentDiagnostic, zap.Error(err)) - var params SignatureHelpParams + var params DocumentDiagnosticParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SignatureHelp(ctx, ¶ms) + resp, err := server.DocumentDiagnostic(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWorkspaceSymbol: // request - defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) + case MethodTextDocumentDocumentColor: // request + defer logger.Debug(MethodTextDocumentDocumentColor, zap.Error(err)) - var params WorkspaceSymbolParams + var params DocumentColorParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Symbols(ctx, ¶ms) + resp, err := server.DocumentColor(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentTypeDefinition: // request - defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) + case MethodTextDocumentDocumentHighlight: // request + defer logger.Debug(MethodTextDocumentDocumentHighlight, zap.Error(err)) - var params TypeDefinitionParams + var params DocumentHighlightParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.TypeDefinition(ctx, ¶ms) + resp, err := server.DocumentHighlight(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodTextDocumentWillSave: // notification - defer logger.Debug(MethodTextDocumentWillSave, zap.Error(err)) + case MethodTextDocumentDocumentLink: // request + defer logger.Debug(MethodTextDocumentDocumentLink, zap.Error(err)) - var params WillSaveTextDocumentParams + var params DocumentLinkParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.WillSave(ctx, ¶ms) + resp, err := server.DocumentLink(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodTextDocumentWillSaveWaitUntil: // request - defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) + case MethodTextDocumentDocumentSymbol: // request + defer logger.Debug(MethodTextDocumentDocumentSymbol, zap.Error(err)) - var params WillSaveTextDocumentParams + var params DocumentSymbolParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillSaveWaitUntil(ctx, ¶ms) + resp, err := server.DocumentSymbol(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodShowDocument: // request - defer logger.Debug(MethodShowDocument, zap.Error(err)) + case MethodTextDocumentFoldingRange: // request + defer logger.Debug(MethodTextDocumentFoldingRange, zap.Error(err)) - var params ShowDocumentParams + var params FoldingRangeParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.ShowDocument(ctx, ¶ms) + resp, err := server.FoldingRange(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodWillCreateFiles: // request - defer logger.Debug(MethodWillCreateFiles, zap.Error(err)) + case MethodTextDocumentFormatting: // request + defer logger.Debug(MethodTextDocumentFormatting, zap.Error(err)) - var params CreateFilesParams + var params DocumentFormattingParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillCreateFiles(ctx, ¶ms) + resp, err := server.DocumentFormatting(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDidCreateFiles: // notification - defer logger.Debug(MethodDidCreateFiles, zap.Error(err)) + case MethodTextDocumentHover: // request + defer logger.Debug(MethodTextDocumentHover, zap.Error(err)) - var params CreateFilesParams + var params HoverParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidCreateFiles(ctx, ¶ms) + resp, err := server.Hover(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodWillRenameFiles: // request - defer logger.Debug(MethodWillRenameFiles, zap.Error(err)) + case MethodTextDocumentImplementation: // request + defer logger.Debug(MethodTextDocumentImplementation, zap.Error(err)) - var params RenameFilesParams + var params ImplementationParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillRenameFiles(ctx, ¶ms) + resp, err := server.Implementation(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDidRenameFiles: // notification - defer logger.Debug(MethodDidRenameFiles, zap.Error(err)) + case MethodTextDocumentInlayHint: // request + defer logger.Debug(MethodTextDocumentInlayHint, zap.Error(err)) - var params RenameFilesParams + var params InlayHintParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidRenameFiles(ctx, ¶ms) + resp, err := server.InlayHint(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodWillDeleteFiles: // request - defer logger.Debug(MethodWillDeleteFiles, zap.Error(err)) + case MethodTextDocumentInlineCompletion: // request + defer logger.Debug(MethodTextDocumentInlineCompletion, zap.Error(err)) - var params DeleteFilesParams + var params InlineCompletionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.WillDeleteFiles(ctx, ¶ms) + resp, err := server.InlineCompletion(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodDidDeleteFiles: // notification - defer logger.Debug(MethodDidDeleteFiles, zap.Error(err)) + case MethodTextDocumentInlineValue: // request + defer logger.Debug(MethodTextDocumentInlineValue, zap.Error(err)) - var params DeleteFilesParams + var params InlineValueParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - err := server.DidDeleteFiles(ctx, ¶ms) + resp, err := server.InlineValue(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodCodeLensRefresh: // request - defer logger.Debug(MethodCodeLensRefresh, zap.Error(err)) + case MethodTextDocumentLinkedEditingRange: // request + defer logger.Debug(MethodTextDocumentLinkedEditingRange, zap.Error(err)) - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + var params LinkedEditingRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) } - err := server.CodeLensRefresh(ctx) + resp, err := server.LinkedEditingRange(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) + + case MethodTextDocumentMoniker: // request + defer logger.Debug(MethodTextDocumentMoniker, zap.Error(err)) + + var params MonikerParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.Moniker(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentOnTypeFormatting: // request + defer logger.Debug(MethodTextDocumentOnTypeFormatting, zap.Error(err)) + + var params DocumentOnTypeFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.DocumentOnTypeFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) case MethodTextDocumentPrepareCallHierarchy: // request defer logger.Debug(MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) @@ -672,60 +669,120 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, replyParseError(ctx, reply, err) } - resp, err := server.PrepareCallHierarchy(ctx, ¶ms) + resp, err := server.CallHierarchyPrepare(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCallHierarchyIncomingCalls: // request - defer logger.Debug(MethodCallHierarchyIncomingCalls, zap.Error(err)) + case MethodTextDocumentPrepareRename: // request + defer logger.Debug(MethodTextDocumentPrepareRename, zap.Error(err)) - var params CallHierarchyIncomingCallsParams + var params PrepareRenameParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.IncomingCalls(ctx, ¶ms) + resp, err := server.PrepareRename(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodCallHierarchyOutgoingCalls: // request - defer logger.Debug(MethodCallHierarchyOutgoingCalls, zap.Error(err)) + case MethodTextDocumentPrepareTypeHierarchy: // request + defer logger.Debug(MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) - var params CallHierarchyOutgoingCallsParams + var params TypeHierarchyPrepareParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TypeHierarchyPrepare(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentRangeFormatting: // request + defer logger.Debug(MethodTextDocumentRangeFormatting, zap.Error(err)) + + var params DocumentRangeFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.DocumentRangeFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentRangesFormatting: // request + defer logger.Debug(MethodTextDocumentRangesFormatting, zap.Error(err)) + + var params DocumentRangesFormattingParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.DocumentRangesFormatting(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentReferences: // request + defer logger.Debug(MethodTextDocumentReferences, zap.Error(err)) + + var params ReferenceParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.OutgoingCalls(ctx, ¶ms) + resp, err := server.References(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensFull: // request - defer logger.Debug(MethodSemanticTokensFull, zap.Error(err)) + case MethodTextDocumentRename: // request + defer logger.Debug(MethodTextDocumentRename, zap.Error(err)) + + var params RenameParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.Rename(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSelectionRange: // request + defer logger.Debug(MethodTextDocumentSelectionRange, zap.Error(err)) + + var params SelectionRangeParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.SelectionRange(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTextDocumentSemanticTokensFull: // request + defer logger.Debug(MethodTextDocumentSemanticTokensFull, zap.Error(err)) var params SemanticTokensParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SemanticTokensFull(ctx, ¶ms) + resp, err := server.SemanticTokens(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensFullDelta: // request - defer logger.Debug(MethodSemanticTokensFullDelta, zap.Error(err)) + case MethodTextDocumentSemanticTokensFullDelta: // request + defer logger.Debug(MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) var params SemanticTokensDeltaParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.SemanticTokensFullDelta(ctx, ¶ms) + resp, err := server.SemanticTokensDelta(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodSemanticTokensRange: // request - defer logger.Debug(MethodSemanticTokensRange, zap.Error(err)) + case MethodTextDocumentSemanticTokensRange: // request + defer logger.Debug(MethodTextDocumentSemanticTokensRange, zap.Error(err)) var params SemanticTokensRangeParams if err := dec.Decode(¶ms); err != nil { @@ -736,38 +793,147 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, return true, reply(ctx, resp, err) - case MethodSemanticTokensRefresh: // request - defer logger.Debug(MethodSemanticTokensRefresh, zap.Error(err)) + case MethodTextDocumentSignatureHelp: // request + defer logger.Debug(MethodTextDocumentSignatureHelp, zap.Error(err)) - if len(req.Params()) > 0 { - return true, reply(ctx, nil, fmt.Errorf("expected no params: %w", jsonrpc2.ErrInvalidParams)) + var params SignatureHelpParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) } - err := server.SemanticTokensRefresh(ctx) + resp, err := server.SignatureHelp(ctx, ¶ms) - return true, reply(ctx, nil, err) + return true, reply(ctx, resp, err) - case MethodLinkedEditingRange: // request - defer logger.Debug(MethodLinkedEditingRange, zap.Error(err)) + case MethodTextDocumentTypeDefinition: // request + defer logger.Debug(MethodTextDocumentTypeDefinition, zap.Error(err)) - var params LinkedEditingRangeParams + var params TypeDefinitionParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.LinkedEditingRange(ctx, ¶ms) + resp, err := server.TypeDefinition(ctx, ¶ms) return true, reply(ctx, resp, err) - case MethodMoniker: // request - defer logger.Debug(MethodMoniker, zap.Error(err)) + case MethodTextDocumentWillSaveWaitUntil: // request + defer logger.Debug(MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - var params MonikerParams + var params WillSaveTextDocumentParams if err := dec.Decode(¶ms); err != nil { return true, replyParseError(ctx, reply, err) } - resp, err := server.Moniker(ctx, ¶ms) + resp, err := server.WillSaveTextDocumentWaitUntil(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTypeHierarchySubtypes: // request + defer logger.Debug(MethodTypeHierarchySubtypes, zap.Error(err)) + + var params TypeHierarchySubtypesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TypeHierarchySubtypes(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodTypeHierarchySupertypes: // request + defer logger.Debug(MethodTypeHierarchySupertypes, zap.Error(err)) + + var params TypeHierarchySupertypesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.TypeHierarchySupertypes(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceDiagnostic: // request + defer logger.Debug(MethodWorkspaceDiagnostic, zap.Error(err)) + + var params WorkspaceDiagnosticParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceDiagnostic(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceExecuteCommand: // request + defer logger.Debug(MethodWorkspaceExecuteCommand, zap.Error(err)) + + var params ExecuteCommandParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.ExecuteCommand(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceSymbol: // request + defer logger.Debug(MethodWorkspaceSymbol, zap.Error(err)) + + var params WorkspaceSymbolParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceSymbol(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillCreateFiles: // request + defer logger.Debug(MethodWorkspaceWillCreateFiles, zap.Error(err)) + + var params CreateFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WillCreateFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillDeleteFiles: // request + defer logger.Debug(MethodWorkspaceWillDeleteFiles, zap.Error(err)) + + var params DeleteFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WillDeleteFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceWillRenameFiles: // request + defer logger.Debug(MethodWorkspaceWillRenameFiles, zap.Error(err)) + + var params RenameFilesParams + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WillRenameFiles(ctx, ¶ms) + + return true, reply(ctx, resp, err) + + case MethodWorkspaceSymbolResolve: // request + defer logger.Debug(MethodWorkspaceSymbolResolve, zap.Error(err)) + + var params WorkspaceSymbol + if err := dec.Decode(¶ms); err != nil { + return true, replyParseError(ctx, reply, err) + } + + resp, err := server.WorkspaceSymbolResolve(ctx, ¶ms) return true, reply(ctx, resp, err) @@ -776,262 +942,317 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier, } } -// Server represents a Language Server Protocol server. -type Server interface { - Initialize(ctx context.Context, params *InitializeParams) (result *InitializeResult, err error) - Initialized(ctx context.Context, params *InitializedParams) (err error) - Shutdown(ctx context.Context) (err error) - Exit(ctx context.Context) (err error) - WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) - LogTrace(ctx context.Context, params *LogTraceParams) (err error) - SetTrace(ctx context.Context, params *SetTraceParams) (err error) - CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) - CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) - CodeLensResolve(ctx context.Context, params *CodeLens) (result *CodeLens, err error) - ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) - Completion(ctx context.Context, params *CompletionParams) (result *CompletionList, err error) - CompletionResolve(ctx context.Context, params *CompletionItem) (result *CompletionItem, err error) - Declaration(ctx context.Context, params *DeclarationParams) (result []Location /* Declaration | DeclarationLink[] | null */, err error) - Definition(ctx context.Context, params *DefinitionParams) (result []Location /* Definition | DefinitionLink[] | null */, err error) - DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) - DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) - DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) - DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) - DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) - DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) - DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) - DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) - DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) - DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) - DocumentLinkResolve(ctx context.Context, params *DocumentLink) (result *DocumentLink, err error) - DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{} /* []SymbolInformation | []DocumentSymbol */, err error) - ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) - FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) - Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) - Hover(ctx context.Context, params *HoverParams) (result *Hover, err error) - Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) - OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) - PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) - RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) - References(ctx context.Context, params *ReferenceParams) (result []Location, err error) - Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) - SignatureHelp(ctx context.Context, params *SignatureHelpParams) (result *SignatureHelp, err error) - Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) - TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) - WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) - WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) - ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) - WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) - DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) - WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) - DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) - WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) - DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) - CodeLensRefresh(ctx context.Context) (err error) - PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) - IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) - OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) - SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) - SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{} /* SemanticTokens | SemanticTokensDelta */, err error) - SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) - SemanticTokensRefresh(ctx context.Context) (err error) - LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) - Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) - Request(ctx context.Context, method string, params interface{}) (result interface{}, err error) -} - -// list of server methods. -const ( - // MethodCancelRequest method name of "$/cancelRequest". - MethodCancelRequest = "$/cancelRequest" - - // MethodInitialize method name of "initialize". - MethodInitialize = "initialize" - - // MethodInitialized method name of "initialized". - MethodInitialized = "initialized" - - // MethodShutdown method name of "shutdown". - MethodShutdown = "shutdown" - - // MethodExit method name of "exit". - MethodExit = "exit" - - // MethodWorkDoneProgressCancel method name of "window/workDoneProgress/cancel". - MethodWorkDoneProgressCancel = "window/workDoneProgress/cancel" - - // MethodLogTrace method name of "$/logTrace". - MethodLogTrace = "$/logTrace" - - // MethodSetTrace method name of "$/setTrace". - MethodSetTrace = "$/setTrace" - - // MethodTextDocumentCodeAction method name of "textDocument/codeAction". - MethodTextDocumentCodeAction = "textDocument/codeAction" - - // MethodTextDocumentCodeLens method name of "textDocument/codeLens". - MethodTextDocumentCodeLens = "textDocument/codeLens" - - // MethodCodeLensResolve method name of "codeLens/resolve". - MethodCodeLensResolve = "codeLens/resolve" - - // MethodTextDocumentColorPresentation method name of "textDocument/colorPresentation". - MethodTextDocumentColorPresentation = "textDocument/colorPresentation" - - // MethodTextDocumentCompletion method name of "textDocument/completion". - MethodTextDocumentCompletion = "textDocument/completion" - - // MethodCompletionItemResolve method name of "completionItem/resolve". - MethodCompletionItemResolve = "completionItem/resolve" - - // MethodTextDocumentDeclaration method name of "textDocument/declaration". - MethodTextDocumentDeclaration = "textDocument/declaration" +// server implements a Language Server Protocol server. +type server struct { + jsonrpc2.Conn - // MethodTextDocumentDefinition method name of "textDocument/definition". - MethodTextDocumentDefinition = "textDocument/definition" + logger *zap.Logger +} - // MethodTextDocumentDidChange method name of "textDocument/didChange". - MethodTextDocumentDidChange = "textDocument/didChange" +var _ Server = (*server)(nil) - // MethodWorkspaceDidChangeConfiguration method name of "workspace/didChangeConfiguration". - MethodWorkspaceDidChangeConfiguration = "workspace/didChangeConfiguration" +func (s *server) Cancel(ctx context.Context, params *CancelParams) (err error) { + s.logger.Debug("notify " + MethodClientCancelRequest) + defer s.logger.Debug("end "+MethodClientCancelRequest, zap.Error(err)) - // MethodWorkspaceDidChangeWatchedFiles method name of "workspace/didChangeWatchedFiles". - MethodWorkspaceDidChangeWatchedFiles = "workspace/didChangeWatchedFiles" + return s.Conn.Notify(ctx, MethodClientCancelRequest, params) +} - // MethodWorkspaceDidChangeWorkspaceFolders method name of "workspace/didChangeWorkspaceFolders". - MethodWorkspaceDidChangeWorkspaceFolders = "workspace/didChangeWorkspaceFolders" +// Progress is the base protocol offers also support to report progress in a generic fashion. +// +// This mechanism can be used to report any kind of progress including work done progress (usually used to report progress in the user interface using a progress bar) and +// partial result progress to support streaming of results. +// +// @since 3.16.0. +func (s *server) Progress(ctx context.Context, params *ProgressParams) (err error) { + s.logger.Debug("notify " + MethodClientProgress) + defer s.logger.Debug("end "+MethodClientProgress, zap.Error(err)) - // MethodTextDocumentDidClose method name of "textDocument/didClose". - MethodTextDocumentDidClose = "textDocument/didClose" + return s.Conn.Notify(ctx, MethodClientProgress, params) +} + +// SetTrace a notification that should be used by the client to modify the trace setting of the server. +// +// @since 3.16.0. +func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { + s.logger.Debug("notify " + MethodSetTrace) + defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodSetTrace, params) +} + +// Exit a notification to ask the server to exit its process. +// +// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. +func (s *server) Exit(ctx context.Context) (err error) { + s.logger.Debug("notify " + MethodExit) + defer s.logger.Debug("end "+MethodExit, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodExit, nil) +} + +// Initialized sends the notification from the client to the server after the client received the result of the +// initialize request but before the client is sending any other request or notification to the server. +// +// The server can use the initialized notification for example to dynamically register capabilities. +// The initialized notification may only be sent once. +func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { + s.logger.Debug("notify " + MethodInitialized) + defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodInitialized, params) +} + +func (s *server) DidChangeNotebookDocument(ctx context.Context, params *DidChangeNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidChange) + defer s.logger.Debug("end "+MethodNotebookDocumentDidChange, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodNotebookDocumentDidChange, params) +} + +// NotebookDocumentDidClose a notification sent when a notebook closes. +// +// @since 3.17.0 +func (s *server) DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidClose) + defer s.logger.Debug("end "+MethodNotebookDocumentDidClose, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodNotebookDocumentDidClose, params) +} + +// NotebookDocumentDidOpen a notification sent when a notebook opens. +// +// @since 3.17.0 +func (s *server) DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidOpen) + defer s.logger.Debug("end "+MethodNotebookDocumentDidOpen, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodNotebookDocumentDidOpen, params) +} + +// NotebookDocumentDidSave a notification sent when a notebook document is saved. +// +// @since 3.17.0 +func (s *server) DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) (err error) { + s.logger.Debug("call " + MethodNotebookDocumentDidSave) + defer s.logger.Debug("end "+MethodNotebookDocumentDidSave, zap.Error(err)) + + return s.Conn.Notify(ctx, MethodNotebookDocumentDidSave, params) +} + +// DidChange sends the notification from the client to the server to signal changes to a text document. +// +// In 2.0 the shape of the params has changed to include proper version numbers and language ids. +func (s *server) DidChangeTextDocument(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { + s.logger.Debug("notify " + MethodTextDocumentDidChange) + defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) - // MethodTextDocumentDidOpen method name of "textDocument/didOpen". - MethodTextDocumentDidOpen = "textDocument/didOpen" + return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) +} - // MethodTextDocumentDidSave method name of "textDocument/didSave". - MethodTextDocumentDidSave = "textDocument/didSave" +// DidClose sends the notification from the client to the server when the document got closed in the client. +// +// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). +// As with the open notification the close notification is about managing the document’s content. +// Receiving a close notification doesn’t mean that the document was open in an editor before. +// +// A close notification requires a previous open notification to be sent. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidClose) + defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) - // MethodTextDocumentDocumentColor method name of"textDocument/documentColor". - MethodTextDocumentDocumentColor = "textDocument/documentColor" + return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) +} - // MethodTextDocumentDocumentHighlight method name of "textDocument/documentHighlight". - MethodTextDocumentDocumentHighlight = "textDocument/documentHighlight" +// DidOpen sends the open notification from the client to the server to signal newly opened text documents. +// +// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. +// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. +// +// An open notification must not be sent more than once without a corresponding close notification send before. +// This means open and close notification must be balanced and the max open count for a particular textDocument is one. +// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. +func (s *server) DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidOpen) + defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) - // MethodTextDocumentDocumentLink method name of "textDocument/documentLink". - MethodTextDocumentDocumentLink = "textDocument/documentLink" + return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) +} - // MethodDocumentLinkResolve method name of "documentLink/resolve". - MethodDocumentLinkResolve = "documentLink/resolve" +// DidSave sends the notification from the client to the server when the document was saved in the client. +func (s *server) DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentDidSave) + defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) - // MethodTextDocumentDocumentSymbol method name of "textDocument/documentSymbol". - MethodTextDocumentDocumentSymbol = "textDocument/documentSymbol" + return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) +} - // MethodWorkspaceExecuteCommand method name of "workspace/executeCommand". - MethodWorkspaceExecuteCommand = "workspace/executeCommand" +// WillSave sends the notification from the client to the server before the document is actually saved. +func (s *server) WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { + s.logger.Debug("call " + MethodTextDocumentWillSave) + defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) - // MethodTextDocumentFoldingRange method name of "textDocument/foldingRange". - MethodTextDocumentFoldingRange = "textDocument/foldingRange" + return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) +} - // MethodTextDocumentFormatting method name of "textDocument/formatting". - MethodTextDocumentFormatting = "textDocument/formatting" +// WindowWorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the +// server side using the "window/workDoneProgress/create". +func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { + s.logger.Debug("call " + MethodWindowWorkDoneProgressCancel) + defer s.logger.Debug("end "+MethodWindowWorkDoneProgressCancel, zap.Error(err)) - // MethodTextDocumentHover method name of "textDocument/hover". - MethodTextDocumentHover = "textDocument/hover" + return s.Conn.Notify(ctx, MethodWindowWorkDoneProgressCancel, params) +} - // MethodTextDocumentImplementation method name of "textDocument/implementation". - MethodTextDocumentImplementation = "textDocument/implementation" +// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. +func (s *server) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) - // MethodTextDocumentOnTypeFormatting method name of "textDocument/onTypeFormatting". - MethodTextDocumentOnTypeFormatting = "textDocument/onTypeFormatting" + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) +} - // MethodTextDocumentPrepareRename method name of "textDocument/prepareRename". - MethodTextDocumentPrepareRename = "textDocument/prepareRename" +// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. +// +// It is recommended that servers register for these file events using the registration mechanism. +// In former implementations clients pushed file events without the server actively asking for it. +func (s *server) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) - // MethodTextDocumentRangeFormatting method name of "textDocument/rangeFormatting". - MethodTextDocumentRangeFormatting = "textDocument/rangeFormatting" + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) +} - // MethodTextDocumentReferences method name of "textDocument/references". - MethodTextDocumentReferences = "textDocument/references" +// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. +// +// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; +// or if the server has registered itself to receive this notification. +// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. +// +// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). +func (s *server) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) + defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) - // MethodTextDocumentRename method name of "textDocument/rename". - MethodTextDocumentRename = "textDocument/rename" + return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) +} - // MethodTextDocumentSignatureHelp method name of "textDocument/signatureHelp". - MethodTextDocumentSignatureHelp = "textDocument/signatureHelp" +// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. +// +// @since 3.16.0. +func (s *server) DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidCreateFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidCreateFiles, zap.Error(err)) - // MethodWorkspaceSymbol method name of "workspace/symbol". - MethodWorkspaceSymbol = "workspace/symbol" + return s.Conn.Notify(ctx, MethodWorkspaceDidCreateFiles, params) +} - // MethodTextDocumentTypeDefinition method name of "textDocument/typeDefinition". - MethodTextDocumentTypeDefinition = "textDocument/typeDefinition" +// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. +// +// @since 3.16.0. +func (s *server) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidDeleteFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidDeleteFiles, zap.Error(err)) - // MethodTextDocumentWillSave method name of "textDocument/willSave". - MethodTextDocumentWillSave = "textDocument/willSave" + return s.Conn.Notify(ctx, MethodWorkspaceDidDeleteFiles, params) +} - // MethodTextDocumentWillSaveWaitUntil method name of "textDocument/willSaveWaitUntil". - MethodTextDocumentWillSaveWaitUntil = "textDocument/willSaveWaitUntil" +// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. +// +// @since 3.16.0. +func (s *server) DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { + s.logger.Debug("call " + MethodWorkspaceDidRenameFiles) + defer s.logger.Debug("end "+MethodWorkspaceDidRenameFiles, zap.Error(err)) - // MethodShowDocument method name of "window/showDocument". - MethodShowDocument = "window/showDocument" + return s.Conn.Notify(ctx, MethodWorkspaceDidRenameFiles, params) +} - // MethodWillCreateFiles method name of "workspace/willCreateFiles". - MethodWillCreateFiles = "workspace/willCreateFiles" +// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (_ []*CallHierarchyIncomingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) - // MethodDidCreateFiles method name of "workspace/didCreateFiles". - MethodDidCreateFiles = "workspace/didCreateFiles" + var result []*CallHierarchyIncomingCall + if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { + return nil, err + } - // MethodWillRenameFiles method name of "workspace/willRenameFiles". - MethodWillRenameFiles = "workspace/willRenameFiles" + return result, nil +} - // MethodDidRenameFiles method name of "workspace/didRenameFiles". - MethodDidRenameFiles = "workspace/didRenameFiles" +// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. +// +// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// +// @since 3.16.0. +func (s *server) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (_ []*CallHierarchyOutgoingCall, err error) { + s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) + defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) - // MethodWillDeleteFiles method name of "workspace/willDeleteFiles". - MethodWillDeleteFiles = "workspace/willDeleteFiles" + var result []*CallHierarchyOutgoingCall + if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { + return nil, err + } - // MethodDidDeleteFiles method name of "workspace/didDeleteFiles". - MethodDidDeleteFiles = "workspace/didDeleteFiles" + return result, nil +} - // MethodCodeLensRefresh method name of "workspace/codeLens/refresh". - MethodCodeLensRefresh = "workspace/codeLens/refresh" +func (s *server) CodeActionResolve(ctx context.Context, params *CodeAction) (_ *CodeAction, err error) { + s.logger.Debug("call " + MethodCodeActionResolve) + defer s.logger.Debug("end "+MethodCodeActionResolve, zap.Error(err)) - // MethodTextDocumentPrepareCallHierarchy method name of "textDocument/prepareCallHierarchy". - MethodTextDocumentPrepareCallHierarchy = "textDocument/prepareCallHierarchy" + var result *CodeAction + if err := Call(ctx, s.Conn, MethodCodeActionResolve, params, &result); err != nil { + return nil, err + } - // MethodCallHierarchyIncomingCalls method name of "callHierarchy/incomingCalls". - MethodCallHierarchyIncomingCalls = "callHierarchy/incomingCalls" + return result, nil +} - // MethodCallHierarchyOutgoingCalls method name of "callHierarchy/outgoingCalls". - MethodCallHierarchyOutgoingCalls = "callHierarchy/outgoingCalls" +// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. +func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { + s.logger.Debug("call " + MethodCodeLensResolve) + defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) - // MethodSemanticTokensFull method name of "textDocument/semanticTokens/full". - MethodSemanticTokensFull = "textDocument/semanticTokens/full" + var result *CodeLens + if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { + return nil, err + } - // MethodSemanticTokensFullDelta method name of "textDocument/semanticTokens/full/delta". - MethodSemanticTokensFullDelta = "textDocument/semanticTokens/full/delta" + return result, nil +} - // MethodSemanticTokensRange method name of "textDocument/semanticTokens/range". - MethodSemanticTokensRange = "textDocument/semanticTokens/range" +// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. +func (s *server) CompletionResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { + s.logger.Debug("call " + MethodCompletionItemResolve) + defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) - // MethodSemanticTokensRefresh method name of "workspace/semanticTokens/refresh". - MethodSemanticTokensRefresh = "workspace/semanticTokens/refresh" + var result *CompletionItem + if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { + return nil, err + } - // MethodLinkedEditingRange method name of "textDocument/linkedEditingRange". - MethodLinkedEditingRange = "textDocument/linkedEditingRange" + return result, nil +} - // MethodMoniker method name of "textDocument/moniker". - MethodMoniker = "textDocument/moniker" -) +// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. +func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { + s.logger.Debug("call " + MethodDocumentLinkResolve) + defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) -// server implements a Language Server Protocol server. -type server struct { - jsonrpc2.Conn + var result *DocumentLink + if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { + return nil, err + } - logger *zap.Logger + return result, nil } -var _ Server = (*server)(nil) - // Initialize sents the request as the first request from the client to the server. // // If the server receives a request or notification before the initialize request it should act as follows: @@ -1057,16 +1278,16 @@ func (s *server) Initialize(ctx context.Context, params *InitializeParams) (_ *I return result, nil } -// Initialized sends the notification from the client to the server after the client received the result of the -// initialize request but before the client is sending any other request or notification to the server. -// -// The server can use the initialized notification for example to dynamically register capabilities. -// The initialized notification may only be sent once. -func (s *server) Initialized(ctx context.Context, params *InitializedParams) (err error) { - s.logger.Debug("notify " + MethodInitialized) - defer s.logger.Debug("end "+MethodInitialized, zap.Error(err)) +func (s *server) InlayHintResolve(ctx context.Context, params *InlayHint) (_ *InlayHint, err error) { + s.logger.Debug("call " + MethodInlayHintResolve) + defer s.logger.Debug("end "+MethodInlayHintResolve, zap.Error(err)) - return s.Conn.Notify(ctx, MethodInitialized, params) + var result *InlayHint + if err := Call(ctx, s.Conn, MethodInlayHintResolve, params, &result); err != nil { + return nil, err + } + + return result, nil } // Shutdown sents the request from the client to the server. @@ -1083,50 +1304,6 @@ func (s *server) Shutdown(ctx context.Context) (err error) { return Call(ctx, s.Conn, MethodShutdown, nil, nil) } -// Exit a notification to ask the server to exit its process. -// -// The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1. -func (s *server) Exit(ctx context.Context) (err error) { - s.logger.Debug("notify " + MethodExit) - defer s.logger.Debug("end "+MethodExit, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodExit, nil) -} - -// LogTrace a notification to log the trace of the server’s execution. -// -// The amount and content of these notifications depends on the current trace configuration. -// -// If trace is "off", the server should not send any logTrace notification. If trace is "message", -// the server should not add the "verbose" field in the LogTraceParams. -// -// @since 3.16.0. -func (s *server) LogTrace(ctx context.Context, params *LogTraceParams) (err error) { - s.logger.Debug("notify " + MethodLogTrace) - defer s.logger.Debug("end "+MethodLogTrace, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodLogTrace, params) -} - -// SetTrace a notification that should be used by the client to modify the trace setting of the server. -// -// @since 3.16.0. -func (s *server) SetTrace(ctx context.Context, params *SetTraceParams) (err error) { - s.logger.Debug("notify " + MethodSetTrace) - defer s.logger.Debug("end "+MethodSetTrace, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodSetTrace, params) -} - -// WorkDoneProgressCancel is the sends notification from the client to the server to cancel a progress initiated on the -// server side using the "window/workDoneProgress/create". -func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) (err error) { - s.logger.Debug("call " + MethodWorkDoneProgressCancel) - defer s.logger.Debug("end "+MethodWorkDoneProgressCancel, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkDoneProgressCancel, params) -} - // CodeAction sends the request is from the client to the server to compute commands for a given text document and range. // // These commands are typically code fixes to either fix problems or to beautify/refactor code. The result of a `textDocument/codeAction` @@ -1135,10 +1312,11 @@ func (s *server) WorkDoneProgressCancel(ctx context.Context, params *WorkDonePro // To ensure that a server is useful in many clients the commands specified in a code actions should be handled by the // server and not by the client (see `workspace/executeCommand` and `ServerCapabilities.executeCommandProvider`). // If the client supports providing edits with a code action then the mode should be used. -func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (result []CodeAction, err error) { +func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (_ *CodeActionRequestResult, err error) { s.logger.Debug("call " + MethodTextDocumentCodeAction) defer s.logger.Debug("end "+MethodTextDocumentCodeAction, zap.Error(err)) + var result *CodeActionRequestResult if err := Call(ctx, s.Conn, MethodTextDocumentCodeAction, params, &result); err != nil { return nil, err } @@ -1147,10 +1325,11 @@ func (s *server) CodeAction(ctx context.Context, params *CodeActionParams) (resu } // CodeLens sends the request from the client to the server to compute code lenses for a given text document. -func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (result []CodeLens, err error) { +func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (_ []*CodeLens, err error) { s.logger.Debug("call " + MethodTextDocumentCodeLens) defer s.logger.Debug("end "+MethodTextDocumentCodeLens, zap.Error(err)) + var result []*CodeLens if err := Call(ctx, s.Conn, MethodTextDocumentCodeLens, params, &result); err != nil { return nil, err } @@ -1158,29 +1337,17 @@ func (s *server) CodeLens(ctx context.Context, params *CodeLensParams) (result [ return result, nil } -// CodeLensResolve sends the request from the client to the server to resolve the command for a given code lens item. -func (s *server) CodeLensResolve(ctx context.Context, params *CodeLens) (_ *CodeLens, err error) { - s.logger.Debug("call " + MethodCodeLensResolve) - defer s.logger.Debug("end "+MethodCodeLensResolve, zap.Error(err)) - - var result *CodeLens - if err := Call(ctx, s.Conn, MethodCodeLensResolve, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // ColorPresentation sends the request from the client to the server to obtain a list of presentations for a color value at a given location. // // # Clients can use the result to // // - modify a color reference. // - show in a color picker and let users pick one of the presentations. -func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentationParams) (result []ColorPresentation, err error) { +func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentationParams) (_ []*ColorPresentation, err error) { s.logger.Debug("call " + MethodTextDocumentColorPresentation) defer s.logger.Debug("end "+MethodTextDocumentColorPresentation, zap.Error(err)) + var result []*ColorPresentation if err := Call(ctx, s.Conn, MethodTextDocumentColorPresentation, params, &result); err != nil { return nil, err } @@ -1201,11 +1368,11 @@ func (s *server) ColorPresentation(ctx context.Context, params *ColorPresentatio // The returned completion item should have the documentation property filled in. The request can delay the computation of // the `detail` and `documentation` properties. However, properties that are needed for the initial sorting and filtering, // like `sortText`, `filterText`, `insertText`, and `textEdit` must be provided in the `textDocument/completion` response and must not be changed during resolve. -func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *CompletionList, err error) { +func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *CompletionResult, err error) { s.logger.Debug("call " + MethodTextDocumentCompletion) defer s.logger.Debug("end "+MethodTextDocumentCompletion, zap.Error(err)) - var result *CompletionList + var result *CompletionResult if err := Call(ctx, s.Conn, MethodTextDocumentCompletion, params, &result); err != nil { return nil, err } @@ -1213,28 +1380,16 @@ func (s *server) Completion(ctx context.Context, params *CompletionParams) (_ *C return result, nil } -// CompletionResolve sends the request from the client to the server to resolve additional information for a given completion item. -func (s *server) CompletionResolve(ctx context.Context, params *CompletionItem) (_ *CompletionItem, err error) { - s.logger.Debug("call " + MethodCompletionItemResolve) - defer s.logger.Debug("end "+MethodCompletionItemResolve, zap.Error(err)) - - var result *CompletionItem - if err := Call(ctx, s.Conn, MethodCompletionItemResolve, params, &result); err != nil { - return nil, err - } - - return result, nil -} - // Declaration sends the request from the client to the server to resolve the declaration location of a symbol at a given text document position. // // The result type LocationLink[] got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.declaration.linkSupport`. // // @since 3.14.0. -func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (result []Location, err error) { +func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (_ *DeclarationResult, err error) { s.logger.Debug("call " + MethodTextDocumentDeclaration) defer s.logger.Debug("end "+MethodTextDocumentDeclaration, zap.Error(err)) + var result *DeclarationResult if err := Call(ctx, s.Conn, MethodTextDocumentDeclaration, params, &result); err != nil { return nil, err } @@ -1247,10 +1402,11 @@ func (s *server) Declaration(ctx context.Context, params *DeclarationParams) (re // The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.definition.linkSupport`. // // @since 3.14.0. -func (s *server) Definition(ctx context.Context, params *DefinitionParams) (result []Location, err error) { +func (s *server) Definition(ctx context.Context, params *DefinitionParams) (_ *DefinitionResult, err error) { s.logger.Debug("call " + MethodTextDocumentDefinition) defer s.logger.Debug("end "+MethodTextDocumentDefinition, zap.Error(err)) + var result *DefinitionResult if err := Call(ctx, s.Conn, MethodTextDocumentDefinition, params, &result); err != nil { return nil, err } @@ -1258,85 +1414,16 @@ func (s *server) Definition(ctx context.Context, params *DefinitionParams) (resu return result, nil } -// DidChange sends the notification from the client to the server to signal changes to a text document. -// -// In 2.0 the shape of the params has changed to include proper version numbers and language ids. -func (s *server) DidChange(ctx context.Context, params *DidChangeTextDocumentParams) (err error) { - s.logger.Debug("notify " + MethodTextDocumentDidChange) - defer s.logger.Debug("end "+MethodTextDocumentDidChange, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidChange, params) -} - -// DidChangeConfiguration sends the notification from the client to the server to signal the change of configuration settings. -func (s *server) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeConfiguration) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeConfiguration, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeConfiguration, params) -} - -// DidChangeWatchedFiles sends the notification from the client to the server when the client detects changes to files watched by the language client. -// -// It is recommended that servers register for these file events using the registration mechanism. -// In former implementations clients pushed file events without the server actively asking for it. -func (s *server) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWatchedFiles) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWatchedFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWatchedFiles, params) -} - -// DidChangeWorkspaceFolders sents the notification from the client to the server to inform the server about workspace folder configuration changes. -// -// The notification is sent by default if both ServerCapabilities/workspace/workspaceFolders and ClientCapabilities/workspace/workspaceFolders are true; -// or if the server has registered itself to receive this notification. -// To register for the workspace/didChangeWorkspaceFolders send a client/registerCapability request from the server to the client. -// -// The registration parameter must have a registrations item of the following form, where id is a unique id used to unregister the capability (the example uses a UUID). -func (s *server) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) (err error) { - s.logger.Debug("call " + MethodWorkspaceDidChangeWorkspaceFolders) - defer s.logger.Debug("end "+MethodWorkspaceDidChangeWorkspaceFolders, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodWorkspaceDidChangeWorkspaceFolders, params) -} +func (s *server) DocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (_ *DocumentDiagnosticReport, err error) { + s.logger.Debug("call " + MethodTextDocumentDiagnostic) + defer s.logger.Debug("end "+MethodTextDocumentDiagnostic, zap.Error(err)) -// DidClose sends the notification from the client to the server when the document got closed in the client. -// -// The document’s truth now exists where the document’s Uri points to (e.g. if the document’s Uri is a file Uri the truth now exists on disk). -// As with the open notification the close notification is about managing the document’s content. -// Receiving a close notification doesn’t mean that the document was open in an editor before. -// -// A close notification requires a previous open notification to be sent. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) DidClose(ctx context.Context, params *DidCloseTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidClose) - defer s.logger.Debug("end "+MethodTextDocumentDidClose, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidClose, params) -} - -// DidOpen sends the open notification from the client to the server to signal newly opened text documents. -// -// The document’s truth is now managed by the client and the server must not try to read the document’s truth using the document’s Uri. -// Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. -// -// An open notification must not be sent more than once without a corresponding close notification send before. -// This means open and close notification must be balanced and the max open count for a particular textDocument is one. -// Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed. -func (s *server) DidOpen(ctx context.Context, params *DidOpenTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidOpen) - defer s.logger.Debug("end "+MethodTextDocumentDidOpen, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentDidOpen, params) -} - -// DidSave sends the notification from the client to the server when the document was saved in the client. -func (s *server) DidSave(ctx context.Context, params *DidSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentDidSave) - defer s.logger.Debug("end "+MethodTextDocumentDidSave, zap.Error(err)) + var result *DocumentDiagnosticReport + if err := Call(ctx, s.Conn, MethodTextDocumentDiagnostic, params, &result); err != nil { + return nil, err + } - return s.Conn.Notify(ctx, MethodTextDocumentDidSave, params) + return result, nil } // DocumentColor sends the request from the client to the server to list all color references found in a given text document. @@ -1348,10 +1435,11 @@ func (s *server) DidSave(ctx context.Context, params *DidSaveTextDocumentParams) // // - Color boxes showing the actual color next to the reference // - Show a color picker when a color reference is edited. -func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) (result []ColorInformation, err error) { +func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) (_ []*ColorInformation, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentColor) defer s.logger.Debug("end "+MethodTextDocumentDocumentColor, zap.Error(err)) + var result []*ColorInformation if err := Call(ctx, s.Conn, MethodTextDocumentDocumentColor, params, &result); err != nil { return nil, err } @@ -1365,10 +1453,11 @@ func (s *server) DocumentColor(ctx context.Context, params *DocumentColorParams) // However we kept ‘textDocument/documentHighlight’ and ‘textDocument/references’ separate requests since the first one is allowed to be more fuzzy. // // Symbol matches usually have a `DocumentHighlightKind` of `Read` or `Write` whereas fuzzy or textual matches use `Text` as the kind. -func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (result []DocumentHighlight, err error) { +func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) (_ []*DocumentHighlight, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentHighlight) defer s.logger.Debug("end "+MethodTextDocumentDocumentHighlight, zap.Error(err)) + var result []*DocumentHighlight if err := Call(ctx, s.Conn, MethodTextDocumentDocumentHighlight, params, &result); err != nil { return nil, err } @@ -1377,10 +1466,11 @@ func (s *server) DocumentHighlight(ctx context.Context, params *DocumentHighligh } // DocumentLink sends the request from the client to the server to request the location of links in a document. -func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) (result []DocumentLink, err error) { +func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) (_ []*DocumentLink, err error) { s.logger.Debug("call " + MethodTextDocumentDocumentLink) defer s.logger.Debug("end "+MethodTextDocumentDocumentLink, zap.Error(err)) + var result []*DocumentLink if err := Call(ctx, s.Conn, MethodTextDocumentDocumentLink, params, &result); err != nil { return nil, err } @@ -1388,95 +1478,145 @@ func (s *server) DocumentLink(ctx context.Context, params *DocumentLinkParams) ( return result, nil } -// DocumentLinkResolve sends the request from the client to the server to resolve the target of a given document link. -func (s *server) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (_ *DocumentLink, err error) { - s.logger.Debug("call " + MethodDocumentLinkResolve) - defer s.logger.Debug("end "+MethodDocumentLinkResolve, zap.Error(err)) +// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. +// +// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. +func (s *server) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (_ *DocumentSymbolResult, err error) { + s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) + defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) - var result *DocumentLink - if err := Call(ctx, s.Conn, MethodDocumentLinkResolve, params, &result); err != nil { + var result *DocumentSymbolResult + if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { return nil, err } return result, nil } -// DocumentSymbol sends the request from the client to the server to return a flat list of all symbols found in a given text document. +// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. // -// Neither the symbol’s location range nor the symbol’s container name should be used to infer a hierarchy. -func (s *server) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (result []interface{}, err error) { - s.logger.Debug("call " + MethodTextDocumentDocumentSymbol) - defer s.logger.Debug("end "+MethodTextDocumentDocumentSymbol, zap.Error(err)) +// @since version 3.10.0. +func (s *server) FoldingRange(ctx context.Context, params *FoldingRangeParams) (_ []*FoldingRange, err error) { + s.logger.Debug("call " + MethodTextDocumentFoldingRange) + defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentDocumentSymbol, params, &result); err != nil { + var result []*FoldingRange + if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { return nil, err } return result, nil } -// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. +// DocumentFormatting sends the request from the client to the server to format a whole document. +func (s *server) DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentFormatting) + defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) + + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Hover sends the request is from the client to the server to request hover information at a given text document position. +func (s *server) Hover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { + s.logger.Debug("call " + MethodTextDocumentHover) + defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) + + var result *Hover + if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { + return nil, err + } + + return result, nil +} + +// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. // -// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the -// request `workspace/applyEdit` which is sent from the server to the client. -func (s *server) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result interface{}, err error) { - s.logger.Debug("call " + MethodWorkspaceExecuteCommand) - defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. +func (s *server) Implementation(ctx context.Context, params *ImplementationParams) (_ *ImplementationResult, err error) { + s.logger.Debug("call " + MethodTextDocumentImplementation) + defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) + + var result *ImplementationResult + if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { + return nil, err + } + + return result, nil +} - if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { +func (s *server) InlayHint(ctx context.Context, params *InlayHintParams) (_ []*InlayHint, err error) { + s.logger.Debug("call " + MethodTextDocumentInlayHint) + defer s.logger.Debug("end "+MethodTextDocumentInlayHint, zap.Error(err)) + + var result []*InlayHint + if err := Call(ctx, s.Conn, MethodTextDocumentInlayHint, params, &result); err != nil { return nil, err } return result, nil } -// FoldingRanges sends the request from the client to the server to return all folding ranges found in a given text document. -// -// @since version 3.10.0. -func (s *server) FoldingRanges(ctx context.Context, params *FoldingRangeParams) (result []FoldingRange, err error) { - s.logger.Debug("call " + MethodTextDocumentFoldingRange) - defer s.logger.Debug("end "+MethodTextDocumentFoldingRange, zap.Error(err)) +func (s *server) InlineCompletion(ctx context.Context, params *InlineCompletionParams) (_ *InlineCompletionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentInlineCompletion) + defer s.logger.Debug("end "+MethodTextDocumentInlineCompletion, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentFoldingRange, params, &result); err != nil { + var result *InlineCompletionResult + if err := Call(ctx, s.Conn, MethodTextDocumentInlineCompletion, params, &result); err != nil { return nil, err } return result, nil } -// Formatting sends the request from the client to the server to format a whole document. -func (s *server) Formatting(ctx context.Context, params *DocumentFormattingParams) (result []TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentFormatting) - defer s.logger.Debug("end "+MethodTextDocumentFormatting, zap.Error(err)) +func (s *server) InlineValue(ctx context.Context, params *InlineValueParams) (_ []*InlineValue, err error) { + s.logger.Debug("call " + MethodTextDocumentInlineValue) + defer s.logger.Debug("end "+MethodTextDocumentInlineValue, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentFormatting, params, &result); err != nil { + var result []*InlineValue + if err := Call(ctx, s.Conn, MethodTextDocumentInlineValue, params, &result); err != nil { return nil, err } return result, nil } -// Hover sends the request is from the client to the server to request hover information at a given text document position. -func (s *server) Hover(ctx context.Context, params *HoverParams) (_ *Hover, err error) { - s.logger.Debug("call " + MethodTextDocumentHover) - defer s.logger.Debug("end "+MethodTextDocumentHover, zap.Error(err)) +// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. +// +// Optionally a word pattern can be returned to describe valid contents. +// +// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. +// +// @since 3.16.0. +func (s *server) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (_ *LinkedEditingRanges, err error) { + s.logger.Debug("call " + MethodTextDocumentLinkedEditingRange) + defer s.logger.Debug("end "+MethodTextDocumentLinkedEditingRange, zap.Error(err)) - var result *Hover - if err := Call(ctx, s.Conn, MethodTextDocumentHover, params, &result); err != nil { + var result *LinkedEditingRanges + if err := Call(ctx, s.Conn, MethodTextDocumentLinkedEditingRange, params, &result); err != nil { return nil, err } return result, nil } -// Implementation sends the request from the client to the server to resolve the implementation location of a symbol at a given text document position. +// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. // -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.implementation.typeDefinition.linkSupport`. -func (s *server) Implementation(ctx context.Context, params *ImplementationParams) (result []Location, err error) { - s.logger.Debug("call " + MethodTextDocumentImplementation) - defer s.logger.Debug("end "+MethodTextDocumentImplementation, zap.Error(err)) +// An array of Moniker types is returned as response to indicate possible monikers at the given location. +// +// If no monikers can be calculated, an empty array or null should be returned. +// +// @since 3.16.0. +func (s *server) Moniker(ctx context.Context, params *MonikerParams) (_ []*Moniker, err error) { + s.logger.Debug("call " + MethodTextDocumentMoniker) + defer s.logger.Debug("end "+MethodTextDocumentMoniker, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentImplementation, params, &result); err != nil { + var result []*Moniker + if err := Call(ctx, s.Conn, MethodTextDocumentMoniker, params, &result); err != nil { return nil, err } @@ -1484,10 +1624,11 @@ func (s *server) Implementation(ctx context.Context, params *ImplementationParam } // OnTypeFormatting sends the request from the client to the server to format parts of the document during typing. -func (s *server) OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (result []TextEdit, err error) { +func (s *server) DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) (_ []*TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentOnTypeFormatting) defer s.logger.Debug("end "+MethodTextDocumentOnTypeFormatting, zap.Error(err)) + var result []*TextEdit if err := Call(ctx, s.Conn, MethodTextDocumentOnTypeFormatting, params, &result); err != nil { return nil, err } @@ -1495,13 +1636,33 @@ func (s *server) OnTypeFormatting(ctx context.Context, params *DocumentOnTypeFor return result, nil } +// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. +// +// The call hierarchy requests are executed in two steps: +// 1. first a call hierarchy item is resolved for the given text document position +// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. +// +// @since 3.16.0. +func (s *server) CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) (_ []*CallHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) + + var result []*CallHierarchyItem + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { + return nil, err + } + + return result, nil +} + // PrepareRename sends the request from the client to the server to setup and test the validity of a rename operation at a given location. // // @since version 3.12.0. -func (s *server) PrepareRename(ctx context.Context, params *PrepareRenameParams) (result *Range, err error) { +func (s *server) PrepareRename(ctx context.Context, params *PrepareRenameParams) (_ *PrepareRenameResult, err error) { s.logger.Debug("call " + MethodTextDocumentPrepareRename) defer s.logger.Debug("end "+MethodTextDocumentPrepareRename, zap.Error(err)) + var result *PrepareRenameResult if err := Call(ctx, s.Conn, MethodTextDocumentPrepareRename, params, &result); err != nil { return nil, err } @@ -1509,11 +1670,24 @@ func (s *server) PrepareRename(ctx context.Context, params *PrepareRenameParams) return result, nil } +func (s *server) TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTextDocumentPrepareTypeHierarchy) + defer s.logger.Debug("end "+MethodTextDocumentPrepareTypeHierarchy, zap.Error(err)) + + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTextDocumentPrepareTypeHierarchy, params, &result); err != nil { + return nil, err + } + + return result, nil +} + // RangeFormatting sends the request from the client to the server to format a given range in a document. -func (s *server) RangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (result []TextEdit, err error) { +func (s *server) DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) (_ []*TextEdit, err error) { s.logger.Debug("call " + MethodTextDocumentRangeFormatting) defer s.logger.Debug("end "+MethodTextDocumentRangeFormatting, zap.Error(err)) + var result []*TextEdit if err := Call(ctx, s.Conn, MethodTextDocumentRangeFormatting, params, &result); err != nil { return nil, err } @@ -1521,11 +1695,24 @@ func (s *server) RangeFormatting(ctx context.Context, params *DocumentRangeForma return result, nil } +func (s *server) DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentRangesFormatting) + defer s.logger.Debug("end "+MethodTextDocumentRangesFormatting, zap.Error(err)) + + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentRangesFormatting, params, &result); err != nil { + return nil, err + } + + return result, nil +} + // References sends the request from the client to the server to resolve project-wide references for the symbol denoted by the given text document position. -func (s *server) References(ctx context.Context, params *ReferenceParams) (result []Location, err error) { +func (s *server) References(ctx context.Context, params *ReferenceParams) (_ []*Location, err error) { s.logger.Debug("call " + MethodTextDocumentReferences) defer s.logger.Debug("end "+MethodTextDocumentReferences, zap.Error(err)) + var result []*Location if err := Call(ctx, s.Conn, MethodTextDocumentReferences, params, &result); err != nil { return nil, err } @@ -1534,10 +1721,11 @@ func (s *server) References(ctx context.Context, params *ReferenceParams) (resul } // Rename sends the request from the client to the server to perform a workspace-wide rename of a symbol. -func (s *server) Rename(ctx context.Context, params *RenameParams) (result *WorkspaceEdit, err error) { +func (s *server) Rename(ctx context.Context, params *RenameParams) (_ *WorkspaceEdit, err error) { s.logger.Debug("call " + MethodTextDocumentRename) defer s.logger.Debug("end "+MethodTextDocumentRename, zap.Error(err)) + var result *WorkspaceEdit if err := Call(ctx, s.Conn, MethodTextDocumentRename, params, &result); err != nil { return nil, err } @@ -1545,335 +1733,265 @@ func (s *server) Rename(ctx context.Context, params *RenameParams) (result *Work return result, nil } -// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. -func (s *server) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { - s.logger.Debug("call " + MethodTextDocumentSignatureHelp) - defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) +func (s *server) SelectionRange(ctx context.Context, params *SelectionRangeParams) (_ []*SelectionRange, err error) { + s.logger.Debug("call " + MethodTextDocumentSelectionRange) + defer s.logger.Debug("end "+MethodTextDocumentSelectionRange, zap.Error(err)) - var result *SignatureHelp - if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { + var result []*SelectionRange + if err := Call(ctx, s.Conn, MethodTextDocumentSelectionRange, params, &result); err != nil { return nil, err } return result, nil } -// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. -func (s *server) Symbols(ctx context.Context, params *WorkspaceSymbolParams) (result []SymbolInformation, err error) { - s.logger.Debug("call " + MethodWorkspaceSymbol) - defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) +// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. +// +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// +// @since 3.16.0. +func (s *server) SemanticTokens(ctx context.Context, params *SemanticTokensParams) (_ *SemanticTokens, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensFull) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFull, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { + var result *SemanticTokens + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFull, params, &result); err != nil { return nil, err } return result, nil } -// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. +// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. +// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. // -// @since version 3.6.0. -func (s *server) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (result []Location, err error) { - s.logger.Debug("call " + MethodTextDocumentTypeDefinition) - defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) +// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// +// @since 3.16.0. +func (s *server) SemanticTokensDelta(ctx context.Context, params *SemanticTokensDeltaParams) (_ *SemanticTokensDeltaResult, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensFullDelta) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensFullDelta, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { + var result *SemanticTokensDeltaResult + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensFullDelta, params, &result); err != nil { return nil, err } return result, nil } -// WillSave sends the notification from the client to the server before the document is actually saved. -func (s *server) WillSave(ctx context.Context, params *WillSaveTextDocumentParams) (err error) { - s.logger.Debug("call " + MethodTextDocumentWillSave) - defer s.logger.Debug("end "+MethodTextDocumentWillSave, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodTextDocumentWillSave, params) -} - -// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. +// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. // -// The request can return an array of TextEdits which will be applied to the text document before it is saved. -// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. -// This is done to keep the save fast and reliable. -func (s *server) WillSaveWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (result []TextEdit, err error) { - s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) - defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) +// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). +// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. +// +// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. +// +// @since 3.16.0. +func (s *server) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (_ *SemanticTokens, err error) { + s.logger.Debug("call " + MethodTextDocumentSemanticTokensRange) + defer s.logger.Debug("end "+MethodTextDocumentSemanticTokensRange, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { + var result *SemanticTokens + if err := Call(ctx, s.Conn, MethodTextDocumentSemanticTokensRange, params, &result); err != nil { return nil, err } return result, nil } -// ShowDocument sends the request from a server to a client to ask the client to display a particular document in the user interface. -// -// @since 3.16.0. -func (s *server) ShowDocument(ctx context.Context, params *ShowDocumentParams) (result *ShowDocumentResult, err error) { - s.logger.Debug("call " + MethodShowDocument) - defer s.logger.Debug("end "+MethodShowDocument, zap.Error(err)) +// SignatureHelp sends the request from the client to the server to request signature information at a given cursor position. +func (s *server) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (_ *SignatureHelp, err error) { + s.logger.Debug("call " + MethodTextDocumentSignatureHelp) + defer s.logger.Debug("end "+MethodTextDocumentSignatureHelp, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodShowDocument, params, &result); err != nil { + var result *SignatureHelp + if err := Call(ctx, s.Conn, MethodTextDocumentSignatureHelp, params, &result); err != nil { return nil, err } return result, nil } -// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. -// -// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. +// TypeDefinition sends the request from the client to the server to resolve the type definition location of a symbol at a given text document position. // -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. +// The result type `[]LocationLink` got introduce with version 3.14.0 and depends in the corresponding client capability `clientCapabilities.textDocument.typeDefinition.linkSupport`. // -// @since 3.16.0. -func (s *server) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWillCreateFiles) - defer s.logger.Debug("end "+MethodWillCreateFiles, zap.Error(err)) +// @since version 3.6.0. +func (s *server) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (_ *TypeDefinitionResult, err error) { + s.logger.Debug("call " + MethodTextDocumentTypeDefinition) + defer s.logger.Debug("end "+MethodTextDocumentTypeDefinition, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWillCreateFiles, params, &result); err != nil { + var result *TypeDefinitionResult + if err := Call(ctx, s.Conn, MethodTextDocumentTypeDefinition, params, &result); err != nil { return nil, err } return result, nil } -// DidCreateFiles sends the did create files notification is sent from the client to the server when files were created from within the client. -// -// @since 3.16.0. -func (s *server) DidCreateFiles(ctx context.Context, params *CreateFilesParams) (err error) { - s.logger.Debug("call " + MethodDidCreateFiles) - defer s.logger.Debug("end "+MethodDidCreateFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodDidCreateFiles, params) -} - -// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. -// -// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. -// -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. +// WillSaveWaitUntil sends the request from the client to the server before the document is actually saved. // -// @since 3.16.0. -func (s *server) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWillRenameFiles) - defer s.logger.Debug("end "+MethodWillRenameFiles, zap.Error(err)) +// The request can return an array of TextEdits which will be applied to the text document before it is saved. +// Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. +// This is done to keep the save fast and reliable. +func (s *server) WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) (_ []*TextEdit, err error) { + s.logger.Debug("call " + MethodTextDocumentWillSaveWaitUntil) + defer s.logger.Debug("end "+MethodTextDocumentWillSaveWaitUntil, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWillRenameFiles, params, &result); err != nil { + var result []*TextEdit + if err := Call(ctx, s.Conn, MethodTextDocumentWillSaveWaitUntil, params, &result); err != nil { return nil, err } return result, nil } -// DidRenameFiles sends the did rename files notification is sent from the client to the server when files were renamed from within the client. -// -// @since 3.16.0. -func (s *server) DidRenameFiles(ctx context.Context, params *RenameFilesParams) (err error) { - s.logger.Debug("call " + MethodDidRenameFiles) - defer s.logger.Debug("end "+MethodDidRenameFiles, zap.Error(err)) - - return s.Conn.Notify(ctx, MethodDidRenameFiles, params) -} - -// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. -// -// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. -// -// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. -// -// @since 3.16.0. -func (s *server) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (result *WorkspaceEdit, err error) { - s.logger.Debug("call " + MethodWillDeleteFiles) - defer s.logger.Debug("end "+MethodWillDeleteFiles, zap.Error(err)) +func (s *server) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTypeHierarchySubtypes) + defer s.logger.Debug("end "+MethodTypeHierarchySubtypes, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodWillDeleteFiles, params, &result); err != nil { + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTypeHierarchySubtypes, params, &result); err != nil { return nil, err } return result, nil } -// DidDeleteFiles sends the did delete files notification is sent from the client to the server when files were deleted from within the client. -// -// @since 3.16.0. -func (s *server) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) (err error) { - s.logger.Debug("call " + MethodDidDeleteFiles) - defer s.logger.Debug("end "+MethodDidDeleteFiles, zap.Error(err)) +func (s *server) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) (_ []*TypeHierarchyItem, err error) { + s.logger.Debug("call " + MethodTypeHierarchySupertypes) + defer s.logger.Debug("end "+MethodTypeHierarchySupertypes, zap.Error(err)) - return s.Conn.Notify(ctx, MethodDidDeleteFiles, params) -} - -// CodeLensRefresh sent from the server to the client. -// -// Servers can use it to ask clients to refresh the code lenses currently shown in editors. -// As a result the client should ask the server to recompute the code lenses for these editors. -// This is useful if a server detects a configuration change which requires a re-calculation of all code lenses. -// -// Note that the client still has the freedom to delay the re-calculation of the code lenses if for example an editor is currently not visible. -// -// @since 3.16.0. -func (s *server) CodeLensRefresh(ctx context.Context) (err error) { - s.logger.Debug("call " + MethodCodeLensRefresh) - defer s.logger.Debug("end "+MethodCodeLensRefresh, zap.Error(err)) + var result []*TypeHierarchyItem + if err := Call(ctx, s.Conn, MethodTypeHierarchySupertypes, params, &result); err != nil { + return nil, err + } - return Call(ctx, s.Conn, MethodCodeLensRefresh, nil, nil) + return result, nil } -// PrepareCallHierarchy sent from the client to the server to return a call hierarchy for the language element of given text document positions. -// -// The call hierarchy requests are executed in two steps: -// 1. first a call hierarchy item is resolved for the given text document position -// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved. -// -// @since 3.16.0. -func (s *server) PrepareCallHierarchy(ctx context.Context, params *CallHierarchyPrepareParams) (result []CallHierarchyItem, err error) { - s.logger.Debug("call " + MethodTextDocumentPrepareCallHierarchy) - defer s.logger.Debug("end "+MethodTextDocumentPrepareCallHierarchy, zap.Error(err)) +func (s *server) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (_ *WorkspaceDiagnosticReport, err error) { + s.logger.Debug("call " + MethodWorkspaceDiagnostic) + defer s.logger.Debug("end "+MethodWorkspaceDiagnostic, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodTextDocumentPrepareCallHierarchy, params, &result); err != nil { + var result *WorkspaceDiagnosticReport + if err := Call(ctx, s.Conn, MethodWorkspaceDiagnostic, params, &result); err != nil { return nil, err } return result, nil } -// IncomingCalls is the request is sent from the client to the server to resolve incoming calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. +// ExecuteCommand sends the request from the client to the server to trigger command execution on the server. // -// @since 3.16.0. -func (s *server) IncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) (result []CallHierarchyIncomingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyIncomingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyIncomingCalls, zap.Error(err)) +// In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the workspace using the +// request `workspace/applyEdit` which is sent from the server to the client. +func (s *server) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (result any, err error) { + s.logger.Debug("call " + MethodWorkspaceExecuteCommand) + defer s.logger.Debug("end "+MethodWorkspaceExecuteCommand, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodCallHierarchyIncomingCalls, params, &result); err != nil { + if err := Call(ctx, s.Conn, MethodWorkspaceExecuteCommand, params, &result); err != nil { return nil, err } return result, nil } -// OutgoingCalls is the request is sent from the client to the server to resolve outgoing calls for a given call hierarchy item. -// -// The request doesn’t define its own client and server capabilities. It is only issued if a server registers for the "textDocument/prepareCallHierarchy" request. -// -// @since 3.16.0. -func (s *server) OutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) (result []CallHierarchyOutgoingCall, err error) { - s.logger.Debug("call " + MethodCallHierarchyOutgoingCalls) - defer s.logger.Debug("end "+MethodCallHierarchyOutgoingCalls, zap.Error(err)) +// Symbols sends the request from the client to the server to list project-wide symbols matching the query string. +func (s *server) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (_ *WorkspaceSymbolResult, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbol) + defer s.logger.Debug("end "+MethodWorkspaceSymbol, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodCallHierarchyOutgoingCalls, params, &result); err != nil { + var result *WorkspaceSymbolResult + if err := Call(ctx, s.Conn, MethodWorkspaceSymbol, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFull is the request is sent from the client to the server to resolve semantic tokens for a given file. -// -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. -// -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// TextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. // -// @since 3.16.0. -func (s *server) SemanticTokensFull(ctx context.Context, params *SemanticTokensParams) (result *SemanticTokens, err error) { - s.logger.Debug("call " + MethodSemanticTokensFull) - defer s.logger.Debug("end "+MethodSemanticTokensFull, zap.Error(err)) +// @since 3.18.0 proposed +func (s *server) TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (_ *TextDocumentContentResult, err error) { + s.logger.Debug("call " + MethodWorkspaceTextDocumentContent) + defer s.logger.Debug("end "+MethodWorkspaceTextDocumentContent, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodSemanticTokensFull, params, &result); err != nil { + var result *TextDocumentContentResult + if err := Call(ctx, s.Conn, MethodWorkspaceTextDocumentContent, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensFullDelta is the request is sent from the client to the server to resolve semantic token delta for a given file. +// WillCreateFiles sends the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. // -// Semantic tokens are used to add additional color information to a file that depends on language specific symbol information. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are created. // -// A semantic token request usually produces a large result. The protocol therefore supports encoding tokens with numbers. +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable. // // @since 3.16.0. -func (s *server) SemanticTokensFullDelta(ctx context.Context, params *SemanticTokensDeltaParams) (result interface{}, err error) { - s.logger.Debug("call " + MethodSemanticTokensFullDelta) - defer s.logger.Debug("end "+MethodSemanticTokensFullDelta, zap.Error(err)) +func (s *server) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillCreateFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillCreateFiles, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodSemanticTokensFullDelta, params, &result); err != nil { + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillCreateFiles, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensRange is the request is sent from the client to the server to resolve semantic token delta for a given file. +// WillDeleteFiles sends the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. // -// When a user opens a file it can be beneficial to only compute the semantic tokens for the visible range (faster rendering of the tokens in the user interface). -// If a server can compute these tokens faster than for the whole file it can provide a handler for the "textDocument/semanticTokens/range" request to handle this case special. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. // -// Please note that if a client also announces that it will send the "textDocument/semanticTokens/range" server should implement this request as well to allow for flicker free scrolling and semantic coloring of a minimap. +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable. // // @since 3.16.0. -func (s *server) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (result *SemanticTokens, err error) { - s.logger.Debug("call " + MethodSemanticTokensRange) - defer s.logger.Debug("end "+MethodSemanticTokensRange, zap.Error(err)) +func (s *server) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillDeleteFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillDeleteFiles, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodSemanticTokensRange, params, &result); err != nil { + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillDeleteFiles, params, &result); err != nil { return nil, err } return result, nil } -// SemanticTokensRefresh is sent from the server to the client. Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens. -// -// As a result the client should ask the server to recompute the semantic tokens for these editors. -// This is useful if a server detects a project wide configuration change which requires a re-calculation of all semantic tokens. -// -// Note that the client still has the freedom to delay the re-calculation of the semantic tokens if for example an editor is currently not visible. -// -// @since 3.16.0. -func (s *server) SemanticTokensRefresh(ctx context.Context) (err error) { - s.logger.Debug("call " + MethodSemanticTokensRefresh) - defer s.logger.Debug("end "+MethodSemanticTokensRefresh, zap.Error(err)) - - return Call(ctx, s.Conn, MethodSemanticTokensRefresh, nil, nil) -} - -// LinkedEditingRange is the linked editing request is sent from the client to the server to return for a given position in a document the range of the symbol at the position and all ranges that have the same content. +// WillRenameFiles sends the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. // -// Optionally a word pattern can be returned to describe valid contents. +// The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. // -// A rename to one of the ranges can be applied to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language configuration is used. +// Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable. // // @since 3.16.0. -func (s *server) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (result *LinkedEditingRanges, err error) { - s.logger.Debug("call " + MethodLinkedEditingRange) - defer s.logger.Debug("end "+MethodLinkedEditingRange, zap.Error(err)) +func (s *server) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (_ *WorkspaceEdit, err error) { + s.logger.Debug("call " + MethodWorkspaceWillRenameFiles) + defer s.logger.Debug("end "+MethodWorkspaceWillRenameFiles, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodLinkedEditingRange, params, &result); err != nil { + var result *WorkspaceEdit + if err := Call(ctx, s.Conn, MethodWorkspaceWillRenameFiles, params, &result); err != nil { return nil, err } return result, nil } -// Moniker is the request is sent from the client to the server to get the symbol monikers for a given text document position. -// -// An array of Moniker types is returned as response to indicate possible monikers at the given location. -// -// If no monikers can be calculated, an empty array or null should be returned. -// -// @since 3.16.0. -func (s *server) Moniker(ctx context.Context, params *MonikerParams) (result []Moniker, err error) { - s.logger.Debug("call " + MethodMoniker) - defer s.logger.Debug("end "+MethodMoniker, zap.Error(err)) +func (s *server) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (_ *WorkspaceSymbol, err error) { + s.logger.Debug("call " + MethodWorkspaceSymbolResolve) + defer s.logger.Debug("end "+MethodWorkspaceSymbolResolve, zap.Error(err)) - if err := Call(ctx, s.Conn, MethodMoniker, params, &result); err != nil { + var result *WorkspaceSymbol + if err := Call(ctx, s.Conn, MethodWorkspaceSymbolResolve, params, &result); err != nil { return nil, err } @@ -1881,15 +1999,14 @@ func (s *server) Moniker(ctx context.Context, params *MonikerParams) (result []M } // Request sends a request from the client to the server that non-compliant with the Language Server Protocol specifications. -func (s *server) Request(ctx context.Context, method string, params interface{}) (interface{}, error) { +func (s *server) Request(ctx context.Context, method string, params any) (any, error) { s.logger.Debug("call " + method) defer s.logger.Debug("end " + method) - var result interface{} + var result any if err := Call(ctx, s.Conn, method, params, &result); err != nil { return nil, err } return result, nil } - diff --git a/server_interface.go b/server_interface.go new file mode 100644 index 00000000..fe6567c1 --- /dev/null +++ b/server_interface.go @@ -0,0 +1,691 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "context" + + "go.lsp.dev/jsonrpc2" +) + +const ( + MethodServerCancelRequest ServerMethod = "$/cancelRequest" // bidirect server notification + MethodServerProgress ServerMethod = "$/progress" // bidirect server notification + MethodSetTrace ServerMethod = "$/setTrace" // server notification + MethodExit ServerMethod = "exit" // server notification + MethodInitialized ServerMethod = "initialized" // server notification + MethodNotebookDocumentDidChange ServerMethod = "notebookDocument/didChange" // server notification + MethodNotebookDocumentDidClose ServerMethod = "notebookDocument/didClose" // server notification + MethodNotebookDocumentDidOpen ServerMethod = "notebookDocument/didOpen" // server notification + MethodNotebookDocumentDidSave ServerMethod = "notebookDocument/didSave" // server notification + MethodTextDocumentDidChange ServerMethod = "textDocument/didChange" // server notification + MethodTextDocumentDidClose ServerMethod = "textDocument/didClose" // server notification + MethodTextDocumentDidOpen ServerMethod = "textDocument/didOpen" // server notification + MethodTextDocumentDidSave ServerMethod = "textDocument/didSave" // server notification + MethodTextDocumentWillSave ServerMethod = "textDocument/willSave" // server notification + MethodWindowWorkDoneProgressCancel ServerMethod = "window/workDoneProgress/cancel" // server notification + MethodWorkspaceDidChangeConfiguration ServerMethod = "workspace/didChangeConfiguration" // server notification + MethodWorkspaceDidChangeWatchedFiles ServerMethod = "workspace/didChangeWatchedFiles" // server notification + MethodWorkspaceDidChangeWorkspaceFolders ServerMethod = "workspace/didChangeWorkspaceFolders" // server notification + MethodWorkspaceDidCreateFiles ServerMethod = "workspace/didCreateFiles" // server notification + MethodWorkspaceDidDeleteFiles ServerMethod = "workspace/didDeleteFiles" // server notification + MethodWorkspaceDidRenameFiles ServerMethod = "workspace/didRenameFiles" // server notification + MethodCallHierarchyIncomingCalls ServerMethod = "callHierarchy/incomingCalls" // server request + MethodCallHierarchyOutgoingCalls ServerMethod = "callHierarchy/outgoingCalls" // server request + MethodCodeActionResolve ServerMethod = "codeAction/resolve" // server request + MethodCodeLensResolve ServerMethod = "codeLens/resolve" // server request + MethodCompletionItemResolve ServerMethod = "completionItem/resolve" // server request + MethodDocumentLinkResolve ServerMethod = "documentLink/resolve" // server request + MethodInitialize ServerMethod = "initialize" // server request + MethodInlayHintResolve ServerMethod = "inlayHint/resolve" // server request + MethodShutdown ServerMethod = "shutdown" // server request + MethodTextDocumentCodeAction ServerMethod = "textDocument/codeAction" // server request + MethodTextDocumentCodeLens ServerMethod = "textDocument/codeLens" // server request + MethodTextDocumentColorPresentation ServerMethod = "textDocument/colorPresentation" // server request + MethodTextDocumentCompletion ServerMethod = "textDocument/completion" // server request + MethodTextDocumentDeclaration ServerMethod = "textDocument/declaration" // server request + MethodTextDocumentDefinition ServerMethod = "textDocument/definition" // server request + MethodTextDocumentDiagnostic ServerMethod = "textDocument/diagnostic" // server request + MethodTextDocumentDocumentColor ServerMethod = "textDocument/documentColor" // server request + MethodTextDocumentDocumentHighlight ServerMethod = "textDocument/documentHighlight" // server request + MethodTextDocumentDocumentLink ServerMethod = "textDocument/documentLink" // server request + MethodTextDocumentDocumentSymbol ServerMethod = "textDocument/documentSymbol" // server request + MethodTextDocumentFoldingRange ServerMethod = "textDocument/foldingRange" // server request + MethodTextDocumentFormatting ServerMethod = "textDocument/formatting" // server request + MethodTextDocumentHover ServerMethod = "textDocument/hover" // server request + MethodTextDocumentImplementation ServerMethod = "textDocument/implementation" // server request + MethodTextDocumentInlayHint ServerMethod = "textDocument/inlayHint" // server request + MethodTextDocumentInlineCompletion ServerMethod = "textDocument/inlineCompletion" // server request + MethodTextDocumentInlineValue ServerMethod = "textDocument/inlineValue" // server request + MethodTextDocumentLinkedEditingRange ServerMethod = "textDocument/linkedEditingRange" // server request + MethodTextDocumentMoniker ServerMethod = "textDocument/moniker" // server request + MethodTextDocumentOnTypeFormatting ServerMethod = "textDocument/onTypeFormatting" // server request + MethodTextDocumentPrepareCallHierarchy ServerMethod = "textDocument/prepareCallHierarchy" // server request + MethodTextDocumentPrepareRename ServerMethod = "textDocument/prepareRename" // server request + MethodTextDocumentPrepareTypeHierarchy ServerMethod = "textDocument/prepareTypeHierarchy" // server request + MethodTextDocumentRangeFormatting ServerMethod = "textDocument/rangeFormatting" // server request + MethodTextDocumentRangesFormatting ServerMethod = "textDocument/rangesFormatting" // server request + MethodTextDocumentReferences ServerMethod = "textDocument/references" // server request + MethodTextDocumentRename ServerMethod = "textDocument/rename" // server request + MethodTextDocumentSelectionRange ServerMethod = "textDocument/selectionRange" // server request + MethodTextDocumentSemanticTokensFull ServerMethod = "textDocument/semanticTokens/full" // server request + MethodTextDocumentSemanticTokensFullDelta ServerMethod = "textDocument/semanticTokens/full/delta" // server request + MethodTextDocumentSemanticTokensRange ServerMethod = "textDocument/semanticTokens/range" // server request + MethodTextDocumentSignatureHelp ServerMethod = "textDocument/signatureHelp" // server request + MethodTextDocumentTypeDefinition ServerMethod = "textDocument/typeDefinition" // server request + MethodTextDocumentWillSaveWaitUntil ServerMethod = "textDocument/willSaveWaitUntil" // server request + MethodTypeHierarchySubtypes ServerMethod = "typeHierarchy/subtypes" // server request + MethodTypeHierarchySupertypes ServerMethod = "typeHierarchy/supertypes" // server request + MethodWorkspaceDiagnostic ServerMethod = "workspace/diagnostic" // server request + MethodWorkspaceExecuteCommand ServerMethod = "workspace/executeCommand" // server request + MethodWorkspaceSymbol ServerMethod = "workspace/symbol" // server request + MethodWorkspaceTextDocumentContent ServerMethod = "workspace/textDocumentContent" // server request + MethodWorkspaceWillCreateFiles ServerMethod = "workspace/willCreateFiles" // server request + MethodWorkspaceWillDeleteFiles ServerMethod = "workspace/willDeleteFiles" // server request + MethodWorkspaceWillRenameFiles ServerMethod = "workspace/willRenameFiles" // server request + MethodWorkspaceSymbolResolve ServerMethod = "workspaceSymbol/resolve" // server request +) + +type Server interface { + Cancel(ctx context.Context, params *CancelParams) error + + Progress(ctx context.Context, params *ProgressParams) error + + SetTrace(ctx context.Context, params *SetTraceParams) error + + // Exit the exit event is sent from the client to the server to ask the server to exit its process. + Exit(ctx context.Context) error + + // Initialized the initialized notification is sent from the client to the server after the client is fully initialized and the server is allowed to send requests from the server to the client. + Initialized(ctx context.Context, params *InitializedParams) error + + DidChangeNotebookDocument(ctx context.Context, params *DidChangeNotebookDocumentParams) error + + // DidCloseNotebookDocument a notification sent when a notebook closes. + // + // @since 3.17.0 + DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) error + + // DidOpenNotebookDocument a notification sent when a notebook opens. + // + // @since 3.17.0 + DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) error + + // DidSaveNotebookDocument a notification sent when a notebook document is saved. + // + // @since 3.17.0 + DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) error + + // DidChangeTextDocument the document change notification is sent from the client to the server to signal changes to a text document. + DidChangeTextDocument(ctx context.Context, params *DidChangeTextDocumentParams) error + + // DidCloseTextDocument the document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notification to be sent. + DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) error + + // DidOpenTextDocument the document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one. + DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) error + + // DidSaveTextDocument the document save notification is sent from the client to the server when the document got saved in the client. + DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) error + + // WillSaveTextDocument a document will save notification is sent from the client to the server before the document is actually saved. + WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) error + + // WorkDoneProgressCancel the `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress initiated on the server side. + WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error + + // DidChangeConfiguration the configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains the changed configuration as defined by the language client. + DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error + + // DidChangeWatchedFiles the watched files notification is sent from the client to the server when the client detects changes + // to file watched by the language client. + DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error + + // DidChangeWorkspaceFolders the `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace folder configuration changes. + DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error + + // DidCreateFiles the did create files notification is sent from the client to the server when files were created from + // within the client. + // + // @since 3.16.0 + DidCreateFiles(ctx context.Context, params *CreateFilesParams) error + + // DidDeleteFiles the will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. + // + // @since 3.16.0 + DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error + + // DidRenameFiles the did rename files notification is sent from the client to the server when files were renamed from + // within the client. + // + // @since 3.16.0 + DidRenameFiles(ctx context.Context, params *RenameFilesParams) error + // CallHierarchyIncomingCalls a request to resolve the incoming calls for a given `CallHierarchyItem`. + // + // @since 3.16.0 + CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) ([]*CallHierarchyIncomingCall, error) + + // CallHierarchyOutgoingCalls a request to resolve the outgoing calls for a given `CallHierarchyItem`. + // + // @since 3.16.0 + CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) + + // CodeActionResolve request to resolve additional information for a given code action.The request's parameter is of type + // CodeAction the response is of type CodeAction or a Thenable that resolves to such. + CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) + + // CodeLensResolve a request to resolve a command for a given code lens. + CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) + + // CompletionResolve request to resolve additional information for a given completion item.The request's parameter is of type CompletionItem the response is of type CompletionItem or a Thenable that resolves to such. + CompletionResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) + + // DocumentLinkResolve request to resolve additional information for a given document link. The request's parameter is of type DocumentLink the response is of type DocumentLink or a Thenable that resolves to such. + DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) + + // Initialize the initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type InitializeParams the response if of type InitializeResult of a Thenable that resolves to such. + Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) + + // InlayHintResolve a request to resolve additional properties for an inlay hint. The request's parameter is of type InlayHint, the response is of type InlayHint or a Thenable that resolves to such. + // + // @since 3.17.0 + InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) + + // Shutdown a shutdown request is sent from the client to the server. It is sent once when the client decides to + // shutdown the server. The only notification that is sent after a shutdown request is the exit event. + Shutdown(ctx context.Context) error + + // CodeAction a request to provide commands for the given text document and range. + CodeAction(ctx context.Context, params *CodeActionParams) (*CodeActionRequestResult, error) + + // CodeLens a request to provide code lens for the given text document. + CodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) + + // ColorPresentation a request to list all presentation for a color. The request's parameter is of type ColorPresentationParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. + ColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) + + // Completion request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, + // `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. + Completion(ctx context.Context, params *CompletionParams) (*CompletionResult, error) + + // Declaration a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a + // typed array of DeclarationLink or a Thenable that resolves to such. + Declaration(ctx context.Context, params *DeclarationParams) (*DeclarationResult, error) + + // Definition a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed + // array of DefinitionLink or a Thenable that resolves to such. + Definition(ctx context.Context, params *DefinitionParams) (*DefinitionResult, error) + + // DocumentDiagnostic the document diagnostic request definition. + // + // @since 3.17.0 + DocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) + + // DocumentColor a request to list all color symbols found in a given text document. The request's parameter is of type DocumentColorParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such. + DocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) + + // DocumentHighlight request to resolve a DocumentHighlight for a given text document position. The request's parameter is of type TextDocumentPosition the request response is an array of type DocumentHighlight or a Thenable that resolves to such. + DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) + + // DocumentLink a request to provide document links. + DocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) + + // DocumentSymbol a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that + // resolves to such. + DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*DocumentSymbolResult, error) + + // FoldingRange a request to provide folding ranges in a document. The request's parameter is of type FoldingRangeParams, the response is of type FoldingRangeList or a Thenable that resolves to such. + FoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) + + // DocumentFormatting a request to format a whole document. + DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) + + // Hover request to request hover information at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type Hover or a Thenable that resolves to such. + Hover(ctx context.Context, params *HoverParams) (*Hover, error) + + // Implementation a request to resolve the implementation locations of a symbol at a given text document position. The + // request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. + Implementation(ctx context.Context, params *ImplementationParams) (*ImplementationResult, error) + + // InlayHint a request to provide inlay hints in a document. The request's parameter is of type InlayHintsParams, + // the response is of type InlayHint InlayHint[] or a Thenable that resolves to such. + // + // @since 3.17.0 + InlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) + + // InlineCompletion a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + InlineCompletion(ctx context.Context, params *InlineCompletionParams) (*InlineCompletionResult, error) + + // InlineValue a request to provide inline values in a document. The request's parameter is of type InlineValueParams, the response is of type InlineValue InlineValue[] or a Thenable that resolves to such. + // + // @since 3.17.0 + InlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) + + // LinkedEditingRange a request to provide ranges that can be edited together. + // + // @since 3.16.0 + LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) + + // Moniker a request to get the moniker of a symbol at a given text document position. The request parameter is + // of type TextDocumentPositionParams. The response is of type Moniker Moniker[] or `null`. + Moniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) + + // DocumentOnTypeFormatting a request to format a document on type. + DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) + + // CallHierarchyPrepare a request to result a `CallHierarchyItem` in a document at a given position. Can be used as an input + // to an incoming or outgoing call hierarchy. + // + // @since 3.16.0 + CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) + + // PrepareRename a request to test and perform the setup necessary for a rename. 3.16 - support for default behavior. + // + // @since 3.16 - support for default behavior + PrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) + + // TypeHierarchyPrepare a request to result a `TypeHierarchyItem` in a document at a given position. Can be used as an input + // to a subtypes or supertypes type hierarchy. + // + // @since 3.17.0 + TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) + + // DocumentRangeFormatting a request to format a range in a document. + DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) + + // DocumentRangesFormatting a request to format ranges in a document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) + + // References a request to resolve project-wide references for the symbol denoted by the given text document position. The request's parameter is of type ReferenceParams the response is of type Location Location[] or a Thenable that resolves to such. + References(ctx context.Context, params *ReferenceParams) ([]*Location, error) + + // Rename a request to rename a symbol. + Rename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) + + // SelectionRange a request to provide selection ranges in a document. The request's parameter is of type SelectionRangeParams, the response is of type SelectionRange SelectionRange[] or a Thenable that resolves to such. + SelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) + + // SemanticTokens. + // + // @since 3.16.0 + SemanticTokens(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) + + // SemanticTokensDelta. + // + // @since 3.16.0 + SemanticTokensDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*SemanticTokensDeltaResult, error) + + // SemanticTokensRange. + // + // @since 3.16.0 + SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) + + SignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) + + // TypeDefinition a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. + TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TypeDefinitionResult, error) + + // WillSaveTextDocumentWaitUntil a document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before + // it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable. + WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) + + // TypeHierarchySubtypes a request to resolve the subtypes for a given `TypeHierarchyItem`. + // + // @since 3.17.0 + TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) + + // TypeHierarchySupertypes a request to resolve the supertypes for a given `TypeHierarchyItem`. + // + // @since 3.17.0 + TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) + + // WorkspaceDiagnostic the workspace diagnostic request definition. + // + // @since 3.17.0 + WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) + + // ExecuteCommand a request send from the client to the server to execute a command. The request might return a workspace edit which the client will apply to the workspace. + ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) + + // WorkspaceSymbol a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. + // The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + // + // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. + WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) + + // TextDocumentContent the `workspace/textDocumentContent` request is sent from the client to the server to request the content of a text document. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) + + // WillCreateFiles the will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a `WorkspaceEdit` which will be applied to workspace before the files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file to be created. + // + // @since 3.16.0 + WillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) + + // WillDeleteFiles the did delete files notification is sent from the client to the server when files were deleted from + // within the client. + // + // @since 3.16.0 + WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) + + // WillRenameFiles the will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. + // + // @since 3.16.0 + WillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) + + // WorkspaceSymbolResolve a request to resolve the range inside the workspace symbol's location. + // + // @since 3.17.0 + WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (*WorkspaceSymbol, error) +} + +// UnimplementedServer should be embedded to have forward compatible implementations. +type UnimplementedServer struct{} + +var _ Server = UnimplementedServer{} + +func (UnimplementedServer) Cancel(ctx context.Context, params *CancelParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Progress(ctx context.Context, params *ProgressParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) SetTrace(ctx context.Context, params *SetTraceParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Exit(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Initialized(ctx context.Context, params *InitializedParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidChangeNotebookDocument(ctx context.Context, params *DidChangeNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidCloseNotebookDocument(ctx context.Context, params *DidCloseNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidOpenNotebookDocument(ctx context.Context, params *DidOpenNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidSaveNotebookDocument(ctx context.Context, params *DidSaveNotebookDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidChangeTextDocument(ctx context.Context, params *DidChangeTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidCloseTextDocument(ctx context.Context, params *DidCloseTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidOpenTextDocument(ctx context.Context, params *DidOpenTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidSaveTextDocument(ctx context.Context, params *DidSaveTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WillSaveTextDocument(ctx context.Context, params *WillSaveTextDocumentParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkDoneProgressCancel(ctx context.Context, params *WorkDoneProgressCancelParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidChangeConfiguration(ctx context.Context, params *DidChangeConfigurationParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidChangeWatchedFiles(ctx context.Context, params *DidChangeWatchedFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidChangeWorkspaceFolders(ctx context.Context, params *DidChangeWorkspaceFoldersParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidCreateFiles(ctx context.Context, params *CreateFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidDeleteFiles(ctx context.Context, params *DeleteFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DidRenameFiles(ctx context.Context, params *RenameFilesParams) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) ([]*CallHierarchyIncomingCall, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CallHierarchyOutgoingCalls(ctx context.Context, params *CallHierarchyOutgoingCallsParams) ([]*CallHierarchyOutgoingCall, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CodeActionResolve(ctx context.Context, params *CodeAction) (*CodeAction, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CodeLensResolve(ctx context.Context, params *CodeLens) (*CodeLens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CompletionResolve(ctx context.Context, params *CompletionItem) (*CompletionItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentLinkResolve(ctx context.Context, params *DocumentLink) (*DocumentLink, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Initialize(ctx context.Context, params *InitializeParams) (*InitializeResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) InlayHintResolve(ctx context.Context, params *InlayHint) (*InlayHint, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Shutdown(ctx context.Context) error { + return jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CodeAction(ctx context.Context, params *CodeActionParams) (*CodeActionRequestResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CodeLens(ctx context.Context, params *CodeLensParams) ([]*CodeLens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) ColorPresentation(ctx context.Context, params *ColorPresentationParams) ([]*ColorPresentation, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Completion(ctx context.Context, params *CompletionParams) (*CompletionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Declaration(ctx context.Context, params *DeclarationParams) (*DeclarationResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Definition(ctx context.Context, params *DefinitionParams) (*DefinitionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentDiagnostic(ctx context.Context, params *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentColor(ctx context.Context, params *DocumentColorParams) ([]*ColorInformation, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentHighlight(ctx context.Context, params *DocumentHighlightParams) ([]*DocumentHighlight, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentLink(ctx context.Context, params *DocumentLinkParams) ([]*DocumentLink, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentSymbol(ctx context.Context, params *DocumentSymbolParams) (*DocumentSymbolResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) FoldingRange(ctx context.Context, params *FoldingRangeParams) ([]*FoldingRange, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentFormatting(ctx context.Context, params *DocumentFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Hover(ctx context.Context, params *HoverParams) (*Hover, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Implementation(ctx context.Context, params *ImplementationParams) (*ImplementationResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) InlayHint(ctx context.Context, params *InlayHintParams) ([]*InlayHint, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) InlineCompletion(ctx context.Context, params *InlineCompletionParams) (*InlineCompletionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) InlineValue(ctx context.Context, params *InlineValueParams) ([]*InlineValue, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Moniker(ctx context.Context, params *MonikerParams) ([]*Moniker, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentOnTypeFormatting(ctx context.Context, params *DocumentOnTypeFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) CallHierarchyPrepare(ctx context.Context, params *CallHierarchyPrepareParams) ([]*CallHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) PrepareRename(ctx context.Context, params *PrepareRenameParams) (*PrepareRenameResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TypeHierarchyPrepare(ctx context.Context, params *TypeHierarchyPrepareParams) ([]*TypeHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentRangeFormatting(ctx context.Context, params *DocumentRangeFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) DocumentRangesFormatting(ctx context.Context, params *DocumentRangesFormattingParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) References(ctx context.Context, params *ReferenceParams) ([]*Location, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) Rename(ctx context.Context, params *RenameParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) SelectionRange(ctx context.Context, params *SelectionRangeParams) ([]*SelectionRange, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) SemanticTokens(ctx context.Context, params *SemanticTokensParams) (*SemanticTokens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) SemanticTokensDelta(ctx context.Context, params *SemanticTokensDeltaParams) (*SemanticTokensDeltaResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) SemanticTokensRange(ctx context.Context, params *SemanticTokensRangeParams) (*SemanticTokens, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) SignatureHelp(ctx context.Context, params *SignatureHelpParams) (*SignatureHelp, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TypeDefinition(ctx context.Context, params *TypeDefinitionParams) (*TypeDefinitionResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WillSaveTextDocumentWaitUntil(ctx context.Context, params *WillSaveTextDocumentParams) ([]*TextEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TypeHierarchySubtypes(ctx context.Context, params *TypeHierarchySubtypesParams) ([]*TypeHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TypeHierarchySupertypes(ctx context.Context, params *TypeHierarchySupertypesParams) ([]*TypeHierarchyItem, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceDiagnostic(ctx context.Context, params *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) ExecuteCommand(ctx context.Context, params *ExecuteCommandParams) (any, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceSymbol(ctx context.Context, params *WorkspaceSymbolParams) (*WorkspaceSymbolResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) TextDocumentContent(ctx context.Context, params *TextDocumentContentParams) (*TextDocumentContentResult, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WillCreateFiles(ctx context.Context, params *CreateFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WillDeleteFiles(ctx context.Context, params *DeleteFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WillRenameFiles(ctx context.Context, params *RenameFilesParams) (*WorkspaceEdit, error) { + return nil, jsonrpc2.ErrInternal +} + +func (UnimplementedServer) WorkspaceSymbolResolve(ctx context.Context, params *WorkspaceSymbol) (*WorkspaceSymbol, error) { + return nil, jsonrpc2.ErrInternal +} diff --git a/text.go b/text.go deleted file mode 100644 index a67d5c2a..00000000 --- a/text.go +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "strconv" -) - -// DidOpenTextDocumentParams params of DidOpenTextDocument notification. -type DidOpenTextDocumentParams struct { - // TextDocument is the document that was opened. - TextDocument TextDocumentItem `json:"textDocument"` -} - -// DidChangeTextDocumentParams params of DidChangeTextDocument notification. -type DidChangeTextDocumentParams struct { - // TextDocument is the document that did change. The version number points - // to the version after all provided content changes have - // been applied. - TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` - - // ContentChanges is the actual content changes. The content changes describe single state changes - // to the document. So if there are two content changes c1 and c2 for a document - // in state S then c1 move the document to S' and c2 to S''. - ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` // []TextDocumentContentChangeEvent | text -} - -// TextDocumentSaveReason represents reasons why a text document is saved. -type TextDocumentSaveReason float64 - -const ( - // TextDocumentSaveReasonManual is the manually triggered, e.g. by the user pressing save, by starting debugging, - // or by an API call. - TextDocumentSaveReasonManual TextDocumentSaveReason = 1 - - // TextDocumentSaveReasonAfterDelay is the automatic after a delay. - TextDocumentSaveReasonAfterDelay TextDocumentSaveReason = 2 - - // TextDocumentSaveReasonFocusOut when the editor lost focus. - TextDocumentSaveReasonFocusOut TextDocumentSaveReason = 3 -) - -// String implements fmt.Stringer. -func (t TextDocumentSaveReason) String() string { - switch t { - case TextDocumentSaveReasonManual: - return "Manual" - case TextDocumentSaveReasonAfterDelay: - return "AfterDelay" - case TextDocumentSaveReasonFocusOut: - return "FocusOut" - default: - return strconv.FormatFloat(float64(t), 'f', -10, 64) - } -} - -// TextDocumentChangeRegistrationOptions describe options to be used when registering for text document change events. -type TextDocumentChangeRegistrationOptions struct { - TextDocumentRegistrationOptions - - // SyncKind how documents are synced to the server. See TextDocumentSyncKind.Full - // and TextDocumentSyncKind.Incremental. - SyncKind TextDocumentSyncKind `json:"syncKind"` -} - -// WillSaveTextDocumentParams is the parameters send in a will save text document notification. -type WillSaveTextDocumentParams struct { - // TextDocument is the document that will be saved. - TextDocument TextDocumentIdentifier `json:"textDocument"` - - // Reason is the 'TextDocumentSaveReason'. - Reason TextDocumentSaveReason `json:"reason,omitempty"` -} - -// DidSaveTextDocumentParams params of DidSaveTextDocument notification. -type DidSaveTextDocumentParams struct { - // Text optional the content when saved. Depends on the includeText value - // when the save notification was requested. - Text string `json:"text,omitempty"` - - // TextDocument is the document that was saved. - TextDocument TextDocumentIdentifier `json:"textDocument"` -} - -// TextDocumentContentChangeEvent an event describing a change to a text document. If range and rangeLength are omitted -// the new text is considered to be the full content of the document. -type TextDocumentContentChangeEvent struct { - // Range is the range of the document that changed. - Range *Range `json:"range,omitempty"` - - // RangeLength is the length of the range that got replaced. - RangeLength uint32 `json:"rangeLength,omitempty"` - - // Text is the new text of the document. - Text string `json:"text"` -} - -// TextDocumentSaveRegistrationOptions TextDocumentSave Registration options. -type TextDocumentSaveRegistrationOptions struct { - TextDocumentRegistrationOptions - - // IncludeText is the client is supposed to include the content on save. - IncludeText bool `json:"includeText,omitempty"` -} - -// DidCloseTextDocumentParams params of DidCloseTextDocument notification. -type DidCloseTextDocumentParams struct { - // TextDocument the document that was closed. - TextDocument TextDocumentIdentifier `json:"textDocument"` -} diff --git a/text_test.go b/text_test.go deleted file mode 100644 index abf88029..00000000 --- a/text_test.go +++ /dev/null @@ -1,930 +0,0 @@ -// SPDX-FileCopyrightText: 2020 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/segmentio/encoding/json" - - "go.lsp.dev/uri" -) - -func TestDidOpenTextDocumentParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"textDocument":{"uri":"file:///path/to/basic.go","languageId":"go","version":10,"text":"Go Language"}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/basic_gen.go","languageId":"cpp","version":10,"text":"C++ Language"}}` - ) - wantType := DidOpenTextDocumentParams{ - TextDocument: TextDocumentItem{ - URI: uri.File("/path/to/basic.go"), - LanguageID: GoLanguage, - Version: int32(10), - Text: "Go Language", - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DidOpenTextDocumentParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DidOpenTextDocumentParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DidOpenTextDocumentParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDidChangeTextDocumentParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"textDocument":{"uri":"file:///path/to/test.go","version":10},"contentChanges":[{"range":{"start":{"line":25,"character":1},"end":{"line":25,"character":3}},"rangeLength":2,"text":"testText"}]}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/test.go","version":10},"contentChanges":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":4}},"rangeLength":3,"text":"invalidText"}]}` - ) - wantType := DidChangeTextDocumentParams{ - TextDocument: VersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Version: int32(10), - }, - ContentChanges: []TextDocumentContentChangeEvent{ - { - Range: &Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 25, - Character: 3, - }, - }, - RangeLength: 2, - Text: "testText", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DidChangeTextDocumentParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DidChangeTextDocumentParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DidChangeTextDocumentParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentSaveReason_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k TextDocumentSaveReason - want string - }{ - { - name: "Manual", - k: TextDocumentSaveReasonManual, - want: "Manual", - }, - { - name: "AfterDelay", - k: TextDocumentSaveReasonAfterDelay, - want: "AfterDelay", - }, - { - name: "FocusOut", - k: TextDocumentSaveReasonFocusOut, - want: "FocusOut", - }, - { - name: "Unknown", - k: TextDocumentSaveReason(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("TextDocumentSaveReason.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestTextDocumentContentChangeEvent(t *testing.T) { - t.Parallel() - - const ( - want = `{"range":{"start":{"line":25,"character":1},"end":{"line":25,"character":3}},"rangeLength":2,"text":"testText"}` - wantInvalid = `{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":4}},"rangeLength":3,"text":"invalidText"}` - wantReplaceAll = `{"text":"replace all"}` - ) - wantType := TextDocumentContentChangeEvent{ - Range: &Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 25, - Character: 3, - }, - }, - RangeLength: 2, - Text: "testText", - } - wantReplaceAllType := TextDocumentContentChangeEvent{ - Text: "replace all", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field TextDocumentContentChangeEvent - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - { - name: "ReplaceAll", - field: wantReplaceAllType, - want: wantReplaceAll, - wantMarshalErr: false, - wantErr: false, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want TextDocumentContentChangeEvent - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentContentChangeEvent - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentChangeRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"}],"syncKind":2}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"}],"syncKind":1}` - ) - wantType := TextDocumentChangeRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - }, - }, - SyncKind: 2, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field TextDocumentChangeRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want TextDocumentChangeRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentChangeRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWillSaveTextDocumentParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"textDocument":{"uri":"file:///path/to/test.go"},"reason":3}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/test.go"}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/invalid.go"},"reason":1}` - ) - wantType := WillSaveTextDocumentParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - Reason: TextDocumentSaveReasonFocusOut, - } - wantTypeNilAll := WillSaveTextDocumentParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WillSaveTextDocumentParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WillSaveTextDocumentParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WillSaveTextDocumentParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDidSaveTextDocumentParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"text":"testText","textDocument":{"uri":"file:///path/to/test.go"}}` - wantNilAll = `{"textDocument":{"uri":"file:///path/to/test.go"}}` - wantInvalid = `{"text":"invalidText","textDocument":{"uri":"file:///path/to/invalid.go"}}` - ) - wantType := DidSaveTextDocumentParams{ - Text: "testText", - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - } - wantTypeNilAll := DidSaveTextDocumentParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DidSaveTextDocumentParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DidSaveTextDocumentParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DidSaveTextDocumentParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestTextDocumentSaveRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"}],"includeText":true}` - wantNilAll = `{"documentSelector":[{"language":"go","scheme":"file","pattern":"*.go"}]}` - wantInvalid = `{"documentSelector":[{"language":"typescript","scheme":"file","pattern":"*.{ts,js}"}],"includeText":false}` - ) - wantType := TextDocumentSaveRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - }, - }, - IncludeText: true, - } - wantTypeNilAll := TextDocumentSaveRegistrationOptions{ - TextDocumentRegistrationOptions: TextDocumentRegistrationOptions{ - DocumentSelector: DocumentSelector{ - { - Language: "go", - Scheme: "file", - Pattern: "*.go", - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field TextDocumentSaveRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want TextDocumentSaveRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got TextDocumentSaveRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDidCloseTextDocumentParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"textDocument":{"uri":"file:///path/to/test.go"}}` - wantInvalid = `{"textDocument":{"uri":"file:///path/to/invalid.go"}}` - ) - wantType := DidCloseTextDocumentParams{ - TextDocument: TextDocumentIdentifier{ - URI: uri.File("/path/to/test.go"), - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DidCloseTextDocumentParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DidCloseTextDocumentParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DidCloseTextDocumentParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} diff --git a/tools/protocol-gen/generator/generator.go b/tools/protocol-gen/generator/generator.go index 39a5669b..f0a1193e 100644 --- a/tools/protocol-gen/generator/generator.go +++ b/tools/protocol-gen/generator/generator.go @@ -109,7 +109,8 @@ func (gen *Generator) writeTo(pp []Printer) (err error) { if err != nil { return err } - root := filepath.Join(filepath.Dir(filepath.Dir(cwd)), "protocol") + root := filepath.Dir(filepath.Dir(cwd)) + fmt.Printf("filename: %s\n", filepath.Join(root, filename)) f, err = os.Create(filepath.Join(root, filename)) if err != nil { return fmt.Errorf("unable to open %s file: %w", filename, err) @@ -207,7 +208,8 @@ func (p *printer) WriteTo() (err error) { if err != nil { return err } - root := filepath.Join(filepath.Dir(filepath.Dir(cwd)), "protocol") + root := filepath.Dir(filepath.Dir(cwd)) + fmt.Printf("filename: %s\n", filepath.Join(root, p.filename)) f, err := os.Create(filepath.Join(root, p.filename)) if err != nil { return fmt.Errorf("unable to open %s file: %w", p.filename, err) diff --git a/tools/protocol-gen/generator/typealiases.go b/tools/protocol-gen/generator/typealiases.go index db3de520..ebc718fb 100644 --- a/tools/protocol-gen/generator/typealiases.go +++ b/tools/protocol-gen/generator/typealiases.go @@ -12,13 +12,13 @@ import ( ) var typeAliasNames = [...]string{ - "typealias", + "type_alias", } // TypeAliases generates TypeAliases Go type from the metaModel schema definition. func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { // Init typeAliases printers - g := NewPrinter("typealias") + g := NewPrinter("type_alias") gen.typeAliases = append(gen.typeAliases, g) for _, alias := range typeAliases { @@ -79,7 +79,7 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { case *protocol.OrType: g.PP(`type `, aliasName, ` struct {`) - g.PP(` Value any `, "`json:\"value\"`") + g.PP(` value any`) g.PP(`}`) } @@ -132,7 +132,7 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { } g.PP(`](val T) `, aliasName, ` {`) g.PP(` return `, aliasName, `{`) - g.PP(` Value: val,`) + g.PP(` value: val,`) g.PP(` }`) g.PP(`}`, "\n") } @@ -140,7 +140,7 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { switch a := alias.Type.(type) { case *protocol.OrType: g.PP(`func (t `, aliasName, `) MarshalJSON() ([]byte, error) {`) - g.PP(` switch val := t.Value.(type) {`) + g.PP(` switch val := t.value.(type) {`) for i, item := range a.Items { switch item := item.(type) { case protocol.BaseType: @@ -173,7 +173,7 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { case *protocol.OrType: g.PP(`func (t *`, aliasName, `) UnmarshalJSON(val []byte) error {`) g.PP(`if string(val) == "null" {`) - g.PP(` t.Value = nil`) + g.PP(` t.value = nil`) g.PP(` return nil`) g.PP(`}`) for i, item := range a.Items { @@ -195,7 +195,7 @@ func (gen *Generator) TypeAliases(typeAliases []*protocol.TypeAlias) error { panic(fmt.Sprintf("typealias.OrType: %#v\n", item)) } g.PP(`if err := unmarshal(val, &h`, i, `); err == nil {`) - g.PP(` t.Value = h`, i) + g.PP(` t.value = h`, i) g.PP(` return nil`) g.PP(`}`) } diff --git a/tools/protocol-gen/main.go b/tools/protocol-gen/main.go index 14487481..63b883c9 100644 --- a/tools/protocol-gen/main.go +++ b/tools/protocol-gen/main.go @@ -96,7 +96,6 @@ func run() error { func fetchLSPSchema(ctx context.Context) ([]byte, error) { uri := fmt.Sprintf(LSPSchemaURI, schemaVersion) - // uri := "https://raw.githubusercontent.com/microsoft/language-server-protocol/gh-pages/_specifications/lsp/3.18/metaModel/metaModel.json" req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, http.NoBody) if err != nil { return nil, fmt.Errorf("failed to create http request: %w", err) diff --git a/type_alias.go b/type_alias.go new file mode 100644 index 00000000..80915267 --- /dev/null +++ b/type_alias.go @@ -0,0 +1,602 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import "fmt" + +type RegularExpressionEngineKind string + +// Pattern the glob pattern to watch relative to the base path. Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none - `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) +// +// @since 3.17.0 +type Pattern string + +// NotebookDocumentFilter a notebook document filter denotes a notebook document by different properties. The properties will be match against the notebook's URI (same as with documents) +// +// @since 3.17.0 +type NotebookDocumentFilter struct { + value any +} + +func NewNotebookDocumentFilter[T NotebookDocumentFilterNotebookType | NotebookDocumentFilterScheme | NotebookDocumentFilterPattern](val T) NotebookDocumentFilter { + return NotebookDocumentFilter{ + value: val, + } +} + +func (t NotebookDocumentFilter) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case NotebookDocumentFilterNotebookType: + return marshal(val) + case NotebookDocumentFilterScheme: + return marshal(val) + case NotebookDocumentFilterPattern: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *NotebookDocumentFilter) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 NotebookDocumentFilterNotebookType + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 NotebookDocumentFilterScheme + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 NotebookDocumentFilterPattern + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// TextDocumentFilter a document filter denotes a document by different properties like the TextDocument.languageId language, the Uri.scheme scheme of its resource, or a glob-pattern that is applied to the TextDocument.fileName path. Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) // // Example: A language filter that applies to typescript files on disk: `{ language: 'typescript', scheme: 'file' }` // // Example: A language filter that applies to all package.json paths: `{ language: 'json', pattern: '**package.json' }` +// +// @since 3.17.0 +type TextDocumentFilter struct { + value any +} + +func NewTextDocumentFilter[T TextDocumentFilterLanguage | TextDocumentFilterScheme | TextDocumentFilterPattern](val T) TextDocumentFilter { + return TextDocumentFilter{ + value: val, + } +} + +func (t TextDocumentFilter) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case TextDocumentFilterLanguage: + return marshal(val) + case TextDocumentFilterScheme: + return marshal(val) + case TextDocumentFilterPattern: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *TextDocumentFilter) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 TextDocumentFilterLanguage + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 TextDocumentFilterScheme + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 TextDocumentFilterPattern + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// GlobPattern the glob pattern. Either a string pattern or a relative pattern. +// +// @since 3.17.0 +type GlobPattern struct { + value any +} + +func NewGlobPattern[T Pattern | RelativePattern](val T) GlobPattern { + return GlobPattern{ + value: val, + } +} + +func (t GlobPattern) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Pattern: + return marshal(val) + case RelativePattern: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *GlobPattern) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Pattern + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 RelativePattern + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DocumentFilter a document filter describes a top level text document or a notebook cell document. 3.17.0 - proposed +// support for NotebookCellTextDocumentFilter. +// +// @since 3.17.0 - proposed support for NotebookCellTextDocumentFilter. +type DocumentFilter struct { + value any +} + +func NewDocumentFilter[T TextDocumentFilter | NotebookCellTextDocumentFilter](val T) DocumentFilter { + return DocumentFilter{ + value: val, + } +} + +func (t DocumentFilter) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case TextDocumentFilter: + return marshal(val) + case NotebookCellTextDocumentFilter: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *DocumentFilter) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 TextDocumentFilter + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 NotebookCellTextDocumentFilter + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// MarkedString markedString can be used to render human readable text. It is either a markdown string or a code-block that provides a language and a code snippet. The language identifier is semantically equal to the +// optional language identifier in fenced code blocks in GitHub issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting The pair of a language and a value is an equivalent to markdown: ```${language} ${value} ``` Note that markdown strings will be sanitized - that means html will be escaped. // // Deprecated: use MarkupContent instead. +type MarkedString struct { + value any +} + +func NewMarkedString[T string | MarkedStringWithLanguage](val T) MarkedString { + return MarkedString{ + value: val, + } +} + +func (t MarkedString) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case MarkedStringWithLanguage: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *MarkedString) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 MarkedStringWithLanguage + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// TextDocumentContentChangeEvent an event describing a change to a text document. If only a text is provided it is considered to be the full content of the document. +type TextDocumentContentChangeEvent struct { + value any +} + +func NewTextDocumentContentChangeEvent[T TextDocumentContentChangePartial | TextDocumentContentChangeWholeDocument](val T) TextDocumentContentChangeEvent { + return TextDocumentContentChangeEvent{ + value: val, + } +} + +func (t TextDocumentContentChangeEvent) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case TextDocumentContentChangePartial: + return marshal(val) + case TextDocumentContentChangeWholeDocument: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *TextDocumentContentChangeEvent) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 TextDocumentContentChangePartial + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 TextDocumentContentChangeWholeDocument + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// WorkspaceDocumentDiagnosticReport a workspace diagnostic document report. +// +// @since 3.17.0 +type WorkspaceDocumentDiagnosticReport struct { + value any +} + +func NewWorkspaceDocumentDiagnosticReport[T WorkspaceFullDocumentDiagnosticReport | WorkspaceUnchangedDocumentDiagnosticReport](val T) WorkspaceDocumentDiagnosticReport { + return WorkspaceDocumentDiagnosticReport{ + value: val, + } +} + +func (t WorkspaceDocumentDiagnosticReport) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case WorkspaceFullDocumentDiagnosticReport: + return marshal(val) + case WorkspaceUnchangedDocumentDiagnosticReport: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *WorkspaceDocumentDiagnosticReport) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 WorkspaceFullDocumentDiagnosticReport + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 WorkspaceUnchangedDocumentDiagnosticReport + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// ChangeAnnotationIdentifier an identifier to refer to a change annotation stored with a workspace edit. +type ChangeAnnotationIdentifier string + +type ProgressToken struct { + value any +} + +func NewProgressToken[T int32 | string](val T) ProgressToken { + return ProgressToken{ + value: val, + } +} + +func (t ProgressToken) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case int32: + return marshal(val) + case string: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *ProgressToken) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 int32 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 string + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DocumentSelector a document selector is the combination of one or many document filters. // // Example: `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]`; The use of a string as a document filter is deprecated +// +// @since 3.16.0. +type DocumentSelector []DocumentFilter + +type PrepareRenameResult struct { + value any +} + +func NewPrepareRenameResult[T Range | PrepareRenamePlaceholder | PrepareRenameDefaultBehavior](val T) PrepareRenameResult { + return PrepareRenameResult{ + value: val, + } +} + +func (t PrepareRenameResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Range: + return marshal(val) + case PrepareRenamePlaceholder: + return marshal(val) + case PrepareRenameDefaultBehavior: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *PrepareRenameResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Range + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 PrepareRenamePlaceholder + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 PrepareRenameDefaultBehavior + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DocumentDiagnosticReport the result of a document diagnostic pull request. A report can either be a full report containing all diagnostics for the requested document or an unchanged report indicating that nothing has changed in terms of diagnostics in comparison to the last pull request. +// +// @since 3.17.0 +type DocumentDiagnosticReport struct { + value any +} + +func NewDocumentDiagnosticReport[T RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport](val T) DocumentDiagnosticReport { + return DocumentDiagnosticReport{ + value: val, + } +} + +func (t DocumentDiagnosticReport) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case RelatedFullDocumentDiagnosticReport: + return marshal(val) + case RelatedUnchangedDocumentDiagnosticReport: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *DocumentDiagnosticReport) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 RelatedFullDocumentDiagnosticReport + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 RelatedUnchangedDocumentDiagnosticReport + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// InlineValue inline value information can be provided by different means: - directly as a text value (class InlineValueText). - as a name to use for a variable lookup (class InlineValueVariableLookup) - as an evaluatable expression (class InlineValueEvaluatableExpression) The InlineValue types combines all inline value types into one type. +// +// @since 3.17.0 +type InlineValue struct { + value any +} + +func NewInlineValue[T InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression](val T) InlineValue { + return InlineValue{ + value: val, + } +} + +func (t InlineValue) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case InlineValueText: + return marshal(val) + case InlineValueVariableLookup: + return marshal(val) + case InlineValueEvaluatableExpression: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *InlineValue) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 InlineValueText + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 InlineValueVariableLookup + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 InlineValueEvaluatableExpression + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DeclarationLink information about where a symbol is declared. Provides additional metadata over normal Location location declarations, including the range of the declaring symbol. Servers should prefer returning `DeclarationLink` over `Declaration` if supported by the client. +type DeclarationLink LocationLink + +// Declaration the declaration of a symbol representation as one or many Location locations. +type Declaration struct { + value any +} + +func NewDeclaration[T Location | []Location](val T) Declaration { + return Declaration{ + value: val, + } +} + +func (t Declaration) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Location: + return marshal(val) + case []Location: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *Declaration) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Location + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []Location + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} + +// DefinitionLink information about where a symbol is defined. Provides additional metadata over normal Location location definitions, including the range of the defining symbol. +type DefinitionLink LocationLink + +// Definition the definition of a symbol represented as one or many Location locations. For most programming languages there is only one location at which a symbol is defined. Servers should prefer returning `DefinitionLink` over `Definition` if supported by the client. +type Definition struct { + value any +} + +func NewDefinition[T Location | []Location](val T) Definition { + return Definition{ + value: val, + } +} + +func (t Definition) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Location: + return marshal(val) + case []Location: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unkonwn type: %T", t) +} + +func (t *Definition) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Location + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []Location + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} +} diff --git a/types.go b/types.go new file mode 100644 index 00000000..e5cadd52 --- /dev/null +++ b/types.go @@ -0,0 +1,20 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +type DocumentURI string + +type ClientMethod = string + +type ServerMethod = string + +// UnmarshalError indicates that a JSON value did not conform to +// one of the expected cases of an LSP union type. +type UnmarshalError struct { + msg string +} + +func (e UnmarshalError) Error() string { + return e.msg +} diff --git a/types_generics.go b/types_generics.go new file mode 100644 index 00000000..96a19860 --- /dev/null +++ b/types_generics.go @@ -0,0 +1,2998 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + +package protocol + +import ( + "fmt" + + "go.lsp.dev/uri" +) + +// CancelParamsID the request id to cancel. +type CancelParamsID struct { + value any +} + +func NewCancelParamsID[T int32 | string](val T) CancelParamsID { + return CancelParamsID{ + value: val, + } +} + +func (t CancelParamsID) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case int32: + return marshal(val) + case string: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CancelParamsID) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 int32 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 string + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [int32 string]"} +} + +// ClientSemanticTokensRequestOptionsFull the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. +type ClientSemanticTokensRequestOptionsFull struct { + value any +} + +func NewClientSemanticTokensRequestOptionsFull[T bool | ClientSemanticTokensRequestFullDelta](val T) *ClientSemanticTokensRequestOptionsFull { + return &ClientSemanticTokensRequestOptionsFull{ + value: val, + } +} + +func (t ClientSemanticTokensRequestOptionsFull) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case ClientSemanticTokensRequestFullDelta: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ClientSemanticTokensRequestOptionsFull) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 ClientSemanticTokensRequestFullDelta + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool ClientSemanticTokensRequestFullDelta]"} +} + +// ClientSemanticTokensRequestOptionsRange the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. +type ClientSemanticTokensRequestOptionsRange struct { + value any +} + +func NewClientSemanticTokensRequestOptionsRange[T bool | Range](val T) *ClientSemanticTokensRequestOptionsRange { + return &ClientSemanticTokensRequestOptionsRange{ + value: val, + } +} + +func (t ClientSemanticTokensRequestOptionsRange) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case Range: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ClientSemanticTokensRequestOptionsRange) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 Range + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool Range]"} +} + +// CodeActionRequestResult a request to provide commands for the given text document and range. +type CodeActionRequestResult struct { + value any +} + +func NewCodeActionRequestResult[T Command | CodeAction](val T) *CodeActionRequestResult { + return &CodeActionRequestResult{ + value: val, + } +} + +func (t CodeActionRequestResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Command: + return marshal(val) + case CodeAction: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CodeActionRequestResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Command + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 CodeAction + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} +} + +// CompletionItemDefaultsEditRange a default edit range. +// +// @since 3.17.0 +type CompletionItemDefaultsEditRange struct { + value any +} + +func NewCompletionItemDefaultsEditRange[T Range | EditRangeWithInsertReplace](val T) *CompletionItemDefaultsEditRange { + return &CompletionItemDefaultsEditRange{ + value: val, + } +} + +func (t CompletionItemDefaultsEditRange) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Range: + return marshal(val) + case EditRangeWithInsertReplace: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CompletionItemDefaultsEditRange) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Range + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 EditRangeWithInsertReplace + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Range EditRangeWithInsertReplace]"} +} + +// CompletionItemDocumentation a human-readable string that represents a doc-comment. +type CompletionItemDocumentation struct { + value any +} + +func NewCompletionItemDocumentation[T string | MarkupContent](val T) *CompletionItemDocumentation { + return &CompletionItemDocumentation{ + value: val, + } +} + +func (t CompletionItemDocumentation) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case MarkupContent: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CompletionItemDocumentation) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// CompletionItemTextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`. +// +// @since 3.16.0 additional type `InsertReplaceEdit` +type CompletionItemTextEdit struct { + value any +} + +func NewCompletionItemTextEdit[T TextEdit | InsertReplaceEdit](val T) *CompletionItemTextEdit { + return &CompletionItemTextEdit{ + value: val, + } +} + +func (t CompletionItemTextEdit) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case TextEdit: + return marshal(val) + case InsertReplaceEdit: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CompletionItemTextEdit) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 TextEdit + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 InsertReplaceEdit + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextEdit InsertReplaceEdit]"} +} + +// CompletionResult request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, +// `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. +type CompletionResult struct { + value any +} + +func NewCompletionResult[T []CompletionItem | CompletionList](val T) *CompletionResult { + return &CompletionResult{ + value: val, + } +} + +func (t CompletionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case []CompletionItem: + return marshal(val) + case CompletionList: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *CompletionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 []CompletionItem + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 CompletionList + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} +} + +// DeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a +// typed array of DeclarationLink or a Thenable that resolves to such. +type DeclarationResult struct { + value any +} + +func NewDeclarationResult[T Declaration | []DeclarationLink](val T) *DeclarationResult { + return &DeclarationResult{ + value: val, + } +} + +func (t DeclarationResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Declaration: + return marshal(val) + case []DeclarationLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DeclarationResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Declaration + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DeclarationLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Declaration []DeclarationLink]"} +} + +// DefinitionResult a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed +// array of DefinitionLink or a Thenable that resolves to such. +type DefinitionResult struct { + value any +} + +func NewDefinitionResult[T Definition | []DefinitionLink](val T) *DefinitionResult { + return &DefinitionResult{ + value: val, + } +} + +func (t DefinitionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Definition: + return marshal(val) + case []DefinitionLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DefinitionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Definition + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + +// DiagnosticCode the diagnostic's code, which usually appear in the user interface. +type DiagnosticCode struct { + value any +} + +func NewDiagnosticCode[T int32 | string](val T) DiagnosticCode { + return DiagnosticCode{ + value: val, + } +} + +func (t DiagnosticCode) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case int32: + return marshal(val) + case string: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DiagnosticCode) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 int32 + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 string + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [int32 string]"} +} + +type DidChangeConfigurationRegistrationOptionsSection struct { + value any +} + +func NewDidChangeConfigurationRegistrationOptionsSection[T string | []string](val T) DidChangeConfigurationRegistrationOptionsSection { + return DidChangeConfigurationRegistrationOptionsSection{ + value: val, + } +} + +func (t DidChangeConfigurationRegistrationOptionsSection) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case []string: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DidChangeConfigurationRegistrationOptionsSection) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []string + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string []string]"} +} + +type DocumentDiagnosticReportPartialResultRelatedDocuments struct { + value any +} + +func NewDocumentDiagnosticReportPartialResultRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](val T) *DocumentDiagnosticReportPartialResultRelatedDocuments { + return &DocumentDiagnosticReportPartialResultRelatedDocuments{ + value: val, + } +} + +func (t DocumentDiagnosticReportPartialResultRelatedDocuments) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case FullDocumentDiagnosticReport: + return marshal(val) + case UnchangedDocumentDiagnosticReport: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DocumentDiagnosticReportPartialResultRelatedDocuments) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 FullDocumentDiagnosticReport + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 UnchangedDocumentDiagnosticReport + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} +} + +// DocumentSymbolResult a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that +// resolves to such. +type DocumentSymbolResult struct { + value any +} + +func NewDocumentSymbolResult[T []SymbolInformation | []DocumentSymbol](val T) DocumentSymbolResult { + return DocumentSymbolResult{ + value: val, + } +} + +func (t DocumentSymbolResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case []SymbolInformation: + return marshal(val) + case []DocumentSymbol: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *DocumentSymbolResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 []SymbolInformation + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DocumentSymbol + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} +} + +// HoverContents the hover's content. +type HoverContents struct { + value any +} + +func NewHoverContents[T MarkupContent | MarkedString | []MarkedString](val T) *HoverContents { + return &HoverContents{ + value: val, + } +} + +func (t HoverContents) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case MarkupContent: + return marshal(val) + case MarkedString: + return marshal(val) + case []MarkedString: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *HoverContents) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 MarkupContent + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 MarkedString + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 []MarkedString + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [MarkupContent MarkedString []MarkedString]"} +} + +// ImplementationResult a request to resolve the implementation locations of a symbol at a given text document position. The +// request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. +type ImplementationResult struct { + value any +} + +func NewImplementationResult[T Definition | []DefinitionLink](val T) *ImplementationResult { + return &ImplementationResult{ + value: val, + } +} + +func (t ImplementationResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Definition: + return marshal(val) + case []DefinitionLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ImplementationResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Definition + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + +// InlayHintLabel the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty. +type InlayHintLabel struct { + value any +} + +func NewInlayHintLabel[T string | []InlayHintLabelPart](val T) InlayHintLabel { + return InlayHintLabel{ + value: val, + } +} + +func (t InlayHintLabel) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case []InlayHintLabelPart: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlayHintLabel) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []InlayHintLabelPart + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string []InlayHintLabelPart]"} +} + +// InlayHintLabelPartTooltip the tooltip text when you hover over this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. +type InlayHintLabelPartTooltip struct { + value any +} + +func NewInlayHintLabelPartTooltip[T string | MarkupContent](val T) *InlayHintLabelPartTooltip { + return &InlayHintLabelPartTooltip{ + value: val, + } +} + +func (t InlayHintLabelPartTooltip) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case MarkupContent: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlayHintLabelPartTooltip) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// InlayHintTooltip the tooltip text when you hover over this item. +type InlayHintTooltip struct { + value any +} + +func NewInlayHintTooltip[T string | MarkupContent](val T) *InlayHintTooltip { + return &InlayHintTooltip{ + value: val, + } +} + +func (t InlayHintTooltip) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case MarkupContent: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlayHintTooltip) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// InlineCompletionItemInsertText the text to replace the range with. Must be set. +type InlineCompletionItemInsertText struct { + value any +} + +func NewInlineCompletionItemInsertText[T string | StringValue](val T) *InlineCompletionItemInsertText { + return &InlineCompletionItemInsertText{ + value: val, + } +} + +func (t InlineCompletionItemInsertText) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case StringValue: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlineCompletionItemInsertText) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 StringValue + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string StringValue]"} +} + +// InlineCompletionResult a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type InlineCompletionResult struct { + value any +} + +func NewInlineCompletionResult[T InlineCompletionList | []InlineCompletionItem](val T) *InlineCompletionResult { + return &InlineCompletionResult{ + value: val, + } +} + +func (t InlineCompletionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case InlineCompletionList: + return marshal(val) + case []InlineCompletionItem: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *InlineCompletionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 InlineCompletionList + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []InlineCompletionItem + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} +} + +// NotebookCellTextDocumentFilterNotebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. +type NotebookCellTextDocumentFilterNotebook struct { + value any +} + +func NewNotebookCellTextDocumentFilterNotebook[T string | NotebookDocumentFilter](val T) *NotebookCellTextDocumentFilterNotebook { + return &NotebookCellTextDocumentFilterNotebook{ + value: val, + } +} + +func (t NotebookCellTextDocumentFilterNotebook) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case NotebookDocumentFilter: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *NotebookCellTextDocumentFilterNotebook) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 NotebookDocumentFilter + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} +} + +// NotebookDocumentFilterWithCellsNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. +type NotebookDocumentFilterWithCellsNotebook struct { + value any +} + +func NewNotebookDocumentFilterWithCellsNotebook[T string | NotebookDocumentFilter](val T) *NotebookDocumentFilterWithCellsNotebook { + return &NotebookDocumentFilterWithCellsNotebook{ + value: val, + } +} + +func (t NotebookDocumentFilterWithCellsNotebook) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case NotebookDocumentFilter: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *NotebookDocumentFilterWithCellsNotebook) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 NotebookDocumentFilter + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} +} + +// NotebookDocumentFilterWithNotebookNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. +type NotebookDocumentFilterWithNotebookNotebook struct { + value any +} + +func NewNotebookDocumentFilterWithNotebookNotebook[T string | NotebookDocumentFilter](val T) *NotebookDocumentFilterWithNotebookNotebook { + return &NotebookDocumentFilterWithNotebookNotebook{ + value: val, + } +} + +func (t NotebookDocumentFilterWithNotebookNotebook) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case NotebookDocumentFilter: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *NotebookDocumentFilterWithNotebookNotebook) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 NotebookDocumentFilter + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} +} + +// NotebookDocumentSyncOptionsNotebookSelector the notebooks to be synced. +type NotebookDocumentSyncOptionsNotebookSelector struct { + value any +} + +func NewNotebookDocumentSyncOptionsNotebookSelector[T NotebookDocumentFilterWithNotebook | NotebookDocumentFilterWithCells](val T) *NotebookDocumentSyncOptionsNotebookSelector { + return &NotebookDocumentSyncOptionsNotebookSelector{ + value: val, + } +} + +func (t NotebookDocumentSyncOptionsNotebookSelector) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case NotebookDocumentFilterWithNotebook: + return marshal(val) + case NotebookDocumentFilterWithCells: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *NotebookDocumentSyncOptionsNotebookSelector) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 NotebookDocumentFilterWithNotebook + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 NotebookDocumentFilterWithCells + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [NotebookDocumentFilterWithNotebook NotebookDocumentFilterWithCells]"} +} + +// ParameterInformationDocumentation the human-readable doc-comment of this parameter. Will be shown in the UI but can be omitted. +type ParameterInformationDocumentation struct { + value any +} + +func NewParameterInformationDocumentation[T string | MarkupContent](val T) *ParameterInformationDocumentation { + return &ParameterInformationDocumentation{ + value: val, + } +} + +func (t ParameterInformationDocumentation) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case MarkupContent: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ParameterInformationDocumentation) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// ParameterInformationLabel the label of this parameter information. Either a string or an inclusive start and exclusive end offsets within its containing signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 string representation as `Position` and `Range` does. To avoid ambiguities a server should use the [start, end] offset value instead of using a substring. Whether a client support this is controlled via `labelOffsetSupport` client capability. *Note*: a label of type string should be a substring of its containing signature label. Its intended use case is to highlight the parameter label +// part in the `SignatureInformation.label`. +type ParameterInformationLabel struct { + value any +} + +func NewParameterInformationLabel[T string | uint32](val T) *ParameterInformationLabel { + return &ParameterInformationLabel{ + value: val, + } +} + +func (t ParameterInformationLabel) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case uint32: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ParameterInformationLabel) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 uint32 + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string uint32]"} +} + +// RelatedFullDocumentDiagnosticReportRelatedDocuments 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 +type RelatedFullDocumentDiagnosticReportRelatedDocuments struct { + value any +} + +func NewRelatedFullDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](val T) *RelatedFullDocumentDiagnosticReportRelatedDocuments { + return &RelatedFullDocumentDiagnosticReportRelatedDocuments{ + value: val, + } +} + +func (t RelatedFullDocumentDiagnosticReportRelatedDocuments) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case FullDocumentDiagnosticReport: + return marshal(val) + case UnchangedDocumentDiagnosticReport: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *RelatedFullDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 FullDocumentDiagnosticReport + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 UnchangedDocumentDiagnosticReport + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} +} + +// RelatedUnchangedDocumentDiagnosticReportRelatedDocuments 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 +type RelatedUnchangedDocumentDiagnosticReportRelatedDocuments struct { + value any +} + +func NewRelatedUnchangedDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](val T) *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments { + return &RelatedUnchangedDocumentDiagnosticReportRelatedDocuments{ + value: val, + } +} + +func (t RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case FullDocumentDiagnosticReport: + return marshal(val) + case UnchangedDocumentDiagnosticReport: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 FullDocumentDiagnosticReport + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 UnchangedDocumentDiagnosticReport + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} +} + +// RelativePatternBaseURI a workspace folder or a base URI to which this pattern will be matched against relatively. +type RelativePatternBaseURI struct { + value any +} + +func NewRelativePatternBaseURI[T WorkspaceFolder | uri.URI](val T) *RelativePatternBaseURI { + return &RelativePatternBaseURI{ + value: val, + } +} + +func (t RelativePatternBaseURI) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case WorkspaceFolder: + return marshal(val) + case uri.URI: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *RelativePatternBaseURI) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 WorkspaceFolder + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 uri.URI + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [WorkspaceFolder uri.URI]"} +} + +// SemanticTokensDeltaResult. +// +// @since 3.16.0 +type SemanticTokensDeltaResult struct { + value any +} + +func NewSemanticTokensDeltaResult[T SemanticTokens | SemanticTokensDelta](val T) *SemanticTokensDeltaResult { + return &SemanticTokensDeltaResult{ + value: val, + } +} + +func (t SemanticTokensDeltaResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case SemanticTokens: + return marshal(val) + case SemanticTokensDelta: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *SemanticTokensDeltaResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 SemanticTokens + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 SemanticTokensDelta + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} +} + +// SemanticTokensOptionsFull server supports providing semantic tokens for a full document. +type SemanticTokensOptionsFull struct { + value any +} + +func NewSemanticTokensOptionsFull[T bool | SemanticTokensFullDelta](val T) *SemanticTokensOptionsFull { + return &SemanticTokensOptionsFull{ + value: val, + } +} + +func (t SemanticTokensOptionsFull) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case SemanticTokensFullDelta: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *SemanticTokensOptionsFull) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 SemanticTokensFullDelta + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool SemanticTokensFullDelta]"} +} + +// SemanticTokensOptionsRange server supports providing semantic tokens for a specific range of a document. +type SemanticTokensOptionsRange struct { + value any +} + +func NewSemanticTokensOptionsRange[T bool | Range](val T) *SemanticTokensOptionsRange { + return &SemanticTokensOptionsRange{ + value: val, + } +} + +func (t SemanticTokensOptionsRange) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case Range: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *SemanticTokensOptionsRange) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 Range + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool Range]"} +} + +// ServerCapabilitiesCallHierarchyProvider the server provides call hierarchy support. +// +// @since 3.16.0 +type ServerCapabilitiesCallHierarchyProvider struct { + value any +} + +func NewServerCapabilitiesCallHierarchyProvider[T bool | CallHierarchyOptions | CallHierarchyRegistrationOptions](val T) *ServerCapabilitiesCallHierarchyProvider { + return &ServerCapabilitiesCallHierarchyProvider{ + value: val, + } +} + +func (t ServerCapabilitiesCallHierarchyProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case CallHierarchyOptions: + return marshal(val) + case CallHierarchyRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesCallHierarchyProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 CallHierarchyOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 CallHierarchyRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool CallHierarchyOptions CallHierarchyRegistrationOptions]"} +} + +// ServerCapabilitiesCodeActionProvider the server provides code actions. CodeActionOptions may only be specified if the client states that it supports `codeActionLiteralSupport` in its initial `initialize` request. +type ServerCapabilitiesCodeActionProvider struct { + value any +} + +func NewServerCapabilitiesCodeActionProvider[T bool | CodeActionOptions](val T) *ServerCapabilitiesCodeActionProvider { + return &ServerCapabilitiesCodeActionProvider{ + value: val, + } +} + +func (t ServerCapabilitiesCodeActionProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case CodeActionOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesCodeActionProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 CodeActionOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool CodeActionOptions]"} +} + +// ServerCapabilitiesColorProvider the server provides color provider support. +type ServerCapabilitiesColorProvider struct { + value any +} + +func NewServerCapabilitiesColorProvider[T bool | DocumentColorOptions | DocumentColorRegistrationOptions](val T) *ServerCapabilitiesColorProvider { + return &ServerCapabilitiesColorProvider{ + value: val, + } +} + +func (t ServerCapabilitiesColorProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case DocumentColorOptions: + return marshal(val) + case DocumentColorRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesColorProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 DocumentColorOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 DocumentColorRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentColorOptions DocumentColorRegistrationOptions]"} +} + +// ServerCapabilitiesDeclarationProvider the server provides Goto Declaration support. +type ServerCapabilitiesDeclarationProvider struct { + value any +} + +func NewServerCapabilitiesDeclarationProvider[T bool | DeclarationOptions | DeclarationRegistrationOptions](val T) *ServerCapabilitiesDeclarationProvider { + return &ServerCapabilitiesDeclarationProvider{ + value: val, + } +} + +func (t ServerCapabilitiesDeclarationProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case DeclarationOptions: + return marshal(val) + case DeclarationRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDeclarationProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 DeclarationOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 DeclarationRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DeclarationOptions DeclarationRegistrationOptions]"} +} + +// ServerCapabilitiesDefinitionProvider the server provides goto definition support. +type ServerCapabilitiesDefinitionProvider struct { + value any +} + +func NewServerCapabilitiesDefinitionProvider[T bool | DefinitionOptions](val T) *ServerCapabilitiesDefinitionProvider { + return &ServerCapabilitiesDefinitionProvider{ + value: val, + } +} + +func (t ServerCapabilitiesDefinitionProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case DefinitionOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDefinitionProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 DefinitionOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DefinitionOptions]"} +} + +// ServerCapabilitiesDiagnosticProvider the server has support for pull model diagnostics. +// +// @since 3.17.0 +type ServerCapabilitiesDiagnosticProvider struct { + value any +} + +func NewServerCapabilitiesDiagnosticProvider[T DiagnosticOptions | DiagnosticRegistrationOptions](val T) *ServerCapabilitiesDiagnosticProvider { + return &ServerCapabilitiesDiagnosticProvider{ + value: val, + } +} + +func (t ServerCapabilitiesDiagnosticProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case DiagnosticOptions: + return marshal(val) + case DiagnosticRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDiagnosticProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 DiagnosticOptions + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 DiagnosticRegistrationOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [DiagnosticOptions DiagnosticRegistrationOptions]"} +} + +// ServerCapabilitiesDocumentFormattingProvider the server provides document formatting. +type ServerCapabilitiesDocumentFormattingProvider struct { + value any +} + +func NewServerCapabilitiesDocumentFormattingProvider[T bool | DocumentFormattingOptions](val T) *ServerCapabilitiesDocumentFormattingProvider { + return &ServerCapabilitiesDocumentFormattingProvider{ + value: val, + } +} + +func (t ServerCapabilitiesDocumentFormattingProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case DocumentFormattingOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDocumentFormattingProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 DocumentFormattingOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentFormattingOptions]"} +} + +// ServerCapabilitiesDocumentHighlightProvider the server provides document highlight support. +type ServerCapabilitiesDocumentHighlightProvider struct { + value any +} + +func NewServerCapabilitiesDocumentHighlightProvider[T bool | DocumentHighlightOptions](val T) *ServerCapabilitiesDocumentHighlightProvider { + return &ServerCapabilitiesDocumentHighlightProvider{ + value: val, + } +} + +func (t ServerCapabilitiesDocumentHighlightProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case DocumentHighlightOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDocumentHighlightProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 DocumentHighlightOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentHighlightOptions]"} +} + +// ServerCapabilitiesDocumentRangeFormattingProvider the server provides document range formatting. +type ServerCapabilitiesDocumentRangeFormattingProvider struct { + value any +} + +func NewServerCapabilitiesDocumentRangeFormattingProvider[T bool | DocumentRangeFormattingOptions](val T) *ServerCapabilitiesDocumentRangeFormattingProvider { + return &ServerCapabilitiesDocumentRangeFormattingProvider{ + value: val, + } +} + +func (t ServerCapabilitiesDocumentRangeFormattingProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case DocumentRangeFormattingOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDocumentRangeFormattingProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 DocumentRangeFormattingOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentRangeFormattingOptions]"} +} + +// ServerCapabilitiesDocumentSymbolProvider the server provides document symbol support. +type ServerCapabilitiesDocumentSymbolProvider struct { + value any +} + +func NewServerCapabilitiesDocumentSymbolProvider[T bool | DocumentSymbolOptions](val T) *ServerCapabilitiesDocumentSymbolProvider { + return &ServerCapabilitiesDocumentSymbolProvider{ + value: val, + } +} + +func (t ServerCapabilitiesDocumentSymbolProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case DocumentSymbolOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesDocumentSymbolProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 DocumentSymbolOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool DocumentSymbolOptions]"} +} + +// ServerCapabilitiesFoldingRangeProvider the server provides folding provider support. +type ServerCapabilitiesFoldingRangeProvider struct { + value any +} + +func NewServerCapabilitiesFoldingRangeProvider[T bool | FoldingRangeOptions | FoldingRangeRegistrationOptions](val T) *ServerCapabilitiesFoldingRangeProvider { + return &ServerCapabilitiesFoldingRangeProvider{ + value: val, + } +} + +func (t ServerCapabilitiesFoldingRangeProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case FoldingRangeOptions: + return marshal(val) + case FoldingRangeRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesFoldingRangeProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 FoldingRangeOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 FoldingRangeRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool FoldingRangeOptions FoldingRangeRegistrationOptions]"} +} + +// ServerCapabilitiesHoverProvider the server provides hover support. +type ServerCapabilitiesHoverProvider struct { + value any +} + +func NewServerCapabilitiesHoverProvider[T bool | HoverOptions](val T) *ServerCapabilitiesHoverProvider { + return &ServerCapabilitiesHoverProvider{ + value: val, + } +} + +func (t ServerCapabilitiesHoverProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case HoverOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesHoverProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 HoverOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool HoverOptions]"} +} + +// ServerCapabilitiesImplementationProvider the server provides Goto Implementation support. +type ServerCapabilitiesImplementationProvider struct { + value any +} + +func NewServerCapabilitiesImplementationProvider[T bool | ImplementationOptions | ImplementationRegistrationOptions](val T) *ServerCapabilitiesImplementationProvider { + return &ServerCapabilitiesImplementationProvider{ + value: val, + } +} + +func (t ServerCapabilitiesImplementationProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case ImplementationOptions: + return marshal(val) + case ImplementationRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesImplementationProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 ImplementationOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 ImplementationRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool ImplementationOptions ImplementationRegistrationOptions]"} +} + +// ServerCapabilitiesInlayHintProvider the server provides inlay hints. +// +// @since 3.17.0 +type ServerCapabilitiesInlayHintProvider struct { + value any +} + +func NewServerCapabilitiesInlayHintProvider[T bool | InlayHintOptions | InlayHintRegistrationOptions](val T) *ServerCapabilitiesInlayHintProvider { + return &ServerCapabilitiesInlayHintProvider{ + value: val, + } +} + +func (t ServerCapabilitiesInlayHintProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case InlayHintOptions: + return marshal(val) + case InlayHintRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesInlayHintProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 InlayHintOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 InlayHintRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool InlayHintOptions InlayHintRegistrationOptions]"} +} + +// ServerCapabilitiesInlineCompletionProvider inline completion options used during static registration. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type ServerCapabilitiesInlineCompletionProvider struct { + value any +} + +func NewServerCapabilitiesInlineCompletionProvider[T bool | InlineCompletionOptions](val T) *ServerCapabilitiesInlineCompletionProvider { + return &ServerCapabilitiesInlineCompletionProvider{ + value: val, + } +} + +func (t ServerCapabilitiesInlineCompletionProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case InlineCompletionOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesInlineCompletionProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 InlineCompletionOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool InlineCompletionOptions]"} +} + +// ServerCapabilitiesInlineValueProvider the server provides inline values. +// +// @since 3.17.0 +type ServerCapabilitiesInlineValueProvider struct { + value any +} + +func NewServerCapabilitiesInlineValueProvider[T bool | InlineValueOptions | InlineValueRegistrationOptions](val T) *ServerCapabilitiesInlineValueProvider { + return &ServerCapabilitiesInlineValueProvider{ + value: val, + } +} + +func (t ServerCapabilitiesInlineValueProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case InlineValueOptions: + return marshal(val) + case InlineValueRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesInlineValueProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 InlineValueOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 InlineValueRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool InlineValueOptions InlineValueRegistrationOptions]"} +} + +// ServerCapabilitiesLinkedEditingRangeProvider the server provides linked editing range support. +// +// @since 3.16.0 +type ServerCapabilitiesLinkedEditingRangeProvider struct { + value any +} + +func NewServerCapabilitiesLinkedEditingRangeProvider[T bool | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions](val T) *ServerCapabilitiesLinkedEditingRangeProvider { + return &ServerCapabilitiesLinkedEditingRangeProvider{ + value: val, + } +} + +func (t ServerCapabilitiesLinkedEditingRangeProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case LinkedEditingRangeOptions: + return marshal(val) + case LinkedEditingRangeRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesLinkedEditingRangeProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 LinkedEditingRangeOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 LinkedEditingRangeRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool LinkedEditingRangeOptions LinkedEditingRangeRegistrationOptions]"} +} + +// ServerCapabilitiesMonikerProvider the server provides moniker support. +// +// @since 3.16.0 +type ServerCapabilitiesMonikerProvider struct { + value any +} + +func NewServerCapabilitiesMonikerProvider[T bool | MonikerOptions | MonikerRegistrationOptions](val T) *ServerCapabilitiesMonikerProvider { + return &ServerCapabilitiesMonikerProvider{ + value: val, + } +} + +func (t ServerCapabilitiesMonikerProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case MonikerOptions: + return marshal(val) + case MonikerRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesMonikerProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 MonikerOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 MonikerRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool MonikerOptions MonikerRegistrationOptions]"} +} + +// ServerCapabilitiesNotebookDocumentSync defines how notebook documents are synced. +// +// @since 3.17.0 +type ServerCapabilitiesNotebookDocumentSync struct { + value any +} + +func NewServerCapabilitiesNotebookDocumentSync[T NotebookDocumentSyncOptions | NotebookDocumentSyncRegistrationOptions](val T) *ServerCapabilitiesNotebookDocumentSync { + return &ServerCapabilitiesNotebookDocumentSync{ + value: val, + } +} + +func (t ServerCapabilitiesNotebookDocumentSync) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case NotebookDocumentSyncOptions: + return marshal(val) + case NotebookDocumentSyncRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesNotebookDocumentSync) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 NotebookDocumentSyncOptions + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 NotebookDocumentSyncRegistrationOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [NotebookDocumentSyncOptions NotebookDocumentSyncRegistrationOptions]"} +} + +// ServerCapabilitiesReferencesProvider the server provides find references support. +type ServerCapabilitiesReferencesProvider struct { + value any +} + +func NewServerCapabilitiesReferencesProvider[T bool | ReferenceOptions](val T) *ServerCapabilitiesReferencesProvider { + return &ServerCapabilitiesReferencesProvider{ + value: val, + } +} + +func (t ServerCapabilitiesReferencesProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case ReferenceOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesReferencesProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 ReferenceOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool ReferenceOptions]"} +} + +// ServerCapabilitiesRenameProvider the server provides rename support. RenameOptions may only be specified if the client states that it +// supports `prepareSupport` in its initial `initialize` request. +type ServerCapabilitiesRenameProvider struct { + value any +} + +func NewServerCapabilitiesRenameProvider[T bool | RenameOptions](val T) *ServerCapabilitiesRenameProvider { + return &ServerCapabilitiesRenameProvider{ + value: val, + } +} + +func (t ServerCapabilitiesRenameProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case RenameOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesRenameProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 RenameOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool RenameOptions]"} +} + +// ServerCapabilitiesSelectionRangeProvider the server provides selection range support. +type ServerCapabilitiesSelectionRangeProvider struct { + value any +} + +func NewServerCapabilitiesSelectionRangeProvider[T bool | SelectionRangeOptions | SelectionRangeRegistrationOptions](val T) *ServerCapabilitiesSelectionRangeProvider { + return &ServerCapabilitiesSelectionRangeProvider{ + value: val, + } +} + +func (t ServerCapabilitiesSelectionRangeProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case SelectionRangeOptions: + return marshal(val) + case SelectionRangeRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesSelectionRangeProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 SelectionRangeOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 SelectionRangeRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool SelectionRangeOptions SelectionRangeRegistrationOptions]"} +} + +// ServerCapabilitiesSemanticTokensProvider the server provides semantic tokens support. +// +// @since 3.16.0 +type ServerCapabilitiesSemanticTokensProvider struct { + value any +} + +func NewServerCapabilitiesSemanticTokensProvider[T SemanticTokensOptions | SemanticTokensRegistrationOptions](val T) *ServerCapabilitiesSemanticTokensProvider { + return &ServerCapabilitiesSemanticTokensProvider{ + value: val, + } +} + +func (t ServerCapabilitiesSemanticTokensProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case SemanticTokensOptions: + return marshal(val) + case SemanticTokensRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesSemanticTokensProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 SemanticTokensOptions + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 SemanticTokensRegistrationOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [SemanticTokensOptions SemanticTokensRegistrationOptions]"} +} + +// ServerCapabilitiesTextDocumentSync defines how text documents are synced. Is either a detailed structure defining each notification or for backwards compatibility the TextDocumentSyncKind number. +type ServerCapabilitiesTextDocumentSync struct { + value any +} + +func NewServerCapabilitiesTextDocumentSync[T TextDocumentSyncOptions | TextDocumentSyncKind](val T) *ServerCapabilitiesTextDocumentSync { + return &ServerCapabilitiesTextDocumentSync{ + value: val, + } +} + +func (t ServerCapabilitiesTextDocumentSync) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case TextDocumentSyncOptions: + return marshal(val) + case TextDocumentSyncKind: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesTextDocumentSync) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 TextDocumentSyncOptions + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 TextDocumentSyncKind + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextDocumentSyncOptions TextDocumentSyncKind]"} +} + +// ServerCapabilitiesTypeDefinitionProvider the server provides Goto Type Definition support. +type ServerCapabilitiesTypeDefinitionProvider struct { + value any +} + +func NewServerCapabilitiesTypeDefinitionProvider[T bool | TypeDefinitionOptions | TypeDefinitionRegistrationOptions](val T) *ServerCapabilitiesTypeDefinitionProvider { + return &ServerCapabilitiesTypeDefinitionProvider{ + value: val, + } +} + +func (t ServerCapabilitiesTypeDefinitionProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case TypeDefinitionOptions: + return marshal(val) + case TypeDefinitionRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesTypeDefinitionProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 TypeDefinitionOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 TypeDefinitionRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool TypeDefinitionOptions TypeDefinitionRegistrationOptions]"} +} + +// ServerCapabilitiesTypeHierarchyProvider the server provides type hierarchy support. +// +// @since 3.17.0 +type ServerCapabilitiesTypeHierarchyProvider struct { + value any +} + +func NewServerCapabilitiesTypeHierarchyProvider[T bool | TypeHierarchyOptions | TypeHierarchyRegistrationOptions](val T) *ServerCapabilitiesTypeHierarchyProvider { + return &ServerCapabilitiesTypeHierarchyProvider{ + value: val, + } +} + +func (t ServerCapabilitiesTypeHierarchyProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case TypeHierarchyOptions: + return marshal(val) + case TypeHierarchyRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesTypeHierarchyProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 TypeHierarchyOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 TypeHierarchyRegistrationOptions + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool TypeHierarchyOptions TypeHierarchyRegistrationOptions]"} +} + +// ServerCapabilitiesWorkspaceSymbolProvider the server provides workspace symbol support. +type ServerCapabilitiesWorkspaceSymbolProvider struct { + value any +} + +func NewServerCapabilitiesWorkspaceSymbolProvider[T bool | WorkspaceSymbolOptions](val T) *ServerCapabilitiesWorkspaceSymbolProvider { + return &ServerCapabilitiesWorkspaceSymbolProvider{ + value: val, + } +} + +func (t ServerCapabilitiesWorkspaceSymbolProvider) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case WorkspaceSymbolOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *ServerCapabilitiesWorkspaceSymbolProvider) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 WorkspaceSymbolOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool WorkspaceSymbolOptions]"} +} + +// SignatureInformationDocumentation the human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. +type SignatureInformationDocumentation struct { + value any +} + +func NewSignatureInformationDocumentation[T string | MarkupContent](val T) *SignatureInformationDocumentation { + return &SignatureInformationDocumentation{ + value: val, + } +} + +func (t SignatureInformationDocumentation) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case MarkupContent: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *SignatureInformationDocumentation) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 MarkupContent + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} +} + +// TextDocumentEditEdits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. +// +// @since 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. +type TextDocumentEditEdits struct { + value any +} + +func NewTextDocumentEditEdits[T TextEdit | AnnotatedTextEdit | SnippetTextEdit](val T) *TextDocumentEditEdits { + return &TextDocumentEditEdits{ + value: val, + } +} + +func (t TextDocumentEditEdits) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case TextEdit: + return marshal(val) + case AnnotatedTextEdit: + return marshal(val) + case SnippetTextEdit: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentEditEdits) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 TextEdit + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 AnnotatedTextEdit + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 SnippetTextEdit + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextEdit AnnotatedTextEdit SnippetTextEdit]"} +} + +// TextDocumentSyncOptionsSave if present save notifications are sent to the server. If omitted the notification should not be sent. +type TextDocumentSyncOptionsSave struct { + value any +} + +func NewTextDocumentSyncOptionsSave[T bool | SaveOptions](val T) *TextDocumentSyncOptionsSave { + return &TextDocumentSyncOptionsSave{ + value: val, + } +} + +func (t TextDocumentSyncOptionsSave) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case bool: + return marshal(val) + case SaveOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TextDocumentSyncOptionsSave) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 bool + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 SaveOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [bool SaveOptions]"} +} + +// TypeDefinitionResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. +type TypeDefinitionResult struct { + value any +} + +func NewTypeDefinitionResult[T Definition | []DefinitionLink](val T) *TypeDefinitionResult { + return &TypeDefinitionResult{ + value: val, + } +} + +func (t TypeDefinitionResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Definition: + return marshal(val) + case []DefinitionLink: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *TypeDefinitionResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Definition + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []DefinitionLink + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} +} + +// WorkspaceEditDocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are +// either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. +type WorkspaceEditDocumentChanges struct { + value any +} + +func NewWorkspaceEditDocumentChanges[T TextDocumentEdit | CreateFile | RenameFile | DeleteFile](val T) *WorkspaceEditDocumentChanges { + return &WorkspaceEditDocumentChanges{ + value: val, + } +} + +func (t WorkspaceEditDocumentChanges) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case TextDocumentEdit: + return marshal(val) + case CreateFile: + return marshal(val) + case RenameFile: + return marshal(val) + case DeleteFile: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceEditDocumentChanges) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 TextDocumentEdit + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 CreateFile + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + var h2 RenameFile + if err := unmarshal(val, &h2); err == nil { + t.value = h2 + return nil + } + var h3 DeleteFile + if err := unmarshal(val, &h3); err == nil { + t.value = h3 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextDocumentEdit CreateFile RenameFile DeleteFile]"} +} + +// WorkspaceFoldersServerCapabilitiesChangeNotifications whether the server wants to receive workspace folder change notifications. If a string is provided the string is treated as an ID under which the notification is registered on the client side. The ID can be used to unregister for these events using the `client/unregisterCapability` request. +type WorkspaceFoldersServerCapabilitiesChangeNotifications struct { + value any +} + +func NewWorkspaceFoldersServerCapabilitiesChangeNotifications[T string | bool](val T) WorkspaceFoldersServerCapabilitiesChangeNotifications { + return WorkspaceFoldersServerCapabilitiesChangeNotifications{ + value: val, + } +} + +func (t WorkspaceFoldersServerCapabilitiesChangeNotifications) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case string: + return marshal(val) + case bool: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceFoldersServerCapabilitiesChangeNotifications) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 string + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 bool + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [string bool]"} +} + +// WorkspaceOptionsTextDocumentContent the server supports the `workspace/textDocumentContent` request. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type WorkspaceOptionsTextDocumentContent struct { + value any +} + +func NewWorkspaceOptionsTextDocumentContent[T TextDocumentContentOptions | TextDocumentContentRegistrationOptions](val T) *WorkspaceOptionsTextDocumentContent { + return &WorkspaceOptionsTextDocumentContent{ + value: val, + } +} + +func (t WorkspaceOptionsTextDocumentContent) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case TextDocumentContentOptions: + return marshal(val) + case TextDocumentContentRegistrationOptions: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceOptionsTextDocumentContent) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 TextDocumentContentOptions + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 TextDocumentContentRegistrationOptions + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [TextDocumentContentOptions TextDocumentContentRegistrationOptions]"} +} + +// WorkspaceSymbolLocation the location of the symbol. Whether a server is allowed to return a location without a range depends +// on the client capability `workspace.symbol.resolveSupport`. See SymbolInformation#location for +// more details. +type WorkspaceSymbolLocation struct { + value any +} + +func NewWorkspaceSymbolLocation[T Location | LocationURIOnly](val T) *WorkspaceSymbolLocation { + return &WorkspaceSymbolLocation{ + value: val, + } +} + +func (t WorkspaceSymbolLocation) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case Location: + return marshal(val) + case LocationURIOnly: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceSymbolLocation) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 Location + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 LocationURIOnly + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [Location LocationURIOnly]"} +} + +// WorkspaceSymbolResult a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. +// The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. +// +// @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. +type WorkspaceSymbolResult struct { + value any +} + +func NewWorkspaceSymbolResult[T []SymbolInformation | []WorkspaceSymbol](val T) WorkspaceSymbolResult { + return WorkspaceSymbolResult{ + value: val, + } +} + +func (t WorkspaceSymbolResult) MarshalJSON() ([]byte, error) { + switch val := t.value.(type) { + case []SymbolInformation: + return marshal(val) + case []WorkspaceSymbol: + return marshal(val) + case nil: + return []byte("null"), nil + } + return nil, fmt.Errorf("unknown type: %T", t) +} + +func (t *WorkspaceSymbolResult) UnmarshalJSON(val []byte) error { + if string(val) == "null" { + t.value = nil + return nil + } + var h0 []SymbolInformation + if err := unmarshal(val, &h0); err == nil { + t.value = h0 + return nil + } + var h1 []WorkspaceSymbol + if err := unmarshal(val, &h1); err == nil { + t.value = h1 + return nil + } + return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []WorkspaceSymbol]"} +} diff --git a/util.go b/util.go deleted file mode 100644 index 4dc29c43..00000000 --- a/util.go +++ /dev/null @@ -1,9 +0,0 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -// NewVersion returns the int32 pointer converted i. -func NewVersion(i int32) *int32 { - return &i -} diff --git a/util_test.go b/util_test.go deleted file mode 100644 index 22c9bfe8..00000000 --- a/util_test.go +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-FileCopyrightText: 2020 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "testing" -) - -func TestNewVersion(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - i int32 - }{ - { - name: "Valid", - i: 5000, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - want := NewVersion(tt.i) - if got := NewVersion(tt.i); *got != *want { - t.Errorf("NewVersion(%v) = %v, want %v", tt.i, *got, *want) - } - }) - } -} diff --git a/window.go b/window.go index 42468e17..6527f4d0 100644 --- a/window.go +++ b/window.go @@ -1,111 +1,110 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// Copyright 2024 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol -import "strconv" +import ( + "go.lsp.dev/uri" +) -// ShowMessageParams params of ShowMessage notification. -type ShowMessageParams struct { - // Message is the actual message. - Message string `json:"message"` +// MessageType the message type. +type MessageType uint32 - // Type is the message type. - Type MessageType `json:"type"` -} +const ( + // ErrorMessageType an error message. + ErrorMessageType MessageType = 1 -// MessageType type of ShowMessageParams type. -type MessageType float64 + // WarningMessageType a warning message. + WarningMessageType MessageType = 2 -const ( - // MessageTypeError an error message. - MessageTypeError MessageType = 1 - // MessageTypeWarning a warning message. - MessageTypeWarning MessageType = 2 - // MessageTypeInfo an information message. - MessageTypeInfo MessageType = 3 - // MessageTypeLog a log message. - MessageTypeLog MessageType = 4 + // InfoMessageType an information message. + InfoMessageType MessageType = 3 + + // LogMessageType a log message. + LogMessageType MessageType = 4 + + // DebugMessageType a debug message. 3.18.0 @proposed. + // + // @since 3.18.0 proposed + DebugMessageType MessageType = 5 ) -// String implements fmt.Stringer. -func (m MessageType) String() string { - switch m { - case MessageTypeError: - return "error" - case MessageTypeWarning: - return "warning" - case MessageTypeInfo: - return "info" - case MessageTypeLog: - return "log" - default: - return strconv.FormatFloat(float64(m), 'f', -10, 64) - } +type WorkDoneProgressCreateParams struct { + // Token the token to be used to report progress. + Token ProgressToken `json:"token"` } -// Enabled reports whether the level is enabled. -func (m MessageType) Enabled(level MessageType) bool { - return level > 0 && m >= level +type WorkDoneProgressCancelParams struct { + // Token the token to be used to report progress. + Token ProgressToken `json:"token"` } -// messageTypeMap map of MessageTypes. -var messageTypeMap = map[string]MessageType{ - "error": MessageTypeError, - "warning": MessageTypeWarning, - "info": MessageTypeInfo, - "log": MessageTypeLog, +// ShowDocumentParams params to show a resource in the UI. +// +// @since 3.16.0 +type ShowDocumentParams struct { + // URI the uri to show. + // + // @since 3.16.0 + URI uri.URI `json:"uri"` + + // External indicates to show the resource in an external program. To show, for example, `https://code.visualstudio.com/` in the default WEB browser set `external` to `true`. + // + // @since 3.16.0 + External bool `json:"external,omitempty"` + + // TakeFocus an optional property to indicate whether the editor showing the document should take focus or not. Clients might ignore this property if an external program is started. + // + // @since 3.16.0 + TakeFocus bool `json:"takeFocus,omitempty"` + + // Selection an optional selection range if the document is a text document. Clients might ignore the property if + // an external program is started or the file is not a text file. + // + // @since 3.16.0 + Selection *Range `json:"selection,omitempty"` } -// ToMessageType converts level to the MessageType. -func ToMessageType(level string) MessageType { - mt, ok := messageTypeMap[level] - if !ok { - return MessageType(0) // unknown - } - - return mt +// ShowDocumentResult the result of a showDocument request. +// +// @since 3.16.0 +type ShowDocumentResult struct { + // Success a boolean indicating if the show was successful. + // + // @since 3.16.0 + Success bool `json:"success"` } -// ShowMessageRequestParams params of ShowMessage request. -type ShowMessageRequestParams struct { - // Actions is the message action items to present. - Actions []MessageActionItem `json:"actions"` +// ShowMessageParams the parameters of a notification message. +type ShowMessageParams struct { + // Type the message type. See MessageType. + Type MessageType `json:"type"` - // Message is the actual message + // Message the actual message. Message string `json:"message"` - - // Type is the message type. See {@link MessageType} - Type MessageType `json:"type"` } -// MessageActionItem item of ShowMessageRequestParams action. type MessageActionItem struct { // Title a short title like 'Retry', 'Open Log' etc. Title string `json:"title"` } -// LogMessageParams params of LogMessage notification. -type LogMessageParams struct { - // Message is the actual message +type ShowMessageRequestParams struct { + // Type the message type. See MessageType. + Type MessageType `json:"type"` + + // Message the actual message. Message string `json:"message"` - // Type is the message type. See {@link MessageType} - Type MessageType `json:"type"` + // Actions the message action items to present. + Actions []MessageActionItem `json:"actions,omitempty"` } -// WorkDoneProgressCreateParams params of WorkDoneProgressCreate request. -// -// @since 3.15.0. -type WorkDoneProgressCreateParams struct { - // Token is the token to be used to report progress. - Token ProgressToken `json:"token"` -} +// LogMessageParams the log message parameters. +type LogMessageParams struct { + // Type the message type. See MessageType. + Type MessageType `json:"type"` -// WorkDoneProgressCancelParams params of WorkDoneProgressCancel request. -// -// @since 3.15.0. -type WorkDoneProgressCancelParams struct { - // Token is the token to be used to report progress. - Token ProgressToken `json:"token"` + // Message the actual message. + Message string `json:"message"` } diff --git a/window_test.go b/window_test.go deleted file mode 100644 index d2bc0370..00000000 --- a/window_test.go +++ /dev/null @@ -1,792 +0,0 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "strconv" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/segmentio/encoding/json" -) - -func TestShowMessageParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"message":"error message","type":1}` - wantUnknown = `{"message":"unknown message","type":0}` - ) - wantType := ShowMessageParams{ - Message: "error message", - Type: MessageTypeError, - } - wantTypeUnkonwn := ShowMessageParams{ - Message: "unknown message", - Type: MessageType(0), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ShowMessageParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Unknown", - field: wantTypeUnkonwn, - want: wantUnknown, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ShowMessageParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Unknown", - field: wantUnknown, - want: wantTypeUnkonwn, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ShowMessageParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestShowMessageRequestParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"actions":[{"title":"Retry"}],"message":"error message","type":1}` - wantUnknown = `{"actions":[{"title":"Retry"}],"message":"unknown message","type":0}` - ) - wantType := ShowMessageRequestParams{ - Actions: []MessageActionItem{ - { - Title: "Retry", - }, - }, - Message: "error message", - Type: MessageTypeError, - } - wantTypeUnkonwn := ShowMessageRequestParams{ - Actions: []MessageActionItem{ - { - Title: "Retry", - }, - }, - Message: "unknown message", - Type: MessageType(0), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field ShowMessageRequestParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Unknown", - field: wantTypeUnkonwn, - want: wantUnknown, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want ShowMessageRequestParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Unknown", - field: wantUnknown, - want: wantTypeUnkonwn, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ShowMessageRequestParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestMessageActionItem(t *testing.T) { - t.Parallel() - - const ( - want = `{"title":"Retry"}` - wantOpenLog = `{"title":"Open Log"}` - ) - wantType := MessageActionItem{ - Title: "Retry", - } - wantTypeOpenLog := MessageActionItem{ - Title: "Open Log", - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field MessageActionItem - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Unknown", - field: wantTypeOpenLog, - want: wantOpenLog, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want MessageActionItem - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Unknown", - field: wantOpenLog, - want: wantTypeOpenLog, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got MessageActionItem - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestLogMessageParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"message":"error message","type":1}` - wantUnknown = `{"message":"unknown message","type":0}` - ) - wantType := LogMessageParams{ - Message: "error message", - Type: MessageTypeError, - } - wantTypeUnknown := LogMessageParams{ - Message: "unknown message", - Type: MessageType(0), - } - - t.Run("Marshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field LogMessageParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Unknown", - field: wantTypeUnknown, - want: wantUnknown, - wantMarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - field string - want LogMessageParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Unknown", - field: wantUnknown, - want: wantTypeUnknown, - wantUnmarshalErr: false, - wantErr: false, - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got LogMessageParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkDoneProgressCreateParams(t *testing.T) { - t.Parallel() - - const ( - wantToken = int32(1569) - invalidToken = int32(1348) - ) - var ( - wantString = `{"token":"` + strconv.FormatInt(int64(wantToken), 10) + `"}` - wantInvalidString = `{"token":"` + strconv.FormatInt(int64(invalidToken), 10) + `"}` - wantNumber = `{"token":` + strconv.FormatInt(int64(wantToken), 10) + `}` - wantInvalidNumber = `{"token":` + strconv.FormatInt(int64(invalidToken), 10) + `}` - ) - token := NewProgressToken(strconv.FormatInt(int64(wantToken), 10)) - wantTypeString := WorkDoneProgressCreateParams{ - Token: *token, - } - numberToken := NewNumberProgressToken(wantToken) - wantTypeNumber := WorkDoneProgressCreateParams{ - Token: *numberToken, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WorkDoneProgressCreateParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid/String", - field: wantTypeString, - want: wantString, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Valid/Number", - field: wantTypeNumber, - want: wantNumber, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid/String", - field: wantTypeString, - want: wantInvalidString, - wantMarshalErr: false, - wantErr: true, - }, - { - name: "Invalid/Number", - field: wantTypeNumber, - want: wantInvalidNumber, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WorkDoneProgressCreateParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid/String", - field: wantString, - want: wantTypeString, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Valid/Number", - field: wantNumber, - want: wantTypeNumber, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid/String", - field: wantInvalidString, - want: wantTypeString, - wantUnmarshalErr: false, - wantErr: true, - }, - { - name: "Invalid/Number", - field: wantInvalidNumber, - want: wantTypeNumber, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkDoneProgressCreateParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(got.Token.String(), strconv.FormatInt(int64(wantToken), 10)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkDoneProgressCancelParams(t *testing.T) { - t.Parallel() - - const ( - wantToken = int32(1569) - invalidToken = int32(1348) - ) - var ( - want = `{"token":` + strconv.FormatInt(int64(wantToken), 10) + `}` - wantInvalid = `{"token":` + strconv.FormatInt(int64(invalidToken), 10) + `}` - ) - token := NewNumberProgressToken(wantToken) - wantType := WorkDoneProgressCancelParams{ - Token: *token, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WorkDoneProgressCancelParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WorkDoneProgressCancelParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkDoneProgressCancelParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(got.Token.String(), strconv.FormatInt(int64(wantToken), 10)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestMessageType_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - m MessageType - want string - }{ - { - name: "Error", - m: MessageTypeError, - want: "error", - }, - { - name: "Warning", - m: MessageTypeWarning, - want: "warning", - }, - { - name: "Info", - m: MessageTypeInfo, - want: "info", - }, - { - name: "Log", - m: MessageTypeLog, - want: "log", - }, - { - name: "Unknown", - m: MessageType(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.m.String(); got != tt.want { - t.Errorf("MessageType.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestMessageType_Enabled(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - m MessageType - level MessageType - want bool - }{ - { - name: "ErrorError", - m: MessageTypeError, - level: MessageTypeError, - want: true, - }, - { - name: "ErrorInfo", - m: MessageTypeError, - level: MessageTypeInfo, - want: false, - }, - { - name: "ErrorUnknown", - m: MessageTypeError, - level: MessageType(0), - want: false, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.m.Enabled(tt.level); got != tt.want { - t.Errorf("MessageType.Enabled(%v) = %v, want %v", tt.level, tt.want, got) - } - }) - } -} - -func TestToMessageType(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - level string - want MessageType - }{ - { - name: "Error", - level: "error", - want: MessageTypeError, - }, - { - name: "Warning", - level: "warning", - want: MessageTypeWarning, - }, - { - name: "Info", - level: "info", - want: MessageTypeInfo, - }, - { - name: "Log", - level: "log", - want: MessageTypeLog, - }, - { - name: "Unknown", - level: "0", - want: MessageType(0), - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := ToMessageType(tt.level); got != tt.want { - t.Errorf("ToMessageType(%v) = %v, want %v", tt.level, tt.want, got) - } - }) - } -} diff --git a/workspace.go b/workspace.go index 3d39cd76..aacd5e8a 100644 --- a/workspace.go +++ b/workspace.go @@ -1,213 +1,488 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// Copyright 2024 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol import ( - "strconv" - "go.lsp.dev/uri" ) -// WorkspaceFolder response of Workspace folders request. +// FileChangeType the file event type. +type FileChangeType uint32 + +const ( + // CreatedFileChangeType the file got created. + CreatedFileChangeType FileChangeType = 1 + + // ChangedFileChangeType the file got changed. + ChangedFileChangeType FileChangeType = 2 + + // DeletedFileChangeType the file got deleted. + DeletedFileChangeType FileChangeType = 3 +) + +type WatchKind uint32 + +const ( + // CreateWatchKind interested in create events. + CreateWatchKind WatchKind = 1 + + // ChangeWatchKind interested in change events. + ChangeWatchKind WatchKind = 2 + + // DeleteWatchKind interested in delete events. + DeleteWatchKind WatchKind = 4 +) + +// FileOperationPatternKind a pattern kind describing if a glob pattern matches a file a folder or both. +// +// @since 3.16.0 +type FileOperationPatternKind string + +const ( + // FileFileOperationPatternKind the pattern matches a file only. + FileFileOperationPatternKind FileOperationPatternKind = "file" + + // FolderFileOperationPatternKind the pattern matches a folder only. + FolderFileOperationPatternKind FileOperationPatternKind = "folder" +) + +// WorkspaceFolder a workspace folder inside a client. type WorkspaceFolder struct { - // URI is the associated URI for this workspace folder. - URI string `json:"uri"` + // URI the associated URI for this workspace folder. + URI uri.URI `json:"uri"` - // Name is the name of the workspace folder. Used to refer to this - // workspace folder in the user interface. + // Name the name of the workspace folder. Used to refer to this workspace folder in the user interface. Name string `json:"name"` } -// DidChangeWorkspaceFoldersParams params of DidChangeWorkspaceFolders notification. -type DidChangeWorkspaceFoldersParams struct { - // Event is the actual workspace folder change event. - Event WorkspaceFoldersChangeEvent `json:"event"` -} - -// WorkspaceFoldersChangeEvent is the workspace folder change event. +// WorkspaceFoldersChangeEvent the workspace folder change event. type WorkspaceFoldersChangeEvent struct { - // Added is the array of added workspace folders + // Added the array of added workspace folders. Added []WorkspaceFolder `json:"added"` - // Removed is the array of the removed workspace folders + // Removed the array of the removed workspace folders. Removed []WorkspaceFolder `json:"removed"` } -// DidChangeConfigurationParams params of DidChangeConfiguration notification. -type DidChangeConfigurationParams struct { - // Settings is the actual changed settings - Settings interface{} `json:"settings,omitempty"` +// DidChangeWorkspaceFoldersParams the parameters of a `workspace/didChangeWorkspaceFolders` notification. +type DidChangeWorkspaceFoldersParams struct { + // Event the actual workspace folder change event. + Event WorkspaceFoldersChangeEvent `json:"event"` +} + +type ConfigurationItem struct { + // ScopeURI the scope to get the configuration section for. + ScopeURI uri.URI `json:"scopeUri,omitempty"` + + // Section the configuration section asked for. + Section string `json:"section,omitempty"` } -// ConfigurationParams params of Configuration request. +// ConfigurationParams the parameters of a configuration request. type ConfigurationParams struct { Items []ConfigurationItem `json:"items"` } -// ConfigurationItem a ConfigurationItem consists of the configuration section to ask for and an additional scope URI. -// The configuration section ask for is defined by the server and doesn’t necessarily need to correspond to the configuration store used be the client. -// So a server might ask for a configuration cpp.formatterOptions but the client stores the configuration in a XML store layout differently. -// It is up to the client to do the necessary conversion. If a scope URI is provided the client should return the setting scoped to the provided resource. -// If the client for example uses EditorConfig to manage its settings the configuration should be returned for the passed resource URI. If the client can’t provide a configuration setting for a given scope then null need to be present in the returned array. -type ConfigurationItem struct { - // ScopeURI is the scope to get the configuration section for. - ScopeURI uri.URI `json:"scopeUri,omitempty"` +// FileCreate represents information on a file/folder create. +// +// @since 3.16.0 +type FileCreate struct { + // URI a file:// URI for the location of the file/folder being created. + // + // @since 3.16.0 + URI string `json:"uri"` +} - // Section is the configuration section asked for. - Section string `json:"section,omitempty"` +// CreateFilesParams the parameters sent in notifications/requests for user-initiated creation of files. +// +// @since 3.16.0 +type CreateFilesParams struct { + // Files an array of all files/folders created in this operation. + // + // @since 3.16.0 + Files []FileCreate `json:"files"` } -// DidChangeWatchedFilesParams params of DidChangeWatchedFiles notification. -type DidChangeWatchedFilesParams struct { - // Changes is the actual file events. - Changes []*FileEvent `json:"changes,omitempty"` +// ResourceOperation a generic resource operation. +type ResourceOperation struct { + // Kind the resource operation kind. + Kind string `json:"kind"` + + // AnnotationID an optional annotation identifier describing the operation. + AnnotationID *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` } -// FileEvent an event describing a file change. -type FileEvent struct { - // Type is the change type. - Type FileChangeType `json:"type"` +// DeleteFileOptions delete file options. +type DeleteFileOptions struct { + // Recursive delete the content recursively if a folder is denoted. + Recursive bool `json:"recursive,omitempty"` - // URI is the file's URI. - URI uri.URI `json:"uri"` + // IgnoreIfNotExists ignore the operation if the file doesn't exist. + IgnoreIfNotExists bool `json:"ignoreIfNotExists,omitempty"` } -// FileChangeType is the file event type. -type FileChangeType float64 +// DeleteFile delete file operation. +type DeleteFile struct { + // extends + ResourceOperation -const ( - // FileChangeTypeCreated is the file got created. - FileChangeTypeCreated FileChangeType = 1 - // FileChangeTypeChanged is the file got changed. - FileChangeTypeChanged FileChangeType = 2 - // FileChangeTypeDeleted is the file got deleted. - FileChangeTypeDeleted FileChangeType = 3 -) + // URI the file to delete. + URI DocumentURI `json:"uri"` -// String implements fmt.Stringer. -func (t FileChangeType) String() string { - switch t { - case FileChangeTypeCreated: - return "Created" - case FileChangeTypeChanged: - return "Changed" - case FileChangeTypeDeleted: - return "Deleted" - default: - return strconv.FormatFloat(float64(t), 'f', -10, 64) - } -} - -// DidChangeWatchedFilesRegistrationOptions describe options to be used when registering for file system change events. -type DidChangeWatchedFilesRegistrationOptions struct { - // Watchers is the watchers to register. - Watchers []FileSystemWatcher `json:"watchers"` + // Options delete options. + Options *DeleteFileOptions `json:"options,omitempty"` } -// FileSystemWatcher watchers of DidChangeWatchedFiles Registration options. -type FileSystemWatcher struct { - // GlobPattern is the glob pattern to watch. - // - // Glob patterns can have the following syntax: - // - `*` to match one or more characters in a path segment - // - `?` to match on one character in a path segment - // - `**` to match any number of path segments, including none - // - `{}` to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files) - // - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - // - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) - GlobPattern string `json:"globPattern"` - - // Kind is the kind of events of interest. If omitted it defaults - // to WatchKind.Create | WatchKind.Change | WatchKind.Delete - // which is 7. - Kind WatchKind `json:"kind,omitempty"` +// RenameFileOptions rename file options. +type RenameFileOptions struct { + // Overwrite overwrite target if existing. Overwrite wins over `ignoreIfExists`. + Overwrite bool `json:"overwrite,omitempty"` + + // IgnoreIfExists ignores if target exists. + IgnoreIfExists bool `json:"ignoreIfExists,omitempty"` } -// WatchKind kind of FileSystemWatcher kind. -type WatchKind float64 +// RenameFile rename file operation. +type RenameFile struct { + // extends + ResourceOperation -const ( - // WatchKindCreate interested in create events. - WatchKindCreate WatchKind = 1 + // OldURI the old (existing) location. + OldURI DocumentURI `json:"oldUri"` - // WatchKindChange interested in change events. - WatchKindChange WatchKind = 2 + // NewURI the new location. + NewURI DocumentURI `json:"newUri"` - // WatchKindDelete interested in delete events. - WatchKindDelete WatchKind = 4 -) + // Options rename options. + Options *RenameFileOptions `json:"options,omitempty"` +} + +// CreateFileOptions options to create a file. +type CreateFileOptions struct { + // Overwrite overwrite existing file. Overwrite wins over `ignoreIfExists`. + Overwrite bool `json:"overwrite,omitempty"` + + // IgnoreIfExists ignore if exists. + IgnoreIfExists bool `json:"ignoreIfExists,omitempty"` +} + +// CreateFile create file operation. +type CreateFile struct { + // extends + ResourceOperation -// String implements fmt.Stringer. -func (k WatchKind) String() string { - switch k { - case WatchKindCreate: - return "Create" - case WatchKindChange: - return "Change" - case WatchKindDelete: - return "Delete" - default: - return strconv.FormatFloat(float64(k), 'f', -10, 64) - } -} - -// WorkspaceSymbolParams is the parameters of a Workspace Symbol request. + // URI the resource to create. + URI DocumentURI `json:"uri"` + + // Options additional options. + Options *CreateFileOptions `json:"options,omitempty"` +} + +// FileOperationPatternOptions matching options for the file operation pattern. +// +// @since 3.16.0 +type FileOperationPatternOptions struct { + // IgnoreCase the pattern should be matched ignoring casing. + // + // @since 3.16.0 + IgnoreCase bool `json:"ignoreCase,omitempty"` +} + +// FileOperationPattern a pattern to describe in which file operation requests or notifications the server is interested in receiving. +// +// @since 3.16.0 +type FileOperationPattern struct { + // Glob the glob pattern to match. Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`). + // + // @since 3.16.0 + Glob string `json:"glob"` + + // Matches whether to match files or folders with this pattern. Matches both if undefined. + // + // @since 3.16.0 + Matches FileOperationPatternKind `json:"matches,omitempty"` + + // Options additional options used during matching. + // + // @since 3.16.0 + Options *FileOperationPatternOptions `json:"options,omitempty"` +} + +// FileOperationFilter a filter to describe in which file operation requests or notifications the server is interested in receiving. +// +// @since 3.16.0 +type FileOperationFilter struct { + // Scheme a Uri scheme like `file` or `untitled`. + // + // @since 3.16.0 + Scheme string `json:"scheme,omitempty"` + + // Pattern the actual file operation pattern. + // + // @since 3.16.0 + Pattern FileOperationPattern `json:"pattern"` +} + +// FileOperationRegistrationOptions the options to register for file operations. +// +// @since 3.16.0 +type FileOperationRegistrationOptions struct { + // Filters the actual filters. + // + // @since 3.16.0 + Filters []FileOperationFilter `json:"filters"` +} + +// FileRename represents information on a file/folder rename. +// +// @since 3.16.0 +type FileRename struct { + // OldURI a file:// URI for the original location of the file/folder being renamed. + // + // @since 3.16.0 + OldURI string `json:"oldUri"` + + // NewURI a file:// URI for the new location of the file/folder being renamed. + // + // @since 3.16.0 + NewURI string `json:"newUri"` +} + +// RenameFilesParams the parameters sent in notifications/requests for user-initiated renames of files. +// +// @since 3.16.0 +type RenameFilesParams struct { + // Files an array of all files/folders renamed in this operation. When a folder is renamed, only the folder will be included, and not its children. + // + // @since 3.16.0 + Files []FileRename `json:"files"` +} + +// FileDelete represents information on a file/folder delete. +// +// @since 3.16.0 +type FileDelete struct { + // URI a file:// URI for the location of the file/folder being deleted. + // + // @since 3.16.0 + URI string `json:"uri"` +} + +// DeleteFilesParams the parameters sent in notifications/requests for user-initiated deletes of files. +// +// @since 3.16.0 +type DeleteFilesParams struct { + // Files an array of all files/folders deleted in this operation. + // + // @since 3.16.0 + Files []FileDelete `json:"files"` +} + +type DidChangeConfigurationClientCapabilities struct { + // DynamicRegistration did change configuration notification supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +type DidChangeWatchedFilesClientCapabilities struct { + // DynamicRegistration did change watched files notification supports dynamic registration. Please note that the current protocol doesn't support static configuration for file changes from the server side. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // RelativePatternSupport whether the client has support for RelativePattern relative pattern or not. + RelativePatternSupport bool `json:"relativePatternSupport,omitempty"` +} + +// ClientSymbolKindOptions. +// +// @since 3.18.0 +type ClientSymbolKindOptions struct { + // ValueSet the symbol kind values the client supports. When this property exists the client also guarantees that it will handle values outside its set gracefully and falls back to a default value when unknown. If this property is not present the client only supports the symbol kinds from `File` to `Array` as defined in the initial version of the protocol. + // + // @since 3.18.0 + ValueSet []SymbolKind `json:"valueSet,omitempty"` +} + +// ClientSymbolTagOptions. +// +// @since 3.18.0 +type ClientSymbolTagOptions struct { + // ValueSet the tags supported by the client. + // + // @since 3.18.0 + ValueSet []SymbolTag `json:"valueSet"` +} + +// ClientSymbolResolveOptions. +// +// @since 3.18.0 +type ClientSymbolResolveOptions struct { + // Properties the properties that a client can resolve lazily. Usually `location.range`. + // + // @since 3.18.0 + Properties []string `json:"properties"` +} + +// WorkspaceSymbolClientCapabilities client capabilities for a WorkspaceSymbolRequest. +type WorkspaceSymbolClientCapabilities struct { + // DynamicRegistration symbol request supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` + + // SymbolKind specific capabilities for the `SymbolKind` in the `workspace/symbol` request. + SymbolKind *ClientSymbolKindOptions `json:"symbolKind,omitempty"` + + // TagSupport the client supports tags on `SymbolInformation`. Clients supporting tags have to handle unknown tags + // gracefully. + TagSupport *ClientSymbolTagOptions `json:"tagSupport,omitempty"` + + // ResolveSupport the client support partial workspace symbols. The client will send the request `workspaceSymbol/resolve` to the server to resolve additional properties. + ResolveSupport *ClientSymbolResolveOptions `json:"resolveSupport,omitempty"` +} + +// ExecuteCommandClientCapabilities the client capabilities of a ExecuteCommandRequest. +type ExecuteCommandClientCapabilities struct { + // DynamicRegistration execute command supports dynamic registration. + DynamicRegistration bool `json:"dynamicRegistration,omitempty"` +} + +type WorkspaceFoldersServerCapabilities struct { + // Supported the server has support for workspace folders. + Supported bool `json:"supported,omitempty"` + + // ChangeNotifications whether the server wants to receive workspace folder change notifications. If a string is provided the string is treated as an ID under which the notification is registered on the client side. The ID can be used to unregister for these events using the `client/unregisterCapability` request. + ChangeNotifications *WorkspaceFoldersServerCapabilitiesChangeNotifications `json:"changeNotifications,omitempty"` +} + +// DidChangeConfigurationParams the parameters of a change configuration notification. +type DidChangeConfigurationParams struct { + // Settings the actual changed settings. + Settings any `json:"settings"` +} + +type DidChangeConfigurationRegistrationOptions struct { + Section *DidChangeConfigurationRegistrationOptionsSection `json:"section,omitempty"` +} + +// FileEvent an event describing a file change. +type FileEvent struct { + // URI the file's uri. + URI DocumentURI `json:"uri"` + + // Type the change type. + Type FileChangeType `json:"type"` +} + +// DidChangeWatchedFilesParams the watched files change notification's parameters. +type DidChangeWatchedFilesParams struct { + // Changes the actual file events. + Changes []FileEvent `json:"changes"` +} + +type FileSystemWatcher struct { + // GlobPattern the glob pattern to watch. See GlobPattern glob pattern for more detail. 3.17.0 support for relative + // patterns. + GlobPattern GlobPattern `json:"globPattern"` + + // Kind the kind of events of interest. If omitted it defaults to WatchKind.Create | WatchKind.Change | WatchKind.Delete which is . + Kind WatchKind `json:"kind,omitempty"` +} + +// DidChangeWatchedFilesRegistrationOptions describe options to be used when registered for text document change events. +type DidChangeWatchedFilesRegistrationOptions struct { + // Watchers the watchers to register. + Watchers []FileSystemWatcher `json:"watchers"` +} + +// WorkspaceSymbolParams the parameters of a WorkspaceSymbolRequest. type WorkspaceSymbolParams struct { + // mixins WorkDoneProgressParams PartialResultParams - // Query a query string to filter symbols by. - // - // Clients may send an empty string here to request all symbols. + // Query a query string to filter symbols by. Clients may send an empty string here to request all symbols. The `query`-parameter should be interpreted in a *relaxed way* as editors will apply their own highlighting and scoring on the results. A good rule of thumb is to match case-insensitive and to simply check that the characters of *query* appear in their order in a candidate symbol. Servers shouldn't use prefix, substring, or similar strict matching. Query string `json:"query"` } -// ExecuteCommandParams params of Execute a command. -type ExecuteCommandParams struct { - WorkDoneProgressParams +// WorkspaceSymbol a special workspace symbol that supports locations without a range. See also SymbolInformation. +// +// @since 3.17.0 +type WorkspaceSymbol struct { + // extends + BaseSymbolInformation - // Command is the identifier of the actual command handler. - Command string `json:"command"` + // Location the location of the symbol. Whether a server is allowed to return a location without a range depends + // on the client capability `workspace.symbol.resolveSupport`. See SymbolInformation#location for + // more details. + // + // @since 3.17.0 + Location WorkspaceSymbolLocation `json:"location"` - // Arguments that the command should be invoked with. - Arguments []interface{} `json:"arguments,omitempty"` + // Data a data entry field that is preserved on a workspace symbol between a workspace symbol request and a workspace symbol resolve request. + // + // @since 3.17.0 + Data any `json:"data,omitempty"` } -// ExecuteCommandRegistrationOptions execute command registration options. -type ExecuteCommandRegistrationOptions struct { - // Commands is the commands to be executed on the server - Commands []string `json:"commands"` +// WorkspaceSymbolRegistrationOptions registration options for a WorkspaceSymbolRequest. +type WorkspaceSymbolRegistrationOptions struct { + // extends + WorkspaceSymbolOptions } -// ApplyWorkspaceEditParams params of Applies a WorkspaceEdit. +// WorkspaceEditMetadata additional data about a workspace edit. 3.18.0 @proposed. +// +// @since 3.18.0 proposed +type WorkspaceEditMetadata struct { + // IsRefactoring signal to the editor that this edit is a refactoring. + // + // @since 3.18.0 proposed + IsRefactoring bool `json:"isRefactoring,omitempty"` +} + +// ApplyWorkspaceEditParams the parameters passed via an apply workspace edit request. type ApplyWorkspaceEditParams struct { - // Label an optional label of the workspace edit. This label is - // presented in the user interface for example on an undo - // stack to undo the workspace edit. + // Label an optional label of the workspace edit. This label is presented in the user interface for example on an undo stack to undo the workspace edit. Label string `json:"label,omitempty"` - // Edit is the edits to apply. + // Edit the edits to apply. Edit WorkspaceEdit `json:"edit"` + + // Metadata additional data about the edit. 3.18.0 @proposed. + Metadata *WorkspaceEditMetadata `json:"metadata,omitempty"` } -// ApplyWorkspaceEditResponse response of Applies a WorkspaceEdit. -type ApplyWorkspaceEditResponse struct { +// ApplyWorkspaceEditResult the result returned from the apply workspace edit request. 3.17 renamed from ApplyWorkspaceEditResponse. +// +// @since 3.17 renamed from ApplyWorkspaceEditResponse +type ApplyWorkspaceEditResult struct { // Applied indicates whether the edit was applied or not. + // + // @since 3.17 renamed from ApplyWorkspaceEditResponse Applied bool `json:"applied"` - // FailureReason an optional textual description for why the edit was not applied. - // This may be used by the server for diagnostic logging or to provide - // a suitable error for a request that triggered the edit. + // FailureReason an optional textual description for why the edit was not applied. This may be used by the server for + // diagnostic logging or to provide a suitable error for a request that triggered the edit. // - // @since 3.16.0. + // @since 3.17 renamed from ApplyWorkspaceEditResponse FailureReason string `json:"failureReason,omitempty"` - // FailedChange depending on the client's failure handling strategy "failedChange" - // might contain the index of the change that failed. This property is - // only available if the client signals a "failureHandlingStrategy" - // in its client capabilities. + // FailedChange depending on the client's failure handling strategy `failedChange` might contain the index of the change that failed. This property is only available if the client signals a `failureHandlingStrategy` in its client capabilities. // - // @since 3.16.0. + // @since 3.17 renamed from ApplyWorkspaceEditResponse FailedChange uint32 `json:"failedChange,omitempty"` } + +// RelativePattern a relative pattern is a helper to construct glob patterns that are matched relatively to a base URI. +// The common value for a `baseUri` is a workspace folder root, but it can be another absolute URI as well. +// +// @since 3.17.0 +type RelativePattern struct { + // BaseURI a workspace folder or a base URI to which this pattern will be matched against relatively. + // + // @since 3.17.0 + BaseURI RelativePatternBaseURI `json:"baseUri"` + + // Pattern the actual glob pattern;. + // + // @since 3.17.0 + Pattern Pattern `json:"pattern"` +} diff --git a/workspace_test.go b/workspace_test.go deleted file mode 100644 index bf96bec7..00000000 --- a/workspace_test.go +++ /dev/null @@ -1,1696 +0,0 @@ -// SPDX-FileCopyrightText: 2020 The Go Language Server Authors -// SPDX-License-Identifier: BSD-3-Clause - -package protocol - -import ( - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/segmentio/encoding/json" - - "go.lsp.dev/uri" -) - -func TestWorkspaceFolder(t *testing.T) { - t.Parallel() - - const ( - want = `{"uri":"/path/to/workspace","name":"testWorkspace"}` - wantInvalid = `{"uri":"/path/to/invalid","name":"invalidWorkspace"}` - ) - wantType := WorkspaceFolder{ - URI: "/path/to/workspace", - Name: "testWorkspace", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WorkspaceFolder - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WorkspaceFolder - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkspaceFolder - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDidChangeWorkspaceFoldersParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"event":{"added":[{"uri":"/path/to/addedWorkspace","name":"testAddedWorkspace"},{"uri":"/path/to/addedWorkspace2","name":"testAddedWorkspace2"}],"removed":[{"uri":"/path/to/removedWorkspace","name":"testRemovedWorkspace"},{"uri":"/path/to/removedWorkspace2","name":"testRemovedWorkspace2"}]}}` - wantInvalid = `{"event":{"added":[{"uri":"/path/to/addedInvalidWorkspace","name":"invalidAddedWorkspace"},{"uri":"/path/to/addedInvalidWorkspace2","name":"invalidAddedWorkspace2"}],"removed":[{"uri":"/path/to/removedInvalidWorkspace","name":"invalidRemovedWorkspace"},{"uri":"/path/to/removedInvalidWorkspace2","name":"invalidRemovedWorkspace2"}]}}` - ) - wantType := DidChangeWorkspaceFoldersParams{ - Event: WorkspaceFoldersChangeEvent{ - Added: []WorkspaceFolder{ - { - URI: "/path/to/addedWorkspace", - Name: "testAddedWorkspace", - }, - { - URI: "/path/to/addedWorkspace2", - Name: "testAddedWorkspace2", - }, - }, - Removed: []WorkspaceFolder{ - { - URI: "/path/to/removedWorkspace", - Name: "testRemovedWorkspace", - }, - { - URI: "/path/to/removedWorkspace2", - Name: "testRemovedWorkspace2", - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DidChangeWorkspaceFoldersParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DidChangeWorkspaceFoldersParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DidChangeWorkspaceFoldersParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWorkspaceFoldersChangeEvent(t *testing.T) { - t.Parallel() - - const ( - want = `{"added":[{"uri":"/path/to/addedWorkspace","name":"testAddedWorkspace"},{"uri":"/path/to/addedWorkspace2","name":"testAddedWorkspace2"}],"removed":[{"uri":"/path/to/removedWorkspace","name":"testRemovedWorkspace"},{"uri":"/path/to/removedWorkspace2","name":"testRemovedWorkspace2"}]}` - wantInvalid = `{"added":[{"uri":"/path/to/addedInvalidWorkspace","name":"invalidAddedWorkspace"},{"uri":"/path/to/addedInvalidWorkspace2","name":"invalidAddedWorkspace2"}],"removed":[{"uri":"/path/to/removedInvalidWorkspace","name":"invalidRemovedWorkspace"},{"uri":"/path/to/removedInvalidWorkspace2","name":"invalidRemovedWorkspace2"}]}` - ) - wantType := WorkspaceFoldersChangeEvent{ - Added: []WorkspaceFolder{ - { - URI: "/path/to/addedWorkspace", - Name: "testAddedWorkspace", - }, - { - URI: "/path/to/addedWorkspace2", - Name: "testAddedWorkspace2", - }, - }, - Removed: []WorkspaceFolder{ - { - URI: "/path/to/removedWorkspace", - Name: "testRemovedWorkspace", - }, - { - URI: "/path/to/removedWorkspace2", - Name: "testRemovedWorkspace2", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WorkspaceFoldersChangeEvent - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WorkspaceFoldersChangeEvent - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkspaceFoldersChangeEvent - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDidChangeConfigurationParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"settings":"testSettings"}` - wantNilAll = `{}` - wantInvalid = `{"settings":"invalidSettings"}` - ) - wantType := DidChangeConfigurationParams{ - Settings: "testSettings", - } - wantTypeNilAll := DidChangeConfigurationParams{} - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DidChangeConfigurationParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DidChangeConfigurationParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DidChangeConfigurationParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestConfigurationParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"items":[{"scopeUri":"file:///path/to/test.go","section":"testSection"}]}` - wantNilAll = `{"items":[]}` - wantInvalid = `{"items":[{"scopeUri":"file:///path/to/invalid.go","section":"invalidSection"}]}` - ) - wantType := ConfigurationParams{ - Items: []ConfigurationItem{ - { - ScopeURI: uri.File("/path/to/test.go"), - Section: "testSection", - }, - }, - } - wantTypeNilAll := ConfigurationParams{ - Items: []ConfigurationItem{}, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ConfigurationParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ConfigurationParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ConfigurationParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestConfigurationItem(t *testing.T) { - t.Parallel() - - const ( - want = `{"scopeUri":"file:///path/to/test.go","section":"testSection"}` - wantNilAll = `{}` - wantInvalid = `{"scopeUri":"file:///path/to/invalid.go","section":"invalidSection"}` - ) - wantType := ConfigurationItem{ - ScopeURI: uri.File("/path/to/test.go"), - Section: "testSection", - } - wantTypeNilAll := ConfigurationItem{} - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ConfigurationItem - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ConfigurationItem - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ConfigurationItem - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestDidChangeWatchedFilesParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"changes":[{"type":2,"uri":"file:///path/to/test.go"}]}` - wantNilAll = `{}` - wantInvalid = `{"changes":[{"type":3,"uri":"file:///path/to/invalid.go"}]}` - ) - wantType := DidChangeWatchedFilesParams{ - Changes: []*FileEvent{ - { - Type: FileChangeTypeChanged, - URI: uri.File("/path/to/test.go"), - }, - }, - } - wantTypeNilAll := DidChangeWatchedFilesParams{} - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DidChangeWatchedFilesParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DidChangeWatchedFilesParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DidChangeWatchedFilesParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestFileEvent(t *testing.T) { - t.Parallel() - - const ( - want = `{"type":2,"uri":"file:///path/to/test.go"}` - wantInvalid = `{"type":3,"uri":"file:///path/to/invalid.go"}` - ) - wantType := FileEvent{ - Type: FileChangeTypeChanged, - URI: uri.File("/path/to/test.go"), - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field FileEvent - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want FileEvent - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got FileEvent - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestFileChangeType_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k FileChangeType - want string - }{ - { - name: "Created", - k: FileChangeTypeCreated, - want: "Created", - }, - { - name: "Changed", - k: FileChangeTypeChanged, - want: "Changed", - }, - { - name: "Deleted", - k: FileChangeTypeDeleted, - want: "Deleted", - }, - { - name: "Unknown", - k: FileChangeType(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("FileChangeType.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestDidChangeWatchedFilesRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"watchers":[{"globPattern":"*","kind":2}]}` - wantNilAll = `{"watchers":[{"globPattern":"*"}]}` - wantInvalid = `{"watchers":[{"globPattern":"?","kind":1}]}` - ) - wantType := DidChangeWatchedFilesRegistrationOptions{ - Watchers: []FileSystemWatcher{ - { - GlobPattern: "*", - Kind: WatchKindChange, - }, - }, - } - wantTypeNilAll := DidChangeWatchedFilesRegistrationOptions{ - Watchers: []FileSystemWatcher{ - { - GlobPattern: "*", - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field DidChangeWatchedFilesRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want DidChangeWatchedFilesRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got DidChangeWatchedFilesRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestWatchKind_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - k WatchKind - want string - }{ - { - name: "CreateWatch", - k: WatchKindCreate, - want: "Create", - }, - { - name: "ChangeWatch", - k: WatchKindChange, - want: "Change", - }, - { - name: "DeleteWatch", - k: WatchKindDelete, - want: "Delete", - }, - { - name: "Unknown", - k: WatchKind(0), - want: "0", - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - if got := tt.k.String(); got != tt.want { - t.Errorf("WatchKind.String() = %v, want %v", tt.want, got) - } - }) - } -} - -func TestWorkspaceSymbolParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - wantPartialResultToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","partialResultToken":"` + wantPartialResultToken + `","query":"testQuery"}` - wantInvalid = `{"workDoneToken":"` + wantPartialResultToken + `","partialResultToken":"` + wantWorkDoneToken + `","query":"invalidQuery"}` - ) - wantType := WorkspaceSymbolParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - PartialResultParams: PartialResultParams{ - PartialResultToken: NewProgressToken(wantPartialResultToken), - }, - Query: "testQuery", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field WorkspaceSymbolParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want WorkspaceSymbolParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got WorkspaceSymbolParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - - if partialResultToken := got.PartialResultToken; partialResultToken != nil { - if diff := cmp.Diff(partialResultToken.String(), wantPartialResultToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestExecuteCommandParams(t *testing.T) { - t.Parallel() - - const ( - wantWorkDoneToken = "156edea9-9d8d-422f-b7ee-81a84594afbb" - invalidWorkDoneToken = "dd134d84-c134-4d7a-a2a3-f8af3ef4a568" - ) - const ( - want = `{"workDoneToken":"` + wantWorkDoneToken + `","command":"testCommand","arguments":["testArguments"]}` - wantNilAll = `{"command":"testCommand"}` - wantInvalid = `{"workDoneToken":"` + invalidWorkDoneToken + `","command":"invalidCommand","arguments":["invalidArguments"]}` - ) - wantType := ExecuteCommandParams{ - WorkDoneProgressParams: WorkDoneProgressParams{ - WorkDoneToken: NewProgressToken(wantWorkDoneToken), - }, - Command: "testCommand", - Arguments: []interface{}{ - "testArguments", - }, - } - wantTypeNilAll := ExecuteCommandParams{ - Command: "testCommand", - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ExecuteCommandParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ExecuteCommandParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ExecuteCommandParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreTypes(WorkDoneProgressParams{}, PartialResultParams{})); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - - if workDoneToken := got.WorkDoneToken; workDoneToken != nil { - if diff := cmp.Diff(workDoneToken.String(), wantWorkDoneToken); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - } - }) - } - }) -} - -func TestExecuteCommandRegistrationOptions(t *testing.T) { - t.Parallel() - - const ( - want = `{"commands":["testCommand","testCommand2"]}` - wantInvalid = `{"commands":["invalidCommand"]}` - ) - wantType := ExecuteCommandRegistrationOptions{ - Commands: []string{ - "testCommand", - "testCommand2", - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ExecuteCommandRegistrationOptions - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ExecuteCommandRegistrationOptions - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ExecuteCommandRegistrationOptions - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestApplyWorkspaceEditParams(t *testing.T) { - t.Parallel() - - const ( - want = `{"label":"testLabel","edit":{"changes":{"file:///path/to/basic.go":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]},"documentChanges":[{"textDocument":{"uri":"file:///path/to/basic.go","version":10},"edits":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]}]}}` - wantNilAll = `{"edit":{"changes":{"file:///path/to/basic.go":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]},"documentChanges":[{"textDocument":{"uri":"file:///path/to/basic.go","version":10},"edits":[{"range":{"start":{"line":25,"character":1},"end":{"line":27,"character":3}},"newText":"foo bar"}]}]}}` - wantInvalid = `{"label":"testLabel","edit":{"changes":{"file:///path/to/basic_gen.go":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"newText":"foo bar"}]},"documentChanges":[{"textDocument":{"uri":"file:///path/to/basic_gen.go","version":10},"edits":[{"range":{"start":{"line":2,"character":1},"end":{"line":3,"character":2}},"newText":"foo bar"}]}]}}` - ) - wantType := ApplyWorkspaceEditParams{ - Label: "testLabel", - Edit: WorkspaceEdit{ - Changes: map[uri.URI][]TextEdit{ - uri.File("/path/to/basic.go"): { - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - DocumentChanges: []TextDocumentEdit{ - { - TextDocument: OptionalVersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Version: NewVersion(int32(10)), - }, - Edits: []TextEdit{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - }, - }, - } - wantTypeNilAll := ApplyWorkspaceEditParams{ - Edit: WorkspaceEdit{ - Changes: map[uri.URI][]TextEdit{ - uri.File("/path/to/basic.go"): { - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - DocumentChanges: []TextDocumentEdit{ - { - TextDocument: OptionalVersionedTextDocumentIdentifier{ - TextDocumentIdentifier: TextDocumentIdentifier{ - URI: uri.File("/path/to/basic.go"), - }, - Version: NewVersion(int32(10)), - }, - Edits: []TextEdit{ - { - Range: Range{ - Start: Position{ - Line: 25, - Character: 1, - }, - End: Position{ - Line: 27, - Character: 3, - }, - }, - NewText: "foo bar", - }, - }, - }, - }, - }, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ApplyWorkspaceEditParams - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantTypeNilAll, - want: wantNilAll, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ApplyWorkspaceEditParams - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "ValidNilAll", - field: wantNilAll, - want: wantTypeNilAll, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ApplyWorkspaceEditParams - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} - -func TestApplyWorkspaceEditResponse(t *testing.T) { - t.Parallel() - - const ( - want = `{"applied":true,"failureReason":"testFailureReason","failedChange":1}` - wantInvalid = `{"applied":false}` - ) - wantType := ApplyWorkspaceEditResponse{ - Applied: true, - FailureReason: "testFailureReason", - FailedChange: 1, - } - - t.Run("Marshal", func(t *testing.T) { - tests := []struct { - name string - field ApplyWorkspaceEditResponse - want string - wantMarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: wantType, - want: want, - wantMarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantType, - want: wantInvalid, - wantMarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got, err := json.Marshal(&tt.field) - if (err != nil) != tt.wantMarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) - - t.Run("Unmarshal", func(t *testing.T) { - tests := []struct { - name string - field string - want ApplyWorkspaceEditResponse - wantUnmarshalErr bool - wantErr bool - }{ - { - name: "Valid", - field: want, - want: wantType, - wantUnmarshalErr: false, - wantErr: false, - }, - { - name: "Invalid", - field: wantInvalid, - want: wantType, - wantUnmarshalErr: false, - wantErr: true, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - var got ApplyWorkspaceEditResponse - if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr { - t.Fatal(err) - } - - if diff := cmp.Diff(tt.want, got); (diff != "") != tt.wantErr { - t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff) - } - }) - } - }) -} From 5c88785b45c04312264322951662f13bf7db6559 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Wed, 5 Feb 2025 16:54:36 +0900 Subject: [PATCH 13/19] WIP10 Signed-off-by: Koichi Shiraishi --- base.go | 2 +- basic.go | 2 +- document.go | 2 +- go.mod | 2 +- language.go | 33 +++++++++++++---------- lifecycle.go | 5 +++- tools/protocol-gen/generator/generator.go | 5 ++-- tools/protocol-gen/generator/structure.go | 1 + tools/protocol-gen/go.mod | 6 ++--- tools/protocol-gen/go.sum | 8 +++--- tools/protocol-gen/main.go | 2 +- type_alias.go | 5 ++-- window.go | 2 +- workspace.go | 2 +- 14 files changed, 42 insertions(+), 35 deletions(-) diff --git a/base.go b/base.go index 28c99bcd..d3ffbe88 100644 --- a/base.go +++ b/base.go @@ -1,4 +1,4 @@ -// Copyright 2024 The Go Language Server Authors +// Copyright 2025 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/basic.go b/basic.go index 93e85134..8d016699 100644 --- a/basic.go +++ b/basic.go @@ -1,4 +1,4 @@ -// Copyright 2024 The Go Language Server Authors +// Copyright 2025 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/document.go b/document.go index 07a8cdd6..36dee8c4 100644 --- a/document.go +++ b/document.go @@ -1,4 +1,4 @@ -// Copyright 2024 The Go Language Server Authors +// Copyright 2025 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/go.mod b/go.mod index 87901a24..ce2b5c33 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.22.2 require ( github.com/google/go-cmp v0.6.0 - github.com/segmentio/encoding v0.4.0 go.lsp.dev/jsonrpc2 v0.10.0 go.lsp.dev/uri v0.3.0 go.uber.org/zap v1.27.0 @@ -12,6 +11,7 @@ require ( require ( github.com/segmentio/asm v1.1.3 // indirect + github.com/segmentio/encoding v0.4.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect ) diff --git a/language.go b/language.go index eb59f58a..b99bd63b 100644 --- a/language.go +++ b/language.go @@ -1,4 +1,4 @@ -// Copyright 2024 The Go Language Server Authors +// Copyright 2025 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol @@ -432,14 +432,14 @@ const ( // ApplyKind defines how values from a set of defaults and an individual item will be merged. // // @since 3.18.0 -type ApplyKind string +type ApplyKind uint32 const ( // ReplaceApplyKind the value from the individual item (if provided and not `null`) will be used instead of the default. - ReplaceApplyKind ApplyKind = "replace" + ReplaceApplyKind ApplyKind = 1 // MergeApplyKind the value from the item will be merged with the default. The specific rules for mergeing values are defined against each field that supports merging. - MergeApplyKind ApplyKind = "merge" + MergeApplyKind ApplyKind = 2 ) // SignatureHelpTriggerKind how a signature help was triggered. @@ -1607,6 +1607,11 @@ type InlineCompletionRegistrationOptions struct { StaticRegistrationOptions } +type TextDocumentFilterClientCapabilities struct { + // RelativePatternSupport the client supports Relative Patterns. + RelativePatternSupport bool `json:"relativePatternSupport,omitempty"` +} + // CodeActionTagOptions. // // @since 3.18.0 - proposed @@ -1935,7 +1940,7 @@ type EditRangeWithInsertReplace struct { Replace Range `json:"replace"` } -// CompletionItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to "replace". Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability. +// CompletionItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to ApplyKind.Replace. Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability. // // @since 3.17.0 type CompletionItemDefaults struct { @@ -1960,16 +1965,16 @@ type CompletionItemDefaults struct { Data any `json:"data,omitempty"` } -// CompletionItemApplyKinds specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as "replace". If a field's value is "replace", the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is "merge", the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability. +// CompletionItemApplyKinds specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as ApplyKind.Replace. If a field's value is ApplyKind.Replace, the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is ApplyKind.Merge, the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability. // // @since 3.18.0 type CompletionItemApplyKinds struct { - // CommitCharacters specifies whether commitCharacters on a completion will replace or be merged with those in `completionList.itemDefaults.commitCharacters`. If "replace", the commit characters from the completion item will always be used unless not provided, in which case those from `completionList.itemDefaults.commitCharacters` will be used. An empty list can be used if a completion item does not have any commit characters and also should not use those from `completionList.itemDefaults.commitCharacters`. If "merge" the commitCharacters for the completion will be the union of all values in both `completionList.itemDefaults.commitCharacters` and the completion's own `commitCharacters`. + // CommitCharacters specifies whether commitCharacters on a completion will replace or be merged with those in `completionList.itemDefaults.commitCharacters`. If ApplyKind.Replace, the commit characters from the completion item will always be used unless not provided, in which case those from `completionList.itemDefaults.commitCharacters` will be used. An empty list can be used if a completion item does not have any commit characters and also should not use those from `completionList.itemDefaults.commitCharacters`. + // If ApplyKind.Merge the commitCharacters for the completion will be the union of all values in both `completionList.itemDefaults.commitCharacters` and the completion's own `commitCharacters`. // @since 3.18.0 CommitCharacters ApplyKind `json:"commitCharacters,omitempty"` - // Data specifies whether the `data` field on a completion will replace or be merged with data from `completionList.itemDefaults.data`. If "replace", the data from the completion item will be used if provided - // (and not `null`), otherwise `completionList.itemDefaults.data` will be used. An empty object can be used if a completion item does not have any data but also should not use the value from `completionList.itemDefaults.data`. If "merge", a shallow merge will be performed between `completionList.itemDefaults.data` and the completion's own data using the following rules: - If a completion's `data` field is not provided (or `null`), the entire `data` field from `completionList.itemDefaults.data` will be used as-is. - If a completion's `data` field is provided, each field will overwrite the field of the same name in `completionList.itemDefaults.data` but no merging of nested fields within that value will occur. + // Data specifies whether the `data` field on a completion will replace or be merged with data from `completionList.itemDefaults.data`. If ApplyKind.Replace, the data from the completion item will be used if provided (and not `null`), otherwise `completionList.itemDefaults.data` will be used. An empty object can be used if a completion item does not have any data but also should not use the value from `completionList.itemDefaults.data`. If ApplyKind.Merge, a shallow merge will be performed between `completionList.itemDefaults.data` and the completion's own data using the following rules: - If a completion's `data` field is not provided (or `null`), the entire `data` field from `completionList.itemDefaults.data` will be used as-is. - If a completion's `data` field is provided, each field will overwrite the field of the same name in `completionList.itemDefaults.data` but no merging of nested fields within that value will occur. // @since 3.18.0 Data ApplyKind `json:"data,omitempty"` } @@ -1979,10 +1984,10 @@ type CompletionList struct { // IsIncomplete this list it not complete. Further typing results in recomputing this list. Recomputed lists have all their items replaced (not appended) in the incomplete completion sessions. IsIncomplete bool `json:"isIncomplete"` - // ItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to "replace". Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability. + // ItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to ApplyKind.Replace. Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability. ItemDefaults *CompletionItemDefaults `json:"itemDefaults,omitempty"` - // ApplyKind specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as "replace". If a field's value is "replace", the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is "merge", the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability. + // ApplyKind specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as ApplyKind.Replace. If a field's value is ApplyKind.Replace, the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is ApplyKind.Merge, the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability. ApplyKind *CompletionItemApplyKinds `json:"applyKind,omitempty"` // Items the completion items. @@ -2745,7 +2750,7 @@ type TextDocumentFilterLanguage struct { // @since 3.18.0 Scheme string `json:"scheme,omitempty"` - // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. Whether clients support relative patterns depends on the client capability `textDocuments.filters.relativePatternSupport`. // @since 3.18.0 Pattern *GlobPattern `json:"pattern,omitempty"` } @@ -2764,7 +2769,7 @@ type TextDocumentFilterScheme struct { // @since 3.18.0 Scheme string `json:"scheme"` - // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. Whether clients support relative patterns depends on the client capability `textDocuments.filters.relativePatternSupport`. // @since 3.18.0 Pattern *GlobPattern `json:"pattern,omitempty"` } @@ -2783,7 +2788,7 @@ type TextDocumentFilterPattern struct { // @since 3.18.0 Scheme string `json:"scheme,omitempty"` - // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. + // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. Whether clients support relative patterns depends on the client capability `textDocuments.filters.relativePatternSupport`. // @since 3.18.0 Pattern GlobPattern `json:"pattern"` } diff --git a/lifecycle.go b/lifecycle.go index 01da8be9..4b9c5e47 100644 --- a/lifecycle.go +++ b/lifecycle.go @@ -1,4 +1,4 @@ -// Copyright 2024 The Go Language Server Authors +// Copyright 2025 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol @@ -883,6 +883,9 @@ type TextDocumentClientCapabilities struct { // Synchronization defines which synchronization capabilities the client supports. Synchronization *TextDocumentSyncClientCapabilities `json:"synchronization,omitempty"` + // Filters defines which filters the client supports. + Filters *TextDocumentFilterClientCapabilities `json:"filters,omitempty"` + // Completion capabilities specific to the `textDocument/completion` request. Completion *CompletionClientCapabilities `json:"completion,omitempty"` diff --git a/tools/protocol-gen/generator/generator.go b/tools/protocol-gen/generator/generator.go index f0a1193e..0e404a88 100644 --- a/tools/protocol-gen/generator/generator.go +++ b/tools/protocol-gen/generator/generator.go @@ -118,7 +118,7 @@ func (gen *Generator) writeTo(pp []Printer) (err error) { gen.files[filename] = f // Writes header content to the file at first - f.WriteString(`// Copyright 2024 The Go Language Server Authors` + "\n") + f.WriteString(`// Copyright 2025 The Go Language Server Authors` + "\n") f.WriteString(`// SPDX-License-Identifier: BSD-3-Clause` + "\n") f.WriteString("\n") f.WriteString(`package protocol` + "\n") @@ -238,8 +238,7 @@ func (p *printer) WriteTo() (err error) { } func normalizeMethodName(methName string) (methIdent string) { - pairs := strings.Split(methName, "/") - for _, s := range pairs { + for s := range strings.SplitSeq(methName, "/") { methIdent += flect.Pascalize(s) } diff --git a/tools/protocol-gen/generator/structure.go b/tools/protocol-gen/generator/structure.go index f5a5849b..01d360c8 100644 --- a/tools/protocol-gen/generator/structure.go +++ b/tools/protocol-gen/generator/structure.go @@ -384,6 +384,7 @@ var structureNames = map[string]string{ "TextDocumentFilterLanguage": "language", "TextDocumentFilterScheme": "language", "TextDocumentFilterPattern": "language", + "TextDocumentFilterClientCapabilities": "language", "NotebookDocumentFilterNotebookType": "document", "NotebookDocumentFilterScheme": "document", "NotebookDocumentFilterPattern": "document", diff --git a/tools/protocol-gen/go.mod b/tools/protocol-gen/go.mod index 1b1ee2e8..348f17b3 100644 --- a/tools/protocol-gen/go.mod +++ b/tools/protocol-gen/go.mod @@ -1,9 +1,9 @@ module go.lsp.dev/protocol/tools/protocol-gen -go 1.23 +go 1.24 require ( - github.com/gobuffalo/flect v1.0.2 + github.com/gobuffalo/flect v1.0.3 github.com/kortschak/utter v1.7.0 - golang.org/x/text v0.14.0 + golang.org/x/text v0.22.0 ) diff --git a/tools/protocol-gen/go.sum b/tools/protocol-gen/go.sum index fbb0c80c..cee2a68f 100644 --- a/tools/protocol-gen/go.sum +++ b/tools/protocol-gen/go.sum @@ -1,8 +1,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= -github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= +github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= +github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/kortschak/utter v1.7.0 h1:6NKMynvGUyqfeMTawfah4zyInlrgwzjkDAHrT+skx/w= github.com/kortschak/utter v1.7.0/go.mod h1:vSmSjbyrlKjjsL71193LmzBOKgwePk9DH6uFaWHIInc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -14,8 +14,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/tools/protocol-gen/main.go b/tools/protocol-gen/main.go index 63b883c9..77a3e43e 100644 --- a/tools/protocol-gen/main.go +++ b/tools/protocol-gen/main.go @@ -22,7 +22,7 @@ import ( const ( LSPSchemaURI = "https://github.com/microsoft/lsprotocol/raw/%s/generator/lsp.json" - schemaVersion = "v2024.0.0b1" + schemaVersion = "main" ) func init() { diff --git a/type_alias.go b/type_alias.go index 80915267..3b1aab3b 100644 --- a/type_alias.go +++ b/type_alias.go @@ -155,10 +155,9 @@ func (t *GlobPattern) UnmarshalJSON(val []byte) error { return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} } -// DocumentFilter a document filter describes a top level text document or a notebook cell document. 3.17.0 - proposed -// support for NotebookCellTextDocumentFilter. +// DocumentFilter a document filter describes a top level text document or a notebook cell document. 3.17.0 - support for NotebookCellTextDocumentFilter. // -// @since 3.17.0 - proposed support for NotebookCellTextDocumentFilter. +// @since 3.17.0 - support for NotebookCellTextDocumentFilter. type DocumentFilter struct { value any } diff --git a/window.go b/window.go index 6527f4d0..91c7a86b 100644 --- a/window.go +++ b/window.go @@ -1,4 +1,4 @@ -// Copyright 2024 The Go Language Server Authors +// Copyright 2025 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/workspace.go b/workspace.go index aacd5e8a..ed807bf4 100644 --- a/workspace.go +++ b/workspace.go @@ -1,4 +1,4 @@ -// Copyright 2024 The Go Language Server Authors +// Copyright 2025 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol From 8039a9213a1800b1a2f60806da1b6f2e4db9e1b7 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Tue, 4 Mar 2025 00:05:46 +0900 Subject: [PATCH 14/19] WIP11 Signed-off-by: Koichi Shiraishi --- generics.go | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++ protocol.go | 15 ++++ 2 files changed, 210 insertions(+) create mode 100644 generics.go diff --git a/generics.go b/generics.go new file mode 100644 index 00000000..59279d18 --- /dev/null +++ b/generics.go @@ -0,0 +1,195 @@ +package protocol + +import ( + "bytes" + "fmt" +) + +// Nil represents a empty sturct that is provides nil type. +type Nil struct{} + +var ( + trueBytes = []byte("true") + falseBytes = []byte("false") + nullBytes = []byte("null") +) + +// OneOf represents a JSON-unmarshals as either a T or a U. +type OneOf[T, U any] struct { + // The underlying value + value any +} + +var ( + _ Marshaler = (*OneOf[any, any])(nil) + _ Unmarshaler = (*OneOf[any, any])(nil) +) + +// Any returns the underlying value. +func (o *OneOf[T, U]) Any() any { + if o == nil { + return nil + } + return o.value +} + +// MarshalJSON implements [Marshaler]. +func (o *OneOf[T, U]) MarshalJSON() ([]byte, error) { + if o == nil { + return nullBytes, nil + } + return marshal(o.value) +} + +// UnmarshalJSON implements [Unmarshaler]. +func (o *OneOf[T, U]) UnmarshalJSON(data []byte) error { + if bytes.Equal(data, nullBytes) { + return nil + } + + // Try to unmarshal as T + var valueT T + errT := unmarshal(data, &valueT) + if errT == nil { + o.value = valueT + return nil + } + + // Try to unmarshal as U + var valueU U + errU := unmarshal(data, &valueU) + if errU == nil { + o.value = valueU + return nil + } + + return fmt.Errorf("cannot unmarshal to either type: %v or %v", errT, errU) +} + +// OneOf3 represents a JSON-unmarshals as either a T, U or V. +type OneOf3[T, U, V any] struct { + // The underlying value + value any +} + +var ( + _ Marshaler = (*OneOf3[any, any, any])(nil) + _ Unmarshaler = (*OneOf3[any, any, any])(nil) +) + +// Any returns the underlying value. +func (o *OneOf3[T, U, V]) Any() any { + if o == nil { + return nil + } + return o.value +} + +// MarshalJSON implements [Marshaler]. +func (o *OneOf3[T, U, V]) MarshalJSON() ([]byte, error) { + if o == nil { + return nullBytes, nil + } + return marshal(o.value) +} + +// UnmarshalJSON implements [Unmarshaler]. +func (o *OneOf3[T, U, V]) UnmarshalJSON(data []byte) error { + if bytes.Equal(data, nullBytes) { + return nil + } + + // Try to unmarshal as T + var valueT T + errT := unmarshal(data, &valueT) + if errT == nil { + o.value = valueT + return nil + } + + // Try to unmarshal as U + var valueU U + errU := unmarshal(data, &valueU) + if errU == nil { + o.value = valueU + return nil + } + + // Try to unmarshal as V + var valueV V + errV := unmarshal(data, &valueV) + if errV == nil { + o.value = valueV + return nil + } + + return fmt.Errorf("cannot unmarshal to either type: %v or %v or %v", errT, errU, errV) +} + +// OneOf4 represents a JSON-unmarshals as either a T, U, V or V. +type OneOf4[T, U, V, Y any] struct { + // The underlying value + value any +} + +var ( + _ Marshaler = (*OneOf4[any, any, any, any])(nil) + _ Unmarshaler = (*OneOf4[any, any, any, any])(nil) +) + +// Any returns the underlying value. +func (o *OneOf4[T, U, V, Y]) Any() any { + if o == nil { + return nil + } + return o.value +} + +// MarshalJSON implements [Marshaler]. +func (o *OneOf4[T, U, V, Y]) MarshalJSON() ([]byte, error) { + if o == nil { + return nullBytes, nil + } + return marshal(o.value) +} + +// UnmarshalJSON implements [Unmarshaler]. +func (o *OneOf4[T, U, V, Y]) UnmarshalJSON(data []byte) error { + if bytes.Equal(data, nullBytes) { + return nil + } + + // Try to unmarshal as T + var valueT T + errT := unmarshal(data, &valueT) + if errT == nil { + o.value = valueT + return nil + } + + // Try to unmarshal as U + var valueU U + errU := unmarshal(data, &valueU) + if errU == nil { + o.value = valueU + return nil + } + + // Try to unmarshal as V + var valueV V + errV := unmarshal(data, &valueV) + if errV == nil { + o.value = valueV + return nil + } + + // Try to unmarshal as V + var valueY Y + errY := unmarshal(data, &valueY) + if errY == nil { + o.value = valueV + return nil + } + + return fmt.Errorf("cannot unmarshal to either type: %v or %v or %v or %v", errT, errU, errV, errY) +} diff --git a/protocol.go b/protocol.go index 236a0497..0c7ef286 100644 --- a/protocol.go +++ b/protocol.go @@ -13,6 +13,12 @@ import ( "go.lsp.dev/jsonrpc2" ) +// Marshaler is the interface implemented by types that +// can marshal themselves into valid JSON. +type Marshaler interface { + MarshalJSON() ([]byte, error) +} + // MarshalFunc function type of marshal JSON data. // // Default is used [json.Marshal]. @@ -24,6 +30,15 @@ func RegiserMarshaler(fn MarshalFunc) { marshal = fn } +// Unmarshaler is the interface implemented by types +// that can unmarshal a JSON description of themselves. +// The input can be assumed to be a valid encoding of +// a JSON value. UnmarshalJSON must copy the JSON data +// if it wishes to retain the data after returning. +type Unmarshaler interface { + UnmarshalJSON([]byte) error +} + // UnmarshalFunc function type of unmarshal JSON data. // // Default is used [json.Unmarshal]. From c9204e3a73d5ade9a2efd8602fe9d3763aeb7f54 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Tue, 4 Mar 2025 00:09:35 +0900 Subject: [PATCH 15/19] all: fix licence header Signed-off-by: Koichi Shiraishi --- base_test.go | 2 +- client.go | 2 +- context.go | 2 +- doc.go | 2 +- generics.go | 3 +++ handler.go | 2 +- lifecycle_test.go | 3 +++ log.go | 2 +- protocol.go | 2 +- server.go | 2 +- version.go | 2 +- 11 files changed, 15 insertions(+), 9 deletions(-) diff --git a/base_test.go b/base_test.go index de5351b5..04d6bbfc 100644 --- a/base_test.go +++ b/base_test.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors +// Copyright 2021 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/client.go b/client.go index 605cb62d..c55f79e9 100644 --- a/client.go +++ b/client.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// Copyright 2019 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/context.go b/context.go index 81ccb888..6bd645a5 100644 --- a/context.go +++ b/context.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2020 The Go Language Server Authors +// Copyright 2020 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/doc.go b/doc.go index ccb35623..247423c9 100644 --- a/doc.go +++ b/doc.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// Copyright 2019 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause // Package protocol implements Language Server Protocol specification in Go. diff --git a/generics.go b/generics.go index 59279d18..f68790da 100644 --- a/generics.go +++ b/generics.go @@ -1,3 +1,6 @@ +// Copyright 2025 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + package protocol import ( diff --git a/handler.go b/handler.go index df4dea48..034000c6 100644 --- a/handler.go +++ b/handler.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors +// Copyright 2021 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/lifecycle_test.go b/lifecycle_test.go index 3b59cc56..add858c8 100644 --- a/lifecycle_test.go +++ b/lifecycle_test.go @@ -1,3 +1,6 @@ +// Copyright 2024 The Go Language Server Authors +// SPDX-License-Identifier: BSD-3-Clause + package protocol import ( diff --git a/log.go b/log.go index 0b7c9aaf..b99464e0 100644 --- a/log.go +++ b/log.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2021 The Go Language Server Authors +// Copyright 2021 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/protocol.go b/protocol.go index 0c7ef286..d5702d5a 100644 --- a/protocol.go +++ b/protocol.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// Copyright 2019 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/server.go b/server.go index aa287d54..5cd8aeb8 100644 --- a/server.go +++ b/server.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019 The Go Language Server Authors +// Copyright 2019 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol diff --git a/version.go b/version.go index 79a27f34..d117cb8b 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2018 The Go Language Server Authors +// Copyright 2018 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol From 7d674aa20f12f6125aae11fe588eb94f8415f9ef Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Tue, 4 Mar 2025 00:28:16 +0900 Subject: [PATCH 16/19] WIP12 Signed-off-by: Koichi Shiraishi --- base.go | 2 +- basic.go | 6 +- client_interface.go | 1 - document.go | 8 +-- go.mod | 4 +- go.sum | 4 +- handler.go | 2 +- language.go | 37 ++++++------ lifecycle.go | 63 +++++++++++---------- server_interface.go | 1 - tools/protocol-gen/generator/structure.go | 24 +++++++- type_alias.go | 13 ----- types_generics.go | 69 ----------------------- workspace.go | 8 +-- 14 files changed, 92 insertions(+), 150 deletions(-) diff --git a/base.go b/base.go index d3ffbe88..8d6d8524 100644 --- a/base.go +++ b/base.go @@ -45,7 +45,7 @@ const ( type CancelParams struct { // ID the request id to cancel. - ID CancelParamsID `json:"id"` + ID OneOf[int32, string] `json:"id"` } type ProgressParams struct { diff --git a/basic.go b/basic.go index 8d016699..e43df146 100644 --- a/basic.go +++ b/basic.go @@ -370,7 +370,7 @@ type TextDocumentEdit struct { TextDocument OptionalVersionedTextDocumentIdentifier `json:"textDocument"` // Edits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. - Edits TextDocumentEditEdits `json:"edits"` + Edits OneOf3[TextEdit, AnnotatedTextEdit, SnippetTextEdit] `json:"edits"` } // ChangeAnnotation additional information that describes document changes. @@ -401,7 +401,7 @@ type WorkspaceEdit struct { // DocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are // either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. - DocumentChanges *WorkspaceEditDocumentChanges `json:"documentChanges,omitempty"` + DocumentChanges *OneOf4[TextDocumentEdit, CreateFile, RenameFile, DeleteFile] `json:"documentChanges,omitempty"` // ChangeAnnotations a map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and delete file / folder operations. Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`. ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"` @@ -463,7 +463,7 @@ type Diagnostic struct { Severity DiagnosticSeverity `json:"severity,omitempty"` // Code the diagnostic's code, which usually appear in the user interface. - Code *DiagnosticCode `json:"code,omitempty"` + Code *OneOf[int32, string] `json:"code,omitempty"` // CodeDescription an optional property to describe the error code. Requires the code field (above) to be present/not null. CodeDescription *CodeDescription `json:"codeDescription,omitempty"` diff --git a/client_interface.go b/client_interface.go index 02daa661..20d5f287 100644 --- a/client_interface.go +++ b/client_interface.go @@ -147,7 +147,6 @@ func (UnimplementedClient) LogMessage(ctx context.Context, params *LogMessagePar func (UnimplementedClient) ShowMessage(ctx context.Context, params *ShowMessageParams) error { return jsonrpc2.ErrInternal } - func (UnimplementedClient) Registration(ctx context.Context, params *RegistrationParams) error { return jsonrpc2.ErrInternal } diff --git a/document.go b/document.go index 36dee8c4..999f83a2 100644 --- a/document.go +++ b/document.go @@ -128,7 +128,7 @@ type NotebookDocumentFilterWithCells struct { // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. // // @since 3.18.0 - Notebook *NotebookDocumentFilterWithCellsNotebook `json:"notebook,omitempty"` + Notebook *OneOf[string, NotebookDocumentFilter] `json:"notebook,omitempty"` // Cells the cells of the matching notebook to be synced. // @@ -143,7 +143,7 @@ type NotebookDocumentFilterWithNotebook struct { // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. // // @since 3.18.0 - Notebook NotebookDocumentFilterWithNotebookNotebook `json:"notebook"` + Notebook OneOf[string, NotebookDocumentFilter] `json:"notebook"` // Cells the cells of the matching notebook to be synced. // @@ -159,7 +159,7 @@ type NotebookDocumentSyncOptions struct { // NotebookSelector the notebooks to be synced. // // @since 3.17.0 - NotebookSelector NotebookDocumentSyncOptionsNotebookSelector `json:"notebookSelector"` + NotebookSelector OneOf[NotebookDocumentFilterWithNotebook, NotebookDocumentFilterWithCells] `json:"notebookSelector"` // Save whether save notification should be forwarded to the server. Will only be honored if mode === `notebook`. // @@ -349,7 +349,7 @@ type TextDocumentSyncOptions struct { WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` // Save if present save notifications are sent to the server. If omitted the notification should not be sent. - Save *TextDocumentSyncOptionsSave `json:"save,omitempty"` + Save *OneOf[bool, SaveOptions] `json:"save,omitempty"` } // DidOpenTextDocumentParams the parameters sent in an open text document notification. diff --git a/go.mod b/go.mod index ce2b5c33..1863e4af 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module go.lsp.dev/protocol -go 1.22.2 +go 1.23 require ( - github.com/google/go-cmp v0.6.0 + github.com/google/go-cmp v0.7.0 go.lsp.dev/jsonrpc2 v0.10.0 go.lsp.dev/uri v0.3.0 go.uber.org/zap v1.27.0 diff --git a/go.sum b/go.sum index 4241d3ae..273fff0e 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc= diff --git a/handler.go b/handler.go index 034000c6..cf9f7626 100644 --- a/handler.go +++ b/handler.go @@ -77,7 +77,7 @@ func notifyCancel(ctx context.Context, conn jsonrpc2.Conn, id jsonrpc2.ID) { ctx = context.WithoutCancel(ctx) // Note that only *jsonrpc2.ID implements json.Marshaler. cid := NewCancelParamsID(fmt.Sprint(id)) - conn.Notify(ctx, "$/cancelRequest", &CancelParams{ID: cid}) + conn.Notify(ctx, "$/cancelRequest", &CancelParams{ID: OneOf[int32, string](cid)}) } func replyParseError(ctx context.Context, reply jsonrpc2.Replier, err error) error { diff --git a/language.go b/language.go index b99bd63b..6d5feb96 100644 --- a/language.go +++ b/language.go @@ -909,12 +909,12 @@ type SemanticTokensOptions struct { // Range server supports providing semantic tokens for a specific range of a document. // // @since 3.16.0 - Range *SemanticTokensOptionsRange `json:"range,omitempty"` + Range *OneOf[bool, Range] `json:"range,omitempty"` // Full server supports providing semantic tokens for a full document. // // @since 3.16.0 - Full *SemanticTokensOptionsFull `json:"full,omitempty"` + Full *OneOf[bool, SemanticTokensFullDelta] `json:"full,omitempty"` } // SemanticTokensRegistrationOptions. @@ -1272,7 +1272,7 @@ type InlayHintLabelPart struct { // Tooltip the tooltip text when you hover over this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. // // @since 3.17.0 - Tooltip *InlayHintLabelPartTooltip `json:"tooltip,omitempty"` + Tooltip *OneOf[string, MarkupContent] `json:"tooltip,omitempty"` // Location an optional source code location that represents this label part. The editor will use this location for the hover and for code navigation features: This part will become a clickable link that resolves // to the definition of the symbol at the given location (not necessarily the location itself), it shows the hover that shows at the given location, and it shows a context menu with further code navigation commands. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. @@ -1299,7 +1299,7 @@ type InlayHint struct { // Label the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty. // // @since 3.17.0 - Label InlayHintLabel `json:"label"` + Label OneOf[string, []InlayHintLabelPart] `json:"label"` // Kind the kind of this hint. Can be omitted in which case the client should fall back to a reasonable default. // @@ -1315,7 +1315,7 @@ type InlayHint struct { // Tooltip the tooltip text when you hover over this item. // // @since 3.17.0 - Tooltip *InlayHintTooltip `json:"tooltip,omitempty"` + Tooltip *OneOf[string, MarkupContent] `json:"tooltip,omitempty"` // PaddingLeft render padding before the hint. Note: Padding should use the editor's background color, not the background color of the hint itself. That means padding can be used to visually align/separate an inlay hint. // @@ -1411,7 +1411,7 @@ type FullDocumentDiagnosticReport struct { // @since 3.17.0 type DocumentDiagnosticReportPartialResult struct { // @since 3.17.0 - RelatedDocuments map[DocumentURI]DocumentDiagnosticReportPartialResultRelatedDocuments `json:"relatedDocuments"` + RelatedDocuments map[DocumentURI]OneOf[FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport] `json:"relatedDocuments"` } // DiagnosticServerCancellationData cancellation data returned from a diagnostic request. @@ -1560,7 +1560,7 @@ type InlineCompletionItem struct { // InsertText the text to replace the range with. Must be set. // // @since 3.18.0 proposed - InsertText InlineCompletionItemInsertText `json:"insertText"` + InsertText OneOf[string, StringValue] `json:"insertText"` // FilterText a text that is used to decide if this inline completion should be shown. When `falsy` the InlineCompletionItem.insertText is used. // @@ -1882,7 +1882,7 @@ type CompletionItem struct { Detail string `json:"detail,omitempty"` // Documentation a human-readable string that represents a doc-comment. - Documentation *CompletionItemDocumentation `json:"documentation,omitempty"` + Documentation *OneOf[string, MarkupContent] `json:"documentation,omitempty"` // Deprecated indicates if this item is deprecated. // @@ -1909,7 +1909,7 @@ type CompletionItem struct { InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"` // TextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`. - TextEdit *CompletionItemTextEdit `json:"textEdit,omitempty"` + TextEdit *OneOf[TextEdit, InsertReplaceEdit] `json:"textEdit,omitempty"` // TextEditText the edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range. Clients will only honor this property if they opt into completion list item defaults using the capability `completionList.itemDefaults`. If not provided and a list's default range is provided the label property is used as a text. TextEditText string `json:"textEditText,omitempty"` @@ -1950,7 +1950,7 @@ type CompletionItemDefaults struct { // EditRange a default edit range. // @since 3.17.0 - EditRange *CompletionItemDefaultsEditRange `json:"editRange,omitempty"` + EditRange *OneOf[Range, EditRangeWithInsertReplace] `json:"editRange,omitempty"` // InsertTextFormat a default insert text format. // @since 3.17.0 @@ -2012,7 +2012,7 @@ type HoverParams struct { // Hover the result of a hover request. type Hover struct { // Contents the hover's content. - Contents HoverContents `json:"contents"` + Contents OneOf3[MarkupContent, MarkedString, []MarkedString] `json:"contents"` // Range an optional range inside the text document that is used to visualize the hover, e.g. by changing the // background color. @@ -2030,10 +2030,13 @@ type HoverRegistrationOptions struct { type ParameterInformation struct { // Label the label of this parameter information. Either a string or an inclusive start and exclusive end offsets within its containing signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 string representation as `Position` and `Range` does. To avoid ambiguities a server should use the [start, end] offset value instead of using a substring. Whether a client support this is controlled via `labelOffsetSupport` client capability. *Note*: a label of type string should be a substring of its containing signature label. Its intended use case is to highlight the parameter label // part in the `SignatureInformation.label`. - Label ParameterInformationLabel `json:"label"` + Label OneOf[string, struct { + x uint32 + y uint32 + }] `json:"label"` // Documentation the human-readable doc-comment of this parameter. Will be shown in the UI but can be omitted. - Documentation *ParameterInformationDocumentation `json:"documentation,omitempty"` + Documentation *OneOf[string, MarkupContent] `json:"documentation,omitempty"` } // SignatureInformation represents the signature of something callable. A signature can have a label, like a function-name, a doc-comment, and a set of parameters. @@ -2042,7 +2045,7 @@ type SignatureInformation struct { Label string `json:"label"` // Documentation the human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. - Documentation *SignatureInformationDocumentation `json:"documentation,omitempty"` + Documentation *OneOf[string, MarkupContent] `json:"documentation,omitempty"` // Parameters the parameters of this signature. Parameters []ParameterInformation `json:"parameters,omitempty"` @@ -2608,7 +2611,7 @@ type RelatedFullDocumentDiagnosticReport struct { // RelatedDocuments 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]*RelatedFullDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` + RelatedDocuments map[DocumentURI]*OneOf[FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport] `json:"relatedDocuments,omitempty"` } // RelatedUnchangedDocumentDiagnosticReport an unchanged diagnostic report with a set of related documents. @@ -2620,7 +2623,7 @@ type RelatedUnchangedDocumentDiagnosticReport struct { // RelatedDocuments 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]*RelatedUnchangedDocumentDiagnosticReportRelatedDocuments `json:"relatedDocuments,omitempty"` + RelatedDocuments map[DocumentURI]*OneOf[FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport] `json:"relatedDocuments,omitempty"` } // PrepareRenamePlaceholder. @@ -2728,7 +2731,7 @@ type NotebookCellTextDocumentFilter struct { // Notebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. // // @since 3.17.0 - Notebook NotebookCellTextDocumentFilterNotebook `json:"notebook"` + Notebook OneOf[string, NotebookDocumentFilter] `json:"notebook"` // Language a language id like `python`. Will be matched against the language id of the notebook cell document. '*' matches every language. // diff --git a/lifecycle.go b/lifecycle.go index 4b9c5e47..81b7664b 100644 --- a/lifecycle.go +++ b/lifecycle.go @@ -728,12 +728,12 @@ type ClientSemanticTokensRequestOptions struct { // Range the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. // // @since 3.18.0 - Range *ClientSemanticTokensRequestOptionsRange `json:"range,omitempty"` + Range *OneOf[bool, Range] `json:"range,omitempty"` // Full the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. // // @since 3.18.0 - Full *ClientSemanticTokensRequestOptionsFull `json:"full,omitempty"` + Full *OneOf[bool, ClientSemanticTokensRequestFullDelta] `json:"full,omitempty"` } // SemanticTokensClientCapabilities. @@ -1224,7 +1224,7 @@ type WorkspaceOptions struct { // TextDocumentContent the server supports the `workspace/textDocumentContent` request. 3.18.0 @proposed. // @since 3.18.0 - TextDocumentContent *WorkspaceOptionsTextDocumentContent `json:"textDocumentContent,omitempty"` + TextDocumentContent *OneOf[TextDocumentContentOptions, TextDocumentContentRegistrationOptions] `json:"textDocumentContent,omitempty"` } // ServerCapabilities defines the capabilities provided by a language server. @@ -1233,43 +1233,43 @@ type ServerCapabilities struct { PositionEncoding PositionEncodingKind `json:"positionEncoding,omitempty"` // TextDocumentSync defines how text documents are synced. Is either a detailed structure defining each notification or for backwards compatibility the TextDocumentSyncKind number. - TextDocumentSync *ServerCapabilitiesTextDocumentSync `json:"textDocumentSync,omitempty"` + TextDocumentSync *OneOf[TextDocumentSyncOptions, TextDocumentSyncKind] `json:"textDocumentSync,omitempty"` // NotebookDocumentSync defines how notebook documents are synced. - NotebookDocumentSync *ServerCapabilitiesNotebookDocumentSync `json:"notebookDocumentSync,omitempty"` + NotebookDocumentSync *OneOf[NotebookDocumentSyncOptions, NotebookDocumentSyncRegistrationOptions] `json:"notebookDocumentSync,omitempty"` // CompletionProvider the server provides completion support. CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"` // HoverProvider the server provides hover support. - HoverProvider *ServerCapabilitiesHoverProvider `json:"hoverProvider,omitempty"` + HoverProvider *OneOf[bool, HoverOptions] `json:"hoverProvider,omitempty"` // SignatureHelpProvider the server provides signature help support. SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` // DeclarationProvider the server provides Goto Declaration support. - DeclarationProvider *ServerCapabilitiesDeclarationProvider `json:"declarationProvider,omitempty"` + DeclarationProvider *OneOf3[bool, DeclarationOptions, DeclarationRegistrationOptions] `json:"declarationProvider,omitempty"` // DefinitionProvider the server provides goto definition support. - DefinitionProvider *ServerCapabilitiesDefinitionProvider `json:"definitionProvider,omitempty"` + DefinitionProvider *OneOf[bool, DefinitionOptions] `json:"definitionProvider,omitempty"` // TypeDefinitionProvider the server provides Goto Type Definition support. - TypeDefinitionProvider *ServerCapabilitiesTypeDefinitionProvider `json:"typeDefinitionProvider,omitempty"` + TypeDefinitionProvider *OneOf3[bool, TypeDefinitionOptions, TypeDefinitionRegistrationOptions] `json:"typeDefinitionProvider,omitempty"` // ImplementationProvider the server provides Goto Implementation support. - ImplementationProvider *ServerCapabilitiesImplementationProvider `json:"implementationProvider,omitempty"` + ImplementationProvider *OneOf3[bool, ImplementationOptions, ImplementationRegistrationOptions] `json:"implementationProvider,omitempty"` // ReferencesProvider the server provides find references support. - ReferencesProvider *ServerCapabilitiesReferencesProvider `json:"referencesProvider,omitempty"` + ReferencesProvider *OneOf[bool, ReferenceOptions] `json:"referencesProvider,omitempty"` // DocumentHighlightProvider the server provides document highlight support. - DocumentHighlightProvider *ServerCapabilitiesDocumentHighlightProvider `json:"documentHighlightProvider,omitempty"` + DocumentHighlightProvider *OneOf[bool, DocumentHighlightOptions] `json:"documentHighlightProvider,omitempty"` // DocumentSymbolProvider the server provides document symbol support. - DocumentSymbolProvider *ServerCapabilitiesDocumentSymbolProvider `json:"documentSymbolProvider,omitempty"` + DocumentSymbolProvider *OneOf[bool, DocumentSymbolOptions] `json:"documentSymbolProvider,omitempty"` // CodeActionProvider the server provides code actions. CodeActionOptions may only be specified if the client states that it supports `codeActionLiteralSupport` in its initial `initialize` request. - CodeActionProvider *ServerCapabilitiesCodeActionProvider `json:"codeActionProvider,omitempty"` + CodeActionProvider *OneOf[bool, CodeActionOptions] `json:"codeActionProvider,omitempty"` // CodeLensProvider the server provides code lens. CodeLensProvider *CodeLensOptions `json:"codeLensProvider,omitempty"` @@ -1278,59 +1278,59 @@ type ServerCapabilities struct { DocumentLinkProvider *DocumentLinkOptions `json:"documentLinkProvider,omitempty"` // ColorProvider the server provides color provider support. - ColorProvider *ServerCapabilitiesColorProvider `json:"colorProvider,omitempty"` + ColorProvider *OneOf3[bool, DocumentColorOptions, DocumentColorRegistrationOptions] `json:"colorProvider,omitempty"` // WorkspaceSymbolProvider the server provides workspace symbol support. - WorkspaceSymbolProvider *ServerCapabilitiesWorkspaceSymbolProvider `json:"workspaceSymbolProvider,omitempty"` + WorkspaceSymbolProvider *OneOf[bool, WorkspaceSymbolOptions] `json:"workspaceSymbolProvider,omitempty"` // DocumentFormattingProvider the server provides document formatting. - DocumentFormattingProvider *ServerCapabilitiesDocumentFormattingProvider `json:"documentFormattingProvider,omitempty"` + DocumentFormattingProvider *OneOf[bool, DocumentFormattingOptions] `json:"documentFormattingProvider,omitempty"` // DocumentRangeFormattingProvider the server provides document range formatting. - DocumentRangeFormattingProvider *ServerCapabilitiesDocumentRangeFormattingProvider `json:"documentRangeFormattingProvider,omitempty"` + DocumentRangeFormattingProvider *OneOf[bool, DocumentRangeFormattingOptions] `json:"documentRangeFormattingProvider,omitempty"` // DocumentOnTypeFormattingProvider the server provides document formatting on typing. DocumentOnTypeFormattingProvider *DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"` // RenameProvider the server provides rename support. RenameOptions may only be specified if the client states that it // supports `prepareSupport` in its initial `initialize` request. - RenameProvider *ServerCapabilitiesRenameProvider `json:"renameProvider,omitempty"` + RenameProvider *OneOf[bool, RenameOptions] `json:"renameProvider,omitempty"` // FoldingRangeProvider the server provides folding provider support. - FoldingRangeProvider *ServerCapabilitiesFoldingRangeProvider `json:"foldingRangeProvider,omitempty"` + FoldingRangeProvider *OneOf3[bool, FoldingRangeOptions, FoldingRangeRegistrationOptions] `json:"foldingRangeProvider,omitempty"` // SelectionRangeProvider the server provides selection range support. - SelectionRangeProvider *ServerCapabilitiesSelectionRangeProvider `json:"selectionRangeProvider,omitempty"` + SelectionRangeProvider *OneOf3[bool, SelectionRangeOptions, SelectionRangeRegistrationOptions] `json:"selectionRangeProvider,omitempty"` // ExecuteCommandProvider the server provides execute command support. ExecuteCommandProvider *ExecuteCommandOptions `json:"executeCommandProvider,omitempty"` // CallHierarchyProvider the server provides call hierarchy support. - CallHierarchyProvider *ServerCapabilitiesCallHierarchyProvider `json:"callHierarchyProvider,omitempty"` + CallHierarchyProvider *OneOf3[bool, CallHierarchyOptions, CallHierarchyRegistrationOptions] `json:"callHierarchyProvider,omitempty"` // LinkedEditingRangeProvider the server provides linked editing range support. - LinkedEditingRangeProvider *ServerCapabilitiesLinkedEditingRangeProvider `json:"linkedEditingRangeProvider,omitempty"` + LinkedEditingRangeProvider *OneOf3[bool, LinkedEditingRangeOptions, LinkedEditingRangeRegistrationOptions] `json:"linkedEditingRangeProvider,omitempty"` // SemanticTokensProvider the server provides semantic tokens support. - SemanticTokensProvider *ServerCapabilitiesSemanticTokensProvider `json:"semanticTokensProvider,omitempty"` + SemanticTokensProvider *OneOf[SemanticTokensOptions, SemanticTokensRegistrationOptions] `json:"semanticTokensProvider,omitempty"` // MonikerProvider the server provides moniker support. - MonikerProvider *ServerCapabilitiesMonikerProvider `json:"monikerProvider,omitempty"` + MonikerProvider *OneOf3[bool, MonikerOptions, MonikerRegistrationOptions] `json:"monikerProvider,omitempty"` // TypeHierarchyProvider the server provides type hierarchy support. - TypeHierarchyProvider *ServerCapabilitiesTypeHierarchyProvider `json:"typeHierarchyProvider,omitempty"` + TypeHierarchyProvider *OneOf3[bool, TypeHierarchyOptions, TypeHierarchyRegistrationOptions] `json:"typeHierarchyProvider,omitempty"` // InlineValueProvider the server provides inline values. - InlineValueProvider *ServerCapabilitiesInlineValueProvider `json:"inlineValueProvider,omitempty"` + InlineValueProvider *OneOf3[bool, InlineValueOptions, InlineValueRegistrationOptions] `json:"inlineValueProvider,omitempty"` // InlayHintProvider the server provides inlay hints. - InlayHintProvider *ServerCapabilitiesInlayHintProvider `json:"inlayHintProvider,omitempty"` + InlayHintProvider *OneOf3[bool, InlayHintOptions, InlayHintRegistrationOptions] `json:"inlayHintProvider,omitempty"` // DiagnosticProvider the server has support for pull model diagnostics. - DiagnosticProvider *ServerCapabilitiesDiagnosticProvider `json:"diagnosticProvider,omitempty"` + DiagnosticProvider *OneOf[DiagnosticOptions, DiagnosticRegistrationOptions] `json:"diagnosticProvider,omitempty"` // InlineCompletionProvider inline completion options used during static registration. 3.18.0 @proposed. - InlineCompletionProvider *ServerCapabilitiesInlineCompletionProvider `json:"inlineCompletionProvider,omitempty"` + InlineCompletionProvider *OneOf[bool, InlineCompletionOptions] `json:"inlineCompletionProvider,omitempty"` // Workspace workspace specific server capabilities. Workspace *WorkspaceOptions `json:"workspace,omitempty"` @@ -1370,7 +1370,8 @@ type InitializeError struct { Retry bool `json:"retry"` } -type InitializedParams struct{} +type InitializedParams struct { +} type SetTraceParams struct { Value TraceValue `json:"value"` diff --git a/server_interface.go b/server_interface.go index fe6567c1..a07397a4 100644 --- a/server_interface.go +++ b/server_interface.go @@ -473,7 +473,6 @@ func (UnimplementedServer) DidDeleteFiles(ctx context.Context, params *DeleteFil func (UnimplementedServer) DidRenameFiles(ctx context.Context, params *RenameFilesParams) error { return jsonrpc2.ErrInternal } - func (UnimplementedServer) CallHierarchyIncomingCalls(ctx context.Context, params *CallHierarchyIncomingCallsParams) ([]*CallHierarchyIncomingCall, error) { return nil, jsonrpc2.ErrInternal } diff --git a/tools/protocol-gen/generator/structure.go b/tools/protocol-gen/generator/structure.go index 01d360c8..55555ef3 100644 --- a/tools/protocol-gen/generator/structure.go +++ b/tools/protocol-gen/generator/structure.go @@ -689,6 +689,28 @@ func (gen *Generator) renderStructuresMapType(g Printer, m *protocol.MapType, ge } func (gen *Generator) renderStructuresOrType(g Printer, or *protocol.OrType, genericsProp GenericsTypes) { - g.P(` `, genericsProp.Name) + var sb strings.Builder + switch len(or.Items) { + case 2: + sb.WriteString(` OneOf`) + case 3: + sb.WriteString(` OneOf3`) + case 4: + sb.WriteString(` OneOf4`) + default: + g.P(` `, genericsProp.Name, ` // or.Items: `, or.Items) + gen.genericsTypes[genericsProp] = or.Items + return + } + sb.WriteString(`[`) + for i, item := range or.Items { + sb.WriteString(item.String()) + if i < len(or.Items)-1 { + sb.WriteString(`,`) + } + } + sb.WriteString(`]`) + g.P(sb.String()) + gen.genericsTypes[genericsProp] = or.Items } diff --git a/type_alias.go b/type_alias.go index 3b1aab3b..cadca5a2 100644 --- a/type_alias.go +++ b/type_alias.go @@ -38,7 +38,6 @@ func (t NotebookDocumentFilter) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *NotebookDocumentFilter) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -88,7 +87,6 @@ func (t TextDocumentFilter) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *TextDocumentFilter) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -136,7 +134,6 @@ func (t GlobPattern) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *GlobPattern) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -179,7 +176,6 @@ func (t DocumentFilter) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *DocumentFilter) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -221,7 +217,6 @@ func (t MarkedString) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *MarkedString) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -262,7 +257,6 @@ func (t TextDocumentContentChangeEvent) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *TextDocumentContentChangeEvent) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -305,7 +299,6 @@ func (t WorkspaceDocumentDiagnosticReport) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *WorkspaceDocumentDiagnosticReport) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -348,7 +341,6 @@ func (t ProgressToken) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *ProgressToken) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -395,7 +387,6 @@ func (t PrepareRenameResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *PrepareRenameResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -443,7 +434,6 @@ func (t DocumentDiagnosticReport) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *DocumentDiagnosticReport) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -488,7 +478,6 @@ func (t InlineValue) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *InlineValue) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -537,7 +526,6 @@ func (t Declaration) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *Declaration) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -581,7 +569,6 @@ func (t Definition) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unkonwn type: %T", t) } - func (t *Definition) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil diff --git a/types_generics.go b/types_generics.go index 96a19860..0b31e5d2 100644 --- a/types_generics.go +++ b/types_generics.go @@ -31,7 +31,6 @@ func (t CancelParamsID) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *CancelParamsID) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -72,7 +71,6 @@ func (t ClientSemanticTokensRequestOptionsFull) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ClientSemanticTokensRequestOptionsFull) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -113,7 +111,6 @@ func (t ClientSemanticTokensRequestOptionsRange) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ClientSemanticTokensRequestOptionsRange) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -154,7 +151,6 @@ func (t CodeActionRequestResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *CodeActionRequestResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -197,7 +193,6 @@ func (t CompletionItemDefaultsEditRange) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *CompletionItemDefaultsEditRange) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -238,7 +233,6 @@ func (t CompletionItemDocumentation) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *CompletionItemDocumentation) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -281,7 +275,6 @@ func (t CompletionItemTextEdit) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *CompletionItemTextEdit) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -323,7 +316,6 @@ func (t CompletionResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *CompletionResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -365,7 +357,6 @@ func (t DeclarationResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *DeclarationResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -407,7 +398,6 @@ func (t DefinitionResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *DefinitionResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -448,7 +438,6 @@ func (t DiagnosticCode) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *DiagnosticCode) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -488,7 +477,6 @@ func (t DidChangeConfigurationRegistrationOptionsSection) MarshalJSON() ([]byte, } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *DidChangeConfigurationRegistrationOptionsSection) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -528,7 +516,6 @@ func (t DocumentDiagnosticReportPartialResultRelatedDocuments) MarshalJSON() ([] } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *DocumentDiagnosticReportPartialResultRelatedDocuments) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -570,7 +557,6 @@ func (t DocumentSymbolResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *DocumentSymbolResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -613,7 +599,6 @@ func (t HoverContents) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *HoverContents) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -660,7 +645,6 @@ func (t ImplementationResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ImplementationResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -701,7 +685,6 @@ func (t InlayHintLabel) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *InlayHintLabel) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -742,7 +725,6 @@ func (t InlayHintLabelPartTooltip) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *InlayHintLabelPartTooltip) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -783,7 +765,6 @@ func (t InlayHintTooltip) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *InlayHintTooltip) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -824,7 +805,6 @@ func (t InlineCompletionItemInsertText) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *InlineCompletionItemInsertText) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -867,7 +847,6 @@ func (t InlineCompletionResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *InlineCompletionResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -908,7 +887,6 @@ func (t NotebookCellTextDocumentFilterNotebook) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *NotebookCellTextDocumentFilterNotebook) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -949,7 +927,6 @@ func (t NotebookDocumentFilterWithCellsNotebook) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *NotebookDocumentFilterWithCellsNotebook) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -990,7 +967,6 @@ func (t NotebookDocumentFilterWithNotebookNotebook) MarshalJSON() ([]byte, error } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *NotebookDocumentFilterWithNotebookNotebook) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1031,7 +1007,6 @@ func (t NotebookDocumentSyncOptionsNotebookSelector) MarshalJSON() ([]byte, erro } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *NotebookDocumentSyncOptionsNotebookSelector) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1072,7 +1047,6 @@ func (t ParameterInformationDocumentation) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ParameterInformationDocumentation) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1114,7 +1088,6 @@ func (t ParameterInformationLabel) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ParameterInformationLabel) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1157,7 +1130,6 @@ func (t RelatedFullDocumentDiagnosticReportRelatedDocuments) MarshalJSON() ([]by } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *RelatedFullDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1200,7 +1172,6 @@ func (t RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) MarshalJSON() } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1241,7 +1212,6 @@ func (t RelativePatternBaseURI) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *RelativePatternBaseURI) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1284,7 +1254,6 @@ func (t SemanticTokensDeltaResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *SemanticTokensDeltaResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1325,7 +1294,6 @@ func (t SemanticTokensOptionsFull) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *SemanticTokensOptionsFull) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1366,7 +1334,6 @@ func (t SemanticTokensOptionsRange) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *SemanticTokensOptionsRange) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1411,7 +1378,6 @@ func (t ServerCapabilitiesCallHierarchyProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesCallHierarchyProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1457,7 +1423,6 @@ func (t ServerCapabilitiesCodeActionProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesCodeActionProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1500,7 +1465,6 @@ func (t ServerCapabilitiesColorProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesColorProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1548,7 +1512,6 @@ func (t ServerCapabilitiesDeclarationProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesDeclarationProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1594,7 +1557,6 @@ func (t ServerCapabilitiesDefinitionProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesDefinitionProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1637,7 +1599,6 @@ func (t ServerCapabilitiesDiagnosticProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesDiagnosticProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1678,7 +1639,6 @@ func (t ServerCapabilitiesDocumentFormattingProvider) MarshalJSON() ([]byte, err } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesDocumentFormattingProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1719,7 +1679,6 @@ func (t ServerCapabilitiesDocumentHighlightProvider) MarshalJSON() ([]byte, erro } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesDocumentHighlightProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1760,7 +1719,6 @@ func (t ServerCapabilitiesDocumentRangeFormattingProvider) MarshalJSON() ([]byte } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesDocumentRangeFormattingProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1801,7 +1759,6 @@ func (t ServerCapabilitiesDocumentSymbolProvider) MarshalJSON() ([]byte, error) } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesDocumentSymbolProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1844,7 +1801,6 @@ func (t ServerCapabilitiesFoldingRangeProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesFoldingRangeProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1890,7 +1846,6 @@ func (t ServerCapabilitiesHoverProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesHoverProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1933,7 +1888,6 @@ func (t ServerCapabilitiesImplementationProvider) MarshalJSON() ([]byte, error) } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesImplementationProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -1983,7 +1937,6 @@ func (t ServerCapabilitiesInlayHintProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesInlayHintProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2031,7 +1984,6 @@ func (t ServerCapabilitiesInlineCompletionProvider) MarshalJSON() ([]byte, error } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesInlineCompletionProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2076,7 +2028,6 @@ func (t ServerCapabilitiesInlineValueProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesInlineValueProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2126,7 +2077,6 @@ func (t ServerCapabilitiesLinkedEditingRangeProvider) MarshalJSON() ([]byte, err } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesLinkedEditingRangeProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2176,7 +2126,6 @@ func (t ServerCapabilitiesMonikerProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesMonikerProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2224,7 +2173,6 @@ func (t ServerCapabilitiesNotebookDocumentSync) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesNotebookDocumentSync) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2265,7 +2213,6 @@ func (t ServerCapabilitiesReferencesProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesReferencesProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2307,7 +2254,6 @@ func (t ServerCapabilitiesRenameProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesRenameProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2350,7 +2296,6 @@ func (t ServerCapabilitiesSelectionRangeProvider) MarshalJSON() ([]byte, error) } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesSelectionRangeProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2398,7 +2343,6 @@ func (t ServerCapabilitiesSemanticTokensProvider) MarshalJSON() ([]byte, error) } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesSemanticTokensProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2439,7 +2383,6 @@ func (t ServerCapabilitiesTextDocumentSync) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesTextDocumentSync) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2482,7 +2425,6 @@ func (t ServerCapabilitiesTypeDefinitionProvider) MarshalJSON() ([]byte, error) } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesTypeDefinitionProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2532,7 +2474,6 @@ func (t ServerCapabilitiesTypeHierarchyProvider) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesTypeHierarchyProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2578,7 +2519,6 @@ func (t ServerCapabilitiesWorkspaceSymbolProvider) MarshalJSON() ([]byte, error) } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *ServerCapabilitiesWorkspaceSymbolProvider) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2619,7 +2559,6 @@ func (t SignatureInformationDocumentation) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *SignatureInformationDocumentation) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2664,7 +2603,6 @@ func (t TextDocumentEditEdits) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *TextDocumentEditEdits) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2710,7 +2648,6 @@ func (t TextDocumentSyncOptionsSave) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *TextDocumentSyncOptionsSave) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2751,7 +2688,6 @@ func (t TypeDefinitionResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *TypeDefinitionResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2797,7 +2733,6 @@ func (t WorkspaceEditDocumentChanges) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *WorkspaceEditDocumentChanges) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2848,7 +2783,6 @@ func (t WorkspaceFoldersServerCapabilitiesChangeNotifications) MarshalJSON() ([] } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *WorkspaceFoldersServerCapabilitiesChangeNotifications) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2891,7 +2825,6 @@ func (t WorkspaceOptionsTextDocumentContent) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *WorkspaceOptionsTextDocumentContent) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2934,7 +2867,6 @@ func (t WorkspaceSymbolLocation) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *WorkspaceSymbolLocation) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil @@ -2978,7 +2910,6 @@ func (t WorkspaceSymbolResult) MarshalJSON() ([]byte, error) { } return nil, fmt.Errorf("unknown type: %T", t) } - func (t *WorkspaceSymbolResult) UnmarshalJSON(val []byte) error { if string(val) == "null" { t.value = nil diff --git a/workspace.go b/workspace.go index ed807bf4..3fd15ccf 100644 --- a/workspace.go +++ b/workspace.go @@ -349,7 +349,7 @@ type WorkspaceFoldersServerCapabilities struct { Supported bool `json:"supported,omitempty"` // ChangeNotifications whether the server wants to receive workspace folder change notifications. If a string is provided the string is treated as an ID under which the notification is registered on the client side. The ID can be used to unregister for these events using the `client/unregisterCapability` request. - ChangeNotifications *WorkspaceFoldersServerCapabilitiesChangeNotifications `json:"changeNotifications,omitempty"` + ChangeNotifications *OneOf[string, bool] `json:"changeNotifications,omitempty"` } // DidChangeConfigurationParams the parameters of a change configuration notification. @@ -359,7 +359,7 @@ type DidChangeConfigurationParams struct { } type DidChangeConfigurationRegistrationOptions struct { - Section *DidChangeConfigurationRegistrationOptionsSection `json:"section,omitempty"` + Section *OneOf[string, []string] `json:"section,omitempty"` } // FileEvent an event describing a file change. @@ -414,7 +414,7 @@ type WorkspaceSymbol struct { // more details. // // @since 3.17.0 - Location WorkspaceSymbolLocation `json:"location"` + Location OneOf[Location, LocationURIOnly] `json:"location"` // Data a data entry field that is preserved on a workspace symbol between a workspace symbol request and a workspace symbol resolve request. // @@ -479,7 +479,7 @@ type RelativePattern struct { // BaseURI a workspace folder or a base URI to which this pattern will be matched against relatively. // // @since 3.17.0 - BaseURI RelativePatternBaseURI `json:"baseUri"` + BaseURI OneOf[WorkspaceFolder, uri.URI] `json:"baseUri"` // Pattern the actual glob pattern;. // From abbd56a018ce327cce3c4aacf28cf36cbc9a406a Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Tue, 4 Mar 2025 00:31:05 +0900 Subject: [PATCH 17/19] WIP13 Signed-off-by: Koichi Shiraishi --- handler.go | 4 ++-- protocol/handler.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/handler.go b/handler.go index cf9f7626..79c19fa0 100644 --- a/handler.go +++ b/handler.go @@ -22,7 +22,7 @@ func CancelHandler(handler jsonrpc2.Handler) jsonrpc2.Handler { // be careful about racing between the two paths. // TODO(iancottrell): Add a test that watches the stream and verifies the response // for the cancelled request flows. - reply := func(ctx context.Context, resp interface{}, err error) error { + reply := func(ctx context.Context, resp any, err error) error { // https://microsoft.github.io/language-server-protocol/specifications/specification-current/#cancelRequest if ctx.Err() != nil && err == nil { err = ErrRequestCancelled @@ -65,7 +65,7 @@ func Handlers(handler jsonrpc2.Handler) jsonrpc2.Handler { } // Call calls method to params and result. -func Call(ctx context.Context, conn jsonrpc2.Conn, method string, params, result interface{}) error { +func Call(ctx context.Context, conn jsonrpc2.Conn, method string, params, result any) error { _, err := conn.Call(ctx, method, params, result) if ctx.Err() != nil { } diff --git a/protocol/handler.go b/protocol/handler.go index a038a4cd..9328887a 100644 --- a/protocol/handler.go +++ b/protocol/handler.go @@ -18,7 +18,7 @@ func Handlers(handler jsonrpc2.Handler) jsonrpc2.Handler { } // Call calls method to params and result. -func Call(ctx context.Context, conn jsonrpc2.Conn, method string, params, result interface{}) error { +func Call(ctx context.Context, conn jsonrpc2.Conn, method string, params, result any) error { _, err := conn.Call(ctx, method, params, result) if ctx.Err() != nil { } From ece7252b9af0775a194a0140b91b75e377e83541 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Tue, 4 Mar 2025 00:38:46 +0900 Subject: [PATCH 18/19] WIP14 Signed-off-by: Koichi Shiraishi --- tools/protocol-gen/generator/structure.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/protocol-gen/generator/structure.go b/tools/protocol-gen/generator/structure.go index 55555ef3..1a5eeacb 100644 --- a/tools/protocol-gen/generator/structure.go +++ b/tools/protocol-gen/generator/structure.go @@ -704,7 +704,12 @@ func (gen *Generator) renderStructuresOrType(g Printer, or *protocol.OrType, gen } sb.WriteString(`[`) for i, item := range or.Items { - sb.WriteString(item.String()) + s := item.String() + // TODO(zchee): ugly way + if s == "LocationUriOnly" { + s = "LocationURIOnly" + } + sb.WriteString(s) if i < len(or.Items)-1 { sb.WriteString(`,`) } From 44a76d43ef466c2120bcdd9664a08f54ca597617 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Tue, 4 Mar 2025 03:10:59 +0900 Subject: [PATCH 19/19] WIP15 Signed-off-by: Koichi Shiraishi --- document.go | 10 +- language.go | 8 +- type_alias.go | 542 +-------- types_generics.go | 2809 ++------------------------------------------- workspace.go | 2 +- 5 files changed, 95 insertions(+), 3276 deletions(-) diff --git a/document.go b/document.go index 999f83a2..02516dff 100644 --- a/document.go +++ b/document.go @@ -128,7 +128,7 @@ type NotebookDocumentFilterWithCells struct { // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. // // @since 3.18.0 - Notebook *OneOf[string, NotebookDocumentFilter] `json:"notebook,omitempty"` + Notebook *OneOf[string, NotebookDocumentFilter[NotebookDocumentFilterNotebookType, NotebookDocumentFilterScheme, NotebookDocumentFilterPattern]] `json:"notebook,omitempty"` // Cells the cells of the matching notebook to be synced. // @@ -143,7 +143,7 @@ type NotebookDocumentFilterWithNotebook struct { // Notebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. // // @since 3.18.0 - Notebook OneOf[string, NotebookDocumentFilter] `json:"notebook"` + Notebook OneOf[string, NotebookDocumentFilter[NotebookDocumentFilterNotebookType, NotebookDocumentFilterScheme, NotebookDocumentFilterPattern]] `json:"notebook"` // Cells the cells of the matching notebook to be synced. // @@ -426,7 +426,7 @@ type NotebookDocumentFilterNotebookType struct { // Pattern a glob pattern. // // @since 3.18.0 - Pattern *GlobPattern `json:"pattern,omitempty"` + Pattern *GlobPattern[Pattern, RelativePattern] `json:"pattern,omitempty"` } // NotebookDocumentFilterScheme a notebook document filter where `scheme` is required field. @@ -446,7 +446,7 @@ type NotebookDocumentFilterScheme struct { // Pattern a glob pattern. // // @since 3.18.0 - Pattern *GlobPattern `json:"pattern,omitempty"` + Pattern *GlobPattern[Pattern, RelativePattern] `json:"pattern,omitempty"` } // NotebookDocumentFilterPattern a notebook document filter where `pattern` is required field. @@ -466,5 +466,5 @@ type NotebookDocumentFilterPattern struct { // Pattern a glob pattern. // // @since 3.18.0 - Pattern GlobPattern `json:"pattern"` + Pattern GlobPattern[Pattern, RelativePattern] `json:"pattern"` } diff --git a/language.go b/language.go index 6d5feb96..aaa0dd92 100644 --- a/language.go +++ b/language.go @@ -2012,7 +2012,7 @@ type HoverParams struct { // Hover the result of a hover request. type Hover struct { // Contents the hover's content. - Contents OneOf3[MarkupContent, MarkedString, []MarkedString] `json:"contents"` + Contents OneOf3[MarkupContent, MarkedString[string, MarkedStringWithLanguage], []MarkedString[string, MarkedStringWithLanguage]] `json:"contents"` // Range an optional range inside the text document that is used to visualize the hover, e.g. by changing the // background color. @@ -2755,7 +2755,7 @@ type TextDocumentFilterLanguage struct { // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. Whether clients support relative patterns depends on the client capability `textDocuments.filters.relativePatternSupport`. // @since 3.18.0 - Pattern *GlobPattern `json:"pattern,omitempty"` + Pattern *GlobPattern[Pattern, RelativePattern] `json:"pattern,omitempty"` } // TextDocumentFilterScheme a document filter where `scheme` is required field. @@ -2774,7 +2774,7 @@ type TextDocumentFilterScheme struct { // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. Whether clients support relative patterns depends on the client capability `textDocuments.filters.relativePatternSupport`. // @since 3.18.0 - Pattern *GlobPattern `json:"pattern,omitempty"` + Pattern *GlobPattern[Pattern, RelativePattern] `json:"pattern,omitempty"` } // TextDocumentFilterPattern a document filter where `pattern` is required field. @@ -2793,5 +2793,5 @@ type TextDocumentFilterPattern struct { // Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. Whether clients support relative patterns depends on the client capability `textDocuments.filters.relativePatternSupport`. // @since 3.18.0 - Pattern GlobPattern `json:"pattern"` + Pattern GlobPattern[Pattern, RelativePattern] `json:"pattern"` } diff --git a/type_alias.go b/type_alias.go index cadca5a2..3c261c33 100644 --- a/type_alias.go +++ b/type_alias.go @@ -3,8 +3,6 @@ package protocol -import "fmt" - type RegularExpressionEngineKind string // Pattern the glob pattern to watch relative to the base path. Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none - `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) @@ -12,577 +10,65 @@ type RegularExpressionEngineKind string // @since 3.17.0 type Pattern string -// NotebookDocumentFilter a notebook document filter denotes a notebook document by different properties. The properties will be match against the notebook's URI (same as with documents) -// -// @since 3.17.0 -type NotebookDocumentFilter struct { - value any -} - -func NewNotebookDocumentFilter[T NotebookDocumentFilterNotebookType | NotebookDocumentFilterScheme | NotebookDocumentFilterPattern](val T) NotebookDocumentFilter { - return NotebookDocumentFilter{ - value: val, - } -} - -func (t NotebookDocumentFilter) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case NotebookDocumentFilterNotebookType: - return marshal(val) - case NotebookDocumentFilterScheme: - return marshal(val) - case NotebookDocumentFilterPattern: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *NotebookDocumentFilter) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 NotebookDocumentFilterNotebookType - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 NotebookDocumentFilterScheme - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 NotebookDocumentFilterPattern - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type NotebookDocumentFilter[T NotebookDocumentFilterNotebookType, U NotebookDocumentFilterScheme, V NotebookDocumentFilterPattern] = OneOf3[T, U, V] // TextDocumentFilter a document filter denotes a document by different properties like the TextDocument.languageId language, the Uri.scheme scheme of its resource, or a glob-pattern that is applied to the TextDocument.fileName path. Glob patterns can have the following syntax: - `*` to match one or more characters in a path segment - `?` to match on one character in a path segment - `**` to match any number of path segments, including none - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) // // Example: A language filter that applies to typescript files on disk: `{ language: 'typescript', scheme: 'file' }` // // Example: A language filter that applies to all package.json paths: `{ language: 'json', pattern: '**package.json' }` // // @since 3.17.0 -type TextDocumentFilter struct { - value any -} - -func NewTextDocumentFilter[T TextDocumentFilterLanguage | TextDocumentFilterScheme | TextDocumentFilterPattern](val T) TextDocumentFilter { - return TextDocumentFilter{ - value: val, - } -} - -func (t TextDocumentFilter) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case TextDocumentFilterLanguage: - return marshal(val) - case TextDocumentFilterScheme: - return marshal(val) - case TextDocumentFilterPattern: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *TextDocumentFilter) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 TextDocumentFilterLanguage - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 TextDocumentFilterScheme - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 TextDocumentFilterPattern - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type TextDocumentFilter[T TextDocumentFilterLanguage, U TextDocumentFilterScheme, V TextDocumentFilterPattern] = OneOf3[T, U, V] // GlobPattern the glob pattern. Either a string pattern or a relative pattern. // // @since 3.17.0 -type GlobPattern struct { - value any -} - -func NewGlobPattern[T Pattern | RelativePattern](val T) GlobPattern { - return GlobPattern{ - value: val, - } -} - -func (t GlobPattern) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Pattern: - return marshal(val) - case RelativePattern: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *GlobPattern) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Pattern - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 RelativePattern - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type GlobPattern[T Pattern, U RelativePattern] = OneOf[T, U] // DocumentFilter a document filter describes a top level text document or a notebook cell document. 3.17.0 - support for NotebookCellTextDocumentFilter. // // @since 3.17.0 - support for NotebookCellTextDocumentFilter. -type DocumentFilter struct { - value any -} - -func NewDocumentFilter[T TextDocumentFilter | NotebookCellTextDocumentFilter](val T) DocumentFilter { - return DocumentFilter{ - value: val, - } -} - -func (t DocumentFilter) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case TextDocumentFilter: - return marshal(val) - case NotebookCellTextDocumentFilter: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *DocumentFilter) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 TextDocumentFilter - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 NotebookCellTextDocumentFilter - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type DocumentFilter[T TextDocumentFilter[TextDocumentFilterLanguage, TextDocumentFilterScheme, TextDocumentFilterPattern], U NotebookCellTextDocumentFilter] = OneOf[T, U] // MarkedString markedString can be used to render human readable text. It is either a markdown string or a code-block that provides a language and a code snippet. The language identifier is semantically equal to the // optional language identifier in fenced code blocks in GitHub issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting The pair of a language and a value is an equivalent to markdown: ```${language} ${value} ``` Note that markdown strings will be sanitized - that means html will be escaped. // // Deprecated: use MarkupContent instead. -type MarkedString struct { - value any -} - -func NewMarkedString[T string | MarkedStringWithLanguage](val T) MarkedString { - return MarkedString{ - value: val, - } -} - -func (t MarkedString) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case MarkedStringWithLanguage: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *MarkedString) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 MarkedStringWithLanguage - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type MarkedString[T string, U MarkedStringWithLanguage] = OneOf[T, U] // TextDocumentContentChangeEvent an event describing a change to a text document. If only a text is provided it is considered to be the full content of the document. -type TextDocumentContentChangeEvent struct { - value any -} - -func NewTextDocumentContentChangeEvent[T TextDocumentContentChangePartial | TextDocumentContentChangeWholeDocument](val T) TextDocumentContentChangeEvent { - return TextDocumentContentChangeEvent{ - value: val, - } -} - -func (t TextDocumentContentChangeEvent) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case TextDocumentContentChangePartial: - return marshal(val) - case TextDocumentContentChangeWholeDocument: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *TextDocumentContentChangeEvent) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 TextDocumentContentChangePartial - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 TextDocumentContentChangeWholeDocument - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type TextDocumentContentChangeEvent[T TextDocumentContentChangePartial, U TextDocumentContentChangeWholeDocument] = OneOf[T, U] // WorkspaceDocumentDiagnosticReport a workspace diagnostic document report. // // @since 3.17.0 -type WorkspaceDocumentDiagnosticReport struct { - value any -} - -func NewWorkspaceDocumentDiagnosticReport[T WorkspaceFullDocumentDiagnosticReport | WorkspaceUnchangedDocumentDiagnosticReport](val T) WorkspaceDocumentDiagnosticReport { - return WorkspaceDocumentDiagnosticReport{ - value: val, - } -} - -func (t WorkspaceDocumentDiagnosticReport) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case WorkspaceFullDocumentDiagnosticReport: - return marshal(val) - case WorkspaceUnchangedDocumentDiagnosticReport: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *WorkspaceDocumentDiagnosticReport) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 WorkspaceFullDocumentDiagnosticReport - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 WorkspaceUnchangedDocumentDiagnosticReport - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type WorkspaceDocumentDiagnosticReport[T WorkspaceFullDocumentDiagnosticReport, U WorkspaceUnchangedDocumentDiagnosticReport] = OneOf[T, U] // ChangeAnnotationIdentifier an identifier to refer to a change annotation stored with a workspace edit. type ChangeAnnotationIdentifier string -type ProgressToken struct { - value any -} - -func NewProgressToken[T int32 | string](val T) ProgressToken { - return ProgressToken{ - value: val, - } -} - -func (t ProgressToken) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case int32: - return marshal(val) - case string: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *ProgressToken) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 int32 - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 string - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type ProgressToken[T int32, U string] = OneOf[T, U] // DocumentSelector a document selector is the combination of one or many document filters. // // Example: `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]`; The use of a string as a document filter is deprecated // // @since 3.16.0. -type DocumentSelector []DocumentFilter +type DocumentSelector []DocumentFilter[TextDocumentFilter[TextDocumentFilterLanguage, TextDocumentFilterScheme, TextDocumentFilterPattern], NotebookCellTextDocumentFilter] -type PrepareRenameResult struct { - value any -} - -func NewPrepareRenameResult[T Range | PrepareRenamePlaceholder | PrepareRenameDefaultBehavior](val T) PrepareRenameResult { - return PrepareRenameResult{ - value: val, - } -} - -func (t PrepareRenameResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Range: - return marshal(val) - case PrepareRenamePlaceholder: - return marshal(val) - case PrepareRenameDefaultBehavior: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *PrepareRenameResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Range - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 PrepareRenamePlaceholder - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 PrepareRenameDefaultBehavior - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type PrepareRenameResult[T Range, U PrepareRenamePlaceholder, V PrepareRenameDefaultBehavior] = OneOf3[T, U, V] // DocumentDiagnosticReport the result of a document diagnostic pull request. A report can either be a full report containing all diagnostics for the requested document or an unchanged report indicating that nothing has changed in terms of diagnostics in comparison to the last pull request. // // @since 3.17.0 -type DocumentDiagnosticReport struct { - value any -} - -func NewDocumentDiagnosticReport[T RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport](val T) DocumentDiagnosticReport { - return DocumentDiagnosticReport{ - value: val, - } -} - -func (t DocumentDiagnosticReport) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case RelatedFullDocumentDiagnosticReport: - return marshal(val) - case RelatedUnchangedDocumentDiagnosticReport: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *DocumentDiagnosticReport) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 RelatedFullDocumentDiagnosticReport - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 RelatedUnchangedDocumentDiagnosticReport - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type DocumentDiagnosticReport[T RelatedFullDocumentDiagnosticReport, U RelatedUnchangedDocumentDiagnosticReport] = OneOf[T, U] // InlineValue inline value information can be provided by different means: - directly as a text value (class InlineValueText). - as a name to use for a variable lookup (class InlineValueVariableLookup) - as an evaluatable expression (class InlineValueEvaluatableExpression) The InlineValue types combines all inline value types into one type. // // @since 3.17.0 -type InlineValue struct { - value any -} - -func NewInlineValue[T InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression](val T) InlineValue { - return InlineValue{ - value: val, - } -} - -func (t InlineValue) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case InlineValueText: - return marshal(val) - case InlineValueVariableLookup: - return marshal(val) - case InlineValueEvaluatableExpression: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *InlineValue) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 InlineValueText - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 InlineValueVariableLookup - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 InlineValueEvaluatableExpression - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type InlineValue[T InlineValueText, U InlineValueVariableLookup, V InlineValueEvaluatableExpression] = OneOf3[T, U, V] // DeclarationLink information about where a symbol is declared. Provides additional metadata over normal Location location declarations, including the range of the declaring symbol. Servers should prefer returning `DeclarationLink` over `Declaration` if supported by the client. type DeclarationLink LocationLink // Declaration the declaration of a symbol representation as one or many Location locations. -type Declaration struct { - value any -} - -func NewDeclaration[T Location | []Location](val T) Declaration { - return Declaration{ - value: val, - } -} - -func (t Declaration) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Location: - return marshal(val) - case []Location: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *Declaration) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Location - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []Location - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type Declaration[T Location, U []Location] = OneOf[T, U] // DefinitionLink information about where a symbol is defined. Provides additional metadata over normal Location location definitions, including the range of the defining symbol. type DefinitionLink LocationLink // Definition the definition of a symbol represented as one or many Location locations. For most programming languages there is only one location at which a symbol is defined. Servers should prefer returning `DefinitionLink` over `Definition` if supported by the client. -type Definition struct { - value any -} - -func NewDefinition[T Location | []Location](val T) Definition { - return Definition{ - value: val, - } -} - -func (t Definition) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Location: - return marshal(val) - case []Location: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unkonwn type: %T", t) -} -func (t *Definition) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Location - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []Location - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{fmt.Sprintf("failed to unmarshal %T", t)} -} +type Definition[T Location, U []Location] = OneOf[T, U] diff --git a/types_generics.go b/types_generics.go index 0b31e5d2..d5fef69d 100644 --- a/types_generics.go +++ b/types_generics.go @@ -4,2926 +4,259 @@ package protocol import ( - "fmt" - "go.lsp.dev/uri" ) // CancelParamsID the request id to cancel. -type CancelParamsID struct { - value any -} - -func NewCancelParamsID[T int32 | string](val T) CancelParamsID { - return CancelParamsID{ - value: val, - } -} - -func (t CancelParamsID) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case int32: - return marshal(val) - case string: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *CancelParamsID) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 int32 - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 string - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [int32 string]"} -} +type CancelParamsID[T int32, U string] = OneOf[T, U] // ClientSemanticTokensRequestOptionsFull the client will send the `textDocument/semanticTokens/full` request if the server provides a corresponding handler. -type ClientSemanticTokensRequestOptionsFull struct { - value any -} - -func NewClientSemanticTokensRequestOptionsFull[T bool | ClientSemanticTokensRequestFullDelta](val T) *ClientSemanticTokensRequestOptionsFull { - return &ClientSemanticTokensRequestOptionsFull{ - value: val, - } -} - -func (t ClientSemanticTokensRequestOptionsFull) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case ClientSemanticTokensRequestFullDelta: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ClientSemanticTokensRequestOptionsFull) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 ClientSemanticTokensRequestFullDelta - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool ClientSemanticTokensRequestFullDelta]"} -} +type ClientSemanticTokensRequestOptionsFull[T bool, U ClientSemanticTokensRequestFullDelta] = OneOf[T, U] // ClientSemanticTokensRequestOptionsRange the client will send the `textDocument/semanticTokens/range` request if the server provides a corresponding handler. -type ClientSemanticTokensRequestOptionsRange struct { - value any -} - -func NewClientSemanticTokensRequestOptionsRange[T bool | Range](val T) *ClientSemanticTokensRequestOptionsRange { - return &ClientSemanticTokensRequestOptionsRange{ - value: val, - } -} - -func (t ClientSemanticTokensRequestOptionsRange) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case Range: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ClientSemanticTokensRequestOptionsRange) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 Range - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool Range]"} -} +type ClientSemanticTokensRequestOptionsRange[T bool, U Range] = OneOf[T, U] // CodeActionRequestResult a request to provide commands for the given text document and range. -type CodeActionRequestResult struct { - value any -} - -func NewCodeActionRequestResult[T Command | CodeAction](val T) *CodeActionRequestResult { - return &CodeActionRequestResult{ - value: val, - } -} - -func (t CodeActionRequestResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Command: - return marshal(val) - case CodeAction: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *CodeActionRequestResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Command - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 CodeAction - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Command CodeAction]"} -} +type CodeActionRequestResult[T Command, U CodeAction] = OneOf[T, U] // CompletionItemDefaultsEditRange a default edit range. // // @since 3.17.0 -type CompletionItemDefaultsEditRange struct { - value any -} - -func NewCompletionItemDefaultsEditRange[T Range | EditRangeWithInsertReplace](val T) *CompletionItemDefaultsEditRange { - return &CompletionItemDefaultsEditRange{ - value: val, - } -} - -func (t CompletionItemDefaultsEditRange) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Range: - return marshal(val) - case EditRangeWithInsertReplace: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *CompletionItemDefaultsEditRange) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Range - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 EditRangeWithInsertReplace - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Range EditRangeWithInsertReplace]"} -} +type CompletionItemDefaultsEditRange[T Range, U EditRangeWithInsertReplace] = OneOf[T, U] // CompletionItemDocumentation a human-readable string that represents a doc-comment. -type CompletionItemDocumentation struct { - value any -} - -func NewCompletionItemDocumentation[T string | MarkupContent](val T) *CompletionItemDocumentation { - return &CompletionItemDocumentation{ - value: val, - } -} - -func (t CompletionItemDocumentation) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case MarkupContent: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *CompletionItemDocumentation) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 MarkupContent - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} -} +type CompletionItemDocumentation[T string, U MarkupContent] = OneOf[T, U] // CompletionItemTextEdit an TextEdit edit which is applied to a document when selecting this completion. When an edit is provided the value of CompletionItem.insertText insertText is ignored. Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for `InsertReplaceEdits` via the `textDocument.completion.insertReplaceSupport` client capability property. *Note 1:* The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested. *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position. 3.16.0 additional type `InsertReplaceEdit`. // // @since 3.16.0 additional type `InsertReplaceEdit` -type CompletionItemTextEdit struct { - value any -} - -func NewCompletionItemTextEdit[T TextEdit | InsertReplaceEdit](val T) *CompletionItemTextEdit { - return &CompletionItemTextEdit{ - value: val, - } -} - -func (t CompletionItemTextEdit) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case TextEdit: - return marshal(val) - case InsertReplaceEdit: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *CompletionItemTextEdit) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 TextEdit - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 InsertReplaceEdit - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [TextEdit InsertReplaceEdit]"} -} +type CompletionItemTextEdit[T TextEdit, U InsertReplaceEdit] = OneOf[T, U] // CompletionResult request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail `detail` and CompletionItem.documentation `documentation` properties to the `completionItem/resolve` request. However, properties that are needed for the initial sorting and filtering, like `sortText`, // `filterText`, `insertText`, and `textEdit`, must not be changed during resolve. -type CompletionResult struct { - value any -} - -func NewCompletionResult[T []CompletionItem | CompletionList](val T) *CompletionResult { - return &CompletionResult{ - value: val, - } -} - -func (t CompletionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case []CompletionItem: - return marshal(val) - case CompletionList: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *CompletionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 []CompletionItem - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 CompletionList - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [[]CompletionItem CompletionList]"} -} +type CompletionResult[T []CompletionItem, U CompletionList] = OneOf[T, U] // DeclarationResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a // typed array of DeclarationLink or a Thenable that resolves to such. -type DeclarationResult struct { - value any -} - -func NewDeclarationResult[T Declaration | []DeclarationLink](val T) *DeclarationResult { - return &DeclarationResult{ - value: val, - } -} - -func (t DeclarationResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Declaration: - return marshal(val) - case []DeclarationLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *DeclarationResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Declaration - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DeclarationLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Declaration []DeclarationLink]"} -} +type DeclarationResult[T Declaration[Location, []Location], U []DeclarationLink] = OneOf[T, U] // DefinitionResult a request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed // array of DefinitionLink or a Thenable that resolves to such. -type DefinitionResult struct { - value any -} - -func NewDefinitionResult[T Definition | []DefinitionLink](val T) *DefinitionResult { - return &DefinitionResult{ - value: val, - } -} - -func (t DefinitionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Definition: - return marshal(val) - case []DefinitionLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *DefinitionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Definition - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DefinitionLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} -} +type DefinitionResult[T Declaration[Location, []Location], U []DefinitionLink] = OneOf[T, U] // DiagnosticCode the diagnostic's code, which usually appear in the user interface. -type DiagnosticCode struct { - value any -} - -func NewDiagnosticCode[T int32 | string](val T) DiagnosticCode { - return DiagnosticCode{ - value: val, - } -} - -func (t DiagnosticCode) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case int32: - return marshal(val) - case string: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *DiagnosticCode) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 int32 - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 string - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [int32 string]"} -} - -type DidChangeConfigurationRegistrationOptionsSection struct { - value any -} - -func NewDidChangeConfigurationRegistrationOptionsSection[T string | []string](val T) DidChangeConfigurationRegistrationOptionsSection { - return DidChangeConfigurationRegistrationOptionsSection{ - value: val, - } -} - -func (t DidChangeConfigurationRegistrationOptionsSection) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case []string: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *DidChangeConfigurationRegistrationOptionsSection) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []string - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string []string]"} -} - -type DocumentDiagnosticReportPartialResultRelatedDocuments struct { - value any -} - -func NewDocumentDiagnosticReportPartialResultRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](val T) *DocumentDiagnosticReportPartialResultRelatedDocuments { - return &DocumentDiagnosticReportPartialResultRelatedDocuments{ - value: val, - } -} - -func (t DocumentDiagnosticReportPartialResultRelatedDocuments) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case FullDocumentDiagnosticReport: - return marshal(val) - case UnchangedDocumentDiagnosticReport: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *DocumentDiagnosticReportPartialResultRelatedDocuments) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 FullDocumentDiagnosticReport - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 UnchangedDocumentDiagnosticReport - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} -} +type DiagnosticCode[T int32, U string] = OneOf[T, U] + +type DidChangeConfigurationRegistrationOptionsSection[T string, U []string] = OneOf[T, U] + +type DocumentDiagnosticReportPartialResultRelatedDocuments[T FullDocumentDiagnosticReport, U UnchangedDocumentDiagnosticReport] = OneOf[T, U] // DocumentSymbolResult a request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that // resolves to such. -type DocumentSymbolResult struct { - value any -} - -func NewDocumentSymbolResult[T []SymbolInformation | []DocumentSymbol](val T) DocumentSymbolResult { - return DocumentSymbolResult{ - value: val, - } -} - -func (t DocumentSymbolResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case []SymbolInformation: - return marshal(val) - case []DocumentSymbol: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *DocumentSymbolResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 []SymbolInformation - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DocumentSymbol - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []DocumentSymbol]"} -} +type DocumentSymbolResult[T []SymbolInformation, U []DocumentSymbol] = OneOf[T, U] // HoverContents the hover's content. -type HoverContents struct { - value any -} - -func NewHoverContents[T MarkupContent | MarkedString | []MarkedString](val T) *HoverContents { - return &HoverContents{ - value: val, - } -} - -func (t HoverContents) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case MarkupContent: - return marshal(val) - case MarkedString: - return marshal(val) - case []MarkedString: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *HoverContents) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 MarkupContent - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 MarkedString - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 []MarkedString - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [MarkupContent MarkedString []MarkedString]"} -} +type HoverContents[T MarkupContent, U MarkedString[string, MarkedStringWithLanguage], V []MarkedString[string, MarkedStringWithLanguage]] = OneOf3[T, U, V] // ImplementationResult a request to resolve the implementation locations of a symbol at a given text document position. The // request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. -type ImplementationResult struct { - value any -} - -func NewImplementationResult[T Definition | []DefinitionLink](val T) *ImplementationResult { - return &ImplementationResult{ - value: val, - } -} - -func (t ImplementationResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Definition: - return marshal(val) - case []DefinitionLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ImplementationResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Definition - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DefinitionLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} -} +type ImplementationResult[T Definition[Location, []Location], U []DefinitionLink] = OneOf[T, U] // InlayHintLabel the label of this hint. A human readable string or an array of InlayHintLabelPart label parts. *Note* that neither the string nor the label part can be empty. -type InlayHintLabel struct { - value any -} - -func NewInlayHintLabel[T string | []InlayHintLabelPart](val T) InlayHintLabel { - return InlayHintLabel{ - value: val, - } -} - -func (t InlayHintLabel) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case []InlayHintLabelPart: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *InlayHintLabel) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []InlayHintLabelPart - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string []InlayHintLabelPart]"} -} +type InlayHintLabel[T string, U []InlayHintLabelPart] = OneOf[T, U] // InlayHintLabelPartTooltip the tooltip text when you hover over this label part. Depending on the client capability `inlayHint.resolveSupport` clients might resolve this property late using the resolve request. -type InlayHintLabelPartTooltip struct { - value any -} - -func NewInlayHintLabelPartTooltip[T string | MarkupContent](val T) *InlayHintLabelPartTooltip { - return &InlayHintLabelPartTooltip{ - value: val, - } -} - -func (t InlayHintLabelPartTooltip) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case MarkupContent: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *InlayHintLabelPartTooltip) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 MarkupContent - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} -} +type InlayHintLabelPartTooltip[T string, U MarkupContent] = OneOf[T, U] // InlayHintTooltip the tooltip text when you hover over this item. -type InlayHintTooltip struct { - value any -} - -func NewInlayHintTooltip[T string | MarkupContent](val T) *InlayHintTooltip { - return &InlayHintTooltip{ - value: val, - } -} - -func (t InlayHintTooltip) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case MarkupContent: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *InlayHintTooltip) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 MarkupContent - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} -} +type InlayHintTooltip[T string, U MarkupContent] = OneOf[T, U] // InlineCompletionItemInsertText the text to replace the range with. Must be set. -type InlineCompletionItemInsertText struct { - value any -} - -func NewInlineCompletionItemInsertText[T string | StringValue](val T) *InlineCompletionItemInsertText { - return &InlineCompletionItemInsertText{ - value: val, - } -} - -func (t InlineCompletionItemInsertText) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case StringValue: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *InlineCompletionItemInsertText) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 StringValue - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string StringValue]"} -} +type InlineCompletionItemInsertText[T string, U StringValue] = OneOf[T, U] // InlineCompletionResult a request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. 3.18.0 @proposed. // // @since 3.18.0 proposed -type InlineCompletionResult struct { - value any -} - -func NewInlineCompletionResult[T InlineCompletionList | []InlineCompletionItem](val T) *InlineCompletionResult { - return &InlineCompletionResult{ - value: val, - } -} - -func (t InlineCompletionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case InlineCompletionList: - return marshal(val) - case []InlineCompletionItem: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *InlineCompletionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 InlineCompletionList - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []InlineCompletionItem - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [InlineCompletionList []InlineCompletionItem]"} -} +type InlineCompletionResult[T InlineCompletionList, U []InlineCompletionItem] = OneOf[T, U] // NotebookCellTextDocumentFilterNotebook a filter that matches against the notebook containing the notebook cell. If a string value is provided it matches against the notebook type. '*' matches every notebook. -type NotebookCellTextDocumentFilterNotebook struct { - value any -} - -func NewNotebookCellTextDocumentFilterNotebook[T string | NotebookDocumentFilter](val T) *NotebookCellTextDocumentFilterNotebook { - return &NotebookCellTextDocumentFilterNotebook{ - value: val, - } -} - -func (t NotebookCellTextDocumentFilterNotebook) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case NotebookDocumentFilter: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *NotebookCellTextDocumentFilterNotebook) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 NotebookDocumentFilter - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} -} +type NotebookCellTextDocumentFilterNotebook[T string, U NotebookDocumentFilter[NotebookDocumentFilterNotebookType, NotebookDocumentFilterScheme, NotebookDocumentFilterPattern]] = OneOf[T, U] // NotebookDocumentFilterWithCellsNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. -type NotebookDocumentFilterWithCellsNotebook struct { - value any -} - -func NewNotebookDocumentFilterWithCellsNotebook[T string | NotebookDocumentFilter](val T) *NotebookDocumentFilterWithCellsNotebook { - return &NotebookDocumentFilterWithCellsNotebook{ - value: val, - } -} - -func (t NotebookDocumentFilterWithCellsNotebook) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case NotebookDocumentFilter: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *NotebookDocumentFilterWithCellsNotebook) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 NotebookDocumentFilter - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} -} +type NotebookDocumentFilterWithCellsNotebook[T string, U NotebookDocumentFilter[NotebookDocumentFilterNotebookType, NotebookDocumentFilterScheme, NotebookDocumentFilterPattern]] = OneOf[T, U] // NotebookDocumentFilterWithNotebookNotebook the notebook to be synced If a string value is provided it matches against the notebook type. '*' matches every notebook. -type NotebookDocumentFilterWithNotebookNotebook struct { - value any -} - -func NewNotebookDocumentFilterWithNotebookNotebook[T string | NotebookDocumentFilter](val T) *NotebookDocumentFilterWithNotebookNotebook { - return &NotebookDocumentFilterWithNotebookNotebook{ - value: val, - } -} - -func (t NotebookDocumentFilterWithNotebookNotebook) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case NotebookDocumentFilter: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *NotebookDocumentFilterWithNotebookNotebook) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 NotebookDocumentFilter - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string NotebookDocumentFilter]"} -} +type NotebookDocumentFilterWithNotebookNotebook[T string, U NotebookDocumentFilter[NotebookDocumentFilterNotebookType, NotebookDocumentFilterScheme, NotebookDocumentFilterPattern]] = OneOf[T, U] // NotebookDocumentSyncOptionsNotebookSelector the notebooks to be synced. -type NotebookDocumentSyncOptionsNotebookSelector struct { - value any -} - -func NewNotebookDocumentSyncOptionsNotebookSelector[T NotebookDocumentFilterWithNotebook | NotebookDocumentFilterWithCells](val T) *NotebookDocumentSyncOptionsNotebookSelector { - return &NotebookDocumentSyncOptionsNotebookSelector{ - value: val, - } -} - -func (t NotebookDocumentSyncOptionsNotebookSelector) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case NotebookDocumentFilterWithNotebook: - return marshal(val) - case NotebookDocumentFilterWithCells: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *NotebookDocumentSyncOptionsNotebookSelector) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 NotebookDocumentFilterWithNotebook - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 NotebookDocumentFilterWithCells - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [NotebookDocumentFilterWithNotebook NotebookDocumentFilterWithCells]"} -} +type NotebookDocumentSyncOptionsNotebookSelector[T NotebookDocumentFilterWithNotebook, U NotebookDocumentFilterWithCells] = OneOf[T, U] // ParameterInformationDocumentation the human-readable doc-comment of this parameter. Will be shown in the UI but can be omitted. -type ParameterInformationDocumentation struct { - value any -} - -func NewParameterInformationDocumentation[T string | MarkupContent](val T) *ParameterInformationDocumentation { - return &ParameterInformationDocumentation{ - value: val, - } -} - -func (t ParameterInformationDocumentation) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case MarkupContent: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ParameterInformationDocumentation) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 MarkupContent - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} -} +type ParameterInformationDocumentation[T string, U MarkupContent] = OneOf[T, U] // ParameterInformationLabel the label of this parameter information. Either a string or an inclusive start and exclusive end offsets within its containing signature label. (see SignatureInformation.label). The offsets are based on a UTF-16 string representation as `Position` and `Range` does. To avoid ambiguities a server should use the [start, end] offset value instead of using a substring. Whether a client support this is controlled via `labelOffsetSupport` client capability. *Note*: a label of type string should be a substring of its containing signature label. Its intended use case is to highlight the parameter label // part in the `SignatureInformation.label`. -type ParameterInformationLabel struct { - value any -} - -func NewParameterInformationLabel[T string | uint32](val T) *ParameterInformationLabel { - return &ParameterInformationLabel{ - value: val, - } -} - -func (t ParameterInformationLabel) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case uint32: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ParameterInformationLabel) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 uint32 - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string uint32]"} -} +type ParameterInformationLabel[T string, U uint32] = OneOf[T, U] // RelatedFullDocumentDiagnosticReportRelatedDocuments 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 -type RelatedFullDocumentDiagnosticReportRelatedDocuments struct { - value any -} - -func NewRelatedFullDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](val T) *RelatedFullDocumentDiagnosticReportRelatedDocuments { - return &RelatedFullDocumentDiagnosticReportRelatedDocuments{ - value: val, - } -} - -func (t RelatedFullDocumentDiagnosticReportRelatedDocuments) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case FullDocumentDiagnosticReport: - return marshal(val) - case UnchangedDocumentDiagnosticReport: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *RelatedFullDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 FullDocumentDiagnosticReport - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 UnchangedDocumentDiagnosticReport - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} -} +type RelatedFullDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport, U UnchangedDocumentDiagnosticReport] = OneOf[T, U] // RelatedUnchangedDocumentDiagnosticReportRelatedDocuments 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 -type RelatedUnchangedDocumentDiagnosticReportRelatedDocuments struct { - value any -} - -func NewRelatedUnchangedDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport](val T) *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments { - return &RelatedUnchangedDocumentDiagnosticReportRelatedDocuments{ - value: val, - } -} - -func (t RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case FullDocumentDiagnosticReport: - return marshal(val) - case UnchangedDocumentDiagnosticReport: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *RelatedUnchangedDocumentDiagnosticReportRelatedDocuments) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 FullDocumentDiagnosticReport - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 UnchangedDocumentDiagnosticReport - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} -} +type RelatedUnchangedDocumentDiagnosticReportRelatedDocuments[T FullDocumentDiagnosticReport, U UnchangedDocumentDiagnosticReport] = OneOf[T, U] // RelativePatternBaseURI a workspace folder or a base URI to which this pattern will be matched against relatively. -type RelativePatternBaseURI struct { - value any -} - -func NewRelativePatternBaseURI[T WorkspaceFolder | uri.URI](val T) *RelativePatternBaseURI { - return &RelativePatternBaseURI{ - value: val, - } -} - -func (t RelativePatternBaseURI) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case WorkspaceFolder: - return marshal(val) - case uri.URI: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *RelativePatternBaseURI) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 WorkspaceFolder - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 uri.URI - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [WorkspaceFolder uri.URI]"} -} +type RelativePatternBaseURI[T WorkspaceFolder, U uri.URI] = OneOf[T, U] // SemanticTokensDeltaResult. // // @since 3.16.0 -type SemanticTokensDeltaResult struct { - value any -} - -func NewSemanticTokensDeltaResult[T SemanticTokens | SemanticTokensDelta](val T) *SemanticTokensDeltaResult { - return &SemanticTokensDeltaResult{ - value: val, - } -} - -func (t SemanticTokensDeltaResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case SemanticTokens: - return marshal(val) - case SemanticTokensDelta: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *SemanticTokensDeltaResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 SemanticTokens - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 SemanticTokensDelta - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [SemanticTokens SemanticTokensDelta]"} -} +type SemanticTokensDeltaResult[T SemanticTokens, U SemanticTokensDelta] = OneOf[T, U] // SemanticTokensOptionsFull server supports providing semantic tokens for a full document. -type SemanticTokensOptionsFull struct { - value any -} - -func NewSemanticTokensOptionsFull[T bool | SemanticTokensFullDelta](val T) *SemanticTokensOptionsFull { - return &SemanticTokensOptionsFull{ - value: val, - } -} - -func (t SemanticTokensOptionsFull) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case SemanticTokensFullDelta: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *SemanticTokensOptionsFull) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 SemanticTokensFullDelta - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool SemanticTokensFullDelta]"} -} +type SemanticTokensOptionsFull[T bool, U SemanticTokensFullDelta] = OneOf[T, U] // SemanticTokensOptionsRange server supports providing semantic tokens for a specific range of a document. -type SemanticTokensOptionsRange struct { - value any -} - -func NewSemanticTokensOptionsRange[T bool | Range](val T) *SemanticTokensOptionsRange { - return &SemanticTokensOptionsRange{ - value: val, - } -} - -func (t SemanticTokensOptionsRange) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case Range: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *SemanticTokensOptionsRange) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 Range - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool Range]"} -} +type SemanticTokensOptionsRange[T bool, U Range] = OneOf[T, U] // ServerCapabilitiesCallHierarchyProvider the server provides call hierarchy support. // // @since 3.16.0 -type ServerCapabilitiesCallHierarchyProvider struct { - value any -} - -func NewServerCapabilitiesCallHierarchyProvider[T bool | CallHierarchyOptions | CallHierarchyRegistrationOptions](val T) *ServerCapabilitiesCallHierarchyProvider { - return &ServerCapabilitiesCallHierarchyProvider{ - value: val, - } -} - -func (t ServerCapabilitiesCallHierarchyProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case CallHierarchyOptions: - return marshal(val) - case CallHierarchyRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesCallHierarchyProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 CallHierarchyOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 CallHierarchyRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool CallHierarchyOptions CallHierarchyRegistrationOptions]"} -} +type ServerCapabilitiesCallHierarchyProvider[T bool, U CallHierarchyOptions, V CallHierarchyRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesCodeActionProvider the server provides code actions. CodeActionOptions may only be specified if the client states that it supports `codeActionLiteralSupport` in its initial `initialize` request. -type ServerCapabilitiesCodeActionProvider struct { - value any -} - -func NewServerCapabilitiesCodeActionProvider[T bool | CodeActionOptions](val T) *ServerCapabilitiesCodeActionProvider { - return &ServerCapabilitiesCodeActionProvider{ - value: val, - } -} - -func (t ServerCapabilitiesCodeActionProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case CodeActionOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesCodeActionProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 CodeActionOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool CodeActionOptions]"} -} +type ServerCapabilitiesCodeActionProvider[T bool, U CodeActionOptions] = OneOf[T, U] // ServerCapabilitiesColorProvider the server provides color provider support. -type ServerCapabilitiesColorProvider struct { - value any -} - -func NewServerCapabilitiesColorProvider[T bool | DocumentColorOptions | DocumentColorRegistrationOptions](val T) *ServerCapabilitiesColorProvider { - return &ServerCapabilitiesColorProvider{ - value: val, - } -} - -func (t ServerCapabilitiesColorProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case DocumentColorOptions: - return marshal(val) - case DocumentColorRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesColorProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 DocumentColorOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 DocumentColorRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool DocumentColorOptions DocumentColorRegistrationOptions]"} -} +type ServerCapabilitiesColorProvider[T bool, U DocumentColorOptions, V DocumentColorRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesDeclarationProvider the server provides Goto Declaration support. -type ServerCapabilitiesDeclarationProvider struct { - value any -} - -func NewServerCapabilitiesDeclarationProvider[T bool | DeclarationOptions | DeclarationRegistrationOptions](val T) *ServerCapabilitiesDeclarationProvider { - return &ServerCapabilitiesDeclarationProvider{ - value: val, - } -} - -func (t ServerCapabilitiesDeclarationProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case DeclarationOptions: - return marshal(val) - case DeclarationRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesDeclarationProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 DeclarationOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 DeclarationRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool DeclarationOptions DeclarationRegistrationOptions]"} -} +type ServerCapabilitiesDeclarationProvider[T bool, U DeclarationOptions, V DeclarationRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesDefinitionProvider the server provides goto definition support. -type ServerCapabilitiesDefinitionProvider struct { - value any -} - -func NewServerCapabilitiesDefinitionProvider[T bool | DefinitionOptions](val T) *ServerCapabilitiesDefinitionProvider { - return &ServerCapabilitiesDefinitionProvider{ - value: val, - } -} - -func (t ServerCapabilitiesDefinitionProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case DefinitionOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesDefinitionProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 DefinitionOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool DefinitionOptions]"} -} +type ServerCapabilitiesDefinitionProvider[T bool, U DefinitionOptions] = OneOf[T, U] // ServerCapabilitiesDiagnosticProvider the server has support for pull model diagnostics. // // @since 3.17.0 -type ServerCapabilitiesDiagnosticProvider struct { - value any -} - -func NewServerCapabilitiesDiagnosticProvider[T DiagnosticOptions | DiagnosticRegistrationOptions](val T) *ServerCapabilitiesDiagnosticProvider { - return &ServerCapabilitiesDiagnosticProvider{ - value: val, - } -} - -func (t ServerCapabilitiesDiagnosticProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case DiagnosticOptions: - return marshal(val) - case DiagnosticRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesDiagnosticProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 DiagnosticOptions - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 DiagnosticRegistrationOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [DiagnosticOptions DiagnosticRegistrationOptions]"} -} +type ServerCapabilitiesDiagnosticProvider[T DiagnosticOptions, U DiagnosticRegistrationOptions] = OneOf[T, U] // ServerCapabilitiesDocumentFormattingProvider the server provides document formatting. -type ServerCapabilitiesDocumentFormattingProvider struct { - value any -} - -func NewServerCapabilitiesDocumentFormattingProvider[T bool | DocumentFormattingOptions](val T) *ServerCapabilitiesDocumentFormattingProvider { - return &ServerCapabilitiesDocumentFormattingProvider{ - value: val, - } -} - -func (t ServerCapabilitiesDocumentFormattingProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case DocumentFormattingOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesDocumentFormattingProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 DocumentFormattingOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool DocumentFormattingOptions]"} -} +type ServerCapabilitiesDocumentFormattingProvider[T bool, U DocumentFormattingOptions] = OneOf[T, U] // ServerCapabilitiesDocumentHighlightProvider the server provides document highlight support. -type ServerCapabilitiesDocumentHighlightProvider struct { - value any -} - -func NewServerCapabilitiesDocumentHighlightProvider[T bool | DocumentHighlightOptions](val T) *ServerCapabilitiesDocumentHighlightProvider { - return &ServerCapabilitiesDocumentHighlightProvider{ - value: val, - } -} - -func (t ServerCapabilitiesDocumentHighlightProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case DocumentHighlightOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesDocumentHighlightProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 DocumentHighlightOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool DocumentHighlightOptions]"} -} +type ServerCapabilitiesDocumentHighlightProvider[T bool, U DocumentHighlightOptions] = OneOf[T, U] // ServerCapabilitiesDocumentRangeFormattingProvider the server provides document range formatting. -type ServerCapabilitiesDocumentRangeFormattingProvider struct { - value any -} - -func NewServerCapabilitiesDocumentRangeFormattingProvider[T bool | DocumentRangeFormattingOptions](val T) *ServerCapabilitiesDocumentRangeFormattingProvider { - return &ServerCapabilitiesDocumentRangeFormattingProvider{ - value: val, - } -} - -func (t ServerCapabilitiesDocumentRangeFormattingProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case DocumentRangeFormattingOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesDocumentRangeFormattingProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 DocumentRangeFormattingOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool DocumentRangeFormattingOptions]"} -} +type ServerCapabilitiesDocumentRangeFormattingProvider[T bool, U DocumentRangeFormattingOptions] = OneOf[T, U] // ServerCapabilitiesDocumentSymbolProvider the server provides document symbol support. -type ServerCapabilitiesDocumentSymbolProvider struct { - value any -} - -func NewServerCapabilitiesDocumentSymbolProvider[T bool | DocumentSymbolOptions](val T) *ServerCapabilitiesDocumentSymbolProvider { - return &ServerCapabilitiesDocumentSymbolProvider{ - value: val, - } -} - -func (t ServerCapabilitiesDocumentSymbolProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case DocumentSymbolOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesDocumentSymbolProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 DocumentSymbolOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool DocumentSymbolOptions]"} -} +type ServerCapabilitiesDocumentSymbolProvider[T bool, U DocumentSymbolOptions] = OneOf[T, U] // ServerCapabilitiesFoldingRangeProvider the server provides folding provider support. -type ServerCapabilitiesFoldingRangeProvider struct { - value any -} - -func NewServerCapabilitiesFoldingRangeProvider[T bool | FoldingRangeOptions | FoldingRangeRegistrationOptions](val T) *ServerCapabilitiesFoldingRangeProvider { - return &ServerCapabilitiesFoldingRangeProvider{ - value: val, - } -} - -func (t ServerCapabilitiesFoldingRangeProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case FoldingRangeOptions: - return marshal(val) - case FoldingRangeRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesFoldingRangeProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 FoldingRangeOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 FoldingRangeRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool FoldingRangeOptions FoldingRangeRegistrationOptions]"} -} +type ServerCapabilitiesFoldingRangeProvider[T bool, U FoldingRangeOptions, V FoldingRangeRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesHoverProvider the server provides hover support. -type ServerCapabilitiesHoverProvider struct { - value any -} - -func NewServerCapabilitiesHoverProvider[T bool | HoverOptions](val T) *ServerCapabilitiesHoverProvider { - return &ServerCapabilitiesHoverProvider{ - value: val, - } -} - -func (t ServerCapabilitiesHoverProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case HoverOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesHoverProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 HoverOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool HoverOptions]"} -} +type ServerCapabilitiesHoverProvider[T bool, U HoverOptions] = OneOf[T, U] // ServerCapabilitiesImplementationProvider the server provides Goto Implementation support. -type ServerCapabilitiesImplementationProvider struct { - value any -} - -func NewServerCapabilitiesImplementationProvider[T bool | ImplementationOptions | ImplementationRegistrationOptions](val T) *ServerCapabilitiesImplementationProvider { - return &ServerCapabilitiesImplementationProvider{ - value: val, - } -} - -func (t ServerCapabilitiesImplementationProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case ImplementationOptions: - return marshal(val) - case ImplementationRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesImplementationProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 ImplementationOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 ImplementationRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool ImplementationOptions ImplementationRegistrationOptions]"} -} +type ServerCapabilitiesImplementationProvider[T bool, U ImplementationOptions, V ImplementationRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesInlayHintProvider the server provides inlay hints. // // @since 3.17.0 -type ServerCapabilitiesInlayHintProvider struct { - value any -} - -func NewServerCapabilitiesInlayHintProvider[T bool | InlayHintOptions | InlayHintRegistrationOptions](val T) *ServerCapabilitiesInlayHintProvider { - return &ServerCapabilitiesInlayHintProvider{ - value: val, - } -} - -func (t ServerCapabilitiesInlayHintProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case InlayHintOptions: - return marshal(val) - case InlayHintRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesInlayHintProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 InlayHintOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 InlayHintRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool InlayHintOptions InlayHintRegistrationOptions]"} -} +type ServerCapabilitiesInlayHintProvider[T bool, U InlayHintOptions, V InlayHintRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesInlineCompletionProvider inline completion options used during static registration. 3.18.0 @proposed. // // @since 3.18.0 proposed -type ServerCapabilitiesInlineCompletionProvider struct { - value any -} - -func NewServerCapabilitiesInlineCompletionProvider[T bool | InlineCompletionOptions](val T) *ServerCapabilitiesInlineCompletionProvider { - return &ServerCapabilitiesInlineCompletionProvider{ - value: val, - } -} - -func (t ServerCapabilitiesInlineCompletionProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case InlineCompletionOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesInlineCompletionProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 InlineCompletionOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool InlineCompletionOptions]"} -} +type ServerCapabilitiesInlineCompletionProvider[T bool, U InlineCompletionOptions] = OneOf[T, U] // ServerCapabilitiesInlineValueProvider the server provides inline values. // // @since 3.17.0 -type ServerCapabilitiesInlineValueProvider struct { - value any -} - -func NewServerCapabilitiesInlineValueProvider[T bool | InlineValueOptions | InlineValueRegistrationOptions](val T) *ServerCapabilitiesInlineValueProvider { - return &ServerCapabilitiesInlineValueProvider{ - value: val, - } -} - -func (t ServerCapabilitiesInlineValueProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case InlineValueOptions: - return marshal(val) - case InlineValueRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesInlineValueProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 InlineValueOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 InlineValueRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool InlineValueOptions InlineValueRegistrationOptions]"} -} +type ServerCapabilitiesInlineValueProvider[T bool, U InlineValueOptions, V InlineValueRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesLinkedEditingRangeProvider the server provides linked editing range support. // // @since 3.16.0 -type ServerCapabilitiesLinkedEditingRangeProvider struct { - value any -} - -func NewServerCapabilitiesLinkedEditingRangeProvider[T bool | LinkedEditingRangeOptions | LinkedEditingRangeRegistrationOptions](val T) *ServerCapabilitiesLinkedEditingRangeProvider { - return &ServerCapabilitiesLinkedEditingRangeProvider{ - value: val, - } -} - -func (t ServerCapabilitiesLinkedEditingRangeProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case LinkedEditingRangeOptions: - return marshal(val) - case LinkedEditingRangeRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesLinkedEditingRangeProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 LinkedEditingRangeOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 LinkedEditingRangeRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool LinkedEditingRangeOptions LinkedEditingRangeRegistrationOptions]"} -} +type ServerCapabilitiesLinkedEditingRangeProvider[T bool, U LinkedEditingRangeOptions, V LinkedEditingRangeRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesMonikerProvider the server provides moniker support. // // @since 3.16.0 -type ServerCapabilitiesMonikerProvider struct { - value any -} - -func NewServerCapabilitiesMonikerProvider[T bool | MonikerOptions | MonikerRegistrationOptions](val T) *ServerCapabilitiesMonikerProvider { - return &ServerCapabilitiesMonikerProvider{ - value: val, - } -} - -func (t ServerCapabilitiesMonikerProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case MonikerOptions: - return marshal(val) - case MonikerRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesMonikerProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 MonikerOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 MonikerRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool MonikerOptions MonikerRegistrationOptions]"} -} +type ServerCapabilitiesMonikerProvider[T bool, U MonikerOptions, V MonikerRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesNotebookDocumentSync defines how notebook documents are synced. // // @since 3.17.0 -type ServerCapabilitiesNotebookDocumentSync struct { - value any -} - -func NewServerCapabilitiesNotebookDocumentSync[T NotebookDocumentSyncOptions | NotebookDocumentSyncRegistrationOptions](val T) *ServerCapabilitiesNotebookDocumentSync { - return &ServerCapabilitiesNotebookDocumentSync{ - value: val, - } -} - -func (t ServerCapabilitiesNotebookDocumentSync) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case NotebookDocumentSyncOptions: - return marshal(val) - case NotebookDocumentSyncRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesNotebookDocumentSync) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 NotebookDocumentSyncOptions - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 NotebookDocumentSyncRegistrationOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [NotebookDocumentSyncOptions NotebookDocumentSyncRegistrationOptions]"} -} +type ServerCapabilitiesNotebookDocumentSync[T NotebookDocumentSyncOptions, U NotebookDocumentSyncRegistrationOptions] = OneOf[T, U] // ServerCapabilitiesReferencesProvider the server provides find references support. -type ServerCapabilitiesReferencesProvider struct { - value any -} - -func NewServerCapabilitiesReferencesProvider[T bool | ReferenceOptions](val T) *ServerCapabilitiesReferencesProvider { - return &ServerCapabilitiesReferencesProvider{ - value: val, - } -} - -func (t ServerCapabilitiesReferencesProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case ReferenceOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesReferencesProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 ReferenceOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool ReferenceOptions]"} -} +type ServerCapabilitiesReferencesProvider[T bool, U ReferenceOptions] = OneOf[T, U] // ServerCapabilitiesRenameProvider the server provides rename support. RenameOptions may only be specified if the client states that it // supports `prepareSupport` in its initial `initialize` request. -type ServerCapabilitiesRenameProvider struct { - value any -} - -func NewServerCapabilitiesRenameProvider[T bool | RenameOptions](val T) *ServerCapabilitiesRenameProvider { - return &ServerCapabilitiesRenameProvider{ - value: val, - } -} - -func (t ServerCapabilitiesRenameProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case RenameOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesRenameProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 RenameOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool RenameOptions]"} -} +type ServerCapabilitiesRenameProvider[T bool, U RenameOptions] = OneOf[T, U] // ServerCapabilitiesSelectionRangeProvider the server provides selection range support. -type ServerCapabilitiesSelectionRangeProvider struct { - value any -} - -func NewServerCapabilitiesSelectionRangeProvider[T bool | SelectionRangeOptions | SelectionRangeRegistrationOptions](val T) *ServerCapabilitiesSelectionRangeProvider { - return &ServerCapabilitiesSelectionRangeProvider{ - value: val, - } -} - -func (t ServerCapabilitiesSelectionRangeProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case SelectionRangeOptions: - return marshal(val) - case SelectionRangeRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesSelectionRangeProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 SelectionRangeOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 SelectionRangeRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool SelectionRangeOptions SelectionRangeRegistrationOptions]"} -} +type ServerCapabilitiesSelectionRangeProvider[T bool, U SelectionRangeOptions, V SelectionRangeRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesSemanticTokensProvider the server provides semantic tokens support. // // @since 3.16.0 -type ServerCapabilitiesSemanticTokensProvider struct { - value any -} - -func NewServerCapabilitiesSemanticTokensProvider[T SemanticTokensOptions | SemanticTokensRegistrationOptions](val T) *ServerCapabilitiesSemanticTokensProvider { - return &ServerCapabilitiesSemanticTokensProvider{ - value: val, - } -} - -func (t ServerCapabilitiesSemanticTokensProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case SemanticTokensOptions: - return marshal(val) - case SemanticTokensRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesSemanticTokensProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 SemanticTokensOptions - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 SemanticTokensRegistrationOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [SemanticTokensOptions SemanticTokensRegistrationOptions]"} -} +type ServerCapabilitiesSemanticTokensProvider[T SemanticTokensOptions, U SemanticTokensRegistrationOptions] = OneOf[T, U] // ServerCapabilitiesTextDocumentSync defines how text documents are synced. Is either a detailed structure defining each notification or for backwards compatibility the TextDocumentSyncKind number. -type ServerCapabilitiesTextDocumentSync struct { - value any -} - -func NewServerCapabilitiesTextDocumentSync[T TextDocumentSyncOptions | TextDocumentSyncKind](val T) *ServerCapabilitiesTextDocumentSync { - return &ServerCapabilitiesTextDocumentSync{ - value: val, - } -} - -func (t ServerCapabilitiesTextDocumentSync) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case TextDocumentSyncOptions: - return marshal(val) - case TextDocumentSyncKind: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesTextDocumentSync) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 TextDocumentSyncOptions - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 TextDocumentSyncKind - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [TextDocumentSyncOptions TextDocumentSyncKind]"} -} +type ServerCapabilitiesTextDocumentSync[T TextDocumentSyncOptions, U TextDocumentSyncKind] = OneOf[T, U] // ServerCapabilitiesTypeDefinitionProvider the server provides Goto Type Definition support. -type ServerCapabilitiesTypeDefinitionProvider struct { - value any -} - -func NewServerCapabilitiesTypeDefinitionProvider[T bool | TypeDefinitionOptions | TypeDefinitionRegistrationOptions](val T) *ServerCapabilitiesTypeDefinitionProvider { - return &ServerCapabilitiesTypeDefinitionProvider{ - value: val, - } -} - -func (t ServerCapabilitiesTypeDefinitionProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case TypeDefinitionOptions: - return marshal(val) - case TypeDefinitionRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesTypeDefinitionProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 TypeDefinitionOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 TypeDefinitionRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool TypeDefinitionOptions TypeDefinitionRegistrationOptions]"} -} +type ServerCapabilitiesTypeDefinitionProvider[T bool, U TypeDefinitionOptions, V TypeDefinitionRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesTypeHierarchyProvider the server provides type hierarchy support. // // @since 3.17.0 -type ServerCapabilitiesTypeHierarchyProvider struct { - value any -} - -func NewServerCapabilitiesTypeHierarchyProvider[T bool | TypeHierarchyOptions | TypeHierarchyRegistrationOptions](val T) *ServerCapabilitiesTypeHierarchyProvider { - return &ServerCapabilitiesTypeHierarchyProvider{ - value: val, - } -} - -func (t ServerCapabilitiesTypeHierarchyProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case TypeHierarchyOptions: - return marshal(val) - case TypeHierarchyRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesTypeHierarchyProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 TypeHierarchyOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 TypeHierarchyRegistrationOptions - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool TypeHierarchyOptions TypeHierarchyRegistrationOptions]"} -} +type ServerCapabilitiesTypeHierarchyProvider[T bool, U TypeHierarchyOptions, V TypeHierarchyRegistrationOptions] = OneOf3[T, U, V] // ServerCapabilitiesWorkspaceSymbolProvider the server provides workspace symbol support. -type ServerCapabilitiesWorkspaceSymbolProvider struct { - value any -} - -func NewServerCapabilitiesWorkspaceSymbolProvider[T bool | WorkspaceSymbolOptions](val T) *ServerCapabilitiesWorkspaceSymbolProvider { - return &ServerCapabilitiesWorkspaceSymbolProvider{ - value: val, - } -} - -func (t ServerCapabilitiesWorkspaceSymbolProvider) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case WorkspaceSymbolOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *ServerCapabilitiesWorkspaceSymbolProvider) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 WorkspaceSymbolOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool WorkspaceSymbolOptions]"} -} +type ServerCapabilitiesWorkspaceSymbolProvider[T bool, U WorkspaceSymbolOptions] = OneOf[T, U] // SignatureInformationDocumentation the human-readable doc-comment of this signature. Will be shown in the UI but can be omitted. -type SignatureInformationDocumentation struct { - value any -} - -func NewSignatureInformationDocumentation[T string | MarkupContent](val T) *SignatureInformationDocumentation { - return &SignatureInformationDocumentation{ - value: val, - } -} - -func (t SignatureInformationDocumentation) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case MarkupContent: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *SignatureInformationDocumentation) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 MarkupContent - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string MarkupContent]"} -} +type SignatureInformationDocumentation[T string, U MarkupContent] = OneOf[T, U] // TextDocumentEditEdits the edits to be applied. 3.16.0 - support for AnnotatedTextEdit. This is guarded using a client capability. 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. // // @since 3.18.0 - support for SnippetTextEdit. This is guarded using a client capability. -type TextDocumentEditEdits struct { - value any -} - -func NewTextDocumentEditEdits[T TextEdit | AnnotatedTextEdit | SnippetTextEdit](val T) *TextDocumentEditEdits { - return &TextDocumentEditEdits{ - value: val, - } -} - -func (t TextDocumentEditEdits) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case TextEdit: - return marshal(val) - case AnnotatedTextEdit: - return marshal(val) - case SnippetTextEdit: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *TextDocumentEditEdits) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 TextEdit - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 AnnotatedTextEdit - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 SnippetTextEdit - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [TextEdit AnnotatedTextEdit SnippetTextEdit]"} -} +type TextDocumentEditEdits[T TextEdit, U AnnotatedTextEdit, V SnippetTextEdit] = OneOf3[T, U, V] // TextDocumentSyncOptionsSave if present save notifications are sent to the server. If omitted the notification should not be sent. -type TextDocumentSyncOptionsSave struct { - value any -} - -func NewTextDocumentSyncOptionsSave[T bool | SaveOptions](val T) *TextDocumentSyncOptionsSave { - return &TextDocumentSyncOptionsSave{ - value: val, - } -} - -func (t TextDocumentSyncOptionsSave) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case bool: - return marshal(val) - case SaveOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *TextDocumentSyncOptionsSave) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 bool - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 SaveOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [bool SaveOptions]"} -} +type TextDocumentSyncOptionsSave[T bool, U SaveOptions] = OneOf[T, U] // TypeDefinitionResult a request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such. -type TypeDefinitionResult struct { - value any -} - -func NewTypeDefinitionResult[T Definition | []DefinitionLink](val T) *TypeDefinitionResult { - return &TypeDefinitionResult{ - value: val, - } -} - -func (t TypeDefinitionResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Definition: - return marshal(val) - case []DefinitionLink: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *TypeDefinitionResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Definition - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []DefinitionLink - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Definition []DefinitionLink]"} -} +type TypeDefinitionResult[T Definition[Location, []Location], U []DefinitionLink] = OneOf[T, U] // WorkspaceEditDocumentChanges depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes are // either an array of `TextDocumentEdit`s to express changes to n different text documents where each text document edit addresses a specific version of a text document. Or it can contain above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations. Whether a client supports versioned document edits is expressed via `workspace.workspaceEdit.documentChanges` client capability. If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s using the `changes` property are supported. -type WorkspaceEditDocumentChanges struct { - value any -} - -func NewWorkspaceEditDocumentChanges[T TextDocumentEdit | CreateFile | RenameFile | DeleteFile](val T) *WorkspaceEditDocumentChanges { - return &WorkspaceEditDocumentChanges{ - value: val, - } -} - -func (t WorkspaceEditDocumentChanges) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case TextDocumentEdit: - return marshal(val) - case CreateFile: - return marshal(val) - case RenameFile: - return marshal(val) - case DeleteFile: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *WorkspaceEditDocumentChanges) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 TextDocumentEdit - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 CreateFile - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - var h2 RenameFile - if err := unmarshal(val, &h2); err == nil { - t.value = h2 - return nil - } - var h3 DeleteFile - if err := unmarshal(val, &h3); err == nil { - t.value = h3 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [TextDocumentEdit CreateFile RenameFile DeleteFile]"} -} +type WorkspaceEditDocumentChanges[T TextDocumentEdit, U CreateFile, V RenameFile, Y DeleteFile] OneOf4[T, U, V, Y] // WorkspaceFoldersServerCapabilitiesChangeNotifications whether the server wants to receive workspace folder change notifications. If a string is provided the string is treated as an ID under which the notification is registered on the client side. The ID can be used to unregister for these events using the `client/unregisterCapability` request. -type WorkspaceFoldersServerCapabilitiesChangeNotifications struct { - value any -} - -func NewWorkspaceFoldersServerCapabilitiesChangeNotifications[T string | bool](val T) WorkspaceFoldersServerCapabilitiesChangeNotifications { - return WorkspaceFoldersServerCapabilitiesChangeNotifications{ - value: val, - } -} - -func (t WorkspaceFoldersServerCapabilitiesChangeNotifications) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case string: - return marshal(val) - case bool: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *WorkspaceFoldersServerCapabilitiesChangeNotifications) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 string - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 bool - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [string bool]"} -} +type WorkspaceFoldersServerCapabilitiesChangeNotifications[T string, U bool] = OneOf[T, U] // WorkspaceOptionsTextDocumentContent the server supports the `workspace/textDocumentContent` request. 3.18.0 @proposed. // // @since 3.18.0 proposed -type WorkspaceOptionsTextDocumentContent struct { - value any -} - -func NewWorkspaceOptionsTextDocumentContent[T TextDocumentContentOptions | TextDocumentContentRegistrationOptions](val T) *WorkspaceOptionsTextDocumentContent { - return &WorkspaceOptionsTextDocumentContent{ - value: val, - } -} - -func (t WorkspaceOptionsTextDocumentContent) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case TextDocumentContentOptions: - return marshal(val) - case TextDocumentContentRegistrationOptions: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *WorkspaceOptionsTextDocumentContent) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 TextDocumentContentOptions - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 TextDocumentContentRegistrationOptions - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [TextDocumentContentOptions TextDocumentContentRegistrationOptions]"} -} +type WorkspaceOptionsTextDocumentContent[T TextDocumentContentOptions, U TextDocumentContentRegistrationOptions] = OneOf[T, U] // WorkspaceSymbolLocation the location of the symbol. Whether a server is allowed to return a location without a range depends // on the client capability `workspace.symbol.resolveSupport`. See SymbolInformation#location for // more details. -type WorkspaceSymbolLocation struct { - value any -} - -func NewWorkspaceSymbolLocation[T Location | LocationURIOnly](val T) *WorkspaceSymbolLocation { - return &WorkspaceSymbolLocation{ - value: val, - } -} - -func (t WorkspaceSymbolLocation) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case Location: - return marshal(val) - case LocationURIOnly: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *WorkspaceSymbolLocation) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 Location - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 LocationURIOnly - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [Location LocationURIOnly]"} -} +type WorkspaceSymbolLocation[T Location, U LocationURIOnly] = OneOf[T, U] // WorkspaceSymbolResult a request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. // The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. // // @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability `workspace.symbol.resolveSupport`. -type WorkspaceSymbolResult struct { - value any -} - -func NewWorkspaceSymbolResult[T []SymbolInformation | []WorkspaceSymbol](val T) WorkspaceSymbolResult { - return WorkspaceSymbolResult{ - value: val, - } -} - -func (t WorkspaceSymbolResult) MarshalJSON() ([]byte, error) { - switch val := t.value.(type) { - case []SymbolInformation: - return marshal(val) - case []WorkspaceSymbol: - return marshal(val) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("unknown type: %T", t) -} -func (t *WorkspaceSymbolResult) UnmarshalJSON(val []byte) error { - if string(val) == "null" { - t.value = nil - return nil - } - var h0 []SymbolInformation - if err := unmarshal(val, &h0); err == nil { - t.value = h0 - return nil - } - var h1 []WorkspaceSymbol - if err := unmarshal(val, &h1); err == nil { - t.value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [[]SymbolInformation []WorkspaceSymbol]"} -} +type WorkspaceSymbolResult[T []SymbolInformation, U []WorkspaceSymbol] = OneOf[T, U] diff --git a/workspace.go b/workspace.go index 3fd15ccf..9651db87 100644 --- a/workspace.go +++ b/workspace.go @@ -380,7 +380,7 @@ type DidChangeWatchedFilesParams struct { type FileSystemWatcher struct { // GlobPattern the glob pattern to watch. See GlobPattern glob pattern for more detail. 3.17.0 support for relative // patterns. - GlobPattern GlobPattern `json:"globPattern"` + GlobPattern GlobPattern[Pattern, RelativePattern] `json:"globPattern"` // Kind the kind of events of interest. If omitted it defaults to WatchKind.Create | WatchKind.Change | WatchKind.Delete which is . Kind WatchKind `json:"kind,omitempty"`