mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
remove expected_name_and_type method on completion context in favor of using fields added in #8008
This commit is contained in:
parent
0ac7a19d0c
commit
67d59aeb7c
1 changed files with 4 additions and 12 deletions
|
@ -118,12 +118,6 @@ impl<'a> RenderContext<'a> {
|
||||||
fn docs(&self, node: impl HasAttrs) -> Option<Documentation> {
|
fn docs(&self, node: impl HasAttrs) -> Option<Documentation> {
|
||||||
node.docs(self.db())
|
node.docs(self.db())
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME delete this method in favor of directly using the fields
|
|
||||||
// on CompletionContext
|
|
||||||
fn expected_name_and_type(&self) -> Option<(String, Type)> {
|
|
||||||
Some((self.completion.expected_name.clone()?, self.completion.expected_type.clone()?))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generic renderer for completion items.
|
/// Generic renderer for completion items.
|
||||||
|
@ -249,8 +243,8 @@ impl<'a> Render<'a> {
|
||||||
relevance.is_local = true;
|
relevance.is_local = true;
|
||||||
item.set_relevance(relevance);
|
item.set_relevance(relevance);
|
||||||
|
|
||||||
if let Some((_expected_name, expected_type)) = self.ctx.expected_name_and_type() {
|
if let Some(expected_type) = self.ctx.completion.expected_type.as_ref() {
|
||||||
if ty != expected_type {
|
if &ty != expected_type {
|
||||||
if let Some(ty_without_ref) = expected_type.remove_ref() {
|
if let Some(ty_without_ref) = expected_type.remove_ref() {
|
||||||
if relevance_type_match(self.ctx.db().upcast(), &ty, &ty_without_ref) {
|
if relevance_type_match(self.ctx.db().upcast(), &ty, &ty_without_ref) {
|
||||||
cov_mark::hit!(suggest_ref);
|
cov_mark::hit!(suggest_ref);
|
||||||
|
@ -322,10 +316,8 @@ impl<'a> Render<'a> {
|
||||||
fn compute_relevance(ctx: &RenderContext, ty: &Type, name: &str) -> CompletionRelevance {
|
fn compute_relevance(ctx: &RenderContext, ty: &Type, name: &str) -> CompletionRelevance {
|
||||||
let mut res = CompletionRelevance::default();
|
let mut res = CompletionRelevance::default();
|
||||||
|
|
||||||
if let Some((expected_name, expected_type)) = ctx.expected_name_and_type() {
|
res.exact_type_match = Some(ty) == ctx.completion.expected_type.as_ref();
|
||||||
res.exact_type_match = ty == &expected_type;
|
res.exact_name_match = Some(name) == ctx.completion.expected_name.as_deref();
|
||||||
res.exact_name_match = name == &expected_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue