mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-03 21:25:25 +00:00 
			
		
		
		
	Merge pull request #19084 from Veykril/push-muworpzpzqup
Split cache priming into distinct phases
This commit is contained in:
		
						commit
						0fd4fc3522
					
				
					 14 changed files with 126 additions and 66 deletions
				
			
		| 
						 | 
					@ -129,9 +129,9 @@ impl fmt::Display for CrateName {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl ops::Deref for CrateName {
 | 
					impl ops::Deref for CrateName {
 | 
				
			||||||
    type Target = str;
 | 
					    type Target = Symbol;
 | 
				
			||||||
    fn deref(&self) -> &str {
 | 
					    fn deref(&self) -> &Symbol {
 | 
				
			||||||
        self.0.as_str()
 | 
					        &self.0
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -230,8 +230,8 @@ impl fmt::Display for CrateDisplayName {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl ops::Deref for CrateDisplayName {
 | 
					impl ops::Deref for CrateDisplayName {
 | 
				
			||||||
    type Target = str;
 | 
					    type Target = Symbol;
 | 
				
			||||||
    fn deref(&self) -> &str {
 | 
					    fn deref(&self) -> &Symbol {
 | 
				
			||||||
        &self.crate_name
 | 
					        &self.crate_name
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -519,7 +519,7 @@ mod tests {
 | 
				
			||||||
                crate_graph[krate]
 | 
					                crate_graph[krate]
 | 
				
			||||||
                    .display_name
 | 
					                    .display_name
 | 
				
			||||||
                    .as_ref()
 | 
					                    .as_ref()
 | 
				
			||||||
                    .is_some_and(|it| &**it.crate_name() == crate_name)
 | 
					                    .is_some_and(|it| it.crate_name().as_str() == crate_name)
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
            .expect("could not find crate");
 | 
					            .expect("could not find crate");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -337,7 +337,7 @@ impl DefMap {
 | 
				
			||||||
    pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, crate_id: CrateId) -> Arc<DefMap> {
 | 
					    pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, crate_id: CrateId) -> Arc<DefMap> {
 | 
				
			||||||
        let crate_graph = db.crate_graph();
 | 
					        let crate_graph = db.crate_graph();
 | 
				
			||||||
        let krate = &crate_graph[crate_id];
 | 
					        let krate = &crate_graph[crate_id];
 | 
				
			||||||
        let name = krate.display_name.as_deref().unwrap_or_default();
 | 
					        let name = krate.display_name.as_deref().map(Symbol::as_str).unwrap_or_default();
 | 
				
			||||||
        let _p = tracing::info_span!("crate_def_map_query", ?name).entered();
 | 
					        let _p = tracing::info_span!("crate_def_map_query", ?name).entered();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let module_data = ModuleData::new(
 | 
					        let module_data = ModuleData::new(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -262,6 +262,6 @@ impl AsName for ast::FieldKind {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl AsName for base_db::Dependency {
 | 
					impl AsName for base_db::Dependency {
 | 
				
			||||||
    fn as_name(&self) -> Name {
 | 
					    fn as_name(&self) -> Name {
 | 
				
			||||||
        Name::new_root(&self.name)
 | 
					        Name::new_symbol_root((*self.name).clone())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,9 +41,9 @@ pub fn prettify_macro_expansion(
 | 
				
			||||||
                } else if let Some(dep) =
 | 
					                } else if let Some(dep) =
 | 
				
			||||||
                    target_crate.dependencies.iter().find(|dep| dep.crate_id == macro_def_crate)
 | 
					                    target_crate.dependencies.iter().find(|dep| dep.crate_id == macro_def_crate)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    make::tokens::ident(&dep.name)
 | 
					                    make::tokens::ident(dep.name.as_str())
 | 
				
			||||||
                } else if let Some(crate_name) = &crate_graph[macro_def_crate].display_name {
 | 
					                } else if let Some(crate_name) = &crate_graph[macro_def_crate].display_name {
 | 
				
			||||||
                    make::tokens::ident(crate_name.crate_name())
 | 
					                    make::tokens::ident(crate_name.crate_name().as_str())
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    return dollar_crate.clone();
 | 
					                    return dollar_crate.clone();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,12 +6,13 @@ mod topologic_sort;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use std::time::Duration;
 | 
					use std::time::Duration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use hir::db::DefDatabase;
 | 
					use hir::{db::DefDatabase, Symbol};
 | 
				
			||||||
 | 
					use itertools::Itertools;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
    base_db::{
 | 
					    base_db::{
 | 
				
			||||||
        ra_salsa::{Database, ParallelDatabase, Snapshot},
 | 
					        ra_salsa::{Database, ParallelDatabase, Snapshot},
 | 
				
			||||||
        Cancelled, CrateId, SourceDatabase, SourceRootDatabase,
 | 
					        Cancelled, CrateId, SourceDatabase,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    symbol_index::SymbolsDatabase,
 | 
					    symbol_index::SymbolsDatabase,
 | 
				
			||||||
    FxIndexMap, RootDatabase,
 | 
					    FxIndexMap, RootDatabase,
 | 
				
			||||||
| 
						 | 
					@ -21,11 +22,12 @@ use crate::{
 | 
				
			||||||
#[derive(Debug)]
 | 
					#[derive(Debug)]
 | 
				
			||||||
pub struct ParallelPrimeCachesProgress {
 | 
					pub struct ParallelPrimeCachesProgress {
 | 
				
			||||||
    /// the crates that we are currently priming.
 | 
					    /// the crates that we are currently priming.
 | 
				
			||||||
    pub crates_currently_indexing: Vec<String>,
 | 
					    pub crates_currently_indexing: Vec<Symbol>,
 | 
				
			||||||
    /// the total number of crates we want to prime.
 | 
					    /// the total number of crates we want to prime.
 | 
				
			||||||
    pub crates_total: usize,
 | 
					    pub crates_total: usize,
 | 
				
			||||||
    /// the total number of crates that have finished priming
 | 
					    /// the total number of crates that have finished priming
 | 
				
			||||||
    pub crates_done: usize,
 | 
					    pub crates_done: usize,
 | 
				
			||||||
 | 
					    pub work_type: &'static str,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn parallel_prime_caches(
 | 
					pub fn parallel_prime_caches(
 | 
				
			||||||
| 
						 | 
					@ -47,41 +49,32 @@ pub fn parallel_prime_caches(
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    enum ParallelPrimeCacheWorkerProgress {
 | 
					    enum ParallelPrimeCacheWorkerProgress {
 | 
				
			||||||
        BeginCrate { crate_id: CrateId, crate_name: String },
 | 
					        BeginCrate { crate_id: CrateId, crate_name: Symbol },
 | 
				
			||||||
        EndCrate { crate_id: CrateId },
 | 
					        EndCrate { crate_id: CrateId },
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // We split off def map computation from other work,
 | 
				
			||||||
 | 
					    // as the def map is the relevant one. Once the defmaps are computed
 | 
				
			||||||
 | 
					    // the project is ready to go, the other indices are just nice to have for some IDE features.
 | 
				
			||||||
 | 
					    #[derive(PartialOrd, Ord, PartialEq, Eq, Copy, Clone)]
 | 
				
			||||||
 | 
					    enum PrimingPhase {
 | 
				
			||||||
 | 
					        DefMap,
 | 
				
			||||||
 | 
					        ImportMap,
 | 
				
			||||||
 | 
					        CrateSymbols,
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let (work_sender, progress_receiver) = {
 | 
					    let (work_sender, progress_receiver) = {
 | 
				
			||||||
        let (progress_sender, progress_receiver) = crossbeam_channel::unbounded();
 | 
					        let (progress_sender, progress_receiver) = crossbeam_channel::unbounded();
 | 
				
			||||||
        let (work_sender, work_receiver) = crossbeam_channel::unbounded();
 | 
					        let (work_sender, work_receiver) = crossbeam_channel::unbounded();
 | 
				
			||||||
        let graph = graph.clone();
 | 
					 | 
				
			||||||
        let local_roots = db.local_roots();
 | 
					 | 
				
			||||||
        let prime_caches_worker = move |db: Snapshot<RootDatabase>| {
 | 
					        let prime_caches_worker = move |db: Snapshot<RootDatabase>| {
 | 
				
			||||||
            while let Ok((crate_id, crate_name)) = work_receiver.recv() {
 | 
					            while let Ok((crate_id, crate_name, kind)) = work_receiver.recv() {
 | 
				
			||||||
                progress_sender
 | 
					                progress_sender
 | 
				
			||||||
                    .send(ParallelPrimeCacheWorkerProgress::BeginCrate { crate_id, crate_name })?;
 | 
					                    .send(ParallelPrimeCacheWorkerProgress::BeginCrate { crate_id, crate_name })?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Compute the DefMap and possibly ImportMap
 | 
					                match kind {
 | 
				
			||||||
                let file_id = graph[crate_id].root_file_id;
 | 
					                    PrimingPhase::DefMap => _ = db.crate_def_map(crate_id),
 | 
				
			||||||
                let root_id = db.file_source_root(file_id);
 | 
					                    PrimingPhase::ImportMap => _ = db.import_map(crate_id),
 | 
				
			||||||
                if db.source_root(root_id).is_library {
 | 
					                    PrimingPhase::CrateSymbols => _ = db.crate_symbols(crate_id.into()),
 | 
				
			||||||
                    db.crate_def_map(crate_id);
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    // This also computes the DefMap
 | 
					 | 
				
			||||||
                    db.import_map(crate_id);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // Compute the symbol search index.
 | 
					 | 
				
			||||||
                // This primes the cache for `ide_db::symbol_index::world_symbols()`.
 | 
					 | 
				
			||||||
                //
 | 
					 | 
				
			||||||
                // We do this for workspace crates only (members of local_roots), because doing it
 | 
					 | 
				
			||||||
                // for all dependencies could be *very* unnecessarily slow in a large project.
 | 
					 | 
				
			||||||
                //
 | 
					 | 
				
			||||||
                // FIXME: We should do it unconditionally if the configuration is set to default to
 | 
					 | 
				
			||||||
                // searching dependencies (rust-analyzer.workspace.symbol.search.scope), but we
 | 
					 | 
				
			||||||
                // would need to pipe that configuration information down here.
 | 
					 | 
				
			||||||
                if local_roots.contains(&root_id) {
 | 
					 | 
				
			||||||
                    db.crate_symbols(crate_id.into());
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                progress_sender.send(ParallelPrimeCacheWorkerProgress::EndCrate { crate_id })?;
 | 
					                progress_sender.send(ParallelPrimeCacheWorkerProgress::EndCrate { crate_id })?;
 | 
				
			||||||
| 
						 | 
					@ -112,16 +105,34 @@ pub fn parallel_prime_caches(
 | 
				
			||||||
    let mut crates_currently_indexing =
 | 
					    let mut crates_currently_indexing =
 | 
				
			||||||
        FxIndexMap::with_capacity_and_hasher(num_worker_threads, Default::default());
 | 
					        FxIndexMap::with_capacity_and_hasher(num_worker_threads, Default::default());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let mut additional_phases = vec![];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while crates_done < crates_total {
 | 
					    while crates_done < crates_total {
 | 
				
			||||||
        db.unwind_if_cancelled();
 | 
					        db.unwind_if_cancelled();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for crate_id in &mut crates_to_prime {
 | 
					        for crate_id in &mut crates_to_prime {
 | 
				
			||||||
            work_sender
 | 
					            let krate = &graph[crate_id];
 | 
				
			||||||
                .send((
 | 
					            let name = krate
 | 
				
			||||||
                    crate_id,
 | 
					                .display_name
 | 
				
			||||||
                    graph[crate_id].display_name.as_deref().unwrap_or_default().to_owned(),
 | 
					                .as_deref()
 | 
				
			||||||
                ))
 | 
					                .cloned()
 | 
				
			||||||
                .ok();
 | 
					                .unwrap_or_else(|| Symbol::integer(crate_id.into_raw().into_u32() as usize));
 | 
				
			||||||
 | 
					            if krate.origin.is_lang() {
 | 
				
			||||||
 | 
					                additional_phases.push((crate_id, name.clone(), PrimingPhase::ImportMap));
 | 
				
			||||||
 | 
					            } else if krate.origin.is_local() {
 | 
				
			||||||
 | 
					                // Compute the symbol search index.
 | 
				
			||||||
 | 
					                // This primes the cache for `ide_db::symbol_index::world_symbols()`.
 | 
				
			||||||
 | 
					                //
 | 
				
			||||||
 | 
					                // We do this for workspace crates only (members of local_roots), because doing it
 | 
				
			||||||
 | 
					                // for all dependencies could be *very* unnecessarily slow in a large project.
 | 
				
			||||||
 | 
					                //
 | 
				
			||||||
 | 
					                // FIXME: We should do it unconditionally if the configuration is set to default to
 | 
				
			||||||
 | 
					                // searching dependencies (rust-analyzer.workspace.symbol.search.scope), but we
 | 
				
			||||||
 | 
					                // would need to pipe that configuration information down here.
 | 
				
			||||||
 | 
					                additional_phases.push((crate_id, name.clone(), PrimingPhase::CrateSymbols));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            work_sender.send((crate_id, name, PrimingPhase::DefMap)).ok();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // recv_timeout is somewhat a hack, we need a way to from this thread check to see if the current salsa revision
 | 
					        // recv_timeout is somewhat a hack, we need a way to from this thread check to see if the current salsa revision
 | 
				
			||||||
| 
						 | 
					@ -153,6 +164,50 @@ pub fn parallel_prime_caches(
 | 
				
			||||||
            crates_currently_indexing: crates_currently_indexing.values().cloned().collect(),
 | 
					            crates_currently_indexing: crates_currently_indexing.values().cloned().collect(),
 | 
				
			||||||
            crates_done,
 | 
					            crates_done,
 | 
				
			||||||
            crates_total,
 | 
					            crates_total,
 | 
				
			||||||
 | 
					            work_type: "Indexing",
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        cb(progress);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let mut crates_done = 0;
 | 
				
			||||||
 | 
					    let crates_total = additional_phases.len();
 | 
				
			||||||
 | 
					    for w in additional_phases.into_iter().sorted_by_key(|&(_, _, phase)| phase) {
 | 
				
			||||||
 | 
					        work_sender.send(w).ok();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while crates_done < crates_total {
 | 
				
			||||||
 | 
					        db.unwind_if_cancelled();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // recv_timeout is somewhat a hack, we need a way to from this thread check to see if the current salsa revision
 | 
				
			||||||
 | 
					        // is cancelled on a regular basis. workers will only exit if they are processing a task that is cancelled, or
 | 
				
			||||||
 | 
					        // if this thread exits, and closes the work channel.
 | 
				
			||||||
 | 
					        let worker_progress = match progress_receiver.recv_timeout(Duration::from_millis(10)) {
 | 
				
			||||||
 | 
					            Ok(p) => p,
 | 
				
			||||||
 | 
					            Err(crossbeam_channel::RecvTimeoutError::Timeout) => {
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            Err(crossbeam_channel::RecvTimeoutError::Disconnected) => {
 | 
				
			||||||
 | 
					                // our workers may have died from a cancelled task, so we'll check and re-raise here.
 | 
				
			||||||
 | 
					                db.unwind_if_cancelled();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        match worker_progress {
 | 
				
			||||||
 | 
					            ParallelPrimeCacheWorkerProgress::BeginCrate { crate_id, crate_name } => {
 | 
				
			||||||
 | 
					                crates_currently_indexing.insert(crate_id, crate_name);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            ParallelPrimeCacheWorkerProgress::EndCrate { crate_id } => {
 | 
				
			||||||
 | 
					                crates_currently_indexing.swap_remove(&crate_id);
 | 
				
			||||||
 | 
					                crates_done += 1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let progress = ParallelPrimeCachesProgress {
 | 
				
			||||||
 | 
					            crates_currently_indexing: crates_currently_indexing.values().cloned().collect(),
 | 
				
			||||||
 | 
					            crates_done,
 | 
				
			||||||
 | 
					            crates_total,
 | 
				
			||||||
 | 
					            work_type: "Populating symbols",
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cb(progress);
 | 
					        cb(progress);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,7 +84,8 @@ impl<'a> dot::Labeller<'a, CrateId, Edge<'a>> for DotCrateGraph {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn node_label(&'a self, n: &CrateId) -> LabelText<'a> {
 | 
					    fn node_label(&'a self, n: &CrateId) -> LabelText<'a> {
 | 
				
			||||||
        let name = self.graph[*n].display_name.as_ref().map_or("(unnamed crate)", |name| name);
 | 
					        let name =
 | 
				
			||||||
 | 
					            self.graph[*n].display_name.as_ref().map_or("(unnamed crate)", |name| name.as_str());
 | 
				
			||||||
        LabelText::LabelStr(name.into())
 | 
					        LabelText::LabelStr(name.into())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -481,6 +481,7 @@ define_symbols! {
 | 
				
			||||||
    u64,
 | 
					    u64,
 | 
				
			||||||
    u8,
 | 
					    u8,
 | 
				
			||||||
    unadjusted,
 | 
					    unadjusted,
 | 
				
			||||||
 | 
					    unknown,
 | 
				
			||||||
    Unknown,
 | 
					    Unknown,
 | 
				
			||||||
    unpin,
 | 
					    unpin,
 | 
				
			||||||
    unreachable_2015,
 | 
					    unreachable_2015,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -508,5 +508,5 @@ fn serialize_crate_name<S>(name: &CrateName, se: S) -> Result<S::Ok, S::Error>
 | 
				
			||||||
where
 | 
					where
 | 
				
			||||||
    S: serde::Serializer,
 | 
					    S: serde::Serializer,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    se.serialize_str(name)
 | 
					    se.serialize_str(name.as_str())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -230,7 +230,7 @@ fn rust_project_is_proc_macro_has_proc_macro_dep() {
 | 
				
			||||||
    let crate_data = &crate_graph[crate_id];
 | 
					    let crate_data = &crate_graph[crate_id];
 | 
				
			||||||
    // Assert that the project crate with `is_proc_macro` has a dependency
 | 
					    // Assert that the project crate with `is_proc_macro` has a dependency
 | 
				
			||||||
    // on the proc_macro sysroot crate.
 | 
					    // on the proc_macro sysroot crate.
 | 
				
			||||||
    crate_data.dependencies.iter().find(|&dep| dep.name.deref() == "proc_macro").unwrap();
 | 
					    crate_data.dependencies.iter().find(|&dep| *dep.name.deref() == sym::proc_macro).unwrap();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[test]
 | 
					#[test]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,7 @@
 | 
				
			||||||
use project_model::{CargoConfig, RustLibSource};
 | 
					use project_model::{CargoConfig, RustLibSource};
 | 
				
			||||||
use rustc_hash::FxHashSet;
 | 
					use rustc_hash::FxHashSet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use hir::{db::HirDatabase, Crate, HirFileIdExt, Module};
 | 
					use hir::{db::HirDatabase, sym, Crate, HirFileIdExt, Module};
 | 
				
			||||||
use ide::{AnalysisHost, AssistResolveStrategy, Diagnostic, DiagnosticsConfig, Severity};
 | 
					use ide::{AnalysisHost, AssistResolveStrategy, Diagnostic, DiagnosticsConfig, Severity};
 | 
				
			||||||
use ide_db::{base_db::SourceRootDatabase, LineIndexDatabase};
 | 
					use ide_db::{base_db::SourceRootDatabase, LineIndexDatabase};
 | 
				
			||||||
use load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
 | 
					use load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
 | 
				
			||||||
| 
						 | 
					@ -60,7 +60,7 @@ impl flags::Diagnostics {
 | 
				
			||||||
            let file_id = module.definition_source_file_id(db).original_file(db);
 | 
					            let file_id = module.definition_source_file_id(db).original_file(db);
 | 
				
			||||||
            if !visited_files.contains(&file_id) {
 | 
					            if !visited_files.contains(&file_id) {
 | 
				
			||||||
                let crate_name =
 | 
					                let crate_name =
 | 
				
			||||||
                    module.krate().display_name(db).as_deref().unwrap_or("unknown").to_owned();
 | 
					                    module.krate().display_name(db).as_deref().unwrap_or(&sym::unknown).to_owned();
 | 
				
			||||||
                println!(
 | 
					                println!(
 | 
				
			||||||
                    "processing crate: {crate_name}, module: {}",
 | 
					                    "processing crate: {crate_name}, module: {}",
 | 
				
			||||||
                    _vfs.file_path(file_id.into())
 | 
					                    _vfs.file_path(file_id.into())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
//! Reports references in code that the IDE layer cannot resolve.
 | 
					//! Reports references in code that the IDE layer cannot resolve.
 | 
				
			||||||
use hir::{db::HirDatabase, AnyDiagnostic, Crate, HirFileIdExt as _, Module, Semantics};
 | 
					use hir::{db::HirDatabase, sym, AnyDiagnostic, Crate, HirFileIdExt as _, Module, Semantics};
 | 
				
			||||||
use ide::{AnalysisHost, RootDatabase, TextRange};
 | 
					use ide::{AnalysisHost, RootDatabase, TextRange};
 | 
				
			||||||
use ide_db::{
 | 
					use ide_db::{
 | 
				
			||||||
    base_db::{SourceDatabase, SourceRootDatabase},
 | 
					    base_db::{SourceDatabase, SourceRootDatabase},
 | 
				
			||||||
| 
						 | 
					@ -66,7 +66,7 @@ impl flags::UnresolvedReferences {
 | 
				
			||||||
            let file_id = module.definition_source_file_id(db).original_file(db);
 | 
					            let file_id = module.definition_source_file_id(db).original_file(db);
 | 
				
			||||||
            if !visited_files.contains(&file_id) {
 | 
					            if !visited_files.contains(&file_id) {
 | 
				
			||||||
                let crate_name =
 | 
					                let crate_name =
 | 
				
			||||||
                    module.krate().display_name(db).as_deref().unwrap_or("unknown").to_owned();
 | 
					                    module.krate().display_name(db).as_deref().unwrap_or(&sym::unknown).to_owned();
 | 
				
			||||||
                let file_path = vfs.file_path(file_id.into());
 | 
					                let file_path = vfs.file_path(file_id.into());
 | 
				
			||||||
                eprintln!("processing crate: {crate_name}, module: {file_path}",);
 | 
					                eprintln!("processing crate: {crate_name}, module: {file_path}",);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -325,26 +325,30 @@ impl GlobalState {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for progress in prime_caches_progress {
 | 
					                for progress in prime_caches_progress {
 | 
				
			||||||
                    let (state, message, fraction);
 | 
					                    let (state, message, fraction, title);
 | 
				
			||||||
                    match progress {
 | 
					                    match progress {
 | 
				
			||||||
                        PrimeCachesProgress::Begin => {
 | 
					                        PrimeCachesProgress::Begin => {
 | 
				
			||||||
                            state = Progress::Begin;
 | 
					                            state = Progress::Begin;
 | 
				
			||||||
                            message = None;
 | 
					                            message = None;
 | 
				
			||||||
                            fraction = 0.0;
 | 
					                            fraction = 0.0;
 | 
				
			||||||
 | 
					                            title = "Indexing";
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        PrimeCachesProgress::Report(report) => {
 | 
					                        PrimeCachesProgress::Report(report) => {
 | 
				
			||||||
                            state = Progress::Report;
 | 
					                            state = Progress::Report;
 | 
				
			||||||
 | 
					                            title = report.work_type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            message = match &report.crates_currently_indexing[..] {
 | 
					                            message = match &*report.crates_currently_indexing {
 | 
				
			||||||
                                [crate_name] => Some(format!(
 | 
					                                [crate_name] => Some(format!(
 | 
				
			||||||
                                    "{}/{} ({crate_name})",
 | 
					                                    "{}/{} ({})",
 | 
				
			||||||
                                    report.crates_done, report.crates_total
 | 
					                                    report.crates_done,
 | 
				
			||||||
 | 
					                                    report.crates_total,
 | 
				
			||||||
 | 
					                                    crate_name.as_str(),
 | 
				
			||||||
                                )),
 | 
					                                )),
 | 
				
			||||||
                                [crate_name, rest @ ..] => Some(format!(
 | 
					                                [crate_name, rest @ ..] => Some(format!(
 | 
				
			||||||
                                    "{}/{} ({} + {} more)",
 | 
					                                    "{}/{} ({} + {} more)",
 | 
				
			||||||
                                    report.crates_done,
 | 
					                                    report.crates_done,
 | 
				
			||||||
                                    report.crates_total,
 | 
					                                    report.crates_total,
 | 
				
			||||||
                                    crate_name,
 | 
					                                    crate_name.as_str(),
 | 
				
			||||||
                                    rest.len()
 | 
					                                    rest.len()
 | 
				
			||||||
                                )),
 | 
					                                )),
 | 
				
			||||||
                                _ => None,
 | 
					                                _ => None,
 | 
				
			||||||
| 
						 | 
					@ -356,6 +360,7 @@ impl GlobalState {
 | 
				
			||||||
                            state = Progress::End;
 | 
					                            state = Progress::End;
 | 
				
			||||||
                            message = None;
 | 
					                            message = None;
 | 
				
			||||||
                            fraction = 1.0;
 | 
					                            fraction = 1.0;
 | 
				
			||||||
 | 
					                            title = "Indexing";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            self.prime_caches_queue.op_completed(());
 | 
					                            self.prime_caches_queue.op_completed(());
 | 
				
			||||||
                            if cancelled {
 | 
					                            if cancelled {
 | 
				
			||||||
| 
						 | 
					@ -365,7 +370,13 @@ impl GlobalState {
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    self.report_progress("Indexing", state, message, Some(fraction), None);
 | 
					                    self.report_progress(
 | 
				
			||||||
 | 
					                        title,
 | 
				
			||||||
 | 
					                        state,
 | 
				
			||||||
 | 
					                        message,
 | 
				
			||||||
 | 
					                        Some(fraction),
 | 
				
			||||||
 | 
					                        Some("rustAnalyzer/cachePriming".to_owned()),
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            Event::Vfs(message) => {
 | 
					            Event::Vfs(message) => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -258,15 +258,7 @@ impl ChangeFixture {
 | 
				
			||||||
                let to_id = crates[&to];
 | 
					                let to_id = crates[&to];
 | 
				
			||||||
                let sysroot = crate_graph[to_id].origin.is_lang();
 | 
					                let sysroot = crate_graph[to_id].origin.is_lang();
 | 
				
			||||||
                crate_graph
 | 
					                crate_graph
 | 
				
			||||||
                    .add_dep(
 | 
					                    .add_dep(from_id, Dependency::with_prelude(to.clone(), to_id, prelude, sysroot))
 | 
				
			||||||
                        from_id,
 | 
					 | 
				
			||||||
                        Dependency::with_prelude(
 | 
					 | 
				
			||||||
                            CrateName::new(&to).unwrap(),
 | 
					 | 
				
			||||||
                            to_id,
 | 
					 | 
				
			||||||
                            prelude,
 | 
					 | 
				
			||||||
                            sysroot,
 | 
					 | 
				
			||||||
                        ),
 | 
					 | 
				
			||||||
                    )
 | 
					 | 
				
			||||||
                    .unwrap();
 | 
					                    .unwrap();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue