-
Notifications
You must be signed in to change notification settings - Fork 112
Preliminary support for include(mapexpr, file)
#939
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
base: master
Are you sure you want to change the base?
Conversation
…ernal-methodtables
…ernal-methodtables
…ernal-methodtables
In conjunction with `CodeTracking.MapFile`, this allows Revise to track changes in files that are included with `include(mapexpr, file)`. This PR supports the implementation of revisions for such files, properly applying the `mapexpr` transformation to the included file's expressions. What's missing: - Revise can't correctly populate the internal data structures needed to initiate `mapexpr` without help. The problem is that Revise only parses files that get edited, but discovering that `file2.jl` gets included from `file1.jl` via a `mapexpr` requires parsing `file1.jl`, which may not have been edited and therefore never scanned via Revise. The right way to fix this is in Julia itself, writing additional info to the package cache header. This will not land before Julia 1.13. - `include(mapexpr, file)` is well-suited to include the same file more than once with different `mapexpr`s. While it hasn't been tested, this seems unlikely to work for now, and the anticipated problems stem all the way back to Julia itself (again, issues that should be fixed in the package cache header). Package authors who want to use this in their packages can add a call to `Revise.parseall(@__MODULE__)` in their `__init__` function to ensure that the `mapexpr` files are parsed and tracked by Revise. Fixes #820, #634
That appears much less intrusive than what I started at timholy/CodeTracking.jl#142 (comment), that's great! IMHO the design remains somewhat less intuitive (treating the |
In conjunction with
CodeTracking.MapExprFile
, this allows Revise to trackchanges in files that are included with
include(mapexpr, file)
. ThisPR supports the implementation of revisions for such files, properly
applying the
mapexpr
transformation to the included file'sexpressions.
What's missing:
initiate
mapexpr
without help. The problem is that Revise onlyparses files that get edited, but discovering that
file2.jl
getsincluded from
file1.jl
via amapexpr
requires parsingfile1.jl
,which may not have been edited and therefore never scanned via Revise.
The right way to fix this is in Julia itself, writing additional info
to the package cache header. This will not land before Julia 1.13.
include(mapexpr, file)
is well-suited to include the same file morethan once with different
mapexpr
s. While it hasn't been tested, thisseems unlikely to work for now, and the anticipated problems stem all
the way back to Julia itself (again, issues that should be fixed in
the package cache header).
Package authors who want to use this in their packages can add a call to
Revise.parseall(@__MODULE__)
in their__init__
function toensure that the
mapexpr
files are parsed and tracked by Revise.Fixes #820, #634
Note this is built on #904 so the diff will be confusing unless you look at only the final commit.