Implement parent-child relation for SourceRoots

This commit adds the said relation by keeping a map of type `FxHashMap<SourceRootId,Option<SourceRootId>>`
inside the `GlobalState`. Its primary use case is reading the rust-analyzer.toml files that can be
placed under every local source root. As a config will be found by traversing this "tree" we need the parent information
for every local source root. This commit omits defining this relation for library source roots entirely.
This commit is contained in:
Ali Bektas 2024-02-26 14:35:54 +01:00
parent ce15e73a8e
commit a15cc86c64
4 changed files with 249 additions and 5 deletions

View file

@ -123,6 +123,17 @@ impl FileSetConfig {
self.n_file_sets
}
/// Get the lexicographically ordered vector of the underlying map.
pub fn roots(&self) -> Vec<(Vec<u8>, u64)> {
let mut stream = self.map.stream();
let mut vc = vec![];
while let Some((pth, idx)) = stream.next() {
vc.push((pth.to_vec(), idx));
}
vc
}
/// Returns the set index for the given `path`.
///
/// `scratch_space` is used as a buffer and will be entirely replaced.