pub struct ConvertContext<'a> {
pub laravel_root: &'a Path,
pub resolved_config_keys: &'a HashSet<String>,
pub tainted_vars: RefCell<HashSet<String>>,
pub degraded_spot_count: Cell<usize>,
}Expand description
Convert-time context threaded through every Blade-conversion call -
scan.rs’s own directive/tag scanning and, through it,
expr.rs’s expression translation. Lives here, one level up from
both, rather than in either - scan already depends on expr
(use super::expr;), so defining this type in scan and having
expr reference it back would make the two modules mutually
dependent for no reason beyond avoiding one extra use at this
shared level.
Fields§
§laravel_root: &'a PathOnly ever read by scan::scan_livewire_tag, to resolve a nested
<livewire:X> component’s own PHP class and enrich its
translation with whatever default property values it declares.
resolved_config_keys: &'a HashSet<String>Every "{config file stem}.{key}" pair a generated
config/{file}.rs module successfully resolved (see
larust_convert::config::convert_body) - expr.rs’s "config"
function-call arm checks membership here to decide whether
config('file.key') has a real generated home to reference,
never touching the underlying value itself (that already lives in
the generated file by the time this runs).
tainted_vars: RefCell<HashSet<String>>Variable names a dropped top-level @php block would have
assigned (see scan.rs’s own doc comment for the full mechanism) -
expr::translate’s "variable_name" arm treats a reference to
any name in here as unsupported, the same as an undefined
superglobal, so it degrades in place instead of translating into a
reference to a binding that no longer exists. Mutated inline
during a single left-to-right scan (never re-read from an earlier
position - Blade renders top-to-bottom and PHP has no forward
declarations, so a reference can only follow the assignment that
taints it), hence the interior mutability despite ConvertContext
otherwise being pure borrowed, read-only config.
Must be constructed fresh per file, never reused across a
whole conversion run - taint from one file’s own @php block has
no meaning for the next file’s variables of the same name.
degraded_spot_count: Cell<usize>How many spots in the current file have degraded so far - every
degrade site calls scan::next_degraded_spot(ctx) to claim the
next number, embedded in both the inline placeholder
(<!-- ... (spot #N) ... -->, always safe to embed - a bare
integer, never raw source) and the matching CONVERSION_REPORT.md
note (which also carries the real original source text, safe
there because a Markdown report is never re-parsed as a template
the way a .blade.xr file is). Lets a file with several drops
actually be navigated - a spot in the output can be traced to its
exact report entry instead of a pile of identical, anonymous
placeholder comments. Must be constructed fresh per file, same
reasoning as tainted_vars.