From 8e554ea5faa1158e084462162d5e1932db5c81c2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jan 2019 13:34:57 +0300 Subject: support ref-patterns --- crates/ra_syntax/src/ast.rs | 6 ++++++ crates/ra_syntax/src/ast/generated.rs | 6 +++++- crates/ra_syntax/src/grammar.ron | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 123a7a6b9..8bf439b60 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -348,6 +348,12 @@ impl UseTreeList { } } +impl RefPat { + pub fn is_mut(&self) -> bool { + self.syntax().children().any(|n| n.kind() == MUT_KW) + } +} + fn child_opt(parent: &P) -> Option<&C> { children(parent).next() } diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 1f6055115..f745cb1cb 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -2456,7 +2456,11 @@ impl AstNode for RefPat { } -impl RefPat {} +impl RefPat { + pub fn pat(&self) -> Option<&Pat> { + super::child_opt(self) + } +} // ReferenceType #[derive(Debug, PartialEq, Eq, Hash)] diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index bddd96a5c..bac62fa04 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -462,7 +462,7 @@ Grammar( ], ), - "RefPat": (), + "RefPat": ( options: [ "Pat" ]), "BindPat": ( traits: ["NameOwner"] ), "PlaceholderPat": (), "PathPat": (), -- cgit v1.2.3