forked from julia-vscode/LanguageServer.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.jl
More file actions
206 lines (169 loc) · 5.2 KB
/
basic.jl
File metadata and controls
206 lines (169 loc) · 5.2 KB
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
mutable struct CancelParams
id::Union{String,Int64}
end
CancelParams(d::Dict) = CancelParams(d["id"])
const TraceValue = String
struct SetTraceParams
value::TraceValue
end
SetTraceParams(d::Dict) = SetTraceParams(d["value"])
struct ProgressParams{T}
token::Union{Int,String} # ProgressToken
value::T
end
mutable struct DocumentFilter <: Outbound
language::Union{String,Missing}
scheme::Union{String,Missing}
pattern::Union{String,Missing}
end
const DocumentSelector = Vector{DocumentFilter}
const DocumentUri = String
@dict_readable struct Position
line::Int
character::Int
end
Position(line::Integer) = Position(line, 0)
struct Range
start::Position
stop::Position
end
# Special case to account for use of 'end' as a fieldname in LSP
Range(d::Dict) = Range(Position(d["start"]), Position(d["end"]))
Range(line::Integer) = Range(Position(line), Position(line))
Range(l0::Integer, c0::Integer, l1::Integer, c1::Integer) = Range(Position(l0, c0), Position(l1, c1))
function JSON.lower(a::Range)
Dict("start" => a.start, "end" => a.stop)
end
@dict_readable struct Location
uri::DocumentUri
range::Range
end
Location(f::String, line::Integer) = Location(f, Range(line))
@dict_readable struct LocationLink <: Outbound
originalSelectionRange::Union{Range,Missing}
targetUri::DocumentUri
targetRange::Range
targetSelectionRange::Range
end
@dict_readable struct WorkspaceFolder
uri::String
name::String
end
##############################################################################
# Diagnostics
const DiagnosticSeverity = Int
const DiagnosticSeverities = (Error = 1,
Warning = 2,
Information = 3,
Hint = 4)
const DiagnosticTag = Int
const DiagnosticTags = (Unnecessary = 1,
Deprecated = 2)
struct DiagnosticRelatedInformation
location::Location
message::String
end
@dict_readable struct Diagnostic <: Outbound
range::Range
severity::Union{DiagnosticSeverity,Missing}
code::Union{String,Missing}
source::Union{String,Missing}
message::String
tags::Union{Vector{DiagnosticTag},Missing}
relatedInformation::Union{Vector{DiagnosticRelatedInformation},Missing}
end
##############################################################################
struct Command <: Outbound # Use traits for this?
title::String
command::String
arguments::Union{Vector{Any},Missing}
end
struct TextEdit
range::Range
newText::String
end
##############################################################################
# Markup
const MarkupKind = String
const MarkupKinds = (PlainText = "plaintext",
Markdown = "markdown")
mutable struct MarkupContent
kind::MarkupKind
value::String
end
MarkupContent(value::String) = MarkupContent(MarkupKinds.Markdown, value)
mutable struct MarkedString
language::String
value::AbstractString
end
Base.convert(::Type{MarkedString}, x::String) = MarkedString("julia", string(x))
MarkedString(x) = MarkedString("julia", string(x))
Base.hash(x::MarkedString) = hash(x.value) # for unique
##############################################################################
# Window
const MessageType = Int
const MessageTypes = (Error = 1,
Warning = 2,
Info = 3,
Log = 4)
struct ShowMessageParams <: Outbound
type::MessageType
message::String
end
struct MessageActionItem <: Outbound
title::String
end
mutable struct ShowMessageRequestParams <: Outbound
type::MessageType
message::String
actions::Union{Vector{MessageActionItem},Missing}
end
mutable struct LogMessageParams <: Outbound
type::Integer
message::String
end
##############################################################################
# Progress
struct WorkDoneProgressCreateParams <: Outbound
token::Union{Int,String} # ProgressToken
end
@dict_readable struct WorkDoneProgressCancelParams
token::Union{Int,String} # ProgressToken
end
struct WorkDoneProgressBegin <: Outbound
kind::String
title::String
cancellable::Union{Bool,Missing}
message::Union{String,Missing}
percentage::Union{Int,Missing}
function WorkDoneProgressBegin(title, cancellable, message, percentage)
new("begin", title, cancellable, message, percentage)
end
end
struct WorkDoneProgressReport <: Outbound
kind::String
cancellable::Union{Bool,Missing}
message::Union{String,Missing}
percentage::Union{Int,Missing}
function WorkDoneProgressReport(cancellable, message, percentage)
new("report", cancellable, message, percentage)
end
end
struct WorkDoneProgressEnd <: Outbound
kind::String
message::Union{String,Missing}
function WorkDoneProgressEnd(message)
new("end", message)
end
end
struct WorkDoneProgressParams <: Outbound
workDoneToken::Union{Int,String,Missing} # ProgressToken
end
struct WorkDoneProgressOptions <: Outbound
workDoneProgress::Union{Bool,Missing}
end
##############################################################################
# Partial
struct PartialResultParams <: Outbound
partialResultToken::Union{Int,String,Missing} # ProgressToken
end