aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast.rs10
-rw-r--r--crates/ra_syntax/src/ast/generated.rs1
-rw-r--r--crates/ra_syntax/src/grammar.ron2
3 files changed, 12 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 3d22a88f3..d6237532b 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -177,6 +177,16 @@ impl Attr {
177 None 177 None
178 } 178 }
179 } 179 }
180
181 pub fn as_named(&self) -> Option<SmolStr> {
182 let tt = self.value()?;
183 let attr = tt.syntax().children().nth(1)?;
184 if attr.kind() == IDENT {
185 Some(attr.leaf_text().unwrap().clone())
186 } else {
187 None
188 }
189 }
180} 190}
181 191
182impl Comment { 192impl Comment {
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index a8d60e882..60314d245 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -755,6 +755,7 @@ impl ToOwned for EnumVariant {
755 755
756impl ast::NameOwner for EnumVariant {} 756impl ast::NameOwner for EnumVariant {}
757impl ast::DocCommentsOwner for EnumVariant {} 757impl ast::DocCommentsOwner for EnumVariant {}
758impl ast::AttrsOwner for EnumVariant {}
758impl EnumVariant { 759impl EnumVariant {
759 pub fn expr(&self) -> Option<&Expr> { 760 pub fn expr(&self) -> Option<&Expr> {
760 super::child_opt(self) 761 super::child_opt(self)
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 2ed1fd1b8..046db5885 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -281,7 +281,7 @@ Grammar(
281 "DocCommentsOwner" 281 "DocCommentsOwner"
282 ], options: [["variant_list", "EnumVariantList"]] ), 282 ], options: [["variant_list", "EnumVariantList"]] ),
283 "EnumVariantList": ( collections: [["variants", "EnumVariant"]] ), 283 "EnumVariantList": ( collections: [["variants", "EnumVariant"]] ),
284 "EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner"], options: ["Expr"] ), 284 "EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner", "AttrsOwner"], options: ["Expr"] ),
285 "TraitDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"] ), 285 "TraitDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"] ),
286 "Module": ( 286 "Module": (
287 traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner" ], 287 traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner" ],