aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions.rs')
-rw-r--r--crates/ide_completion/src/completions.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/crates/ide_completion/src/completions.rs b/crates/ide_completion/src/completions.rs
index 78154bf3e..151bf3783 100644
--- a/crates/ide_completion/src/completions.rs
+++ b/crates/ide_completion/src/completions.rs
@@ -18,7 +18,7 @@ pub(crate) mod unqualified_path;
18 18
19use std::iter; 19use std::iter;
20 20
21use hir::{known, ModPath, ScopeDef, Type}; 21use hir::known;
22use ide_db::SymbolKind; 22use ide_db::SymbolKind;
23 23
24use crate::{ 24use crate::{
@@ -69,12 +69,17 @@ impl Completions {
69 items.into_iter().for_each(|item| self.add(item.into())) 69 items.into_iter().for_each(|item| self.add(item.into()))
70 } 70 }
71 71
72 pub(crate) fn add_field(&mut self, ctx: &CompletionContext, field: hir::Field, ty: &Type) { 72 pub(crate) fn add_field(&mut self, ctx: &CompletionContext, field: hir::Field, ty: &hir::Type) {
73 let item = render_field(RenderContext::new(ctx), field, ty); 73 let item = render_field(RenderContext::new(ctx), field, ty);
74 self.add(item); 74 self.add(item);
75 } 75 }
76 76
77 pub(crate) fn add_tuple_field(&mut self, ctx: &CompletionContext, field: usize, ty: &Type) { 77 pub(crate) fn add_tuple_field(
78 &mut self,
79 ctx: &CompletionContext,
80 field: usize,
81 ty: &hir::Type,
82 ) {
78 let item = render_tuple_field(RenderContext::new(ctx), field, ty); 83 let item = render_tuple_field(RenderContext::new(ctx), field, ty);
79 self.add(item); 84 self.add(item);
80 } 85 }
@@ -89,8 +94,8 @@ impl Completions {
89 pub(crate) fn add_resolution( 94 pub(crate) fn add_resolution(
90 &mut self, 95 &mut self,
91 ctx: &CompletionContext, 96 ctx: &CompletionContext,
92 local_name: String, 97 local_name: hir::Name,
93 resolution: &ScopeDef, 98 resolution: &hir::ScopeDef,
94 ) { 99 ) {
95 if let Some(item) = render_resolution(RenderContext::new(ctx), local_name, resolution) { 100 if let Some(item) = render_resolution(RenderContext::new(ctx), local_name, resolution) {
96 self.add(item); 101 self.add(item);
@@ -100,7 +105,7 @@ impl Completions {
100 pub(crate) fn add_macro( 105 pub(crate) fn add_macro(
101 &mut self, 106 &mut self,
102 ctx: &CompletionContext, 107 ctx: &CompletionContext,
103 name: Option<String>, 108 name: Option<hir::Name>,
104 macro_: hir::MacroDef, 109 macro_: hir::MacroDef,
105 ) { 110 ) {
106 let name = match name { 111 let name = match name {
@@ -116,7 +121,7 @@ impl Completions {
116 &mut self, 121 &mut self,
117 ctx: &CompletionContext, 122 ctx: &CompletionContext,
118 func: hir::Function, 123 func: hir::Function,
119 local_name: Option<String>, 124 local_name: Option<hir::Name>,
120 ) { 125 ) {
121 if let Some(item) = render_fn(RenderContext::new(ctx), None, local_name, func) { 126 if let Some(item) = render_fn(RenderContext::new(ctx), None, local_name, func) {
122 self.add(item) 127 self.add(item)
@@ -127,7 +132,7 @@ impl Completions {
127 &mut self, 132 &mut self,
128 ctx: &CompletionContext, 133 ctx: &CompletionContext,
129 func: hir::Function, 134 func: hir::Function,
130 local_name: Option<String>, 135 local_name: Option<hir::Name>,
131 ) { 136 ) {
132 if let Some(item) = render_method(RenderContext::new(ctx), None, local_name, func) { 137 if let Some(item) = render_method(RenderContext::new(ctx), None, local_name, func) {
133 self.add(item) 138 self.add(item)
@@ -149,7 +154,7 @@ impl Completions {
149 &mut self, 154 &mut self,
150 ctx: &CompletionContext, 155 ctx: &CompletionContext,
151 variant: hir::Variant, 156 variant: hir::Variant,
152 path: ModPath, 157 path: hir::ModPath,
153 ) { 158 ) {
154 if let Some(item) = render_variant_pat(RenderContext::new(ctx), variant, None, Some(path)) { 159 if let Some(item) = render_variant_pat(RenderContext::new(ctx), variant, None, Some(path)) {
155 self.add(item); 160 self.add(item);
@@ -183,7 +188,7 @@ impl Completions {
183 &mut self, 188 &mut self,
184 ctx: &CompletionContext, 189 ctx: &CompletionContext,
185 variant: hir::Variant, 190 variant: hir::Variant,
186 path: ModPath, 191 path: hir::ModPath,
187 ) { 192 ) {
188 let item = render_variant(RenderContext::new(ctx), None, None, variant, Some(path)); 193 let item = render_variant(RenderContext::new(ctx), None, None, variant, Some(path));
189 self.add(item); 194 self.add(item);
@@ -193,7 +198,7 @@ impl Completions {
193 &mut self, 198 &mut self,
194 ctx: &CompletionContext, 199 ctx: &CompletionContext,
195 variant: hir::Variant, 200 variant: hir::Variant,
196 local_name: Option<String>, 201 local_name: Option<hir::Name>,
197 ) { 202 ) {
198 let item = render_variant(RenderContext::new(ctx), None, local_name, variant, None); 203 let item = render_variant(RenderContext::new(ctx), None, local_name, variant, None);
199 self.add(item); 204 self.add(item);