mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 17:28:09 +00:00
Merge #2860
2860: Minimize visibility r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
04b8bda515
3 changed files with 12 additions and 6 deletions
|
@ -63,7 +63,7 @@ impl CargoTargetSpec {
|
|||
None => return Ok(None),
|
||||
};
|
||||
let file_id = world.analysis().crate_root(crate_id)?;
|
||||
let path = world.vfs.read().file2path(ra_vfs::VfsFile(file_id.0));
|
||||
let path = world.file_id_to_path(file_id);
|
||||
let res = world.workspaces.iter().find_map(|ws| match ws {
|
||||
ProjectWorkspace::Cargo { cargo, .. } => {
|
||||
let tgt = cargo.target_by_root(&path)?;
|
||||
|
|
|
@ -681,10 +681,12 @@ pub fn handle_code_action(
|
|||
continue;
|
||||
}
|
||||
|
||||
let edits = vec![TextEdit::new(fix.location.range, fix.replacement.clone())];
|
||||
let mut edit_map = std::collections::HashMap::new();
|
||||
edit_map.insert(fix.location.uri.clone(), edits);
|
||||
let edit = WorkspaceEdit::new(edit_map);
|
||||
let edit = {
|
||||
let edits = vec![TextEdit::new(fix.location.range, fix.replacement.clone())];
|
||||
let mut edit_map = std::collections::HashMap::new();
|
||||
edit_map.insert(fix.location.uri.clone(), edits);
|
||||
WorkspaceEdit::new(edit_map)
|
||||
};
|
||||
|
||||
let action = CodeAction {
|
||||
title: fix.title.clone(),
|
||||
|
|
|
@ -62,9 +62,9 @@ pub struct WorldSnapshot {
|
|||
pub options: Options,
|
||||
pub workspaces: Arc<Vec<ProjectWorkspace>>,
|
||||
pub analysis: Analysis,
|
||||
pub vfs: Arc<RwLock<Vfs>>,
|
||||
pub latest_requests: Arc<RwLock<LatestRequests>>,
|
||||
pub check_watcher: Arc<RwLock<CheckState>>,
|
||||
vfs: Arc<RwLock<Vfs>>,
|
||||
}
|
||||
|
||||
impl WorldState {
|
||||
|
@ -265,6 +265,10 @@ impl WorldSnapshot {
|
|||
Ok(url)
|
||||
}
|
||||
|
||||
pub fn file_id_to_path(&self, id: FileId) -> PathBuf {
|
||||
self.vfs.read().file2path(VfsFile(id.0))
|
||||
}
|
||||
|
||||
pub fn file_line_endings(&self, id: FileId) -> LineEndings {
|
||||
self.vfs.read().file_line_endings(VfsFile(id.0))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue