Skip to content

Commit 73934d3

Browse files
authored
Format files using DocumentFormat
1 parent 0700041 commit 73934d3

36 files changed

+355
-362
lines changed

docs/make.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ makedocs(;
77
repo="https://github.com/julia-vscode/LanguageServer.jl/blob/{commit}{path}#L{line}",
88
sitename="LanguageServer.jl",
99
format=Documenter.HTML(;
10-
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true",
10+
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true"
1111
# canonical="https://www.julia-vscode.org/LanguageServer.jl",
1212
# assets=String[],
1313
),
1414
pages=[
1515
"Home" => "index.md",
1616
"Syntax Reference" => "syntax.md",
17-
],
17+
]
1818
)
1919

2020
deploydocs(;
21-
repo="github.com/julia-vscode/LanguageServer.jl",
21+
repo="github.com/julia-vscode/LanguageServer.jl"
2222
)

src/URIs2/URIs2.jl

+56-56
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ end
1919
function URI(value::AbstractString)
2020
m = match(r"^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?", value)
2121

22-
m===nothing && error("Invalid argument.")
22+
m === nothing && error("Invalid argument.")
2323

2424
return URI(
2525
m.captures[2],
26-
m.captures[4]===nothing ? nothing : percent_decode(m.captures[4]),
27-
m.captures[5]===nothing ? nothing : percent_decode(m.captures[5]),
28-
m.captures[7]===nothing ? nothing : percent_decode(m.captures[7]),
29-
m.captures[9]===nothing ? nothing : percent_decode(m.captures[9])
26+
m.captures[4] === nothing ? nothing : percent_decode(m.captures[4]),
27+
m.captures[5] === nothing ? nothing : percent_decode(m.captures[5]),
28+
m.captures[7] === nothing ? nothing : percent_decode(m.captures[7]),
29+
m.captures[9] === nothing ? nothing : percent_decode(m.captures[9])
3030
)
3131
end
3232

@@ -38,58 +38,58 @@ function URI(;
3838
path::AbstractString="",
3939
query::Union{AbstractString,Nothing}=nothing,
4040
fragment::Union{AbstractString,Nothing}=nothing
41-
)
41+
)
4242
return URI(scheme, authority, path, query, fragment)
4343
end
4444

4545
@inline function is_rfc3986_unreserved(c::Char)
4646
return 'A' <= c <= 'Z' ||
47-
'a' <= c <= 'z' ||
48-
'0' <= c <= '9' ||
49-
c == '-' ||
50-
c == '.' ||
51-
c == '_' ||
52-
c == '~'
47+
'a' <= c <= 'z' ||
48+
'0' <= c <= '9' ||
49+
c == '-' ||
50+
c == '.' ||
51+
c == '_' ||
52+
c == '~'
5353
end
5454

5555
@inline function is_rfc3986_sub_delim(c::Char)
5656
return c == '!' ||
57-
c == '$' ||
58-
c == '&' ||
59-
c == '\'' ||
60-
c == '(' ||
61-
c == ')' ||
62-
c == '*' ||
63-
c == '+' ||
64-
c == ',' ||
65-
c == ';' ||
66-
c == '='
57+
c == '$' ||
58+
c == '&' ||
59+
c == '\'' ||
60+
c == '(' ||
61+
c == ')' ||
62+
c == '*' ||
63+
c == '+' ||
64+
c == ',' ||
65+
c == ';' ||
66+
c == '='
6767
end
6868

6969
@inline function is_rfc3986_pchar(c::Char)
7070
return is_rfc3986_unreserved(c) ||
71-
is_rfc3986_sub_delim(c) ||
72-
c == ':' ||
73-
c == '@'
71+
is_rfc3986_sub_delim(c) ||
72+
c == ':' ||
73+
c == '@'
7474
end
7575

7676
@inline function is_rfc3986_query(c::Char)
77-
return is_rfc3986_pchar(c) || c=='/' || c=='?'
77+
return is_rfc3986_pchar(c) || c == '/' || c == '?'
7878
end
7979

8080
@inline function is_rfc3986_fragment(c::Char)
81-
return is_rfc3986_pchar(c) || c=='/' || c=='?'
81+
return is_rfc3986_pchar(c) || c == '/' || c == '?'
8282
end
8383

8484
@inline function is_rfc3986_userinfo(c::Char)
8585
return is_rfc3986_unreserved(c) ||
86-
is_rfc3986_sub_delim(c) ||
87-
c == ':'
86+
is_rfc3986_sub_delim(c) ||
87+
c == ':'
8888
end
8989

9090
@inline function is_rfc3986_reg_name(c::Char)
9191
return is_rfc3986_unreserved(c) ||
92-
is_rfc3986_sub_delim(c)
92+
is_rfc3986_sub_delim(c)
9393
end
9494

