aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-05-27 22:28:14 +0100
committerLukas Wirth <[email protected]>2021-05-27 22:28:14 +0100
commitfc37e2f953a0d200e875c4711c1b0bf79a75a2a2 (patch)
tree9cd8d24d855969c91d8bf81d14af034856d08674 /crates/syntax/src
parent01bfc5f5c0cf6b73c26d006802016c9b02066f94 (diff)
Attribute completion is context aware
Diffstat (limited to 'crates/syntax/src')
-rw-r--r--crates/syntax/src/ast/node_ext.rs7
1 files changed, 7 insertions, 0 deletions
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 {
243 } 243 }
244 } 244 }
245 245
246 pub fn as_single_name_ref(&self) -> Option<ast::NameRef> {
247 match self.qualifier() {
248 Some(_) => None,
249 None => self.segment()?.name_ref(),
250 }
251 }
252
246 pub fn first_qualifier_or_self(&self) -> ast::Path { 253 pub fn first_qualifier_or_self(&self) -> ast::Path {
247 successors(Some(self.clone()), ast::Path::qualifier).last().unwrap() 254 successors(Some(self.clone()), ast::Path::qualifier).last().unwrap()
248 } 255 }