Skip to main content

VisibilityIndex

Struct VisibilityIndex 

Source
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>

Source

pub fn cpp(&self) -> &'a dyn CppSource

Source

pub fn build( cpp: &'a dyn CppSource, analyzer: &CppGraphSource<'_>, roots: &HashSet<ProjectFile>, ) -> Self

Source

pub fn build_with_cancellation( cpp: &'a dyn CppSource, analyzer: &CppGraphSource<'_>, roots: &HashSet<ProjectFile>, cancellation: Option<&CancellationToken>, ) -> Self

Source

pub fn is_visible(&self, file: &ProjectFile, target: &CodeUnit) -> bool

Source

pub fn call_arity_evidence( &self, file: &ProjectFile, call: Node<'_>, source: &str, ) -> CallArityEvidence

Source

pub fn macro_event_cell(&self, file: &ProjectFile) -> MacroEventCell

Source

pub fn macro_environment_cursor_cell( &self, file: &ProjectFile, ) -> MacroEnvironmentCursorCell

Source

pub fn macro_environment( &self, file: &ProjectFile, before_byte: usize, ) -> Arc<MacroEnvironment>

Source

pub fn object_macro_replacement_at( &self, file: &ProjectFile, name: &str, before_byte: usize, ) -> Option<String>

Source

pub fn macro_include_protection( &self, file: &ProjectFile, ) -> MacroIncludeProtection

Source

pub fn ordinary_type_import_cell( &self, file: &ProjectFile, ) -> OrdinaryTypeImportCell

Source

pub fn project_using_index( &self, build: impl FnOnce() -> ProjectUsingIndex, ) -> &ProjectUsingIndex

Source

pub fn all_visible_source_files(&self) -> Vec<ProjectFile>

Source

pub fn source_is_visible( &self, root: &ProjectFile, source: &ProjectFile, ) -> bool

Source

pub fn include_activation_for_source( &self, cpp: &dyn CppSource, file: &ProjectFile, prepared: &PreparedSyntaxTree, donor_source: &ProjectFile, ) -> Option<usize>

Source

pub fn conditional_include_projections_for_source( &self, file: &ProjectFile, prepared: &PreparedSyntaxTree, donor_source: &ProjectFile, ) -> Arc<[ConditionalIncludeProjection]>

Source

pub fn note_using_donor_activation_for_test(&self)

Source

pub fn note_using_namespace_lookup_for_test(&self)

Source

pub fn note_using_name_candidate_inspection_for_test(&self)

Source

pub fn note_using_source_index_walk_for_test(&self)

Source

pub fn is_physically_visible( &self, file: &ProjectFile, target: &CodeUnit, ) -> bool

Source

pub fn declaration_visible_at( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, declaration: &CodeUnit, reference_byte: usize, ) -> bool

Source

pub fn callable_arity_at_reference( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, reference_byte: usize, ) -> Option<CallableArity>

Source

pub fn external_type_candidate_visible_at( &self, file: &ProjectFile, candidate: &CodeUnit, reference_byte: usize, ) -> bool

Source

pub fn external_type_declaration_visible_at( &self, file: &ProjectFile, candidate: &CodeUnit, reference_byte: usize, ) -> bool

Source

pub fn external_type_candidate_visible_in_context( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, reference: Node<'_>, ) -> bool

Source

pub fn is_exhaustive_same_fqn_type_declaration_family( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, ) -> bool

Source

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.

Source

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.

Source

pub fn type_candidate_may_be_visible_before_reference( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, candidate: &CodeUnit, reference_byte: usize, ) -> bool

Source

pub fn preprocessor_guards_stable_between( &self, file: &ProjectFile, start_byte: usize, end_byte: usize, guards: &HashSet<PreprocessorGuard>, ) -> bool

Source

pub fn resolve_type( &self, file: &ProjectFile, raw_name: &str, ) -> Option<CodeUnit>

Source

pub fn resolve_type_node_result( &self, file: &ProjectFile, node: Node<'_>, source: &str, ) -> Result<Option<CodeUnit>, CppTemplateResolutionError>

Source

pub fn resolve_type_node_primary( &self, file: &ProjectFile, node: Node<'_>, source: &str, ) -> Option<CodeUnit>

Source

pub fn resolve_template_arguments( &self, file: &ProjectFile, primary: CodeUnit, arguments: &[CppTemplateExpression], ) -> Result<CodeUnit, CppTemplateResolutionError>

Source

pub fn resolve_type_components_lexically( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, components: &[String], global: bool, lexical_scope: &[String], ) -> LexicalTypeResolution

Source

pub fn resolve_type_components_lexically_for_forward( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, components: &[String], global: bool, lexical_scope: &[String], ) -> LexicalTypeResolution

Source

pub fn resolve_type_components_lexically_for_target( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, components: &[String], global: bool, lexical_scope: &[String], target: &CodeUnit, ) -> LexicalTypeResolution

Source

pub fn coarse_unqualified_type_reference_may_resolve( &self, file: &ProjectFile, name: &str, ) -> bool

Source

pub fn structured_type_reference_may_resolve_to_target( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, components: &[String], global: bool, lexical_scope: &[String], target: &CodeUnit, ) -> bool

Source

pub fn target_preserving_reference_namespace( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, identifier: &str, target: &CodeUnit, ) -> Option<Vec<String>>

Source

pub fn resolve_imported_type_candidate( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, target: &CodeUnit, target_components: &[String], direct_target: Option<&CodeUnit>, preserve_alias: bool, ) -> LexicalTypeResolution

Source

pub fn resolve_callable_value_components_lexically( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, owner_components: &[String], member_name: &str, global: bool, lexical_scope: &[String], ) -> LexicalCallableValueResolution

Source

pub fn canonical_type_unit( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, unit: &CodeUnit, ) -> Option<CodeUnit>

Source

pub fn canonical_visible_full_type_unit( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, unit: &CodeUnit, ) -> Option<CodeUnit>

Source

pub fn structured_alias_primary_preserves_target( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, candidate: &CodeUnit, target: &CodeUnit, ) -> bool

Source

pub fn structured_class_alias_resolves_to_target( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, alias: &CodeUnit, target: &CodeUnit, ) -> bool

Source

pub fn template_alias_arguments_preserve_target( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, alias: &CodeUnit, arguments: &[CppTemplateExpression], target: &CodeUnit, ) -> bool

Source

pub fn is_primary_template(&self, unit: &CodeUnit) -> bool

Source

pub fn is_template_specialization(&self, unit: &CodeUnit) -> bool

Source

pub fn same_template_owner_identity( &self, left: &CodeUnit, right: &CodeUnit, ) -> bool

Source

pub fn same_template_member_identity( &self, analyzer: &CppGraphSource<'_>, left: &CodeUnit, right: &CodeUnit, ) -> bool

Source

pub fn unique_type_candidate_preserving_target( &self, analyzer: &CppGraphSource<'_>, visible_from: &ProjectFile, candidates: &[&CodeUnit], target: &CodeUnit, ) -> Option<CodeUnit>

Source

pub fn alternate_same_fqn_type_declarations( &self, analyzer: &CppGraphSource<'_>, candidates: &[&CodeUnit], target: &CodeUnit, ) -> bool

Source

pub fn complementary_same_fqn_type_declarations( &self, analyzer: &CppGraphSource<'_>, candidates: &[&CodeUnit], target: &CodeUnit, ) -> bool

Source

pub fn resolves_to_type( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, raw_name: &str, target: &CodeUnit, ) -> bool

Source

pub fn alias_target(&self, alias: &CodeUnit) -> Option<CodeUnit>

Source

pub fn canonical_type_for_reference( &self, file: &ProjectFile, raw_name: &str, ) -> Option<CodeUnit>

Source

pub fn parser_alias_resolves_to_type( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, raw_name: &str, target: &CodeUnit, ) -> bool

Source

pub fn resolve_named( &self, file: &ProjectFile, raw_name: &str, kind: TargetKind, ) -> Option<CodeUnit>

Source

pub fn contains_named_symbol( &self, file: &ProjectFile, raw_name: &str, kind: TargetKind, target: &CodeUnit, ) -> bool

Source

pub fn named_candidates( &self, file: &ProjectFile, raw_name: &str, kind: TargetKind, ) -> Vec<CodeUnit>

Source

pub fn resolve_known_non_target( &self, file: &ProjectFile, raw_name: &str, kind: TargetKind, target: &CodeUnit, ) -> bool

Source

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>

Source

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>)

Source

pub fn visible_identifier_candidates<'b>( &'b self, file: &ProjectFile, identifier: &str, ) -> impl Iterator<Item = &'b CodeUnit> + 'b

Source

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.

Source

pub fn indexed_structural_class_scope( &self, file: &ProjectFile, class: Node<'_>, source: &str, ) -> Option<Vec<String>>

Source

pub fn indexed_enclosing_owner_scope( &self, analyzer: &CppGraphSource<'_>, file: &ProjectFile, node: Node<'_>, ) -> Option<Vec<String>>

Source

pub fn callable_is_constructor_declaration( &self, analyzer: &CppGraphSource<'_>, candidate: &CodeUnit, ) -> bool

Source

pub fn type_name_candidates<'b>( &'b self, file: &ProjectFile, normalized: &str, ) -> Vec<&'b CodeUnit>

Source

pub fn visible_members_for_owner_name<'b>( &'b self, file: &ProjectFile, owner: &CodeUnit, name: &str, ) -> Vec<&'b CodeUnit>

Source

pub fn visible_member_for_owner_name( &self, file: &ProjectFile, owner: &CodeUnit, name: &str, ) -> VisibleMemberResolution

Source

pub fn type_candidates<'b>( &'b self, file: &ProjectFile, normalized: &str, ) -> Vec<&'b CodeUnit>

Source

pub fn named_candidates_for_normalized<'b>( &'b self, file: &ProjectFile, normalized: &str, kind: TargetKind, ) -> Vec<&'b CodeUnit>

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CapabilityProvider for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.