pub struct WorkspaceIndex { /* private fields */ }Expand description
Unified multi-crate index for a cargo workspace or multi-index directory.
Implementations§
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn find_def_at_in_reader<'a>(
&'a self,
reader_idx: usize,
file_id: u32,
line: u32,
col: u32,
inner_ref: Option<&'a RefEntry>,
) -> Option<ResolvedDefinition<'a>>
pub fn find_def_at_in_reader<'a>( &'a self, reader_idx: usize, file_id: u32, line: u32, col: u32, inner_ref: Option<&'a RefEntry>, ) -> Option<ResolvedDefinition<'a>>
Resolves a definition at (file_id, line, col) in reader_idx. A pre-looked-up
inner_ref answers unless a definition at the cursor lies inside its span (an item written
inside a macro invocation or a generated call whose reference spans it); without a
reference the smallest definition containing the cursor answers.
Sourcepub fn definition_inside_reference_at(
&self,
reader_idx: usize,
file_id: u32,
line: u32,
col: u32,
r: &RefEntry,
) -> Option<&DefEntry>
pub fn definition_inside_reference_at( &self, reader_idx: usize, file_id: u32, line: u32, col: u32, r: &RefEntry, ) -> Option<&DefEntry>
The smallest definition of reader_idx at (file_id, line, col) whose span lies inside the
span of the reference r, when r is wide enough to enclose one. Such a definition takes
precedence over the reference at the cursor.
Sourcepub fn find_definition_at<'a>(
&'a self,
file: &str,
line: u32,
col: u32,
) -> Option<ResolvedDefinition<'a>>
pub fn find_definition_at<'a>( &'a self, file: &str, line: u32, col: u32, ) -> Option<ResolvedDefinition<'a>>
Finds a definition at a cursor location, seamlessly resolving cross-crate references.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn auto_discover() -> Result<Self>
pub fn auto_discover() -> Result<Self>
Auto-discovers .ridx indices starting from current directory up to root or target/ridx.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn resolved_reader_file_ids(&self, file: &str) -> Vec<(usize, u32)>
pub fn resolved_reader_file_ids(&self, file: &str) -> Vec<(usize, u32)>
Returns prioritized (reader_idx, file_id) pairs for file (library targets first).
Sourcepub fn target_file_for_reader<'a>(
&self,
reader_idx: usize,
file: &'a str,
) -> Option<Cow<'a, str>>
pub fn target_file_for_reader<'a>( &self, reader_idx: usize, file: &'a str, ) -> Option<Cow<'a, str>>
Resolves file (absolute, relative to the workspace root, or relative to the reader’s
source root) to the path string the reader at reader_idx stores for it, or None when
this reader does not index the file. Every string returned is accepted by that reader’s
exact find_file_id: the input is re-expressed in the reader’s coordinates (relative to
the workspace root or to the source root) and compared whole, never by suffix.
Sourcepub fn candidate_reader_indices_for_file(&self, file: &str) -> Vec<usize>
pub fn candidate_reader_indices_for_file(&self, file: &str) -> Vec<usize>
Returns reader indices prioritized for querying items in file:
matching readers first (ordered with library targets before tests/benchmarks),
followed by any remaining workspace readers.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn reader_index_for_file(&self, file_path: &str) -> Option<usize>
pub fn reader_index_for_file(&self, file_path: &str) -> Option<usize>
Returns the index in self.readers for the crate that contains or owns the specified file path.
Sourcepub fn file_in_bin_only(&self, file_path: &str) -> bool
pub fn file_in_bin_only(&self, file_path: &str) -> bool
Whether file_path is compiled into a binary target (src/main.rs, a module of it, a [[bin]] path) and not
into the package’s library: its crate:: is the binary, the library is another crate to it.
Sourcepub fn target_kind_at(&self, idx: usize) -> Option<TargetKind>
pub fn target_kind_at(&self, idx: usize) -> Option<TargetKind>
Returns the target kind for the reader at index idx if known.
Sourcepub fn reader_indices_for_file(&self, file_path: &str) -> Vec<usize>
pub fn reader_indices_for_file(&self, file_path: &str) -> Vec<usize>
Returns the indices in self.readers for all crate units that contain or own the specified file path.
Employs longest prefix matching on source_roots so that subpackage targets are returned
rather than broader ancestor workspace roots, invariant to reader insertion order.
Sourcepub fn extern_crate_names_for_file(&self, file_path: &str) -> Option<Vec<&str>>
pub fn extern_crate_names_for_file(&self, file_path: &str) -> Option<Vec<&str>>
The names under which the compilation unit of file_path links other crates (its extern names), when the
index records them; None when it does not.
Sourcepub fn module_of_file(&self, file_path: &str) -> Option<String>
pub fn module_of_file(&self, file_path: &str) -> Option<String>
The crate-relative module file_path is (flags::complete::fish, "" for the crate root), read from the
module-level items the index holds for it (functions, types, traits, consts, statics, modules): the shallowest
of their parents, so an inline mod tests { … } of the file does not stand for it. None when the file
declares no such item.
Sourcepub fn module_path_for_file(&self, file_path: &str) -> Option<String>
pub fn module_path_for_file(&self, file_path: &str) -> Option<String>
Returns the canonical module path corresponding to file_path in the owning crate
(e.g. serde::de::impls for serde/src/de/impls.rs).
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn direct_blast_radius(
&self,
def: &ResolvedDefinition<'_>,
) -> DirectBlastRadius
pub fn direct_blast_radius( &self, def: &ResolvedDefinition<'_>, ) -> DirectBlastRadius
Returns the direct-reference blast radius for def across workspace shards (O(1) via
precomputed BlastRadiusIndex, falling back to HashSet scan when the index is unbuilt).
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn collect_reexport_aliases(&self, target_path: &str) -> Vec<String>
pub fn collect_reexport_aliases(&self, target_path: &str) -> Vec<String>
Collects any known re-export alias paths for a symbol within the workspace.
Sourcepub fn has_unmerged_reexport_references(
&self,
target_path: &str,
found_refs: &[WorkspaceReference<'_>],
) -> bool
pub fn has_unmerged_reexport_references( &self, target_path: &str, found_refs: &[WorkspaceReference<'_>], ) -> bool
Checks whether there are references to a re-export of target_path that are
not included in found_refs.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn find_trait_item_declaration<'a>(
&'a self,
def: &ResolvedDefinition<'a>,
) -> Option<ResolvedDefinition<'a>>
pub fn find_trait_item_declaration<'a>( &'a self, def: &ResolvedDefinition<'a>, ) -> Option<ResolvedDefinition<'a>>
Resolves the trait declaration for an associated item defined inside a trait impl.
pub fn external_trait_for_def( &self, def: &ResolvedDefinition<'_>, ) -> Option<String>
pub fn external_trait_for_impl_item( &self, loc_refs: &LocationReferences<'_>, ) -> Option<String>
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn exact_symbols_by_name<'a>(
&'a self,
ident: &str,
) -> Vec<WorkspaceSymbol<'a>>
pub fn exact_symbols_by_name<'a>( &'a self, ident: &str, ) -> Vec<WorkspaceSymbol<'a>>
O(1) exact bare-identifier lookup across all indexed definitions (including dependencies).
Sourcepub fn exact_local_symbols_by_name<'a>(
&'a self,
ident: &str,
) -> Vec<WorkspaceSymbol<'a>>
pub fn exact_local_symbols_by_name<'a>( &'a self, ident: &str, ) -> Vec<WorkspaceSymbol<'a>>
O(1) exact bare-identifier lookup across local (non-dependency) workspace definitions.
Sourcepub fn exact_symbols_filtered<'a, F>(
&'a self,
ident: &str,
filter: F,
) -> Vec<WorkspaceSymbol<'a>>
pub fn exact_symbols_filtered<'a, F>( &'a self, ident: &str, filter: F, ) -> Vec<WorkspaceSymbol<'a>>
O(1) exact bare-identifier lookup filtered by shard reader index.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn has_compiler_impl_defs(&self) -> bool
pub fn has_compiler_impl_defs(&self) -> bool
Returns true if any workspace shard contains compiler-emitted DefKind::Impl definitions.
Sourcepub fn find_implementations<'a>(
&'a self,
def: &ResolvedDefinition<'a>,
_file: &Path,
) -> Vec<WorkspaceReference<'a>>
pub fn find_implementations<'a>( &'a self, def: &ResolvedDefinition<'a>, _file: &Path, ) -> Vec<WorkspaceReference<'a>>
Finds all implementations for a nominal type, trait, or trait associated item.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn find_references<'a>(
&'a self,
target_path: &str,
) -> Vec<WorkspaceReference<'a>>
pub fn find_references<'a>( &'a self, target_path: &str, ) -> Vec<WorkspaceReference<'a>>
Finds all references to a symbol across every crate in the workspace.
Sourcepub fn type_at(&self, file: &str, line: u32, col: u32) -> Option<&str>
pub fn type_at(&self, file: &str, line: u32, col: u32) -> Option<&str>
Inferred expression type at cursor location.
Sourcepub fn type_entry_at(
&self,
file: &str,
line: u32,
col: u32,
) -> Option<(&str, Option<&str>)>
pub fn type_entry_at( &self, file: &str, line: u32, col: u32, ) -> Option<(&str, Option<&str>)>
Inferred expression type and optional canonical owner path at cursor location.
Sourcepub fn types_in_lines(
&self,
file: &str,
start_line: u32,
end_line: u32,
) -> Vec<((u32, u32), (u32, u32), &'_ str)>
pub fn types_in_lines( &self, file: &str, start_line: u32, end_line: u32, ) -> Vec<((u32, u32), (u32, u32), &'_ str)>
Every recorded type whose span starts on lines start_line..=end_line (1-based) of file, as
((start_line, start_col), (end_line, end_col), type) with 1-based columns. Every shard compiling the file
contributes (a library and its test harness compile different cfg regions); for a span recorded by several,
the first shard’s type is kept.
Sourcepub fn find_definitions_by_owner<'a>(
&'a self,
owner: &str,
) -> Vec<ResolvedDefinition<'a>>
pub fn find_definitions_by_owner<'a>( &'a self, owner: &str, ) -> Vec<ResolvedDefinition<'a>>
Finds all definitions belonging to an owner (canonical type path or module path) across the workspace.
Sourcepub fn find_definitions_by_owner_for_file<'a>(
&'a self,
file: &str,
owner: &str,
) -> Vec<ResolvedDefinition<'a>>
pub fn find_definitions_by_owner_for_file<'a>( &'a self, file: &str, owner: &str, ) -> Vec<ResolvedDefinition<'a>>
Finds all definitions belonging to an owner within the scope accessible from file.
Non-library targets (benchmarks, tests, examples, binaries) that do not contain file
are excluded from the search to prevent symbol leakage into standard library and crate queries.
Sourcepub fn resolve_deref_chain(&self, source: &str, max_depth: usize) -> Vec<&str>
pub fn resolve_deref_chain(&self, source: &str, max_depth: usize) -> Vec<&str>
Resolves the autoderef chain starting from source up to max_depth steps across the workspace.
Handles multiple supertraits across workspace readers via breadth-first search.
Sourcepub fn resolve_deref_chain_canonical(
&self,
source: &str,
max_depth: usize,
) -> Vec<String>
pub fn resolve_deref_chain_canonical( &self, source: &str, max_depth: usize, ) -> Vec<String>
Self::resolve_deref_chain with every target as a full path. A shard records a target inside its own crate
relative to that crate (parser::Parser in winnow); read bare, it can name another crate’s item (the
parser crate’s Parser struct). Such targets get the recording crate’s name in front.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn find_references_for_unit<'a>(
&'a self,
target_path: &str,
target_unit_key: Option<&str>,
) -> Vec<WorkspaceReference<'a>>
pub fn find_references_for_unit<'a>( &'a self, target_path: &str, target_unit_key: Option<&str>, ) -> Vec<WorkspaceReference<'a>>
Finds all references to a symbol, optionally scoped to a target dependency unit.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn cargo_main_entrypoint(
&self,
file_path: &Path,
) -> Option<(String, String)>
pub fn cargo_main_entrypoint( &self, file_path: &Path, ) -> Option<(String, String)>
Returns (target_kind, target_name) if file_path is a Cargo target root whose entrypoint is fn main.
Sourcepub fn check_rename_refusal_for_def(
&self,
def: &ResolvedDefinition<'_>,
precomputed_refs: Option<&[WorkspaceReference<'_>]>,
) -> Result<(), RenameRefusal>
pub fn check_rename_refusal_for_def( &self, def: &ResolvedDefinition<'_>, precomputed_refs: Option<&[WorkspaceReference<'_>]>, ) -> Result<(), RenameRefusal>
Evaluates all workspace-level semantic rename refusal rules for def.
Sourcepub fn check_prepare_rename_at<'a>(
&'a self,
file: &str,
line: u32,
col: u32,
) -> Option<Result<ResolvedDefinition<'a>, RenameRefusal>>
pub fn check_prepare_rename_at<'a>( &'a self, file: &str, line: u32, col: u32, ) -> Option<Result<ResolvedDefinition<'a>, RenameRefusal>>
Lightweight validation for textDocument/prepareRename without expanding full workspace edits.
Sourcepub fn unindexed_symbol_owner_info(
&self,
reader_idx: Option<usize>,
kind: DefKind,
path: &str,
file: &str,
start_line: u32,
) -> (String, String, bool, bool, bool)
pub fn unindexed_symbol_owner_info( &self, reader_idx: Option<usize>, kind: DefKind, path: &str, file: &str, start_line: u32, ) -> (String, String, bool, bool, bool)
Returns (def_crate, owner_short, is_trait_owner, has_self, is_externally_visible) for semantic resolution in unindexed Cargo targets.
Sourcepub fn try_find_rename_references_at<'a>(
&'a self,
file: &str,
line: u32,
col: u32,
) -> Option<Result<LocationReferences<'a>, RenameRefusal>>
pub fn try_find_rename_references_at<'a>( &'a self, file: &str, line: u32, col: u32, ) -> Option<Result<LocationReferences<'a>, RenameRefusal>>
Resolves and expands all workspace rename references at (file, line, col), returning an explicit
RenameRefusal if renaming the target symbol is semantically unsafe or disallowed.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn search_symbols<'a>(&'a self, query: &str) -> Vec<WorkspaceSymbol<'a>>
pub fn search_symbols<'a>(&'a self, query: &str) -> Vec<WorkspaceSymbol<'a>>
Substring symbol search across all definitions in the workspace.
Sourcepub fn search_local_symbols<'a>(
&'a self,
query: &str,
) -> Vec<WorkspaceSymbol<'a>>
pub fn search_local_symbols<'a>( &'a self, query: &str, ) -> Vec<WorkspaceSymbol<'a>>
Substring symbol search across non-dependency definitions in the workspace.
Sourcepub fn search_symbols_filtered<'a, F>(
&'a self,
query: &str,
filter: F,
) -> Vec<WorkspaceSymbol<'a>>
pub fn search_symbols_filtered<'a, F>( &'a self, query: &str, filter: F, ) -> Vec<WorkspaceSymbol<'a>>
Substring symbol search with custom reader predicate.
Sourcepub fn find_first_symbol<'a, F>(
&'a self,
query: &str,
predicate: F,
) -> Option<WorkspaceSymbol<'a>>
pub fn find_first_symbol<'a, F>( &'a self, query: &str, predicate: F, ) -> Option<WorkspaceSymbol<'a>>
Finds the first symbol matching query and predicate without eagerly collecting all matches.
Sourcepub fn for_each_symbol_ascii<F>(
&self,
needle_lower: &[u8],
preferred_crate: Option<&str>,
cb: F,
) -> bool
pub fn for_each_symbol_ascii<F>( &self, needle_lower: &[u8], preferred_crate: Option<&str>, cb: F, ) -> bool
Iterates over matching definitions across workspace readers without eager allocation,
searching preferred crate first and stopping when cb returns false or scan budget is exhausted.
Sourcepub fn for_each_symbol_in_crate<F>(
&self,
target_crate: &str,
needle_lower: &[u8],
cb: F,
) -> bool
pub fn for_each_symbol_in_crate<F>( &self, target_crate: &str, needle_lower: &[u8], cb: F, ) -> bool
Iterates over matching definitions specifically for a single target crate without eager allocation.
Sourcepub fn has_crate(&self, target_crate: &str) -> bool
pub fn has_crate(&self, target_crate: &str) -> bool
Returns true if any index reader in the workspace has the given crate name.
Sourcepub fn find_direct_references_at<'a>(
&'a self,
file: &str,
line: u32,
col: u32,
) -> Option<LocationReferences<'a>>
pub fn find_direct_references_at<'a>( &'a self, file: &str, line: u32, col: u32, ) -> Option<LocationReferences<'a>>
Finds all direct references to the symbol at cursor location without expanding across trait/impl containers.
Sourcepub fn resolve_definitions_at<'a>(
&'a self,
file: &str,
positions: &[(u32, u32)],
) -> Vec<Option<ResolvedDefinition<'a>>>
pub fn resolve_definitions_at<'a>( &'a self, file: &str, positions: &[(u32, u32)], ) -> Vec<Option<ResolvedDefinition<'a>>>
The definitions the symbols at positions in file refer to, as Self::find_direct_references_at resolves
them, without collecting their references. The file is located among the index’s units once.
Sourcepub fn resolve_definitions_in<'a>(
&'a self,
pairs: &[(usize, u32)],
file: &str,
positions: &[(u32, u32)],
) -> Vec<Option<ResolvedDefinition<'a>>>
pub fn resolve_definitions_in<'a>( &'a self, pairs: &[(usize, u32)], file: &str, positions: &[(u32, u32)], ) -> Vec<Option<ResolvedDefinition<'a>>>
Self::resolve_definitions_at with the file’s (reader, file id) pairs from
Self::resolved_reader_file_ids, for callers that resolve in one file many times.
Sourcepub fn find_references_at<'a>(
&'a self,
file: &str,
line: u32,
col: u32,
) -> Option<LocationReferences<'a>>
pub fn find_references_at<'a>( &'a self, file: &str, line: u32, col: u32, ) -> Option<LocationReferences<'a>>
Finds all references to the symbol at cursor location across the workspace, including container-scoped trait/impl links for associated items.
Sourcepub fn find_rename_references_at<'a>(
&'a self,
file: &str,
line: u32,
col: u32,
) -> Option<LocationReferences<'a>>
pub fn find_rename_references_at<'a>( &'a self, file: &str, line: u32, col: u32, ) -> Option<LocationReferences<'a>>
Finds all references and sibling trait/impl declarations required to rename the symbol at cursor.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn search_workspace_symbols<'a>(
&'a self,
query: &str,
limit: usize,
) -> Vec<WorkspaceSymbol<'a>>
pub fn search_workspace_symbols<'a>( &'a self, query: &str, limit: usize, ) -> Vec<WorkspaceSymbol<'a>>
Workspace symbol search. A plain query follows rust-analyzer (see search_workspace_symbols_like_ra); an empty
query or a path query (a::b) keeps the local-first substring search.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn find_definition_by_path<'a>(
&'a self,
path: &str,
) -> Option<ResolvedDefinition<'a>>
pub fn find_definition_by_path<'a>( &'a self, path: &str, ) -> Option<ResolvedDefinition<'a>>
Finds a definition by full or relative canonical path across the workspace.
Sourcepub fn crate_source_root(&self, crate_name: &str) -> Option<&Path>
pub fn crate_source_root(&self, crate_name: &str) -> Option<&Path>
Returns the source root path for a loaded crate, if it is an external dependency.
Sourcepub fn crate_name_for_file(&self, file_path: &str) -> Option<&str>
pub fn crate_name_for_file(&self, file_path: &str) -> Option<&str>
Returns the crate name that contains or owns the specified file path, if known.
Sourcepub fn resolve_path_for_crate(&self, crate_name: &str, file: &str) -> PathBuf
pub fn resolve_path_for_crate(&self, crate_name: &str, file: &str) -> PathBuf
Resolves a file path for a given crate. If the path is relative and the crate is an external dependency with a source root, joins the source root with the relative path.
Sourcepub fn find_type_param_in_scope<'a>(
&'a self,
file: &str,
name: &str,
line: u32,
col: u32,
) -> Option<ResolvedDefinition<'a>>
pub fn find_type_param_in_scope<'a>( &'a self, file: &str, name: &str, line: u32, col: u32, ) -> Option<ResolvedDefinition<'a>>
Finds a generic type parameter (DefKind::TyParam) in scope at (file, line, col).
Sourcepub fn find_owners_of_definition<'a>(
&'a self,
def: &ResolvedDefinition<'a>,
) -> Vec<&'a str>
pub fn find_owners_of_definition<'a>( &'a self, def: &ResolvedDefinition<'a>, ) -> Vec<&'a str>
Finds all owners/bounds associated with a definition.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn note_at(
&self,
file: &str,
line: u32,
col: u32,
kind: u32,
) -> Option<&str>
pub fn note_at( &self, file: &str, line: u32, col: u32, kind: u32, ) -> Option<&str>
The kind note whose span starts at (line, col) of file (an absolute or workspace path).
Sourcepub fn note_at_definition(
&self,
d: &ResolvedDefinition<'_>,
kind: u32,
) -> Option<&str>
pub fn note_at_definition( &self, d: &ResolvedDefinition<'_>, kind: u32, ) -> Option<&str>
The kind note at the name of definition d, read from the shard that defines it.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn shard_mtime_for_file(&self, file_path: &str) -> Option<SystemTime>
pub fn shard_mtime_for_file(&self, file_path: &str) -> Option<SystemTime>
Returns the file modification timestamp of the index shard containing the given source file.
Sourcepub fn units_agree_on_source(&self, file_path: &str) -> bool
pub fn units_agree_on_source(&self, file_path: &str) -> bool
Whether every compilation unit recording a source hash for file_path recorded the same one. A failed build of
one unit (lib test with an error in mod tests) leaves that unit’s data from the text before while the units
that built record the new text: no single text then matches all of the file’s data.
Every unit, not the candidates navigation ranks (those prefer the innermost source root): an integration test
of an outer package including the file with #[path] holds it too (review of 503071cb). Dependencies hold no
workspace file.
Sourcepub fn source_hash_for_file(&self, file_path: &str) -> Option<u64>
pub fn source_hash_for_file(&self, file_path: &str) -> Option<u64>
Returns the compiled source hash (from rustc compilation provenance) for a file if available.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn resolve_qualifier<'a>(
&'a self,
file: &str,
qual: &str,
) -> Option<ResolvedDefinition<'a>>
pub fn resolve_qualifier<'a>( &'a self, file: &str, qual: &str, ) -> Option<ResolvedDefinition<'a>>
Resolves a qualifier path in the lexical and module scope of file.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn reload_manifest_if_modified(&mut self) -> Result<bool>
pub fn reload_manifest_if_modified(&mut self) -> Result<bool>
Fast sub-microsecond check: verifies if ridx_manifest.json mtime/size/hash has changed. If manifest is unchanged, returns Ok(false) immediately with zero shard filesystem syscalls. If manifest was updated or switched, triggers full shard reload and returns Ok(true).
Sourcepub fn reload_if_modified(&mut self) -> Result<bool>
pub fn reload_if_modified(&mut self) -> Result<bool>
Checks timestamps of indexed files and reloads any that have changed. Also scans directory for newly generated .ridx files and removes deleted ones. If an active variant manifest exists and was switched, atomically reloads the new variant’s reader set. Returns true if any index was updated, added, removed, or switched.
Sourcepub fn reload_if_modified_with_cache_dir(
&mut self,
cache_dir: impl AsRef<Path>,
) -> Result<bool>
pub fn reload_if_modified_with_cache_dir( &mut self, cache_dir: impl AsRef<Path>, ) -> Result<bool>
Checks timestamps of indexed files and reloads any that have changed, using an explicit cache directory.
Sourcepub fn is_file_reloaded(&self, file_path: &str) -> bool
pub fn is_file_reloaded(&self, file_path: &str) -> bool
Checks if a file path belongs to any shard that was newly reloaded or published in the last reload.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn rename_cache(&self) -> Arc<RenameWorkspaceCache> ⓘ
pub fn rename_cache(&self) -> Arc<RenameWorkspaceCache> ⓘ
Returns the shared workspace rename cache for the current generation.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn has_sysroot(&self) -> bool
pub fn has_sysroot(&self) -> bool
Returns true if sysroot shards (core) are attached to the workspace.
Sourcepub fn lang_item(&self, kind: LangItemKind) -> Option<(usize, LangItemView)>
pub fn lang_item(&self, kind: LangItemKind) -> Option<(usize, LangItemView)>
Resolves kind across attached shards (core, alloc, workspace), returning (reader_idx, view).
Sourcepub fn attach_sysroot_shards_for_key(&mut self, cas_key: &str)
pub fn attach_sysroot_shards_for_key(&mut self, cas_key: &str)
Attaches cached sysroot shards for the given cas_key to the workspace if not already present.
Sourcepub fn attach_sysroot_shards_for_key_in(
&mut self,
base_cache: &Path,
cas_key: &str,
)
pub fn attach_sysroot_shards_for_key_in( &mut self, base_cache: &Path, cas_key: &str, )
Attaches cached sysroot shards for the given cas_key located in base_cache.
pub fn attach_shard_paths(&mut self, shards: &[PathBuf])
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn is_reader_in_dep_graph(
&self,
source_readers: &[usize],
target_reader_idx: usize,
) -> bool
pub fn is_reader_in_dep_graph( &self, source_readers: &[usize], target_reader_idx: usize, ) -> bool
Returns true if target_reader_idx is directly or transitively (up to 6 hops)
referenced in extern_units or dependencies of any reader in source_readers.
Sourcepub fn find_enclosing_impl_or_trait_def(
&self,
reader_idx: usize,
file_id: u32,
line: u32,
) -> Option<&DefEntry>
pub fn find_enclosing_impl_or_trait_def( &self, reader_idx: usize, file_id: u32, line: u32, ) -> Option<&DefEntry>
Finds the nearest preceding Impl, AssocFn, AssocTy, AssocConst, or Trait
definition in (reader_idx, file_id) at or before line via binary search on defs_by_pos.
Sourcepub fn find_type_param_in_reader<'a>(
&'a self,
reader_idx: usize,
file_id: u32,
name: &str,
line: u32,
col: u32,
) -> Option<ResolvedDefinition<'a>>
pub fn find_type_param_in_reader<'a>( &'a self, reader_idx: usize, file_id: u32, name: &str, line: u32, col: u32, ) -> Option<ResolvedDefinition<'a>>
Finds a generic type parameter (DefKind::TyParam) in (reader_idx, file_id) matching name
whose enclosing item span contains (line, col) via binary search on defs_by_pos.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn warm_background_caches(&self)
pub fn warm_background_caches(&self)
Spawns a background thread to warm the reachability bitset cache and workspace assoc-item indices.
Source§impl WorkspaceIndex
impl WorkspaceIndex
Sourcepub fn crate_count(&self) -> usize
pub fn crate_count(&self) -> usize
Number of crates loaded in this workspace index.
Sourcepub fn unit_match(&self) -> &UnitMatchIndex
pub fn unit_match(&self) -> &UnitMatchIndex
Reference to the internal unit matching index.
Sourcepub fn readers(&self) -> &[IndexReader<Mmap>]
pub fn readers(&self) -> &[IndexReader<Mmap>]
Slice of crate index readers.
Sourcepub fn generation_at(&self, idx: usize) -> Option<&str>
pub fn generation_at(&self, idx: usize) -> Option<&str>
Returns the snapshot generation for reader at index i.
Sourcepub fn meta_path_at(&self, idx: usize) -> Option<&Path>
pub fn meta_path_at(&self, idx: usize) -> Option<&Path>
Returns the sidecar metadata path for reader at index i.
Sourcepub fn meta_mtime_at(&self, idx: usize) -> Option<SystemTime>
pub fn meta_mtime_at(&self, idx: usize) -> Option<SystemTime>
Returns the sidecar metadata modification time for reader at index i.
Sourcepub fn source_root_at(&self, idx: usize) -> Option<&Path>
pub fn source_root_at(&self, idx: usize) -> Option<&Path>
Returns the source root path for reader at index i, if known.
Sourcepub fn stats(&self) -> WorkspaceStats
pub fn stats(&self) -> WorkspaceStats
Aggregated statistics across all crates in the workspace.
Sourcepub fn active_variant_id(&self) -> Option<&str>
pub fn active_variant_id(&self) -> Option<&str>
Currently active build variant ID, if loaded from a variant manifest.
Sourcepub fn sysroot_cas_key(&self) -> Option<&str>
pub fn sysroot_cas_key(&self) -> Option<&str>
Returns the sysroot CAS key from the active variant manifest, if present.
Sourcepub fn workspace_root(&self) -> Option<&Path>
pub fn workspace_root(&self) -> Option<&Path>
Root directory of the workspace if known.
Sourcepub fn set_workspace_root(&mut self, root: Option<PathBuf>)
pub fn set_workspace_root(&mut self, root: Option<PathBuf>)
Sets or overrides the workspace root directory.
Sourcepub fn is_external_target(
&self,
target_file: &str,
target_path: &Path,
target_unit_key: Option<&str>,
) -> bool
pub fn is_external_target( &self, target_file: &str, target_path: &Path, target_unit_key: Option<&str>, ) -> bool
Checks whether a target file, path, or unit key belongs to an external dependency or outside the workspace.
Sourcepub fn is_external_path(&self, path: &Path) -> bool
pub fn is_external_path(&self, path: &Path) -> bool
Checks whether an arbitrary path belongs to an external dependency or outside the workspace.
Sourcepub fn is_reader_dependency(&self, idx: usize) -> bool
pub fn is_reader_dependency(&self, idx: usize) -> bool
Returns whether the reader at index idx is marked as a dependency.
Sourcepub fn is_reader_external(&self, idx: usize) -> bool
pub fn is_reader_external(&self, idx: usize) -> bool
Checks whether the reader at index idx belongs to an external dependency or outside the workspace.
Sourcepub fn are_sibling_workspace_units(&self, idx1: usize, idx2: usize) -> bool
pub fn are_sibling_workspace_units(&self, idx1: usize, idx2: usize) -> bool
Checks whether two readers represent sibling units of the same workspace package
(e.g. lib and lib test shards of the same package).
Sibling units share the same non-external source root and crate name, but may have
distinct unit keys (e.g. unit_lib vs unit_test).
Sourcepub fn instance_id(&self) -> u64
pub fn instance_id(&self) -> u64
Returns the unique instance ID for this workspace.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Returns the current index generation counter. Incremented on each index reload or modification.
Sourcepub fn bump_generation(&mut self) -> u64
pub fn bump_generation(&mut self) -> u64
Explicitly bumps the index generation counter.