From 4092b8d0b58598d0b4b820fff37b1d8c741c47b9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 21 Dec 2018 15:19:46 +0300 Subject: make compleion item details private --- crates/ra_lsp_server/src/main_loop/handlers.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'crates/ra_lsp_server') 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::{ PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, }; -use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition}; +use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition, InsertText}; use ra_syntax::{TextUnit, text_utils::intersect}; use ra_text_edit::text_utils::contains_offset_nonstrict; use rustc_hash::FxHashMap; @@ -423,15 +423,21 @@ pub fn handle_completion( .into_iter() .map(|item| { let mut res = CompletionItem { - label: item.label, - filter_text: item.lookup, + label: item.label().to_string(), + filter_text: Some(item.lookup().to_string()), ..Default::default() }; - if let Some(snip) = item.snippet { - res.insert_text = Some(snip); - res.insert_text_format = Some(InsertTextFormat::Snippet); - res.kind = Some(CompletionItemKind::Keyword); - }; + match item.insert_text() { + InsertText::PlainText { text } => { + res.insert_text = Some(text); + res.insert_text_format = Some(InsertTextFormat::PlainText); + } + InsertText::Snippet { text } => { + res.insert_text = Some(text); + res.insert_text_format = Some(InsertTextFormat::Snippet); + res.kind = Some(CompletionItemKind::Keyword); + } + } res }) .collect(); -- cgit v1.2.3