mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Auto merge of #16742 - alibektas:13529/source_root_tree, r=Veykril
internal: Implement parent-child relation for `SourceRoot`s This commit adds the said relation by keeping a map of type `FxHashMap<SourceRootId,Option<SourceRootId>>` inside the `GlobalState`. Its primary use case is reading `rust-analyzer.toml`(#13529) files that can be placed in every local source root. As a config will be found by traversing this "tree" we need the parent information for every local source root. This commit omits defining this relation for library source roots entirely.
This commit is contained in:
commit
a1fda6476c
4 changed files with 164 additions and 5 deletions
|
@ -8,7 +8,7 @@ use std::{collections::hash_map::Entry, time::Instant};
|
|||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||
use flycheck::FlycheckHandle;
|
||||
use hir::ChangeWithProcMacros;
|
||||
use ide::{Analysis, AnalysisHost, Cancellable, FileId};
|
||||
use ide::{Analysis, AnalysisHost, Cancellable, FileId, SourceRootId};
|
||||
use ide_db::base_db::{CrateId, ProcMacroPaths};
|
||||
use load_cargo::SourceRootConfig;
|
||||
use lsp_types::{SemanticTokens, Url};
|
||||
|
@ -66,6 +66,8 @@ pub(crate) struct GlobalState {
|
|||
pub(crate) diagnostics: DiagnosticCollection,
|
||||
pub(crate) mem_docs: MemDocs,
|
||||
pub(crate) source_root_config: SourceRootConfig,
|
||||
/// A mapping that maps a local source root's `SourceRootId` to it parent's `SourceRootId`, if it has one.
|
||||
pub(crate) local_roots_parent_map: FxHashMap<SourceRootId, SourceRootId>,
|
||||
pub(crate) semantic_tokens_cache: Arc<Mutex<FxHashMap<Url, SemanticTokens>>>,
|
||||
|
||||
// status
|
||||
|
@ -204,6 +206,7 @@ impl GlobalState {
|
|||
send_hint_refresh_query: false,
|
||||
last_reported_status: None,
|
||||
source_root_config: SourceRootConfig::default(),
|
||||
local_roots_parent_map: FxHashMap::default(),
|
||||
config_errors: Default::default(),
|
||||
|
||||
proc_macro_clients: Arc::from_iter([]),
|
||||
|
|
|
@ -515,6 +515,7 @@ impl GlobalState {
|
|||
version: self.vfs_config_version,
|
||||
});
|
||||
self.source_root_config = project_folders.source_root_config;
|
||||
self.local_roots_parent_map = self.source_root_config.source_root_parent_map();
|
||||
|
||||
self.recreate_crate_graph(cause);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue