コード例 #1
0
    public BottomUpPathMerger(
        Iterable<IjFolder> foldersToWalk, int limit, PackagePathCache packagePathCache) {
      this.tree = new MutableDirectedGraph<>();
      this.packagePathCache = packagePathCache;
      this.mergePathsMap = new HashMap<>();

      for (IjFolder folder : foldersToWalk) {
        mergePathsMap.put(folder.getPath(), folder);

        Path path = folder.getPath();
        while (path.getNameCount() > limit) {
          Path parent = path.getParent();
          if (parent == null) {
            break;
          }

          boolean isParentAndGrandParentAlreadyInTree = tree.containsNode(parent);
          tree.addEdge(parent, path);
          if (isParentAndGrandParentAlreadyInTree) {
            break;
          }

          path = parent;
        }
      }
    }
コード例 #2
0
  private DependencyGraph createDependencyGraphFromBuildRules(Iterable<? extends BuildRule> rules) {
    MutableDirectedGraph<BuildRule> graph = new MutableDirectedGraph<BuildRule>();
    for (BuildRule rule : rules) {
      for (BuildRule dep : rule.getDeps()) {
        graph.addEdge(rule, dep);
      }
    }

    return new DependencyGraph(graph);
  }
コード例 #3
0
ファイル: ProjectCommandTest.java プロジェクト: h87kg/buck
  private PartialGraph createGraphFromBuildRules(List<BuildRule> rules) {
    MutableDirectedGraph<BuildRule> graph = new MutableDirectedGraph<>();
    for (BuildRule rule : rules) {
      for (BuildRule dep : rule.getDeps()) {
        graph.addEdge(rule, dep);
      }
    }

    List<BuildTarget> buildTargets =
        Lists.transform(
            rules,
            new Function<BuildRule, BuildTarget>() {
              @Override
              public BuildTarget apply(BuildRule rule) {
                return rule.getBuildTarget();
              }
            });

    DependencyGraph dependencyGraph = new DependencyGraph(graph);
    return PartialGraphFactory.newInstance(dependencyGraph, buildTargets);
  }