mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Support loading OUT_DIR from cargo check at launch
This commit is contained in:
parent
2720e2374b
commit
33c6c7abc6
10 changed files with 242 additions and 108 deletions
|
@ -54,12 +54,18 @@ pub(crate) fn load_cargo(
|
|||
|
||||
// FIXME: outdirs?
|
||||
let outdirs = FxHashMap::default();
|
||||
let extern_source_roots = FxHashMap::default();
|
||||
|
||||
let crate_graph = ws.to_crate_graph(&default_cfg_options, &outdirs, &mut |path: &Path| {
|
||||
let vfs_file = vfs.load(path);
|
||||
log::debug!("vfs file {:?} -> {:?}", path, vfs_file);
|
||||
vfs_file.map(vfs_file_to_id)
|
||||
});
|
||||
let crate_graph = ws.to_crate_graph(
|
||||
&default_cfg_options,
|
||||
&outdirs,
|
||||
&extern_source_roots,
|
||||
&mut |path: &Path| {
|
||||
let vfs_file = vfs.load(path);
|
||||
log::debug!("vfs file {:?} -> {:?}", path, vfs_file);
|
||||
vfs_file.map(vfs_file_to_id)
|
||||
},
|
||||
);
|
||||
log::debug!("crate graph: {:?}", crate_graph);
|
||||
|
||||
let source_roots = roots
|
||||
|
|
|
@ -105,11 +105,15 @@ impl WorldState {
|
|||
}));
|
||||
}
|
||||
|
||||
let extern_dirs: FxHashSet<_> =
|
||||
let mut extern_dirs: FxHashSet<_> =
|
||||
additional_out_dirs.iter().map(|(_, path)| (PathBuf::from(path))).collect();
|
||||
for ws in workspaces.iter() {
|
||||
extern_dirs.extend(ws.out_dirs());
|
||||
}
|
||||
|
||||
let mut extern_source_roots = FxHashMap::default();
|
||||
|
||||
roots.extend(additional_out_dirs.iter().map(|(_, path)| {
|
||||
roots.extend(extern_dirs.iter().map(|path| {
|
||||
let mut filter = RustPackageFilterBuilder::default().set_member(false);
|
||||
for glob in exclude_globs.iter() {
|
||||
filter = filter.exclude(glob.clone());
|
||||
|
@ -148,17 +152,21 @@ impl WorldState {
|
|||
vfs_file.map(|f| FileId(f.0))
|
||||
};
|
||||
|
||||
let mut outdirs = FxHashMap::default();
|
||||
for (name, path) in additional_out_dirs {
|
||||
let path = PathBuf::from(&path);
|
||||
if let Some(id) = extern_source_roots.get(&path) {
|
||||
outdirs.insert(name, (id.clone(), path.to_string_lossy().replace("\\", "/")));
|
||||
}
|
||||
}
|
||||
let additional_out_dirs: FxHashMap<String, PathBuf> = additional_out_dirs
|
||||
.into_iter()
|
||||
.map(|(name, path)| (name, PathBuf::from(&path)))
|
||||
.collect();
|
||||
|
||||
workspaces
|
||||
.iter()
|
||||
.map(|ws| ws.to_crate_graph(&default_cfg_options, &outdirs, &mut load))
|
||||
.map(|ws| {
|
||||
ws.to_crate_graph(
|
||||
&default_cfg_options,
|
||||
&additional_out_dirs,
|
||||
&extern_source_roots,
|
||||
&mut load,
|
||||
)
|
||||
})
|
||||
.for_each(|graph| {
|
||||
crate_graph.extend(graph);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue