Skip to content

Commit 266fab3

Browse files
authored
Format files using DocumentFormat
1 parent 146ad42 commit 266fab3

36 files changed

Lines changed: 364 additions & 366 deletions

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: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ end
1414

1515
@static if Sys.iswindows()
1616
function Base.:(==)(a::URI, b::URI)
17-
if a.scheme=="file" && b.scheme=="file"
17+
if a.scheme == "file" && b.scheme == "file"
1818
a_path_norm = lowercase(a.path)
1919
b_path_norm = lowercase(b.path)
2020

2121
return a.scheme == b.scheme &&
22-
a.authority == b.authority &&
23-
a_path_norm == b_path_norm &&
24-
a.query == b.query &&
25-
a.fragment == b.fragment
22+
a.authority == b.authority &&
23+
a_path_norm == b_path_norm &&
24+
a.query == b.query &&
25+
a.fragment == b.fragment
2626
else
2727
return a.scheme == b.scheme &&
28-
a.authority == b.authority &&
29-
a.path == b.path &&
30-
a.query == b.query &&
31-
a.fragment == b.fragment
28+
a.authority == b.authority &&
29+
a.path == b.path &&
30+
a.query == b.query &&
31+
a.fragment == b.fragment
3232
end
3333
end
3434

3535
function Base.hash(a::URI, h::UInt)
36-
if a.scheme=="file"
36+
if a.scheme == "file"
3737
path_norm = lowercase(a.path)
3838
return hash((a.scheme, a.authority, path_norm, a.query, a.fragment), h)
3939
else
@@ -49,14 +49,14 @@ end
4949
function URI(value::AbstractString)
5050
m = match(r"^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?", value)
5151

52-
m===nothing && error("Invalid argument.")
52+
m === nothing && error("Invalid argument.")
5353

5454
return URI(
5555
m.captures[2],
56-
m.captures[4]===nothing ? nothing : percent_decode(m.captures[4]),
57-
m.captures[5]===nothing ? nothing : percent_decode(m.captures[5]),
58-
m.captures[7]===nothing ? nothing : percent_decode(m.captures[7]),
59-
m.captures[9]===nothing ? nothing : percent_decode(m.captures[9])
56+
m.captures[4] === nothing ? nothing : percent_decode(m.captures[4]),
57+
m.captures[5] === nothing ? nothing : percent_decode(m.captures[5]),
58+
m.captures[7] === nothing ? nothing : percent_decode(m.captures[7]),
59+
m.captures[9] === nothing ? nothing : percent_decode(m.captures[9])
6060
)
6161
end
6262

@@ -68,58 +68,58 @@ function URI(;
6868
path::AbstractString="",
6969
query::Union{AbstractString,Nothing}=nothing,
7070
fragment::Union{AbstractString,Nothing}=nothing
71-
)
71+
)
7272
return URI(scheme, authority, path, query, fragment)
7373
end
7474

7575
@inline function is_rfc3986_unreserved(c::Char)
7676
return 'A' <= c <= 'Z' ||
77-
'a' <= c <= 'z' ||
78-
'0' <= c <= '9' ||
79-
c == '-' ||
80-
c == '.' ||
81-
c == '_' ||
82-
c == '~'
77+
'a' <= c <= 'z' ||
78+
'0' <= c <= '9' ||
79+
c == '-' ||
80+
c == '.' ||
81+
c == '_' ||
82+
c == '~'
8383
end
8484

8585
@inline function is_rfc3986_sub_delim(c::Char)
8686
return c == '!' ||
87-
c == '$' ||
88-
c == '&' ||
89-
c == '\'' ||
90-
c == '(' ||
91-
c == ')' ||
92-
c == '*' ||
93-
c == '+' ||
94-
c == ',' ||
95-
c == ';' ||
96-
c == '='
87+
c == '$' ||
88+
c == '&' ||
89+
c == '\'' ||
90+
c == '(' ||
91+
c == ')' ||
92+
c == '*' ||
93+
c == '+' ||
94+
c == ',' ||
95+
c == ';' ||
96+
c == '='
9797
end
9898

9999
@inline function is_rfc3986_pchar(c::Char)
100100
return is_rfc3986_unreserved(c) ||
101-
is_rfc3986_sub_delim(c) ||
102-
c == ':' ||
103-
c == '@'
101+
is_rfc3986_sub_delim(c) ||
102+
c == ':' ||
103+
c == '@'
104104
end
105105

106106
@inline function is_rfc3986_query(c::Char)
107-
return is_rfc3986_pchar(c) || c=='/' || c=='?'
107+
return is_rfc3986_pchar(c) || c == '/' || c == '?'
108108
end
109109

110110
@inline function is_rfc3986_fragment(c::Char)
111-
return is_rfc3986_pchar(c) || c=='/' || c=='?'
111+
return is_rfc3986_pchar(c) || c == '/' || c == '?'
112112
end
113113

