diff options
author | Jeremy Kolb <[email protected]> | 2019-07-07 22:28:21 +0100 |
---|---|---|
committer | Jeremy Kolb <[email protected]> | 2019-07-07 22:28:21 +0100 |
commit | 9c6e93cd6c108536015272b6a363ed5cc1d4fb44 (patch) | |
tree | 3da433526a8d98fa4913fb81423b47afa7c4fd65 /crates/ra_lsp_server | |
parent | 3f44aaf363be0669e618a8340fd91b47ae6344c4 (diff) |
Simplify responses by using into()
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 23 |
2 files changed, 13 insertions, 12 deletions
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 9c9dda01f..50bc8111b 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -13,7 +13,7 @@ crossbeam-channel = "0.3.5" | |||
13 | flexi_logger = "0.13.0" | 13 | flexi_logger = "0.13.0" |
14 | log = "0.4.3" | 14 | log = "0.4.3" |
15 | url_serde = "0.2.0" | 15 | url_serde = "0.2.0" |
16 | lsp-types = { git = "https://github.com/kjeremy/languageserver-types", branch = "flatten", features = ["proposed"] } | 16 | lsp-types = { version = "0.59.0", features = ["proposed"] } |
17 | rustc-hash = "1.0" | 17 | rustc-hash = "1.0" |
18 | parking_lot = "0.8.0" | 18 | parking_lot = "0.8.0" |
19 | 19 | ||
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 | ||
3 | use gen_lsp_server::ErrorCode; | 3 | use gen_lsp_server::ErrorCode; |
4 | use lsp_types::{ | 4 | use 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 | }; |
11 | use ra_ide_api::{ | 11 | use 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 | ||
218 | pub fn handle_workspace_symbol( | 218 | pub 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 | ||
281 | pub fn handle_goto_implementation( | 281 | pub 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 | ||
301 | pub fn handle_goto_type_definition( | 301 | pub 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 | ||
321 | pub fn handle_parent_module( | 321 | pub 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 | ||
441 | pub fn handle_folding_range( | 442 | pub fn handle_folding_range( |