MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / build_visible_writes

Function build_visible_writes

src/diagnostics/undefined_variables.rs:554–578  ·  view source on GitHub ↗

Build the set of writes visible to the frame at `frame_idx` by walking up the parent chain. - **Arrow functions and catch blocks** inherit all writes visible to their parent, plus their own direct writes. - **Closures** see only their own direct writes (captures are already recorded as Write accesses by the scope collector). - **Outermost / function / method** frames see only their own direct wri

(
    frame_idx: usize,
    frames: &[crate::scope_collector::Frame],
    frame_own_writes: &[Vec<(&'a str, u32)>],
)

Source from the content-addressed store, hash-verified

552/// - **Outermost / function / method** frames see only their own
553/// direct writes.
554fn build_visible_writes<'a>(
555 frame_idx: usize,
556 frames: &[crate::scope_collector::Frame],
557 frame_own_writes: &[Vec<(&'a str, u32)>],
558) -> Vec<(&'a str, u32)> {
559 let frame = &frames[frame_idx];
560 let own = &frame_own_writes[frame_idx];
561
562 match frame.kind {
563 FrameKind::ArrowFunction | FrameKind::Catch => {
564 // Inherit parent's visible writes, then add our own.
565 let parent_writes = match find_parent_frame_idx(frame_idx, frames) {
566 Some(parent_idx) => build_visible_writes(parent_idx, frames, frame_own_writes),
567 None => Vec::new(),
568 };
569 let mut combined = parent_writes;
570 combined.extend_from_slice(own);
571 combined
572 }
573 _ => {
574 // Closures, outermost, functions, methods: own writes only.
575 own.clone()
576 }
577 }
578}
579
580// ─── Dynamic variable / extract detection ───────────────────────────────────
581

Callers 1

check_scopeFunction · 0.85

Calls 2

find_parent_frame_idxFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected