mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Implement parent-child relation for SourceRoot
s
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:
parent
ce15e73a8e
commit
a15cc86c64
4 changed files with 249 additions and 5 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue