Skip to content

Commit

Permalink
Format files using DocumentFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Aug 22, 2020
1 parent 3c0ca06 commit 23418a6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 44 deletions.
16 changes: 8 additions & 8 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ using SymbolServer
using Documenter

makedocs(;
modules = [SymbolServer],
authors = "Julia VSCode",
repo = "https://github.com/julia-vscode/SymbolServer.jl/blob/{commit}{path}#L{line}",
sitename = "SymbolServer.jl",
format = Documenter.HTML(;
prettyurls = prettyurls = get(ENV, "CI", nothing) == "true",
modules=[SymbolServer],
authors="Julia VSCode",
repo="https://github.com/julia-vscode/SymbolServer.jl/blob/{commit}{path}#L{line}",
sitename="SymbolServer.jl",
format=Documenter.HTML(;
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true",
# canonical="https://www.julia-vscode.org/SymbolServer.jl",
# assets=String[],
),
pages = [
pages=[
"Home" => "index.md",
"Syntax Reference" => "syntax.md",
],
)

deploydocs(;
repo = "github.com/julia-vscode/SymbolServer.jl",
repo="github.com/julia-vscode/SymbolServer.jl",
)
6 changes: 3 additions & 3 deletions src/SymbolServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ mutable struct SymbolServerInstance
canceled_processes::Set{Process}
store_path::String

function SymbolServerInstance(depot_path::String = "", store_path::Union{String,Nothing} = nothing)
function SymbolServerInstance(depot_path::String="", store_path::Union{String,Nothing}=nothing)
return new(nothing, depot_path, Set{Process}(), store_path === nothing ? abspath(joinpath(@__DIR__, "..", "store")) : store_path)
end
end

function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, progress_callback = nothing, error_handler = nothing)
function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, progress_callback=nothing, error_handler=nothing)
!ispath(environment_path) && return :success, recursive_copy(stdlibs)

jl_cmd = joinpath(Sys.BINDIR, Base.julia_exename())
Expand Down Expand Up @@ -91,7 +91,7 @@ function getstore(ssi::SymbolServerInstance, environment_path::AbstractString, p

take!(server_is_ready)

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)
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)
ssi.process = p

if success(p)
Expand Down
14 changes: 7 additions & 7 deletions src/faketypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct FakeTypeName
parameters::Vector{Any}
end

function FakeTypeName(@nospecialize(x); justname = false)
function FakeTypeName(@nospecialize(x); justname=false)
if x isa DataType
xname = x.name
xnamename = xname.name
Expand Down Expand Up @@ -46,18 +46,18 @@ struct FakeUnion
a
b
end
FakeUnion(u::Union) = FakeUnion(FakeTypeName(u.a, justname = true), FakeTypeName(u.b, justname = true))
FakeUnion(u::Union) = FakeUnion(FakeTypeName(u.a, justname=true), FakeTypeName(u.b, justname=true))
struct FakeTypeVar
name::Symbol
lb
ub
end
FakeTypeVar(tv::TypeVar) = FakeTypeVar(tv.name, FakeTypeName(tv.lb, justname = true), FakeTypeName(tv.ub, justname = true))
FakeTypeVar(tv::TypeVar) = FakeTypeVar(tv.name, FakeTypeName(tv.lb, justname=true), FakeTypeName(tv.ub, justname=true))
struct FakeUnionAll
var::FakeTypeVar
body::Any
end
FakeUnionAll(ua::UnionAll) = FakeUnionAll(FakeTypeVar(ua.var), FakeTypeName(ua.body, justname = true))
FakeUnionAll(ua::UnionAll) = FakeUnionAll(FakeTypeVar(ua.var), FakeTypeName(ua.body, justname=true))

function _parameter(@nospecialize(p))
if p isa Union{Int,Symbol,Bool,Char}
Expand All @@ -67,7 +67,7 @@ function _parameter(@nospecialize(p))
elseif p isa Tuple
_parameter.(p)
else
FakeTypeName(p, justname = true)
FakeTypeName(p, justname=true)
end
end

Expand All @@ -84,11 +84,11 @@ function Base.print(io::IO, tn::FakeTypeName)
end
end
Base.print(io::IO, x::FakeUnionAll) = print(io, x.body, " where ", x.var)
function Base.print(io::IO, x::FakeUnion; inunion = false)
function Base.print(io::IO, x::FakeUnion; inunion=false)
!inunion && print(io, "Union{")
print(io, x.a, ",")
if x.b isa FakeUnion
print(io, x.b, inunion = true)
print(io, x.b, inunion=true)
else
print(io, x.b, "}")
end
Expand Down
34 changes: 17 additions & 17 deletions src/symbols.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function maybe_fixup_stdlib_path(path)
end

const _global_method_cache = IdDict{Any,Vector{Any}}()
function methodinfo(@nospecialize(f); types = Tuple, world = typemax(UInt))
function methodinfo(@nospecialize(f); types=Tuple, world=typemax(UInt))
key = (f, types, world)
cached = get(_global_method_cache, key, nothing)
if cached === nothing
Expand All @@ -158,7 +158,7 @@ function cache_methods(@nospecialize(f), name, env)
world = typemax(UInt)
ms = Tuple{Module,MethodStore}[]
methods0 = try
methodinfo(f; types = types, world = world)
methodinfo(f; types=types, world=world)
catch err
return ms
end
Expand Down Expand Up @@ -230,10 +230,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)
Expand All @@ -250,11 +250,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)
for s in unsorted_names(m, all=true)
!isdefined(m, s) && continue
x = getfield(m, s)
state = f(m, s, x, state)
Expand All @@ -270,7 +270,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
Expand All @@ -291,7 +291,7 @@ end

