Skip to content

Commit 697f032

Browse files
authored
Format files using DocumentFormat
1 parent fe6ee79 commit 697f032

File tree

11 files changed

+155
-136
lines changed

11 files changed

+155
-136
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/SymbolServer.jl/blob/{commit}{path}#L{line}",
88
sitename="SymbolServer.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/SymbolServer.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/SymbolServer.jl",
21+
repo="github.com/julia-vscode/SymbolServer.jl"
2222
)

registryindexer/main.jl

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
max_n = 1_000_000
44
max_versions = 1_000_000
5-
max_tasks = length(ARGS)>1 ? parse(Int, ARGS[2]) : 1
5+
max_tasks = length(ARGS) > 1 ? parse(Int, ARGS[2]) : 1
66

77
julia_versions = [v"1.7.2"]
88

@@ -13,26 +13,26 @@ Pkg.instantiate()
1313

1414
using ProgressMeter, Query, JSON, UUIDs, Tar, CodecZlib
1515

16-
function get_all_package_versions(;max_versions=typemax(Int))
16+
function get_all_package_versions(; max_versions=typemax(Int))
1717
registry_folder_path = joinpath(homedir(), ".julia", "registries", "General")
1818
registry_path = joinpath(registry_folder_path, "Registry.toml")
1919

2020
registry_content = Pkg.TOML.parsefile(registry_path)
2121

2222
packages = registry_content["packages"] |>
23-
@map({
24-
name = _[2]["name"],
25-
uuid = UUID(_[1]),
26-
path = _[2]["path"]
27-
}) |>
28-
@mutate(
29-
versions = (Pkg.TOML.parsefile(joinpath(registry_folder_path, _.path, "Versions.toml")) |>
30-
@map(i->{version=VersionNumber(i[1]), treehash=i[2]["git-tree-sha1"]}) |>
31-
@orderby_descending(i->i.version) |>
32-
@take(max_versions) |>
33-
collect)
34-
) |>
35-
collect
23+
@map({
24+
name = _[2]["name"],
25+
uuid = UUID(_[1]),
26+
path = _[2]["path"]
27+
}) |>
28+
@mutate(
29+
versions = (Pkg.TOML.parsefile(joinpath(registry_folder_path, _.path, "Versions.toml")) |>
30+
@map(i -> {version = VersionNumber(i[1]), treehash = i[2]["git-tree-sha1"]}) |>
31+
@orderby_descending(i -> i.version) |>
32+
@take(max_versions) |>
33+
collect)
34+
) |>
35+
collect
3636

3737
return packages
3838
end
@@ -42,7 +42,7 @@ function get_flattened_package_versions(packages)
4242

4343
for p in packages
4444
for v in p.versions
45-
push!(flattened_packageversions, (;p.name, p.uuid, p.path, version=v.version, treehash=v.treehash))
45+
push!(flattened_packageversions, (; p.name, p.uuid, p.path, version=v.version, treehash=v.treehash))
4646
end
4747
end
4848

@@ -54,11 +54,11 @@ function execute(cmd::Base.Cmd)
5454
err = IOBuffer()
5555
process = run(pipeline(ignorestatus(cmd), stdout=out, stderr=err))
5656

57-
out_string =String(take!(out))
57+
out_string = String(take!(out))
5858
err_string = String(take!(err))
59-
return (stdout = out_string,
60-
stderr = err_string,
61-
code = process.exitcode)
59+
return (stdout=out_string,
60+
stderr=err_string,
61+
code=process.exitcode)
6262
end
6363

6464
@info "Indexing started..."
@@ -69,7 +69,7 @@ flattened_packageversions = get_flattened_package_versions(all_packages)
6969

7070
@info "Loaded package versions from registry..."
7171

72-
cache_folder = length(ARGS)>0 ? ARGS[1] : joinpath(@__DIR__, "..", "registryindexcache")
72+
cache_folder = length(ARGS) > 0 ? ARGS[1] : joinpath(@__DIR__, "..", "registryindexcache")
7373

7474
@info "Using the following folder as the cache folder: " cache_folder
7575

