List of usage examples for com.google.common.collect SortedSetMultimap isEmpty
boolean isEmpty();
From source file:com.google.idea.blaze.android.rendering.BlazeRenderErrorContributor.java
/** * Blaze doesn't resolve class dependencies from resources until building the final * android_binary, so we could end up with resources that ultimately build correctly, but fail to * find their class dependencies during rendering in the layout editor. *///from w ww . j a va 2s. c om private void reportResourceTargetShouldDependOnClassTarget(TargetIdeInfo target, TargetMap targetMap, ArtifactLocationDecoder decoder) { Collection<String> missingClasses = logger.getMissingClasses(); if (missingClasses == null || missingClasses.isEmpty()) { return; } // Sorted entries for deterministic error message. SortedSetMultimap<String, TargetKey> missingClassToTargetMap = TreeMultimap.create(); SourceToTargetMap sourceToTargetMap = SourceToTargetMap.getInstance(project); ImmutableCollection transitiveDependencies = TransitiveDependencyMap.getInstance(project) .getTransitiveDependencies(target.key); for (String missingClass : missingClasses) { File sourceFile = getSourceFileForClass(missingClass); if (sourceFile == null) { continue; } ImmutableCollection<TargetKey> sourceTargets = sourceToTargetMap.getRulesForSourceFile(sourceFile); if (sourceTargets.stream().noneMatch(sourceTarget -> sourceTarget.equals(target.key) || transitiveDependencies.contains(sourceTarget))) { missingClassToTargetMap.putAll(missingClass, sourceTargets); } } if (missingClassToTargetMap.isEmpty()) { return; } HtmlBuilder builder = new HtmlBuilder(); addTargetLink(builder, target, decoder).add(" contains resource files that reference these classes:") .beginList(); for (String missingClass : missingClassToTargetMap.keySet()) { builder.listItem().addLink(missingClass, getLinkManager().createOpenClassUrl(missingClass)) .add(" from "); for (TargetKey targetKey : missingClassToTargetMap.get(missingClass)) { addTargetLink(builder, targetMap.get(targetKey), decoder).add(" "); } } builder.endList().add("Please fix your dependencies so that "); addTargetLink(builder, target, decoder).add(" correctly depends on these classes, ") .addLink("then ", "sync the project", " ", getLinkManager().createSyncProjectUrl()) .addLink("and ", "refresh the layout", ".", getLinkManager().createRefreshRenderUrl()).newline() .newline() .addBold("NOTE: blaze can still build with the incorrect dependencies " + "due to the way it handles resources, " + "but the layout editor needs them to be correct."); addIssue().setSeverity(HighlightSeverity.ERROR, HIGH_PRIORITY + 1) // Reported above missing classes. .setSummary("Missing class dependencies").setHtmlContent(builder).build(); }