diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-21 15:14:34 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-21 15:14:34 +0000 |
commit | 0dcea10616e173a513667e3c761dc06c8253366b (patch) | |
tree | 4652bd1f393540f2f5abdaaab367cfb0b46a10d6 /crates/ra_lsp_server/src | |
parent | 463e5af3f2ff54b74e4aeb73e75047c00b6339be (diff) | |
parent | 45232dfa689bafadf98b92ef30fd32ea9a5e9e7a (diff) |
Merge #312
312: Completion refactoring r=matklad a=matklad
Just a usual refactoring, turning a rather ad-hoc completion infra into something extensible
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 1751d7fa8..2dfeb061a 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -8,7 +8,7 @@ use languageserver_types::{ | |||
8 | PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, | 8 | PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, |
9 | WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, | 9 | WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, |
10 | }; | 10 | }; |
11 | use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition}; | 11 | use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition, InsertText}; |
12 | use ra_syntax::{TextUnit, text_utils::intersect}; | 12 | use ra_syntax::{TextUnit, text_utils::intersect}; |
13 | use ra_text_edit::text_utils::contains_offset_nonstrict; | 13 | use ra_text_edit::text_utils::contains_offset_nonstrict; |
14 | use rustc_hash::FxHashMap; | 14 | use rustc_hash::FxHashMap; |
@@ -423,15 +423,21 @@ pub fn handle_completion( | |||
423 | .into_iter() | 423 | .into_iter() |
424 | .map(|item| { | 424 | .map(|item| { |
425 | let mut res = CompletionItem { | 425 | let mut res = CompletionItem { |
426 | label: item.label, | 426 | label: item.label().to_string(), |
427 | filter_text: item.lookup, | 427 | filter_text: Some(item.lookup().to_string()), |
428 | ..Default::default() | 428 | ..Default::default() |
429 | }; | 429 | }; |
430 | if let Some(snip) = item.snippet { | 430 | match item.insert_text() { |
431 | res.insert_text = Some(snip); | 431 | InsertText::PlainText { text } => { |
432 | res.insert_text_format = Some(InsertTextFormat::Snippet); | 432 | res.insert_text = Some(text); |
433 | res.kind = Some(CompletionItemKind::Keyword); | 433 | res.insert_text_format = Some(InsertTextFormat::PlainText); |
434 | }; | 434 | } |
435 | InsertText::Snippet { text } => { | ||
436 | res.insert_text = Some(text); | ||
437 | res.insert_text_format = Some(InsertTextFormat::Snippet); | ||
438 | res.kind = Some(CompletionItemKind::Keyword); | ||
439 | } | ||
440 | } | ||
435 | res | 441 | res |
436 | }) | 442 | }) |
437 | .collect(); | 443 | .collect(); |