diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/display/structure.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs index 2ba10b2ef..223941688 100644 --- a/crates/ra_ide_api/src/display/structure.rs +++ b/crates/ra_ide_api/src/display/structure.rs | |||
@@ -1,5 +1,6 @@ | |||
1 | use crate::TextRange; | 1 | use crate::TextRange; |
2 | 2 | ||
3 | use ra_syntax::ast::PatKind; | ||
3 | use ra_syntax::{ | 4 | use ra_syntax::{ |
4 | algo::visit::{visitor, Visitor}, | 5 | algo::visit::{visitor, Visitor}, |
5 | ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, | 6 | ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, |
@@ -155,6 +156,27 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
155 | } | 156 | } |
156 | decl(mc) | 157 | decl(mc) |
157 | }) | 158 | }) |
159 | .visit(|let_statement: &ast::LetStmt| { | ||
160 | let let_syntax = let_statement.syntax(); | ||
161 | |||
162 | let mut label = String::new(); | ||
163 | collapse_ws(let_syntax, &mut label); | ||
164 | |||
165 | let pat = match let_statement.pat()?.kind() { | ||
166 | PatKind::BindPat(bind_pat) => bind_pat, | ||
167 | _ => return None, | ||
168 | }; | ||
169 | |||
170 | Some(StructureNode { | ||
171 | parent: None, | ||
172 | label, | ||
173 | navigation_range: pat.syntax().range(), | ||
174 | node_range: let_syntax.range(), | ||
175 | kind: let_syntax.kind(), | ||
176 | detail: None, | ||
177 | deprecated: false, | ||
178 | }) | ||
179 | }) | ||
158 | .accept(&node)? | 180 | .accept(&node)? |
159 | } | 181 | } |
160 | 182 | ||