fix: Cleanup param name inlay hint filtering

This commit is contained in:
Lukas Wirth 2025-03-31 07:43:08 +02:00
parent fb133c8c80
commit 2b382eb772
7 changed files with 188 additions and 119 deletions

View file

@ -36,6 +36,16 @@ impl ast::NameRef {
pub fn text(&self) -> TokenText<'_> {
text_of_first_token(self.syntax())
}
pub fn text_non_mutable(&self) -> &str {
fn first_token(green_ref: &GreenNodeData) -> &GreenTokenData {
green_ref.children().next().and_then(NodeOrToken::into_token).unwrap()
}
match self.syntax().green() {
Cow::Borrowed(green_ref) => first_token(green_ref).text(),
Cow::Owned(_) => unreachable!(),
}
}
pub fn as_tuple_field(&self) -> Option<usize> {
self.text().parse().ok()