9595
function encode(io::IO, s::AbstractString, issafe::Function)
@@ -104,14 +104,14 @@ function encode(io::IO, s::AbstractString, issafe::Function)
104104
end
105105

106106
@inline function is_ipv4address(s::AbstractString)
107-
if length(s)==1
107+
if length(s) == 1
108108
return '0' <= s[1] <= '9'
109-
elseif length(s)==2
109+
elseif length(s) == 2
110110
return '1' <= s[1] <= '9' && '0' <= s[2] <= '9'
111-
elseif length(s)==3
112-
return (s[1]=='1' && '0' <= s[2] <= '9' && '0' <= s[3] <= '9') ||
113-
(s[1]=='2' && '0' <= s[2] <= '4' && '0' <= s[3] <= '9') ||
114-
(s[1]=='2' && s[2] == '5' && '0' <= s[3] <= '5')
111+
elseif length(s) == 3
112+
return (s[1] == '1' && '0' <= s[2] <= '9' && '0' <= s[3] <= '9') ||
113+
(s[1] == '2' && '0' <= s[2] <= '4' && '0' <= s[3] <= '9') ||
114+
(s[1] == '2' && s[2] == '5' && '0' <= s[3] <= '5')
115115
else
116116
return false
117117
end
@@ -143,44 +143,44 @@ function Base.print(io::IO, uri::URI)
143143
query = uri.query
144144
fragment = uri.fragment
145145

146-
if scheme!==nothing
146+
if scheme !== nothing
147147
print(io, scheme)
148148
print(io, ':')
149-
end
149+
end
150150

151-
if authority!==nothing
151+
if authority !== nothing
152152
print(io, "//")
153153

154-
idx = findfirst("@", authority)
155-
if idx !== nothing
156-
# <user>@<auth>
157-
userinfo = SubString(authority, 1:idx.start-1)
158-
host_and_port = SubString(authority, idx.start + 1)
159-
encode(io, userinfo, is_rfc3986_userinfo)
154+
idx = findfirst("@", authority)
155+
if idx !== nothing
156+
# <user>@<auth>
157+
userinfo = SubString(authority, 1:idx.start-1)
158+
host_and_port = SubString(authority, idx.start + 1)
159+
encode(io, userinfo, is_rfc3986_userinfo)
160160
print(io, '@')
161161
else
162162
host_and_port = SubString(authority, 1)
163-
end
163+
end
164164

165-
idx3 = findfirst(":", host_and_port)
166-
if idx3 === nothing
165+
idx3 = findfirst(":", host_and_port)
166+
if idx3 === nothing
167167
encode_host(io, host_and_port)
168-
else
169-
# <auth>:<port>
168+
else
169+
# <auth>:<port>
170170
encode_host(io, SubString(host_and_port, 1:idx3.start-1))
171-
print(io, SubString(host_and_port, idx3.start))
171+
print(io, SubString(host_and_port, idx3.start))
172172
end
173-
end
173+
end
174174

175-
# Append path
176-
encode_path(io, path)
175+
# Append path
176+
encode_path(io, path)
177177

178-
if query!==nothing
178+
if query !== nothing
179179
print(io, '?')
180180
encode(io, query, is_rfc3986_query)
181181
end
182182

183-
if fragment!==nothing
183+
if fragment !== nothing
184184
print(io, '#')
185185
encode(io, fragment, is_rfc3986_fragment)
186186
end

src/URIs2/uri_helpers.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ function uri2filepath(uri::URI)
77
path = uri.path
88
host = uri.authority
99

10-
if host!==nothing && host != "" && length(path) > 1
10+
if host !== nothing && host != "" && length(path) > 1
1111
# unc path: file://shares/c$/far/boo
1212
value = "//$host$path"
1313
elseif length(path) >= 3 &&
14-
path[1] == '/' &&
15-
isascii(path[2]) && isletter(path[2]) &&
16-
path[3] == ':'
14+
path[1] == '/' &&
15+
isascii(path[2]) && isletter(path[2]) &&
16+
path[3] == ':'
1717
# windows drive letter: file:///c:/far/boo
1818
value = lowercase(path[2]) * path[3:end]
1919
else
@@ -42,14 +42,14 @@ function filepath2uri(path::String)
4242
if startswith(path, "//")
4343
# UNC path //foo/bar/foobar
4444
idx = findnext("/", path, 3)
45-
if idx===nothing
45+
if idx === nothing
4646
authority = path[3:end]
4747
path = "/"
4848
else
4949
authority = path[3:idx.start-1]
5050
path = path[idx.start:end]
5151
end
52-
elseif length(path)>=2 && isascii(path[1]) && isletter(path[1]) && path[2]==':'
52+
elseif length(path) >= 2 && isascii(path[1]) && isletter(path[1]) && path[2] == ':'
5353
path = string('/', lowercase(path[1]), SubString(path, 2))
5454
end
5555

src/document.jl

