From bf5f34bf872323daf6f0a0034ff2ffe1c0a1b1f4 Mon Sep 17 00:00:00 2001 From: Henry Wong Date: Thu, 30 May 2019 10:13:54 +0000 Subject: [PATCH] internal/lsp: remove the redundant `Server.Run()` call. `go s.Run(ctx)` repeats `h(s)`. Change-Id: I03ae6df64ad34194b8f46aabd0cf67e5a9e8c777 GitHub-Last-Rev: 3669875d72a196a8c84fb1709a7cf9f84fdbb688 GitHub-Pull-Request: golang/tools#105 Reviewed-on: https://go-review.googlesource.com/c/tools/+/179297 Reviewed-by: Ian Cottrell --- internal/lsp/cmd/serve.go | 4 ++-- internal/lsp/server.go | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/lsp/cmd/serve.go b/internal/lsp/cmd/serve.go index b24c9261f9..4a07bf7ddf 100644 --- a/internal/lsp/cmd/serve.go +++ b/internal/lsp/cmd/serve.go @@ -81,7 +81,7 @@ func (s *Serve) Run(ctx context.Context, args ...string) error { // For debugging purposes only. run := func(srv *lsp.Server) { srv.Conn.Logger = logger(s.Trace, out) - go srv.Conn.Run(ctx) + go srv.Run(ctx) } if s.Address != "" { return lsp.RunServerOnAddress(ctx, s.app.cache, s.Address, run) @@ -92,7 +92,7 @@ func (s *Serve) Run(ctx context.Context, args ...string) error { stream := jsonrpc2.NewHeaderStream(os.Stdin, os.Stdout) srv := lsp.NewServer(s.app.cache, stream) srv.Conn.Logger = logger(s.Trace, out) - return srv.Conn.Run(ctx) + return srv.Run(ctx) } func (s *Serve) forward() error { diff --git a/internal/lsp/server.go b/internal/lsp/server.go index 2903951e96..ed04bde434 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -53,10 +53,7 @@ func RunServerOnAddress(ctx context.Context, cache source.Cache, addr string, h if err != nil { return err } - stream := jsonrpc2.NewHeaderStream(conn, conn) - s := NewServer(cache, stream) - h(s) - go s.Run(ctx) + h(NewServer(cache, jsonrpc2.NewHeaderStream(conn, conn))) } }