From 38048c35d800230d3e5a79041186366dd0ef44ae Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 20 Mar 2021 23:22:09 +0100 Subject: Don't use an untyped String for ActiveParam tracking --- crates/ide_db/src/call_info.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'crates/ide_db') diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs index 7e26c3ccf..e583a52f4 100644 --- a/crates/ide_db/src/call_info.rs +++ b/crates/ide_db/src/call_info.rs @@ -4,7 +4,7 @@ use either::Either; use hir::{HasAttrs, HirDisplay, Semantics, Type}; use stdx::format_to; use syntax::{ - ast::{self, ArgListOwner}, + ast::{self, ArgListOwner, NameOwner}, match_ast, AstNode, SyntaxNode, SyntaxToken, TextRange, TextSize, }; @@ -142,7 +142,7 @@ fn call_info_impl( #[derive(Debug)] pub struct ActiveParameter { pub ty: Type, - pub name: String, + pub pat: Either, } impl ActiveParameter { @@ -165,8 +165,14 @@ impl ActiveParameter { return None; } let (pat, ty) = params.swap_remove(idx); - let name = pat?.to_string(); - Some(ActiveParameter { ty, name }) + pat.map(|pat| ActiveParameter { ty, pat }) + } + + pub fn ident(&self) -> Option { + self.pat.as_ref().right().and_then(|param| match param { + ast::Pat::IdentPat(ident) => ident.name(), + _ => None, + }) } } -- cgit v1.2.3