Skip to content

Commit 456bbbd

Browse files
committed
add include_location::Bool option for showprov
1 parent 2197b66 commit 456bbbd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/utils.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,26 @@ function _show_provtree(io::IO, prov, indent)
3939
printstyled(io, "@ $fn:$line\n", color=:light_black)
4040
end
4141

42-
function showprov(io::IO, exs::AbstractVector; note=nothing, highlight_kwargs...)
42+
function showprov(io::IO, exs::AbstractVector;
43+
note=nothing, include_location::Bool=true, highlight_kwargs...)
4344
for (i,ex) in enumerate(Iterators.reverse(exs))
4445
sr = sourceref(ex)
4546
if i > 1
4647
print(io, "\n\n")
4748
end
4849
k = kind(ex)
49-
if isnothing(note)
50+
if isnothing(note) # use provided `note` otherwise
5051
note = i > 1 && k == K"macrocall" ? "in macro expansion" :
5152
i > 1 && k == K"$" ? "interpolated here" :
5253
"in source"
5354
end
5455
highlight(io, sr; note=note, highlight_kwargs...)
5556

56-
line, _ = source_location(sr)
57-
locstr = "$(filename(sr)):$line"
58-
JuliaSyntax._printstyled(io, "\n# @ $locstr", fgcolor=:light_black)
57+
if include_location
58+
line, _ = source_location(sr)
59+
locstr = "$(filename(sr)):$line"
60+
JuliaSyntax._printstyled(io, "\n# @ $locstr", fgcolor=:light_black)
61+
end
5962
end
6063
end
6164

0 commit comments

Comments
 (0)