下面列出了com.google.common.collect.ImmutableSortedMap#isEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/** 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);
}
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);
}
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());
}
}