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

Function extract_trailing_identifier

src/inlay_hints.rs:497–508  ·  view source on GitHub ↗

Extract the trailing identifier from a member-access expression. For `$this->foo->bar`, returns `"bar"`. For `SomeClass::method`, returns `"method"`.

(text: &str)

Source from the content-addressed store, hash-verified

495/// For `$this->foo->bar`, returns `"bar"`.
496/// For `SomeClass::method`, returns `"method"`.
497fn extract_trailing_identifier(text: &str) -> Option<&str> {
498 let trimmed = text.trim();
499 // Look for `->identifier` or `::identifier` at the end.
500 let pos = trimmed.rfind("->").or_else(|| trimmed.rfind("::"))?;
501 let after = &trimmed[pos + 2..];
502 // The trailing part should be a simple identifier.
503 if after.chars().all(|c| c.is_alphanumeric() || c == '_') && !after.is_empty() {
504 Some(after)
505 } else {
506 None
507 }
508}
509
510/// Compare two identifiers ignoring case and treating snake_case
511/// as equivalent to camelCase.

Callers 1

should_suppress_hintFunction · 0.70

Calls 2

allMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected