@@ -6,7 +6,7 @@ CodeTracking can be thought of as an extension of InteractiveUtils, and pairs we
66- `definition`: a lower-level variant of the above
77- `pkgfiles`: return information about the source files that define a package
88- `whereis`: Return location information about methods (with Revise, it updates as you edit files)
9- - `signatures_at`: return the signatures of all methods whose definition spans the specified location
9+ - `signatures_at`: return the signatures (and the corresponding method table) of all methods whose definition spans the specified location
1010"""
1111module CodeTracking
1212
@@ -54,8 +54,8 @@ const method_lookup_callback = Ref{Any}(nothing)
5454# id is the PkgId of the corresponding package
5555# relpath is the path of the file from the basedir of `id`
5656# mod is the "active" module at that point in the source
57- # exsigs is a ex=>sigs dictionary, where `ex` is the source expression and `sigs `
58- # a list of method-signatures defined by that expression.
57+ # exsigs is a `ex => mt_sigs` dictionary, where `ex` is the source expression and `mt_sigs `
58+ # a list of `method_table => signature` pairs defined by that expression.
5959const expressions_callback = Ref {Any} (nothing )
6060
6161const juliabase = joinpath (" julia" , " base" )
@@ -69,9 +69,7 @@ MethodInfoKey(method::Method) = MethodInfoKey(method_table(method), method.sig)
6969"""
7070 filepath, line = whereis(method::Method)
7171
72- Return the file and line of the definition of `method`. The meaning of `line`
73- depends on the Julia version: on Julia 1.5 and higher it is the line number of
74- the method declaration, otherwise it is the first line of the method's body.
72+ Return the file and line of the definition of `method`.
7573"""
7674function whereis (method:: Method )
7775 file, line = String (method. file), method. line
@@ -140,11 +138,9 @@ function whereis(lineinfo::Core.LineInfoNode, method::Method)
140138end
141139
142140"""
143- sigs = signatures_at(filename, line)
141+ mt_sigs = signatures_at(filename, line)
144142
145- Return the signatures of all methods whose definition spans the specified location.
146- Prior to Julia 1.5, `line` must correspond to a line in the method body
147- (not the signature or final `end`).
143+ Return the `method_table => signature` pairs of all methods whose definition spans the specified location.
148144
149145Returns `nothing` if there are no methods at that location.
150146"""
@@ -181,11 +177,11 @@ function signatures_at(filename::AbstractString, line::Integer)
181177end
182178
183179"""
184- sigs = signatures_at(mod::Module, relativepath, line)
180+ mt_sigs = signatures_at(mod::Module, relativepath, line)
185181
186- For a package that defines module `mod`, return the signatures of all methods whose definition
187- spans the specified location. `relativepath` indicates the path of the file relative to
188- the packages top-level directory, e.g., `"src/utils.jl"`.
182+ For a package that defines module `mod`, return the `method_table => signature` pairs of
183+ all methods whose definition spans the specified location. `relativepath` indicates the
184+ path of the file relative to the packages top-level directory, e.g., `"src/utils.jl"`.
189185`line` must correspond to a line in the method body (not the signature or final `end`).
190186
191187Returns `nothing` if there are no methods at that location.
@@ -200,10 +196,10 @@ function signatures_at(id::PkgId, relpath::AbstractString, line::Integer)
200196 expressions === nothing && error (" cannot look up methods by line number, try `using Revise` before loading other packages" )
201197 try
202198 for (mod, exsigs) in Base. invokelatest (expressions, id, relpath)
203- for (ex, sigs ) in exsigs
199+ for (ex, mt_sigs ) in exsigs
204200 lr = linerange (ex)
205201 lr === nothing && continue
206- line ∈ lr && return sigs
202+ line ∈ lr && return mt_sigs
207203 end
208204 end
209205 catch
0 commit comments