pub struct GraphBuildHelper<'a> { /* private fields */ }Expand description
Helper for building graphs in GraphBuilder implementations.
Provides high-level abstractions over StagingGraph that handle:
- String interning with local ID tracking
- Qualified name deduplication
- Node and edge creation with proper types
Implementations§
Source§impl<'a> GraphBuildHelper<'a>
impl<'a> GraphBuildHelper<'a>
Sourcepub fn new(
staging: &'a mut StagingGraph,
file: &Path,
language: Language,
) -> Self
pub fn new( staging: &'a mut StagingGraph, file: &Path, language: Language, ) -> Self
Create a new helper for the given staging graph and file.
The file_id should be pre-allocated by the caller (typically 0 for
per-file staging buffers).
Sourcepub fn with_file_id(
staging: &'a mut StagingGraph,
file: &Path,
language: Language,
file_id: FileId,
) -> Self
pub fn with_file_id( staging: &'a mut StagingGraph, file: &Path, language: Language, file_id: FileId, ) -> Self
Create a helper with a specific file ID.
Sourcepub fn lookup_node(&self, name: &str, kind: NodeKind) -> Option<NodeId>
pub fn lookup_node(&self, name: &str, kind: NodeKind) -> Option<NodeId>
Look up a node ID by its qualified name and kind from the internal cache.
Returns the NodeId if a node with the given (name, kind) pair was
previously created through this helper. This is used by macro boundary
analysis to find graph nodes corresponding to AST items.
Sourcepub fn staging_mut(&mut self) -> &mut StagingGraph
pub fn staging_mut(&mut self) -> &mut StagingGraph
Mutable access to the underlying StagingGraph.
Exposed for plugin call sites that need to forward typed
metadata into the staging buffer alongside their normal add_*
node-creation flow — for example, the Go plugin’s
add_synthetic_variable helper (C_SUPPRESS) which calls
StagingGraph::merge_macro_metadata to record a
NodeFlags::SYNTHETIC flag on the freshly-staged Variable
node so the suppression contract on
[crate::graph::unified::concurrent::graph::GraphSnapshot::find_by_pattern]
is satisfied via the canonical metadata-bit channel (in addition
to the structural name-shape fallback).
Sourcepub fn attach_body_hashes(&mut self, content: &[u8])
pub fn attach_body_hashes(&mut self, content: &[u8])
Attach body hashes to all staged nodes using the given content bytes.
Multi-language plugins (Vue, Svelte) should call this per extracted script block so that node body spans — which are relative to the block content, not the full SFC file — produce correct hashes. Nodes that already have a hash are skipped, so the later whole-file call in the indexing entrypoint is harmless.
Sourcepub fn intern(&mut self, s: &str) -> StringId
pub fn intern(&mut self, s: &str) -> StringId
Intern a string and get a local StringId.
Strings are deduplicated: calling with the same value returns the same ID.
The local StringId is passed to the staging graph so that during
commit_strings(), a remap table from local to global IDs can be built.
Sourcepub fn has_node(&self, qualified_name: &str) -> bool
pub fn has_node(&self, qualified_name: &str) -> bool
Check if a node with the given qualified name already exists.
Sourcepub fn get_node(&self, qualified_name: &str) -> Option<NodeId>
pub fn get_node(&self, qualified_name: &str) -> Option<NodeId>
Get an existing node by qualified name.
Sourcepub fn has_node_with_kind(&self, qualified_name: &str, kind: NodeKind) -> bool
pub fn has_node_with_kind(&self, qualified_name: &str, kind: NodeKind) -> bool
Check if a node with the given qualified name and kind already exists.
Sourcepub fn get_node_with_kind(
&self,
qualified_name: &str,
kind: NodeKind,
) -> Option<NodeId>
pub fn get_node_with_kind( &self, qualified_name: &str, kind: NodeKind, ) -> Option<NodeId>
Get an existing node by qualified name and kind.
Sourcepub fn add_function(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_async: bool,
is_unsafe: bool,
) -> NodeId
pub fn add_function( &mut self, qualified_name: &str, span: Option<Span>, is_async: bool, is_unsafe: bool, ) -> NodeId
Add a function node with the given qualified name.
Returns the NodeId (creating the node if it doesn’t exist).
Sourcepub fn add_function_with_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_async: bool,
is_unsafe: bool,
visibility: Option<&str>,
) -> NodeId
pub fn add_function_with_visibility( &mut self, qualified_name: &str, span: Option<Span>, is_async: bool, is_unsafe: bool, visibility: Option<&str>, ) -> NodeId
Add a function node with visibility.
Returns the NodeId (creating the node if it doesn’t exist).
Sourcepub fn add_function_with_signature(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_async: bool,
is_unsafe: bool,
visibility: Option<&str>,
signature: Option<&str>,
) -> NodeId
pub fn add_function_with_signature( &mut self, qualified_name: &str, span: Option<Span>, is_async: bool, is_unsafe: bool, visibility: Option<&str>, signature: Option<&str>, ) -> NodeId
Add a function node with signature (return type).
The signature is used for returns: queries.
Returns the NodeId (creating the node if it doesn’t exist).
Sourcepub fn add_method(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_async: bool,
is_static: bool,
) -> NodeId
pub fn add_method( &mut self, qualified_name: &str, span: Option<Span>, is_async: bool, is_static: bool, ) -> NodeId
Add a method node with the given qualified name.
Sourcepub fn add_method_with_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_async: bool,
is_static: bool,
visibility: Option<&str>,
) -> NodeId
pub fn add_method_with_visibility( &mut self, qualified_name: &str, span: Option<Span>, is_async: bool, is_static: bool, visibility: Option<&str>, ) -> NodeId
Add a method node with visibility.
Sourcepub fn add_method_with_signature(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_async: bool,
is_static: bool,
visibility: Option<&str>,
signature: Option<&str>,
) -> NodeId
pub fn add_method_with_signature( &mut self, qualified_name: &str, span: Option<Span>, is_async: bool, is_static: bool, visibility: Option<&str>, signature: Option<&str>, ) -> NodeId
Add a method node with signature (return type).
The signature is used for returns: queries.
Returns the NodeId (creating the node if it doesn’t exist).
Sourcepub fn add_class(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
pub fn add_class(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
Add a class node.
Dual-use bare helper (issue #394): also used to create type-reference
stubs (e.g. puppet inherited-class targets), so it defaults
is_definition = false. Real declaration sites opt in via
mark_definition (or use
add_class_with_visibility).
Sourcepub fn add_class_with_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
visibility: Option<&str>,
) -> NodeId
pub fn add_class_with_visibility( &mut self, qualified_name: &str, span: Option<Span>, visibility: Option<&str>, ) -> NodeId
Add a class node with visibility.
Sourcepub fn add_struct(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
pub fn add_struct(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
Add a struct node.
Dual-use bare helper (issue #394): also used to create reference stubs
(e.g. go embedded-parent-struct targets), so it defaults
is_definition = false. Real declaration sites opt in via
mark_definition (or use
add_struct_with_visibility).
Sourcepub fn add_struct_with_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
visibility: Option<&str>,
) -> NodeId
pub fn add_struct_with_visibility( &mut self, qualified_name: &str, span: Option<Span>, visibility: Option<&str>, ) -> NodeId
Add a struct node with visibility.
Sourcepub fn add_module(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
pub fn add_module(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
Add a module node.
Dual-use bare helper (issue #394): also used to create FFI/import-target
stubs (e.g. python/kotlin native targets), so it defaults
is_definition = false. Real module-declaration sites opt in via
mark_definition.
Sourcepub fn add_resource(
&mut self,
qualified_name: &str,
span: Option<Span>,
) -> NodeId
pub fn add_resource( &mut self, qualified_name: &str, span: Option<Span>, ) -> NodeId
Add a resource node.
Sourcepub fn add_endpoint(
&mut self,
qualified_name: &str,
span: Option<Span>,
) -> NodeId
pub fn add_endpoint( &mut self, qualified_name: &str, span: Option<Span>, ) -> NodeId
Add an endpoint node for HTTP route handlers.
The qualified name should follow the convention route::{METHOD}::{path},
for example route::GET::/api/users or route::POST::/api/items.
Endpoint nodes are used by Pass 5 (cross-language linking) to match HTTP requests from client code to server-side route handlers.
Sourcepub fn add_import(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
pub fn add_import(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
Add an import node.
Sourcepub fn add_verbatim_import(&mut self, name: &str, span: Option<Span>) -> NodeId
pub fn add_verbatim_import(&mut self, name: &str, span: Option<Span>) -> NodeId
Add an import node while preserving the original path-like identifier.
Use this for resource imports such as styles.css, app.js, or
similar asset filenames where . is part of the path rather than a
language-native qualified-name separator.
Sourcepub fn add_variable(
&mut self,
qualified_name: &str,
span: Option<Span>,
) -> NodeId
pub fn add_variable( &mut self, qualified_name: &str, span: Option<Span>, ) -> NodeId
Add a variable node.
Dual-use bare helper (issue #394): also used to create reference stubs
(e.g. rust field targets, sap-abap typed references), so it defaults
is_definition = false. Real variable/parameter/field declaration sites
opt in via mark_definition.
Sourcepub fn add_verbatim_variable(
&mut self,
name: &str,
span: Option<Span>,
) -> NodeId
pub fn add_verbatim_variable( &mut self, name: &str, span: Option<Span>, ) -> NodeId
Add a variable node while preserving the original identifier exactly.
Use this for static asset references where the literal path is the graph identity.
Sourcepub fn add_constant(
&mut self,
qualified_name: &str,
span: Option<Span>,
) -> NodeId
pub fn add_constant( &mut self, qualified_name: &str, span: Option<Span>, ) -> NodeId
Add a constant node.
Sourcepub fn add_constant_with_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
visibility: Option<&str>,
) -> NodeId
pub fn add_constant_with_visibility( &mut self, qualified_name: &str, span: Option<Span>, visibility: Option<&str>, ) -> NodeId
Add a constant node with visibility.
Sourcepub fn add_constant_with_static_and_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_static: bool,
visibility: Option<&str>,
) -> NodeId
pub fn add_constant_with_static_and_visibility( &mut self, qualified_name: &str, span: Option<Span>, is_static: bool, visibility: Option<&str>, ) -> NodeId
Add a constant node with static and visibility attributes.
Sourcepub fn add_constant_with_name_static_and_visibility(
&mut self,
name: &str,
qualified_name: &str,
span: Option<Span>,
is_static: bool,
visibility: Option<&str>,
) -> NodeId
pub fn add_constant_with_name_static_and_visibility( &mut self, name: &str, qualified_name: &str, span: Option<Span>, is_static: bool, visibility: Option<&str>, ) -> NodeId
Add a constant node with an explicit simple semantic name.
Use this when the graph identity must keep a language-specific qualified form but the searchable symbol name is the bare declaration name.
Sourcepub fn add_property_with_static_and_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_static: bool,
visibility: Option<&str>,
) -> NodeId
pub fn add_property_with_static_and_visibility( &mut self, qualified_name: &str, span: Option<Span>, is_static: bool, visibility: Option<&str>, ) -> NodeId
Add a property node with static and visibility attributes.
Sourcepub fn add_property_with_name_static_and_visibility(
&mut self,
name: &str,
qualified_name: &str,
span: Option<Span>,
is_static: bool,
visibility: Option<&str>,
) -> NodeId
pub fn add_property_with_name_static_and_visibility( &mut self, name: &str, qualified_name: &str, span: Option<Span>, is_static: bool, visibility: Option<&str>, ) -> NodeId
Add a property node with an explicit simple semantic name.
Use this when the graph identity must keep a language-specific qualified form but the searchable symbol name is the bare declaration name.
Sourcepub fn add_enum(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
pub fn add_enum(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
Add an enum node.
Sourcepub fn add_enum_with_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
visibility: Option<&str>,
) -> NodeId
pub fn add_enum_with_visibility( &mut self, qualified_name: &str, span: Option<Span>, visibility: Option<&str>, ) -> NodeId
Add an enum node with visibility.
Sourcepub fn add_interface(
&mut self,
qualified_name: &str,
span: Option<Span>,
) -> NodeId
pub fn add_interface( &mut self, qualified_name: &str, span: Option<Span>, ) -> NodeId
Add an interface/trait node.
Dual-use bare helper (issue #394): also used to create type-reference
stubs (e.g. go interface-type references), so it defaults
is_definition = false. Real declaration sites opt in via
mark_definition (or use
add_interface_with_visibility).
Sourcepub fn add_interface_with_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
visibility: Option<&str>,
) -> NodeId
pub fn add_interface_with_visibility( &mut self, qualified_name: &str, span: Option<Span>, visibility: Option<&str>, ) -> NodeId
Add an interface/trait node with visibility.
Sourcepub fn add_type(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
pub fn add_type(&mut self, qualified_name: &str, span: Option<Span>) -> NodeId
Add a type alias node.
Irreducibly dual-use bare helper (issue #394): used for BOTH typedef/
type-alias declarations AND type references (the dominant use), so it
defaults is_definition = false. A type DECLARED in the workspace opts
in at its declaration site via mark_definition
(references then dedupe into it and the OR-in keeps it true); a type only
ever referenced stays false.
Sourcepub fn add_type_with_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
visibility: Option<&str>,
) -> NodeId
pub fn add_type_with_visibility( &mut self, qualified_name: &str, span: Option<Span>, visibility: Option<&str>, ) -> NodeId
Add a type alias node with visibility.
Sourcepub fn add_lifetime(
&mut self,
qualified_name: &str,
span: Option<Span>,
) -> NodeId
pub fn add_lifetime( &mut self, qualified_name: &str, span: Option<Span>, ) -> NodeId
Add a lifetime node.
Sourcepub fn add_lifetime_constraint_edge(
&mut self,
source: NodeId,
target: NodeId,
constraint_kind: LifetimeConstraintKind,
)
pub fn add_lifetime_constraint_edge( &mut self, source: NodeId, target: NodeId, constraint_kind: LifetimeConstraintKind, )
Add a lifetime constraint edge.
Sourcepub fn add_trait_method_binding_edge(
&mut self,
caller: NodeId,
callee: NodeId,
trait_name: &str,
impl_type: &str,
is_ambiguous: bool,
)
pub fn add_trait_method_binding_edge( &mut self, caller: NodeId, callee: NodeId, trait_name: &str, impl_type: &str, is_ambiguous: bool, )
Add a trait method binding edge.
This edge represents the resolution of a trait method call to a concrete implementation.
Sourcepub fn add_macro_expansion_edge(
&mut self,
invocation: NodeId,
expansion: NodeId,
expansion_kind: MacroExpansionKind,
is_verified: bool,
)
pub fn add_macro_expansion_edge( &mut self, invocation: NodeId, expansion: NodeId, expansion_kind: MacroExpansionKind, is_verified: bool, )
Add a macro expansion edge.
Represents the expansion of a macro invocation to its generated code. Only available when macro expansion is enabled.
§Arguments
invocation- The macro invocation site node (e.g., derive attribute or macro call)expansion- The macro definition or generated code nodeexpansion_kind- The kind of macro expansion (Derive, Attribute, Declarative, Function)is_verified- Whether the expansion has been verified (requirescargo expand)
§Example
// #[derive(Debug)] on a struct
let struct_id = helper.add_struct("MyStruct", Some(span));
let derive_macro_id = helper.add_node("MyStruct::derive_Debug", None, NodeKind::Macro);
helper.add_macro_expansion_edge(
struct_id,
derive_macro_id,
MacroExpansionKind::Derive,
false,
);Sourcepub fn add_node(
&mut self,
qualified_name: &str,
span: Option<Span>,
kind: NodeKind,
) -> NodeId
pub fn add_node( &mut self, qualified_name: &str, span: Option<Span>, kind: NodeKind, ) -> NodeId
Add a generic node with custom kind.
Generic nodes default to is_definition = false: the caller passes a raw
NodeKind so the helper cannot know whether the node is a real
declaration or a structural/reference stub. Real-declaration callers are
marked explicitly in Stage 2.
Sourcepub fn add_node_with_visibility(
&mut self,
qualified_name: &str,
span: Option<Span>,
kind: NodeKind,
visibility: Option<&str>,
) -> NodeId
pub fn add_node_with_visibility( &mut self, qualified_name: &str, span: Option<Span>, kind: NodeKind, visibility: Option<&str>, ) -> NodeId
Add a generic node with visibility.
Defaults to is_definition = false for the same reason as
add_node.
Sourcepub fn mark_definition(&mut self, node_id: NodeId)
pub fn mark_definition(&mut self, node_id: NodeId)
Mark a just-created staged node as a real source declaration
(is_definition = true).
This is the explicit opt-in (issue #394) for declaration sites that
create their node through a DUAL-USE bare helper (add_function,
add_method, add_class, add_struct, add_enum-less kinds aside,
add_interface, add_type, add_module, add_variable) or the generic
add_node/add_node_with_visibility, all of which default
is_definition = false because the helper cannot tell a declaration from
a call/FFI/reference/import stub. A declaration handler calls this right
after creating its node.
The signal is monotonic (OR-in): once marked true it is never cleared, so calling this on a node that was also reached as a stub (or vice-versa) converges to true, which is correct (a symbol declared in the workspace IS a definition regardless of also being referenced).
Sourcepub fn add_call_edge(&mut self, caller: NodeId, callee: NodeId)
pub fn add_call_edge(&mut self, caller: NodeId, callee: NodeId)
Add a call edge from caller to callee.
Sourcepub fn add_call_edge_with_span(
&mut self,
caller: NodeId,
callee: NodeId,
spans: Vec<Span>,
)
pub fn add_call_edge_with_span( &mut self, caller: NodeId, callee: NodeId, spans: Vec<Span>, )
Add a call edge from caller to callee with source span information.
The span should point to the call site location in source code.
§Note
This method uses default metadata (argument_count: 255 sentinel for unknown, is_async: false).
Use add_call_edge_full when you need to specify
argument count or async status explicitly.
Sourcepub fn add_call_edge_full(
&mut self,
caller: NodeId,
callee: NodeId,
argument_count: u8,
is_async: bool,
)
pub fn add_call_edge_full( &mut self, caller: NodeId, callee: NodeId, argument_count: u8, is_async: bool, )
Add a call edge with full metadata.
Use this method when you know the argument count or when the call is async.
For calls where metadata is unknown, use add_call_edge
which uses default values (argument_count: 255 sentinel, is_async: false).
§Arguments
caller- The node making the callcallee- The node being calledargument_count- Number of arguments in the call (0-254, use 255 for unknown)is_async- Whether this is an async/await call
§Canonical Usage
| Scenario | Method |
|---|---|
| Argument count known, sync call | add_call_edge_full(caller, callee, arg_count, false) |
| Argument count known, async call | add_call_edge_full(caller, callee, arg_count, true) |
| Argument count unknown, sync call | add_call_edge(caller, callee) or add_call_edge_full(caller, callee, 255, false) |
§Example
// Function call with 3 arguments
helper.add_call_edge_full(main_id, helper_id, 3, false);
// Async call with 1 argument
helper.add_call_edge_full(main_id, async_fn_id, 1, true);Sourcepub fn add_call_edge_full_with_span(
&mut self,
caller: NodeId,
callee: NodeId,
argument_count: u8,
is_async: bool,
spans: Vec<Span>,
)
pub fn add_call_edge_full_with_span( &mut self, caller: NodeId, callee: NodeId, argument_count: u8, is_async: bool, spans: Vec<Span>, )
Add a call edge with full metadata and source span information.
Combines the functionality of add_call_edge_full
and span tracking.
Sourcepub fn add_channel(
&mut self,
qualified_name: &str,
span: Option<Span>,
_buffer_kind: ChannelBufferKind,
_capacity: Option<u32>,
) -> NodeId
pub fn add_channel( &mut self, qualified_name: &str, span: Option<Span>, _buffer_kind: ChannelBufferKind, _capacity: Option<u32>, ) -> NodeId
Stage a NodeKind::Channel node for a Go channel alias-class (T2.4).
Dedupes by (qualified_name, NodeKind::Channel) through the canonical
node cache, so all operation sites on the same alias-class collapse to
one node. buffer_kind / capacity classify the channel’s
make(chan T, N) form; in Phase 1 the classifier is carried onto each
ChannelPeer edge (where the planner consumes it) rather than into a
separate node-metadata payload, so the parameters document the
classification at the call site without a persistence-format addition.
Sourcepub fn add_channel_peer_edge_with_span(
&mut self,
op_site: NodeId,
channel: NodeId,
direction: ChannelPeerDirection,
buffer_kind: ChannelBufferKind,
span: Span,
)
pub fn add_channel_peer_edge_with_span( &mut self, op_site: NodeId, channel: NodeId, direction: ChannelPeerDirection, buffer_kind: ChannelBufferKind, span: Span, )
Stage a ChannelPeer edge from an operation-site CallSite to its
canonical Channel node (T2.4).
Sourcepub fn add_instantiates_edge_with_span(
&mut self,
call_site: NodeId,
target: NodeId,
type_args: SmallVec<[TypeArg; 4]>,
inference_kind: InferenceKind,
span: Span,
)
pub fn add_instantiates_edge_with_span( &mut self, call_site: NodeId, target: NodeId, type_args: SmallVec<[TypeArg; 4]>, inference_kind: InferenceKind, span: Span, )
Stage an Instantiates edge from a generic call-site CallSite to the
generic function / method definition (T2.5).
type_args is taken by value so the Go plugin can build it via
SmallVec::from_iter(...) and move ownership. The TypeArg.name
StringIds are interned through this helper’s interner, so they are
remapped to global ids during the commit’s string-table dedup.
Sourcepub fn add_table_read_edge_with_span(
&mut self,
reader: NodeId,
table: NodeId,
table_name: &str,
schema: Option<&str>,
spans: Vec<Span>,
)
pub fn add_table_read_edge_with_span( &mut self, reader: NodeId, table: NodeId, table_name: &str, schema: Option<&str>, spans: Vec<Span>, )
Add a database table read edge (SQL).
Sourcepub fn add_table_write_edge_with_span(
&mut self,
writer: NodeId,
table: NodeId,
table_name: &str,
schema: Option<&str>,
operation: TableWriteOp,
spans: Vec<Span>,
)
pub fn add_table_write_edge_with_span( &mut self, writer: NodeId, table: NodeId, table_name: &str, schema: Option<&str>, operation: TableWriteOp, spans: Vec<Span>, )
Add a database table write edge (SQL).
Sourcepub fn add_triggered_by_edge_with_span(
&mut self,
trigger: NodeId,
table: NodeId,
trigger_name: &str,
schema: Option<&str>,
spans: Vec<Span>,
)
pub fn add_triggered_by_edge_with_span( &mut self, trigger: NodeId, table: NodeId, trigger_name: &str, schema: Option<&str>, spans: Vec<Span>, )
Add a database trigger relationship edge (SQL).
Convention: trigger -> table with EdgeKind::TriggeredBy.
Sourcepub fn add_import_edge(&mut self, importer: NodeId, imported: NodeId)
pub fn add_import_edge(&mut self, importer: NodeId, imported: NodeId)
Add an import edge from importer to imported module/symbol.
This method uses default metadata (alias: None, is_wildcard: false).
Use add_import_edge_full when importing
with an alias or for wildcard imports.
Sourcepub fn add_import_edge_full(
&mut self,
importer: NodeId,
imported: NodeId,
alias: Option<&str>,
is_wildcard: bool,
)
pub fn add_import_edge_full( &mut self, importer: NodeId, imported: NodeId, alias: Option<&str>, is_wildcard: bool, )
Add an import edge with full metadata.
Use this method when the import has an alias or is a wildcard import.
For simple imports without alias or wildcard, use add_import_edge.
§Arguments
importer- The node importing (e.g., module or file)imported- The node being importedalias- Optional alias string (e.g., forimport { foo as bar }, alias is “bar”)is_wildcard- Whether this is a wildcard import (e.g.,import *)
§Canonical Usage
| Import Syntax | Method |
|---|---|
import foo | add_import_edge(importer, imported) |
import foo as bar | add_import_edge_full(importer, imported, Some("bar"), false) |
import * / import *.* | add_import_edge_full(importer, imported, None, true) |
import * as ns | add_import_edge_full(importer, imported, Some("ns"), true) |
§Example
// import { HashMap as Map } from "std::collections"
let alias_id = helper.intern("Map");
helper.add_import_edge_full(module_id, hashmap_id, Some("Map"), false);
// import * from "lodash"
helper.add_import_edge_full(module_id, lodash_id, None, true);Sourcepub fn add_export_edge(&mut self, module: NodeId, exported: NodeId)
pub fn add_export_edge(&mut self, module: NodeId, exported: NodeId)
Add an export edge from module to exported symbol.
This method uses default metadata (kind: ExportKind::Direct, alias: None).
Use add_export_edge_full for re-exports,
default exports, namespace exports, or exports with aliases.
Sourcepub fn add_export_edge_full(
&mut self,
module: NodeId,
exported: NodeId,
kind: ExportKind,
alias: Option<&str>,
)
pub fn add_export_edge_full( &mut self, module: NodeId, exported: NodeId, kind: ExportKind, alias: Option<&str>, )
Add an export edge with full metadata.
Use this method for re-exports, default exports, namespace exports,
or exports with aliases. For simple direct exports without alias,
use add_export_edge.
§Arguments
module- The module/file node that contains the exportexported- The symbol being exportedkind- The kind of export:ExportKind::Direct- Direct export (export { foo })ExportKind::Reexport- Re-export from another module (export { foo } from "mod")ExportKind::Default- Default export (export default foo)ExportKind::Namespace- Namespace export (export * as ns from "mod")
alias- Optional alias string (e.g., forexport { foo as bar }, alias is “bar”)
§Canonical Usage
| Export Syntax (JS/TS) | Method |
|---|---|
export { name } | add_export_edge(module, name) |
export default foo | add_export_edge_full(module, foo, ExportKind::Default, None) |
export { foo as bar } | add_export_edge_full(module, foo, ExportKind::Direct, Some("bar")) |
export { foo } from "mod" | add_export_edge_full(module, foo, ExportKind::Reexport, None) |
export { foo as bar } from "mod" | add_export_edge_full(module, foo, ExportKind::Reexport, Some("bar")) |
export * from "mod" | add_export_edge_full(module, mod, ExportKind::Reexport, None) |
export * as ns from "mod" | add_export_edge_full(module, mod, ExportKind::Namespace, Some("ns")) |
§Example
// export default MyComponent;
helper.add_export_edge_full(module_id, component_id, ExportKind::Default, None);
// export { helper as utilHelper };
helper.add_export_edge_full(module_id, helper_id, ExportKind::Direct, Some("utilHelper"));
// export * as utils from "./utils";
helper.add_export_edge_full(module_id, utils_id, ExportKind::Namespace, Some("utils"));Sourcepub fn add_reference_edge(&mut self, from: NodeId, to: NodeId)
pub fn add_reference_edge(&mut self, from: NodeId, to: NodeId)
Add a reference edge (variable/field access).
Sourcepub fn add_defines_edge(&mut self, parent: NodeId, child: NodeId)
pub fn add_defines_edge(&mut self, parent: NodeId, child: NodeId)
Add a defines edge (module defines symbol).
Sourcepub fn add_typeof_edge(&mut self, source: NodeId, target: NodeId)
pub fn add_typeof_edge(&mut self, source: NodeId, target: NodeId)
Add a type-of edge (symbol has type).
Add a TypeOf edge without context metadata (backward compatibility).
For new code, prefer add_typeof_edge_with_context to provide semantic context.
Sourcepub fn add_typeof_edge_with_context(
&mut self,
source: NodeId,
target: NodeId,
context: Option<TypeOfContext>,
index: Option<u16>,
name: Option<&str>,
)
pub fn add_typeof_edge_with_context( &mut self, source: NodeId, target: NodeId, context: Option<TypeOfContext>, index: Option<u16>, name: Option<&str>, )
Add a TypeOf edge with optional context metadata.
§Parameters
source: The node that has this type (e.g., variable, function, parameter)target: The type nodecontext: Where this type reference appears (Parameter, Return, Field, Variable, etc.)index: Position/index (for parameters, returns, fields)name: Name (for parameters, returns, fields, variables)
§Examples
// Function parameter: func foo(ctx context.Context)
helper.add_typeof_edge_with_context(
func_id,
type_id,
Some(TypeOfContext::Parameter),
Some(0),
Some("ctx"),
);
// Function return: func bar() error
helper.add_typeof_edge_with_context(
func_id,
error_type_id,
Some(TypeOfContext::Return),
Some(0),
None,
);
// Variable: var x int
helper.add_typeof_edge_with_context(
var_id,
int_type_id,
Some(TypeOfContext::Variable),
None,
Some("x"),
);Sourcepub fn add_implements_edge(&mut self, implementor: NodeId, interface: NodeId)
pub fn add_implements_edge(&mut self, implementor: NodeId, interface: NodeId)
Add an implements edge (class implements interface).
Sourcepub fn add_inherits_edge(&mut self, child: NodeId, parent: NodeId)
pub fn add_inherits_edge(&mut self, child: NodeId, parent: NodeId)
Add an inherits edge (class extends class).
Sourcepub fn add_wraps_edge(
&mut self,
source: NodeId,
target: NodeId,
kind: WrapKind,
chain_position: Option<u16>,
span: Option<Span>,
)
pub fn add_wraps_edge( &mut self, source: NodeId, target: NodeId, kind: WrapKind, chain_position: Option<u16>, span: Option<Span>, )
Add a T3 Wraps edge from a wrapper expression to a wrapped error
value (Go error chains, 02_DESIGN §1.3 / §2.4).
The kind discriminates the source-syntax form
(fmt.Errorf("%w", err), Unwrap() method, errors.{Is,As,AsType,Join});
chain_position carries the verb index for %w (0-based, skipping
%%) and the slice index for errors.Join / Unwrap() []error
slice literals (None for single-value forms).
span optionally records the source location of the wrap site
(e.g. the %w verb or the Unwrap() call expression). Pass None
when the caller cannot resolve a meaningful position. Wraps edges
route through the existing staging EdgeStore exactly like
Self::add_implements_edge — Phase 4d-prime is the only new
pipeline structural change required by T3.
Sourcepub fn add_contains_edge(&mut self, parent: NodeId, child: NodeId)
pub fn add_contains_edge(&mut self, parent: NodeId, child: NodeId)
Add a contains edge (parent contains child, e.g., class contains method).
Sourcepub fn add_webassembly_edge(&mut self, caller: NodeId, wasm_target: NodeId)
pub fn add_webassembly_edge(&mut self, caller: NodeId, wasm_target: NodeId)
Add a WebAssembly call edge.
Used when JavaScript/TypeScript code instantiates or calls WebAssembly modules:
WebAssembly.instantiate()/WebAssembly.instantiateStreaming()new WebAssembly.Module()/new WebAssembly.Instance()- Calling exported WASM functions
Sourcepub fn add_ffi_edge(
&mut self,
caller: NodeId,
ffi_target: NodeId,
convention: FfiConvention,
)
pub fn add_ffi_edge( &mut self, caller: NodeId, ffi_target: NodeId, convention: FfiConvention, )
Add an FFI call edge with the specified calling convention.
Used for foreign function interface calls:
- Node.js native addons (
.nodefiles) - ctypes/cffi in Python
- JNI in Java
- P/Invoke in C#
Sourcepub fn add_http_request_edge(
&mut self,
caller: NodeId,
target: NodeId,
method: HttpMethod,
url: Option<&str>,
)
pub fn add_http_request_edge( &mut self, caller: NodeId, target: NodeId, method: HttpMethod, url: Option<&str>, )
Add an HTTP request edge.
Use this when detecting HTTP calls like fetch() or axios.get().
Sourcepub fn ensure_callee(
&mut self,
qualified_name: &str,
call_site_span: Span,
kind_hint: CalleeKindHint,
) -> NodeId
pub fn ensure_callee( &mut self, qualified_name: &str, call_site_span: Span, kind_hint: CalleeKindHint, ) -> NodeId
Ensure a callee node exists for call-edge construction, with a non-optional call-site span.
This is the preferred API for Stage 2 call-edge building. The span is
required so that every stub gets at least the caller’s line — never 0.
The kind_hint guides the sweep order and determines the NodeKind
used if a fresh node must be created.
Cross-kind reuse: if a node with the same canonical qualified name already exists as any call-compatible kind, it is returned as-is.
Sourcepub fn ensure_function(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_async: bool,
is_unsafe: bool,
) -> NodeId
pub fn ensure_function( &mut self, qualified_name: &str, span: Option<Span>, is_async: bool, is_unsafe: bool, ) -> NodeId
Ensure a function node exists, creating it if needed.
Cross-kind reuse: if a node with the same canonical qualified name
already exists as any call-compatible kind (Method, Macro, Constant,
LambdaTarget), the existing node is returned as-is. This prevents
duplicate spanless Function nodes from being created during Stage 2
call-edge construction, which would cause get_references to silently
drop callers due to location-based deduplication at (file, line=0, col=0).
The Stage 1 declaration node is authoritative for metadata — no attributes are mutated on cross-kind reuse.
Sourcepub fn ensure_method(
&mut self,
qualified_name: &str,
span: Option<Span>,
is_async: bool,
is_static: bool,
) -> NodeId
pub fn ensure_method( &mut self, qualified_name: &str, span: Option<Span>, is_async: bool, is_static: bool, ) -> NodeId
Ensure a method node exists, creating it if needed.
Cross-kind reuse: if a node with the same canonical qualified name
already exists as any call-compatible kind (Function, Macro, Constant,
LambdaTarget), the existing node is returned as-is. See
ensure_function for the rationale.
Sourcepub fn stats(&self) -> HelperStats
pub fn stats(&self) -> HelperStats
Get statistics about what’s been staged.
Sourcepub fn mark_function_address_taken_by_name(&mut self, target_fn_name: &str)
pub fn mark_function_address_taken_by_name(&mut self, target_fn_name: &str)
Record target_fn_name as address-taken on the per-file C indirect
staging payload (DESIGN §2.5 patterns).
The name is interned through the helper’s standard staging
interner — DESIGN §2.5 specifies a per-file Vec<StringId>, so
each push goes through self.intern(...) so the local → global
StringId remap built by StagingGraph::commit_strings applies
uniformly during Phase 3 commit. U11 resolves each global
StringId to its canonical NodeId via the post-unification
qualified-name index and applies the NodeFlags::ADDRESS_TAKEN
bit. Duplicates within a file are tolerated — mark_address_taken
is idempotent.
Sourcepub fn set_local_scope_index(&mut self, index: LocalScopeIndex)
pub fn set_local_scope_index(&mut self, index: LocalScopeIndex)
Install the per-file LocalScopeIndex on the C indirect staging
payload (DESIGN §4.1).
Called from the top of the C plugin’s build_graph after running
the tree-sitter scope-arena builder. U11 transfers the index into
CIndirectSideTables::local_scope_indices keyed by FileId.
Sourcepub fn push_indirect_callsite(
&mut self,
caller_qualified_name: &str,
use_span: (usize, usize),
shape: IndirectShape,
argument_count: u32,
is_async: bool,
)
pub fn push_indirect_callsite( &mut self, caller_qualified_name: &str, use_span: (usize, usize), shape: IndirectShape, argument_count: u32, is_async: bool, )
Push a PendingIndirectCallsite onto the per-file C indirect
staging payload (DESIGN §4.2).
The caller is identified by its qualified name string; U11 resolves
it to a NodeId after Phase 4c-prime cross-file unification. U12’s
resolver consumes the callsite list in pass5b_c_indirect_resolve.
Sourcepub fn push_binding(
&mut self,
struct_tag: &str,
field_name: &str,
instance_name: &str,
target_fn_name: &str,
site_kind: BindingSiteKind,
)
pub fn push_binding( &mut self, struct_tag: &str, field_name: &str, instance_name: &str, target_fn_name: &str, site_kind: BindingSiteKind, )
Push a PendingBinding onto the per-file C indirect staging
payload (DESIGN §7.1).
Designated initializer ({ .field = fn }) and positional
initializer ({ fn1, fn2 }) sites are both routed through this
helper, with the site_kind discriminator preserved for U12’s
resolver.
Sourcepub fn push_struct_field_fnptr_signature(
&mut self,
struct_tag: &str,
field_name: &str,
signature: &str,
)
pub fn push_struct_field_fnptr_signature( &mut self, struct_tag: &str, field_name: &str, signature: &str, )
Push a struct function-pointer field signature onto the per-file C indirect staging payload (DESIGN §3.2.2 / §3.7).
The signature follows the DESIGN §3.1 canonical-string grammar.
U11 interns each leg and inserts into
CIndirectSideTables::struct_field_fnptr.
Sourcepub fn c_indirect(&self) -> Option<&CIndirectStagingPayload>
pub fn c_indirect(&self) -> Option<&CIndirectStagingPayload>
Immutable accessor for the C indirect staging payload, if any.
Exposed for tests and for the C plugin’s own walkers that need to
consult prior state (e.g. to suppress duplicate emissions within
the same file). Returns None until at least one
mark_function_address_taken_by_name / set_local_scope_index /
push_indirect_callsite / push_binding /
push_struct_field_fnptr_signature call has populated the payload.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !UnwindSafe for GraphBuildHelper<'a>
impl<'a> Freeze for GraphBuildHelper<'a>
impl<'a> RefUnwindSafe for GraphBuildHelper<'a>
impl<'a> Send for GraphBuildHelper<'a>
impl<'a> Sync for GraphBuildHelper<'a>
impl<'a> Unpin for GraphBuildHelper<'a>
impl<'a> UnsafeUnpin for GraphBuildHelper<'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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more