mirror of
https://github.com/golang/go
synced 2024-11-19 00:44:40 -07:00
6889da9d54
This is a super minimal change that will simplify the diffs for when I actually delete the getMapper function. Change-Id: I16984b344c87b3645fd451668b6ea747c5be12ab Reviewed-on: https://go-review.googlesource.com/c/tools/+/190557 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
39 lines
958 B
Go
39 lines
958 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/protocol"
|
|
"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
|
|
}
|
|
|
|
func getMapper(ctx context.Context, f source.File) (*protocol.ColumnMapper, error) {
|
|
data, _, err := f.Handle(ctx).Read(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
tok, err := f.GetToken(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return protocol.NewColumnMapper(f.URI(), f.URI().Filename(), f.FileSet(), tok, data), nil
|
|
}
|