From e7217e1a01e4b2c5b136d8f38f21b5ade0ddcf86 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 25 Oct 2018 17:42:29 +0300 Subject: dead code --- crates/ra_analysis/src/roots.rs | 116 ---------------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 crates/ra_analysis/src/roots.rs (limited to 'crates/ra_analysis/src/roots.rs') diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs deleted file mode 100644 index 1e9e613ac..000000000 --- a/crates/ra_analysis/src/roots.rs +++ /dev/null @@ -1,116 +0,0 @@ -use std::{sync::Arc}; - -use rustc_hash::FxHashSet; -use rayon::prelude::*; -use salsa::Database; - -use crate::{ - Cancelable, - db::{self, FilesDatabase, SyntaxDatabase}, - imp::FileResolverImp, - symbol_index::SymbolIndex, - FileId, -}; - -pub(crate) trait SourceRoot { - fn contains(&self, file_id: FileId) -> bool; - fn db(&self) -> &db::RootDatabase; - fn symbols(&self, acc: &mut Vec>) -> Cancelable<()>; -} - -#[derive(Default, Debug, Clone)] -pub(crate) struct WritableSourceRoot { - db: db::RootDatabase, -} - -impl WritableSourceRoot { - pub fn apply_changes( - &mut self, - changes: &mut dyn Iterator)>, - file_resolver: Option, - ) { - let mut changed = FxHashSet::default(); - let mut removed = FxHashSet::default(); - for (file_id, text) in changes { - match text { - None => { - removed.insert(file_id); - } - Some(text) => { - self.db - .query(db::FileTextQuery) - .set(file_id, Arc::new(text)); - changed.insert(file_id); - } - } - } - let file_set = self.db.file_set(); - let mut files: FxHashSet = file_set.files.clone(); - for file_id in removed { - files.remove(&file_id); - } - files.extend(changed); - let resolver = file_resolver.unwrap_or_else(|| file_set.resolver.clone()); - self.db - .query(db::FileSetQuery) - .set((), Arc::new(db::FileSet { files, resolver })); - } -} - -impl SourceRoot for WritableSourceRoot { - fn contains(&self, file_id: FileId) -> bool { - self.db.file_set().files.contains(&file_id) - } - fn db(&self) -> &db::RootDatabase { - &self.db - } - fn symbols<'a>(&'a self, acc: &mut Vec>) -> Cancelable<()> { - for &file_id in self.db.file_set().files.iter() { - let symbols = self.db.file_symbols(file_id)?; - acc.push(symbols) - } - Ok(()) - } -} - -#[derive(Debug, Clone)] -pub(crate) struct ReadonlySourceRoot { - db: db::RootDatabase, - symbol_index: Arc, -} - -impl ReadonlySourceRoot { - pub(crate) fn new( - files: Vec<(FileId, String)>, - resolver: FileResolverImp, - ) -> ReadonlySourceRoot { - let db = db::RootDatabase::default(); - let mut file_ids = FxHashSet::default(); - for (file_id, text) in files { - file_ids.insert(file_id); - db.query(db::FileTextQuery).set(file_id, Arc::new(text)); - } - - db.query(db::FileSetQuery) - .set((), Arc::new(db::FileSet { files: file_ids, resolver })); - let file_set = db.file_set(); - let symbol_index = - SymbolIndex::for_files(file_set.files.par_iter() - .map_with(db.clone(), |db, &file_id| (file_id, db.file_syntax(file_id)))); - - ReadonlySourceRoot { db, symbol_index: Arc::new(symbol_index) } - } -} - -impl SourceRoot for ReadonlySourceRoot { - fn contains(&self, file_id: FileId) -> bool { - self.db.file_set().files.contains(&file_id) - } - fn db(&self) -> &db::RootDatabase { - &self.db - } - fn symbols(&self, acc: &mut Vec>) -> Cancelable<()> { - acc.push(Arc::clone(&self.symbol_index)); - Ok(()) - } -} -- cgit v1.2.3