mirror of
https://github.com/golang/go
synced 2024-11-18 21:44:45 -07:00
be5259f298
This relates to https://github.com/golang/go/issues/31374 and should switch all instances within `gopls` to use `x/errors` instead of `fmt` to create new errors. Change-Id: I18339b75d12418d852e0dcc2ba0ed6c2970783b3 GitHub-Last-Rev: f4a55d9b79e7458ef1f1e06cb5eabbabd884f321 GitHub-Pull-Request: golang/tools#108 Reviewed-on: https://go-review.googlesource.com/c/tools/+/179880 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
// Copyright 2019 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 lsp
|
|
|
|
import (
|
|
"context"
|
|
|
|
"golang.org/x/tools/internal/lsp/protocol"
|
|
"golang.org/x/tools/internal/span"
|
|
errors "golang.org/x/xerrors"
|
|
)
|
|
|
|
func (s *Server) changeFolders(ctx context.Context, event protocol.WorkspaceFoldersChangeEvent) error {
|
|
for _, folder := range event.Removed {
|
|
view := s.session.View(folder.Name)
|
|
if view != nil {
|
|
view.Shutdown(ctx)
|
|
} else {
|
|
return errors.Errorf("view %s for %v not found", folder.Name, folder.URI)
|
|
}
|
|
}
|
|
|
|
for _, folder := range event.Added {
|
|
if err := s.addView(ctx, folder.Name, span.NewURI(folder.URI)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *Server) addView(ctx context.Context, name string, uri span.URI) error {
|
|
view := s.session.NewView(ctx, name, uri)
|
|
s.stateMu.Lock()
|
|
state := s.state
|
|
s.stateMu.Unlock()
|
|
if state >= serverInitialized {
|
|
s.fetchConfig(ctx, view)
|
|
}
|
|
return nil
|
|
}
|