diff options
Diffstat (limited to 'crates/ra_ide/src/completion/completion_item.rs')
-rw-r--r-- | crates/ra_ide/src/completion/completion_item.rs | 42 |
1 files changed, 2 insertions, 40 deletions
diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs index a3ae9c86b..8b96b81db 100644 --- a/crates/ra_ide/src/completion/completion_item.rs +++ b/crates/ra_ide/src/completion/completion_item.rs | |||
@@ -305,46 +305,6 @@ impl Builder { | |||
305 | self | 305 | self |
306 | } | 306 | } |
307 | #[allow(unused)] | 307 | #[allow(unused)] |
308 | pub(crate) fn compute_score(mut self, ctx: &CompletionContext) -> Builder { | ||
309 | let (active_name, active_type) = if let Some(record_field) = &ctx.record_field_syntax { | ||
310 | if let Some((struct_field, _)) = ctx.sema.resolve_record_field(record_field) { | ||
311 | ( | ||
312 | struct_field.name(ctx.db).to_string(), | ||
313 | struct_field.signature_ty(ctx.db).display(ctx.db).to_string(), | ||
314 | ) | ||
315 | } else { | ||
316 | return self; | ||
317 | } | ||
318 | } else if let Some(call_info) = call_info(ctx.db, ctx.file_position) { | ||
319 | if call_info.active_parameter_type().is_some() | ||
320 | && call_info.active_parameter_name().is_some() | ||
321 | { | ||
322 | ( | ||
323 | call_info.active_parameter_name().unwrap(), | ||
324 | call_info.active_parameter_type().unwrap(), | ||
325 | ) | ||
326 | } else { | ||
327 | return self; | ||
328 | } | ||
329 | } else { | ||
330 | return self; | ||
331 | }; | ||
332 | |||
333 | // Compute score | ||
334 | // For the same type | ||
335 | if let Some(a_parameter_type) = &self.detail { | ||
336 | if &active_type == a_parameter_type { | ||
337 | // If same type + same name then go top position | ||
338 | if active_name == self.label { | ||
339 | return self.set_score(CompletionScore::TypeAndNameMatch); | ||
340 | } else { | ||
341 | return self.set_score(CompletionScore::TypeMatch); | ||
342 | } | ||
343 | } | ||
344 | } | ||
345 | |||
346 | self | ||
347 | } | ||
348 | pub(crate) fn set_score(mut self, score: CompletionScore) -> Builder { | 308 | pub(crate) fn set_score(mut self, score: CompletionScore) -> Builder { |
349 | self.score = Some(score); | 309 | self.score = Some(score); |
350 | self | 310 | self |
@@ -363,7 +323,9 @@ impl<'a> Into<CompletionItem> for Builder { | |||
363 | 323 | ||
364 | #[derive(Debug, Clone)] | 324 | #[derive(Debug, Clone)] |
365 | pub enum CompletionScore { | 325 | pub enum CompletionScore { |
326 | /// If only type match | ||
366 | TypeMatch, | 327 | TypeMatch, |
328 | /// If type and name match | ||
367 | TypeAndNameMatch, | 329 | TypeAndNameMatch, |
368 | } | 330 | } |
369 | 331 | ||