mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Display type when completing tuples
This commit is contained in:
parent
eaef729377
commit
52633b2a07
2 changed files with 55 additions and 1 deletions
|
@ -46,13 +46,14 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ty::Tuple(fields) => {
|
Ty::Tuple(fields) => {
|
||||||
for (i, _ty) in fields.iter().enumerate() {
|
for (i, ty) in fields.iter().enumerate() {
|
||||||
CompletionItem::new(
|
CompletionItem::new(
|
||||||
CompletionKind::Reference,
|
CompletionKind::Reference,
|
||||||
ctx.source_range(),
|
ctx.source_range(),
|
||||||
i.to_string(),
|
i.to_string(),
|
||||||
)
|
)
|
||||||
.kind(CompletionItemKind::Field)
|
.kind(CompletionItemKind::Field)
|
||||||
|
.detail(ty.to_string())
|
||||||
.add_to(acc);
|
.add_to(acc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,4 +175,17 @@ mod tests {
|
||||||
",
|
",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tuple_field_completion() {
|
||||||
|
check_ref_completion(
|
||||||
|
"tuple_field_completion",
|
||||||
|
r"
|
||||||
|
fn foo() {
|
||||||
|
let b = (0, 3.14);
|
||||||
|
b.<|>
|
||||||
|
}
|
||||||
|
",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
created: "2019-01-24T13:22:02.107228200+00:00"
|
||||||
|
creator: insta@0.5.2
|
||||||
|
expression: kind_completions
|
||||||
|
source: crates/ra_ide_api/src/completion/completion_item.rs
|
||||||
|
---
|
||||||
|
[
|
||||||
|
CompletionItem {
|
||||||
|
completion_kind: Reference,
|
||||||
|
label: "0",
|
||||||
|
kind: Some(
|
||||||
|
Field
|
||||||
|
),
|
||||||
|
detail: Some(
|
||||||
|
"i32"
|
||||||
|
),
|
||||||
|
documentation: None,
|
||||||
|
lookup: None,
|
||||||
|
insert_text: None,
|
||||||
|
insert_text_format: PlainText,
|
||||||
|
source_range: [75; 75),
|
||||||
|
text_edit: None
|
||||||
|
},
|
||||||
|
CompletionItem {
|
||||||
|
completion_kind: Reference,
|
||||||
|
label: "1",
|
||||||
|
kind: Some(
|
||||||
|
Field
|
||||||
|
),
|
||||||
|
detail: Some(
|
||||||
|
"f64"
|
||||||
|
),
|
||||||
|
documentation: None,
|
||||||
|
lookup: None,
|
||||||
|
insert_text: None,
|
||||||
|
insert_text_format: PlainText,
|
||||||
|
source_range: [75; 75),
|
||||||
|
text_edit: None
|
||||||
|
}
|
||||||
|
]
|
Loading…
Add table
Add a link
Reference in a new issue