114114
@inline function is_rfc3986_userinfo(c::Char)
115115
return is_rfc3986_unreserved(c) ||
116-
is_rfc3986_sub_delim(c) ||
117-
c == ':'
116+
is_rfc3986_sub_delim(c) ||
117+
c == ':'
118118
end
119119

120120
@inline function is_rfc3986_reg_name(c::Char)
121121
return is_rfc3986_unreserved(c) ||
122-
is_rfc3986_sub_delim(c)
122+
is_rfc3986_sub_delim(c)
123123
end
124124

125125
function encode(io::IO, s::AbstractString, issafe::Function)
@@ -134,14 +134,14 @@ function encode(io::IO, s::AbstractString, issafe::Function)
134134
end
135135

136136
@inline function is_ipv4address(s::AbstractString)
137-
if length(s)==1
137+
if length(s) == 1
138138
return '0' <= s[1] <= '9'
139-
elseif length(s)==2
139+
elseif length(s) == 2
140140
return '1' <= s[1] <= '9' && '0' <= s[2] <= '9'
141-
elseif length(s)==3
142-
return (s[1]=='1' && '0' <= s[2] <= '9' && '0' <= s[3] <= '9') ||
143-
(s[1]=='2' && '0' <= s[2] <= '4' && '0' <= s[3] <= '9') ||
144-
(s[1]=='2' && s[2] == '5' && '0' <= s[3] <= '5')
141+
elseif length(s) == 3
142+
return (s[1] == '1' && '0' <= s[2] <= '9' && '0' <= s[3] <= '9') ||
143+
(s[1] == '2' && '0' <= s[2] <= '4' && '0' <= s[3] <= '9') ||
144+
(s[1] == '2' && s[2] == '5' && '0' <= s[3] <= '5')
145145
else
146146
return false
147147
end
@@ -173,44 +173,44 @@ function Base.print(io::IO, uri::URI)
173173
query = uri.query
174174
fragment = uri.fragment
175175

176-
if scheme!==nothing
176+
if scheme !== nothing
177177
print(io, scheme)
178178
print(io, ':')
179-
end
179+
end
180180

181-
if authority!==nothing
181+
if authority !== nothing
182182
print(io, "//")
183183

184-
idx = findfirst("@", authority)
185-
if idx !== nothing
186-
# <user>@<auth>
187-
userinfo = SubString(authority, 1:idx.start-1)
188-
host_and_port = SubString(authority, idx.start + 1)
189-
encode(io, userinfo, is_rfc3986_userinfo)
184+
idx = findfirst("@", authority)
185+
if idx !== nothing
186+
# <user>@<auth>
187+
userinfo = SubString(authority, 1:idx.start-1)
188+
host_and_port = SubString(authority, idx.start + 1)
189+
encode(io, userinfo, is_rfc3986_userinfo)
190190
print(io, '@')
191191
else
192192
host_and_port = SubString(authority, 1)
193-
end
193+
end
194194

195-
idx3 = findfirst(":", host_and_port)
196-
if idx3 === nothing
195+
idx3 = findfirst(":", host_and_port)
196+
if idx3 === nothing
197197
encode_host(io, host_and_port)
198-
else
199-
# <auth>:<port>
198+
else
199+
# <auth>:<port>
200200
encode_host(io, SubString(host_and_port, 1:idx3.start-1))
201-
print(io, SubString(host_and_port, idx3.start))
201+
print(io, SubString(host_and_port, idx3.start))
202202
end
203-
end
203+
end
204204

205-
# Append path
206-
encode_path(io, path)
205+
# Append path
206+
encode_path(io, path)
207207

208-
if query!==nothing
208+
if query !== nothing
209209
print(io, '?')
210210
encode(io, query, is_rfc3986_query)
211211
end
212212

213-
if fragment!==nothing
213+
if fragment !== nothing
214214
print(io, '#')
215215
encode(io, fragment, is_rfc3986_fragment)
216216
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/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)

src/languageserverinstance.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ mutable struct LanguageServerInstance
6363

6464
shutdown_requested::Bool
6565

66-
function LanguageServerInstance(pipe_in, pipe_out, env_path="", depot_path="", err_handler=nothing, symserver_store_path=nothing, download=true, symbolcache_upstream = nothing)
66+
function LanguageServerInstance(pipe_in, pipe_out, env_path="", depot_path="", err_handler=nothing, symserver_store_path=nothing, download=true, symbolcache_upstream=nothing)
6767
new(
6868
JSONRPC.JSONRPCEndpoint(pipe_in, pipe_out, err_handler),
6969
Set{String}(),
7070
Dict{URI,Document}(),
7171
env_path,
7272
depot_path,
73-
SymbolServer.SymbolServerInstance(depot_path, symserver_store_path; symbolcache_upstream = symbolcache_upstream),
73+
SymbolServer.SymbolServerInstance(depot_path, symserver_store_path; symbolcache_upstream=symbolcache_upstream),
7474
Channel(Inf),
7575
StaticLint.ExternalEnv(deepcopy(SymbolServer.stdlibs), SymbolServer.collect_extended_methods(SymbolServer.stdlibs), collect(keys(SymbolServer.stdlibs))),
7676
Dict(),
@@ -179,7 +179,7 @@ function trigger_symbolstore_reload(server::LanguageServerInstance)
179179
ssi_ret, payload = SymbolServer.getstore(
180180
server.symbol_server,
181181
server.env_path,
182-
function (msg, percentage = missing)
182+
function (msg, percentage=missing)
183183
if server.clientcapability_window_workdoneprogress && server.current_symserver_progress_token !== nothing
184184
msg = ismissing(percentage) ? msg : string(msg, " ($percentage%)")
185185
JSONRPC.send(
@@ -193,7 +193,7 @@ function trigger_symbolstore_reload(server::LanguageServerInstance)
193193
end
194194
end,
195195
server.err_handler,
196-
download = server.symserver_use_download
196+
download=server.symserver_use_download
197197
)
198198

199199
server.number_of_outstanding_symserver_requests -= 1
@@ -281,7 +281,7 @@ function Base.run(server::LanguageServerInstance)
281281
@debug "LS: Starting client listener task."
282282
while true
283283
msg = JSONRPC.get_next_message(server.jr_endpoint)
284-
put!(server.combined_msg_queue, (type = :clientmsg, msg = msg))
284+
put!(server.combined_msg_queue, (type=:clientmsg, msg=msg))
285285
end
286286
catch err
287287
bt = catch_backtrace()
@@ -294,7 +294,7 @@ function Base.run(server::LanguageServerInstance)
294294
end
295295
finally
296296
if isopen(server.combined_msg_queue)
297-
put!(server.combined_msg_queue, (type = :close,))
297+
put!(server.combined_msg_queue, (type=:close,))
298298
close(server.combined_msg_queue)
299299
end
300300
@debug "LS: Client listener task done."
@@ -304,7 +304,7 @@ function Base.run(server::LanguageServerInstance)
304304
@debug "LS: Starting symbol server listener task."
305305
while true
306306
msg = take!(server.symbol_results_channel)
307-
put!(server.combined_msg_queue, (type = :symservmsg, msg = msg))
307+
put!(server.combined_msg_queue, (type=:symservmsg, msg=msg))
308308
end
309309
catch err
310310
bt = catch_backtrace()
@@ -317,7 +317,7 @@ function Base.run(server::LanguageServerInstance)
317317
end
318318
finally
319319
if isopen(server.combined_msg_queue)
320-
put!(server.combined_msg_queue, (type = :close,))
320+
put!(server.combined_msg_queue, (type=:close,))
321321
close(server.combined_msg_queue)
322322
end
323323
@debug "LS: Symbol server listener task done."

src/multienv.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const project_names = ("JuliaProject.toml", "Project.toml")
1010
const manifest_names = ("JuliaManifest.toml", "Manifest.toml")
1111

1212
# return nothing or the project file at env
13-
function env_file(env::String, names = project_names)::Union{Nothing,String}
13+
function env_file(env::String, names=project_names)::Union{Nothing,String}
1414
if isdir(env)
1515
for proj in names
1616
project_file = joinpath(env, proj)
@@ -49,7 +49,7 @@ function get_env_for_root(doc::Document, server::LanguageServerInstance)
4949
(safe_isfile(env_proj_file) && safe_isfile(env_manifest_file)) || return
5050

5151
# Find which workspace folder the doc is in.
52-
parent_workspaceFolders = sort(filter(f->startswith(doc._path, f), collect(server.workspaceFolders)), by = length, rev = true)
52+
parent_workspaceFolders = sort(filter(f -> startswith(doc._path, f), collect(server.workspaceFolders)), by=length, rev=true)
5353

5454
isempty(parent_workspaceFolders) && return
5555
# arbitrarily pick one
@@ -94,11 +94,11 @@ function get_env_for_root(doc::Document, server::LanguageServerInstance)
9494
msg
9595
))
9696
end
97-
@error msg exception=(err, catch_backtrace())
97+
@error msg exception = (err, catch_backtrace())
9898
end
9999
end
100100

101-
function complete_dep_tree(uuid, env_manifest, alldeps = Dict{Base.UUID,Pkg.Types.PackageEntry}())
101+
function complete_dep_tree(uuid, env_manifest, alldeps=Dict{Base.UUID,Pkg.Types.PackageEntry}())
102102
haskey(alldeps, uuid) && return alldeps
103103
alldeps[uuid] = env_manifest[uuid]
104104
for dep_uuid in values(alldeps[uuid].deps)

0 commit comments

Comments
 (0)