aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/presentation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion/presentation.rs')
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
new file mode 100644
index 000000000..6b2de56bc
--- /dev/null
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -0,0 +1,33 @@
1//! This modules takes care of rendering various defenitions as completion items.
2use hir::Docs;
3
4use crate::completion::{Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem};
5
6impl Completions {
7 pub(crate) fn add_field(
8 &mut self,
9 kind: CompletionKind,
10 ctx: &CompletionContext,
11 field: hir::StructField,
12 substs: &hir::Substs,
13 ) {
14 CompletionItem::new(kind, ctx.source_range(), field.name(ctx.db).to_string())
15 .kind(CompletionItemKind::Field)
16 .detail(field.ty(ctx.db).subst(substs).to_string())
17 .set_documentation(field.docs(ctx.db))
18 .add_to(self);
19 }
20
21 pub(crate) fn add_pos_field(
22 &mut self,
23 kind: CompletionKind,
24 ctx: &CompletionContext,
25 field: usize,
26 ty: &hir::Ty,
27 ) {
28 CompletionItem::new(kind, ctx.source_range(), field.to_string())
29 .kind(CompletionItemKind::Field)
30 .detail(ty.to_string())
31 .add_to(self);
32 }
33}