private void appendComponentPathUnlessAtRoot(StringBuilder message, Node node) { if (!node.componentPath().equals(graph.rootComponentNode().componentPath())) { new Formatter(message).format(" [%s]", node.componentPath()); } }
private Function<ComponentNode, Set<TypeElement>> uncachedInheritedModules(BindingGraph graph) { return componentNode -> componentNode.componentPath().atRoot() ? ImmutableSet.of() : graph .componentNode(componentNode.componentPath().parent()) .map(parent -> union(ownedModules(parent, graph), inheritedModules(parent, graph))) .get(); }
Diagnostic.Kind diagnosticKind = ERROR; StringBuilder message = new StringBuilder(componentNode.componentPath().currentComponent().getQualifiedName()); if (bindingGraph.isModuleBindingGraph() && componentNode.componentPath().atRoot()) {
@Override protected void visitComponent(BindingGraph graph) { ComponentNode grandparentComponent = parentComponent; parentComponent = currentComponent; currentComponent = ComponentNodeImpl.create( componentTreePath().toComponentPath(), graph.componentDescriptor()); network.addNode(currentComponent); for (ResolvedBindings resolvedBindings : graph.resolvedBindings()) { ImmutableSet<TypeElement> declaringModules = subcomponentDeclaringModules(resolvedBindings); for (BindingNode binding : bindingNodes(resolvedBindings)) { addBinding(binding); if (binding.kind().equals(SUBCOMPONENT_BUILDER) && binding.componentPath().equals(currentComponent.componentPath())) { network.addEdge( binding, subcomponentNode(binding.key().type(), graph), new SubcomponentBuilderBindingEdgeImpl(declaringModules)); } } } super.visitComponent(graph); currentComponent = parentComponent; parentComponent = grandparentComponent; }
private ImmutableSet<TypeElement> findMissingModules( ChildFactoryMethodEdge edge, BindingGraph graph) { ImmutableSet<TypeElement> factoryMethodParameters = subgraphFactoryMethodParameters(edge, graph); ComponentNode child = (ComponentNode) graph.network().incidentNodes(edge).target(); SetView<TypeElement> modulesOwnedByChild = ownedModules(child, graph); return graph.bindings().stream() // bindings owned by child .filter(binding -> binding.componentPath().equals(child.componentPath())) // that require a module instance .filter(binding -> binding.requiresModuleInstance()) .map(binding -> binding.contributingModule().get()) .distinct() // module owned by child .filter(module -> modulesOwnedByChild.contains(module)) // module not in the method parameters .filter(module -> !factoryMethodParameters.contains(module)) // module doesn't have an accessible no-arg constructor .filter(moduleType -> !componentCanMakeNewInstances(moduleType)) .collect(toImmutableSet()); }
private ImmutableSet<TypeElement> subgraphFactoryMethodParameters( ChildFactoryMethodEdge edge, BindingGraph bindingGraph) { ComponentNode parent = (ComponentNode) bindingGraph.network().incidentNodes(edge).source(); DeclaredType parentType = asDeclared(parent.componentPath().currentComponent().asType()); ExecutableType factoryMethodType = asExecutable(types.asMemberOf(parentType, edge.factoryMethod())); return asTypeElements(factoryMethodType.getParameterTypes()); }
DiagnosticReporterImpl(BindingGraph graph, String plugin) { this.graph = graph; this.plugin = plugin; this.rootComponent = graph.rootComponentNode().componentPath().currentComponent(); }