From d42346fed61f706d68fe888631a41ea5f2752d7f Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Sat, 11 Apr 2020 22:54:18 +0200 Subject: Improve autocompletion by looking on the type and name Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_ide/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'crates/ra_ide/src/lib.rs') diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 5599f143f..357c01cdf 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -127,6 +127,21 @@ pub struct CallInfo { pub active_parameter: Option, } +impl CallInfo { + pub fn active_parameter_type(&self) -> Option { + if let Some(id) = self.active_parameter { + return self.signature.parameter_types.get(id).map(|param_ty| param_ty.clone()); + } + None + } + pub fn active_parameter_name(&self) -> Option { + if let Some(id) = self.active_parameter { + return self.signature.parameter_names.get(id).map(|param_ty| param_ty.clone()); + } + None + } +} + /// `AnalysisHost` stores the current state of the world. #[derive(Debug)] pub struct AnalysisHost { -- cgit v1.2.3