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_ide_api_light/src/structure.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'crates/ra_ide_api_light/src/structure.rs') diff --git a/crates/ra_ide_api_light/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs index 4e080ed03..dc3534498 100644 --- a/crates/ra_ide_api_light/src/structure.rs +++ b/crates/ra_ide_api_light/src/structure.rs @@ -2,7 +2,7 @@ use crate::TextRange; use ra_syntax::{ algo::visit::{visitor, Visitor}, - ast::{self, NameOwner, TypeParamsOwner}, + ast::{self, AttrsOwner, NameOwner, TypeParamsOwner}, AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, }; @@ -14,6 +14,7 @@ pub struct StructureNode { pub node_range: TextRange, pub kind: SyntaxKind, pub detail: Option, + pub deprecated: bool, } pub fn file_structure(file: &SourceFile) -> Vec { @@ -40,11 +41,11 @@ pub fn file_structure(file: &SourceFile) -> Vec { } fn structure_node(node: &SyntaxNode) -> Option { - fn decl(node: &N) -> Option { + fn decl(node: &N) -> Option { decl_with_detail(node, None) } - fn decl_with_type_ref( + fn decl_with_type_ref( node: &N, type_ref: Option<&ast::TypeRef>, ) -> Option { @@ -56,8 +57,12 @@ fn structure_node(node: &SyntaxNode) -> Option { decl_with_detail(node, detail) } - fn decl_with_detail(node: &N, detail: Option) -> Option { + fn decl_with_detail( + node: &N, + detail: Option, + ) -> Option { let name = node.name()?; + dbg!(name.text().to_string()); Some(StructureNode { parent: None, label: name.text().to_string(), @@ -65,6 +70,10 @@ fn structure_node(node: &SyntaxNode) -> Option { node_range: node.syntax().range(), kind: node.syntax().kind(), detail, + deprecated: node + .attrs() + .filter_map(|x| x.as_named()) + .any(|x| x == "deprecated"), }) } @@ -128,6 +137,7 @@ fn structure_node(node: &SyntaxNode) -> Option { node_range: im.syntax().range(), kind: im.syntax().kind(), detail: None, + deprecated: false, }; Some(node) }) @@ -165,6 +175,12 @@ const C: i32 = 92; impl E {} impl fmt::Debug for E {} + +#[deprecated] +fn obsolete() {} + +#[deprecated(note = "for awhile")] +fn very_obsolete() {} "#, ); let structure = file_structure(&file); -- cgit v1.2.3 From d107926f8621dfc08010ffc5bf4a1ac6356c6c87 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Wed, 6 Feb 2019 07:22:16 -0500 Subject: Remove stray dbg! --- crates/ra_ide_api_light/src/structure.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide_api_light/src/structure.rs') diff --git a/crates/ra_ide_api_light/src/structure.rs b/crates/ra_ide_api_light/src/structure.rs index dc3534498..330a3694c 100644 --- a/crates/ra_ide_api_light/src/structure.rs +++ b/crates/ra_ide_api_light/src/structure.rs @@ -62,7 +62,7 @@ fn structure_node(node: &SyntaxNode) -> Option { detail: Option, ) -> Option { let name = node.name()?; - dbg!(name.text().to_string()); + Some(StructureNode { parent: None, label: name.text().to_string(), -- cgit v1.2.3