diff --git a/registryindexer/main.jl b/registryindexer/main.jl index 6b754c91..957e6c64 100644 --- a/registryindexer/main.jl +++ b/registryindexer/main.jl @@ -2,7 +2,7 @@ max_n = 1_000_000 max_versions = 1_000_000 -max_tasks = length(ARGS)>1 ? parse(Int, ARGS[2]) : 1 +max_tasks = length(ARGS) > 1 ? parse(Int, ARGS[2]) : 1 julia_versions = [v"1.10.4"] @@ -13,26 +13,26 @@ Pkg.instantiate() using ProgressMeter, Query, JSON, UUIDs, Tar, CodecZlib -function get_all_package_versions(;max_versions=typemax(Int)) +function get_all_package_versions(; max_versions=typemax(Int)) registry_folder_path = joinpath(homedir(), ".julia", "registries", "General") registry_path = joinpath(registry_folder_path, "Registry.toml") registry_content = Pkg.TOML.parsefile(registry_path) packages = registry_content["packages"] |> - @map({ - name = _[2]["name"], - uuid = UUID(_[1]), - path = _[2]["path"] - }) |> - @mutate( - versions = (Pkg.TOML.parsefile(joinpath(registry_folder_path, _.path, "Versions.toml")) |> - @map(i->{version=VersionNumber(i[1]), treehash=i[2]["git-tree-sha1"]}) |> - @orderby_descending(i->i.version) |> - @take(max_versions) |> - collect) - ) |> - collect + @map({ + name = _[2]["name"], + uuid = UUID(_[1]), + path = _[2]["path"] + }) |> + @mutate( + versions = (Pkg.TOML.parsefile(joinpath(registry_folder_path, _.path, "Versions.toml")) |> + @map(i -> {version = VersionNumber(i[1]), treehash = i[2]["git-tree-sha1"]}) |> + @orderby_descending(i -> i.version) |> + @take(max_versions) |> + collect) + ) |> + collect return packages end @@ -42,7 +42,7 @@ function get_flattened_package_versions(packages) for p in packages for v in p.versions - push!(flattened_packageversions, (;p.name, p.uuid, p.path, version=v.version, treehash=v.treehash)) + push!(flattened_packageversions, (; p.name, p.uuid, p.path, version=v.version, treehash=v.treehash)) end end @@ -54,11 +54,11 @@ function execute(cmd::Base.Cmd) err = IOBuffer() process = run(pipeline(ignorestatus(cmd), stdout=out, stderr=err)) - out_string =String(take!(out)) + out_string = String(take!(out)) err_string = String(take!(err)) - return (stdout = out_string, - stderr = err_string, - code = process.exitcode) + return (stdout=out_string, + stderr=err_string, + code=process.exitcode) end @info "Indexing started..." @@ -69,7 +69,7 @@ flattened_packageversions = get_flattened_package_versions(all_packages) @info "Loaded package versions from registry..." -cache_folder = length(ARGS)>0 ? ARGS[1] : joinpath(@__DIR__, "..", "registryindexcache") +cache_folder = length(ARGS) > 0 ? ARGS[1] : joinpath(@__DIR__, "..", "registryindexcache") @info "Using the following folder as the cache folder: " cache_folder @@ -92,7 +92,7 @@ asyncmap(julia_versions) do v print(f, res.stderr) end - if res.code!=0 + if res.code != 0 error("Could not create docker image.") end end @@ -108,10 +108,10 @@ true || asyncmap(julia_versions) do v else res = execute(`docker run --rm --mount type=bind,source="$cache_folder",target=/symcache juliavscodesymbolindexer:$v julia SymbolServer/src/indexbasestdlib.jl $v`) - if res.code==10 || res.code==20 - if res.code==10 + if res.code == 10 || res.code == 20 + if res.code == 10 # global count_failed_to_load += 1 - elseif res.code==20 + elseif res.code == 20 # global count_failed_to_install += 1 end @@ -121,7 +121,7 @@ true || asyncmap(julia_versions) do v # # Write them to a file # open(joinpath(path, error_filename), "w") do io # end - + # Pkg.PlatformEngines.package(path, cache_path) # end @@ -136,7 +136,7 @@ true || asyncmap(julia_versions) do v # global status_db # 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)])) - elseif res.code==0 + elseif res.code == 0 # global count_successfully_cached += 1 else # global count_failed_to_index += 1 @@ -154,7 +154,7 @@ end @info "Now computing which of the total $(length(flattened_packageversions)) package versions that exist still need to be indexed..." unindexed_packageversions = filter(collect(Iterators.take(flattened_packageversions, max_n))) do v - versionwithoutplus = replace(string(v.version), '+'=>'_') + versionwithoutplus = replace(string(v.version), '+' => '_') cache_path = joinpath(cache_folder, "v1", "packages", string(uppercase(v.name[1])), "$(v.name)_$(v.uuid)", "v$(versionwithoutplus)_$(v.treehash).tar.gz") @@ -179,7 +179,7 @@ status_db = isfile(statusdb_filename) ? JSON.parsefile(statusdb_filename) : [] @info "Starting the actual indexing process..." asyncmap(unindexed_packageversions, ntasks=max_tasks) do v - versionwithoutplus = replace(string(v.version), '+'=>'_') + versionwithoutplus = replace(string(v.version), '+' => '_') cache_path = joinpath(cache_folder, "v1", "packages", string(uppercase(v.name[1])), "$(v.name)_$(v.uuid)") mkpath(cache_path) @@ -188,12 +188,12 @@ asyncmap(unindexed_packageversions, ntasks=max_tasks) do v mktempdir() do path 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)`) - if res.code==37 # This is our magic error code that indicates everything worked + if res.code == 37 # This is our magic error code that indicates everything worked global count_successfully_cached += 1 else - if res.code==10 + if res.code == 10 global count_failed_to_load += 1 - elseif res.code==20 + elseif res.code == 20 global count_failed_to_install += 1 else global count_failed_to_index += 1 @@ -209,20 +209,20 @@ asyncmap(unindexed_packageversions, ntasks=max_tasks) do v isfile(joinpath(path, error_filename)) && rm(joinpath(path, error_filename)) # Write them to a file - open(joinpath(path, error_filename), "w") do io + open(joinpath(path, error_filename), "w") do io end - open(joinpath(cache_folder, "logs", res.code==10 ? "packageloadfailure" : res.code==20 ? "packageinstallfailure" : "packageindexfailure", "log_$(v.name)_v$(versionwithoutplus)_stdout.txt"), "w") do f + open(joinpath(cache_folder, "logs", res.code == 10 ? "packageloadfailure" : res.code == 20 ? "packageinstallfailure" : "packageindexfailure", "log_$(v.name)_v$(versionwithoutplus)_stdout.txt"), "w") do f print(f, res.stdout) end - open(joinpath(cache_folder, "logs", res.code==10 ? "packageloadfailure" : res.code==20 ? "packageinstallfailure" : "packageindexfailure", "log_$(v.name)_v$(versionwithoutplus)_stderr.txt"), "w") do f + open(joinpath(cache_folder, "logs", res.code == 10 ? "packageloadfailure" : res.code == 20 ? "packageinstallfailure" : "packageindexfailure", "log_$(v.name)_v$(versionwithoutplus)_stderr.txt"), "w") do f print(f, res.stderr) end global status_db - 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)])) + 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)])) end # @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 end end - next!(p, showvalues = [ - (:finished_package_count,p.counter+1), + next!(p, showvalues=[ + (:finished_package_count, p.counter + 1), (:count_successfully_cached, count_successfully_cached), (:count_failed_to_install, count_failed_to_install), (:count_failed_to_load, count_failed_to_load), diff --git a/src/SymbolServer.jl b/src/SymbolServer.jl index 78bd0c5f..ffefdd2c 100644 --- a/src/SymbolServer.jl +++ b/src/SymbolServer.jl @@ -25,7 +25,7 @@ mutable struct SymbolServerInstance store_path::String symbolcache_upstream::String - 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) + 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) if symbolcache_upstream === nothing symbolcache_upstream = "https://www.julia-vscode.org/symbolcache" end @@ -134,23 +134,23 @@ function download_cache_files(ssi, environment_path, progress_callback) get_file_from_cloud(manifest, uuid, environment_path, ssi.depot_path, ssi.store_path, download_dir, ssi.symbolcache_upstream) yield() n_done += 1 - percentage = round(Int, 100*(n_done/n_total)) + percentage = round(Int, 100 * (n_done / n_total)) if percentage < 100 progress_callback("Downloading cache files...", percentage) end end end end - took = round(time() - t0, sigdigits = 2) + took = round(time() - t0, sigdigits=2) progress_callback("All cache files downloaded (took $(took)s).", 100) end end end -function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, progress_callback=nothing, error_handler=nothing; download = false) +function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, progress_callback=nothing, error_handler=nothing; download=false) !ispath(environment_path) && return :success, recursive_copy(stdlibs) _progress_callback = (msg, p) -> progress_callback === nothing ? - println(lpad(p, 4), "% - ", msg) : progress_callback(msg, p) + println(lpad(p, 4), "% - ", msg) : progress_callback(msg, p) # see if we can download any package caches before local indexing if download @@ -241,9 +241,9 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p end cmd = Cmd(path) if ssi.julia_exe_version > v"1.11-" - open(pipeline(Cmd(`$(cmd) --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) + open(pipeline(Cmd(`$(cmd) --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) else - open(pipeline(Cmd(`$(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), read=true, write=true) + open(pipeline(Cmd(`$(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), read=true, write=true) end catch err if stderr_for_client_process !== nothing @@ -270,7 +270,7 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p else @debug "SymbolStore: store failure" if currently_loading_a_package - return :package_load_crash, (package_name = current_package_name, stderr = stderr_for_client_process) + return :package_load_crash, (package_name=current_package_name, stderr=stderr_for_client_process) else return :failure, stderr_for_client_process end @@ -291,7 +291,8 @@ function pipe_name() # Try to use /tmp and if that fails, hope the long pipe name works anyway maybe = "/tmp/" * prefix * uuid try - touch(maybe); rm(maybe) # Check permissions on this path + touch(maybe) + rm(maybe) # Check permissions on this path pipename = maybe catch end @@ -299,7 +300,7 @@ function pipe_name() return pipename end -function load_project_packages_into_store!(ssi::SymbolServerInstance, environment_path, store, progress_callback = nothing) +function load_project_packages_into_store!(ssi::SymbolServerInstance, environment_path, store, progress_callback=nothing) project_filename = isfile(joinpath(environment_path, "JuliaProject.toml")) ? joinpath(environment_path, "JuliaProject.toml") : joinpath(environment_path, "Project.toml") project = try Pkg.API.read_project(project_filename) @@ -317,7 +318,7 @@ function load_project_packages_into_store!(ssi::SymbolServerInstance, environmen for (i, uuid) in enumerate(uuids) 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)) end - took = round(time() - t0, sigdigits = 2) + took = round(time() - t0, sigdigits=2) progress_callback("Loaded all packages into cache in $(took)s", 100) end @@ -326,7 +327,7 @@ end 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. """ -function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UUID, environment_path, manifest, store, progress_callback = nothing, percentage = missing) +function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UUID, environment_path, manifest, store, progress_callback=nothing, percentage=missing) yield() isinmanifest(manifest, uuid) || return pe = frommanifest(manifest, uuid) @@ -353,7 +354,7 @@ function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UU end store[Symbol(pe_name)] = package_data.val - took = round(time() - t0, sigdigits = 2) + took = round(time() - t0, sigdigits=2) msg = "Done loading $pe_name from cache..." if took > 0.01 msg *= " (took $(took)s)" @@ -383,7 +384,7 @@ end function clear_disc_store(ssi::SymbolServerInstance) for f in readdir(ssi.store_path) if occursin(f, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") - rm(joinpath(ssi.store_path, f), recursive = true) + rm(joinpath(ssi.store_path, f), recursive=true) end end end diff --git a/src/faketypes.jl b/src/faketypes.jl index b7174bd3..9837e1f2 100644 --- a/src/faketypes.jl +++ b/src/faketypes.jl @@ -90,7 +90,7 @@ function Base.print(io::IO, tn::FakeTypeName) end Base.print(io::IO, x::FakeUnionAll) = print(io, x.body, " where ", x.var) function Base.print(io::IO, x::FakeUnion; inunion=false) - !inunion && print(io, "Union{") + !inunion && print(io, "Union{") print(io, x.a, ",") if x.b isa FakeUnion print(io, x.b, inunion=true) diff --git a/src/indexpackage.jl b/src/indexpackage.jl index 421a0bf4..2fc690db 100644 --- a/src/indexpackage.jl +++ b/src/indexpackage.jl @@ -13,7 +13,7 @@ current_package_treehash = ARGS[4] # This path will always be mounted in the docker container in which we are running store_path = "/symcache" -current_package_versionwithoutplus = replace(string(current_package_version), '+'=>'_') +current_package_versionwithoutplus = replace(string(current_package_version), '+' => '_') filename_with_extension = "v$(current_package_versionwithoutplus)_$current_package_treehash.jstore" module LoadingBay end @@ -45,7 +45,7 @@ end env = getenvtree([current_package_name]) symbols(env, m, get_return_type=true) - # Strip out paths +# Strip out paths 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")) # There's an issue here - @enum used within CSTParser seems to add a method that is introduced from Enums.jl... diff --git a/src/serialize.jl b/src/serialize.jl index 5568a9fb..fd918237 100644 --- a/src/serialize.jl +++ b/src/serialize.jl @@ -169,7 +169,7 @@ function write_vector(io, x) end end -function read(io, t = Base.read(io, UInt8)) +function read(io, t=Base.read(io, UInt8)) # There are a bunch of `yield`s in potentially expensive code paths. # One top-level `yield` would probably increase responsiveness in the # LS, but increases runtime by 3x. This seems like a good compromise. @@ -221,7 +221,7 @@ function read(io, t = Base.read(io, UInt8)) file = read(io) line = Base.read(io, UInt32) nsig = Base.read(io, Int) - sig = Vector{Pair{Any, Any}}(undef, nsig) + sig = Vector{Pair{Any,Any}}(undef, nsig) for i in 1:nsig sig[i] = read(io) => read(io) end @@ -259,7 +259,7 @@ function read(io, t = Base.read(io, UInt8)) false elseif t === TupleHeader N = Base.read(io, Int) - ntuple(i->read(io), N) + ntuple(i -> read(io), N) elseif t === PackageHeader yield() name = read(io) diff --git a/src/server.jl b/src/server.jl index d892b1f2..3a62a488 100644 --- a/src/server.jl +++ b/src/server.jl @@ -97,7 +97,7 @@ end # Load all packages together # This is important, or methods added to functions in other packages that are loaded earlier would not be in the cache for (i, uuid) in enumerate(packages_to_load) - load_package(ctx, uuid, conn, LoadingBay, round(Int, 100*(i - 1)/length(packages_to_load))) + load_package(ctx, uuid, conn, LoadingBay, round(Int, 100 * (i - 1) / length(packages_to_load))) end # Create image of whole package env. This creates the module structure only. @@ -109,8 +109,8 @@ visited = Base.IdSet{Module}([Base, Core]) for (pid, m) in Base.loaded_modules if pid.uuid !== nothing && is_stdlib(pid.uuid) && - isinmanifest(ctx, pid.uuid) && - isfile(joinpath(server.storedir, SymbolServer.get_cache_path(manifest(ctx), pid.uuid)...)) + isinmanifest(ctx, pid.uuid) && + isfile(joinpath(server.storedir, SymbolServer.get_cache_path(manifest(ctx), pid.uuid)...)) push!(visited, m) delete!(env_symbols, Symbol(pid.name)) end diff --git a/src/symbols.jl b/src/symbols.jl index da2612db..50bbef85 100644 --- a/src/symbols.jl +++ b/src/symbols.jl @@ -118,7 +118,12 @@ function maybe_fix_path(file) return maybe_fixup_stdlib_path(file) end -safe_isfile(x) = try isfile(x); catch; false end +safe_isfile(x) = + try + isfile(x) + catch + false + end const BUILDBOT_STDLIB_PATH = dirname(abspath(joinpath(String((@which versioninfo()).file), "..", "..", ".."))) replace_buildbot_stdlibpath(str::String) = replace(str, BUILDBOT_STDLIB_PATH => Sys.STDLIB) """ @@ -147,7 +152,7 @@ _default_world_age() = end const _global_method_cache = IdDict{Any,Vector{Any}}() -function methodinfo(@nospecialize(f); types = Tuple, world = _default_world_age()) +function methodinfo(@nospecialize(f); types=Tuple, world=_default_world_age()) key = (f, types, world) if haskey(_global_method_cache, key) return _global_method_cache[key] @@ -182,9 +187,9 @@ function cache_methods(@nospecialize(f), name, env, get_return_type) world = _default_world_age() ms = Tuple{Module,MethodStore}[] methods0 = try - methodinfo(f; types = types, world = world) + methodinfo(f; types=types, world=world) catch err - @debug "Error in method lookup for $f" ex=(err, catch_backtrace()) + @debug "Error in method lookup for $f" ex = (err, catch_backtrace()) return ms end ind_of_method_w_kws = Int[] # stores the index of methods with kws. @@ -270,10 +275,10 @@ else end end -function apply_to_everything(f, m = nothing, visited = Base.IdSet{Module}()) +function apply_to_everything(f, m=nothing, visited=Base.IdSet{Module}()) if m isa Module push!(visited, m) - for s in unsorted_names(m, all = true, imported = true) + for s in unsorted_names(m, all=true, imported=true) (!isdefined(m, s) || s == nameof(m)) && continue x = getfield(m, s) f(x) @@ -290,11 +295,11 @@ end -function oneverything(f, m = nothing, visited = Base.IdSet{Module}()) +function oneverything(f, m=nothing, visited=Base.IdSet{Module}()) if m isa Module push!(visited, m) state = nothing - for s in unsorted_names(m, all = true, imported = true) + for s in unsorted_names(m, all=true, imported=true) !isdefined(m, s) && continue x = getfield(m, s) state = f(m, s, x, state) @@ -310,7 +315,7 @@ function oneverything(f, m = nothing, visited = Base.IdSet{Module}()) end const _global_symbol_cache_by_mod = IdDict{Module,Base.IdSet{Symbol}}() -function build_namecache(m, s, @nospecialize(x), state::Union{Base.IdSet{Symbol},Nothing} = nothing) +function build_namecache(m, s, @nospecialize(x), state::Union{Base.IdSet{Symbol},Nothing}=nothing) if state === nothing state = get(_global_symbol_cache_by_mod, m, nothing) if state === nothing @@ -360,10 +365,10 @@ end usedby(outer, inner) = outer !== inner && isdefined(outer, nameof(inner)) && getproperty(outer, nameof(inner)) === inner && all(isdefined(outer, name) || !isdefined(inner, name) for name in unsorted_names(inner)) istoplevelmodule(m) = parentmodule(m) === m || parentmodule(m) === Main -function getmoduletree(m::Module, amn, visited = Base.IdSet{Module}()) +function getmoduletree(m::Module, amn, visited=Base.IdSet{Module}()) push!(visited, m) cache = ModuleStore(m) - for s in unsorted_names(m, all = true, imported = true) + for s in unsorted_names(m, all=true, imported=true) !isdefined(m, s) && continue x = getfield(m, s) if x isa Module @@ -392,16 +397,16 @@ function getmoduletree(m::Module, amn, visited = Base.IdSet{Module}()) cache end -function getenvtree(names = nothing) +function getenvtree(names=nothing) amn = allmodulenames() EnvStore(nameof(m) => getmoduletree(m, amn) for m in Base.loaded_modules_array() if names === nothing || nameof(m) in names) end # faster and more correct split_module_names all_names(m) = all_names(m, x -> isdefined(m, x)) -function all_names(m, pred, symbols = Set(Symbol[]), seen = Set(Module[])) +function all_names(m, pred, symbols=Set(Symbol[]), seen=Set(Module[])) push!(seen, m) - ns = unsorted_names(m; all = true, imported = false) + ns = unsorted_names(m; all=true, imported=false) for n in ns isdefined(m, n) || continue Base.isdeprecated(m, n) && continue @@ -416,7 +421,7 @@ function all_names(m, pred, symbols = Set(Symbol[]), seen = Set(Module[])) symbols end -function symbols(env::EnvStore, m::Union{Module,Nothing} = nothing, allnames::Base.IdSet{Symbol} = getallns(), visited = Base.IdSet{Module}(); get_return_type = false) +function symbols(env::EnvStore, m::Union{Module,Nothing}=nothing, allnames::Base.IdSet{Symbol}=getallns(), visited=Base.IdSet{Module}(); get_return_type=false) if m isa Module cache = _lookup(VarRef(m), env, true) cache === nothing && return @@ -466,7 +471,7 @@ function symbols(env::EnvStore, m::Union{Module,Nothing} = nothing, allnames::Ba if x === m cache[s] = VarRef(x) elseif parentmodule(x) === m - symbols(env, x, allnames, visited, get_return_type = get_return_type) + symbols(env, x, allnames, visited, get_return_type=get_return_type) else cache[s] = VarRef(x) end @@ -476,16 +481,16 @@ function symbols(env::EnvStore, m::Union{Module,Nothing} = nothing, allnames::Ba end else for m in Base.loaded_modules_array() - in(m, visited) || symbols(env, m, allnames, visited, get_return_type = get_return_type) + in(m, visited) || symbols(env, m, allnames, visited, get_return_type=get_return_type) end end end -function load_core(; get_return_type = false) +function load_core(; get_return_type=false) c = Pkg.Types.Context() - cache = getenvtree([:Core,:Base]) - symbols(cache, get_return_type = get_return_type) + cache = getenvtree([:Core, :Base]) + symbols(cache, get_return_type=get_return_type) cache[:Main] = ModuleStore(VarRef(nothing, :Main), Dict(), "", true, [], []) # This is wrong. Every module contains it's own include function. @@ -501,7 +506,7 @@ function load_core(; get_return_type = false) m1.file, m1.line, Pair{Any,Any}[ - :x => SymbolServer.FakeTypeName(SymbolServer.VarRef(SymbolServer.VarRef(nothing, :Core), :AbstractString), Any[]) + :x=>SymbolServer.FakeTypeName(SymbolServer.VarRef(SymbolServer.VarRef(nothing, :Core), :AbstractString), Any[]) ], [], m1.rt @@ -512,7 +517,7 @@ function load_core(; get_return_type = false) cache[:Base][Symbol("@.")] = cache[:Base][Symbol("@__dot__")] cache[:Core][:Main] = GenericStore(VarRef(nothing, :Main), FakeTypeName(Module), _doc(Base.Docs.Binding(Main, :Main)), true) # Add built-ins - builtins = Symbol[nameof(getfield(Core, n).instance) for n in unsorted_names(Core, all = true) if isdefined(Core, n) && getfield(Core, n) isa DataType && isdefined(getfield(Core, n), :instance) && getfield(Core, n).instance isa Core.Builtin] + builtins = Symbol[nameof(getfield(Core, n).instance) for n in unsorted_names(Core, all=true) if isdefined(Core, n) && getfield(Core, n) isa DataType && isdefined(getfield(Core, n), :instance) && getfield(Core, n).instance isa Core.Builtin] cnames = unsorted_names(Core) for f in builtins if !haskey(cache[:Core], f) @@ -543,7 +548,7 @@ function load_core(; get_return_type = false) push!(cache[:Core][:fieldtype].methods, MethodStore(:fieldtype, :Core, "built-in", 0, [:t => FakeTypeName(DataType), :field => FakeTypeName(Symbol)], Symbol[], FakeTypeName(Type{T} where T))) push!(cache[:Core][:getfield].methods, MethodStore(:setfield, :Core, "built-in", 0, [:object => FakeTypeName(Any), :item => FakeTypeName(Any)], Symbol[], FakeTypeName(Any))) push!(cache[:Core][:ifelse].methods, MethodStore(:ifelse, :Core, "built-in", 0, [:condition => FakeTypeName(Bool), :x => FakeTypeName(Any), :y => FakeTypeName(Any)], Symbol[], FakeTypeName(Any))) - push!(cache[:Core][:invoke].methods, MethodStore(:invoke, :Core, "built-in", 0, [:f => FakeTypeName(Function), :x => FakeTypeName(Any), :argtypes => FakeTypeName(Type{T} where T) , :args => FakeTypeName(Vararg{Any})], Symbol[], FakeTypeName(Any))) + push!(cache[:Core][:invoke].methods, MethodStore(:invoke, :Core, "built-in", 0, [:f => FakeTypeName(Function), :x => FakeTypeName(Any), :argtypes => FakeTypeName(Type{T} where T), :args => FakeTypeName(Vararg{Any})], Symbol[], FakeTypeName(Any))) push!(cache[:Core][:isa].methods, MethodStore(:isa, :Core, "built-in", 0, [:a => FakeTypeName(Any), :T => FakeTypeName(Type{T} where T)], Symbol[], FakeTypeName(Bool))) push!(cache[:Core][:isdefined].methods, MethodStore(:getproperty, :Core, "built-in", 0, [:value => FakeTypeName(Any), :field => FakeTypeName(Any)], Symbol[], FakeTypeName(Any))) push!(cache[:Core][:nfields].methods, MethodStore(:nfields, :Core, "built-in", 0, [:x => FakeTypeName(Any)], Symbol[], FakeTypeName(Int))) @@ -607,7 +612,7 @@ function load_core(; get_return_type = false) end -function collect_extended_methods(depot::EnvStore, extendeds = Dict{VarRef,Vector{VarRef}}()) +function collect_extended_methods(depot::EnvStore, extendeds=Dict{VarRef,Vector{VarRef}}()) for m in depot collect_extended_methods(m[2], extendeds, m[2].name) end @@ -624,7 +629,11 @@ function collect_extended_methods(mod::ModuleStore, extendeds, mname) end end -getallns() = let allns = Base.IdSet{Symbol}(); oneverything((m, s, x, state) -> push!(allns, s)); allns end +getallns() = + let allns = Base.IdSet{Symbol}() + oneverything((m, s, x, state) -> push!(allns, s)) + allns + end """ split_module_names(m::Module, allns) @@ -655,5 +664,11 @@ function split_module_names(m::Module, allns) internal_names, availablenames end -get_all_modules() = let allms = Base.IdSet{Module}(); apply_to_everything(x -> if x isa Module push!(allms, x) end); allms end -get_used_modules(M, allms = get_all_modules()) = [m for m in allms if usedby(M, m)] +get_all_modules() = + let allms = Base.IdSet{Module}() + apply_to_everything(x -> if x isa Module + push!(allms, x) + end) + allms + end +get_used_modules(M, allms=get_all_modules()) = [m for m in allms if usedby(M, m)] diff --git a/src/utils.jl b/src/utils.jl index 6961da9f..233aae0a 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -40,7 +40,7 @@ function read_manifest(manifest_filename) return m.deps end catch err - @warn "Could not load manifest." exception=(err, catch_backtrace()) + @warn "Could not load manifest." exception = (err, catch_backtrace()) return nothing end end @@ -204,7 +204,7 @@ function _doc(binding::Base.Docs.Binding) result === nothing || return string(result) end results, groups = Base.Docs.DocStr[], Base.Docs.MultiDoc[] - # Lookup `binding` and `sig` for matches in all modules of the docsystem. + # Lookup `binding` and `sig` for matches in all modules of the docsystem. for mod in Base.Docs.modules dict = Base.Docs.meta(mod)::IdDict{Any,Any} if haskey(dict, binding) @@ -396,40 +396,40 @@ recursive_copy(ua::FakeUnionAll) = FakeUnionAll(recursive_copy(ua.var), recursiv end recursive_copy(m::ModuleStore) = ModuleStore(recursive_copy(m.name), recursive_copy(m.vals), m.doc, - m.exported, copy(m.exportednames), copy(m.used_modules)) + m.exported, copy(m.exportednames), copy(m.used_modules)) recursive_copy(p::Package) = Package(p.name, - recursive_copy(p.val), - p.uuid, - recursive_copy(p.sha)) + recursive_copy(p.val), + p.uuid, + recursive_copy(p.sha)) recursive_copy(ms::MethodStore) = MethodStore(ms.name, - ms.mod, - ms.file, - ms.line, - recursive_copy(ms.sig), - copy(ms.kws), - recursive_copy(ms.rt)) + ms.mod, + ms.file, + ms.line, + recursive_copy(ms.sig), + copy(ms.kws), + recursive_copy(ms.rt)) recursive_copy(dts::DataTypeStore) = DataTypeStore(recursive_copy(dts.name), - recursive_copy(dts.super), - recursive_copy(dts.parameters), - recursive_copy(dts.types), - recursive_copy(dts.fieldnames), - recursive_copy(dts.methods), - dts.doc, - dts.exported) + recursive_copy(dts.super), + recursive_copy(dts.parameters), + recursive_copy(dts.types), + recursive_copy(dts.fieldnames), + recursive_copy(dts.methods), + dts.doc, + dts.exported) recursive_copy(fs::FunctionStore) = FunctionStore(recursive_copy(fs.name), - recursive_copy(fs.methods), - fs.doc, - recursive_copy(fs.extends), - fs.exported) + recursive_copy(fs.methods), + fs.doc, + recursive_copy(fs.extends), + fs.exported) recursive_copy(gs::GenericStore) = GenericStore(recursive_copy(gs.name), - recursive_copy(gs.typ), - gs.doc, - gs.exported) + recursive_copy(gs.typ), + gs.doc, + gs.exported) # Tools for modifying source location @@ -620,7 +620,7 @@ function get_pkg_path(pkg::Base.PkgId, env, depot_path) return nothing end -function load_package(c::Pkg.Types.Context, uuid, conn, loadingbay, percentage = missing) +function load_package(c::Pkg.Types.Context, uuid, conn, loadingbay, percentage=missing) isinmanifest(c, uuid isa String ? Base.UUID(uuid) : uuid) || return pe_name = packagename(c, uuid) @@ -665,7 +665,7 @@ function get_cache_path(manifest, uuid) ver = VERSION end end - ver = replace(string(ver), '+'=>'_') + ver = replace(string(ver), '+' => '_') th = tree_hash(pkg_info) th = th === nothing ? "nothing" : th diff --git a/test/runtests.jl b/test/runtests.jl index 876f6869..49388673 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -110,7 +110,7 @@ end ssi = SymbolServerInstance("", store_path) @async begin - ret_status, store = getstore(ssi, path, download = false) + ret_status, store = getstore(ssi, path, download=false) @test ret_status == :canceled end @@ -120,7 +120,7 @@ end sleep(1) # this will cancel the previous getstore request - ret_status2, store2 = getstore(ssi, path, download = false) + ret_status2, store2 = getstore(ssi, path, download=false) if ret_status2 == :failure @info String(take!(store2)) diff --git a/test/testenv/dev/TableTraits/test/runtests.jl b/test/testenv/dev/TableTraits/test/runtests.jl index 62782681..8953085f 100644 --- a/test/testenv/dev/TableTraits/test/runtests.jl +++ b/test/testenv/dev/TableTraits/test/runtests.jl @@ -4,9 +4,9 @@ using Test @testset "TableTraits" begin - table_array = [(a = 1,), (a = 2,)] - any_table_array = Any[(a = 1,), (a = 2,)] - other_array = [1,2,3] + table_array = [(a=1,), (a=2,)] + any_table_array = Any[(a=1,), (a=2,)] + other_array = [1, 2, 3] without_eltype = (i for i in table_array) @test isiterabletable(table_array)