aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
authorJeremy Kolb <[email protected]>2019-07-07 22:28:21 +0100
committerJeremy Kolb <[email protected]>2019-07-07 22:28:21 +0100
commit9c6e93cd6c108536015272b6a363ed5cc1d4fb44 (patch)
tree3da433526a8d98fa4913fb81423b47afa7c4fd65 /crates/ra_lsp_server/src
parent3f44aaf363be0669e618a8340fd91b47ae6344c4 (diff)
Simplify responses by using into()
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 6b407cb0c..62c8cbf71 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -2,11 +2,11 @@ use std::{fmt::Write as _, io::Write as _};
2 2
3use gen_lsp_server::ErrorCode; 3use gen_lsp_server::ErrorCode;
4use lsp_types::{ 4use lsp_types::{
5 CodeAction, CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, 5 CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic,
6 DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeKind, 6 DiagnosticSeverity, DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange,
7 FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, MarkupKind, Position, 7 FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent,
8 PrepareRenameResponse, Range, RenameParams, SymbolInformation, TextDocumentIdentifier, 8 MarkupKind, Position, PrepareRenameResponse, Range, RenameParams, SymbolInformation,
9 TextEdit, WorkspaceEdit, 9 TextDocumentIdentifier, TextEdit, WorkspaceEdit,
10}; 10};
11use ra_ide_api::{ 11use ra_ide_api::{
12 AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, 12 AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo,
@@ -212,7 +212,7 @@ pub fn handle_document_symbol(
212 } 212 }
213 } 213 }
214 214
215 Ok(Some(req::DocumentSymbolResponse::Nested(res))) 215 Ok(Some(res.into()))
216} 216}
217 217
218pub fn handle_workspace_symbol( 218pub fn handle_workspace_symbol(
@@ -275,7 +275,7 @@ pub fn handle_goto_definition(
275 .map(|nav| RangeInfo::new(nav_range, nav)) 275 .map(|nav| RangeInfo::new(nav_range, nav))
276 .map(|nav| to_location_link(&nav, &world, &line_index)) 276 .map(|nav| to_location_link(&nav, &world, &line_index))
277 .collect::<Result<Vec<_>>>()?; 277 .collect::<Result<Vec<_>>>()?;
278 Ok(Some(req::GotoDefinitionResponse::Link(res))) 278 Ok(Some(res.into()))
279} 279}
280 280
281pub fn handle_goto_implementation( 281pub fn handle_goto_implementation(
@@ -295,7 +295,7 @@ pub fn handle_goto_implementation(
295 .map(|nav| RangeInfo::new(nav_range, nav)) 295 .map(|nav| RangeInfo::new(nav_range, nav))
296 .map(|nav| to_location_link(&nav, &world, &line_index)) 296 .map(|nav| to_location_link(&nav, &world, &line_index))
297 .collect::<Result<Vec<_>>>()?; 297 .collect::<Result<Vec<_>>>()?;
298 Ok(Some(req::GotoDefinitionResponse::Link(res))) 298 Ok(Some(res.into()))
299} 299}
300 300
301pub fn handle_goto_type_definition( 301pub fn handle_goto_type_definition(
@@ -315,7 +315,7 @@ pub fn handle_goto_type_definition(
315 .map(|nav| RangeInfo::new(nav_range, nav)) 315 .map(|nav| RangeInfo::new(nav_range, nav))
316 .map(|nav| to_location_link(&nav, &world, &line_index)) 316 .map(|nav| to_location_link(&nav, &world, &line_index))
317 .collect::<Result<Vec<_>>>()?; 317 .collect::<Result<Vec<_>>>()?;
318 Ok(Some(req::GotoDefinitionResponse::Link(res))) 318 Ok(Some(res.into()))
319} 319}
320 320
321pub fn handle_parent_module( 321pub fn handle_parent_module(
@@ -433,9 +433,10 @@ pub fn handle_completion(
433 Some(items) => items, 433 Some(items) => items,
434 }; 434 };
435 let line_index = world.analysis().file_line_index(position.file_id); 435 let line_index = world.analysis().file_line_index(position.file_id);
436 let items = items.into_iter().map(|item| item.conv_with(&line_index)).collect(); 436 let items: Vec<CompletionItem> =
437 items.into_iter().map(|item| item.conv_with(&line_index)).collect();
437 438
438 Ok(Some(req::CompletionResponse::Array(items))) 439 Ok(Some(items.into()))
439} 440}
440 441
441pub fn handle_folding_range( 442pub fn handle_folding_range(