Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Oct 16, 2019
1 parent 4c98ae0 commit fffe94f
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,24 @@ end
# In case the line numbers in the source code have changed since the code was compiled,
# allow packages to set a callback function that corrects them.
# (Used by Revise and perhaps other packages.)
default_methodloc(method::Method) = method.file, method.line
const methodloc_callback = Ref{Function}(default_methodloc)
const methodloc_callback = Ref{Function}()

# This function does the method location updating
function updated_methodloc(m)
file, line = invokelatest(methodloc_callback[], m)
if file !== nothing && isdefined(@__MODULE__, :Sys)
function updated_methodloc(m::Method)::Tuple{String, Int32}
file, line = string(m.file), m.line
if isassigned(methodloc_callback)
try
file, line = invokelatest(methodloc_callback[], m)
catch
end
end
# The file defining Base.Sys gets included after this file is included so make sure
# this function is valid even in this intermediary state
if isdefined(@__MODULE__, :Sys) && Sys.BUILD_STDLIB_PATH != Sys.STDLIB
# BUILD_STDLIB_PATH gets defined in sysinfo.jl
file = replace(String(file), normpath(Sys.BUILD_STDLIB_PATH) => normpath(Sys.STDLIB))
file = replace(file, normpath(Sys.BUILD_STDLIB_PATH) => normpath(Sys.STDLIB))
end
return Symbol(file), line
return file, line
end

functionloc(m::Core.MethodInstance) = functionloc(m.def)
Expand Down Expand Up @@ -205,10 +212,7 @@ function show(io::IO, m::Method)
show_method_params(io, tv)
print(io, " in ", m.module)
if line > 0
try
file, line = updated_methodloc(m)
catch
end
file, line = updated_methodloc(m)
print(io, " at ", file, ":", line)
end
end
Expand Down Expand Up @@ -257,11 +261,7 @@ function show_method_table(io::IO, ms::MethodList, max::Int=-1, header::Bool=tru
println(io)
print(io, "[$(n)] ")
show(io, meth)
file, line = meth.file, meth.line
try
file, line = updated_methodloc(m)
catch
end
file, line = updated_methodloc(meth)
push!(LAST_SHOWN_LINE_INFOS, (string(file), line))
else
rest += 1
Expand Down Expand Up @@ -371,10 +371,7 @@ function show(io::IO, ::MIME"text/html", m::Method)
end
print(io, " in ", m.module)
if line > 0
try
file, line = updated_methodloc(m)
catch
end
file, line = updated_methodloc(m)
u = url(m)
if isempty(u)
print(io, " at ", file, ":", line)
Expand Down Expand Up @@ -408,11 +405,7 @@ function show(io::IO, mime::MIME"text/plain", mt::AbstractVector{Method})
first = false
print(io, "[$(i)] ")
show(io, m)
file, line = m.file, m.line
try
file, line = updated_methodloc(m)
catch
end
file, line = updated_methodloc(m)
push!(LAST_SHOWN_LINE_INFOS, (string(file), line))
end
end
Expand Down

0 comments on commit fffe94f

Please sign in to comment.