From 154bce18644698f4e8ef2a2ad2bdd853f2f1e31c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 27 Jan 2019 18:07:45 +0300 Subject: remove dead code --- crates/ra_db/src/lib.rs | 1 - crates/ra_db/src/mock.rs | 30 ------------------------------ crates/ra_ide_api/src/mock_analysis.rs | 6 ++---- 3 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 crates/ra_db/src/mock.rs diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 6e17f33f0..ca775030d 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -2,7 +2,6 @@ mod cancellation; mod input; mod loc2id; -pub mod mock; use std::{ panic, sync::Arc, diff --git a/crates/ra_db/src/mock.rs b/crates/ra_db/src/mock.rs deleted file mode 100644 index 5e185062b..000000000 --- a/crates/ra_db/src/mock.rs +++ /dev/null @@ -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 { - 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 + 'a { - self.0 - .iter() - .map(|(id, path)| (*id, path.as_relative_path())) - } -} diff --git a/crates/ra_ide_api/src/mock_analysis.rs b/crates/ra_ide_api/src/mock_analysis.rs index 846c76cfe..0f2d22ab2 100644 --- a/crates/ra_ide_api/src/mock_analysis.rs +++ b/crates/ra_ide_api/src/mock_analysis.rs @@ -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); } -- cgit v1.2.3