mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
New VFS
This commit is contained in:
parent
7aa66371ee
commit
dad1333b48
46 changed files with 1028 additions and 1001 deletions
|
@ -4,7 +4,6 @@
|
|||
//! the default `FileSet`.
|
||||
use std::{fmt, iter};
|
||||
|
||||
use paths::AbsPathBuf;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::{FileId, Vfs, VfsPath};
|
||||
|
@ -41,7 +40,7 @@ impl fmt::Debug for FileSet {
|
|||
#[derive(Debug)]
|
||||
pub struct FileSetConfig {
|
||||
n_file_sets: usize,
|
||||
roots: Vec<(AbsPathBuf, usize)>,
|
||||
roots: Vec<(VfsPath, usize)>,
|
||||
}
|
||||
|
||||
impl Default for FileSetConfig {
|
||||
|
@ -66,11 +65,7 @@ impl FileSetConfig {
|
|||
self.n_file_sets
|
||||
}
|
||||
fn classify(&self, path: &VfsPath) -> usize {
|
||||
let path = match path.as_path() {
|
||||
Some(it) => it,
|
||||
None => return self.len() - 1,
|
||||
};
|
||||
let idx = match self.roots.binary_search_by(|(p, _)| p.as_path().cmp(path)) {
|
||||
let idx = match self.roots.binary_search_by(|(p, _)| p.cmp(path)) {
|
||||
Ok(it) => it,
|
||||
Err(it) => it.saturating_sub(1),
|
||||
};
|
||||
|
@ -83,7 +78,7 @@ impl FileSetConfig {
|
|||
}
|
||||
|
||||
pub struct FileSetConfigBuilder {
|
||||
roots: Vec<Vec<AbsPathBuf>>,
|
||||
roots: Vec<Vec<VfsPath>>,
|
||||
}
|
||||
|
||||
impl Default for FileSetConfigBuilder {
|
||||
|
@ -96,12 +91,12 @@ impl FileSetConfigBuilder {
|
|||
pub fn len(&self) -> usize {
|
||||
self.roots.len()
|
||||
}
|
||||
pub fn add_file_set(&mut self, roots: Vec<AbsPathBuf>) {
|
||||
pub fn add_file_set(&mut self, roots: Vec<VfsPath>) {
|
||||
self.roots.push(roots)
|
||||
}
|
||||
pub fn build(self) -> FileSetConfig {
|
||||
let n_file_sets = self.roots.len() + 1;
|
||||
let mut roots: Vec<(AbsPathBuf, usize)> = self
|
||||
let mut roots: Vec<(VfsPath, usize)> = self
|
||||
.roots
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue