/** Populates the result from the graph traversal state. */
  private void assembleResult(ResolveState resolveState, DependencyGraphVisitor listener) {
    listener.start(resolveState.root);

    // Visit the nodes
    for (ConfigurationNode resolvedConfiguration : resolveState.getConfigurationNodes()) {
      if (resolvedConfiguration.isSelected()) {
        resolvedConfiguration.validate();
        listener.visitNode(resolvedConfiguration);
      }
    }
    // Visit the edges
    for (ConfigurationNode resolvedConfiguration : resolveState.getConfigurationNodes()) {
      if (resolvedConfiguration.isSelected()) {
        listener.visitEdge(resolvedConfiguration);
      }
    }

    listener.finish(resolveState.root);
  }
 public void validate() {
   for (DependencyEdge incomingEdge : incomingEdges) {
     ConfigurationNode fromNode = incomingEdge.from;
     if (!fromNode.isSelected()) {
       throw new IllegalStateException(
           String.format(
               "Unexpected state %s for parent node for dependency from %s to %s.",
               fromNode.moduleRevision.state, fromNode, this));
     }
   }
 }
Пример #3
0
  /** Populates the result from the graph traversal state. */
  private void assembleResult(
      ResolveState resolveState,
      ResolvedConfigurationBuilder result,
      ResolvedConfigurationListener listener) {
    FailureState failureState = new FailureState(resolveState.root);
    ModuleVersionIdentifier root = resolveState.root.toId();
    listener.start(root);

    for (ConfigurationNode resolvedConfiguration : resolveState.getConfigurationNodes()) {
      if (resolvedConfiguration.isSelected()) {
        resolvedConfiguration.attachToParents(result);
        resolvedConfiguration.collectFailures(failureState);
        listener.resolvedModuleVersion(resolvedConfiguration.moduleRevision);
      }
    }
    for (ConfigurationNode resolvedConfiguration : resolveState.getConfigurationNodes()) {
      if (resolvedConfiguration.isSelected()) {
        listener.resolvedConfiguration(
            resolvedConfiguration.toId(), resolvedConfiguration.outgoingEdges);
      }
    }
    failureState.attachFailures(result);
    result.done(resolveState.root.getResult());
  }