aboutsummaryrefslogtreecommitdiff
path: root/gopls/internal/lsp/testdata/symbols/main.go
blob: 65e0869fd5f84686990d844980f003783fd49021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main

import (
	"io"
)

// Each symbol marker in this file defines the following information:
//  symbol(name, selectionSpan, kind, detail, id, parentID)
//    - name: DocumentSymbol.Name
//    - selectionSpan: DocumentSymbol.SelectionRange
//    - kind: DocumentSymbol.Kind
//    - detail: DocumentSymbol.Detail
//    - id: if non-empty, a unique identifier for this symbol
//    - parentID: if non-empty, the id of the parent of this symbol
//
// This data in aggregate defines a set of document symbols and their
// parent-child relationships, which is compared against the DocummentSymbols
// response from gopls for the current file.
//
// TODO(rfindley): the symbol annotations here are complicated and difficult to
// maintain. It would be simpler to just write out the full expected response
// in the golden file, perhaps as raw JSON.

var _ = 1

var x = 42 //@symbol("x", "x", "Variable", "", "", "")

var nested struct { //@symbol("nested", "nested", "Variable", "struct{...}", "nested", "")
	nestedField struct { //@symbol("nestedField", "nestedField", "Field", "struct{...}", "nestedField", "nested")
		f int //@symbol("f", "f", "Field", "int", "", "nestedField")
	}
}

const y = 43 //@symbol("y", "y", "Constant", "", "", "")

type Number int //@symbol("Number", "Number", "Class", "int", "", "")

type Alias = string //@symbol("Alias", "Alias", "Class", "string", "", "")

type NumberAlias = Number //@symbol("NumberAlias", "NumberAlias", "Class", "Number", "", "")

type (
	Boolean   bool   //@symbol("Boolean", "Boolean", "Class", "bool", "", "")
	BoolAlias = bool //@symbol("BoolAlias", "BoolAlias", "Class", "bool", "", "")
)

type Foo struct { //@symbol("Foo", "Foo", "Struct", "struct{...}", "Foo", "")
	Quux                    //@symbol("Quux", "Quux", "Field", "Quux", "", "Foo")
	W         io.Writer     //@symbol("W", "W", "Field", "io.Writer", "", "Foo")
	Bar       int           //@symbol("Bar", "Bar", "Field", "int", "", "Foo")
	baz       string        //@symbol("baz", "baz", "Field", "string", "", "Foo")
	funcField func(int) int //@symbol("funcField", "funcField", "Field", "func(int) int", "", "Foo")
}

type Quux struct { //@symbol("Quux", "Quux", "Struct", "struct{...}", "Quux", "")
	X, Y float64 //@symbol("X", "X", "Field", "float64", "", "Quux"), symbol("Y", "Y", "Field", "float64", "", "Quux")
}

type EmptyStruct struct{} //@symbol("EmptyStruct", "EmptyStruct", "Struct", "struct{}", "", "")

func (f Foo) Baz() string { //@symbol("(Foo).Baz", "Baz", "Method", "func() string", "", "")
	return f.baz
}

func _() {}

func (q *Quux) Do() {} //@symbol("(*Quux).Do", "Do", "Method", "func()", "", "")

func main() { //@symbol("main", "main", "Function", "func()", "", "")
}

type Stringer interface { //@symbol("Stringer", "Stringer", "Interface", "interface{...}", "Stringer", "")
	String() string //@symbol("String", "String", "Method", "func() string", "", "Stringer")
}

type ABer interface { //@symbol("ABer", "ABer", "Interface", "interface{...}", "ABer", "")
	B()        //@symbol("B", "B", "Method", "func()", "", "ABer")
	A() string //@symbol("A", "A", "Method", "func() string", "", "ABer")
}

type WithEmbeddeds interface { //@symbol("WithEmbeddeds", "WithEmbeddeds", "Interface", "interface{...}", "WithEmbeddeds", "")
	Do()      //@symbol("Do", "Do", "Method", "func()", "", "WithEmbeddeds")
	ABer      //@symbol("ABer", "ABer", "Field", "ABer", "", "WithEmbeddeds")
	io.Writer //@symbol("Writer", "Writer", "Field", "io.Writer", "", "WithEmbeddeds")
}

type EmptyInterface interface{} //@symbol("EmptyInterface", "EmptyInterface", "Interface", "interface{}", "", "")

func Dunk() int { return 0 } //@symbol("Dunk", "Dunk", "Function", "func() int", "", "")

func dunk() {} //@symbol("dunk", "dunk", "Function", "func()", "", "")