aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-21 22:59:32 +0000
committerAleksey Kladov <[email protected]>2018-12-21 22:59:32 +0000
commitf1f2804c71ee997e36904dea72911104b2e2375b (patch)
treee908c071563d91cfdbad64c6dc59f955804d8b1c /crates/ra_lsp_server/src/main_loop
parent328d123f5baeab8ff9a1f63a6744f6eec89818ab (diff)
move completion items to conv
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs29
1 files changed, 4 insertions, 25 deletions
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;
2 2
3use gen_lsp_server::ErrorCode; 3use gen_lsp_server::ErrorCode;
4use languageserver_types::{ 4use languageserver_types::{
5 CodeActionResponse, Command, CompletionItem, CompletionItemKind, Diagnostic, 5 CodeActionResponse, Command, Diagnostic,
6 DiagnosticSeverity, DocumentSymbol, Documentation, FoldingRange, FoldingRangeKind, 6 DiagnosticSeverity, DocumentSymbol, Documentation, FoldingRange, FoldingRangeKind,
7 FoldingRangeParams, InsertTextFormat, Location, MarkupContent, MarkupKind, MarkedString, Position, 7 FoldingRangeParams, Location, MarkupContent, MarkupKind, MarkedString, Position,
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};
11use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition, InsertText}; 11use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition};
12use ra_syntax::{TextUnit, text_utils::intersect}; 12use ra_syntax::{TextUnit, text_utils::intersect};
13use ra_text_edit::text_utils::contains_offset_nonstrict; 13use ra_text_edit::text_utils::contains_offset_nonstrict;
14use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
@@ -419,28 +419,7 @@ pub fn handle_completion(
419 None => return Ok(None), 419 None => return Ok(None),
420 Some(items) => items, 420 Some(items) => items,
421 }; 421 };
422 let items = items 422 let items = items.into_iter().map(|item| item.conv()).collect();
423 .into_iter()
424 .map(|item| {
425 let mut res = CompletionItem {
426 label: item.label().to_string(),
427 filter_text: Some(item.lookup().to_string()),
428 ..Default::default()
429 };
430 match item.insert_text() {
431 InsertText::PlainText { text } => {
432 res.insert_text = Some(text);
433 res.insert_text_format = Some(InsertTextFormat::PlainText);
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 }
441 res
442 })
443 .collect();
444 423
445 Ok(Some(req::CompletionResponse::Array(items))) 424 Ok(Some(req::CompletionResponse::Array(items)))
446} 425}