Skip to content

Commit bd96d0b

Browse files
committed
Minimize visibility
1 parent c78d269 commit bd96d0b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

crates/ra_lsp_server/src/cargo_target_spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl CargoTargetSpec {
6363
None => return Ok(None),
6464
};
6565
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);
6767
let res = world.workspaces.iter().find_map(|ws| match ws {
6868
ProjectWorkspace::Cargo { cargo, .. } => {
6969
let tgt = cargo.target_by_root(&path)?;

crates/ra_lsp_server/src/main_loop/handlers.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,12 @@ pub fn handle_code_action(
681681
continue;
682682
}
683683

684-
let edits = vec![TextEdit::new(fix.location.range, fix.replacement.clone())];
685-
let mut edit_map = std::collections::HashMap::new();
686-
edit_map.insert(fix.location.uri.clone(), edits);
687-
let edit = WorkspaceEdit::new(edit_map);
684+
let edit = {
685+
let edits = vec![TextEdit::new(fix.location.range, fix.replacement.clone())];
686+
let mut edit_map = std::collections::HashMap::new();
687+
edit_map.insert(fix.location.uri.clone(), edits);
688+
WorkspaceEdit::new(edit_map)
689+
};
688690

689691
let action = CodeAction {
690692
title: fix.title.clone(),

crates/ra_lsp_server/src/world.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ pub struct WorldSnapshot {
6262
pub options: Options,
6363
pub workspaces: Arc<Vec<ProjectWorkspace>>,
6464
pub analysis: Analysis,
65-
pub vfs: Arc<RwLock<Vfs>>,
6665
pub latest_requests: Arc<RwLock<LatestRequests>>,
6766
pub check_watcher: Arc<RwLock<CheckState>>,
67+
vfs: Arc<RwLock<Vfs>>,
6868
}
6969

7070
impl WorldState {
@@ -265,6 +265,10 @@ impl WorldSnapshot {
265265
Ok(url)
266266
}
267267

268+
pub fn file_id_to_path(&self, id: FileId) -> PathBuf {
269+
self.vfs.read().file2path(VfsFile(id.0))
270+
}
271+
268272
pub fn file_line_endings(&self, id: FileId) -> LineEndings {
269273
self.vfs.read().file_line_endings(VfsFile(id.0))
270274
}

0 commit comments

Comments
 (0)