From b6c662c573014710d4e8d9fd9253793141d8bbe0 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 19 Jul 2019 08:53:12 +0300 Subject: If possible, show type lenses for the let bindings --- crates/ra_ide_api/src/display/structure.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crates/ra_ide_api/src/display') 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 @@ use crate::TextRange; +use ra_syntax::ast::PatKind; use ra_syntax::{ algo::visit::{visitor, Visitor}, ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, @@ -155,6 +156,27 @@ fn structure_node(node: &SyntaxNode) -> Option { } decl(mc) }) + .visit(|let_statement: &ast::LetStmt| { + let let_syntax = let_statement.syntax(); + + let mut label = String::new(); + collapse_ws(let_syntax, &mut label); + + let pat = match let_statement.pat()?.kind() { + PatKind::BindPat(bind_pat) => bind_pat, + _ => return None, + }; + + Some(StructureNode { + parent: None, + label, + navigation_range: pat.syntax().range(), + node_range: let_syntax.range(), + kind: let_syntax.kind(), + detail: None, + deprecated: false, + }) + }) .accept(&node)? } -- cgit v1.2.3