diff options
author | Kevin DeLorey <[email protected]> | 2020-02-05 04:04:57 +0000 |
---|---|---|
committer | Kevin DeLorey <[email protected]> | 2020-02-05 04:04:57 +0000 |
commit | fc46ed81ee54d342d83e428ca74cbb0083547251 (patch) | |
tree | 4f81d8e27f25abf0eb133f260f1829a3ee52f3d2 /crates/ra_ide/src/completion/presentation.rs | |
parent | 698ff91c1309b189ca0f08e3d62d219305ae5f46 (diff) |
Add detection for a user already starting a fn impl and still providing completion.
Diffstat (limited to 'crates/ra_ide/src/completion/presentation.rs')
-rw-r--r-- | crates/ra_ide/src/completion/presentation.rs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 0689013ba..97475fc0b 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs | |||
@@ -129,39 +129,6 @@ impl Completions { | |||
129 | self.add_function_with_name(ctx, None, func) | 129 | self.add_function_with_name(ctx, None, func) |
130 | } | 130 | } |
131 | 131 | ||
132 | pub(crate) fn add_function_impl(&mut self, ctx: &CompletionContext, func: &hir::Function) { | ||
133 | use crate::display::FunctionSignature; | ||
134 | |||
135 | let display = FunctionSignature::from_hir(ctx.db, func.clone()); | ||
136 | |||
137 | let func_name = func.name(ctx.db); | ||
138 | |||
139 | let mut builder = CompletionItem::new( | ||
140 | CompletionKind::Reference, | ||
141 | ctx.source_range(), | ||
142 | format!("fn {}()", func_name.to_string())) | ||
143 | .set_documentation(func.docs(ctx.db)); | ||
144 | |||
145 | let completion_kind = if func.has_self_param(ctx.db) { | ||
146 | CompletionItemKind::Method | ||
147 | } else { | ||
148 | CompletionItemKind::Function | ||
149 | }; | ||
150 | |||
151 | let snippet = { | ||
152 | let mut s = format!("{}", display); | ||
153 | s.push_str(" { $0}"); | ||
154 | s | ||
155 | }; | ||
156 | |||
157 | builder = builder | ||
158 | .insert_text(snippet) | ||
159 | .kind(completion_kind) | ||
160 | .lookup_by(func_name.to_string()); | ||
161 | |||
162 | self.add(builder.build()); | ||
163 | } | ||
164 | |||
165 | fn guess_macro_braces(&self, macro_name: &str, docs: &str) -> &'static str { | 132 | fn guess_macro_braces(&self, macro_name: &str, docs: &str) -> &'static str { |
166 | let mut votes = [0, 0, 0]; | 133 | let mut votes = [0, 0, 0]; |
167 | for (idx, s) in docs.match_indices(¯o_name) { | 134 | for (idx, s) in docs.match_indices(¯o_name) { |