Skip to content

Commit 660a78c

Browse files
davidanthoffgithub-actions[bot]
authored andcommitted
Format files using DocumentFormat
1 parent c071b37 commit 660a78c

File tree

10 files changed

+139
-123
lines changed

10 files changed

+139
-123
lines changed

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: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mutable struct SymbolServerInstance
2525
store_path::String
2626
symbolcache_upstream::String
2727

28-
function SymbolServerInstance(depot_path::String="", store_path::Union{String,Nothing}=nothing, julia_exe::Union{NamedTuple{(:path,:version),Tuple{String,VersionNumber}},Nothing}=nothing; symbolcache_upstream = nothing)
28+
function SymbolServerInstance(depot_path::String="", store_path::Union{String,Nothing}=nothing, julia_exe::Union{NamedTuple{(:path, :version),Tuple{String,VersionNumber}},Nothing}=nothing; symbolcache_upstream=nothing)
2929
if symbolcache_upstream === nothing
3030
symbolcache_upstream = "https://www.julia-vscode.org/symbolcache"
3131
end
@@ -43,15 +43,15 @@ function get_general_pkgs()
4343
@static if VERSION >= v"1.7-"
4444
regs = Pkg.Types.Context().registries
4545
i = findfirst(r -> r.name == "General" && r.uuid == GENERAL_REGISTRY_UUID, regs)
46-
i === nothing && return Dict{UUID, PkgEntry}()
46+
i === nothing && return Dict{UUID,PkgEntry}()
4747
return regs[i].pkgs
4848
else
4949
for r in Pkg.Types.collect_registries()
5050
(r.name == "General" && r.uuid == GENERAL_REGISTRY_UUID) || continue
5151
reg = Pkg.Types.read_registry(joinpath(r.path, "Registry.toml"))
5252
return reg["packages"]
5353
end
54-
return Dict{UUID, PkgEntry}()
54+
return Dict{UUID,PkgEntry}()
5555
end
5656
finally
5757
append!(empty!(Base.DEPOT_PATH), dp_before)
@@ -134,23 +134,23 @@ function download_cache_files(ssi, environment_path, progress_callback)
134134
get_file_from_cloud(manifest, uuid, environment_path, ssi.depot_path, ssi.store_path, download_dir, ssi.symbolcache_upstream)
135135
yield()
136136
n_done += 1
137-
percentage = round(Int, 100*(n_done/n_total))
137+
percentage = round(Int, 100 * (n_done / n_total))
138138
if percentage < 100
139139
progress_callback("Downloading cache files...", percentage)
140140
end
141141
end
142142
end
143143
end
144-
took = round(time() - t0, sigdigits = 2)
144+
took = round(time() - t0, sigdigits=2)
145145
progress_callback("All cache files downloaded (took $(took)s).", 100)
146146
end
147147
end
148148
end
149149

150-
function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, progress_callback=nothing, error_handler=nothing; download = false)
150+
function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, progress_callback=nothing, error_handler=nothing; download=false)
151151
!ispath(environment_path) && return :success, recursive_copy(stdlibs)
152152
_progress_callback = (msg, p) -> progress_callback === nothing ?
153-
println(lpad(p, 4), "% - ", msg) : progress_callback(msg, p)
153+
println(lpad(p, 4), "% - ", msg) : progress_callback(msg, p)
154154

