Skip to main content

GraphBuilderV2

Struct GraphBuilderV2 

Source
pub struct GraphBuilderV2<'a> { /* private fields */ }
Expand description

Builder for constructing CodeGraphV2.

Provides a convenient API for adding symbols and relationships to the graph.

§Example

let mut registry = SymbolRegistry::new();
let mut builder = GraphBuilderV2::new(&mut registry);

let foo = builder.add_symbol(SymbolPath::parse("mylib::foo")?, SymbolKind::Function)?;
let bar = builder.add_symbol(SymbolPath::parse("mylib::bar")?, SymbolKind::Function)?;
builder.add_call(foo, bar);

let graph = builder.build();

Implementations§

Source§

impl<'a> GraphBuilderV2<'a>

Source

pub fn new(registry: &'a mut SymbolRegistry) -> Self

Create a new builder.

Source

pub fn with_capacity( registry: &'a mut SymbolRegistry, nodes: usize, edges: usize, ) -> Self

Create a new builder with pre-allocated capacity.

Source

pub fn add_symbol( &mut self, path: SymbolPath, kind: SymbolKind, ) -> Result<SymbolId, RegistrationError>

Add a symbol to both registry and graph.

Returns the SymbolId for the added symbol. Also adds the symbol to the kind index for efficient kind-based queries.

Source

pub fn add_existing_symbol(&mut self, id: SymbolId, kind: SymbolKind)

Add an existing symbol to the graph (already registered in registry).

Use this when the symbol is already registered but not yet in the graph.

Source

pub fn add_crate_root( &mut self, path: SymbolPath, ) -> Result<SymbolId, RegistrationError>

Add a crate root.

Source

pub fn add_existing_crate_root(&mut self, id: SymbolId)

Add an existing symbol as a crate root.

Source

pub fn add_contains(&mut self, parent: SymbolId, child: SymbolId)

Add a Contains relationship (parent → child).

Source

pub fn add_call(&mut self, caller: SymbolId, callee: SymbolId)

Add a Calls relationship (caller → callee).

Source

pub fn add_implements(&mut self, implementor: SymbolId, trait_or_type: SymbolId)

Add an Implements relationship (implementor → trait/type).

Source

pub fn add_match_expr( &mut self, function_id: SymbolId, file_id: FileId, enum_id: SymbolId, offset: u32, line: u32, )

Add a match expression to a function (String-free version).

Uses FileId and SymbolId instead of PathBuf and String.

§Arguments
  • function_id - The function containing the match expression
  • file_id - The file containing the match expression
  • enum_id - The enum being matched
  • offset - Byte offset in the file
  • line - Line number (1-indexed)
Source

pub fn build(self) -> CodeGraphV2

Build the graph, consuming the builder.

Note: Unlike V1, indices are built incrementally during add_symbol, so no post-build index rebuild is needed.

Source

pub fn registry(&self) -> &SymbolRegistry

Get a reference to the registry.

Source

pub fn registry_mut(&mut self) -> &mut SymbolRegistry

Get a mutable reference to the registry.

Source

pub fn graph(&self) -> &CodeGraphV2

Get a reference to the graph being built.

Auto Trait Implementations§

§

impl<'a> Freeze for GraphBuilderV2<'a>

§

impl<'a> RefUnwindSafe for GraphBuilderV2<'a>

§

impl<'a> Send for GraphBuilderV2<'a>

§

impl<'a> Sync for GraphBuilderV2<'a>

§

impl<'a> Unpin for GraphBuilderV2<'a>

§

impl<'a> UnsafeUnpin for GraphBuilderV2<'a>

§

impl<'a> !UnwindSafe for GraphBuilderV2<'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> 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> 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.