aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-01-16 10:59:03 +0000
committerGitHub <[email protected]>2020-01-16 10:59:03 +0000
commit04b8bda51582b06c5af8bf2fbacd58f264c9f6f0 (patch)
treeb06e700f4a8a038252852618f4a5ada06ca69f5b /crates
parentc78d269b66dd7e02321bf447eef1375c81f66a1e (diff)
parentbd96d0b258437cbfcaba5d0a6a79813eaa5f29fe (diff)
Merge #2860
2860: Minimize visibility r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_lsp_server/src/cargo_target_spec.rs2
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs10
-rw-r--r--crates/ra_lsp_server/src/world.rs6
3 files changed, 12 insertions, 6 deletions
diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs
index c4a9e7101..594caffe2 100644
--- a/crates/ra_lsp_server/src/cargo_target_spec.rs
+++ b/crates/ra_lsp_server/src/cargo_target_spec.rs
@@ -63,7 +63,7 @@ impl CargoTargetSpec {
63 None => return Ok(None), 63 None => return Ok(None),
64 }; 64 };
65 let file_id = world.analysis().crate_root(crate_id)?; 65 let file_id = world.analysis().crate_root(crate_id)?;
66 let path = world.vfs.read().file2path(ra_vfs::VfsFile(file_id.0)); 66 let path = world.file_id_to_path(file_id);
67 let res = world.workspaces.iter().find_map(|ws| match ws { 67 let res = world.workspaces.iter().find_map(|ws| match ws {
68 ProjectWorkspace::Cargo { cargo, .. } => { 68 ProjectWorkspace::Cargo { cargo, .. } => {
69 let tgt = cargo.target_by_root(&path)?; 69 let tgt = cargo.target_by_root(&path)?;
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 9e9964880..8e43f0575 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -681,10 +681,12 @@ pub fn handle_code_action(
681 continue; 681 continue;
682 } 682 }
683 683
684 let edits = vec![TextEdit::new(fix.location.range, fix.replacement.clone())]; 684 let edit = {
685 let mut edit_map = std::collections::HashMap::new(); 685 let edits = vec![TextEdit::new(fix.location.range, fix.replacement.clone())];
686 edit_map.insert(fix.location.uri.clone(), edits); 686 let mut edit_map = std::collections::HashMap::new();
687 let edit = WorkspaceEdit::new(edit_map); 687 edit_map.insert(fix.location.uri.clone(), edits);
688 WorkspaceEdit::new(edit_map)
689 };
688 690
689 let action = CodeAction { 691 let action = CodeAction {
690 title: fix.title.clone(), 692 title: fix.title.clone(),
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs
index 7a3030a51..e7a0acfc7 100644
--- a/crates/ra_lsp_server/src/world.rs
+++ b/crates/ra_lsp_server/src/world.rs
@@ -62,9 +62,9 @@ pub struct WorldSnapshot {
62 pub options: Options, 62 pub options: Options,
63 pub workspaces: Arc<Vec<ProjectWorkspace>>, 63 pub workspaces: Arc<Vec<ProjectWorkspace>>,
64 pub analysis: Analysis, 64 pub analysis: Analysis,
65 pub vfs: Arc<RwLock<Vfs>>,
66 pub latest_requests: Arc<RwLock<LatestRequests>>, 65 pub latest_requests: Arc<RwLock<LatestRequests>>,
67 pub check_watcher: Arc<RwLock<CheckState>>, 66 pub check_watcher: Arc<RwLock<CheckState>>,
67 vfs: Arc<RwLock<Vfs>>,
68} 68}
69 69
70impl WorldState { 70impl WorldState {
@@ -265,6 +265,10 @@ impl WorldSnapshot {
265 Ok(url) 265 Ok(url)
266 } 266 }
267 267
268 pub fn file_id_to_path(&self, id: FileId) -> PathBuf {
269 self.vfs.read().file2path(VfsFile(id.0))
270 }
271
268 pub fn file_line_endings(&self, id: FileId) -> LineEndings { 272 pub fn file_line_endings(&self, id: FileId) -> LineEndings {
269 self.vfs.read().file_line_endings(VfsFile(id.0)) 273 self.vfs.read().file_line_endings(VfsFile(id.0))
270 } 274 }