From f1f2804c71ee997e36904dea72911104b2e2375b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 22 Dec 2018 01:59:32 +0300 Subject: move completion items to conv --- crates/ra_lsp_server/src/main_loop/handlers.rs | 29 ++++---------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 2dfeb061a..252d1ba3e 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -2,13 +2,13 @@ use std::collections::HashMap; use gen_lsp_server::ErrorCode; use languageserver_types::{ - CodeActionResponse, Command, CompletionItem, CompletionItemKind, Diagnostic, + CodeActionResponse, Command, Diagnostic, DiagnosticSeverity, DocumentSymbol, Documentation, FoldingRange, FoldingRangeKind, - FoldingRangeParams, InsertTextFormat, Location, MarkupContent, MarkupKind, MarkedString, Position, + FoldingRangeParams, Location, MarkupContent, MarkupKind, MarkedString, Position, PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, }; -use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition, InsertText}; +use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition}; use ra_syntax::{TextUnit, text_utils::intersect}; use ra_text_edit::text_utils::contains_offset_nonstrict; use rustc_hash::FxHashMap; @@ -419,28 +419,7 @@ pub fn handle_completion( None => return Ok(None), Some(items) => items, }; - let items = items - .into_iter() - .map(|item| { - let mut res = CompletionItem { - label: item.label().to_string(), - filter_text: Some(item.lookup().to_string()), - ..Default::default() - }; - 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(); + let items = items.into_iter().map(|item| item.conv()).collect(); Ok(Some(req::CompletionResponse::Array(items))) } -- cgit v1.2.3