Skip to content

Commit 6081535

Browse files
authored
Format files using DocumentFormat
1 parent 0955a4d commit 6081535

36 files changed

+355
-362
lines changed

docs/make.jl

Lines changed: 3 additions & 3 deletions
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

Lines changed: 56 additions & 56 deletions
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

@@ -36,58 +36,58 @@ function URI(;
3636
path::AbstractString="",
3737
query::Union{AbstractString,Nothing}=nothing,
3838
fragment::Union{AbstractString,Nothing}=nothing
39-
)
39+
)
4040
return URI(scheme, authority, path, query, fragment)
4141
end
4242

4343
@inline function is_rfc3986_unreserved(c::Char)
4444
return 'A' <= c <= 'Z' ||
45-
'a' <= c <= 'z' ||
46-
'0' <= c <= '9' ||
47-
c == '-' ||
48-
c == '.' ||
49-
c == '_' ||
50-
c == '~'
45+
'a' <= c <= 'z' ||
46+
'0' <= c <= '9' ||
47+
c == '-' ||
48+
c == '.' ||
49+
c == '_' ||
50+
c == '~'
5151
end
5252

5353
@inline function is_rfc3986_sub_delim(c::Char)
5454
return c == '!' ||
55-
c == '$' ||
56-
c == '&' ||
57-
c == '\'' ||
58-
c == '(' ||
59-
c == ')' ||
60-
c == '*' ||
61-
c == '+' ||
62-
c == ',' ||
63-
c == ';' ||
64-
c == '='
55+
c == '$' ||
56+
c == '&' ||
57+
c == '\'' ||
58+
c == '(' ||
59+
c == ')' ||
60+
c == '*' ||
61+
c == '+' ||
62+
c == ',' ||
63+
c == ';' ||
64+
c == '='
6565
end
6666

6767
@inline function is_rfc3986_pchar(c::Char)
6868
return is_rfc3986_unreserved(c) ||
69-
is_rfc3986_sub_delim(c) ||
70-
c == ':' ||
71-
c == '@'
69+
is_rfc3986_sub_delim(c) ||
70+
c == ':' ||
71+
c == '@'
7272
end
7373

7474
@inline function is_rfc3986_query(c::Char)
75-
return is_rfc3986_pchar(c) || c=='/' || c=='?'
75+
return is_rfc3986_pchar(c) || c == '/' || c == '?'
7676
end
7777

7878
@inline function is_rfc3986_fragment(c::Char)
79-
return is_rfc3986_pchar(c) || c=='/' || c=='?'
79+
return is_rfc3986_pchar(c) || c == '/' || c == '?'
8080
end
8181

8282
@inline function is_rfc3986_userinfo(c::Char)
8383
return is_rfc3986_unreserved(c) ||
84-
is_rfc3986_sub_delim(c) ||
85-
c == ':'
84+
is_rfc3986_sub_delim(c) ||
85+
c == ':'
8686
end
8787

8888
@inline function is_rfc3986_reg_name(c::Char)
8989
return is_rfc3986_unreserved(c) ||
90-
is_rfc3986_sub_delim(c)
90+
is_rfc3986_sub_delim(c)
9191
end
9292

9393
function encode(io::IO, s::AbstractString, issafe::Function)
@@ -102,14 +102,14 @@ function encode(io::IO, s::AbstractString, issafe::Function)
102102
end
103103

104104
@inline function is_ipv4address(s::AbstractString)
105-
if length(s)==1
105+
if length(s) == 1
106106
return '0' <= s[1] <= '9'
107-
elseif length(s)==2
107+
elseif length(s) == 2
108108
return '1' <= s[1] <= '9' && '0' <= s[2] <= '9'
109-
elseif length(s)==3
110-
return (s[1]=='1' && '0' <= s[2] <= '9' && '0' <= s[3] <= '9') ||
111-
(s[1]=='2' && '0' <= s[2] <= '4' && '0' <= s[3] <= '9') ||
112-
(s[1]=='2' && s[2] == '5' && '0' <= s[3] <= '5')
109+
elseif length(s) == 3
110+
return (s[1] == '1' && '0' <= s[2] <= '9' && '0' <= s[3] <= '9') ||
111+
(s[1] == '2' && '0' <= s[2] <= '4' && '0' <= s[3] <= '9') ||
112+
(s[1] == '2' && s[2] == '5' && '0' <= s[3] <= '5')
113113
else
114114
return false
115115
end
@@ -141,44 +141,44 @@ function Base.print(io::IO, uri::URI)
141141
query = uri.query
142142
fragment = uri.fragment
143143

144-
if scheme!==nothing
144+
if scheme !== nothing
145145
print(io, scheme)
146146
print(io, ':')
147-
end
147+
end
148148

149-
if authority!==nothing
149+
if authority !== nothing
150150
print(io, "//")
151151

152-
idx = findfirst("@", authority)
153-
if idx !== nothing
154-
# <user>@<auth>
155-
userinfo = SubString(authority, 1:idx.start-1)
156-
host_and_port = SubString(authority, idx.start + 1)
157-
encode(io, userinfo, is_rfc3986_userinfo)
152+
idx = findfirst("@", authority)
153+
if idx !== nothing
154+
# <user>@<auth>
155+
userinfo = SubString(authority, 1:idx.start-1)
156+
host_and_port = SubString(authority, idx.start + 1)
157+
encode(io, userinfo, is_rfc3986_userinfo)
158158
print(io, '@')
159159
else
160160
host_and_port = SubString(authority, 1)
161-
end
161+
end
162162

163-
idx3 = findfirst(":", host_and_port)
164-
if idx3 === nothing
163+
idx3 = findfirst(":", host_and_port)
164+
if idx3 === nothing
165165
encode_host(io, host_and_port)
166-
else
167-
# <auth>:<port>
166+
else
167+
# <auth>:<port>
168168
encode_host(io, SubString(host_and_port, 1:idx3.start-1))
169-
print(io, SubString(host_and_port, idx3.start))
169+
print(io, SubString(host_and_port, idx3.start))
170170
end
171-
end
171+
end
172172

173-
# Append path
174-
encode_path(io, path)
173+
# Append path
174+
encode_path(io, path)
175175

176-
if query!==nothing
176+
if query !== nothing
177177
print(io, '?')
178178
encode(io, query, is_rfc3986_query)
179179
end
180180

181-
if fragment!==nothing
181+
if fragment !== nothing
182182
print(io, '#')
183183
encode(io, fragment, is_rfc3986_fragment)
184184
end

src/URIs2/uri_helpers.jl

Lines changed: 6 additions & 6 deletions
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

Lines changed: 12 additions & 12 deletions
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

Lines changed: 1 addition & 1 deletion
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)