Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @autoinfiltrate for simple, ad-hoc interactive debugging #150

Merged
merged 2 commits into from
May 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ See also: [Infiltrator.jl](https://github.com/JuliaDebug/Infiltrator.jl)
API of TrixiParticles.jl, and it thus can altered (or be removed) at any time without it being
considered a breaking change.
"""
macro autoinfiltrate(condition = true)
macro autoinfiltrate(condition=true)
pkgid = Base.PkgId(Base.UUID("5903a43b-9cc3-4c30-8d17-598619ec4e9b"), "Infiltrator")
if !haskey(Base.loaded_modules, pkgid)
try
Expand All @@ -286,19 +286,16 @@ macro autoinfiltrate(condition = true)
end
i = get(Base.loaded_modules, pkgid, nothing)
lnn = LineNumberNode(__source__.line, __source__.file)

if i === nothing
return Expr(
:macrocall,
Symbol("@warn"),
lnn,
"Could not load Infiltrator.")
return Expr(:macrocall,
Symbol("@warn"),
lnn,
"Could not load Infiltrator.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we can allow the previous version in the future with the option variable_call_indent (see domluna/JuliaFormatter.jl#676).
I want to wait for this PR to make it into VSCode before we add it to TrixiP, though.

end

return Expr(
:macrocall,
Expr(:., i, QuoteNode(Symbol("@infiltrate"))),
lnn,
esc(condition)
)

return Expr(:macrocall,
Expr(:., i, QuoteNode(Symbol("@infiltrate"))),
lnn,
esc(condition))
end