1
0
mirror of https://github.com/golang/go synced 2024-11-19 04:54:41 -07:00
go/internal/lsp/util.go
Rebecca Stambler 2ca718005c internal/lsp: use protocol.TextEdits in suggested fixes
Change-Id: I8b454dd8c59839468ecfcb19b7edfa659e386b57
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193957
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-07 02:01:28 +00:00

26 lines
589 B
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/source"
"golang.org/x/tools/internal/span"
errors "golang.org/x/xerrors"
)
func getGoFile(ctx context.Context, view source.View, uri span.URI) (source.GoFile, error) {
f, err := view.GetFile(ctx, uri)
if err != nil {
return nil, err
}
gof, ok := f.(source.GoFile)
if !ok {
return nil, errors.Errorf("%s is not a Go file", uri)
}
return gof, nil
}