Find which class the cursor (byte offset) is inside. When multiple classes contain the offset (e.g. an anonymous class nested inside a named class's method), the smallest (most specific) class is returned. This ensures that `$this` inside an anonymous class body resolves to the anonymous class, not the outer class.
(classes: &[Arc<ClassInfo>], offset: u32)
| 770 | /// class is returned. This ensures that `$this` inside an anonymous |
| 771 | /// class body resolves to the anonymous class, not the outer class. |
| 772 | pub(crate) fn find_class_at_offset(classes: &[Arc<ClassInfo>], offset: u32) -> Option<&ClassInfo> { |
| 773 | classes |
| 774 | .iter() |
| 775 | .map(|c| c.as_ref()) |
| 776 | .filter(|c| offset >= c.start_offset && offset <= c.end_offset) |
| 777 | .min_by_key(|c| c.end_offset - c.start_offset) |
| 778 | } |
| 779 | |
| 780 | /// Find a class in a slice by name, preferring namespace-aware matching |
| 781 | /// when the name is fully qualified. |
no test coverage detected