mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
hack around nested libraries
This commit is contained in:
parent
8a572043e7
commit
6b1f30ade9
@ -59,6 +59,9 @@ impl FileResolverImp {
|
|||||||
pub(crate) fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId> {
|
pub(crate) fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId> {
|
||||||
self.inner.resolve(file_id, path)
|
self.inner.resolve(file_id, path)
|
||||||
}
|
}
|
||||||
|
pub(crate) fn debug_path(&self, file_id: FileId) -> Option<std::path::PathBuf> {
|
||||||
|
self.inner.debug_path(file_id)
|
||||||
|
}
|
||||||
fn inner(&self) -> *const FileResolver {
|
fn inner(&self) -> *const FileResolver {
|
||||||
&*self.inner
|
&*self.inner
|
||||||
}
|
}
|
||||||
@ -138,6 +141,11 @@ impl AnalysisHostImpl {
|
|||||||
let mut files = FxHashSet::default();
|
let mut files = FxHashSet::default();
|
||||||
for (file_id, text) in library.files {
|
for (file_id, text) in library.files {
|
||||||
files.insert(file_id);
|
files.insert(file_id);
|
||||||
|
log::debug!(
|
||||||
|
"library file: {:?} {:?}",
|
||||||
|
file_id,
|
||||||
|
library.file_resolver.debug_path(file_id)
|
||||||
|
);
|
||||||
self.db
|
self.db
|
||||||
.query_mut(crate::input::FileSourceRootQuery)
|
.query_mut(crate::input::FileSourceRootQuery)
|
||||||
.set_constant(file_id, source_root_id);
|
.set_constant(file_id, source_root_id);
|
||||||
|
@ -33,6 +33,9 @@ impl CrateGraph {
|
|||||||
pub trait FileResolver: fmt::Debug + Send + Sync + 'static {
|
pub trait FileResolver: fmt::Debug + Send + Sync + 'static {
|
||||||
fn file_stem(&self, file_id: FileId) -> String;
|
fn file_stem(&self, file_id: FileId) -> String;
|
||||||
fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId>;
|
fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId>;
|
||||||
|
fn debug_path(&self, _file_id: FileId) -> Option<std::path::PathBuf> {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
salsa::query_group! {
|
salsa::query_group! {
|
||||||
|
@ -168,9 +168,35 @@ fn main_loop_inner(
|
|||||||
let workspaces = vec![ws];
|
let workspaces = vec![ws];
|
||||||
feedback(internal_mode, "workspace loaded", msg_sender);
|
feedback(internal_mode, "workspace loaded", msg_sender);
|
||||||
for ws in workspaces.iter() {
|
for ws in workspaces.iter() {
|
||||||
for pkg in ws.packages().filter(|pkg| !pkg.is_member(ws)) {
|
// Add each library as constant input. If library is
|
||||||
debug!("sending root, {}", pkg.root(ws).to_path_buf().display());
|
// within the workspace, don't treat it as a library.
|
||||||
fs_worker.send(pkg.root(ws).to_path_buf());
|
//
|
||||||
|
// HACK: If source roots are nested, pick the outer one.
|
||||||
|
|
||||||
|
let mut roots = ws
|
||||||
|
.packages()
|
||||||
|
.filter(|pkg| !pkg.is_member(ws))
|
||||||
|
.filter_map(|pkg| {
|
||||||
|
let root = pkg.root(ws).to_path_buf();
|
||||||
|
if root.starts_with(&ws_root) {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(root)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
roots.sort_by_key(|it| it.as_os_str().len());
|
||||||
|
let unique = roots
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.filter(|&(idx, long)| {
|
||||||
|
!roots[..idx].iter().any(|short| long.starts_with(short))
|
||||||
|
})
|
||||||
|
.map(|(_idx, root)| root);
|
||||||
|
|
||||||
|
for root in unique {
|
||||||
|
debug!("sending root, {}", root.display());
|
||||||
|
fs_worker.send(root.to_owned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.set_workspaces(workspaces);
|
state.set_workspaces(workspaces);
|
||||||
|
@ -79,6 +79,10 @@ impl FileResolver for PathMap {
|
|||||||
let path = normalize(&path);
|
let path = normalize(&path);
|
||||||
self.get_id(&path)
|
self.get_id(&path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn debug_path(&self, file_id: FileId) -> Option<PathBuf> {
|
||||||
|
Some(self.get_path(file_id).to_owned())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn normalize(path: &Path) -> PathBuf {
|
fn normalize(path: &Path) -> PathBuf {
|
||||||
|
Loading…
Reference in New Issue
Block a user