diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 10 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 5 |
3 files changed, 19 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 4b7edbbe7..0ee9ef199 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -713,6 +713,16 @@ impl FieldPatList { | |||
713 | } | 713 | } |
714 | } | 714 | } |
715 | 715 | ||
716 | impl BindPat { | ||
717 | pub fn is_mutable(&self) -> bool { | ||
718 | self.syntax().children().any(|n| n.kind() == MUT_KW) | ||
719 | } | ||
720 | |||
721 | pub fn is_ref(&self) -> bool { | ||
722 | self.syntax().children().any(|n| n.kind() == REF_KW) | ||
723 | } | ||
724 | } | ||
725 | |||
716 | #[test] | 726 | #[test] |
717 | fn test_doc_comment_of_items() { | 727 | fn test_doc_comment_of_items() { |
718 | let file = SourceFile::parse( | 728 | let file = SourceFile::parse( |
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 251d53bdf..ead0f1293 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -180,7 +180,11 @@ impl AstNode for BindPat { | |||
180 | 180 | ||
181 | 181 | ||
182 | impl ast::NameOwner for BindPat {} | 182 | impl ast::NameOwner for BindPat {} |
183 | impl BindPat {} | 183 | impl BindPat { |
184 | pub fn pat(&self) -> Option<&Pat> { | ||
185 | super::child_opt(self) | ||
186 | } | ||
187 | } | ||
184 | 188 | ||
185 | // Block | 189 | // Block |
186 | #[derive(Debug, PartialEq, Eq, Hash)] | 190 | #[derive(Debug, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 33080f664..d58e0dd35 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -488,7 +488,10 @@ Grammar( | |||
488 | ), | 488 | ), |
489 | 489 | ||
490 | "RefPat": ( options: [ "Pat" ]), | 490 | "RefPat": ( options: [ "Pat" ]), |
491 | "BindPat": ( traits: ["NameOwner"] ), | 491 | "BindPat": ( |
492 | options: [ "Pat" ], | ||
493 | traits: ["NameOwner"] | ||
494 | ), | ||
492 | "PlaceholderPat": (), | 495 | "PlaceholderPat": (), |
493 | "PathPat": ( options: [ "Path" ] ), | 496 | "PathPat": ( options: [ "Path" ] ), |
494 | "StructPat": ( options: ["FieldPatList", "Path"] ), | 497 | "StructPat": ( options: ["FieldPatList", "Path"] ), |