@@ -92,7 +92,7 @@ asyncmap(julia_versions) do v
9292
print(f, res.stderr)
9393
end
9494

95-
if res.code!=0
95+
if res.code != 0
9696
error("Could not create docker image.")
9797
end
9898
end
@@ -108,10 +108,10 @@ true || asyncmap(julia_versions) do v
108108
else
109109
res = execute(`docker run --rm --mount type=bind,source="$cache_folder",target=/symcache juliavscodesymbolindexer:$v julia SymbolServer/src/indexbasestdlib.jl $v`)
110110

111-
if res.code==10 || res.code==20
112-
if res.code==10
111+
if res.code == 10 || res.code == 20
112+
if res.code == 10
113113
# global count_failed_to_load += 1
114-
elseif res.code==20
114+
elseif res.code == 20
115115
# global count_failed_to_install += 1
116116
end
117117

@@ -121,7 +121,7 @@ true || asyncmap(julia_versions) do v
121121
# # Write them to a file
122122
# open(joinpath(path, error_filename), "w") do io
123123
# end
124-
124+
125125
# Pkg.PlatformEngines.package(path, cache_path)
126126
# end
127127

@@ -136,7 +136,7 @@ true || asyncmap(julia_versions) do v
136136
# global status_db
137137

138138
# push!(status_db, Dict("name"=>v.name, "uuid"=>string(v.uuid), "version"=>string(v.version), "treehash"=>v.treehash, "status"=>res.code==20 ? "install_error" : "load_error", "indexattempts"=>[Dict("juliaversion"=>string(VERSION), "stdout"=>res.stdout, "stderr"=>res.stderr)]))
139-
elseif res.code==0
139+
elseif res.code == 0
140140
# global count_successfully_cached += 1
141141
else
142142
# global count_failed_to_index += 1
@@ -154,7 +154,7 @@ end
154154
@info "Now computing which of the total $(length(flattened_packageversions)) package versions that exist still need to be indexed..."
155155

156156
unindexed_packageversions = filter(collect(Iterators.take(flattened_packageversions, max_n))) do v
157-
versionwithoutplus = replace(string(v.version), '+'=>'_')
157+
versionwithoutplus = replace(string(v.version), '+' => '_')
158158

159159
cache_path = joinpath(cache_folder, "v1", "packages", string(uppercase(v.name[1])), "$(v.name)_$(v.uuid)", "v$(versionwithoutplus)_$(v.treehash).tar.gz")
160160

@@ -179,7 +179,7 @@ status_db = isfile(statusdb_filename) ? JSON.parsefile(statusdb_filename) : []
179179
@info "Starting the actual indexing process..."
180180

181181
asyncmap(unindexed_packageversions, ntasks=max_tasks) do v
182-
versionwithoutplus = replace(string(v.version), '+'=>'_')
182+
versionwithoutplus = replace(string(v.version), '+' => '_')
183183

184184
cache_path = joinpath(cache_folder, "v1", "packages", string(uppercase(v.name[1])), "$(v.name)_$(v.uuid)")
185185
mkpath(cache_path)
@@ -188,12 +188,12 @@ asyncmap(unindexed_packageversions, ntasks=max_tasks) do v
188188
mktempdir() do path
189189
res = execute(`docker run --rm --mount type=bind,source="$path",target=/symcache juliavscodesymbolindexer:$(first(julia_versions)) julia SymbolServer/src/indexpackage.jl $(v.name) $(v.version) $(v.uuid) $(v.treehash)`)
190190

191-
if res.code==37 # This is our magic error code that indicates everything worked
191+
if res.code == 37 # This is our magic error code that indicates everything worked
192192
global count_successfully_cached += 1
193193
else
194-
if res.code==10
194+
if res.code == 10
195195
global count_failed_to_load += 1
196-
elseif res.code==20
196+
elseif res.code == 20
197197
global count_failed_to_install += 1
198198
else
199199
global count_failed_to_index += 1
@@ -209,20 +209,20 @@ asyncmap(unindexed_packageversions, ntasks=max_tasks) do v
209209
isfile(joinpath(path, error_filename)) && rm(joinpath(path, error_filename))
210210

