Java Code Examples for com.google.common.collect.ImmutableSortedMap#isEmpty()

The following examples show how to use com.google.common.collect.ImmutableSortedMap#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigFeatureFlagConfiguration.java    From bazel with Apache License 2.0 5 votes vote down vote up
/** Creates a new configuration fragment from the given {@link ConfigFeatureFlagOptions}. */
@VisibleForTesting
ConfigFeatureFlagConfiguration(ImmutableSortedMap<Label, String> flagValues) {
  this.flagValues = flagValues;
  // We don't hash flags set to their default values; all valid configurations of a target have
  // the same set of known flags, so the set of flags set to something other than their default
  // values is enough to disambiguate configurations. Similarly, whether or not a configuration
  // is trimmed need not be hashed; enforceTransitiveConfigsForConfigFeatureFlag should not change
  // within a build, and when it's enabled, the only configuration which is untrimmed
  // (the top-level configuration) shouldn't be used for any actual targets.
  this.flagHash = flagValues.isEmpty() ? null : hashFlags(flagValues);
}
 
Example 2
Source File: Dot.java    From buck with Apache License 2.0 5 votes vote down vote up
private static <T> String printNode(
    T node,
    Function<T, String> nodeToId,
    Function<T, String> nodeToName,
    Function<T, String> nodeToTypeName,
    Function<T, ImmutableSortedMap<String, String>> nodeToAttributes,
    boolean compactMode) {
  String source = nodeToName.apply(node);
  String sourceType = nodeToTypeName.apply(node);
  String extraAttributes = "";
  ImmutableSortedMap<String, String> nodeAttributes = nodeToAttributes.apply(node);

  String labelAttribute = "";
  if (compactMode) {
    labelAttribute = ",label=" + escape(source);
    source = nodeToId.apply(node); // Don't need to escape numeric IDs
  } else {
    source = escape(source);
  }

  if (!nodeAttributes.isEmpty()) {
    extraAttributes =
        ","
            + nodeAttributes.entrySet().stream()
                .map(entry -> escape("buck_" + entry.getKey()) + "=" + escape(entry.getValue()))
                .collect(Collectors.joining(","));
  }
  return String.format(
      "  %s [style=filled,color=%s%s%s];%n",
      source, Dot.colorFromType(sourceType), labelAttribute, extraAttributes);
}
 
Example 3
Source File: GeneratedResourceWarnings.java    From intellij with Apache License 2.0 4 votes vote down vote up
public static void submit(
    Consumer<IssueOutput> context,
    Project project,
    ProjectViewSet projectViewSet,
    ArtifactLocationDecoder artifactLocationDecoder,
    Set<ArtifactLocation> generatedResourceLocations,
    Set<String> whitelistedLocations) {
  if (generatedResourceLocations.isEmpty()) {
    return;
  }
  Set<ArtifactLocation> nonWhitelistedLocations = new HashSet<>();
  Set<String> unusedWhitelistEntries = new HashSet<>();
  filterWhitelistedEntries(
      generatedResourceLocations,
      whitelistedLocations,
      nonWhitelistedLocations,
      unusedWhitelistEntries);
  // Tag any warnings with the project view file.
  File projectViewFile = projectViewSet.getTopLevelProjectViewFile().projectViewFile;
  if (!nonWhitelistedLocations.isEmpty()) {
    GeneratedResourceClassifier classifier =
        new GeneratedResourceClassifier(
            project,
            nonWhitelistedLocations,
            artifactLocationDecoder,
            BlazeExecutor.getInstance().getExecutor());
    ImmutableSortedMap<ArtifactLocation, Integer> interestingDirectories =
        classifier.getInterestingDirectories();
    if (!interestingDirectories.isEmpty()) {
      context.accept(IssueOutput.warn(
              String.format(
                  "Dropping %d generated resource directories.\n"
                      + "R classes will not contain resources from these directories.\n"
                      + "Double-click to add to project view if needed to resolve references.",
                  interestingDirectories.size()))
          .inFile(projectViewFile)
          .onLine(1)
          .inColumn(1)
          .build());
      for (Map.Entry<ArtifactLocation, Integer> entry : interestingDirectories.entrySet()) {
        context.accept(IssueOutput.warn(
                String.format(
                    "Dropping generated resource directory '%s' w/ %d subdirs",
                    entry.getKey(), entry.getValue()))
            .inFile(projectViewFile)
            .navigatable(
                new AddGeneratedResourceDirectoryNavigatable(
                    project, projectViewFile, entry.getKey()))
            .build());
      }
    }
  }
  // Warn about unused parts of the whitelist.
  if (!unusedWhitelistEntries.isEmpty()) {
    context.accept(IssueOutput.warn(
            String.format(
                "%d unused entries in project view section \"%s\":\n%s",
                unusedWhitelistEntries.size(),
                GeneratedAndroidResourcesSection.KEY.getName(),
                String.join("\n  ", unusedWhitelistEntries)))
        .inFile(projectViewFile)
        .build());
  }
}