internal/lsp: avoid panic during interface assertion

This change fixes a panic in the non-standard request.

Fixes golang/go#43462

Change-Id: I216a56f96ca6159cb9b102183ba3a3eddd186889
GitHub-Last-Rev: 992e818f8a
GitHub-Pull-Request: golang/tools#265
Reviewed-on: https://go-review.googlesource.com/c/tools/+/281092
Reviewed-by: Peter Weinberger <pjw@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
pohzipohzi 2021-01-02 00:12:34 +00:00 коммит произвёл Dmitri Shuralyov
Родитель c4dccaf3ad
Коммит 2993f551b7
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -115,8 +115,9 @@ func (s *Server) workDoneProgressCancel(ctx context.Context, params *protocol.Wo
}
func (s *Server) nonstandardRequest(ctx context.Context, method string, params interface{}) (interface{}, error) {
paramMap := params.(map[string]interface{})
if method == "gopls/diagnoseFiles" {
switch method {
case "gopls/diagnoseFiles":
paramMap := params.(map[string]interface{})
for _, file := range paramMap["files"].([]interface{}) {
snapshot, fh, ok, release, err := s.beginFileRequest(ctx, protocol.DocumentURI(file.(string)), source.UnknownKind)
defer release()