@@ -7,21 +7,33 @@ using UUIDs
77export PkgFiles
88export whereis, definition, pkgfiles
99
10- include(" data .jl" )
10+ include(" pkgfiles .jl" )
1111include(" utils.jl" )
1212
13+ # ## Global storage
14+
15+ # These values get populated by Revise
16+
17+ const method_info = IdDict{Type,Tuple{LineNumberNode,Expr}}()
18+
19+ const _pkgfiles = Dict{PkgId,PkgFiles}()
20+
21+ const method_lookup_callback = Ref{Any}(nothing )
22+
23+ # ## Public API
24+
1325"""
1426 filepath, line = whereis(method::Method)
1527
1628Return the file and line of the definition of `method`. `line`
1729is the first line of the method's body.
1830"""
1931function whereis(method:: Method )
20- lin = get(method_locations , method. sig, nothing )
32+ lin = get(method_info , method. sig, nothing )
2133 if lin === nothing
2234 file, line = String(method. file), method. line
2335 else
24- file, line = fileline(lin)
36+ file, line = fileline(lin[ 1 ] )
2537 end
2638 if ! isabspath(file)
2739 # This is a Base or Core method
6880Return an expression that defines `method`.
6981"""
7082function definition(method:: Method , :: Type{Expr} )
71- def = get(method_definitions , method. sig, nothing )
83+ def = get(method_info , method. sig, nothing )
7284 if def === nothing
7385 f = method_lookup_callback[]
7486 if f != = nothing
7587 Base. invokelatest(f, method)
7688 end
77- def = get(method_definitions , method. sig, nothing )
89+ def = get(method_info , method. sig, nothing )
7890 end
79- return def === nothing ? nothing : copy(def)
91+ return def === nothing ? nothing : copy(def[ 2 ] )
8092end
8193
8294definition(method:: Method ) = definition(method, Expr)
0 commit comments