1 // Copyright 2020 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.
11 "golang.org/x/tools/internal/lsp/fake"
12 "golang.org/x/tools/internal/lsp/protocol"
15 // expSymbolInformation and the types it references are pointer-based versions
16 // of fake.SymbolInformation, used to make it easier to partially assert
17 // against values of type fake.SymbolInformation
19 // expSymbolInformation is a pointer-based version of fake.SymbolInformation
20 type expSymbolInformation struct {
22 Kind *protocol.SymbolKind
26 func (e *expSymbolInformation) matchAgainst(sis []fake.SymbolInformation) bool {
27 for _, si := range sis {
35 func (e *expSymbolInformation) match(si fake.SymbolInformation) bool {
36 if e.Name != nil && *e.Name != si.Name {
39 if e.Kind != nil && *e.Kind != si.Kind {
42 if e.Location != nil && !e.Location.match(si.Location) {
48 func (e *expSymbolInformation) String() string {
49 byts, err := json.MarshalIndent(e, "", " ")
51 panic(fmt.Errorf("failed to json.Marshal *expSymbolInformation: %v", err))
56 // expLocation is a pointer-based version of fake.Location
57 type expLocation struct {
62 func (e *expLocation) match(l fake.Location) bool {
63 if e.Path != nil && *e.Path != l.Path {
66 if e.Range != nil && !e.Range.match(l.Range) {
72 // expRange is a pointer-based version of fake.Range
73 type expRange struct {
78 func (e *expRange) match(l fake.Range) bool {
79 if e.Start != nil && !e.Start.match(l.Start) {
82 if e.End != nil && !e.End.match(l.End) {
88 // expPos is a pointer-based version of fake.Pos
94 func (e *expPos) match(l fake.Pos) bool {
95 if e.Line != nil && *e.Line != l.Line {
98 if e.Column != nil && *e.Column != l.Column {
104 func pString(s string) *string {
108 func pInt(i int) *int {
112 func pKind(k protocol.SymbolKind) *protocol.SymbolKind {