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

Function resolve_class_keyword

src/util.rs:1875–1886  ·  view source on GitHub ↗

Resolve `self`, `static`, `$this`, or `parent` to a class name. Returns `Some(class_name)` when the keyword can be resolved, or `None` when: - `keyword` is not a recognised class keyword, or - there is no `current_class`, or - `parent` is used but the class has no parent. This centralises the keyword → class-name mapping that was previously duplicated across 10+ call sites.

(
    keyword: &str,
    current_class: Option<&ClassInfo>,
)

Source from the content-addressed store, hash-verified

1873/// This centralises the keyword → class-name mapping that was
1874/// previously duplicated across 10+ call sites.
1875pub(crate) fn resolve_class_keyword(
1876 keyword: &str,
1877 current_class: Option<&ClassInfo>,
1878) -> Option<String> {
1879 if is_self_or_static(keyword) {
1880 current_class.map(|cc| cc.name.to_string())
1881 } else if keyword.eq_ignore_ascii_case("parent") {
1882 current_class.and_then(|cc| cc.parent_class.map(|a| a.to_string()))
1883 } else {
1884 None
1885 }
1886}
1887
1888// ─── Shared helpers for code actions and diagnostics ────────────────────────
1889

Calls 2

is_self_or_staticFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected