public class ComponentTreeTraverser
extends java.lang.Object
Subclasses can override visitComponent(BindingGraph) to perform custom logic at each
component in the tree, and visitSubcomponentFactoryMethod(BindingGraph, BindingGraph,
ExecutableElement) to perform custom logic at each subcomponent factory method.
| Constructor and Description |
|---|
ComponentTreeTraverser(dagger.internal.codegen.BindingGraph rootGraph,
dagger.internal.codegen.CompilerOptions compilerOptions)
Constructs a traverser for a root (component, not subcomponent) binding graph.
|
| Modifier and Type | Method and Description |
|---|---|
protected dagger.model.ComponentPath |
componentPath()
Returns an immutable snapshot of the path from the root component to the currently visited
component.
|
protected dagger.internal.codegen.BindingGraph |
graphForAncestor(javax.lang.model.element.TypeElement ancestor)
Returns the BindingGraph for
ancestor, where ancestor is in the component path
of the current traversal. |
protected dagger.model.ComponentPath |
pathFromRootToAncestor(javax.lang.model.element.TypeElement ancestor)
Returns the subpath from the root component to the matching
ancestor of the current
component. |
void |
traverseComponents()
Calls
visitComponent(BindingGraph) for the root component. |
protected void |
visitComponent(dagger.internal.codegen.BindingGraph graph)
Called once for each component in a component hierarchy.
|
protected void |
visitEntryPoint(dagger.model.DependencyRequest entryPoint,
dagger.internal.codegen.BindingGraph graph)
Called once for each entry point in a component.
|
protected void |
visitSubcomponentFactoryMethod(dagger.internal.codegen.BindingGraph graph,
dagger.internal.codegen.BindingGraph parent,
javax.lang.model.element.ExecutableElement factoryMethod)
Called if this component was installed in its parent by a subcomponent factory method.
|
public ComponentTreeTraverser(dagger.internal.codegen.BindingGraph rootGraph,
dagger.internal.codegen.CompilerOptions compilerOptions)
public final void traverseComponents()
visitComponent(BindingGraph) for the root component.java.lang.IllegalStateException - if a traversal is in progressprotected void visitComponent(dagger.internal.codegen.BindingGraph graph)
Subclasses can override this method to perform whatever logic is required per component.
They should call the super implementation if they want to continue the traversal in the
standard order.
This implementation does the following:
visitSubcomponentFactoryMethod(BindingGraph, BindingGraph, ExecutableElement).
visitEntryPoint(DependencyRequest,
BindingGraph).
visitComponent(BindingGraph), updating the
traversal state.
graph - the currently visited graphprotected void visitSubcomponentFactoryMethod(dagger.internal.codegen.BindingGraph graph,
dagger.internal.codegen.BindingGraph parent,
javax.lang.model.element.ExecutableElement factoryMethod)
This implementation does nothing.
graph - the currently visited graphparent - the parent graphfactoryMethod - the factory method in the parent component that declares that the current
component is a childprotected void visitEntryPoint(dagger.model.DependencyRequest entryPoint,
dagger.internal.codegen.BindingGraph graph)
Subclasses can override this method to perform whatever logic is required per entry point.
They should call the super implementation if they want to continue the traversal in the
standard order.
This implementation does nothing.
graph - the graph for the component that contains the entry pointprotected final dagger.model.ComponentPath componentPath()
protected final dagger.model.ComponentPath pathFromRootToAncestor(javax.lang.model.element.TypeElement ancestor)
ancestor of the current
component.protected final dagger.internal.codegen.BindingGraph graphForAncestor(javax.lang.model.element.TypeElement ancestor)
ancestor, where ancestor is in the component path
of the current traversal.