aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-03-09 14:39:22 +0000
committerAleksey Kladov <[email protected]>2021-03-09 14:39:22 +0000
commit2cc278c6ffa900d9fba8e19c5a1fc6996fbe6639 (patch)
tree927a604c36cd308d8aa39c3d098f31c4dbe5df22 /crates
parent21913d0fdb848445a908021dbcd4c3accf2ca0a5 (diff)
Fix bad names
`res` should only be used for the result variable
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/to_proto.rs52
1 files changed, 26 insertions, 26 deletions
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 4235eb6dd..261d9fb18 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -173,20 +173,20 @@ pub(crate) fn snippet_text_edit_vec(
173 173
174pub(crate) fn completion_item( 174pub(crate) fn completion_item(
175 line_index: &LineIndex, 175 line_index: &LineIndex,
176 completion_item: CompletionItem, 176 item: CompletionItem,
177) -> Vec<lsp_types::CompletionItem> { 177) -> Vec<lsp_types::CompletionItem> {
178 fn set_score(res: &mut lsp_types::CompletionItem, label: &str) { 178 fn set_score(lsp_item: &mut lsp_types::CompletionItem, label: &str) {
179 res.preselect = Some(true); 179 lsp_item.preselect = Some(true);
180 // HACK: sort preselect items first 180 // HACK: sort preselect items first
181 res.sort_text = Some(format!(" {}", label)); 181 lsp_item.sort_text = Some(format!(" {}", label));
182 } 182 }
183 183
184 let mut additional_text_edits = Vec::new(); 184 let mut additional_text_edits = Vec::new();
185 let mut text_edit = None; 185 let mut text_edit = None;
186 // LSP does not allow arbitrary edits in completion, so we have to do a 186 // LSP does not allow arbitrary edits in completion, so we have to do a
187 // non-trivial mapping here. 187 // non-trivial mapping here.
188 let source_range = completion_item.source_range(); 188 let source_range = item.source_range();
189 for indel in completion_item.text_edit().iter() { 189 for indel in item.text_edit().iter() {
190 if indel.delete.contains_range(source_range) { 190 if indel.delete.contains_range(source_range) {
191 text_edit = Some(if indel.delete == source_range { 191 text_edit = Some(if indel.delete == source_range {
192 self::text_edit(line_index, indel.clone()) 192 self::text_edit(line_index, indel.clone())
@@ -207,46 +207,46 @@ pub(crate) fn completion_item(
207 } 207 }
208 let text_edit = text_edit.unwrap(); 208 let text_edit = text_edit.unwrap();
209 209
210 let mut res = lsp_types::CompletionItem { 210 let mut lsp_item = lsp_types::CompletionItem {
211 label: completion_item.label().to_string(), 211 label: item.label().to_string(),
212 detail: completion_item.detail().map(|it| it.to_string()), 212 detail: item.detail().map(|it| it.to_string()),
213 filter_text: Some(completion_item.lookup().to_string()), 213 filter_text: Some(item.lookup().to_string()),
214 kind: completion_item.kind().map(completion_item_kind), 214 kind: item.kind().map(completion_item_kind),
215 text_edit: Some(text_edit.into()), 215 text_edit: Some(text_edit.into()),
216 additional_text_edits: Some(additional_text_edits), 216 additional_text_edits: Some(additional_text_edits),
217 documentation: completion_item.documentation().map(documentation), 217 documentation: item.documentation().map(documentation),
218 deprecated: Some(completion_item.deprecated()), 218 deprecated: Some(item.deprecated()),
219 ..Default::default() 219 ..Default::default()
220 }; 220 };
221 221
222 if completion_item.score().is_some() { 222 if item.score().is_some() {
223 set_score(&mut res, completion_item.label()); 223 set_score(&mut lsp_item, item.label());
224 } 224 }
225 225
226 if completion_item.deprecated() { 226 if item.deprecated() {
227 res.tags = Some(vec![lsp_types::CompletionItemTag::Deprecated]) 227 lsp_item.tags = Some(vec![lsp_types::CompletionItemTag::Deprecated])
228 } 228 }
229 229
230 if completion_item.trigger_call_info() { 230 if item.trigger_call_info() {
231 res.command = Some(command::trigger_parameter_hints()); 231 lsp_item.command = Some(command::trigger_parameter_hints());
232 } 232 }
233 233
234 let mut all_results = match completion_item.ref_match() { 234 let mut res = match item.ref_match() {
235 Some(ref_match) => { 235 Some(ref_match) => {
236 let mut refed = res.clone(); 236 let mut refed = lsp_item.clone();
237 let (mutability, _score) = ref_match; 237 let (mutability, _score) = ref_match;
238 let label = format!("&{}{}", mutability.as_keyword_for_ref(), refed.label); 238 let label = format!("&{}{}", mutability.as_keyword_for_ref(), refed.label);
239 set_score(&mut refed, &label); 239 set_score(&mut refed, &label);
240 refed.label = label; 240 refed.label = label;
241 vec![res, refed] 241 vec![lsp_item, refed]
242 } 242 }
243 None => vec![res], 243 None => vec![lsp_item],
244 }; 244 };
245 245
246 for mut r in all_results.iter_mut() { 246 for mut r in res.iter_mut() {
247 r.insert_text_format = Some(insert_text_format(completion_item.insert_text_format())); 247 r.insert_text_format = Some(insert_text_format(item.insert_text_format()));
248 } 248 }
249 all_results 249 res
250} 250}
251 251
252pub(crate) fn signature_help( 252pub(crate) fn signature_help(