-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbols.go
288 lines (232 loc) · 7.04 KB
/
symbols.go
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
package lsp
// SymbolKind specifies the type of a symbol.
type SymbolKind int
const (
// SKFile denotes a file symbol kind.
SKFile SymbolKind = iota + 1
// SKModule denotes a module symbol kind.
SKModule
// SKNamespace denotes a namespace symbol kind.
SKNamespace
// SKPackage denotes a package symbol kind.
SKPackage
// SKClass denotes a class symbol kind.
SKClass
// SKMethod denotes a method symbol kind.
SKMethod
// SKProperty denotes a property symbol kind.
SKProperty
// SKField denotes a field symbol kind.
SKField
// SKConstructor denotes a constructor symbol kind.
SKConstructor
// SKEnum denotes an enum symbol kind.
SKEnum
// SKInterface denotes an interface symbol kind.
SKInterface
// SKFunction denotes a function symbol kind.
SKFunction
// SKVariable denotes a variable symbol kind.
SKVariable
// SKConstant denotes a constant symbol kind.
SKConstant
// SKString denotes a string symbol kind.
SKString
// SKNumber denotes a number symbol kind.
SKNumber
// SKBoolean denotes a boolean symbol kind.
SKBoolean
// SKArray denotes an array symbol kind.
SKArray
// SKObject denotes an object symbol kind.
SKObject
// SKKey denotes a key symbol kind.
SKKey
// SKNull denotes a null symbol kind.
SKNull
// SKEnumMember denotes an enum member symbol kind.
SKEnumMember
// SKStruct denotes a struct symbol kind.
SKStruct
// SKEvent denotes an event symbol kind.
SKEvent
// SKOperator denotes an operator symbol kind.
SKOperator
// SKTypeParameter denotes a type parameter symbol kind.
SKTypeParameter
)
func (kind SymbolKind) String() string {
switch kind {
case SKFile:
return "file"
case SKModule:
return "module"
case SKNamespace:
return "namespace"
case SKPackage:
return "package"
case SKClass:
return "class"
case SKMethod:
return "method"
case SKProperty:
return "property"
case SKField:
return "field"
case SKConstructor:
return "constructor"
case SKEnum:
return "enum"
case SKInterface:
return "interface"
case SKFunction:
return "function"
case SKVariable:
return "variable"
case SKConstant:
return "constant"
case SKString:
return "string"
case SKNumber:
return "number"
case SKBoolean:
return "boolean"
case SKArray:
return "array"
case SKObject:
return "object"
case SKKey:
return "key"
case SKNull:
return "null"
case SKEnumMember:
return "enum member"
case SKStruct:
return "struct"
case SKEvent:
return "event"
case SKOperator:
return "operator"
case SKTypeParameter:
return "type parameter"
}
return "<unknown>"
}
// Symbol tags are extra annotations that tweak the rendering of a symbol.
//
// @since 3.16
type SymbolTag int
const (
// STDeprecated will render a symbol as obsolete, usually using a strike-out.
STDeprecated SymbolTag = iota + 1
)
func (tag SymbolTag) String() string {
switch tag {
case STDeprecated:
return "deprecated"
}
return "<unknown>"
}
// WorkspaceSymbolOptions is a literal for WorkDoneProgressOptions for symbols
// in a workspace.
type WorkspaceSymbolOptions struct {
WorkDoneProgressOptions
}
// WorkspaceSymbolRegistrationOptions contains the workspace symbol registration
// options.
type WorkspaceSymbolRegistrationOptions struct {
WorkspaceSymbolOptions
}
// WorkspaceSymbolParams contains the fields sent in a `workspace/symbol`
// request.
type WorkspaceSymbolParams struct {
WorkDoneProgressParams
PartialResultParams
// A query string to filter symbols by. Clients may send an empty string here
// to request all symbols.
Query string `json:"query"`
}
// DocumentSymbol represents programming constructs like variables, classes,
// interfaces etc. that appear in a document. Document symbols can be
// hierarchical and they have two ranges: one that encloses its definition and
// one that points to its most interesting range, for example, the range of an
// identifier.
type DocumentSymbol struct {
// The name of this symbol.
// Will be displayed in the user interface and therefore must not be
// an empty string or a string only consisting of white spaces.
Name string `json:"name"`
// More detail for this symbol, e.g the signature of a function.
Detail string `json:"detail,omitempty"`
// The kind of this symbol.
Kind SymbolKind `json:"kind"`
// Tags for this document symbol.
//
// @since 3.16.0
Tags []SymbolTag `json:"tags,omitempty"`
// Indicates if this symbol is deprecated.
Deprecated bool `json:"deprecated,omitempty"`
// The range enclosing this symbol not including leading/trailing
// whitespace but everything else like comments.
// This information is typically used to determine if the client's cursor
// is inside the symbol to reveal in the symbol in the UI.
Range *Range `json:"range"`
// The range that should be selected and revealed when this symbol
// is being picked, for example, the name of a function.
// Must be contained by the `range`.
SelectionRange *Range `json:"selectionRange"`
// Children of this symbol, e.g. properties of a class.
Children []DocumentSymbol `json:"children,omitempty"`
}
// SymbolInformation represents information about programming constructs like
// variables, classes, interfaces etc.
type SymbolInformation struct {
// The name of this symbol
Name string `json:"name"`
// The kind of this symbol.
Kind SymbolKind `json:"kind"`
// Tags for this symbol.
//
// @since 3.16.0
Tags []SymbolTag `json:"tags,omitempty"`
// Indicates if this symbol is deprecated.
Deprecated bool `json:"deprecated,omitempty"`
// The location of this symbol. The location's range is used by a tool
// to reveal the location in the editor. If the symbol is selected in the
// tool the range's start information is used to position the cursor. So
// the range usually spans more then the actual symbol's name and does
// normally include things like visibility modifiers.
//
// The range doesn't have to denote a node range in the sense of a abstract
// syntax tree. It can therefore not be used to re-construct a hierarchy of
// the symbols.
Location Location `json:"location"`
// The name of the symbol containing this symbol. This information is for
// user interface purposes (e.g. to render a qualifier in the user interface
// if necessary). It can't be used to re-infer a hierarchy for the document
// symbols.
ContainerName string `json:"containerName,omitempty"`
}
// DocumentSymbolOptions contains the options for the document symbol handler.
type DocumentSymbolOptions struct {
WorkDoneProgressOptions
// A human-readable string that is shown when multiple outlines trees are
// shown for the same document.
//
// @since 3.16.0
Label string `json:"label,omitempty"`
}
// DocumentSymbolRegistrationOptions contains the options for the document
// symbol handler registration.
type DocumentSymbolRegistrationOptions struct {
TextDocumentRegistrationOptions
DocumentHighlightOptions
}
// DocumentSymbolParams contains the fields sent in a
// `textDocument/documentSymbol` request.
type DocumentSymbolParams struct {
WorkDoneProgressParams
PartialResultParams
// The text document.
TextDocument TextDocumentIdentifier `json:"textDocument"`
}