Merge pull request #19325 from Veykril/push-sxyvwwsmtxrr
Rank ADT constructors as constructors for completion scoring
This commit is contained in:
commit
129545f41c
2 changed files with 102 additions and 12 deletions
|
@ -1151,6 +1151,24 @@ fn main() { Foo::Fo$0 }
|
|||
),
|
||||
lookup: "Foo{}",
|
||||
detail: "Foo { x: i32, y: i32 }",
|
||||
relevance: CompletionRelevance {
|
||||
exact_name_match: false,
|
||||
type_match: None,
|
||||
is_local: false,
|
||||
trait_: None,
|
||||
is_name_already_imported: false,
|
||||
requires_import: false,
|
||||
is_private_editable: false,
|
||||
postfix_match: None,
|
||||
function: Some(
|
||||
CompletionRelevanceFn {
|
||||
has_params: true,
|
||||
has_self_param: false,
|
||||
return_type: DirectConstructor,
|
||||
},
|
||||
),
|
||||
is_skipping_completion: false,
|
||||
},
|
||||
trigger_call_info: true,
|
||||
},
|
||||
]
|
||||
|
@ -1183,6 +1201,24 @@ fn main() { Foo::Fo$0 }
|
|||
),
|
||||
lookup: "Foo()",
|
||||
detail: "Foo(i32, i32)",
|
||||
relevance: CompletionRelevance {
|
||||
exact_name_match: false,
|
||||
type_match: None,
|
||||
is_local: false,
|
||||
trait_: None,
|
||||
is_name_already_imported: false,
|
||||
requires_import: false,
|
||||
is_private_editable: false,
|
||||
postfix_match: None,
|
||||
function: Some(
|
||||
CompletionRelevanceFn {
|
||||
has_params: true,
|
||||
has_self_param: false,
|
||||
return_type: DirectConstructor,
|
||||
},
|
||||
),
|
||||
is_skipping_completion: false,
|
||||
},
|
||||
trigger_call_info: true,
|
||||
},
|
||||
]
|
||||
|
@ -1261,6 +1297,24 @@ fn main() { Foo::Fo$0 }
|
|||
Variant,
|
||||
),
|
||||
detail: "Foo",
|
||||
relevance: CompletionRelevance {
|
||||
exact_name_match: false,
|
||||
type_match: None,
|
||||
is_local: false,
|
||||
trait_: None,
|
||||
is_name_already_imported: false,
|
||||
requires_import: false,
|
||||
is_private_editable: false,
|
||||
postfix_match: None,
|
||||
function: Some(
|
||||
CompletionRelevanceFn {
|
||||
has_params: false,
|
||||
has_self_param: false,
|
||||
return_type: DirectConstructor,
|
||||
},
|
||||
),
|
||||
is_skipping_completion: false,
|
||||
},
|
||||
trigger_call_info: true,
|
||||
},
|
||||
]
|
||||
|
@ -1335,7 +1389,13 @@ fn main() { let _: m::Spam = S$0 }
|
|||
requires_import: false,
|
||||
is_private_editable: false,
|
||||
postfix_match: None,
|
||||
function: None,
|
||||
function: Some(
|
||||
CompletionRelevanceFn {
|
||||
has_params: true,
|
||||
has_self_param: false,
|
||||
return_type: DirectConstructor,
|
||||
},
|
||||
),
|
||||
is_skipping_completion: false,
|
||||
},
|
||||
trigger_call_info: true,
|
||||
|
@ -1365,7 +1425,13 @@ fn main() { let _: m::Spam = S$0 }
|
|||
requires_import: false,
|
||||
is_private_editable: false,
|
||||
postfix_match: None,
|
||||
function: None,
|
||||
function: Some(
|
||||
CompletionRelevanceFn {
|
||||
has_params: false,
|
||||
has_self_param: false,
|
||||
return_type: DirectConstructor,
|
||||
},
|
||||
),
|
||||
is_skipping_completion: false,
|
||||
},
|
||||
trigger_call_info: true,
|
||||
|
@ -1590,6 +1656,24 @@ use self::E::*;
|
|||
documentation: Documentation(
|
||||
"variant docs",
|
||||
),
|
||||
relevance: CompletionRelevance {
|
||||
exact_name_match: false,
|
||||
type_match: None,
|
||||
is_local: false,
|
||||
trait_: None,
|
||||
is_name_already_imported: false,
|
||||
requires_import: false,
|
||||
is_private_editable: false,
|
||||
postfix_match: None,
|
||||
function: Some(
|
||||
CompletionRelevanceFn {
|
||||
has_params: false,
|
||||
has_self_param: false,
|
||||
return_type: DirectConstructor,
|
||||
},
|
||||
),
|
||||
is_skipping_completion: false,
|
||||
},
|
||||
trigger_call_info: true,
|
||||
},
|
||||
CompletionItem {
|
||||
|
@ -2081,8 +2165,8 @@ fn main() {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
lc ssss S [type+local]
|
||||
st S S [type]
|
||||
lc ssss S [type+local]
|
||||
st S S [type]
|
||||
ex ssss [type]
|
||||
ex S [type]
|
||||
|
@ -2153,14 +2237,14 @@ fn main() {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
st S S []
|
||||
st &S [type]
|
||||
ex core::ops::Deref::deref(&t) [type_could_unify]
|
||||
lc m i32 [local]
|
||||
lc t T [local]
|
||||
lc &t [type+local]
|
||||
st S S []
|
||||
st &S [type]
|
||||
st S S []
|
||||
st &S [type]
|
||||
st T T []
|
||||
st &T [type]
|
||||
fn foo(…) fn(&S) []
|
||||
|
@ -2202,14 +2286,14 @@ fn main() {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
st S S []
|
||||
st &mut S [type]
|
||||
ex core::ops::DerefMut::deref_mut(&mut t) [type_could_unify]
|
||||
lc m i32 [local]
|
||||
lc t T [local]
|
||||
lc &mut t [type+local]
|
||||
st S S []
|
||||
st &mut S [type]
|
||||
st S S []
|
||||
st &mut S [type]
|
||||
st T T []
|
||||
st &mut T [type]
|
||||
fn foo(…) fn(&mut S) []
|
||||
|
@ -2306,9 +2390,9 @@ fn main() {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
ex core::ops::Deref::deref(&bar()) [type_could_unify]
|
||||
st S S []
|
||||
st &S [type]
|
||||
ex core::ops::Deref::deref(&bar()) [type_could_unify]
|
||||
st S S []
|
||||
st &S [type]
|
||||
st T T []
|
||||
|
@ -2827,11 +2911,11 @@ fn foo() {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
ev Foo::B Foo::B [type_could_unify]
|
||||
ev Foo::A(…) Foo::A(T) [type_could_unify]
|
||||
lc foo Foo<u32> [type+local]
|
||||
ex foo [type]
|
||||
ex Foo::B [type]
|
||||
ev Foo::A(…) Foo::A(T) [type_could_unify]
|
||||
ev Foo::B Foo::B [type_could_unify]
|
||||
en Foo Foo<{unknown}> [type_could_unify]
|
||||
fn foo() fn() []
|
||||
fn bar() fn() -> Foo<u8> []
|
||||
|
|
|
@ -8,7 +8,7 @@ use ide_db::{
|
|||
|
||||
use crate::{
|
||||
context::{CompletionContext, PathCompletionCtx, PathKind},
|
||||
item::{Builder, CompletionItem},
|
||||
item::{Builder, CompletionItem, CompletionRelevanceFn},
|
||||
render::{
|
||||
compute_type_match,
|
||||
variant::{
|
||||
|
@ -17,7 +17,7 @@ use crate::{
|
|||
},
|
||||
RenderContext,
|
||||
},
|
||||
CompletionItemKind, CompletionRelevance,
|
||||
CompletionItemKind, CompletionRelevance, CompletionRelevanceReturnType,
|
||||
};
|
||||
|
||||
pub(crate) fn render_variant_lit(
|
||||
|
@ -131,6 +131,12 @@ fn render(
|
|||
let ty = thing.ty(db);
|
||||
item.set_relevance(CompletionRelevance {
|
||||
type_match: compute_type_match(ctx.completion, &ty),
|
||||
// function is a misnomer here, this is more about constructor information
|
||||
function: Some(CompletionRelevanceFn {
|
||||
has_params: !fields.is_empty(),
|
||||
has_self_param: false,
|
||||
return_type: CompletionRelevanceReturnType::DirectConstructor,
|
||||
}),
|
||||
..ctx.completion_relevance()
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue