From bc0f79f74ad0ab4f663b94772ccbfabed1de625e Mon Sep 17 00:00:00 2001 From: gfreezy Date: Tue, 15 Jan 2019 00:09:03 +0800 Subject: rename mod --- crates/ra_lsp_server/src/main_loop.rs | 5 +-- crates/ra_lsp_server/src/main_loop/handlers.rs | 47 +++++++++++++++++--------- 2 files changed, 32 insertions(+), 20 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index c48c4dd9e..fa07b1942 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -411,10 +411,7 @@ struct PoolDispatcher<'a> { } impl<'a> PoolDispatcher<'a> { - fn on<'b, R>( - &'b mut self, - f: fn(ServerWorld, R::Params) -> Result, - ) -> Result<&'b mut Self> + fn on(&mut self, f: fn(ServerWorld, R::Params) -> Result) -> Result<&mut Self> where R: req::Request, R::Params: DeserializeOwned + Send + 'static, diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 11a705200..c010a6ddf 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -1,5 +1,3 @@ -use std::collections::HashMap; - use gen_lsp_server::ErrorCode; use lsp_types::{ CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, @@ -7,7 +5,7 @@ use lsp_types::{ FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, MarkupKind, ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range, RenameParams, SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, - WorkspaceEdit, + WorkspaceEdit, DocumentChanges, TextDocumentEdit, DocumentChangeOperation, ResourceOp }; use ra_ide_api::{ FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity, @@ -467,26 +465,43 @@ pub fn handle_rename(world: ServerWorld, params: RenameParams) -> Result>>(); - Ok(Some(WorkspaceEdit { - changes: Some(changes), + let text_document_ops = source_change + .file_system_edits + .drain(..) + .into_iter() + .map(|e| e.try_conv_with(&world)) + .collect::>>(); - // TODO: return this instead if client/server support it. See #144 - document_changes: None, + let mut document_changes = Vec::new(); + document_changes.extend( + text_document_edits? + .into_iter() + .map(DocumentChangeOperation::Edit), + ); + document_changes.extend( + text_document_ops? + .into_iter() + .map(DocumentChangeOperation::Op), + ); + + Ok(Some(WorkspaceEdit { + changes: None, + document_changes: Some(DocumentChanges::Operations(document_changes)), })) } -- cgit v1.2.3