internal/lsp: remove the non context xlog path
And purge the loggers from the view and session. Change-Id: I262958f340e9a5ac9cc9b3db9e9910381e457478 Reviewed-on: https://go-review.googlesource.com/c/tools/+/185989 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
1b7e409d2c
commit
565492930f
|
@ -14,7 +14,6 @@ import (
|
||||||
|
|
||||||
"golang.org/x/tools/internal/lsp/debug"
|
"golang.org/x/tools/internal/lsp/debug"
|
||||||
"golang.org/x/tools/internal/lsp/source"
|
"golang.org/x/tools/internal/lsp/source"
|
||||||
"golang.org/x/tools/internal/lsp/xlog"
|
|
||||||
"golang.org/x/tools/internal/memoize"
|
"golang.org/x/tools/internal/memoize"
|
||||||
"golang.org/x/tools/internal/span"
|
"golang.org/x/tools/internal/span"
|
||||||
)
|
)
|
||||||
|
@ -77,7 +76,6 @@ func (c *cache) NewSession(ctx context.Context) source.Session {
|
||||||
s := &session{
|
s := &session{
|
||||||
cache: c,
|
cache: c,
|
||||||
id: strconv.FormatInt(index, 10),
|
id: strconv.FormatInt(index, 10),
|
||||||
log: xlog.From(ctx),
|
|
||||||
overlays: make(map[span.URI]*overlay),
|
overlays: make(map[span.URI]*overlay),
|
||||||
filesWatchMap: NewWatchMap(),
|
filesWatchMap: NewWatchMap(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,6 @@ import (
|
||||||
type session struct {
|
type session struct {
|
||||||
cache *cache
|
cache *cache
|
||||||
id string
|
id string
|
||||||
// the logger to use to communicate back with the client
|
|
||||||
log xlog.Logger
|
|
||||||
|
|
||||||
viewMu sync.Mutex
|
viewMu sync.Mutex
|
||||||
views []*view
|
views []*view
|
||||||
|
@ -179,10 +177,6 @@ func (s *session) removeView(ctx context.Context, view *view) error {
|
||||||
return fmt.Errorf("view %s for %v not found", view.Name(), view.Folder())
|
return fmt.Errorf("view %s for %v not found", view.Name(), view.Folder())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) Logger() xlog.Logger {
|
|
||||||
return s.log
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Propagate the language ID through to the view.
|
// TODO: Propagate the language ID through to the view.
|
||||||
func (s *session) DidOpen(ctx context.Context, uri span.URI, _ source.FileKind, text []byte) {
|
func (s *session) DidOpen(ctx context.Context, uri span.URI, _ source.FileKind, text []byte) {
|
||||||
// Mark the file as open.
|
// Mark the file as open.
|
||||||
|
|
|
@ -19,13 +19,11 @@ type canceller struct{ jsonrpc2.EmptyHandler }
|
||||||
|
|
||||||
type clientHandler struct {
|
type clientHandler struct {
|
||||||
canceller
|
canceller
|
||||||
log xlog.Logger
|
|
||||||
client Client
|
client Client
|
||||||
}
|
}
|
||||||
|
|
||||||
type serverHandler struct {
|
type serverHandler struct {
|
||||||
canceller
|
canceller
|
||||||
log xlog.Logger
|
|
||||||
server Server
|
server Server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +41,7 @@ func (canceller) Cancel(ctx context.Context, conn *jsonrpc2.Conn, id jsonrpc2.ID
|
||||||
func NewClient(ctx context.Context, stream jsonrpc2.Stream, client Client) (context.Context, *jsonrpc2.Conn, Server) {
|
func NewClient(ctx context.Context, stream jsonrpc2.Stream, client Client) (context.Context, *jsonrpc2.Conn, Server) {
|
||||||
ctx = xlog.With(ctx, NewLogger(client))
|
ctx = xlog.With(ctx, NewLogger(client))
|
||||||
conn := jsonrpc2.NewConn(stream)
|
conn := jsonrpc2.NewConn(stream)
|
||||||
conn.AddHandler(&clientHandler{log: xlog.From(ctx), client: client})
|
conn.AddHandler(&clientHandler{client: client})
|
||||||
return ctx, conn, &serverDispatcher{Conn: conn}
|
return ctx, conn, &serverDispatcher{Conn: conn}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +49,11 @@ func NewServer(ctx context.Context, stream jsonrpc2.Stream, server Server) (cont
|
||||||
conn := jsonrpc2.NewConn(stream)
|
conn := jsonrpc2.NewConn(stream)
|
||||||
client := &clientDispatcher{Conn: conn}
|
client := &clientDispatcher{Conn: conn}
|
||||||
ctx = xlog.With(ctx, NewLogger(client))
|
ctx = xlog.With(ctx, NewLogger(client))
|
||||||
conn.AddHandler(&serverHandler{log: xlog.From(ctx), server: server})
|
conn.AddHandler(&serverHandler{server: server})
|
||||||
return ctx, conn, client
|
return ctx, conn, client
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendParseError(ctx context.Context, log xlog.Logger, req *jsonrpc2.Request, err error) {
|
func sendParseError(ctx context.Context, req *jsonrpc2.Request, err error) {
|
||||||
if _, ok := err.(*jsonrpc2.Error); !ok {
|
if _, ok := err.(*jsonrpc2.Error); !ok {
|
||||||
err = jsonrpc2.NewErrorf(jsonrpc2.CodeParseError, "%v", err)
|
err = jsonrpc2.NewErrorf(jsonrpc2.CodeParseError, "%v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"golang.org/x/tools/internal/jsonrpc2"
|
"golang.org/x/tools/internal/jsonrpc2"
|
||||||
|
"golang.org/x/tools/internal/lsp/xlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client interface {
|
type Client interface {
|
||||||
|
@ -30,7 +31,7 @@ func (h clientHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, deliver
|
||||||
case "$/cancelRequest":
|
case "$/cancelRequest":
|
||||||
var params CancelParams
|
var params CancelParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
r.Conn().Cancel(params.ID)
|
r.Conn().Cancel(params.ID)
|
||||||
|
@ -38,41 +39,41 @@ func (h clientHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, deliver
|
||||||
case "window/showMessage": // notif
|
case "window/showMessage": // notif
|
||||||
var params ShowMessageParams
|
var params ShowMessageParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.client.ShowMessage(ctx, ¶ms); err != nil {
|
if err := h.client.ShowMessage(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "window/logMessage": // notif
|
case "window/logMessage": // notif
|
||||||
var params LogMessageParams
|
var params LogMessageParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.client.LogMessage(ctx, ¶ms); err != nil {
|
if err := h.client.LogMessage(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "telemetry/event": // notif
|
case "telemetry/event": // notif
|
||||||
var params interface{}
|
var params interface{}
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.client.Event(ctx, ¶ms); err != nil {
|
if err := h.client.Event(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/publishDiagnostics": // notif
|
case "textDocument/publishDiagnostics": // notif
|
||||||
var params PublishDiagnosticsParams
|
var params PublishDiagnosticsParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.client.PublishDiagnostics(ctx, ¶ms); err != nil {
|
if err := h.client.PublishDiagnostics(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "workspace/workspaceFolders": // req
|
case "workspace/workspaceFolders": // req
|
||||||
|
@ -82,62 +83,62 @@ func (h clientHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, deliver
|
||||||
}
|
}
|
||||||
resp, err := h.client.WorkspaceFolders(ctx)
|
resp, err := h.client.WorkspaceFolders(ctx)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "workspace/configuration": // req
|
case "workspace/configuration": // req
|
||||||
var params ConfigurationParams
|
var params ConfigurationParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.client.Configuration(ctx, ¶ms)
|
resp, err := h.client.Configuration(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "client/registerCapability": // req
|
case "client/registerCapability": // req
|
||||||
var params RegistrationParams
|
var params RegistrationParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
err := h.client.RegisterCapability(ctx, ¶ms)
|
err := h.client.RegisterCapability(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, nil, err); err != nil {
|
if err := r.Reply(ctx, nil, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "client/unregisterCapability": // req
|
case "client/unregisterCapability": // req
|
||||||
var params UnregistrationParams
|
var params UnregistrationParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
err := h.client.UnregisterCapability(ctx, ¶ms)
|
err := h.client.UnregisterCapability(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, nil, err); err != nil {
|
if err := r.Reply(ctx, nil, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "window/showMessageRequest": // req
|
case "window/showMessageRequest": // req
|
||||||
var params ShowMessageRequestParams
|
var params ShowMessageRequestParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.client.ShowMessageRequest(ctx, ¶ms)
|
resp, err := h.client.ShowMessageRequest(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "workspace/applyEdit": // req
|
case "workspace/applyEdit": // req
|
||||||
var params ApplyWorkspaceEditParams
|
var params ApplyWorkspaceEditParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.client.ApplyEdit(ctx, ¶ms)
|
resp, err := h.client.ApplyEdit(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"golang.org/x/tools/internal/jsonrpc2"
|
"golang.org/x/tools/internal/jsonrpc2"
|
||||||
|
"golang.org/x/tools/internal/lsp/xlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server interface {
|
type Server interface {
|
||||||
|
@ -62,7 +63,7 @@ func (h serverHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, deliver
|
||||||
case "$/cancelRequest":
|
case "$/cancelRequest":
|
||||||
var params CancelParams
|
var params CancelParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
r.Conn().Cancel(params.ID)
|
r.Conn().Cancel(params.ID)
|
||||||
|
@ -70,204 +71,204 @@ func (h serverHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, deliver
|
||||||
case "workspace/didChangeWorkspaceFolders": // notif
|
case "workspace/didChangeWorkspaceFolders": // notif
|
||||||
var params DidChangeWorkspaceFoldersParams
|
var params DidChangeWorkspaceFoldersParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.DidChangeWorkspaceFolders(ctx, ¶ms); err != nil {
|
if err := h.server.DidChangeWorkspaceFolders(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "initialized": // notif
|
case "initialized": // notif
|
||||||
var params InitializedParams
|
var params InitializedParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.Initialized(ctx, ¶ms); err != nil {
|
if err := h.server.Initialized(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "exit": // notif
|
case "exit": // notif
|
||||||
if err := h.server.Exit(ctx); err != nil {
|
if err := h.server.Exit(ctx); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "workspace/didChangeConfiguration": // notif
|
case "workspace/didChangeConfiguration": // notif
|
||||||
var params DidChangeConfigurationParams
|
var params DidChangeConfigurationParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.DidChangeConfiguration(ctx, ¶ms); err != nil {
|
if err := h.server.DidChangeConfiguration(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/didOpen": // notif
|
case "textDocument/didOpen": // notif
|
||||||
var params DidOpenTextDocumentParams
|
var params DidOpenTextDocumentParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.DidOpen(ctx, ¶ms); err != nil {
|
if err := h.server.DidOpen(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/didChange": // notif
|
case "textDocument/didChange": // notif
|
||||||
var params DidChangeTextDocumentParams
|
var params DidChangeTextDocumentParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.DidChange(ctx, ¶ms); err != nil {
|
if err := h.server.DidChange(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/didClose": // notif
|
case "textDocument/didClose": // notif
|
||||||
var params DidCloseTextDocumentParams
|
var params DidCloseTextDocumentParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.DidClose(ctx, ¶ms); err != nil {
|
if err := h.server.DidClose(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/didSave": // notif
|
case "textDocument/didSave": // notif
|
||||||
var params DidSaveTextDocumentParams
|
var params DidSaveTextDocumentParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.DidSave(ctx, ¶ms); err != nil {
|
if err := h.server.DidSave(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/willSave": // notif
|
case "textDocument/willSave": // notif
|
||||||
var params WillSaveTextDocumentParams
|
var params WillSaveTextDocumentParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.WillSave(ctx, ¶ms); err != nil {
|
if err := h.server.WillSave(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "workspace/didChangeWatchedFiles": // notif
|
case "workspace/didChangeWatchedFiles": // notif
|
||||||
var params DidChangeWatchedFilesParams
|
var params DidChangeWatchedFilesParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.DidChangeWatchedFiles(ctx, ¶ms); err != nil {
|
if err := h.server.DidChangeWatchedFiles(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "$/setTraceNotification": // notif
|
case "$/setTraceNotification": // notif
|
||||||
var params SetTraceParams
|
var params SetTraceParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.SetTraceNotification(ctx, ¶ms); err != nil {
|
if err := h.server.SetTraceNotification(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "$/logTraceNotification": // notif
|
case "$/logTraceNotification": // notif
|
||||||
var params LogTraceParams
|
var params LogTraceParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.server.LogTraceNotification(ctx, ¶ms); err != nil {
|
if err := h.server.LogTraceNotification(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/implementation": // req
|
case "textDocument/implementation": // req
|
||||||
var params TextDocumentPositionParams
|
var params TextDocumentPositionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Implementation(ctx, ¶ms)
|
resp, err := h.server.Implementation(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/typeDefinition": // req
|
case "textDocument/typeDefinition": // req
|
||||||
var params TextDocumentPositionParams
|
var params TextDocumentPositionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.TypeDefinition(ctx, ¶ms)
|
resp, err := h.server.TypeDefinition(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/documentColor": // req
|
case "textDocument/documentColor": // req
|
||||||
var params DocumentColorParams
|
var params DocumentColorParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.DocumentColor(ctx, ¶ms)
|
resp, err := h.server.DocumentColor(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/colorPresentation": // req
|
case "textDocument/colorPresentation": // req
|
||||||
var params ColorPresentationParams
|
var params ColorPresentationParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.ColorPresentation(ctx, ¶ms)
|
resp, err := h.server.ColorPresentation(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/foldingRange": // req
|
case "textDocument/foldingRange": // req
|
||||||
var params FoldingRangeParams
|
var params FoldingRangeParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.FoldingRange(ctx, ¶ms)
|
resp, err := h.server.FoldingRange(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/declaration": // req
|
case "textDocument/declaration": // req
|
||||||
var params TextDocumentPositionParams
|
var params TextDocumentPositionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Declaration(ctx, ¶ms)
|
resp, err := h.server.Declaration(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/selectionRange": // req
|
case "textDocument/selectionRange": // req
|
||||||
var params SelectionRangeParams
|
var params SelectionRangeParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.SelectionRange(ctx, ¶ms)
|
resp, err := h.server.SelectionRange(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "initialize": // req
|
case "initialize": // req
|
||||||
var params InitializeParams
|
var params InitializeParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Initialize(ctx, ¶ms)
|
resp, err := h.server.Initialize(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "shutdown": // req
|
case "shutdown": // req
|
||||||
|
@ -277,238 +278,238 @@ func (h serverHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, deliver
|
||||||
}
|
}
|
||||||
err := h.server.Shutdown(ctx)
|
err := h.server.Shutdown(ctx)
|
||||||
if err := r.Reply(ctx, nil, err); err != nil {
|
if err := r.Reply(ctx, nil, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/willSaveWaitUntil": // req
|
case "textDocument/willSaveWaitUntil": // req
|
||||||
var params WillSaveTextDocumentParams
|
var params WillSaveTextDocumentParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.WillSaveWaitUntil(ctx, ¶ms)
|
resp, err := h.server.WillSaveWaitUntil(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/completion": // req
|
case "textDocument/completion": // req
|
||||||
var params CompletionParams
|
var params CompletionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Completion(ctx, ¶ms)
|
resp, err := h.server.Completion(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "completionItem/resolve": // req
|
case "completionItem/resolve": // req
|
||||||
var params CompletionItem
|
var params CompletionItem
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Resolve(ctx, ¶ms)
|
resp, err := h.server.Resolve(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/hover": // req
|
case "textDocument/hover": // req
|
||||||
var params TextDocumentPositionParams
|
var params TextDocumentPositionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Hover(ctx, ¶ms)
|
resp, err := h.server.Hover(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/signatureHelp": // req
|
case "textDocument/signatureHelp": // req
|
||||||
var params TextDocumentPositionParams
|
var params TextDocumentPositionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.SignatureHelp(ctx, ¶ms)
|
resp, err := h.server.SignatureHelp(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/definition": // req
|
case "textDocument/definition": // req
|
||||||
var params TextDocumentPositionParams
|
var params TextDocumentPositionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Definition(ctx, ¶ms)
|
resp, err := h.server.Definition(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/references": // req
|
case "textDocument/references": // req
|
||||||
var params ReferenceParams
|
var params ReferenceParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.References(ctx, ¶ms)
|
resp, err := h.server.References(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/documentHighlight": // req
|
case "textDocument/documentHighlight": // req
|
||||||
var params TextDocumentPositionParams
|
var params TextDocumentPositionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.DocumentHighlight(ctx, ¶ms)
|
resp, err := h.server.DocumentHighlight(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/documentSymbol": // req
|
case "textDocument/documentSymbol": // req
|
||||||
var params DocumentSymbolParams
|
var params DocumentSymbolParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.DocumentSymbol(ctx, ¶ms)
|
resp, err := h.server.DocumentSymbol(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "workspace/symbol": // req
|
case "workspace/symbol": // req
|
||||||
var params WorkspaceSymbolParams
|
var params WorkspaceSymbolParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Symbol(ctx, ¶ms)
|
resp, err := h.server.Symbol(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/codeAction": // req
|
case "textDocument/codeAction": // req
|
||||||
var params CodeActionParams
|
var params CodeActionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.CodeAction(ctx, ¶ms)
|
resp, err := h.server.CodeAction(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/codeLens": // req
|
case "textDocument/codeLens": // req
|
||||||
var params CodeLensParams
|
var params CodeLensParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.CodeLens(ctx, ¶ms)
|
resp, err := h.server.CodeLens(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "codeLens/resolve": // req
|
case "codeLens/resolve": // req
|
||||||
var params CodeLens
|
var params CodeLens
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.ResolveCodeLens(ctx, ¶ms)
|
resp, err := h.server.ResolveCodeLens(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/formatting": // req
|
case "textDocument/formatting": // req
|
||||||
var params DocumentFormattingParams
|
var params DocumentFormattingParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Formatting(ctx, ¶ms)
|
resp, err := h.server.Formatting(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/rangeFormatting": // req
|
case "textDocument/rangeFormatting": // req
|
||||||
var params DocumentRangeFormattingParams
|
var params DocumentRangeFormattingParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.RangeFormatting(ctx, ¶ms)
|
resp, err := h.server.RangeFormatting(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/onTypeFormatting": // req
|
case "textDocument/onTypeFormatting": // req
|
||||||
var params DocumentOnTypeFormattingParams
|
var params DocumentOnTypeFormattingParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.OnTypeFormatting(ctx, ¶ms)
|
resp, err := h.server.OnTypeFormatting(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/rename": // req
|
case "textDocument/rename": // req
|
||||||
var params RenameParams
|
var params RenameParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.Rename(ctx, ¶ms)
|
resp, err := h.server.Rename(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/prepareRename": // req
|
case "textDocument/prepareRename": // req
|
||||||
var params TextDocumentPositionParams
|
var params TextDocumentPositionParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.PrepareRename(ctx, ¶ms)
|
resp, err := h.server.PrepareRename(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "textDocument/documentLink": // req
|
case "textDocument/documentLink": // req
|
||||||
var params DocumentLinkParams
|
var params DocumentLinkParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.DocumentLink(ctx, ¶ms)
|
resp, err := h.server.DocumentLink(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "documentLink/resolve": // req
|
case "documentLink/resolve": // req
|
||||||
var params DocumentLink
|
var params DocumentLink
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.ResolveDocumentLink(ctx, ¶ms)
|
resp, err := h.server.ResolveDocumentLink(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
case "workspace/executeCommand": // req
|
case "workspace/executeCommand": // req
|
||||||
var params ExecuteCommandParams
|
var params ExecuteCommandParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
resp, err := h.server.ExecuteCommand(ctx, ¶ms)
|
resp, err := h.server.ExecuteCommand(ctx, ¶ms)
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
|
@ -113,16 +113,16 @@ function goNot(side: side, m: string) {
|
||||||
if (a != '') {
|
if (a != '') {
|
||||||
case1 = `var params ${a}
|
case1 = `var params ${a}
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if err := h.${side.name}.${nm}(ctx, ¶ms); err != nil {
|
if err := h.${side.name}.${nm}(ctx, ¶ms); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true`;
|
return true`;
|
||||||
} else {
|
} else {
|
||||||
case1 = `if err := h.${side.name}.${nm}(ctx); err != nil {
|
case1 = `if err := h.${side.name}.${nm}(ctx); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true`;
|
return true`;
|
||||||
}
|
}
|
||||||
|
@ -154,24 +154,24 @@ function goReq(side: side, m: string) {
|
||||||
if (a != '') {
|
if (a != '') {
|
||||||
case1 = `var params ${a}
|
case1 = `var params ${a}
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
const arg2 = a == '' ? '' : ', ¶ms';
|
const arg2 = a == '' ? '' : ', ¶ms';
|
||||||
let case2 = `if err := h.${side.name}.${nm}(ctx${arg2}); err != nil {
|
let case2 = `if err := h.${side.name}.${nm}(ctx${arg2}); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}`;
|
}`;
|
||||||
if (b != '') {
|
if (b != '') {
|
||||||
case2 = `resp, err := h.${side.name}.${nm}(ctx${arg2})
|
case2 = `resp, err := h.${side.name}.${nm}(ctx${arg2})
|
||||||
if err := r.Reply(ctx, resp, err); err != nil {
|
if err := r.Reply(ctx, resp, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true`;
|
return true`;
|
||||||
} else { // response is nil
|
} else { // response is nil
|
||||||
case2 = `err := h.${side.name}.${nm}(ctx${arg2})
|
case2 = `err := h.${side.name}.${nm}(ctx${arg2})
|
||||||
if err := r.Reply(ctx, nil, err); err != nil {
|
if err := r.Reply(ctx, nil, err); err != nil {
|
||||||
h.log.Errorf(ctx, "%v", err)
|
xlog.Errorf(ctx, "%v", err)
|
||||||
}
|
}
|
||||||
return true`
|
return true`
|
||||||
}
|
}
|
||||||
|
@ -226,6 +226,7 @@ function output(side: side) {
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"golang.org/x/tools/internal/jsonrpc2"
|
"golang.org/x/tools/internal/jsonrpc2"
|
||||||
|
"golang.org/x/tools/internal/lsp/xlog"
|
||||||
)
|
)
|
||||||
`);
|
`);
|
||||||
const a = side.name[0].toUpperCase() + side.name.substring(1)
|
const a = side.name[0].toUpperCase() + side.name.substring(1)
|
||||||
|
@ -240,7 +241,7 @@ function output(side: side) {
|
||||||
case "$/cancelRequest":
|
case "$/cancelRequest":
|
||||||
var params CancelParams
|
var params CancelParams
|
||||||
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
|
||||||
sendParseError(ctx, h.log, r, err)
|
sendParseError(ctx, r, err)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
r.Conn().Cancel(params.ID)
|
r.Conn().Cancel(params.ID)
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"golang.org/x/tools/go/analysis"
|
"golang.org/x/tools/go/analysis"
|
||||||
"golang.org/x/tools/go/packages"
|
"golang.org/x/tools/go/packages"
|
||||||
"golang.org/x/tools/internal/lsp/diff"
|
"golang.org/x/tools/internal/lsp/diff"
|
||||||
"golang.org/x/tools/internal/lsp/xlog"
|
|
||||||
"golang.org/x/tools/internal/span"
|
"golang.org/x/tools/internal/span"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -134,9 +133,6 @@ type Session interface {
|
||||||
// Cache returns the cache that created this session.
|
// Cache returns the cache that created this session.
|
||||||
Cache() Cache
|
Cache() Cache
|
||||||
|
|
||||||
// Returns the logger in use for this session.
|
|
||||||
Logger() xlog.Logger
|
|
||||||
|
|
||||||
// View returns a view with a mathing name, if the session has one.
|
// View returns a view with a mathing name, if the session has one.
|
||||||
View(name string) View
|
View(name string) View
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ import (
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Logger is a wrapper over a sink to provide a clean API over the core log
|
// logger is a wrapper over a sink to provide a clean API over the core log
|
||||||
// function.
|
// function.
|
||||||
type Logger struct {
|
type logger struct {
|
||||||
sink Sink
|
sink Sink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,18 +37,18 @@ type StdSink struct{}
|
||||||
|
|
||||||
// Errorf is intended for the logging of errors that we could not easily return
|
// Errorf is intended for the logging of errors that we could not easily return
|
||||||
// to the client but that caused problems internally.
|
// to the client but that caused problems internally.
|
||||||
func (l Logger) Errorf(ctx context.Context, format string, args ...interface{}) {
|
func (l logger) Errorf(ctx context.Context, format string, args ...interface{}) {
|
||||||
l.sink.Log(ctx, ErrorLevel, fmt.Sprintf(format, args...))
|
l.sink.Log(ctx, ErrorLevel, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infof is intended for logging of messages that may help the user understand
|
// Infof is intended for logging of messages that may help the user understand
|
||||||
// the behavior or be useful in a bug report.
|
// the behavior or be useful in a bug report.
|
||||||
func (l Logger) Infof(ctx context.Context, format string, args ...interface{}) {
|
func (l logger) Infof(ctx context.Context, format string, args ...interface{}) {
|
||||||
l.sink.Log(ctx, InfoLevel, fmt.Sprintf(format, args...))
|
l.sink.Log(ctx, InfoLevel, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debugf is intended to be used only while debugging.
|
// Debugf is intended to be used only while debugging.
|
||||||
func (l Logger) Debugf(ctx context.Context, format string, args ...interface{}) {
|
func (l logger) Debugf(ctx context.Context, format string, args ...interface{}) {
|
||||||
l.sink.Log(ctx, DebugLevel, fmt.Sprintf(format, args...))
|
l.sink.Log(ctx, DebugLevel, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ func With(ctx context.Context, sink Sink) context.Context {
|
||||||
return context.WithValue(ctx, contextKey, sink)
|
return context.WithValue(ctx, contextKey, sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
func From(ctx context.Context) Logger {
|
func From(ctx context.Context) logger {
|
||||||
return Logger{sink: ctx.Value(contextKey).(Sink)}
|
return logger{sink: ctx.Value(contextKey).(Sink)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Errorf(ctx context.Context, format string, args ...interface{}) {
|
func Errorf(ctx context.Context, format string, args ...interface{}) {
|
||||||
|
|
Loading…
Reference in New Issue