-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
window.go
111 lines (92 loc) · 2.77 KB
/
window.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
// SPDX-FileCopyrightText: 2019 The Go Language Server Authors
// SPDX-License-Identifier: BSD-3-Clause
package protocol
import "strconv"
// ShowMessageParams params of ShowMessage notification.
type ShowMessageParams struct {
// Message is the actual message.
Message string `json:"message"`
// Type is the message type.
Type MessageType `json:"type"`
}
// MessageType type of ShowMessageParams type.
type MessageType float64
const (
// MessageTypeError an error message.
MessageTypeError MessageType = 1
// MessageTypeWarning a warning message.
MessageTypeWarning MessageType = 2
// MessageTypeInfo an information message.
MessageTypeInfo MessageType = 3
// MessageTypeLog a log message.
MessageTypeLog MessageType = 4
)
// String implements fmt.Stringer.
func (m MessageType) String() string {
switch m {
case MessageTypeError:
return "error"
case MessageTypeWarning:
return "warning"
case MessageTypeInfo:
return "info"
case MessageTypeLog:
return "log"
default:
return strconv.FormatFloat(float64(m), 'f', -10, 64)
}
}
// Enabled reports whether the level is enabled.
func (m MessageType) Enabled(level MessageType) bool {
return level > 0 && m >= level
}
// messageTypeMap map of MessageTypes.
var messageTypeMap = map[string]MessageType{
"error": MessageTypeError,
"warning": MessageTypeWarning,
"info": MessageTypeInfo,
"log": MessageTypeLog,
}
// ToMessageType converts level to the MessageType.
func ToMessageType(level string) MessageType {
mt, ok := messageTypeMap[level]
if !ok {
return MessageType(0) // unknown
}
return mt
}
// ShowMessageRequestParams params of ShowMessage request.
type ShowMessageRequestParams struct {
// Actions is the message action items to present.
Actions []MessageActionItem `json:"actions"`
// Message is the actual message
Message string `json:"message"`
// Type is the message type. See {@link MessageType}
Type MessageType `json:"type"`
}
// MessageActionItem item of ShowMessageRequestParams action.
type MessageActionItem struct {
// Title a short title like 'Retry', 'Open Log' etc.
Title string `json:"title"`
}
// LogMessageParams params of LogMessage notification.
type LogMessageParams struct {
// Message is the actual message
Message string `json:"message"`
// Type is the message type. See {@link MessageType}
Type MessageType `json:"type"`
}
// WorkDoneProgressCreateParams params of WorkDoneProgressCreate request.
//
// @since 3.15.0.
type WorkDoneProgressCreateParams struct {
// Token is the token to be used to report progress.
Token ProgressToken `json:"token"`
}
// WorkDoneProgressCancelParams params of WorkDoneProgressCancel request.
//
// @since 3.15.0.
type WorkDoneProgressCancelParams struct {
// Token is the token to be used to report progress.
Token ProgressToken `json:"token"`
}