pub struct VisibilityIndex<'a> {
pub visible_by_file: HashMap<ProjectFile, HashSet<CodeUnit>>,
pub macro_include_protection_cells: Mutex<HashMap<ProjectFile, Arc<OnceLock<MacroIncludeProtection>>>>,
pub macro_environment_cursors: Mutex<HashMap<(ProjectFile, ThreadId), MacroEnvironmentCursorCell>>,
/* private fields */
}Expand description
Per-query C++ visibility facts.
The analyzer is borrowed, never cloned: TreeSitterAnalyzer::clone gives
the clone a fresh, empty QueryReadCache on purpose (clones cross
generations and overlays, where another generation’s hydrated states would
be wrong). An index that owned a clone would therefore see an inactive read
cache for every prepared_syntax call it makes, re-reading and re-parsing
the same source from the store once per candidate instead of once per query
— the #1175 blow-up, where one scan re-parsed a 4.8 MB generated header
tens of thousands of times.
Fields§
§visible_by_file: HashMap<ProjectFile, HashSet<CodeUnit>>§macro_include_protection_cells: Mutex<HashMap<ProjectFile, Arc<OnceLock<MacroIncludeProtection>>>>§macro_environment_cursors: Mutex<HashMap<(ProjectFile, ThreadId), MacroEnvironmentCursorCell>>Implementations§
Source§impl<'a> VisibilityIndex<'a>
impl<'a> VisibilityIndex<'a>
pub fn cpp(&self) -> &'a dyn CppSource
pub fn build( cpp: &'a dyn CppSource, analyzer: &CppGraphSource<'_>, roots: &HashSet<ProjectFile>, ) -> Self
pub fn build_with_cancellation( cpp: &'a dyn CppSource, analyzer: &CppGraphSource<'_>, roots: &HashSet<ProjectFile>, cancellation: Option<&CancellationToken>, ) -> Self
pub fn is_visible(&self, file: &ProjectFile, target: &CodeUnit) -> bool
pub fn call_arity_evidence( &self, file: &ProjectFile, call: Node<'_>, source: &str, ) -> CallArityEvidence
pub fn macro_event_cell(&self, file: &ProjectFile) -> MacroEventCell
pub fn macro_environment_cursor_cell( &self, file: &ProjectFile, ) -> MacroEnvironmentCursorCell
pub fn macro_environment( &self, file: &ProjectFile, before_byte: usize, ) -> Arc<MacroEnvironment> ⓘ
pub fn object_macro_replacement_at( &self, file: &ProjectFile, name: &str, before_byte: usize, ) -> Option<String>
pub fn macro_include_protection( &self, file: &ProjectFile, ) -> MacroIncludeProtection
pub fn ordinary_type_import_cell( &self, file: &ProjectFile, ) -> OrdinaryTypeImportCell
pub fn project_using_index( &self, build: impl FnOnce() -> ProjectUsingIndex, ) -> &ProjectUsingIndex
pub fn all_visible_source_files(&self) -> Vec<ProjectFile>
pub fn source_is_visible( &self, root: &ProjectFile, source: &ProjectFile, ) -> bool
pub fn include_activation_for_source( &self, cpp: &dyn CppSource, file: &ProjectFile, prepared: &PreparedSyntaxTree, donor_source: &ProjectFile, ) -> Option<usize>
pub fn conditional_include_projections_for_source( &self, file: &ProjectFile, prepared: &PreparedSyntaxTree, donor_source: &ProjectFile, ) -> Arc<[ConditionalIncludeProjection]> ⓘ
pub fn note_using_donor_activation_for_test(&self)
pub fn note_using_namespace_lookup_for_test(&self)
pub fn note_using_name_candidate_inspection_for_test(&self)
pub fn note_using_source_index_walk_for_test(&self)
pub fn is_physically_visible( &self, file: &ProjectFile, target: &CodeUnit, ) -> bool
pub fn declaration_visible_at( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, declaration: &CodeUnit, reference_byte: usize, ) -> bool
pub fn callable_arity_at_reference( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, reference_byte: usize, ) -> Option<CallableArity>
pub fn external_type_candidate_visible_at( &self, file: &ProjectFile, candidate: &CodeUnit, reference_byte: usize, ) -> bool
pub fn external_type_declaration_visible_at( &self, file: &ProjectFile, candidate: &CodeUnit, reference_byte: usize, ) -> bool
pub fn external_type_candidate_visible_in_context( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, reference: Node<'_>, ) -> bool
pub fn is_exhaustive_same_fqn_type_declaration_family( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, ) -> bool
Sourcepub fn dependent_member_pointer_alias_visible_in_context(
&self,
analyzer: &CppGraphSource<'_>,
file: &ProjectFile,
candidate: &CodeUnit,
owner_components: &[String],
reference: Node<'_>,
) -> bool
pub fn dependent_member_pointer_alias_visible_in_context( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, owner_components: &[String], reference: Node<'_>, ) -> bool
Prove a nested type alias used as a dependent member-pointer owner when its owning class has mutually-exclusive declarations. A common C++11 compatibility shape provides the owning class in one preprocessor branch and aliases it to a standard-library type in the other branch; the nested fallback alias is therefore not itself active in every branch even though the qualified owner API is.
This is deliberately narrower than ordinary type visibility. The caller has already recovered a member-pointer owner path from the CST; this helper additionally requires the target’s structured parent to match that path, physical source visibility, and exact preprocessor guard agreement with the parent declaration. Only then may the parent’s direct/complementary same-FQN visibility stand in for the nested terminal’s active-branch check.
Sourcepub fn external_type_candidate_guard_compatible_in_context(
&self,
analyzer: &CppGraphSource<'_>,
file: &ProjectFile,
candidate: &CodeUnit,
reference: Node<'_>,
) -> bool
pub fn external_type_candidate_guard_compatible_in_context( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, reference: Node<'_>, ) -> bool
Check a type candidate’s preprocessor/import context without imposing ordinary declaration-before-reference ordering for same-file peers.
C++ class scope makes member names visible throughout the complete class, including a trailing return type that appears before the member alias declaration in source order. Callers must first prove that the reference is inside the candidate’s indexed class owner; this helper only relaxes the byte-order predicate while retaining guard and include activation checks.
pub fn type_candidate_may_be_visible_before_reference( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, reference_byte: usize, ) -> bool
pub fn preprocessor_guards_stable_between( &self, file: &ProjectFile, start_byte: usize, end_byte: usize, guards: &HashSet<PreprocessorGuard>, ) -> bool
pub fn resolve_type( &self, file: &ProjectFile, raw_name: &str, ) -> Option<CodeUnit>
pub fn resolve_type_node_result( &self, file: &ProjectFile, node: Node<'_>, source: &str, ) -> Result<Option<CodeUnit>, CppTemplateResolutionError>
pub fn resolve_type_node_primary( &self, file: &ProjectFile, node: Node<'_>, source: &str, ) -> Option<CodeUnit>
pub fn resolve_template_arguments( &self, file: &ProjectFile, primary: CodeUnit, arguments: &[CppTemplateExpression], ) -> Result<CodeUnit, CppTemplateResolutionError>
pub fn resolve_type_components_lexically( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, components: &[String], global: bool, lexical_scope: &[String], ) -> LexicalTypeResolution
pub fn resolve_type_components_lexically_for_forward( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, components: &[String], global: bool, lexical_scope: &[String], ) -> LexicalTypeResolution
pub fn resolve_type_components_lexically_for_target( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, components: &[String], global: bool, lexical_scope: &[String], target: &CodeUnit, ) -> LexicalTypeResolution
pub fn coarse_unqualified_type_reference_may_resolve( &self, file: &ProjectFile, name: &str, ) -> bool
pub fn structured_type_reference_may_resolve_to_target( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, components: &[String], global: bool, lexical_scope: &[String], target: &CodeUnit, ) -> bool
pub fn target_preserving_reference_namespace( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, identifier: &str, target: &CodeUnit, ) -> Option<Vec<String>>
pub fn resolve_imported_type_candidate( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, target: &CodeUnit, target_components: &[String], direct_target: Option<&CodeUnit>, preserve_alias: bool, ) -> LexicalTypeResolution
pub fn resolve_callable_value_components_lexically( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, owner_components: &[String], member_name: &str, global: bool, lexical_scope: &[String], ) -> LexicalCallableValueResolution
pub fn canonical_type_unit( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, unit: &CodeUnit, ) -> Option<CodeUnit>
pub fn canonical_visible_full_type_unit( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, unit: &CodeUnit, ) -> Option<CodeUnit>
pub fn structured_alias_primary_preserves_target( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, candidate: &CodeUnit, target: &CodeUnit, ) -> bool
pub fn structured_class_alias_resolves_to_target( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, alias: &CodeUnit, target: &CodeUnit, ) -> bool
pub fn template_alias_arguments_preserve_target( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, alias: &CodeUnit, arguments: &[CppTemplateExpression], target: &CodeUnit, ) -> bool
pub fn is_primary_template(&self, unit: &CodeUnit) -> bool
pub fn is_template_specialization(&self, unit: &CodeUnit) -> bool
pub fn same_template_owner_identity( &self, left: &CodeUnit, right: &CodeUnit, ) -> bool
pub fn same_template_member_identity( &self, analyzer: &CppGraphSource<'_>, left: &CodeUnit, right: &CodeUnit, ) -> bool
pub fn unique_type_candidate_preserving_target( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, candidates: &[&CodeUnit], target: &CodeUnit, ) -> Option<CodeUnit>
pub fn alternate_same_fqn_type_declarations( &self, analyzer: &CppGraphSource<'_>, candidates: &[&CodeUnit], target: &CodeUnit, ) -> bool
pub fn complementary_same_fqn_type_declarations( &self, analyzer: &CppGraphSource<'_>, candidates: &[&CodeUnit], target: &CodeUnit, ) -> bool
pub fn resolves_to_type( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, raw_name: &str, target: &CodeUnit, ) -> bool
pub fn alias_target(&self, alias: &CodeUnit) -> Option<CodeUnit>
pub fn canonical_type_for_reference( &self, file: &ProjectFile, raw_name: &str, ) -> Option<CodeUnit>
pub fn parser_alias_resolves_to_type( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, raw_name: &str, target: &CodeUnit, ) -> bool
pub fn resolve_named( &self, file: &ProjectFile, raw_name: &str, kind: TargetKind, ) -> Option<CodeUnit>
pub fn contains_named_symbol( &self, file: &ProjectFile, raw_name: &str, kind: TargetKind, target: &CodeUnit, ) -> bool
pub fn named_candidates( &self, file: &ProjectFile, raw_name: &str, kind: TargetKind, ) -> Vec<CodeUnit>
pub fn resolve_known_non_target( &self, file: &ProjectFile, raw_name: &str, kind: TargetKind, target: &CodeUnit, ) -> bool
pub fn resolve_call_return_binding( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, raw_name: &str, arity: usize, lexical_namespace: Option<&str>, direct_type: Option<&CodeUnit>, ) -> Option<CppScanBinding>
pub fn resolve_call_return_binding_without_arity( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, raw_name: &str, lexical_namespace: Option<&str>, direct_type: Option<&CodeUnit>, ) -> (bool, Option<CppScanBinding>)
pub fn visible_identifier_candidates<'b>( &'b self, file: &ProjectFile, identifier: &str, ) -> impl Iterator<Item = &'b CodeUnit> + 'b
Sourcepub fn visible_type_reference_component_names_for_target(
&self,
analyzer: &CppGraphSource<'_>,
file: &ProjectFile,
target: &CodeUnit,
) -> HashSet<String>
pub fn visible_type_reference_component_names_for_target( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, target: &CodeUnit, ) -> HashSet<String>
Return terminal reference names that can denote target from file.
The indexed candidate table covers ordinary declarations and aliases; parser-only aliases are read through their per-file cells so this path never reparses a source that has already been inspected by the visibility index.
pub fn indexed_structural_class_scope( &self, file: &ProjectFile, class: Node<'_>, source: &str, ) -> Option<Vec<String>>
pub fn indexed_enclosing_owner_scope( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, node: Node<'_>, ) -> Option<Vec<String>>
pub fn callable_is_constructor_declaration( &self, analyzer: &CppGraphSource<'_>, candidate: &CodeUnit, ) -> bool
pub fn type_name_candidates<'b>( &'b self, file: &ProjectFile, normalized: &str, ) -> Vec<&'b CodeUnit>
pub fn visible_members_for_owner_name<'b>( &'b self, file: &ProjectFile, owner: &CodeUnit, name: &str, ) -> Vec<&'b CodeUnit>
pub fn visible_member_for_owner_name( &self, file: &ProjectFile, owner: &CodeUnit, name: &str, ) -> VisibleMemberResolution
pub fn type_candidates<'b>( &'b self, file: &ProjectFile, normalized: &str, ) -> Vec<&'b CodeUnit>
pub fn named_candidates_for_normalized<'b>( &'b self, file: &ProjectFile, normalized: &str, kind: TargetKind, ) -> Vec<&'b CodeUnit>
pub fn candidate_units<'b>( &'b self, file: &ProjectFile, normalized: &str, kind: TargetKind, ) -> Vec<&'b CodeUnit>
Auto Trait Implementations§
impl<'a> !Freeze for VisibilityIndex<'a>
impl<'a> !RefUnwindSafe for VisibilityIndex<'a>
impl<'a> !UnwindSafe for VisibilityIndex<'a>
impl<'a> Send for VisibilityIndex<'a>
impl<'a> Sync for VisibilityIndex<'a>
impl<'a> Unpin for VisibilityIndex<'a>
impl<'a> UnsafeUnpin for VisibilityIndex<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more