Skip to content

Commit

Permalink
Internal changes
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 671862639
  • Loading branch information
bcorso authored and Dagger Team committed Sep 6, 2024
1 parent af62f2d commit c718e0b
Show file tree
Hide file tree
Showing 4 changed files with 1,107 additions and 91 deletions.
11 changes: 8 additions & 3 deletions java/dagger/internal/codegen/binding/BindingGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public abstract class BindingGraph {
@AutoValue
public abstract static class TopLevelBindingGraph
extends dagger.internal.codegen.model.BindingGraph {
static TopLevelBindingGraph create(
private static TopLevelBindingGraph create(
ImmutableNetwork<Node, Edge> network,
boolean isFullBindingGraph) {
TopLevelBindingGraph topLevelBindingGraph =
Expand Down Expand Up @@ -198,8 +198,13 @@ private static ImmutableSet<Binding> frameworkRequestBindingSet(
}

static BindingGraph create(
ComponentNode componentNode, TopLevelBindingGraph topLevelBindingGraph) {
return create(Optional.empty(), componentNode, topLevelBindingGraph);
ImmutableNetwork<Node, Edge> network,
boolean isFullBindingGraph) {
TopLevelBindingGraph topLevelBindingGraph =
TopLevelBindingGraph.create(
network,
isFullBindingGraph);
return create(Optional.empty(), topLevelBindingGraph.rootComponentNode(), topLevelBindingGraph);
}

private static BindingGraph create(
Expand Down
43 changes: 36 additions & 7 deletions java/dagger/internal/codegen/binding/BindingGraphConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import com.google.common.graph.ImmutableNetwork;
import com.google.common.graph.MutableNetwork;
import com.google.common.graph.NetworkBuilder;
import dagger.internal.codegen.binding.BindingGraph.TopLevelBindingGraph;
import dagger.internal.codegen.binding.BindingGraphFactory.LegacyBindingGraph;
import dagger.internal.codegen.binding.ComponentDescriptor.ComponentMethodDescriptor;
import dagger.internal.codegen.model.BindingGraph.ComponentNode;
import dagger.internal.codegen.model.BindingGraph.DependencyEdge;
Expand Down Expand Up @@ -69,11 +67,42 @@ BindingGraph convert(LegacyBindingGraph legacyBindingGraph, boolean isFullBindin
if (!isFullBindingGraph) {
unreachableNodes(network.asGraph(), rootNode).forEach(network::removeNode);
}
TopLevelBindingGraph topLevelBindingGraph =
TopLevelBindingGraph.create(
ImmutableNetwork.copyOf(network),
isFullBindingGraph);
return BindingGraph.create(rootNode, topLevelBindingGraph);

return BindingGraph.create(
ImmutableNetwork.copyOf(network),
isFullBindingGraph);
}

/** Represents a fully resolved binding graph. */
interface LegacyBindingGraph {
/** Returns the {@link ComponentNode} associated with this binding graph. */
ComponentNode componentNode();

/** Returns the {@link ComponentPath} associated with this binding graph. */
ComponentPath componentPath();

/** Returns the {@link ComponentDescriptor} associated with this binding graph. */
ComponentDescriptor componentDescriptor();

/**
* Returns the {@link ResolvedBindings} in this graph or a parent graph that matches the given
* request.
*
* <p>An exception is thrown if there are no resolved bindings found for the request; however,
* this should never happen since all dependencies should have been resolved at this point.
*/
ResolvedBindings resolvedBindings(BindingRequest request);

/**
* Returns all {@link ResolvedBindings} for the given request.
*
* <p>Note that this only returns the bindings resolved in this component. Bindings resolved in
* parent components are not included.
*/
Iterable<ResolvedBindings> resolvedBindings();

/** Returns the resolved subgraphs. */
ImmutableList<? extends LegacyBindingGraph> subgraphs();
}

private static final class Converter {
Expand Down
Loading

0 comments on commit c718e0b

Please sign in to comment.