List of usage examples for com.google.common.collect ImmutableSet.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:com.facebook.buck.cxx.CxxPreprocessorInput.java
public static CxxPreprocessorInput concat(Iterable<CxxPreprocessorInput> inputs) { ImmutableSet.Builder<BuildTarget> rules = ImmutableSet.builder(); ImmutableMultimap.Builder<CxxSource.Type, String> preprocessorFlags = ImmutableMultimap.builder(); ImmutableCxxHeaders.Builder includes = ImmutableCxxHeaders.builder(); ImmutableList.Builder<Path> includeRoots = ImmutableList.builder(); ImmutableList.Builder<Path> systemIncludeRoots = ImmutableList.builder(); for (CxxPreprocessorInput input : inputs) { rules.addAll(input.getRules()); preprocessorFlags.putAll(input.getPreprocessorFlags()); includes.putAllNameToPathMap(input.getIncludes().nameToPathMap()); includes.putAllFullNameToPathMap(input.getIncludes().fullNameToPathMap()); includeRoots.addAll(input.getIncludeRoots()); systemIncludeRoots.addAll(input.getSystemIncludeRoots()); }/*w w w .j a va2s . co m*/ return new CxxPreprocessorInput(rules.build(), preprocessorFlags.build(), includes.build(), includeRoots.build(), systemIncludeRoots.build()); }
From source file:com.facebook.presto.hive.metastore.MetastoreUtil.java
public static Set<HivePrivilegeInfo> toGrants(List<PrivilegeGrantInfo> userGrants) { if (userGrants == null) { return ImmutableSet.of(); }/*from w w w . j a v a2 s . com*/ ImmutableSet.Builder<HivePrivilegeInfo> privileges = ImmutableSet.builder(); for (PrivilegeGrantInfo userGrant : userGrants) { privileges.addAll(parsePrivilege(userGrant)); } return privileges.build(); }
From source file:com.facebook.buck.features.haskell.HaskellGhciRule.java
public static HaskellGhciRule from(BuildTarget buildTarget, ProjectFilesystem projectFilesystem, BuildRuleParams params, SourcePathRuleFinder ruleFinder, HaskellSources srcs, ImmutableList<String> compilerFlags, Optional<SourcePath> ghciBinDep, Optional<SourcePath> ghciInit, BuildRule omnibusSharedObject, ImmutableSortedMap<String, SourcePath> solibs, ImmutableSortedMap<String, SourcePath> preloadLibs, ImmutableSet<HaskellPackage> firstOrderHaskellPackages, ImmutableSet<HaskellPackage> haskellPackages, ImmutableSet<HaskellPackage> prebuiltHaskellPackages, boolean enableProfiling, Path ghciScriptTemplate, ImmutableList<SourcePath> extraScriptTemplates, Path ghciIservScriptTemplate, Path ghciBinutils, Path ghciGhc, Path ghciIServ, Path ghciIServProf, Path ghciLib, Path ghciCxx, Path ghciCc, Path ghciCpp, Path ghciPackager) {//www .j a v a 2 s. c om ImmutableSet.Builder<BuildRule> extraDeps = ImmutableSet.builder(); extraDeps.add(omnibusSharedObject); for (HaskellPackage pkg : haskellPackages) { extraDeps.addAll(pkg.getDeps(ruleFinder)::iterator); } for (HaskellPackage pkg : prebuiltHaskellPackages) { extraDeps.addAll(pkg.getDeps(ruleFinder)::iterator); } ghciBinDep.flatMap(ruleFinder::getRule).ifPresent(extraDeps::add); extraDeps.addAll(ruleFinder.filterBuildRuleInputs(solibs.values())); extraDeps.addAll(ruleFinder.filterBuildRuleInputs(preloadLibs.values())); return new HaskellGhciRule(buildTarget, projectFilesystem, params.copyAppendingExtraDeps(extraDeps.build()), srcs, compilerFlags, ghciBinDep, ghciInit, omnibusSharedObject, solibs, preloadLibs, firstOrderHaskellPackages, haskellPackages, prebuiltHaskellPackages, enableProfiling, ghciScriptTemplate, extraScriptTemplates, ghciIservScriptTemplate, ghciBinutils, ghciGhc, ghciIServ, ghciIServProf, ghciLib, ghciCxx, ghciCc, ghciCpp, ghciPackager); }
From source file:com.facebook.buck.features.go.GoDescriptors.java
static GoCompile createGoCompileRule(BuildTarget buildTarget, ProjectFilesystem projectFilesystem, BuildRuleParams params, ActionGraphBuilder graphBuilder, GoBuckConfig goBuckConfig, Path packageName, ImmutableSet<SourcePath> srcs, List<String> compilerFlags, List<String> assemblerFlags, GoPlatform platform, Iterable<BuildTarget> deps, Iterable<BuildTarget> cgoDeps, List<ListType> goListTypes) { SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(graphBuilder); SourcePathResolver pathResolver = DefaultSourcePathResolver.from(ruleFinder); Preconditions.checkState(buildTarget.getFlavors().contains(platform.getFlavor())); ImmutableSet<GoLinkable> linkables = requireGoLinkables(buildTarget, graphBuilder, platform, deps); ImmutableList.Builder<BuildRule> linkableDepsBuilder = ImmutableList.builder(); for (GoLinkable linkable : linkables) { linkableDepsBuilder.addAll(linkable.getDeps(ruleFinder)); }//from ww w .jav a2s .com BuildTarget target = createSymlinkTreeTarget(buildTarget); SymlinkTree symlinkTree = makeSymlinkTree(target, projectFilesystem, ruleFinder, pathResolver, linkables); graphBuilder.addToIndex(symlinkTree); ImmutableList.Builder<SourcePath> extraAsmOutputsBuilder = ImmutableList.builder(); ImmutableSet.Builder<SourcePath> generatedSrcBuilder = ImmutableSet.builder(); for (BuildTarget cgoBuildTarget : cgoDeps) { CGoLibrary lib = getCGoLibrary(graphBuilder, platform, cgoBuildTarget); generatedSrcBuilder.addAll(lib.getGeneratedGoSource()); extraAsmOutputsBuilder.add(lib.getOutput()); linkableDepsBuilder.add(lib); } LOG.verbose("Symlink tree for compiling %s: %s", buildTarget, symlinkTree.getLinks()); return new GoCompile(buildTarget, projectFilesystem, params.copyAppendingExtraDeps(linkableDepsBuilder.build()) .copyAppendingExtraDeps(ImmutableList.of(symlinkTree)) .copyAppendingExtraDeps(getDependenciesFromSources(ruleFinder, srcs)), symlinkTree, packageName, getPackageImportMap(goBuckConfig.getVendorPaths(), buildTarget.getBasePath(), linkables.stream().flatMap(input -> input.getGoLinkInput().keySet().stream()) .collect(ImmutableList.toImmutableList())), srcs, generatedSrcBuilder.build(), ImmutableList.copyOf(compilerFlags), ImmutableList.copyOf(assemblerFlags), platform, goBuckConfig.getGensymabis(), extraAsmOutputsBuilder.build(), goListTypes); }
From source file:com.facebook.buck.features.go.GoDescriptors.java
static Iterable<BuildRule> getCgoLinkableDeps(Iterable<BuildRule> deps) { ImmutableSet.Builder<BuildRule> linkables = ImmutableSet.builder(); new AbstractBreadthFirstTraversal<BuildRule>(deps) { @Override//from w w w. j a v a2s . c o m public Iterable<BuildRule> visit(BuildRule rule) { if (rule instanceof CGoLibrary) { linkables.addAll(((CGoLibrary) rule).getLinkableDeps()); return ImmutableList.of(); } return rule.getBuildDeps(); } }.start(); return linkables.build(); }
From source file:dagger.internal.codegen.ConfigurationAnnotations.java
/** Traverses includes from superclasses and adds them into the builder. */ private static void addIncludesFromSuperclasses(Types types, TypeElement element, ImmutableSet.Builder<TypeElement> builder, TypeMirror objectType) { // Also add the superclass to the queue, in case any @Module definitions were on that. TypeMirror superclass = element.getSuperclass(); while (!types.isSameType(objectType, superclass) && superclass.getKind().equals(TypeKind.DECLARED)) { element = MoreElements.asType(types.asElement(superclass)); getModuleAnnotation(element).ifPresent(moduleMirror -> { builder.addAll(MoreTypes.asTypeElements(getModuleIncludes(moduleMirror))); });/*from w w w . j a va 2s. co m*/ superclass = element.getSuperclass(); } }
From source file:com.facebook.buck.apple.xcode.RuleDependencyFinder.java
private static ImmutableSet<BuildRule> gatherTransitiveDependencies(Iterable<? extends BuildRule> initial) { final ImmutableSet.Builder<BuildRule> buildRulesBuilder = ImmutableSet.builder(); AbstractAcyclicDepthFirstPostOrderTraversal<BuildRule> allDependenciesTraversal = new AbstractAcyclicDepthFirstPostOrderTraversal<BuildRule>() { @Override/* w w w.ja va 2 s . c o m*/ protected Iterator<BuildRule> findChildren(BuildRule node) throws IOException { return node.getDeps().iterator(); } @Override protected void onNodeExplored(BuildRule node) { } @Override protected void onTraversalComplete(Iterable<BuildRule> nodesInExplorationOrder) { buildRulesBuilder.addAll(nodesInExplorationOrder); } }; try { allDependenciesTraversal.traverse(initial); } catch (AbstractAcyclicDepthFirstPostOrderTraversal.CycleException e) { throw new HumanReadableException(e, "Cycle detected while gathering build rule dependencies for project generation:\n " + e.getMessage()); } catch (IOException e) { throw new RuntimeException(e); } return buildRulesBuilder.build(); }
From source file:dagger2.internal.codegen.ConfigurationAnnotations.java
/** Traverses includes from superclasses and adds them into the builder. */ private static void addIncludesFromSuperclasses(Types types, TypeElement element, ImmutableSet.Builder<TypeElement> builder, TypeMirror objectType) { // Also add the superclass to the queue, in case any @Module definitions were on that. TypeMirror superclass = element.getSuperclass(); while (!types.isSameType(objectType, superclass) && superclass.getKind().equals(TypeKind.DECLARED)) { element = MoreElements.asType(types.asElement(superclass)); Optional<AnnotationMirror> moduleMirror = getAnnotationMirror(element, Module.class) .or(getAnnotationMirror(element, ProducerModule.class)); if (moduleMirror.isPresent()) { builder.addAll(MoreTypes.asTypeElements(getModuleIncludes(moduleMirror.get()))); }//from w ww. j a va 2s .c o m superclass = element.getSuperclass(); } }
From source file:com.google.devtools.build.lib.rules.objc.ObjcCommon.java
/** * Returns all directories matching {@code containerType} that contain the items in * {@code artifacts}. This function ignores artifacts that are not in any directory matching * {@code containerType}./* www .j av a 2 s .c o m*/ */ static Iterable<PathFragment> uniqueContainers(Iterable<Artifact> artifacts, FileType containerType) { ImmutableSet.Builder<PathFragment> containers = new ImmutableSet.Builder<>(); for (Artifact artifact : artifacts) { containers.addAll(ObjcCommon.nearestContainerMatching(containerType, artifact).asSet()); } return containers.build(); }
From source file:com.opengamma.strata.engine.marketdata.CalculationRequirements.java
/** * Merges multiple sets of requirements into a single set. * * @param requirements market data requirements * @return a single set of requirements containing all the requirements from the input sets *///from w ww.j a va 2 s. c o m public static CalculationRequirements combine(List<CalculationRequirements> requirements) { ImmutableSet.Builder<ObservableId> observablesBuilder = ImmutableSet.builder(); ImmutableSet.Builder<MarketDataId<?>> nonObservablesBuilder = ImmutableSet.builder(); ImmutableSet.Builder<ObservableId> timeSeriesBuilder = ImmutableSet.builder(); ImmutableSet.Builder<Currency> outputCurrenciesBuilder = ImmutableSet.builder(); for (CalculationRequirements req : requirements) { observablesBuilder.addAll(req.observables); nonObservablesBuilder.addAll(req.nonObservables); timeSeriesBuilder.addAll(req.timeSeries); outputCurrenciesBuilder.addAll(req.outputCurrencies); } return new CalculationRequirements(observablesBuilder.build(), nonObservablesBuilder.build(), timeSeriesBuilder.build(), outputCurrenciesBuilder.build()); }