Skip to content

Commit

Permalink
revise updated method's line numbers
Browse files Browse the repository at this point in the history
closes #513
  • Loading branch information
aviatesk committed May 21, 2024
1 parent 8935d08 commit 21d6d03
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ authors = ["Shuhei Kadowaki <[email protected]>"]
version = "0.9.0"

[deps]
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
LoweredCodeUtils = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
Expand All @@ -22,6 +23,7 @@ ReviseExt = "Revise"
[compat]
Aqua = "0.8.2"
BenchmarkTools = "1.3.2"
CodeTracking = "1.3.1"
Example = "0.5.3"
InteractiveUtils = "1.10"
JuliaInterpreter = "0.9"
Expand Down
2 changes: 2 additions & 0 deletions src/JET.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ using Base.Meta: ParseError, isexpr, lower

using Base.Experimental: @MethodTable, @overlay

using CodeTracking: CodeTracking

using LoweredCodeUtils: LoweredCodeUtils, add_ssa_preds!, callee_matches

using JuliaInterpreter: _INACTIVE_EXCEPTION, Frame, JuliaInterpreter, is_quotenode_egal
Expand Down
11 changes: 10 additions & 1 deletion src/ui/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,15 @@ function print_frame_loc(io, frame, config, color)
def = frame.linfo.def
mod = def isa Module ? def : def.module
path = String(frame.file)
line = frame.line
Δline = 0
if def isa Method
# revise cached line number if method location has been updated
newline = CodeTracking.whereis(def)[2]
if newline != 0
Δline = newline - Int(def.line)
end
end
if config.fullpath
path = tofullpath(path)
elseif !isabspath(path)
Expand All @@ -249,7 +258,7 @@ function print_frame_loc(io, frame, config, color)
# end
modulecolor = color
printstyled(io, mod; color = modulecolor)
printstyled(io, ' ', path, ':', frame.line; color)
printstyled(io, ' ', path, ':', line+Δline; color)
end

function print_error_frame(io, report, config, depth)
Expand Down

0 comments on commit 21d6d03

Please sign in to comment.