From 852b08379473cc3ee06878c5aae809b63d76cbc3 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Tue, 5 Feb 2019 17:05:46 -0500 Subject: Fill deprecation for LSP --- crates/ra_syntax/src/ast.rs | 10 ++++++++++ crates/ra_syntax/src/ast/generated.rs | 1 + crates/ra_syntax/src/grammar.ron | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax') 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 { None } } + + pub fn as_named(&self) -> Option { + let tt = self.value()?; + let attr = tt.syntax().children().nth(1)?; + if attr.kind() == IDENT { + Some(attr.leaf_text().unwrap().clone()) + } else { + None + } + } } impl 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 { impl ast::NameOwner for EnumVariant {} impl ast::DocCommentsOwner for EnumVariant {} +impl ast::AttrsOwner for EnumVariant {} impl EnumVariant { pub fn expr(&self) -> Option<&Expr> { 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( "DocCommentsOwner" ], options: [["variant_list", "EnumVariantList"]] ), "EnumVariantList": ( collections: [["variants", "EnumVariant"]] ), - "EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner"], options: ["Expr"] ), + "EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner", "AttrsOwner"], options: ["Expr"] ), "TraitDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"] ), "Module": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner" ], -- cgit v1.2.3