mirror of https://github.com/golang/go.git
internal/lsp: make ShowDocument RPC available to gopls
The window/showDocument RPC is now correctly classified as being sent from the server to the client. Change-Id: I659528af69662fb709242d326563d52070fd5702 Reviewed-on: https://go-review.googlesource.com/c/tools/+/315990 Run-TryBot: Peter Weinberger <pjw@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Peter Weinberger <pjw@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
3e17c62e37
commit
062bf4eb8a
|
|
@ -443,6 +443,10 @@ func (c *cmdClient) Progress(context.Context, *protocol.ProgressParams) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *cmdClient) ShowDocument(context.Context, *protocol.ShowDocumentParams) (*protocol.ShowDocumentResult, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *cmdClient) WorkDoneProgressCreate(context.Context, *protocol.WorkDoneProgressCreateParams) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,10 @@ func (c *Client) WorkDoneProgressCreate(ctx context.Context, params *protocol.Wo
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) ShowDocument(context.Context, *protocol.ShowDocumentParams) (*protocol.ShowDocumentResult, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// ApplyEdit applies edits sent from the server.
|
||||
func (c *Client) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResponse, error) {
|
||||
if len(params.Edit.Changes) != 0 {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ type Client interface {
|
|||
WorkspaceFolders(context.Context) ([]WorkspaceFolder /*WorkspaceFolder[] | null*/, error)
|
||||
Configuration(context.Context, *ParamConfiguration) ([]interface{}, 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)
|
||||
|
|
@ -91,6 +92,13 @@ func clientDispatch(ctx context.Context, client Client, reply jsonrpc2.Replier,
|
|||
}
|
||||
err := client.WorkDoneProgressCreate(ctx, ¶ms)
|
||||
return true, reply(ctx, nil, err)
|
||||
case "window/showDocument": // req
|
||||
var params ShowDocumentParams
|
||||
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
||||
return true, sendParseError(ctx, reply, err)
|
||||
}
|
||||
resp, err := client.ShowDocument(ctx, ¶ms)
|
||||
return true, reply(ctx, resp, err)
|
||||
case "client/registerCapability": // req
|
||||
var params RegistrationParams
|
||||
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
||||
|
|
@ -164,6 +172,14 @@ func (s *clientDispatcher) WorkDoneProgressCreate(ctx context.Context, params *W
|
|||
return Call(ctx, s.Conn, "window/workDoneProgress/create", params, nil) // Call, not Notify
|
||||
}
|
||||
|
||||
func (s *clientDispatcher) ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) {
|
||||
var result *ShowDocumentResult
|
||||
if err := Call(ctx, s.Conn, "window/showDocument", params, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *clientDispatcher) RegisterCapability(ctx context.Context, params *RegistrationParams) error {
|
||||
return Call(ctx, s.Conn, "client/registerCapability", params, nil) // Call, not Notify
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ type Server interface {
|
|||
SemanticTokensFullDelta(context.Context, *SemanticTokensDeltaParams) (interface{} /* SemanticTokens | SemanticTokensDelta | float64*/, error)
|
||||
SemanticTokensRange(context.Context, *SemanticTokensRangeParams) (*SemanticTokens /*SemanticTokens | null*/, error)
|
||||
SemanticTokensRefresh(context.Context) error
|
||||
ShowDocument(context.Context, *ShowDocumentParams) (*ShowDocumentResult, error)
|
||||
LinkedEditingRange(context.Context, *LinkedEditingRangeParams) (*LinkedEditingRanges /*LinkedEditingRanges | null*/, error)
|
||||
WillCreateFiles(context.Context, *CreateFilesParams) (*WorkspaceEdit /*WorkspaceEdit | null*/, error)
|
||||
WillRenameFiles(context.Context, *RenameFilesParams) (*WorkspaceEdit /*WorkspaceEdit | null*/, error)
|
||||
|
|
@ -294,13 +293,6 @@ func serverDispatch(ctx context.Context, server Server, reply jsonrpc2.Replier,
|
|||
}
|
||||
err := server.SemanticTokensRefresh(ctx)
|
||||
return true, reply(ctx, nil, err)
|
||||
case "window/showDocument": // req
|
||||
var params ShowDocumentParams
|
||||
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
||||
return true, sendParseError(ctx, reply, err)
|
||||
}
|
||||
resp, err := server.ShowDocument(ctx, ¶ms)
|
||||
return true, reply(ctx, resp, err)
|
||||
case "textDocument/linkedEditingRange": // req
|
||||
var params LinkedEditingRangeParams
|
||||
if err := json.Unmarshal(r.Params(), ¶ms); err != nil {
|
||||
|
|
@ -708,14 +700,6 @@ func (s *serverDispatcher) SemanticTokensRefresh(ctx context.Context) error {
|
|||
return Call(ctx, s.Conn, "workspace/semanticTokens/refresh", nil, nil)
|
||||
}
|
||||
|
||||
func (s *serverDispatcher) ShowDocument(ctx context.Context, params *ShowDocumentParams) (*ShowDocumentResult, error) {
|
||||
var result *ShowDocumentResult
|
||||
if err := Call(ctx, s.Conn, "window/showDocument", params, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *serverDispatcher) LinkedEditingRange(ctx context.Context, params *LinkedEditingRangeParams) (*LinkedEditingRanges /*LinkedEditingRanges | null*/, error) {
|
||||
var result *LinkedEditingRanges /*LinkedEditingRanges | null*/
|
||||
if err := Call(ctx, s.Conn, "textDocument/linkedEditingRange", params, &result); err != nil {
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ function setReceives() {
|
|||
receives.set('workspace/applyEdit', 'client');
|
||||
receives.set('textDocument/publishDiagnostics', 'client');
|
||||
receives.set('window/workDoneProgress/create', 'client');
|
||||
receives.set('window/showDocument', 'client');
|
||||
receives.set('$/progress', 'client');
|
||||
// a small check
|
||||
receives.forEach((_, k) => {
|
||||
|
|
|
|||
|
|
@ -228,10 +228,6 @@ func (s *Server) SetTrace(context.Context, *protocol.SetTraceParams) error {
|
|||
return notImplemented("SetTrace")
|
||||
}
|
||||
|
||||
func (s *Server) ShowDocument(context.Context, *protocol.ShowDocumentParams) (*protocol.ShowDocumentResult, error) {
|
||||
return nil, notImplemented("ShowDocument")
|
||||
}
|
||||
|
||||
func (s *Server) Shutdown(ctx context.Context) error {
|
||||
return s.shutdown(ctx)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue