-
Notifications
You must be signed in to change notification settings - Fork 108
/
hover.go
46 lines (36 loc) · 1.17 KB
/
hover.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
// SPDX-License-Identifier: MIT
package protocol
import (
"encoding/json"
"github.com/caixw/apidoc/v7/core"
)
// HoverCapabilities 客户端有关 hover 功能的描述
type HoverCapabilities struct {
// Whether hover supports dynamic registration.
DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
// The client supports the follow content formats for the content
// property. The order describes the preferred format of the client.
ContentFormat []MarkupKind `json:"contentFormat,omitempty"`
}
// HoverParams textDocument/hover 发送的参数
type HoverParams struct {
WorkDoneProgressParams
TextDocumentPositionParams
}
// Hover textDocument/hover 的返回结果
type Hover struct {
// The hover's content
Contents MarkupContent `json:"contents"`
// An optional range is a range inside a text document
// that is used to visualize a hover, e.g. by changing the background color.
Range core.Range `json:"range"`
}
// MarshalJSON 允许在 hover 为空值是返回 null
func (h *Hover) MarshalJSON() ([]byte, error) {
if h.Contents.Kind == "" {
return json.Marshal(nil)
}
type hoverShadow Hover
shadow := (*hoverShadow)(h)
return json.Marshal(shadow)
}