function allmodulenames()
symbols = Base.IdSet{Symbol}()
oneverything((m, s, x, state)->(x isa Module && push!(symbols, s); return state))
oneverything((m, s, x, state) -> (x isa Module && push!(symbols, s); return state))
return symbols
end

Expand Down Expand Up @@ -320,10 +320,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
Expand Down Expand Up @@ -352,12 +352,12 @@ 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

function symbols(env::EnvStore, m::Union{Module,Nothing} = nothing, allnames::Base.IdSet{Symbol} = getallns(), visited = Base.IdSet{Module}())
function symbols(env::EnvStore, m::Union{Module,Nothing}=nothing, allnames::Base.IdSet{Symbol}=getallns(), visited=Base.IdSet{Module}())
if m isa Module
cache = _lookup(VarRef(m), env, true)
cache === nothing && return
Expand Down Expand Up @@ -452,7 +452,7 @@ function load_core()
cache[:Base][Symbol("@.")] = cache[:Base][Symbol("@__dot__")]
cache[:Core][:Main] = GenericStore(VarRef(nothing, :Main), FakeTypeName(Module), _doc(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)
Expand Down Expand Up @@ -529,7 +529,7 @@ function load_core()
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
Expand All @@ -546,7 +546,7 @@ function collect_extended_methods(mod::ModuleStore, extendeds, mname)
end
end

getallns() = let allns = Base.IdSet{Symbol}(); SymbolServer.oneverything((m, s, x, state)->push!(allns, s)); allns end
getallns() = let allns = Base.IdSet{Symbol}(); SymbolServer.oneverything((m, s, x, state) -> push!(allns, s)); allns end

"""
split_module_names(m::Module, allns)
Expand Down Expand Up @@ -577,5 +577,5 @@ 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)]
12 changes: 6 additions & 6 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ else
is_package_deved(manifest, uuid) = manifest[uuid].path !== nothing
end

function sha2_256_dir(path, sha = sha = zeros(UInt8, 32))
function sha2_256_dir(path, sha=sha = zeros(UInt8, 32))
(uperm(path) & 0x04) != 0x04 && return
startswith(path, ".") && return
if isfile(path) && endswith(path, ".jl")
Expand Down Expand Up @@ -231,10 +231,10 @@ function _doc(@nospecialize(object))
end
end

_lookup(vr::FakeUnion, depot::EnvStore, cont = false) = nothing
_lookup(vr::FakeTypeName, depot::EnvStore, cont = false) = _lookup(vr.name, depot, cont)
_lookup(vr::FakeUnionAll, depot::EnvStore, cont = false) = _lookup(vr.body, depot, cont)
function _lookup(vr::VarRef, depot::EnvStore, cont = false)
_lookup(vr::FakeUnion, depot::EnvStore, cont=false) = nothing
_lookup(vr::FakeTypeName, depot::EnvStore, cont=false) = _lookup(vr.name, depot, cont)
_lookup(vr::FakeUnionAll, depot::EnvStore, cont=false) = _lookup(vr.body, depot, cont)
function _lookup(vr::VarRef, depot::EnvStore, cont=false)
if vr.parent === nothing
if haskey(depot, vr.name)
val = depot[vr.name]
Expand Down Expand Up @@ -341,7 +341,7 @@ extends_methods(f::FunctionStore) = f.name != f.extends
get_top_module(vr::VarRef) = vr.parent === nothing ? vr.name : get_top_module(vr.parent)

# Sorting is the main performance of calling `names`
unsorted_names(m::Module; all::Bool = false, imported::Bool = false) =
unsorted_names(m::Module; all::Bool=false, imported::Bool=false) =
ccall(:jl_module_names, Array{Symbol,1}, (Any, Cint, Cint), m, all, imported)

## recursive_copy
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ allns = SymbolServer.getallns()
function missingsymbols(m::Module, cache::SymbolServer.ModuleStore, env)
notfound = Symbol[]
notfoundhidden = Symbol[]
for n in names(m, all = true)
for n in names(m, all=true)
if isdefined(m, n) && !haskey(cache.vals, n)
push!(notfound, n)
end
Expand Down Expand Up @@ -37,7 +37,7 @@ function missingsymbols(m::Module, cache::SymbolServer.ModuleStore, env)
end

# Check that we don't have any VarRefs that point to themselves or to nothing.
function check_varrefs(env, m = nothing)
function check_varrefs(env, m=nothing)
if m === nothing
for (n, m) in env
check_varrefs(env, m)
Expand Down Expand Up @@ -67,7 +67,7 @@ end
end

@testset "Builtins have appropriate methods" begin
for n in names(Core, all = true)
for n in names(Core, all=true)
if isdefined(Core, n) && (x = getfield(Core, n)) isa Core.Builtin && haskey(SymbolServer.stdlibs[:Core], n)
@test !isempty(SymbolServer.stdlibs[:Core][n].methods)
@test !isempty(first(SymbolServer.stdlibs[:Core][n].methods).sig)
Expand Down

0 comments on commit 23418a6

Please sign in to comment.