internal/lsp: generate RPC interface from Typescript source
The generated code adds some server methods that are unsupported, but were prviously unimplemented, and makes small adjusments to some parameter types. Change-Id: I3dd32cafa3e457193f0771e0f8e150c88b381c82 Reviewed-on: https://go-review.googlesource.com/c/tools/+/173420 Run-TryBot: Peter Weinberger <pjw@google.com> Reviewed-by: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
b9fed7929f
commit
08ecc9edd9
|
@ -190,7 +190,7 @@ func (c *baseClient) LogMessage(ctx context.Context, p *protocol.LogMessageParam
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (c *baseClient) Telemetry(ctx context.Context, t interface{}) error { return nil }
|
||||
func (c *baseClient) Event(ctx context.Context, t *interface{}) error { return nil }
|
||||
func (c *baseClient) RegisterCapability(ctx context.Context, p *protocol.RegistrationParams) error {
|
||||
return nil
|
||||
}
|
||||
|
@ -218,8 +218,8 @@ func (c *baseClient) Configuration(ctx context.Context, p *protocol.Configuratio
|
|||
}
|
||||
return results, nil
|
||||
}
|
||||
func (c *baseClient) ApplyEdit(ctx context.Context, p *protocol.ApplyWorkspaceEditParams) (bool, error) {
|
||||
return false, nil
|
||||
func (c *baseClient) ApplyEdit(ctx context.Context, p *protocol.ApplyWorkspaceEditParams) (*protocol.ApplyWorkspaceEditResponse, error) {
|
||||
return &protocol.ApplyWorkspaceEditResponse{Applied: false, FailureReason: "not implemented"}, nil
|
||||
}
|
||||
func (c *baseClient) PublishDiagnostics(ctx context.Context, p *protocol.PublishDiagnosticsParams) error {
|
||||
return nil
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
// Copyright 2018 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
|
||||
|
||||
//automatically generated
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
@ -14,15 +12,15 @@ import (
|
|||
|
||||
type Client interface {
|
||||
ShowMessage(context.Context, *ShowMessageParams) error
|
||||
ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem, error)
|
||||
LogMessage(context.Context, *LogMessageParams) error
|
||||
Telemetry(context.Context, interface{}) error
|
||||
RegisterCapability(context.Context, *RegistrationParams) error
|
||||
UnregisterCapability(context.Context, *UnregistrationParams) error
|
||||
Event(context.Context, *interface{}) error
|
||||
PublishDiagnostics(context.Context, *PublishDiagnosticsParams) error
|
||||
WorkspaceFolders(context.Context) ([]WorkspaceFolder, error)
|
||||
Configuration(context.Context, *ConfigurationParams) ([]interface{}, error)
|
||||
ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (bool, error)
|
||||
PublishDiagnostics(context.Context, *PublishDiagnosticsParams) error
|
||||
RegisterCapability(context.Context, *RegistrationParams) error
|
||||
UnregisterCapability(context.Context, *UnregistrationParams) error
|
||||
ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem, error)
|
||||
ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResponse, error)
|
||||
}
|
||||
|
||||
func clientHandler(log xlog.Logger, client Client) jsonrpc2.Handler {
|
||||
|
@ -35,8 +33,7 @@ func clientHandler(log xlog.Logger, client Client) jsonrpc2.Handler {
|
|||
return
|
||||
}
|
||||
conn.Cancel(params.ID)
|
||||
|
||||
case "window/showMessage":
|
||||
case "window/showMessage": // notif
|
||||
var params ShowMessageParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
|
@ -45,19 +42,7 @@ func clientHandler(log xlog.Logger, client Client) jsonrpc2.Handler {
|
|||
if err := client.ShowMessage(ctx, ¶ms); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
case "window/showMessageRequest":
|
||||
var params ShowMessageRequestParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
return
|
||||
}
|
||||
resp, err := client.ShowMessageRequest(ctx, ¶ms)
|
||||
if err := conn.Reply(ctx, r, resp, err); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
case "window/logMessage":
|
||||
case "window/logMessage": // notif
|
||||
var params LogMessageParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
|
@ -66,38 +51,25 @@ func clientHandler(log xlog.Logger, client Client) jsonrpc2.Handler {
|
|||
if err := client.LogMessage(ctx, ¶ms); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
case "telemetry/event":
|
||||
case "telemetry/event": // notif
|
||||
var params interface{}
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
return
|
||||
}
|
||||
if err := client.Telemetry(ctx, ¶ms); err != nil {
|
||||
if err := client.Event(ctx, ¶ms); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
case "client/registerCapability":
|
||||
var params RegistrationParams
|
||||
case "textDocument/publishDiagnostics": // notif
|
||||
var params PublishDiagnosticsParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
return
|
||||
}
|
||||
if err := client.RegisterCapability(ctx, ¶ms); err != nil {
|
||||
if err := client.PublishDiagnostics(ctx, ¶ms); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
case "client/unregisterCapability":
|
||||
var params UnregistrationParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
return
|
||||
}
|
||||
if err := client.UnregisterCapability(ctx, ¶ms); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
case "workspace/workspaceFolders":
|
||||
case "workspace/workspaceFolders": // req
|
||||
if r.Params != nil {
|
||||
conn.Reply(ctx, r, nil, jsonrpc2.NewErrorf(jsonrpc2.CodeInvalidParams, "Expected no params"))
|
||||
return
|
||||
|
@ -106,8 +78,7 @@ func clientHandler(log xlog.Logger, client Client) jsonrpc2.Handler {
|
|||
if err := conn.Reply(ctx, r, resp, err); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
case "workspace/configuration":
|
||||
case "workspace/configuration": // req
|
||||
var params ConfigurationParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
|
@ -117,8 +88,35 @@ func clientHandler(log xlog.Logger, client Client) jsonrpc2.Handler {
|
|||
if err := conn.Reply(ctx, r, resp, err); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
case "workspace/applyEdit":
|
||||
case "client/registerCapability": // req
|
||||
var params RegistrationParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
return
|
||||
}
|
||||
if err := client.RegisterCapability(ctx, ¶ms); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
case "client/unregisterCapability": // req
|
||||
var params UnregistrationParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
return
|
||||
}
|
||||
if err := client.UnregisterCapability(ctx, ¶ms); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
case "window/showMessageRequest": // req
|
||||
var params ShowMessageRequestParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
return
|
||||
}
|
||||
resp, err := client.ShowMessageRequest(ctx, ¶ms)
|
||||
if err := conn.Reply(ctx, r, resp, err); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
case "workspace/applyEdit": // req
|
||||
var params ApplyWorkspaceEditParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
|
@ -129,16 +127,6 @@ func clientHandler(log xlog.Logger, client Client) jsonrpc2.Handler {
|
|||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
case "textDocument/publishDiagnostics":
|
||||
var params PublishDiagnosticsParams
|
||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||
sendParseError(ctx, log, conn, r, err)
|
||||
return
|
||||
}
|
||||
if err := client.PublishDiagnostics(ctx, ¶ms); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
|
||||
default:
|
||||
if r.IsNotify() {
|
||||
conn.Reply(ctx, r, nil, jsonrpc2.NewErrorf(jsonrpc2.CodeMethodNotFound, "method %q not found", r.Method))
|
||||
|
@ -151,58 +139,57 @@ type clientDispatcher struct {
|
|||
*jsonrpc2.Conn
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) ShowMessage(ctx context.Context, params *ShowMessageParams) error {
|
||||
return c.Conn.Notify(ctx, "window/showMessage", params)
|
||||
func (s *clientDispatcher) ShowMessage(ctx context.Context, params *ShowMessageParams) error {
|
||||
return s.Conn.Notify(ctx, "window/showMessage", params)
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) {
|
||||
func (s *clientDispatcher) LogMessage(ctx context.Context, params *LogMessageParams) error {
|
||||
return s.Conn.Notify(ctx, "window/logMessage", params)
|
||||
}
|
||||
|
||||
func (s *clientDispatcher) Event(ctx context.Context, params *interface{}) error {
|
||||
return s.Conn.Notify(ctx, "telemetry/event", params)
|
||||
}
|
||||
|
||||
func (s *clientDispatcher) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error {
|
||||
return s.Conn.Notify(ctx, "textDocument/publishDiagnostics", params)
|
||||
}
|
||||
func (s *clientDispatcher) WorkspaceFolders(ctx context.Context) ([]WorkspaceFolder, error) {
|
||||
var result []WorkspaceFolder
|
||||
if err := s.Conn.Call(ctx, "workspace/workspaceFolders", nil, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *clientDispatcher) Configuration(ctx context.Context, params *ConfigurationParams) ([]interface{}, error) {
|
||||
var result []interface{}
|
||||
if err := s.Conn.Call(ctx, "workspace/configuration", params, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *clientDispatcher) RegisterCapability(ctx context.Context, params *RegistrationParams) error {
|
||||
return s.Conn.Notify(ctx, "client/registerCapability", params) // Notify? (not Call?)
|
||||
}
|
||||
|
||||
func (s *clientDispatcher) UnregisterCapability(ctx context.Context, params *UnregistrationParams) error {
|
||||
return s.Conn.Notify(ctx, "client/unregisterCapability", params) // Notify? (not Call?)
|
||||
}
|
||||
|
||||
func (s *clientDispatcher) ShowMessageRequest(ctx context.Context, params *ShowMessageRequestParams) (*MessageActionItem, error) {
|
||||
var result MessageActionItem
|
||||
if err := c.Conn.Call(ctx, "window/showMessageRequest", params, &result); err != nil {
|
||||
if err := s.Conn.Call(ctx, "window/showMessageRequest", params, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) LogMessage(ctx context.Context, params *LogMessageParams) error {
|
||||
return c.Conn.Notify(ctx, "window/logMessage", params)
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) Telemetry(ctx context.Context, params interface{}) error {
|
||||
return c.Conn.Notify(ctx, "telemetry/event", params)
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) RegisterCapability(ctx context.Context, params *RegistrationParams) error {
|
||||
return c.Conn.Notify(ctx, "client/registerCapability", params)
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) UnregisterCapability(ctx context.Context, params *UnregistrationParams) error {
|
||||
return c.Conn.Notify(ctx, "client/unregisterCapability", params)
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) WorkspaceFolders(ctx context.Context) ([]WorkspaceFolder, error) {
|
||||
var result []WorkspaceFolder
|
||||
if err := c.Conn.Call(ctx, "workspace/workspaceFolders", nil, &result); err != nil {
|
||||
func (s *clientDispatcher) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResponse, error) {
|
||||
var result ApplyWorkspaceEditResponse
|
||||
if err := s.Conn.Call(ctx, "workspace/applyEdit", params, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) Configuration(ctx context.Context, params *ConfigurationParams) ([]interface{}, error) {
|
||||
var result []interface{}
|
||||
if err := c.Conn.Call(ctx, "workspace/configuration", params, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) ApplyEdit(ctx context.Context, params *ApplyWorkspaceEditParams) (bool, error) {
|
||||
var result bool
|
||||
if err := c.Conn.Call(ctx, "workspace/applyEdit", params, &result); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *clientDispatcher) PublishDiagnostics(ctx context.Context, params *PublishDiagnosticsParams) error {
|
||||
return c.Conn.Notify(ctx, "textDocument/publishDiagnostics", params)
|
||||
return &result, nil
|
||||
}
|
|
@ -3378,6 +3378,27 @@ type TextDocumentContentChangeEvent struct {
|
|||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
// SetTraceParams is
|
||||
type SetTraceParams struct {
|
||||
|
||||
// Value is
|
||||
Value TraceValues `json:"value"`
|
||||
}
|
||||
|
||||
// LogTraceParams is
|
||||
type LogTraceParams struct {
|
||||
|
||||
// Message is
|
||||
Message string `json:"message"`
|
||||
|
||||
// Verbose is
|
||||
Verbose string `json:"verbose,omitempty"`
|
||||
}
|
||||
|
||||
// Tracer is
|
||||
type Tracer struct {
|
||||
}
|
||||
|
||||
// FoldingRangeKind defines constants
|
||||
type FoldingRangeKind string
|
||||
|
||||
|
@ -3435,6 +3456,24 @@ type CodeActionKind string
|
|||
// TextDocumentSaveReason defines constants
|
||||
type TextDocumentSaveReason float64
|
||||
|
||||
// ErrorCodes defines constants
|
||||
type ErrorCodes float64
|
||||
|
||||
// Touch defines constants
|
||||
type Touch float64
|
||||
|
||||
// Trace defines constants
|
||||
type Trace string
|
||||
|
||||
// TraceFormat defines constants
|
||||
type TraceFormat string
|
||||
|
||||
// ConnectionErrors defines constants
|
||||
type ConnectionErrors float64
|
||||
|
||||
// ConnectionState defines constants
|
||||
type ConnectionState float64
|
||||
|
||||
const (
|
||||
|
||||
/*Comment defined:
|
||||
|
@ -3890,6 +3929,42 @@ const (
|
|||
* When the editor lost focus.
|
||||
*/
|
||||
FocusOut TextDocumentSaveReason = 3
|
||||
|
||||
// MessageWriteError is
|
||||
MessageWriteError ErrorCodes = 1
|
||||
|
||||
// MessageReadError is
|
||||
MessageReadError ErrorCodes = 2
|
||||
|
||||
// First is
|
||||
First Touch = 1
|
||||
|
||||
// Last is
|
||||
Last Touch = 2
|
||||
|
||||
// JSON is
|
||||
JSON TraceFormat = "json"
|
||||
|
||||
/*Closed defined:
|
||||
* The connection is closed.
|
||||
*/
|
||||
Closed ConnectionErrors = 1
|
||||
|
||||
/*Disposed defined:
|
||||
* The connection got disposed.
|
||||
*/
|
||||
Disposed ConnectionErrors = 2
|
||||
|
||||
/*AlreadyListening defined:
|
||||
* The connection is already in listening mode.
|
||||
*/
|
||||
AlreadyListening ConnectionErrors = 3
|
||||
|
||||
// New is
|
||||
New ConnectionState = 1
|
||||
|
||||
// Listening is
|
||||
Listening ConnectionState = 2
|
||||
)
|
||||
|
||||
// DocumentFilter is a type
|
||||
|
@ -3949,3 +4024,12 @@ type DefinitionLink LocationLink
|
|||
* by the client.
|
||||
*/
|
||||
type DeclarationLink LocationLink
|
||||
|
||||
// LSPMessageType is a type
|
||||
/**
|
||||
* A LSP Log Entry.
|
||||
*/
|
||||
type LSPMessageType string
|
||||
|
||||
// TraceValues is a type
|
||||
type TraceValues string
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -206,16 +206,16 @@ func (s *Server) CodeLens(context.Context, *protocol.CodeLensParams) ([]protocol
|
|||
return nil, nil // ignore
|
||||
}
|
||||
|
||||
func (s *Server) CodeLensResolve(context.Context, *protocol.CodeLens) (*protocol.CodeLens, error) {
|
||||
return nil, notImplemented("CodeLensResolve")
|
||||
func (s *Server) ResolveCodeLens(context.Context, *protocol.CodeLens) (*protocol.CodeLens, error) {
|
||||
return nil, notImplemented("ResolveCodeLens")
|
||||
}
|
||||
|
||||
func (s *Server) DocumentLink(context.Context, *protocol.DocumentLinkParams) ([]protocol.DocumentLink, error) {
|
||||
return nil, nil // ignore
|
||||
}
|
||||
|
||||
func (s *Server) DocumentLinkResolve(context.Context, *protocol.DocumentLink) (*protocol.DocumentLink, error) {
|
||||
return nil, notImplemented("DocumentLinkResolve")
|
||||
func (s *Server) ResolveDocumentLink(context.Context, *protocol.DocumentLink) (*protocol.DocumentLink, error) {
|
||||
return nil, notImplemented("ResolveDocumentLink")
|
||||
}
|
||||
|
||||
func (s *Server) DocumentColor(context.Context, *protocol.DocumentColorParams) ([]protocol.ColorInformation, error) {
|
||||
|
@ -238,14 +238,37 @@ func (s *Server) OnTypeFormatting(context.Context, *protocol.DocumentOnTypeForma
|
|||
return nil, notImplemented("OnTypeFormatting")
|
||||
}
|
||||
|
||||
func (s *Server) Rename(context.Context, *protocol.RenameParams) ([]protocol.WorkspaceEdit, error) {
|
||||
func (s *Server) Rename(context.Context, *protocol.RenameParams) (*protocol.WorkspaceEdit, error) {
|
||||
return nil, notImplemented("Rename")
|
||||
}
|
||||
|
||||
func (s *Server) Declaration(context.Context, *protocol.TextDocumentPositionParams) ([]protocol.DeclarationLink, error) {
|
||||
return nil, notImplemented("Declaration")
|
||||
}
|
||||
|
||||
func (s *Server) FoldingRange(context.Context, *protocol.FoldingRangeParams) ([]protocol.FoldingRange, error) {
|
||||
return nil, notImplemented("FoldingRange")
|
||||
}
|
||||
|
||||
func (s *Server) LogTraceNotification(context.Context, *protocol.LogTraceParams) error {
|
||||
return notImplemented("LogtraceNotification")
|
||||
}
|
||||
|
||||
func (s *Server) PrepareRename(context.Context, *protocol.TextDocumentPositionParams) (*protocol.Range, error) {
|
||||
return nil, notImplemented("PrepareRename")
|
||||
}
|
||||
|
||||
func (s *Server) Resolve(context.Context, *protocol.CompletionItem) (*protocol.CompletionItem, error) {
|
||||
return nil, notImplemented("Resolve")
|
||||
}
|
||||
|
||||
func (s *Server) SelectionRange(context.Context, *protocol.SelectionRangeParams) ([][]protocol.SelectionRange, error) {
|
||||
return nil, notImplemented("SelectionRange")
|
||||
}
|
||||
|
||||
func (s *Server) SetTraceNotification(context.Context, *protocol.SetTraceParams) error {
|
||||
return notImplemented("SetTraceNotification")
|
||||
}
|
||||
func notImplemented(method string) *jsonrpc2.Error {
|
||||
return jsonrpc2.NewErrorf(jsonrpc2.CodeMethodNotFound, "method %q not yet implemented", method)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue