aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast/node_ext.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-29 13:14:16 +0100
committerGitHub <[email protected]>2021-05-29 13:14:16 +0100
commit247faf271b9098624cb0b09dd4914da66497dd5a (patch)
treeb327bd6ab1a67f3655a81f37547af05c2ceaef2b /crates/syntax/src/ast/node_ext.rs
parent7869b01b702d1f12acb03ac131b6eb90ad82e9bb (diff)
parentc9f0f47bbba3d02a6389af14aaf1c3d1d088d191 (diff)
Merge #9027
9027: feat: Attribute completion is context aware r=Veykril a=Veykril This splits off the `lint` and `derive` completions into their own submodules of `attribute`. The idea is to create a lazy global hashmap that maps `SyntaxKind` to attribute names(`&[&str]`) in which we index with the syntax kind of the "thing" we are attributing giving us the attributes back that are valid for this kind. Then we use this name to do a binary search on the attribute list to fetch and build the corresponding completion item. Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/syntax/src/ast/node_ext.rs')
-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 }