1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 "golang.org/x/tools/internal/span"
15 func (r *runner) References(t *testing.T, spn span.Span, itemList []span.Span) {
16 for _, includeDeclaration := range []bool{true, false} {
17 t.Run(fmt.Sprintf("refs-declaration-%v", includeDeclaration), func(t *testing.T) {
18 var itemStrings []string
19 for i, s := range itemList {
20 // We don't want the first result if we aren't including the declaration.
21 if i == 0 && !includeDeclaration {
24 itemStrings = append(itemStrings, fmt.Sprint(s))
26 sort.Strings(itemStrings)
28 for _, s := range itemStrings {
31 expect = r.Normalize(expect)
34 filename := uri.Filename()
35 target := filename + fmt.Sprintf(":%v:%v", spn.Start().Line(), spn.Start().Column())
36 args := []string{"references"}
37 if includeDeclaration {
38 args = append(args, "-d")
40 args = append(args, target)
41 got, stderr := r.NormalizeGoplsCmd(t, args...)
43 t.Errorf("references failed for %s: %s", target, stderr)
44 } else if expect != got {
45 t.Errorf("references failed for %s expected:\n%s\ngot:\n%s", target, expect, got)