mirror of
https://github.com/golang/go
synced 2024-11-19 08:54:47 -07:00
59b2cd78f8
This change adds command line support for implementation. Example: $ gopls implementation ~/tmp/foo/main.go:8:6 $ gopls implementation ~/tmp/foo/main.go:#53 Updates golang/go#32875 Change-Id: I3aa89a788ded886368b07c1824325069f3cba88a Reviewed-on: https://go-review.googlesource.com/c/tools/+/208357 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
37 lines
944 B
Go
37 lines
944 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 cmdtest
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"testing"
|
|
|
|
"golang.org/x/tools/internal/lsp/tests"
|
|
"golang.org/x/tools/internal/span"
|
|
)
|
|
|
|
func (r *runner) Implementation(t *testing.T, spn span.Span, imp tests.Implementations) {
|
|
var itemStrings []string
|
|
for _, i := range imp.Implementations {
|
|
itemStrings = append(itemStrings, fmt.Sprint(i))
|
|
}
|
|
sort.Strings(itemStrings)
|
|
var expect string
|
|
for _, i := range itemStrings {
|
|
expect += i + "\n"
|
|
}
|
|
expect = r.Normalize(expect)
|
|
|
|
uri := spn.URI()
|
|
filename := uri.Filename()
|
|
target := filename + fmt.Sprintf(":%v:%v", spn.Start().Line(), spn.Start().Column())
|
|
|
|
got, _ := r.NormalizeGoplsCmd(t, "implementation", target)
|
|
if expect != got {
|
|
t.Errorf("implementation failed for %s expected:\n%s\ngot:\n%s", target, expect, got)
|
|
}
|
|
}
|