+12-12
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function get_offset(doc::Document, line::Integer, character::Integer)
7777
line_offsets = get_line_offsets(doc)
7878
io = IOBuffer(get_text(doc))
7979
try
80-
seek(io, line_offsets[line + 1])
80+
seek(io, line_offsets[line+1])
8181
while character > 0
8282
c = read(io, Char)
8383
character -= 1
@@ -102,7 +102,7 @@ get_offset(doc, p::Position) = get_offset(doc, p.line, p.character)
102102
get_offset(doc, r::Range) = get_offset(doc, r.start):get_offset(doc, r.stop)
103103

104104
# 1-based. Basically the index at which (line, character) can be found in the document.
105-
get_offset2(doc::Document, p::Position, forgiving_mode=false) = get_offset2(doc, p.line, p.character, forgiving_mode)
105+
get_offset2(doc::Document, p::Position, forgiving_mode=false) = get_offset2(doc, p.line, p.character, forgiving_mode)
106106
function get_offset2(doc::Document, line::Integer, character::Integer, forgiving_mode=false)
107107
line_offsets = get_line_offsets2!(doc)
108108
text = get_text(doc)
@@ -114,9 +114,9 @@ function get_offset2(doc::Document, line::Integer, character::Integer, forgiving
114114
throw(LSOffsetError("get_offset2 crashed. More diagnostics:\nline=$line\nline_offsets='$line_offsets'"))
115115
end
116116

117-
line_offset = line_offsets[line + 1]
117+
line_offset = line_offsets[line+1]
118118

119-
next_line_offset = line + 1 < length(line_offsets) ? line_offsets[line + 2] : nextind(text, lastindex(text))
119+
next_line_offset = line + 1 < length(line_offsets) ? line_offsets[line+2] : nextind(text, lastindex(text))
120120

121121
pos = line_offset
122122

@@ -177,16 +177,16 @@ function get_line_offsets(doc::Document, force=false)
177177
doc._line_offsets = Int[0]
178178
text = get_text(doc)
179179
ind = firstindex(text)
180-
while ind <= lastindex(text)
180+
while ind <= lastindex(text)
181181
c = text[ind]
182182
nl = c == '\n' || c == '\r'
183-
if c == '\r' && ind + 1 <= lastindex(text) && text[ind + 1] == '\n'
183+
if c == '\r' && ind + 1 <= lastindex(text) && text[ind+1] == '\n'
184184
ind += 1
185185
end
186186
nl && push!(doc._line_offsets, ind)
187187
ind = nextind(text, ind)
188188
end
189-
end
189+
end
190190
return doc._line_offsets
191191
end
192192

@@ -195,10 +195,10 @@ function get_line_offsets2!(doc::Document, force=false)
195195
doc._line_offsets2 = Int[1]
196196
text = get_text(doc)
197197
ind = firstindex(text)
198-
while ind <= lastindex(text)
198+
while ind <= lastindex(text)
199199
c = text[ind]
200200
if c == '\n' || c == '\r'
201-
if c == '\r' && ind + 1 <= lastindex(text) && text[ind + 1] == '\n'
201+
if c == '\r' && ind + 1 <= lastindex(text) && text[ind+1] == '\n'
202202
ind += 1
203203
end
204204
push!(doc._line_offsets2, ind + 1)
@@ -218,12 +218,12 @@ function get_line_of(line_offsets::Vector{Int}, offset::Integer)
218218
else
219219
line = 1
220220
while line < nlines
221-
if line_offsets[line] <= offset < line_offsets[line + 1]
221+
if line_offsets[line] <= offset < line_offsets[line+1]
222222
break
223223
end
224224
line += 1
225225
end
226-
end
226+
end
227227
return line, line_offsets[line]
228228
end
229229

@@ -244,7 +244,7 @@ function get_position_at(doc::Document, offset::Integer)
244244
c = read(io, Char)
245245
character += 1
246246
if UInt32(c) >= 0x010000
247-
character += 1
247+
character += 1
248248
end
249249
end
250250
close(io)

src/extensions/messagedefs.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const julia_getModuleAt_request_type = JSONRPC.RequestType("julia/getModuleAt", VersionedTextDocumentPositionParams, String)
2-
const julia_getCurrentBlockRange_request_type = JSONRPC.RequestType("julia/getCurrentBlockRange", VersionedTextDocumentPositionParams, Tuple{Position, Position, Position})
2+
const julia_getCurrentBlockRange_request_type = JSONRPC.RequestType("julia/getCurrentBlockRange", VersionedTextDocumentPositionParams, Tuple{Position,Position,Position})
33
const julia_getDocAt_request_type = JSONRPC.RequestType("julia/getDocAt", VersionedTextDocumentPositionParams, String)
44
const julia_getDocFromWord_request_type = JSONRPC.RequestType("julia/getDocFromWord", NamedTuple{(:word,),Tuple{String}}, String)

0 commit comments

Comments
 (0)