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>
diff --git a/internal/lsp/cache/cache.go b/internal/lsp/cache/cache.go
index ed2468f..298be2d 100644
--- a/internal/lsp/cache/cache.go
+++ b/internal/lsp/cache/cache.go
@@ -14,7 +14,6 @@
"golang.org/x/tools/internal/lsp/debug"
"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/span"
)
@@ -77,7 +76,6 @@
s := &session{
cache: c,
id: strconv.FormatInt(index, 10),
- log: xlog.From(ctx),
overlays: make(map[span.URI]*overlay),
filesWatchMap: NewWatchMap(),
}
diff --git a/internal/lsp/cache/session.go b/internal/lsp/cache/session.go
index 0104287..d746c34 100644
--- a/internal/lsp/cache/session.go
+++ b/internal/lsp/cache/session.go
@@ -24,8 +24,6 @@
type session struct {
cache *cache
id string
- // the logger to use to communicate back with the client
- log xlog.Logger
viewMu sync.Mutex
views []*view
@@ -179,10 +177,6 @@
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.
func (s *session) DidOpen(ctx context.Context, uri span.URI, _ source.FileKind, text []byte) {
// Mark the file as open.
diff --git a/internal/lsp/protocol/protocol.go b/internal/lsp/protocol/protocol.go
index ff16c8a..731f8bc 100644
--- a/internal/lsp/protocol/protocol.go
+++ b/internal/lsp/protocol/protocol.go
@@ -19,13 +19,11 @@
type clientHandler struct {
canceller
- log xlog.Logger
client Client
}
type serverHandler struct {
canceller
- log xlog.Logger
server Server
}
@@ -43,7 +41,7 @@
func NewClient(ctx context.Context, stream jsonrpc2.Stream, client Client) (context.Context, *jsonrpc2.Conn, Server) {
ctx = xlog.With(ctx, NewLogger(client))
conn := jsonrpc2.NewConn(stream)
- conn.AddHandler(&clientHandler{log: xlog.From(ctx), client: client})
+ conn.AddHandler(&clientHandler{client: client})
return ctx, conn, &serverDispatcher{Conn: conn}
}
@@ -51,11 +49,11 @@
conn := jsonrpc2.NewConn(stream)
client := &clientDispatcher{Conn: conn}
ctx = xlog.With(ctx, NewLogger(client))
- conn.AddHandler(&serverHandler{log: xlog.From(ctx), server: server})
+ conn.AddHandler(&serverHandler{server: server})
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 {
err = jsonrpc2.NewErrorf(jsonrpc2.CodeParseError, "%v", err)
}
diff --git a/internal/lsp/protocol/tsclient.go b/internal/lsp/protocol/tsclient.go
index 6d096a8..d5b4b01 100644
--- a/internal/lsp/protocol/tsclient.go
+++ b/internal/lsp/protocol/tsclient.go
@@ -7,6 +7,7 @@
"encoding/json"
"golang.org/x/tools/internal/jsonrpc2"
+ "golang.org/x/tools/internal/lsp/xlog"
)
type Client interface {
@@ -30,7 +31,7 @@
case "$/cancelRequest":
var params CancelParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
r.Conn().Cancel(params.ID)
@@ -38,41 +39,41 @@
case "window/showMessage": // notif
var params ShowMessageParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.client.ShowMessage(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "window/logMessage": // notif
var params LogMessageParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.client.LogMessage(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "telemetry/event": // notif
var params interface{}
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.client.Event(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/publishDiagnostics": // notif
var params PublishDiagnosticsParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.client.PublishDiagnostics(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "workspace/workspaceFolders": // req
@@ -82,62 +83,62 @@
}
resp, err := h.client.WorkspaceFolders(ctx)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "workspace/configuration": // req
var params ConfigurationParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.client.Configuration(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "client/registerCapability": // req
var params RegistrationParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
err := h.client.RegisterCapability(ctx, ¶ms)
if err := r.Reply(ctx, nil, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "client/unregisterCapability": // req
var params UnregistrationParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
err := h.client.UnregisterCapability(ctx, ¶ms)
if err := r.Reply(ctx, nil, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "window/showMessageRequest": // req
var params ShowMessageRequestParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.client.ShowMessageRequest(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "workspace/applyEdit": // req
var params ApplyWorkspaceEditParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.client.ApplyEdit(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
diff --git a/internal/lsp/protocol/tsserver.go b/internal/lsp/protocol/tsserver.go
index fb5d2d4c..0d254da 100644
--- a/internal/lsp/protocol/tsserver.go
+++ b/internal/lsp/protocol/tsserver.go
@@ -7,6 +7,7 @@
"encoding/json"
"golang.org/x/tools/internal/jsonrpc2"
+ "golang.org/x/tools/internal/lsp/xlog"
)
type Server interface {
@@ -62,7 +63,7 @@
case "$/cancelRequest":
var params CancelParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
r.Conn().Cancel(params.ID)
@@ -70,204 +71,204 @@
case "workspace/didChangeWorkspaceFolders": // notif
var params DidChangeWorkspaceFoldersParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.DidChangeWorkspaceFolders(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "initialized": // notif
var params InitializedParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.Initialized(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "exit": // notif
if err := h.server.Exit(ctx); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "workspace/didChangeConfiguration": // notif
var params DidChangeConfigurationParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.DidChangeConfiguration(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/didOpen": // notif
var params DidOpenTextDocumentParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.DidOpen(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/didChange": // notif
var params DidChangeTextDocumentParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.DidChange(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/didClose": // notif
var params DidCloseTextDocumentParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.DidClose(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/didSave": // notif
var params DidSaveTextDocumentParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.DidSave(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/willSave": // notif
var params WillSaveTextDocumentParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.WillSave(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "workspace/didChangeWatchedFiles": // notif
var params DidChangeWatchedFilesParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.DidChangeWatchedFiles(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "$/setTraceNotification": // notif
var params SetTraceParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.SetTraceNotification(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "$/logTraceNotification": // notif
var params LogTraceParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.server.LogTraceNotification(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/implementation": // req
var params TextDocumentPositionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Implementation(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/typeDefinition": // req
var params TextDocumentPositionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.TypeDefinition(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/documentColor": // req
var params DocumentColorParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.DocumentColor(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/colorPresentation": // req
var params ColorPresentationParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.ColorPresentation(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/foldingRange": // req
var params FoldingRangeParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.FoldingRange(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/declaration": // req
var params TextDocumentPositionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Declaration(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/selectionRange": // req
var params SelectionRangeParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.SelectionRange(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "initialize": // req
var params InitializeParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Initialize(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "shutdown": // req
@@ -277,238 +278,238 @@
}
err := h.server.Shutdown(ctx)
if err := r.Reply(ctx, nil, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/willSaveWaitUntil": // req
var params WillSaveTextDocumentParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.WillSaveWaitUntil(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/completion": // req
var params CompletionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Completion(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "completionItem/resolve": // req
var params CompletionItem
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Resolve(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/hover": // req
var params TextDocumentPositionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Hover(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/signatureHelp": // req
var params TextDocumentPositionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.SignatureHelp(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/definition": // req
var params TextDocumentPositionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Definition(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/references": // req
var params ReferenceParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.References(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/documentHighlight": // req
var params TextDocumentPositionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.DocumentHighlight(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/documentSymbol": // req
var params DocumentSymbolParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.DocumentSymbol(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "workspace/symbol": // req
var params WorkspaceSymbolParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Symbol(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/codeAction": // req
var params CodeActionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.CodeAction(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/codeLens": // req
var params CodeLensParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.CodeLens(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "codeLens/resolve": // req
var params CodeLens
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.ResolveCodeLens(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/formatting": // req
var params DocumentFormattingParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Formatting(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/rangeFormatting": // req
var params DocumentRangeFormattingParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.RangeFormatting(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/onTypeFormatting": // req
var params DocumentOnTypeFormattingParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.OnTypeFormatting(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/rename": // req
var params RenameParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.Rename(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/prepareRename": // req
var params TextDocumentPositionParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.PrepareRename(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "textDocument/documentLink": // req
var params DocumentLinkParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.DocumentLink(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "documentLink/resolve": // req
var params DocumentLink
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.ResolveDocumentLink(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
case "workspace/executeCommand": // req
var params ExecuteCommandParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
resp, err := h.server.ExecuteCommand(ctx, ¶ms)
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true
diff --git a/internal/lsp/protocol/typescript/requests.ts b/internal/lsp/protocol/typescript/requests.ts
index 3390290..409faa8 100644
--- a/internal/lsp/protocol/typescript/requests.ts
+++ b/internal/lsp/protocol/typescript/requests.ts
@@ -113,16 +113,16 @@
if (a != '') {
case1 = `var params ${a}
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
if err := h.${side.name}.${nm}(ctx, ¶ms); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true`;
} else {
case1 = `if err := h.${side.name}.${nm}(ctx); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true`;
}
@@ -154,24 +154,24 @@
if (a != '') {
case1 = `var params ${a}
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}`;
}
const arg2 = a == '' ? '' : ', ¶ms';
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 != '') {
case2 = `resp, err := h.${side.name}.${nm}(ctx${arg2})
if err := r.Reply(ctx, resp, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true`;
} else { // response is nil
case2 = `err := h.${side.name}.${nm}(ctx${arg2})
if err := r.Reply(ctx, nil, err); err != nil {
- h.log.Errorf(ctx, "%v", err)
+ xlog.Errorf(ctx, "%v", err)
}
return true`
}
@@ -226,6 +226,7 @@
"encoding/json"
"golang.org/x/tools/internal/jsonrpc2"
+ "golang.org/x/tools/internal/lsp/xlog"
)
`);
const a = side.name[0].toUpperCase() + side.name.substring(1)
@@ -240,7 +241,7 @@
case "$/cancelRequest":
var params CancelParams
if err := json.Unmarshal(*r.Params, ¶ms); err != nil {
- sendParseError(ctx, h.log, r, err)
+ sendParseError(ctx, r, err)
return true
}
r.Conn().Cancel(params.ID)
diff --git a/internal/lsp/source/view.go b/internal/lsp/source/view.go
index f40553d..bc0ad76 100644
--- a/internal/lsp/source/view.go
+++ b/internal/lsp/source/view.go
@@ -14,7 +14,6 @@
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/packages"
"golang.org/x/tools/internal/lsp/diff"
- "golang.org/x/tools/internal/lsp/xlog"
"golang.org/x/tools/internal/span"
)
@@ -134,9 +133,6 @@
// Cache returns the cache that created this session.
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(name string) View
diff --git a/internal/lsp/xlog/xlog.go b/internal/lsp/xlog/xlog.go
index 6d9fc36..9a6c753 100644
--- a/internal/lsp/xlog/xlog.go
+++ b/internal/lsp/xlog/xlog.go
@@ -10,9 +10,9 @@
"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.
-type Logger struct {
+type logger struct {
sink Sink
}
@@ -37,18 +37,18 @@
// Errorf is intended for the logging of errors that we could not easily return
// 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...))
}
// Infof is intended for logging of messages that may help the user understand
// 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...))
}
// 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...))
}
@@ -73,8 +73,8 @@
return context.WithValue(ctx, contextKey, sink)
}
-func From(ctx context.Context) Logger {
- return Logger{sink: ctx.Value(contextKey).(Sink)}
+func From(ctx context.Context) logger {
+ return logger{sink: ctx.Value(contextKey).(Sink)}
}
func Errorf(ctx context.Context, format string, args ...interface{}) {