mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
Merge #691
691: remove dead code r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
b2b62b9579
3 changed files with 2 additions and 35 deletions
|
@ -2,7 +2,6 @@
|
|||
mod cancellation;
|
||||
mod input;
|
||||
mod loc2id;
|
||||
pub mod mock;
|
||||
|
||||
use std::{
|
||||
panic, sync::Arc,
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
use rustc_hash::FxHashSet;
|
||||
use relative_path::{RelativePath, RelativePathBuf};
|
||||
|
||||
use crate::{FileId};
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct FileMap(Vec<(FileId, RelativePathBuf)>);
|
||||
|
||||
impl FileMap {
|
||||
pub fn add(&mut self, path: RelativePathBuf) -> FileId {
|
||||
let file_id = FileId((self.0.len() + 1) as u32);
|
||||
self.0.push((file_id, path));
|
||||
file_id
|
||||
}
|
||||
|
||||
pub fn files(&self) -> FxHashSet<FileId> {
|
||||
self.iter().map(|(id, _)| id).collect()
|
||||
}
|
||||
|
||||
pub fn file_id(&self, path: &str) -> FileId {
|
||||
assert!(path.starts_with('/'));
|
||||
self.iter().find(|(_, p)| p == &path[1..]).unwrap().0
|
||||
}
|
||||
|
||||
fn iter<'a>(&'a self) -> impl Iterator<Item = (FileId, &'a RelativePath)> + 'a {
|
||||
self.0
|
||||
.iter()
|
||||
.map(|(id, path)| (*id, path.as_relative_path()))
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ use std::sync::Arc;
|
|||
|
||||
use relative_path::RelativePathBuf;
|
||||
use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER};
|
||||
use ra_db::mock::FileMap;
|
||||
|
||||
use crate::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, FilePosition, FileRange, SourceRootId};
|
||||
|
||||
|
@ -83,15 +82,14 @@ impl MockAnalysis {
|
|||
}
|
||||
pub fn analysis_host(self) -> AnalysisHost {
|
||||
let mut host = AnalysisHost::default();
|
||||
let mut file_map = FileMap::default();
|
||||
let source_root = SourceRootId(0);
|
||||
let mut change = AnalysisChange::new();
|
||||
change.add_root(source_root, true);
|
||||
let mut crate_graph = CrateGraph::default();
|
||||
for (path, contents) in self.files.into_iter() {
|
||||
for (i, (path, contents)) in self.files.into_iter().enumerate() {
|
||||
assert!(path.starts_with('/'));
|
||||
let path = RelativePathBuf::from_path(&path[1..]).unwrap();
|
||||
let file_id = file_map.add(path.clone());
|
||||
let file_id = FileId(i as u32 + 1);
|
||||
if path == "/lib.rs" || path == "/main.rs" {
|
||||
crate_graph.add_crate_root(file_id);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue