aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorMarcus Klaas de Vries <[email protected]>2019-01-17 12:08:18 +0000
committerAleksey Kladov <[email protected]>2019-01-19 12:37:26 +0000
commitd48d5b8b6ca59b462b3a84dad9868daff2eddb6d (patch)
tree20f1936ccf07abea463ae81b36132efd76ad4f71 /crates/ra_syntax/src
parent9433a108cfcf3a9c7de9299d6641a5abf9031a17 (diff)
Add initial (flawed) implementation of binding annotations
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs10
-rw-r--r--crates/ra_syntax/src/ast/generated.rs6
-rw-r--r--crates/ra_syntax/src/grammar.ron5
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
716impl 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]
717fn test_doc_comment_of_items() { 727fn 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
182impl ast::NameOwner for BindPat {} 182impl ast::NameOwner for BindPat {}
183impl BindPat {} 183impl 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"] ),