ProjectGraph class
A graph of dependencies between widget classes and global files in a project.
This class enables intelligent features by tracking which files depend on which other files, allowing us to determine what needs to be regenerated, revalidated, or included in context when a change is made.
Usage
// Build graph from project
final graph = ProjectGraph.fromProject(project);
// Query for dependents
final affected = graph.getDependents('widgetClass:homePageKey');
// Apply incremental update
graph.applyUpdate(projectUpdate);
Constructors
-
ProjectGraph({Map<
String, DependencyNode> ? nodes})
Properties
-
appEventNodeIds
→ Iterable<
String> -
Get all app event node IDs.
no setter
-
componentNodeIds
→ Iterable<
String> -
Get all component node IDs.
no setter
-
globalNodeIds
→ Iterable<
String> -
Get all global file node IDs.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
libraryDependencyNodeIds
→ Iterable<
String> -
Get all library dependency node IDs.
no setter
-
nodes
→ Map<
String, DependencyNode> -
Read-only access to all nodes.
no setter
-
pageNodeIds
→ Iterable<
String> -
Get all page node IDs.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
widgetClassNodeIds
→ Iterable<
String> -
Get all widget class node IDs (pages and components).
no setter
Methods
-
addDependency(
String fromId, String toId) → void -
Add a dependency edge from
fromIdtotoId. -
addNode(
DependencyNode node) → void - Add a node to the graph.
-
cleanupOrphanNodes(
) → void - Clean up all orphan app state variable nodes.
-
clone(
) → ProjectGraph - Create a deep copy of this graph.
-
computeCentrality(
) → Map< String, int> - Compute centrality scores for nodes.
-
computeStructureHash(
) → int - Compute a structure hash that changes when widget classes are added/deleted/renamed.
-
findCycles(
) → List< List< String> > - Find cycles in the graph.
-
findUnreachable(
Set< String> entryPoints) → Set<String> - Find nodes unreachable from the given entry points.
-
getContext(
String nodeId, {int depth = 2}) → Set< String> - Get context around a node up to a certain depth.
-
getDependencies(
String nodeId, {bool transitive = true}) → Set< String> - Get all nodes that this node depends on.
-
getDependents(
String nodeId, {bool transitive = true}) → Set< String> - Get all nodes that depend on the given node.
-
getNode(
String nodeId) → DependencyNode? - Get a node by ID.
-
hasEdge(
String fromId, String toId) → bool -
Check if an edge exists from
fromIdtotoId. -
hasNode(
String nodeId) → bool - Check if a node exists.
-
nodeIdsByTypes(
Set< DependencyNodeType> types) → Iterable<String> - Get node IDs filtered by types.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeDependency(
String fromId, String toId) → void -
Remove a dependency edge from
fromIdtotoId. -
removeIfOrphan(
String nodeId) → void - Remove a node if it has no dependents (nothing imports it).
-
removeNode(
String nodeId) → void - Remove a node from the graph.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited