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

Use different version if Revise is tracking proto #36

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Changes from all commits
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
24 changes: 23 additions & 1 deletion src/ProtoStruct.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@

const revise_uuid = Base.UUID("295af30f-e4ad-537b-8983-00126c2a3abe")
const revise_pkgid = Base.PkgId(revise_uuid, "Revise")

function checkrev()
revise_pkgid in keys(Base.loaded_modules) || return false
d = @__DIR__
f = splitpath(@__FILE__)[end]
watched_files = getproperty(Base.loaded_modules[revise_pkgid], :watched_files)
d in keys(watched_files) || return false
trackedfiles = watched_files[d].trackedfiles
return f in keys(trackedfiles)

Check warning on line 12 in src/ProtoStruct.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtoStruct.jl#L7-L12

Added lines #L7 - L12 were not covered by tests
end

macro proto(expr)
if checkrev()
@eval __module__ $(_proto(expr))
BeastyBlacksmith marked this conversation as resolved.
Show resolved Hide resolved
return

Check warning on line 18 in src/ProtoStruct.jl

View check run for this annotation

Codecov / codecov/patch

src/ProtoStruct.jl#L17-L18

Added lines #L17 - L18 were not covered by tests
else
return esc(_proto(expr))
end
end

function _proto(expr)
if expr.head == :macrocall && expr.args[1] == Symbol("@kwdef")
expr = expr.args[3]
end
Expand Down Expand Up @@ -230,6 +252,6 @@
end
end
end
return esc(ex)
return ex
end

Loading