aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgfreezy <[email protected]>2019-01-17 11:57:24 +0000
committerAleksey Kladov <[email protected]>2019-01-19 12:36:58 +0000
commit6ab6d1eaa036f8620542ad9c12764957e868b7e0 (patch)
tree4bd9a3bc5f99d25efafde8673f5c40825521f760
parent5c8cb56506646637e45a646657baf12fa9a8f49a (diff)
fix comments
-rw-r--r--crates/ra_ide_api/src/imp.rs5
-rw-r--r--crates/ra_ide_api/src/lib.rs2
-rw-r--r--crates/ra_ide_api/src/rename.rs4
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs34
4 files changed, 5 insertions, 40 deletions
diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs
index b52a3f4d5..fa79908a1 100644
--- a/crates/ra_ide_api/src/imp.rs
+++ b/crates/ra_ide_api/src/imp.rs
@@ -19,7 +19,6 @@ use crate::{
19 CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit, 19 CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit,
20 Query, RootChange, SourceChange, SourceFileEdit, 20 Query, RootChange, SourceChange, SourceFileEdit,
21 symbol_index::{FileSymbol, LibrarySymbolsQuery}, 21 symbol_index::{FileSymbol, LibrarySymbolsQuery},
22 rename::rename
23}; 22};
24 23
25impl db::RootDatabase { 24impl db::RootDatabase {
@@ -232,10 +231,6 @@ impl db::RootDatabase {
232 .collect() 231 .collect()
233 } 232 }
234 233
235 pub(crate) fn rename(&self, position: FilePosition, new_name: &str) -> Option<SourceChange> {
236 rename(self, position, new_name)
237 }
238
239 pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Vec<FileSymbol> { 234 pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
240 let name = name_ref.text(); 235 let name = name_ref.text();
241 let mut query = Query::new(name.to_string()); 236 let mut query = Query::new(name.to_string());
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 1845bf443..33bef178a 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -466,7 +466,7 @@ impl Analysis {
466 position: FilePosition, 466 position: FilePosition,
467 new_name: &str, 467 new_name: &str,
468 ) -> Cancelable<Option<SourceChange>> { 468 ) -> Cancelable<Option<SourceChange>> {
469 self.with_db(|db| db.rename(position, new_name)) 469 self.with_db(|db| rename::rename(db, position, new_name))
470 } 470 }
471 471
472 fn with_db<F: FnOnce(&db::RootDatabase) -> T + std::panic::UnwindSafe, T>( 472 fn with_db<F: FnOnce(&db::RootDatabase) -> T + std::panic::UnwindSafe, T>(
diff --git a/crates/ra_ide_api/src/rename.rs b/crates/ra_ide_api/src/rename.rs
index 9f8a00ae7..9ab6f2a77 100644
--- a/crates/ra_ide_api/src/rename.rs
+++ b/crates/ra_ide_api/src/rename.rs
@@ -40,9 +40,7 @@ fn find_name_and_module_at_offset(
40 position: FilePosition, 40 position: FilePosition,
41) -> Option<(&ast::Name, &ast::Module)> { 41) -> Option<(&ast::Name, &ast::Module)> {
42 let ast_name = find_node_at_offset::<ast::Name>(syntax, position.offset); 42 let ast_name = find_node_at_offset::<ast::Name>(syntax, position.offset);
43 let ast_name_parent = ast_name 43 let ast_name_parent = ast::Module::cast(ast_name?.syntax().parent()?);
44 .and_then(|n| n.syntax().parent())
45 .and_then(|p| ast::Module::cast(p));
46 44
47 if let (Some(ast_module), Some(name)) = (ast_name_parent, ast_name) { 45 if let (Some(ast_module), Some(name)) = (ast_name_parent, ast_name) {
48 return Some((name, ast_module)); 46 return Some((name, ast_module));
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index c010a6ddf..9cdca82c4 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -5,7 +5,7 @@ use lsp_types::{
5 FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, 5 FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent,
6 MarkupKind, ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range, 6 MarkupKind, ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range,
7 RenameParams, SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, 7 RenameParams, SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit,
8 WorkspaceEdit, DocumentChanges, TextDocumentEdit, DocumentChangeOperation, ResourceOp 8 WorkspaceEdit
9}; 9};
10use ra_ide_api::{ 10use ra_ide_api::{
11 FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity, 11 FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity,
@@ -472,37 +472,9 @@ pub fn handle_rename(world: ServerWorld, params: RenameParams) -> Result<Option<
472 return Ok(None); 472 return Ok(None);
473 } 473 }
474 474
475 let mut source_change = change.unwrap(); 475 let source_change_req = change.unwrap().try_conv_with(&world)?;
476 let text_document_edits = source_change
477 .source_file_edits
478 .drain(..)
479 .into_iter()
480 .map(|e| e.try_conv_with(&world))
481 .collect::<Result<Vec<TextDocumentEdit>>>();
482
483 let text_document_ops = source_change
484 .file_system_edits
485 .drain(..)
486 .into_iter()
487 .map(|e| e.try_conv_with(&world))
488 .collect::<Result<Vec<ResourceOp>>>();
489
490 let mut document_changes = Vec::new();
491 document_changes.extend(
492 text_document_edits?
493 .into_iter()
494 .map(DocumentChangeOperation::Edit),
495 );
496 document_changes.extend(
497 text_document_ops?
498 .into_iter()
499 .map(DocumentChangeOperation::Op),
500 );
501 476
502 Ok(Some(WorkspaceEdit { 477 Ok(Some(source_change_req.workspace_edit))
503 changes: None,
504 document_changes: Some(DocumentChanges::Operations(document_changes)),
505 }))
506} 478}
507 479
508pub fn handle_references( 480pub fn handle_references(