internal/lsp: eliminate getFileLocked function

Apparently, the convention is to name something "Locked" if the
implementation is mutex is already locked when the function is called.

Turns out there were no callers of getFileLocked anyway, so just delete
that function and rename to getFile.

Change-Id: Ia7a9a620c3eb8eb0ce6b0a44ddb2ed62a604484d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215737
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Rebecca Stambler 2020-01-21 15:36:50 -05:00
parent 3e306b7b28
commit fc669b13a2
3 changed files with 4 additions and 9 deletions

View File

@ -279,7 +279,7 @@ func (s *session) DidModifyFile(ctx context.Context, c source.FileModification)
}
}
// Make sure that the file is added to the view.
f, err := view.getFileLocked(c.URI)
f, err := view.getFile(c.URI)
if err != nil {
return nil, err
}

View File

@ -533,7 +533,7 @@ func (s *snapshot) getFileURIs() []span.URI {
// GetFile returns a File for the given URI. It will always succeed because it
// adds the file to the managed set if needed.
func (s *snapshot) GetFile(uri span.URI) (source.FileHandle, error) {
f, err := s.view.getFileLocked(uri)
f, err := s.view.getFile(uri)
if err != nil {
return nil, err
}

View File

@ -403,17 +403,12 @@ func (v *view) knownFile(uri span.URI) bool {
return f != nil && err == nil
}
// getFileLocked returns a File for the given URI. It will always succeed because it
// getFile returns a file for the given URI. It will always succeed because it
// adds the file to the managed set if needed.
func (v *view) getFileLocked(uri span.URI) (*fileBase, error) {
func (v *view) getFile(uri span.URI) (*fileBase, error) {
v.mu.Lock()
defer v.mu.Unlock()
return v.getFile(uri)
}
// getFile is the unlocked internal implementation of GetFile.
func (v *view) getFile(uri span.URI) (*fileBase, error) {
f, err := v.findFile(uri)
if err != nil {
return nil, err