mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
7900: show function params in completion detail r=matklad a=JoshMcguigan This resolves #7842 by updating the detail for function completions from `-> T` to `fn(T, U) -> V`. I added an expicit unit test for this, `ide_completion::render::fn_detail_includes_args_and_return_type`, which passes. Lots of other unit tests fail (~60 of them) due to this change, although I believe the failures are purely cosmetic (they were testing the exact format of this output). I'm happy to go update those tests, but before I do that I'd like to make sure this is in fact the format we want for the detail? edit - I realized `UPDATE_EXPECT=1 cargo test` automatically updates `expect!` tests. Big 👍 to whoever worked on that! So I'll go ahead and update all these tests soon. But I still would like to confirm `fn(T, U) -> V` is the desired content in the `detail` field. 8000: Use hir formatter for hover text r=matklad a=oxalica Fix #2765 , (should) fix #4665 Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com> Co-authored-by: oxalica <oxalicc@pm.me>
This commit is contained in:
commit
1a82af3527
21 changed files with 1058 additions and 212 deletions
|
@ -451,6 +451,44 @@ fn main() { Foo::Fo$0 }
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fn_detail_includes_args_and_return_type() {
|
||||
check(
|
||||
r#"
|
||||
fn foo<T>(a: u32, b: u32, t: T) -> (u32, T) { (a, t) }
|
||||
|
||||
fn main() { fo$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "foo(…)",
|
||||
source_range: 68..70,
|
||||
delete: 68..70,
|
||||
insert: "foo(${1:a}, ${2:b}, ${3:t})$0",
|
||||
kind: SymbolKind(
|
||||
Function,
|
||||
),
|
||||
lookup: "foo",
|
||||
detail: "fn(u32, u32, T) -> (u32, T)",
|
||||
trigger_call_info: true,
|
||||
},
|
||||
CompletionItem {
|
||||
label: "main()",
|
||||
source_range: 68..70,
|
||||
delete: 68..70,
|
||||
insert: "main()$0",
|
||||
kind: SymbolKind(
|
||||
Function,
|
||||
),
|
||||
lookup: "main",
|
||||
detail: "fn()",
|
||||
},
|
||||
]
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enum_detail_just_parentheses_for_unit() {
|
||||
check(
|
||||
|
@ -538,7 +576,7 @@ fn main() { let _: m::Spam = S$0 }
|
|||
Function,
|
||||
),
|
||||
lookup: "main",
|
||||
detail: "-> ()",
|
||||
detail: "fn()",
|
||||
},
|
||||
]
|
||||
"#]],
|
||||
|
@ -567,7 +605,7 @@ fn main() { som$0 }
|
|||
Function,
|
||||
),
|
||||
lookup: "main",
|
||||
detail: "-> ()",
|
||||
detail: "fn()",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "something_deprecated()",
|
||||
|
@ -578,7 +616,7 @@ fn main() { som$0 }
|
|||
Function,
|
||||
),
|
||||
lookup: "something_deprecated",
|
||||
detail: "-> ()",
|
||||
detail: "fn()",
|
||||
deprecated: true,
|
||||
},
|
||||
CompletionItem {
|
||||
|
@ -590,7 +628,7 @@ fn main() { som$0 }
|
|||
Function,
|
||||
),
|
||||
lookup: "something_else_deprecated",
|
||||
detail: "-> ()",
|
||||
detail: "fn()",
|
||||
deprecated: true,
|
||||
},
|
||||
]
|
||||
|
@ -641,7 +679,7 @@ impl S {
|
|||
insert: "bar()$0",
|
||||
kind: Method,
|
||||
lookup: "bar",
|
||||
detail: "-> ()",
|
||||
detail: "fn(self)",
|
||||
documentation: Documentation(
|
||||
"Method docs",
|
||||
),
|
||||
|
@ -741,7 +779,7 @@ fn foo(s: S) { s.$0 }
|
|||
insert: "the_method()$0",
|
||||
kind: Method,
|
||||
lookup: "the_method",
|
||||
detail: "-> ()",
|
||||
detail: "fn(&self)",
|
||||
},
|
||||
]
|
||||
"#]],
|
||||
|
@ -1049,7 +1087,7 @@ fn main() {
|
|||
Function,
|
||||
),
|
||||
lookup: "foo",
|
||||
detail: "-> ()",
|
||||
detail: "fn(&mut S)",
|
||||
trigger_call_info: true,
|
||||
},
|
||||
CompletionItem {
|
||||
|
@ -1061,7 +1099,7 @@ fn main() {
|
|||
Function,
|
||||
),
|
||||
lookup: "main",
|
||||
detail: "-> ()",
|
||||
detail: "fn()",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "s",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue