Multimap validate()

in java/io/bazel/rules/closure/webfiles/WebfilesValidator.java [84:118]


  Multimap<String, String> validate(
      Webfiles target,
      Iterable<Webfiles> directDeps,
      Supplier<? extends Iterable<Webfiles>> transitiveDeps)
      throws IOException {
    this.errors = ArrayListMultimap.create();
    this.transitiveDeps = transitiveDeps;
    accessibleAssets.clear();
    relationships.clear();
    for (WebfilesSource src : target.getSrcList()) {
      accessibleAssets.add(Webpath.get(src.getWebpath()));
    }
    for (Webfiles dep : directDeps) {
      for (WebfilesSource src : dep.getSrcList()) {
        accessibleAssets.add(Webpath.get(src.getWebpath()));
      }
    }
    for (WebfilesSource src : target.getSrcList()) {
      Path path = fs.getPath(src.getPath());
      if (src.getPath().endsWith(".html")) {
        validateHtml(path, Webpath.get(src.getWebpath()));
      } else if (src.getPath().endsWith(".css")) {
        validateCss(
            path, Webpath.get(src.getWebpath()), new String(Files.readAllBytes(path), UTF_8));
      }
    }
    for (ImmutableSet<Webpath> scc : Tarjan.run(relationships).getStronglyConnectedComponents()) {
      errors.put(
          CYCLES_ERROR,
          String.format(
              "These webpaths are strongly connected; please make your html acyclic\n\n  - %s\n",
              Joiner.on("\n  - ").join(Ordering.natural().sortedCopy(scc))));
    }
    return errors;
  }