From fc37e2f953a0d200e875c4711c1b0bf79a75a2a2 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 27 May 2021 23:28:14 +0200 Subject: Attribute completion is context aware --- crates/syntax/src/ast/node_ext.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/syntax/src') diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index df8f98b5b..884fe0739 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs @@ -243,6 +243,13 @@ impl ast::Path { } } + pub fn as_single_name_ref(&self) -> Option { + 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() } -- cgit v1.2.3