Skip to content

Commit 3962b0d

Browse files
Merge #8027
8027: Completion context remove exact match method in favor of fields r=JoshMcguigan a=JoshMcguigan This is a minor cleanup PR following #8008. It removes the `expected_name_and_type` method on completion context in favor of using the fields. I thought this method was used in more places, or else it may have just made sense to make this change directly in #8008 🤷 Co-authored-by: Josh Mcguigan <[email protected]>
2 parents b245e8d + 67d59ae commit 3962b0d

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

crates/ide_completion/src/render.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ impl<'a> RenderContext<'a> {
118118
fn docs(&self, node: impl HasAttrs) -> Option<Documentation> {
119119
node.docs(self.db())
120120
}
121-
122-
// FIXME delete this method in favor of directly using the fields
123-
// on CompletionContext
124-
fn expected_name_and_type(&self) -> Option<(String, Type)> {
125-
Some((self.completion.expected_name.clone()?, self.completion.expected_type.clone()?))
126-
}
127121
}
128122

129123
/// Generic renderer for completion items.
@@ -249,8 +243,8 @@ impl<'a> Render<'a> {
249243
relevance.is_local = true;
250244
item.set_relevance(relevance);
251245

252-
if let Some((_expected_name, expected_type)) = self.ctx.expected_name_and_type() {
253-
if ty != expected_type {
246+
if let Some(expected_type) = self.ctx.completion.expected_type.as_ref() {
247+
if &ty != expected_type {
254248
if let Some(ty_without_ref) = expected_type.remove_ref() {
255249
if relevance_type_match(self.ctx.db().upcast(), &ty, &ty_without_ref) {
256250
cov_mark::hit!(suggest_ref);
@@ -322,10 +316,8 @@ impl<'a> Render<'a> {
322316
fn compute_relevance(ctx: &RenderContext, ty: &Type, name: &str) -> CompletionRelevance {
323317
let mut res = CompletionRelevance::default();
324318

325-
if let Some((expected_name, expected_type)) = ctx.expected_name_and_type() {
326-
res.exact_type_match = ty == &expected_type;
327-
res.exact_name_match = name == &expected_name;
328-
}
319+
res.exact_type_match = Some(ty) == ctx.completion.expected_type.as_ref();
320+
res.exact_name_match = Some(name) == ctx.completion.expected_name.as_deref();
329321

330322
res
331323
}

0 commit comments

Comments
 (0)