Attribute completion is context aware

This commit is contained in:
Lukas Wirth 2021-05-27 23:28:14 +02:00
parent 01bfc5f5c0
commit fc37e2f953
4 changed files with 150 additions and 28 deletions

View file

@ -243,6 +243,13 @@ impl ast::Path {
}
}
pub fn as_single_name_ref(&self) -> Option<ast::NameRef> {
match self.qualifier() {
Some(_) => None,
None => self.segment()?.name_ref(),
}
}
pub fn first_qualifier_or_self(&self) -> ast::Path {
successors(Some(self.clone()), ast::Path::qualifier).last().unwrap()
}