211211
# Write them to a file
212-
open(joinpath(path, error_filename), "w") do io
212+
open(joinpath(path, error_filename), "w") do io
213213
end
214214

215-
open(joinpath(cache_folder, "logs", res.code==10 ? "packageloadfailure" : res.code==20 ? "packageinstallfailure" : "packageindexfailure", "log_$(v.name)_v$(versionwithoutplus)_stdout.txt"), "w") do f
215+
open(joinpath(cache_folder, "logs", res.code == 10 ? "packageloadfailure" : res.code == 20 ? "packageinstallfailure" : "packageindexfailure", "log_$(v.name)_v$(versionwithoutplus)_stdout.txt"), "w") do f
216216
print(f, res.stdout)
217217
end
218218

219-
open(joinpath(cache_folder, "logs", res.code==10 ? "packageloadfailure" : res.code==20 ? "packageinstallfailure" : "packageindexfailure", "log_$(v.name)_v$(versionwithoutplus)_stderr.txt"), "w") do f
219+
open(joinpath(cache_folder, "logs", res.code == 10 ? "packageloadfailure" : res.code == 20 ? "packageinstallfailure" : "packageindexfailure", "log_$(v.name)_v$(versionwithoutplus)_stderr.txt"), "w") do f
220220
print(f, res.stderr)
221221
end
222222

223223
global status_db
224224

225-
push!(status_db, Dict("name"=>v.name, "uuid"=>string(v.uuid), "version"=>string(v.version), "treehash"=>v.treehash, "status"=>res.code==20 ? "install_error" : res.code==10 ? "load_error" : "index_error", "indexattempts"=>[Dict("juliaversion"=>string(VERSION), "stdout"=>res.stdout, "stderr"=>res.stderr)]))
225+
push!(status_db, Dict("name" => v.name, "uuid" => string(v.uuid), "version" => string(v.version), "treehash" => v.treehash, "status" => res.code == 20 ? "install_error" : res.code == 10 ? "load_error" : "index_error", "indexattempts" => [Dict("juliaversion" => string(VERSION), "stdout" => res.stdout, "stderr" => res.stderr)]))
226226
end
227227

228228
# @info "Files to be compressed" path readdir(path, join=true) ispath(cache_path) isfile(cache_path_compressed)
@@ -237,8 +237,8 @@ asyncmap(unindexed_packageversions, ntasks=max_tasks) do v
237237
end
238238
end
239239

240-
next!(p, showvalues = [
241-
(:finished_package_count,p.counter+1),
240+
next!(p, showvalues=[
241+
(:finished_package_count, p.counter + 1),
242242
(:count_successfully_cached, count_successfully_cached),
243243
(:count_failed_to_install, count_failed_to_install),
244244
(:count_failed_to_load, count_failed_to_load),

src/SymbolServer.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ mutable struct SymbolServerInstance
1919
store_path::String
2020
symbolcache_upstream::String
2121

22-
function SymbolServerInstance(depot_path::String="", store_path::Union{String,Nothing}=nothing; symbolcache_upstream = nothing)
22+
function SymbolServerInstance(depot_path::String="", store_path::Union{String,Nothing}=nothing; symbolcache_upstream=nothing)
2323
if symbolcache_upstream === nothing
2424
symbolcache_upstream = "https://www.julia-vscode.org/symbolcache"
2525
end
2626
return new(nothing, depot_path, Set{Process}(), store_path === nothing ? abspath(joinpath(@__DIR__, "..", "store")) : store_path, symbolcache_upstream)
2727
end
2828
end
2929

30-
function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, progress_callback=nothing, error_handler=nothing; download = false)
30+
function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, progress_callback=nothing, error_handler=nothing; download=false)
3131
!ispath(environment_path) && return :success, recursive_copy(stdlibs)
3232

3333
# see if we can download any package cache's before
@@ -42,9 +42,9 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p
4242
if manifest !== nothing
4343
@debug "Downloading cache files for manifest at $(manifest_filename)."
4444
to_download = collect(validate_disc_store(ssi.store_path, manifest))
45-
batches = Iterators.partition(to_download, max(1, floor(Int, length(to_download)÷50)))
45+
batches = Iterators.partition(to_download, max(1, floor(Int, length(to_download) ÷ 50)))
4646
for (i, batch) in enumerate(batches)
47-
percentage = round(Int, 100*(i - 1)/length(batches))
47+
percentage = round(Int, 100 * (i - 1) / length(batches))
4848
progress_callback !== nothing && progress_callback("Downloading caches...", percentage)
4949
@sync for pkg in batch
5050
@async begin
@@ -131,7 +131,7 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p
131131
end
132132
end
133133
take!(server_is_ready)
134-
p = open(pipeline(Cmd(`$jl_cmd --code-coverage=$(use_code_coverage==0 ? "none" : "user") --startup-file=no --compiled-modules=no --history-file=no --project=$environment_path $server_script $(ssi.store_path) $pipename`, env=env_to_use), stderr=stderr_for_client_process), read=true, write=true)
134+
p = open(pipeline(Cmd(`$jl_cmd --code-coverage=$(use_code_coverage==0 ? "none" : "user") --startup-file=no --compiled-modules=no --history-file=no --project=$environment_path $server_script $(ssi.store_path) $pipename`, env=env_to_use), stderr=stderr_for_client_process), read=true, write=true)
135135
ssi.process = p
136136

137137
yield()
@@ -150,7 +150,7 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p
150150
else
151151
@debug "SymbolStore: store failure"
152152
if currently_loading_a_package
153-
return :package_load_crash, (package_name = current_package_name, stderr = stderr_for_client_process)
153+
return :package_load_crash, (package_name=current_package_name, stderr=stderr_for_client_process)
154154
else
155155
return :failure, stderr_for_client_process
156156
end
@@ -171,15 +171,16 @@ function pipe_name()
171171
# Try to use /tmp and if that fails, hope the long pipe name works anyway
172172
maybe = "/tmp/" * prefix * uuid
173173
try
174-
touch(maybe); rm(maybe) # Check permissions on this path
174+
touch(maybe)
175+
rm(maybe) # Check permissions on this path
175176
pipename = maybe
176177
catch
177178
end
178179
end
179180
return pipename
180181
end
181182

182-
function load_project_packages_into_store!(ssi::SymbolServerInstance, environment_path, store, progress_callback = nothing)
183+
function load_project_packages_into_store!(ssi::SymbolServerInstance, environment_path, store, progress_callback=nothing)
183184
project_filename = isfile(joinpath(environment_path, "JuliaProject.toml")) ? joinpath(environment_path, "JuliaProject.toml") : joinpath(environment_path, "Project.toml")
184185
project = try
185186
Pkg.API.read_project(project_filename)
@@ -203,7 +204,7 @@ end
203204
204205
Tries to load the on-disc stored cache for a package (uuid). Attempts to generate (and save to disc) a new cache if the file does not exist or is unopenable.
205206
"""
206-
function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UUID, environment_path, manifest, store, progress_callback = nothing, percentage = missing)
207+
function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UUID, environment_path, manifest, store, progress_callback=nothing, percentage=missing)
207208
yield()
208209
isinmanifest(manifest, uuid) || return
209210
pe = frommanifest(manifest, uuid)
@@ -252,7 +253,7 @@ end
252253
function clear_disc_store(ssi::SymbolServerInstance)
253254
for f in readdir(ssi.store_path)
254255
if occursin(f, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
255-
rm(joinpath(ssi.store_path, f), recursive = true)
256+
rm(joinpath(ssi.store_path, f), recursive=true)
256257
end
257258
end
258259
end

src/faketypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function Base.print(io::IO, tn::FakeTypeName)
8888
end
8989
Base.print(io::IO, x::FakeUnionAll) = print(io, x.body, " where ", x.var)
9090
function Base.print(io::IO, x::FakeUnion; inunion=false)
91-
!inunion && print(io, "Union{")
91+
!inunion && print(io, "Union{")
9292
print(io, x.a, ",")
9393
if x.b isa FakeUnion
9494
print(io, x.b, inunion=true)

src/indexpackage.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ current_package_treehash = ARGS[4]
1313
# This path will always be mounted in the docker container in which we are running
1414
store_path = "/symcache"
1515

16-
current_package_versionwithoutplus = replace(string(current_package_version), '+'=>'_')
16+
current_package_versionwithoutplus = replace(string(current_package_version), '+' => '_')
1717
filename_with_extension = "v$(current_package_versionwithoutplus)_$current_package_treehash.jstore"
1818

1919
module LoadingBay end
@@ -45,7 +45,7 @@ end
4545
env = getenvtree([current_package_name])
4646
symbols(env, m, get_return_type=true)
4747

48-
# Strip out paths
48+
# Strip out paths
4949
modify_dirs(env[current_package_name], f -> modify_dir(f, pkg_src_dir(Base.loaded_modules[Base.PkgId(current_package_uuid, string(current_package_name))]), "PLACEHOLDER"))
5050

5151
# There's an issue here - @enum used within CSTParser seems to add a method that is introduced from Enums.jl...

src/serialize.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function write_vector(io, x)
169169
end
170170
end
171171

172-
function read(io, t = Base.read(io, UInt8))
172+
function read(io, t=Base.read(io, UInt8))
173173
# There are a bunch of `yield`s in potentially expensive code paths.
174174
# One top-level `yield` would probably increase responsiveness in the
175175
# LS, but increases runtime by 3x. This seems like a good compromise.
@@ -221,7 +221,7 @@ function read(io, t = Base.read(io, UInt8))
221221
file = read(io)
222222
line = Base.read(io, UInt32)
223223
nsig = Base.read(io, Int)
224-
sig = Vector{Pair{Any, Any}}(undef, nsig)
224+
sig = Vector{Pair{Any,Any}}(undef, nsig)
225225
for i in 1:nsig
226226
sig[i] = read(io) => read(io)
227227
end
@@ -259,7 +259,7 @@ function read(io, t = Base.read(io, UInt8))
259259
false
260260
elseif t === TupleHeader
261261
N = Base.read(io, Int)
262-
ntuple(i->read(io), N)
262+
ntuple(i -> read(io), N)
263263
elseif t === PackageHeader
264264
yield()
265265
name = read(io)

src/server.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ visited = Base.IdSet{Module}([Base, Core])
9292

9393
# Load all packages together
9494
for (i, uuid) in enumerate(packages_to_load)
95-
load_package(ctx, uuid, conn, LoadingBay, round(Int, 100*(i - 1)/length(packages_to_load)))
95+
load_package(ctx, uuid, conn, LoadingBay, round(Int, 100 * (i - 1) / length(packages_to_load)))
9696

9797
# XXX: The following *may* duplicate some work, but we want to make sure that interrupts of
9898
# the SymbolServer process don't invalidate *all* work done (which would happen when only
@@ -103,12 +103,12 @@ for (i, uuid) in enumerate(packages_to_load)
103103

104104
# Populate the above with symbols, skipping modules that don't need caching.
105105
# symbols (env_symbols)
106-
# don't need to cache these each time...
106+
# don't need to cache these each time...
107107
for (pid, m) in Base.loaded_modules
108108
if pid.uuid !== nothing &&
109-
is_stdlib(pid.uuid) &&
110-
isinmanifest(ctx, pid.uuid) &&
111-
isfile(joinpath(server.storedir, SymbolServer.get_cache_path(manifest(ctx), pid.uuid)...))
109+
is_stdlib(pid.uuid) &&
110+
isinmanifest(ctx, pid.uuid) &&
111+
isfile(joinpath(server.storedir, SymbolServer.get_cache_path(manifest(ctx), pid.uuid)...))
112112
push!(visited, m)
113113
delete!(env_symbols, Symbol(pid.name))
114114
end

0 commit comments

Comments
 (0)