List of usage examples for com.google.common.collect ImmutableCollection contains
public boolean contains(@Nullable Object object)
From source file:com.github.hilcode.versionator.Model.java
public Model release(final ImmutableCollection<GroupArtifact> exclusions) { final ImmutableList.Builder<Gav> gavsBuilder = ImmutableList.builder(); for (final Pom pom : this.poms) { if (pom.gav.version.isRelease() && !pom.isReleasable() && !exclusions.contains(pom.gav.groupArtifact)) { gavsBuilder.add(Gav.BUILDER.build(pom.gav.groupArtifact, pom.gav.version.next().toSnapshot())); }/*w ww. j a v a2 s. c o m*/ } final ImmutableList<Gav> gavs = gavsBuilder.build(); final Model result = apply(gavs); final ImmutableList.Builder<Gav> gavsBuilder_ = ImmutableList.builder(); for (final Pom pom : result.poms) { if (pom.gav.version.isSnapshot() && !exclusions.contains(pom.gav.groupArtifact)) { gavsBuilder_.add(Gav.BUILDER.build(pom.gav.groupArtifact, pom.gav.version.toRelease())); } if (pom.parent.isPresent() && pom.parent.get().gav.version.isSnapshot() && !exclusions.contains(pom.parent.get().gav.groupArtifact)) { gavsBuilder_.add(Gav.BUILDER.build(pom.parent.get().gav.groupArtifact, pom.parent.get().gav.version.toRelease())); } for (final Dependency dependency : pom.dependencies) { if (dependency.gav.version.isSnapshot() && !exclusions.contains(dependency.gav.groupArtifact)) { gavsBuilder_.add( Gav.BUILDER.build(dependency.gav.groupArtifact, dependency.gav.version.toRelease())); } } } final ImmutableList<Gav> gavs_ = gavsBuilder_.build(); final ImmutableList.Builder<Pom> pomsBuilder = ImmutableList.builder(); for (final Pom pom : result.poms) { Pom pom_ = pom; for (final Gav gav_ : gavs_) { pom_ = pom_.apply(gav_); } pomsBuilder.add(pom_); } return Model.BUILDER.build(pomsBuilder.build()); }
From source file:com.facebook.buck.features.haskell.HaskellHaddockDescription.java
@Override public BuildRule createBuildRule(BuildRuleCreationContextWithTargetGraph context, BuildTarget baseTarget, BuildRuleParams params, HaskellHaddockDescriptionArg args) { String name = baseTarget.getShortName(); LOG.info("Creating Haddock " + name); ActionGraphBuilder graphBuilder = context.getActionGraphBuilder(); SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(graphBuilder); HaskellPlatform platform = getPlatform(baseTarget, args); ImmutableCollection<BuildRule> deps = graphBuilder.getAllRules(args.getDeps()); // Collect all Haskell deps ImmutableSet.Builder<HaskellHaddockInput> haddockInputs = ImmutableSet.builder(); // Traverse all deps to pull packages + locations new AbstractBreadthFirstTraversal<BuildRule>(deps) { @Override/*from w ww . j a v a2 s . c om*/ public Iterable<BuildRule> visit(BuildRule rule) { ImmutableSet.Builder<BuildRule> traverse = ImmutableSet.builder(); if (rule instanceof HaskellCompileDep) { HaskellCompileDep haskellCompileDep = (HaskellCompileDep) rule; // Only index first order dependencies if (deps.contains(rule)) { haddockInputs.add(haskellCompileDep.getHaddockInput(platform)); } traverse.addAll(haskellCompileDep.getCompileDeps(platform)); } return traverse.build(); } }.start(); return graphBuilder.addToIndex(HaskellHaddockRule.from(baseTarget, context.getProjectFilesystem(), params, ruleFinder, platform.getHaddock().resolve(graphBuilder), args.getHaddockFlags(), haddockInputs.build())); }
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. *//* w ww.ja va2 s . c o m*/ 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(); }
From source file:com.google.idea.blaze.android.resources.actions.BlazeCreateResourceUtils.java
static void setupResDirectoryChoices(Project project, @Nullable VirtualFile contextFile, JBLabel resDirLabel, ComboboxWithBrowseButton resDirComboAndBrowser) { // Reset the item list before filling it back up. resDirComboAndBrowser.getComboBox().removeAllItems(); BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); if (blazeProjectData != null) { BlazeAndroidSyncData syncData = blazeProjectData.syncState.get(BlazeAndroidSyncData.class); if (syncData != null) { ImmutableCollection<TargetKey> rulesRelatedToContext = null; File fileFromContext = null; if (contextFile != null) { fileFromContext = VfsUtilCore.virtualToIoFile(contextFile); rulesRelatedToContext = SourceToTargetMap.getInstance(project) .getRulesForSourceFile(fileFromContext); if (rulesRelatedToContext.isEmpty()) { rulesRelatedToContext = null; }/* www . j a va 2 s .c o m*/ } ArtifactLocationDecoder artifactLocationDecoder = blazeProjectData.artifactLocationDecoder; // Sort: // - contextFile/res if contextFile is a directory, // to optimize the right click on directory case, or the "closest" string // match to the contextFile from the res directories known to blaze // - the rest of the direct dirs, then transitive dirs of the context rules, // then any known res dir in the project // as a backup, in alphabetical order. Set<File> resourceDirs = Sets.newTreeSet(); Set<File> transitiveDirs = Sets.newTreeSet(); Set<File> allResDirs = Sets.newTreeSet(); for (AndroidResourceModule androidResourceModule : syncData.importResult.androidResourceModules) { Collection<File> resources = artifactLocationDecoder.decodeAll(androidResourceModule.resources); Collection<File> transitiveResources = artifactLocationDecoder .decodeAll(androidResourceModule.transitiveResources); // labelsRelatedToContext should include deps, // but as a first pass we only check the rules themselves // for resources. If we come up empty, then have anyResDir as a backup. allResDirs.addAll(transitiveResources); if (rulesRelatedToContext != null && !rulesRelatedToContext.contains(androidResourceModule.targetKey)) { continue; } resourceDirs.addAll(resources); transitiveDirs.addAll(transitiveResources); } // No need to show some directories twice. transitiveDirs.removeAll(resourceDirs); JComboBox resDirCombo = resDirComboAndBrowser.getComboBox(); // Allow the user to browse and overwrite some of the entries, // in case our inference is wrong. resDirCombo.setEditable(true); // Optimize the right-click on a non-res directory (consider res directory right under that) // After the use confirms the choice, a directory will be created if it is missing. if (fileFromContext != null && fileFromContext.isDirectory()) { File closestDirToContext = new File(fileFromContext.getPath(), "res"); resDirCombo.setSelectedItem(closestDirToContext); } else { // If we're not completely sure, let people know there are options // via the placeholder text, and put the most likely on top. String placeHolder = PLACEHOLDER_TEXT; resDirCombo.addItem(placeHolder); resDirCombo.setSelectedItem(placeHolder); if (fileFromContext != null) { File closestDirToContext = findClosestDirToContext(fileFromContext.getPath(), resourceDirs); closestDirToContext = closestDirToContext != null ? closestDirToContext : findClosestDirToContext(fileFromContext.getPath(), transitiveDirs); if (closestDirToContext != null) { resDirCombo.addItem(closestDirToContext); resourceDirs.remove(closestDirToContext); transitiveDirs.remove(closestDirToContext); } } } if (!resourceDirs.isEmpty() || !transitiveDirs.isEmpty()) { for (File resourceDir : resourceDirs) { resDirCombo.addItem(resourceDir); } for (File resourceDir : transitiveDirs) { resDirCombo.addItem(resourceDir); } } else { for (File resourceDir : allResDirs) { resDirCombo.addItem(resourceDir); } } resDirComboAndBrowser.setVisible(true); resDirLabel.setVisible(true); } } }