diff options
author | Kirill Bulatov <[email protected]> | 2019-07-19 06:53:12 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2019-07-20 19:39:04 +0100 |
commit | b6c662c573014710d4e8d9fd9253793141d8bbe0 (patch) | |
tree | 2b680a1c7c50125ed6a90d8de20d9d15460349b4 /crates/ra_ide_api | |
parent | 7bde8012cb28c44de7ffc779003781d385323808 (diff) |
If possible, show type lenses for the let bindings
Diffstat (limited to 'crates/ra_ide_api')
-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 | ||