Skip to content

Commit 9c6e93c

Browse files
committed
Simplify responses by using into()
1 parent 3f44aaf commit 9c6e93c

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/gen_lsp_server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
88
description = "Generic LSP server scaffold."
99

1010
[dependencies]
11-
lsp-types = { git = "https://github.com/kjeremy/languageserver-types", branch = "flatten" }
11+
lsp-types = "0.59.0"
1212
log = "0.4.3"
1313
serde_json = "1.0.34"
1414
serde = { version = "1.0.83", features = ["derive"] }

crates/ra_lsp_server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ crossbeam-channel = "0.3.5"
1313
flexi_logger = "0.13.0"
1414
log = "0.4.3"
1515
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"] }
1717
rustc-hash = "1.0"
1818
parking_lot = "0.8.0"
1919

crates/ra_lsp_server/src/main_loop/handlers.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::{fmt::Write as _, io::Write as _};
22

33
use gen_lsp_server::ErrorCode;
44
use lsp_types::{
5-
CodeAction, CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity,
6-
DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeKind,
7-
FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, MarkupKind, Position,
8-
PrepareRenameResponse, Range, RenameParams, SymbolInformation, TextDocumentIdentifier,
9-
TextEdit, WorkspaceEdit,
5+
CodeAction, CodeActionResponse, CodeLens, Command, CompletionItem, Diagnostic,
6+
DiagnosticSeverity, DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange,
7+
FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent,
8+
MarkupKind, Position, PrepareRenameResponse, Range, RenameParams, SymbolInformation,
9+
TextDocumentIdentifier, TextEdit, WorkspaceEdit,
1010
};
1111
use ra_ide_api::{
1212
AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo,
@@ -212,7 +212,7 @@ pub fn handle_document_symbol(
212212
}
213213
}
214214

215-
Ok(Some(req::DocumentSymbolResponse::Nested(res)))
215+
Ok(Some(res.into()))
216216
}
217217

218218
pub fn handle_workspace_symbol(
@@ -275,7 +275,7 @@ pub fn handle_goto_definition(
275275
.map(|nav| RangeInfo::new(nav_range, nav))
276276
.map(|nav| to_location_link(&nav, &world, &line_index))
277277
.collect::<Result<Vec<_>>>()?;
278-
Ok(Some(req::GotoDefinitionResponse::Link(res)))
278+
Ok(Some(res.into()))
279279
}
280280

281281
pub fn handle_goto_implementation(
@@ -295,7 +295,7 @@ pub fn handle_goto_implementation(
295295
.map(|nav| RangeInfo::new(nav_range, nav))
296296
.map(|nav| to_location_link(&nav, &world, &line_index))
297297
.collect::<Result<Vec<_>>>()?;
298-
Ok(Some(req::GotoDefinitionResponse::Link(res)))
298+
Ok(Some(res.into()))
299299
}
300300

301301
pub fn handle_goto_type_definition(
@@ -315,7 +315,7 @@ pub fn handle_goto_type_definition(
315315
.map(|nav| RangeInfo::new(nav_range, nav))
316316
.map(|nav| to_location_link(&nav, &world, &line_index))
317317
.collect::<Result<Vec<_>>>()?;
318-
Ok(Some(req::GotoDefinitionResponse::Link(res)))
318+
Ok(Some(res.into()))
319319
}
320320

321321
pub fn handle_parent_module(
@@ -433,9 +433,10 @@ pub fn handle_completion(
433433
Some(items) => items,
434434
};
435435
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();
437438

438-
Ok(Some(req::CompletionResponse::Array(items)))
439+
Ok(Some(items.into()))
439440
}
440441

441442
pub fn handle_folding_range(

0 commit comments

Comments
 (0)