internal: Refactor our record pat/expr handling in completion context

This commit is contained in:
Lukas Wirth 2022-05-24 13:24:36 +02:00
parent 697ade6f8d
commit 6a8b8a6039
9 changed files with 151 additions and 125 deletions

View file

@ -510,6 +510,10 @@ impl ast::RecordPatField {
}
}
pub fn parent_record_pat(&self) -> ast::RecordPat {
self.syntax().ancestors().find_map(ast::RecordPat::cast).unwrap()
}
/// Deals with field init shorthand
pub fn field_name(&self) -> Option<NameOrNameRef> {
if let Some(name_ref) = self.name_ref() {