internal/lsp: latest version of LSP stubs

This CL updates the LSP to 3.17.0. It is a DANGEROUS CL as the stubs
are being generated by Go code reading vscode's language independent
description of the protocol (in metaMode.json in the vscode-languageserver-node
repository.)

Some of the union types in the protocol have Go types with names containing  'Or'.
These types have custom marshaling and unmarshaling code.

Embedded structures in the protocol are broken out as their own
types, with names constructed from the context in which they occur.

The natural output has been modified to minimize the number of changes
needed for gopls. (e.g., Workspace6Gn is preserved for compatibility.0
Thus, many types that are union types in the LSP description have been replaced by the
types gopls already uses.

Updates golang/go#52969

Change-Id: I16f6d877215155ac9e782b0f5bcbdab3f1aa2593
Reviewed-on: https://go-review.googlesource.com/c/tools/+/424214
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Peter Weinberger 2022-08-16 11:12:59 -04:00
parent ec743893cd
commit 9250e22aa3
11 changed files with 4796 additions and 5078 deletions

View File

@ -22,13 +22,13 @@ import (
"text/tabwriter"
"time"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/gopls/internal/lsp"
"golang.org/x/tools/gopls/internal/lsp/cache"
"golang.org/x/tools/gopls/internal/lsp/debug"
"golang.org/x/tools/gopls/internal/lsp/lsprpc"
"golang.org/x/tools/gopls/internal/lsp/protocol"
"golang.org/x/tools/gopls/internal/lsp/source"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/tool"
"golang.org/x/tools/internal/xcontext"
@ -422,6 +422,10 @@ func fileURI(uri protocol.DocumentURI) span.URI {
return sURI
}
func (c *cmdClient) CodeLensRefresh(context.Context) error { return nil }
func (c *cmdClient) LogTrace(context.Context, *protocol.LogTraceParams) error { return nil }
func (c *cmdClient) ShowMessage(ctx context.Context, p *protocol.ShowMessageParams) error { return nil }
func (c *cmdClient) ShowMessageRequest(ctx context.Context, p *protocol.ShowMessageRequestParams) (*protocol.MessageActionItem, error) {

View File

@ -30,6 +30,10 @@ type Client struct {
hooks ClientHooks
}
func (c *Client) CodeLensRefresh(context.Context) error { return nil }
func (c *Client) LogTrace(context.Context, *protocol.LogTraceParams) error { return nil }
func (c *Client) ShowMessage(ctx context.Context, params *protocol.ShowMessageParams) error {
if c.hooks.OnShowMessage != nil {
return c.hooks.OnShowMessage(ctx, params)

View File

@ -15,12 +15,12 @@ import (
"path/filepath"
"sync"
"golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/bug"
"golang.org/x/tools/gopls/internal/lsp/debug"
"golang.org/x/tools/gopls/internal/lsp/protocol"
"golang.org/x/tools/gopls/internal/lsp/source"
"golang.org/x/tools/internal/bug"
"golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/span"
)
@ -173,10 +173,7 @@ See https://github.com/golang/go/issues/45732 for more information.`,
},
},
},
ServerInfo: struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
}{
ServerInfo: protocol.PServerInfoMsg_initialize{
Name: "gopls",
Version: string(goplsVersion),
},
@ -404,13 +401,12 @@ func (s *Server) fetchConfig(ctx context.Context, name string, folder span.URI,
return nil
}
configs, err := s.client.Configuration(ctx, &protocol.ParamConfiguration{
ConfigurationParams: protocol.ConfigurationParams{
Items: []protocol.ConfigurationItem{{
ScopeURI: string(folder),
Section: "gopls",
}},
},
})
Items: []protocol.ConfigurationItem{{
ScopeURI: string(folder),
Section: "gopls",
}},
},
)
if err != nil {
return fmt.Errorf("failed to get workspace configuration from client (%s): %v", folder, err)
}

View File

@ -10,7 +10,6 @@ import (
var (
namesTextDocumentSyncKind [int(Incremental) + 1]string
namesInitializeError [int(UnknownProtocolVersion) + 1]string
namesMessageType [int(Log) + 1]string
namesFileChangeType [int(Deleted) + 1]string
namesWatchKind [int(WatchDelete) + 1]string
@ -29,8 +28,6 @@ func init() {
namesTextDocumentSyncKind[int(Full)] = "Full"
namesTextDocumentSyncKind[int(Incremental)] = "Incremental"
namesInitializeError[int(UnknownProtocolVersion)] = "UnknownProtocolVersion"
namesMessageType[int(Error)] = "Error"
namesMessageType[int(Warning)] = "Warning"
namesMessageType[int(Info)] = "Info"
@ -149,14 +146,6 @@ func ParseTextDocumentSyncKind(s string) TextDocumentSyncKind {
return TextDocumentSyncKind(parseEnum(s, namesTextDocumentSyncKind[:]))
}
func (e InitializeError) Format(f fmt.State, c rune) {
formatEnum(f, c, int(e), namesInitializeError[:], "InitializeError")
}
func ParseInitializeError(s string) InitializeError {
return InitializeError(parseEnum(s, namesInitializeError[:]))
}
func (e MessageType) Format(f fmt.State, c rune) {
formatEnum(f, c, int(e), namesMessageType[:], "MessageType")
}
@ -173,10 +162,6 @@ func ParseFileChangeType(s string) FileChangeType {
return FileChangeType(parseEnum(s, namesFileChangeType[:]))
}
func (e WatchKind) Format(f fmt.State, c rune) {
formatEnum(f, c, int(e), namesWatchKind[:], "WatchKind")
}
func ParseWatchKind(s string) WatchKind {
return WatchKind(parseEnum(s, namesWatchKind[:]))
}

View File

@ -1,104 +1,90 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Copyright 2019-2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated (see typescript/README.md) DO NOT EDIT.
package protocol
// Package protocol contains data types and code for LSP json rpcs
// generated automatically from vscode-languageserver-node
// commit: 696f9285bf849b73745682fdb1c1feac73eb8772
// last fetched Fri Apr 01 2022 10:53:41 GMT-0400 (Eastern Daylight Time)
// Code generated from version 3.17.0 of protocol/metaModel.json.
// git hash 8de18faed635819dd2bc631d2c26ce4a18f7cf4a (as of Tue Sep 13 10:45:25 2022)
// Code generated; DO NOT EDIT.
import (
"context"
"encoding/json"
"fmt"
"golang.org/x/tools/internal/jsonrpc2"
)
type Client interface {
ShowMessage(context.Context, *ShowMessageParams) error
LogMessage(context.Context, *LogMessageParams) error
Event(context.Context, *interface{}) error
PublishDiagnostics(context.Context, *PublishDiagnosticsParams) error
Progress(context.Context, *ProgressParams) error
WorkspaceFolders(context.Context) ([]WorkspaceFolder /*WorkspaceFolder[] | null*/, error)
Configuration(context.Context, *ParamConfiguration) ([]LSPAny, error)
WorkDoneProgressCreate(context.Context, *WorkDoneProgressCreateParams) error
ShowDocument(context.Context, *ShowDocumentParams) (*ShowDocumentResult, error)
RegisterCapability(context.Context, *RegistrationParams) error
UnregisterCapability(context.Context, *UnregistrationParams) error
ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem /*MessageActionItem | null*/, error)
ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error)
LogTrace(context.Context, *LogTraceParams) error // $/logTrace
Progress(context.Context, *ProgressParams) error // $/progress
RegisterCapability(context.Context, *RegistrationParams) error // client/registerCapability
UnregisterCapability(context.Context, *UnregistrationParams) error // client/unregisterCapability
Event(context.Context, *interface{}) error // telemetry/event
PublishDiagnostics(context.Context, *PublishDiagnosticsParams) error // textDocument/publishDiagnostics
LogMessage(context.Context, *LogMessageParams) error // window/logMessage
ShowDocument(context.Context, *ShowDocumentParams) (*ShowDocumentResult, error) // window/showDocument
ShowMessage(context.Context, *ShowMessageParams) error // window/showMessage
ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem, error) // window/showMessageRequest
WorkDoneProgressCreate(context.Context, *WorkDoneProgressCreateParams) error // window/workDoneProgress/create
ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) // workspace/applyEdit
CodeLensRefresh(context.Context) error // workspace/codeLens/refresh
Configuration(context.Context, *ParamConfiguration) ([]LSPAny, error) // workspace/configuration
WorkspaceFolders(context.Context) ([]WorkspaceFolder, error) // workspace/workspaceFolders
}
func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier, r jsonrpc2.Request) (bool, error) {
switch r.Method() {
case "window/showMessage": // notif
var params ShowMessageParams
case "$/logTrace":
var params LogTraceParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.ShowMessage(ctx, &params)
return true, reply(ctx, nil, err)
case "window/logMessage": // notif
var params LogMessageParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.LogMessage(ctx, &params)
return true, reply(ctx, nil, err)
case "telemetry/event": // notif
var params interface{}
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.Event(ctx, &params)
return true, reply(ctx, nil, err)
case "textDocument/publishDiagnostics": // notif
var params PublishDiagnosticsParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.PublishDiagnostics(ctx, &params)
return true, reply(ctx, nil, err)
case "$/progress": // notif
err := client.LogTrace(ctx, &params)
return true, reply(ctx, nil, err) // 231
case "$/progress":
var params ProgressParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.Progress(ctx, &params)
return true, reply(ctx, nil, err)
case "workspace/workspaceFolders": // req
if len(r.Params()) > 0 {
return true, reply(ctx, nil, fmt.Errorf("%w: expected no params", jsonrpc2.ErrInvalidParams))
}
resp, err := client.WorkspaceFolders(ctx)
if err != nil {
return true, reply(ctx, nil, err)
}
return true, reply(ctx, resp, nil)
case "workspace/configuration": // req
var params ParamConfiguration
return true, reply(ctx, nil, err) // 231
case "client/registerCapability":
var params RegistrationParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
resp, err := client.Configuration(ctx, &params)
if err != nil {
return true, reply(ctx, nil, err)
}
return true, reply(ctx, resp, nil)
case "window/workDoneProgress/create": // req
var params WorkDoneProgressCreateParams
err := client.RegisterCapability(ctx, &params)
return true, reply(ctx, nil, err) // 155
case "client/unregisterCapability":
var params UnregistrationParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.WorkDoneProgressCreate(ctx, &params)
return true, reply(ctx, nil, err)
case "window/showDocument": // req
err := client.UnregisterCapability(ctx, &params)
return true, reply(ctx, nil, err) // 155
case "telemetry/event":
var params interface{}
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.Event(ctx, &params)
return true, reply(ctx, nil, err) // 231
case "textDocument/publishDiagnostics":
var params PublishDiagnosticsParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.PublishDiagnostics(ctx, &params)
return true, reply(ctx, nil, err) // 231
case "window/logMessage":
var params LogMessageParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.LogMessage(ctx, &params)
return true, reply(ctx, nil, err) // 231
case "window/showDocument":
var params ShowDocumentParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
@ -107,22 +93,15 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier,
if err != nil {
return true, reply(ctx, nil, err)
}
return true, reply(ctx, resp, nil)
case "client/registerCapability": // req
var params RegistrationParams
return true, reply(ctx, resp, nil) // 146
case "window/showMessage":
var params ShowMessageParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.RegisterCapability(ctx, &params)
return true, reply(ctx, nil, err)
case "client/unregisterCapability": // req
var params UnregistrationParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.UnregisterCapability(ctx, &params)
return true, reply(ctx, nil, err)
case "window/showMessageRequest": // req
err := client.ShowMessage(ctx, &params)
return true, reply(ctx, nil, err) // 231
case "window/showMessageRequest":
var params ShowMessageRequestParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
@ -131,8 +110,15 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier,
if err != nil {
return true, reply(ctx, nil, err)
}
return true, reply(ctx, resp, nil)
case "workspace/applyEdit": // req
return true, reply(ctx, resp, nil) // 146
case "window/workDoneProgress/create":
var params WorkDoneProgressCreateParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
err := client.WorkDoneProgressCreate(ctx, &params)
return true, reply(ctx, nil, err) // 155
case "workspace/applyEdit":
var params ApplyWorkspaceEditParams
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
@ -141,80 +127,93 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier,
if err != nil {
return true, reply(ctx, nil, err)
}
return true, reply(ctx, resp, nil)
return true, reply(ctx, resp, nil) // 146
case "workspace/codeLens/refresh":
err := client.CodeLensRefresh(ctx)
return true, reply(ctx, nil, err) // 170
case "workspace/configuration":
var params ParamConfiguration
if err := json.Unmarshal(r.Params(), &params); err != nil {
return true, sendParseError(ctx, reply, err)
}
resp, err := client.Configuration(ctx, &params)
if err != nil {
return true, reply(ctx, nil, err)
}
return true, reply(ctx, resp, nil) // 146
case "workspace/workspaceFolders":
resp, err := client.WorkspaceFolders(ctx)
if err != nil {
return true, reply(ctx, nil, err)
}
return true, reply(ctx, resp, nil) // 165
default:
return false, nil
}
}
func (s *clientDispatcher) ShowMessage(ctx context.Context, params *ShowMessageParams) error {
return s.sender.Notify(ctx, "window/showMessage", params)
}
func (s *clientDispatcher) LogMessage(ctx context.Context, params *LogMessageParams) error {
return s.sender.Notify(ctx, "window/logMessage", params)
}
func (s *clientDispatcher) Event(ctx context.Context, params *interface{}) error {
return s.sender.Notify(ctx, "telemetry/event", params)
}
func (s *clientDispatcher) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error {
return s.sender.Notify(ctx, "textDocument/publishDiagnostics", params)
}
func (s *clientDispatcher) LogTrace(ctx context.Context, params *LogTraceParams) error {
return s.sender.Notify(ctx, "$/logTrace", params)
} // 244
func (s *clientDispatcher) Progress(ctx context.Context, params *ProgressParams) error {
return s.sender.Notify(ctx, "$/progress", params)
}
func (s *clientDispatcher) WorkspaceFolders(ctx context.Context) ([]WorkspaceFolder /*WorkspaceFolder[] | null*/, error) {
var result []WorkspaceFolder /*WorkspaceFolder[] | null*/
if err := s.sender.Call(ctx, "workspace/workspaceFolders", nil, &result); err != nil {
return nil, err
}
return result, nil
}
func (s *clientDispatcher) Configuration(ctx context.Context, params *ParamConfiguration) ([]LSPAny, error) {
var result []LSPAny
if err := s.sender.Call(ctx, "workspace/configuration", params, &result); err != nil {
return nil, err
}
return result, nil
}
func (s *clientDispatcher) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error {
return s.sender.Call(ctx, "window/workDoneProgress/create", params, nil) // Call, not Notify
}
} // 244
func (s *clientDispatcher) RegisterCapability(ctx context.Context, params *RegistrationParams) error {
return s.sender.Call(ctx, "client/registerCapability", params, nil)
} // 194
func (s *clientDispatcher) UnregisterCapability(ctx context.Context, params *UnregistrationParams) error {
return s.sender.Call(ctx, "client/unregisterCapability", params, nil)
} // 194
func (s *clientDispatcher) Event(ctx context.Context, params *interface{}) error {
return s.sender.Notify(ctx, "telemetry/event", params)
} // 244
func (s *clientDispatcher) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error {
return s.sender.Notify(ctx, "textDocument/publishDiagnostics", params)
} // 244
func (s *clientDispatcher) LogMessage(ctx context.Context, params *LogMessageParams) error {
return s.sender.Notify(ctx, "window/logMessage", params)
} // 244
func (s *clientDispatcher) ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) {
var result *ShowDocumentResult
if err := s.sender.Call(ctx, "window/showDocument", params, &result); err != nil {
return nil, err
}
return result, nil
}
func (s *clientDispatcher) RegisterCapability(ctx context.Context, params *RegistrationParams) error {
return s.sender.Call(ctx, "client/registerCapability", params, nil) // Call, not Notify
}
func (s *clientDispatcher) UnregisterCapability(ctx context.Context, params *UnregistrationParams) error {
return s.sender.Call(ctx, "client/unregisterCapability", params, nil) // Call, not Notify
}
func (s *clientDispatcher) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem /*MessageActionItem | null*/, error) {
var result *MessageActionItem /*MessageActionItem | null*/
} // 169
func (s *clientDispatcher) ShowMessage(ctx context.Context, params *ShowMessageParams) error {
return s.sender.Notify(ctx, "window/showMessage", params)
} // 244
func (s *clientDispatcher) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) {
var result *MessageActionItem
if err := s.sender.Call(ctx, "window/showMessageRequest", params, &result); err != nil {
return nil, err
}
return result, nil
}
} // 169
func (s *clientDispatcher) WorkDoneProgressCreate(ctx context.Context, params *WorkDoneProgressCreateParams) error {
return s.sender.Call(ctx, "window/workDoneProgress/create", params, nil)
} // 194
func (s *clientDispatcher) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) {
var result *ApplyWorkspaceEditResult
if err := s.sender.Call(ctx, "workspace/applyEdit", params, &result); err != nil {
return nil, err
}
return result, nil
}
} // 169
func (s *clientDispatcher) CodeLensRefresh(ctx context.Context) error {
return s.sender.Call(ctx, "workspace/codeLens/refresh", nil, nil)
} // 209
func (s *clientDispatcher) Configuration(ctx context.Context, params *ParamConfiguration) ([]LSPAny, error) {
var result []LSPAny
if err := s.sender.Call(ctx, "workspace/configuration", params, &result); err != nil {
return nil, err
}
return result, nil
} // 169
func (s *clientDispatcher) WorkspaceFolders(ctx context.Context) ([]WorkspaceFolder, error) {
var result []WorkspaceFolder
if err := s.sender.Call(ctx, "workspace/workspaceFolders", nil, &result); err != nil {
return nil, err
}
return result, nil
} // 204

View File

@ -0,0 +1,440 @@
// Copyright 2019-2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package protocol
// Code generated from version 3.17.0 of protocol/metaModel.json.
// git hash 8de18faed635819dd2bc631d2c26ce4a18f7cf4a (as of Tue Sep 13 10:45:25 2022)
// Code generated; DO NOT EDIT.
import "encoding/json"
import "errors"
import "fmt"
func (t OrFEditRangePItemDefaults) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case FEditRangePItemDefaults:
return json.Marshal(x)
case Range:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [FEditRangePItemDefaults Range]", t)
}
func (t *OrFEditRangePItemDefaults) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 FEditRangePItemDefaults
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 Range
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [FEditRangePItemDefaults Range]")
}
func (t OrFNotebookPNotebookSelector) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case NotebookDocumentFilter:
return json.Marshal(x)
case string:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [NotebookDocumentFilter string]", t)
}
func (t *OrFNotebookPNotebookSelector) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 NotebookDocumentFilter
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 string
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [NotebookDocumentFilter string]")
}
func (t OrPLocation_workspace_symbol) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case Location:
return json.Marshal(x)
case PLocationMsg_workspace_symbol:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [Location PLocationMsg_workspace_symbol]", t)
}
func (t *OrPLocation_workspace_symbol) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 Location
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 PLocationMsg_workspace_symbol
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [Location PLocationMsg_workspace_symbol]")
}
func (t OrPSection_workspace_didChangeConfiguration) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case []string:
return json.Marshal(x)
case string:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [[]string string]", t)
}
func (t *OrPSection_workspace_didChangeConfiguration) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 []string
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 string
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [[]string string]")
}
func (t OrPTooltipPLabel) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case MarkupContent:
return json.Marshal(x)
case string:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [MarkupContent string]", t)
}
func (t *OrPTooltipPLabel) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 MarkupContent
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 string
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [MarkupContent string]")
}
func (t OrPTooltip_textDocument_inlayHint) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case MarkupContent:
return json.Marshal(x)
case string:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [MarkupContent string]", t)
}
func (t *OrPTooltip_textDocument_inlayHint) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 MarkupContent
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 string
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [MarkupContent string]")
}
func (t Or_Definition) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case Location:
return json.Marshal(x)
case []Location:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [Location []Location]", t)
}
func (t *Or_Definition) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 Location
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 []Location
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [Location []Location]")
}
func (t Or_DocumentDiagnosticReport) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case RelatedFullDocumentDiagnosticReport:
return json.Marshal(x)
case RelatedUnchangedDocumentDiagnosticReport:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [RelatedFullDocumentDiagnosticReport RelatedUnchangedDocumentDiagnosticReport]", t)
}
func (t *Or_DocumentDiagnosticReport) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 RelatedFullDocumentDiagnosticReport
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 RelatedUnchangedDocumentDiagnosticReport
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [RelatedFullDocumentDiagnosticReport RelatedUnchangedDocumentDiagnosticReport]")
}
func (t Or_DocumentFilter) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case NotebookCellTextDocumentFilter:
return json.Marshal(x)
case TextDocumentFilter:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [NotebookCellTextDocumentFilter TextDocumentFilter]", t)
}
func (t *Or_DocumentFilter) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 NotebookCellTextDocumentFilter
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 TextDocumentFilter
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [NotebookCellTextDocumentFilter TextDocumentFilter]")
}
func (t Or_InlineValue) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case InlineValueEvaluatableExpression:
return json.Marshal(x)
case InlineValueText:
return json.Marshal(x)
case InlineValueVariableLookup:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [InlineValueEvaluatableExpression InlineValueText InlineValueVariableLookup]", t)
}
func (t *Or_InlineValue) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 InlineValueEvaluatableExpression
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 InlineValueText
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
var h2 InlineValueVariableLookup
if err := json.Unmarshal(x, &h2); err == nil {
t.Value = h2
return nil
}
return errors.New("unmarshal failed to match one of [InlineValueEvaluatableExpression InlineValueText InlineValueVariableLookup]")
}
func (t Or_MarkedString) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case Msg_MarkedString:
return json.Marshal(x)
case string:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [Msg_MarkedString string]", t)
}
func (t *Or_MarkedString) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 Msg_MarkedString
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 string
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [Msg_MarkedString string]")
}
func (t Or_RelativePattern_baseUri) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case URI:
return json.Marshal(x)
case WorkspaceFolder:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [URI WorkspaceFolder]", t)
}
func (t *Or_RelativePattern_baseUri) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 URI
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 WorkspaceFolder
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [URI WorkspaceFolder]")
}
func (t Or_WorkspaceDocumentDiagnosticReport) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case WorkspaceFullDocumentDiagnosticReport:
return json.Marshal(x)
case WorkspaceUnchangedDocumentDiagnosticReport:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [WorkspaceFullDocumentDiagnosticReport WorkspaceUnchangedDocumentDiagnosticReport]", t)
}
func (t *Or_WorkspaceDocumentDiagnosticReport) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 WorkspaceFullDocumentDiagnosticReport
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 WorkspaceUnchangedDocumentDiagnosticReport
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [WorkspaceFullDocumentDiagnosticReport WorkspaceUnchangedDocumentDiagnosticReport]")
}
func (t Or_textDocument_declaration) MarshalJSON() ([]byte, error) {
switch x := t.Value.(type) {
case Declaration:
return json.Marshal(x)
case []DeclarationLink:
return json.Marshal(x)
case nil:
return []byte("null"), nil
}
return nil, fmt.Errorf("type %T not one of [Declaration []DeclarationLink]", t)
}
func (t *Or_textDocument_declaration) UnmarshalJSON(x []byte) error {
if string(x) == "null" {
t.Value = nil
return nil
}
var h0 Declaration
if err := json.Unmarshal(x, &h0); err == nil {
t.Value = h0
return nil
}
var h1 []DeclarationLink
if err := json.Unmarshal(x, &h1); err == nil {
t.Value = h1
return nil
}
return errors.New("unmarshal failed to match one of [Declaration []DeclarationLink]")
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -10,10 +10,10 @@ import (
"fmt"
"sync"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/gopls/internal/lsp/progress"
"golang.org/x/tools/gopls/internal/lsp/protocol"
"golang.org/x/tools/gopls/internal/lsp/source"
"golang.org/x/tools/internal/jsonrpc2"
"golang.org/x/tools/internal/span"
)
@ -123,7 +123,7 @@ type pendingModificationSet struct {
changes []source.FileModification
}
func (s *Server) workDoneProgressCancel(params *protocol.WorkDoneProgressCancelParams) error {
func (s *Server) workDoneProgressCancel(ctx context.Context, params *protocol.WorkDoneProgressCancelParams) error {
return s.progress.Cancel(params.Token)
}

View File

@ -20,10 +20,6 @@ func (s *Server) CodeLens(ctx context.Context, params *protocol.CodeLensParams)
return s.codeLens(ctx, params)
}
func (s *Server) CodeLensRefresh(context.Context) error {
return notImplemented("CodeLensRefresh")
}
func (s *Server) ColorPresentation(context.Context, *protocol.ColorPresentationParams) ([]protocol.ColorPresentation, error) {
return nil, notImplemented("ColorPresentation")
}
@ -32,11 +28,11 @@ func (s *Server) Completion(ctx context.Context, params *protocol.CompletionPara
return s.completion(ctx, params)
}
func (s *Server) Declaration(context.Context, *protocol.DeclarationParams) (protocol.Declaration, error) {
func (s *Server) Declaration(context.Context, *protocol.DeclarationParams) (*protocol.Or_textDocument_declaration, error) {
return nil, notImplemented("Declaration")
}
func (s *Server) Definition(ctx context.Context, params *protocol.DefinitionParams) (protocol.Definition, error) {
func (s *Server) Definition(ctx context.Context, params *protocol.DefinitionParams) ([]protocol.Location, error) {
return s.definition(ctx, params)
}
@ -144,7 +140,7 @@ func (s *Server) Hover(ctx context.Context, params *protocol.HoverParams) (*prot
return s.hover(ctx, params)
}
func (s *Server) Implementation(ctx context.Context, params *protocol.ImplementationParams) (protocol.Definition, error) {
func (s *Server) Implementation(ctx context.Context, params *protocol.ImplementationParams) ([]protocol.Location, error) {
return s.implementation(ctx, params)
}
@ -180,10 +176,6 @@ func (s *Server) LinkedEditingRange(context.Context, *protocol.LinkedEditingRang
return nil, notImplemented("LinkedEditingRange")
}
func (s *Server) LogTrace(context.Context, *protocol.LogTraceParams) error {
return notImplemented("LogTrace")
}
func (s *Server) Moniker(context.Context, *protocol.MonikerParams) ([]protocol.Moniker, error) {
return nil, notImplemented("Moniker")
}
@ -212,6 +204,10 @@ func (s *Server) PrepareTypeHierarchy(context.Context, *protocol.TypeHierarchyPr
return nil, notImplemented("PrepareTypeHierarchy")
}
func (s *Server) Progress(context.Context, *protocol.ProgressParams) error {
return notImplemented("Progress")
}
func (s *Server) RangeFormatting(context.Context, *protocol.DocumentRangeFormattingParams) ([]protocol.TextEdit, error) {
return nil, notImplemented("RangeFormatting")
}
@ -292,7 +288,7 @@ func (s *Server) Symbol(ctx context.Context, params *protocol.WorkspaceSymbolPar
return s.symbol(ctx, params)
}
func (s *Server) TypeDefinition(ctx context.Context, params *protocol.TypeDefinitionParams) (protocol.Definition, error) {
func (s *Server) TypeDefinition(ctx context.Context, params *protocol.TypeDefinitionParams) ([]protocol.Location, error) {
return s.typeDefinition(ctx, params)
}
@ -317,5 +313,5 @@ func (s *Server) WillSaveWaitUntil(context.Context, *protocol.WillSaveTextDocume
}
func (s *Server) WorkDoneProgressCancel(ctx context.Context, params *protocol.WorkDoneProgressCancelParams) error {
return s.workDoneProgressCancel(params)
return s.workDoneProgressCancel(ctx, params)
}

View File

@ -99,7 +99,7 @@ func allDeltas(t *testing.T, v [][]int, repls ...string) {
}
func tryChange(start, end int, repl string) error {
var p, q protocol.InitializeParams
var p, q protocol.ParamInitialize
mod := input[:start] + repl + input[end:]
excerpt := func() (string, string) {
a := start - 5