mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Merge #1981
1981: tweak fn labels in completion r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
da190278e9
4 changed files with 33 additions and 36 deletions
|
@ -121,7 +121,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "foo(…)",
|
||||
label: "foo()",
|
||||
source_range: [187; 187),
|
||||
delete: [187; 187),
|
||||
insert: "foo()$0",
|
||||
|
@ -161,7 +161,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "foo(…)",
|
||||
label: "foo()",
|
||||
source_range: [126; 126),
|
||||
delete: [126; 126),
|
||||
insert: "foo()$0",
|
||||
|
@ -214,7 +214,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "the_method(…)",
|
||||
label: "the_method()",
|
||||
source_range: [144; 144),
|
||||
delete: [144; 144),
|
||||
insert: "the_method()$0",
|
||||
|
@ -243,7 +243,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "the_method(…)",
|
||||
label: "the_method()",
|
||||
source_range: [151; 151),
|
||||
delete: [151; 151),
|
||||
insert: "the_method()$0",
|
||||
|
@ -272,7 +272,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "the_method(…)",
|
||||
label: "the_method()",
|
||||
source_range: [155; 155),
|
||||
delete: [155; 155),
|
||||
insert: "the_method()$0",
|
||||
|
@ -324,7 +324,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "the_method(…)",
|
||||
label: "the_method()",
|
||||
source_range: [249; 249),
|
||||
delete: [249; 249),
|
||||
insert: "the_method()$0",
|
||||
|
@ -394,7 +394,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "blah(…)",
|
||||
label: "blah()",
|
||||
source_range: [299; 300),
|
||||
delete: [299; 300),
|
||||
insert: "blah()$0",
|
||||
|
|
|
@ -378,7 +378,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "m(…)",
|
||||
label: "m()",
|
||||
source_range: [100; 100),
|
||||
delete: [100; 100),
|
||||
insert: "m()$0",
|
||||
|
@ -480,7 +480,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "m(…)",
|
||||
label: "m()",
|
||||
source_range: [100; 100),
|
||||
delete: [100; 100),
|
||||
insert: "m()$0",
|
||||
|
@ -516,7 +516,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "m(…)",
|
||||
label: "m()",
|
||||
source_range: [101; 101),
|
||||
delete: [101; 101),
|
||||
insert: "m()$0",
|
||||
|
@ -576,7 +576,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "bar(…)",
|
||||
label: "bar()",
|
||||
source_range: [185; 185),
|
||||
delete: [185; 185),
|
||||
insert: "bar()$0",
|
||||
|
@ -585,7 +585,7 @@ mod tests {
|
|||
detail: "fn bar()",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "foo(…)",
|
||||
label: "foo()",
|
||||
source_range: [185; 185),
|
||||
delete: [185; 185),
|
||||
insert: "foo()$0",
|
||||
|
@ -624,7 +624,7 @@ mod tests {
|
|||
detail: "#[macro_export]\nmacro_rules! foo",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "main(…)",
|
||||
label: "main()",
|
||||
source_range: [179; 179),
|
||||
delete: [179; 179),
|
||||
insert: "main()$0",
|
||||
|
|
|
@ -211,7 +211,7 @@ mod tests {
|
|||
detail: "i32",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "quux(…)",
|
||||
label: "quux()",
|
||||
source_range: [242; 242),
|
||||
delete: [242; 242),
|
||||
insert: "quux()$0",
|
||||
|
@ -239,7 +239,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "quux(…)",
|
||||
label: "quux()",
|
||||
source_range: [95; 95),
|
||||
delete: [95; 95),
|
||||
insert: "quux()$0",
|
||||
|
@ -279,7 +279,7 @@ mod tests {
|
|||
kind: TypeParam,
|
||||
},
|
||||
CompletionItem {
|
||||
label: "quux(…)",
|
||||
label: "quux()",
|
||||
source_range: [52; 52),
|
||||
delete: [52; 52),
|
||||
insert: "quux()$0",
|
||||
|
@ -384,7 +384,7 @@ mod tests {
|
|||
kind: Struct,
|
||||
},
|
||||
CompletionItem {
|
||||
label: "quux(…)",
|
||||
label: "quux()",
|
||||
source_range: [105; 105),
|
||||
delete: [105; 105),
|
||||
insert: "quux()$0",
|
||||
|
@ -443,7 +443,7 @@ mod tests {
|
|||
kind: Struct,
|
||||
},
|
||||
CompletionItem {
|
||||
label: "quux(…)",
|
||||
label: "quux()",
|
||||
source_range: [117; 117),
|
||||
delete: [117; 117),
|
||||
insert: "quux()$0",
|
||||
|
@ -475,7 +475,7 @@ mod tests {
|
|||
kind: Struct,
|
||||
},
|
||||
CompletionItem {
|
||||
label: "x(…)",
|
||||
label: "x()",
|
||||
source_range: [55; 55),
|
||||
delete: [55; 55),
|
||||
insert: "x()$0",
|
||||
|
@ -513,7 +513,7 @@ mod tests {
|
|||
detail: "i32",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "foo(…)",
|
||||
label: "foo()",
|
||||
source_range: [146; 146),
|
||||
delete: [146; 146),
|
||||
insert: "foo()$0",
|
||||
|
@ -577,7 +577,7 @@ mod tests {
|
|||
kind: Struct,
|
||||
},
|
||||
CompletionItem {
|
||||
label: "foo(…)",
|
||||
label: "foo()",
|
||||
source_range: [18; 18),
|
||||
delete: [18; 18),
|
||||
insert: "foo()$0",
|
||||
|
@ -671,7 +671,7 @@ mod tests {
|
|||
kind: Module,
|
||||
},
|
||||
CompletionItem {
|
||||
label: "main(…)",
|
||||
label: "main()",
|
||||
source_range: [252; 252),
|
||||
delete: [252; 252),
|
||||
insert: "main()$0",
|
||||
|
@ -710,7 +710,7 @@ mod tests {
|
|||
detail: "macro_rules! foo",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "foo(…)",
|
||||
label: "foo()",
|
||||
source_range: [49; 49),
|
||||
delete: [49; 49),
|
||||
insert: "foo()$0",
|
||||
|
@ -749,7 +749,7 @@ mod tests {
|
|||
detail: "macro_rules! foo",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "main(…)",
|
||||
label: "main()",
|
||||
source_range: [57; 57),
|
||||
delete: [57; 57),
|
||||
insert: "main()$0",
|
||||
|
@ -788,7 +788,7 @@ mod tests {
|
|||
detail: "macro_rules! foo",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "main(…)",
|
||||
label: "main()",
|
||||
source_range: [50; 50),
|
||||
delete: [50; 50),
|
||||
insert: "main()$0",
|
||||
|
|
|
@ -188,16 +188,13 @@ impl Completions {
|
|||
&& ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis")
|
||||
{
|
||||
tested_by!(inserts_parens_for_function_calls);
|
||||
let snippet =
|
||||
let (snippet, label) =
|
||||
if data.params().is_empty() || data.has_self_param() && data.params().len() == 1 {
|
||||
format!("{}()$0", data.name())
|
||||
(format!("{}()$0", data.name()), format!("{}()", name))
|
||||
} else {
|
||||
format!("{}($0)", data.name())
|
||||
(format!("{}($0)", data.name()), format!("{}(…)", name))
|
||||
};
|
||||
builder = builder
|
||||
.lookup_by(name.clone())
|
||||
.label(format!("{}(…)", name))
|
||||
.insert_snippet(snippet);
|
||||
builder = builder.lookup_by(name.clone()).label(label).insert_snippet(snippet);
|
||||
}
|
||||
|
||||
self.add(builder)
|
||||
|
@ -279,7 +276,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "main(…)",
|
||||
label: "main()",
|
||||
source_range: [61; 64),
|
||||
delete: [61; 64),
|
||||
insert: "main()$0",
|
||||
|
@ -288,7 +285,7 @@ mod tests {
|
|||
detail: "fn main()",
|
||||
},
|
||||
CompletionItem {
|
||||
label: "no_args(…)",
|
||||
label: "no_args()",
|
||||
source_range: [61; 64),
|
||||
delete: [61; 64),
|
||||
insert: "no_args()$0",
|
||||
|
@ -309,7 +306,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "main(…)",
|
||||
label: "main()",
|
||||
source_range: [80; 85),
|
||||
delete: [80; 85),
|
||||
insert: "main()$0",
|
||||
|
@ -344,7 +341,7 @@ mod tests {
|
|||
@r###"
|
||||
[
|
||||
CompletionItem {
|
||||
label: "foo(…)",
|
||||
label: "foo()",
|
||||
source_range: [163; 164),
|
||||
delete: [163; 164),
|
||||
insert: "foo()$0",
|
||||
|
|
Loading…
Reference in a new issue