155155
# see if we can download any package caches before local indexing
156156
if download
@@ -231,9 +231,9 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p
231231
# as of 2023-11-09, loading Pkg with --compiled-modules=no also changes something with the
232232
# active project, which breaks the server.jl script
233233
p = if ssi.julia_exe_version > v"1.11-"
234-
open(pipeline(Cmd(`$(ssi.julia_exe_path) --code-coverage=$(use_code_coverage==0 ? "none" : "user") --startup-file=no --compiled-modules=existing --history-file=no --project=$environment_path $server_script $(ssi.store_path) $pipename`, env=env_to_use), stderr=stderr), read=true, write=true)
234+
open(pipeline(Cmd(`$(ssi.julia_exe_path) --code-coverage=$(use_code_coverage==0 ? "none" : "user") --startup-file=no --compiled-modules=existing --history-file=no --project=$environment_path $server_script $(ssi.store_path) $pipename`, env=env_to_use), stderr=stderr), read=true, write=true)
235235
else
236-
open(pipeline(Cmd(`$(ssi.julia_exe_path) --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), read=true, write=true)
236+
open(pipeline(Cmd(`$(ssi.julia_exe_path) --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), read=true, write=true)
237237
end
238238
ssi.process = p
239239

@@ -253,7 +253,7 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p
253253
else
254254
@debug "SymbolStore: store failure"
255255
if currently_loading_a_package
256-
return :package_load_crash, (package_name = current_package_name, stderr = stderr_for_client_process)
256+
return :package_load_crash, (package_name=current_package_name, stderr=stderr_for_client_process)
257257
else
258258
return :failure, stderr_for_client_process
259259
end
@@ -274,15 +274,16 @@ function pipe_name()
274274
# Try to use /tmp and if that fails, hope the long pipe name works anyway
275275
maybe = "/tmp/" * prefix * uuid
276276
try
277-
touch(maybe); rm(maybe) # Check permissions on this path
277+
touch(maybe)
278+
rm(maybe) # Check permissions on this path
278279
pipename = maybe
279280
catch
280281
end
281282
end
282283
return pipename
283284
end
284285

285-
function load_project_packages_into_store!(ssi::SymbolServerInstance, environment_path, store, progress_callback = nothing)
286+
function load_project_packages_into_store!(ssi::SymbolServerInstance, environment_path, store, progress_callback=nothing)
286287
project_filename = isfile(joinpath(environment_path, "JuliaProject.toml")) ? joinpath(environment_path, "JuliaProject.toml") : joinpath(environment_path, "Project.toml")
287288
project = try
288289
Pkg.API.read_project(project_filename)
@@ -300,7 +301,7 @@ function load_project_packages_into_store!(ssi::SymbolServerInstance, environmen
300301
for (i, uuid) in enumerate(uuids)
301302
load_package_from_cache_into_store!(ssi, uuid isa UUID ? uuid : UUID(uuid), environment_path, manifest, store, progress_callback, round(Int, 100 * (i - 1) / num_uuids))
302303
end
303-
took = round(time() - t0, sigdigits = 2)
304+
took = round(time() - t0, sigdigits=2)
304305
progress_callback("Loaded all packages into cache in $(took)s", 100)
305306
end
306307

@@ -309,7 +310,7 @@ end
309310
310311
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.
311312
"""
312-
function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UUID, environment_path, manifest, store, progress_callback = nothing, percentage = missing)
313+
function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UUID, environment_path, manifest, store, progress_callback=nothing, percentage=missing)
313314
yield()
314315
isinmanifest(manifest, uuid) || return
315316
pe = frommanifest(manifest, uuid)
@@ -336,7 +337,7 @@ function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UU
336337
end
337338

338339
store[Symbol(pe_name)] = package_data.val
339-
took = round(time() - t0, sigdigits = 2)
340+
took = round(time() - t0, sigdigits=2)
340341
msg = "Done loading $pe_name from cache..."
341342
if took > 0.01
342343
msg *= " (took $(took)s)"
@@ -366,7 +367,7 @@ end
366367
function clear_disc_store(ssi::SymbolServerInstance)
367368
for f in readdir(ssi.store_path)
368369
if occursin(f, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
369-
rm(joinpath(ssi.store_path, f), recursive = true)
370+
rm(joinpath(ssi.store_path, f), recursive=true)
370371
end
371372
end
372373
end

src/faketypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function Base.print(io::IO, tn::FakeTypeName)
9090
end
9191
Base.print(io::IO, x::FakeUnionAll) = print(io, x.body, " where ", x.var)
9292
function Base.print(io::IO, x::FakeUnion; inunion=false)
93-
!inunion && print(io, "Union{")
93+
!inunion && print(io, "Union{")
9494
print(io, x.a, ",")
9595
if x.b isa FakeUnion
9696
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)

0 commit comments

Comments
 (0)