Check whether `target_class` is the same class as, or an ancestor of, the class the cursor is inside. Returns `true` when: - `current_class.name == target_class.name` (same class), or - walking the parent chain of `current_class` reaches `target_class`. This controls visibility filtering: when `true`, `__construct` is offered via `::` access and protected members are visible.
(
current_class: Option<&ClassInfo>,
target_class: &ClassInfo,
class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
)
| 560 | /// This controls visibility filtering: when `true`, `__construct` is |
| 561 | /// offered via `::` access and protected members are visible. |
| 562 | pub(crate) fn is_ancestor_of( |
| 563 | current_class: Option<&ClassInfo>, |
| 564 | target_class: &ClassInfo, |
| 565 | class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>, |
| 566 | ) -> bool { |
| 567 | let Some(cc) = current_class else { |
| 568 | return false; |
| 569 | }; |
| 570 | if cc.name == target_class.name { |
| 571 | return true; |
| 572 | } |
| 573 | // Walk the parent chain of the current class to see if the target |
| 574 | // is an ancestor. |
| 575 | let mut ancestor_name = cc.parent_class; |
| 576 | let mut depth = 0u32; |
| 577 | while let Some(ref name) = ancestor_name { |
| 578 | depth += 1; |
| 579 | if depth > 20 { |
| 580 | break; |
| 581 | } |
| 582 | // ClassInfo.name stores the short name (e.g. "BaseService") |
| 583 | // while parent_class stores the FQN (e.g. "App\\BaseService"). |
| 584 | // Compare against both the full name and the short (last segment) |
| 585 | // so that cross-file inheritance is detected correctly. |
| 586 | let short = name.rsplit('\\').next().unwrap_or(name); |
| 587 | if target_class.name == *name || target_class.name == short { |
| 588 | return true; |
| 589 | } |
| 590 | ancestor_name = class_loader(name).and_then(|ci| ci.parent_class); |
| 591 | } |
| 592 | false |
| 593 | } |
| 594 | |
| 595 | /// Build completion items from multiple candidate classes (union types), |
| 596 | /// resolving each through full inheritance and deduplicating across them. |
no test coverage detected