Example usage for com.google.common.collect ImmutableList.Builder addAll

List of usage examples for com.google.common.collect ImmutableList.Builder addAll

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList.Builder addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

Usage

From source file:com.google.devtools.build.lib.rules.java.JavaCommon.java

private static ImmutableList<TransitiveInfoCollection> collectTargetsTreatedAsDeps(RuleContext ruleContext,
        JavaSemantics semantics, ClasspathType type) {
    ImmutableList.Builder<TransitiveInfoCollection> builder = new Builder<>();

    if (!type.equals(ClasspathType.COMPILE_ONLY)) {
        builder.addAll(getRuntimeDeps(ruleContext));
        builder.addAll(getExports(ruleContext));
    }//from  ww  w . j  av a2s  . com
    builder.addAll(ruleContext.getPrerequisites("deps", Mode.TARGET));

    semantics.collectTargetsTreatedAsDeps(ruleContext, builder);

    // Implicitly add dependency on java launcher cc_binary when --java_launcher= is enabled,
    // or when launcher attribute is specified in a build rule.
    TransitiveInfoCollection launcher = JavaHelper.launcherForTarget(semantics, ruleContext);
    if (launcher != null) {
        builder.add(launcher);
    }

    return builder.build();
}

From source file:com.facebook.buck.cxx.CxxLibraryFactory.java

private static ImmutableList<SourcePath> requireObjects(BuildTarget buildTarget,
        ProjectFilesystem projectFilesystem, ActionGraphBuilder graphBuilder,
        SourcePathResolver sourcePathResolver, SourcePathRuleFinder ruleFinder, CellPathResolver cellRoots,
        CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform, PicType pic, CxxLibraryDescriptionArg args,
        ImmutableSet<BuildRule> deps,
        CxxLibraryDescription.TransitiveCxxPreprocessorInputFunction transitivePreprocessorInputs,
        Optional<CxxLibraryDescriptionDelegate> delegate) {

    // TODO(T21900747): Fix dependence on order of object paths
    ImmutableList.Builder<SourcePath> builder = ImmutableList.builder();
    ImmutableMap<CxxPreprocessAndCompile, SourcePath> cxxObjects = requireCxxObjects(buildTarget,
            projectFilesystem, graphBuilder, sourcePathResolver, ruleFinder, cellRoots, cxxBuckConfig,
            cxxPlatform, pic, args, deps, transitivePreprocessorInputs, delegate);

    builder.addAll(cxxObjects.values());

    Optional<ImmutableList<SourcePath>> pluginObjectPaths = delegate
            .flatMap(p -> p.getObjectFilePaths(buildTarget, graphBuilder, cxxPlatform));
    pluginObjectPaths.ifPresent(paths -> builder.addAll(paths));

    return builder.build();
}

From source file:com.facebook.buck.android.NdkCxxPlatforms.java

private static ImmutableList<String> getCxxppflags(NdkCxxPlatformTargetConfiguration targetConfiguration,
        NdkCxxToolchainPaths toolchainPaths) {
    ImmutableList.Builder<String> flags = ImmutableList.builder();
    flags.addAll(getCxxRuntimeIncludeFlags(targetConfiguration, toolchainPaths));
    flags.addAll(getCommonIncludes(toolchainPaths));
    flags.addAll(getCommonPreprocessorFlags());
    flags.addAll(getCommonFlags(targetConfiguration, toolchainPaths));
    flags.addAll(getCommonCxxFlags());//from  w  w w .  ja v  a  2 s.c  o  m
    if (targetConfiguration.getCompiler().getType() == NdkCxxPlatformCompiler.Type.GCC) {
        flags.add("-Wno-literal-suffix");
    }
    flags.addAll(targetConfiguration.getCompilerFlags(targetConfiguration.getCompiler().getType()));
    return flags.build();
}

From source file:io.prestosql.plugin.hive.HiveUtil.java

public static List<HiveColumnHandle> hiveColumnHandles(Table table) {
    ImmutableList.Builder<HiveColumnHandle> columns = ImmutableList.builder();

    // add the data fields first
    columns.addAll(getRegularColumnHandles(table));

    // add the partition keys last (like Hive does)
    columns.addAll(getPartitionKeyColumnHandles(table));

    // add hidden columns
    columns.add(pathColumnHandle());/*from w  ww.j ava 2  s. c  om*/
    if (table.getStorage().getBucketProperty().isPresent()) {
        columns.add(bucketColumnHandle());
    }

    return columns.build();
}

From source file:org.apache.flex.compiler.internal.targets.Target.java

/**
 * Find all the externally visible definitions in the given compilation unit
 * list.//w w w  . j a  v  a2  s  .c  o m
 * 
 * @param compilationUnits A collection of compilation units.
 * @return All the externally visible definitions in the given compilation
 * unit list.
 * @throws InterruptedException Concurrency error.
 */
public static ImmutableList<IDefinition> getAllExternallyVisibleDefinitions(
        final Collection<ICompilationUnit> compilationUnits) throws InterruptedException {
    assert compilationUnits != null : "Expected collection of compilation units.";

    final ImmutableList.Builder<IDefinition> builder = new ImmutableList.Builder<IDefinition>();
    for (final ICompilationUnit compilationUnit : compilationUnits) {
        final IFileScopeRequestResult result = compilationUnit.getFileScopeRequest().get();
        builder.addAll(result.getExternallyVisibleDefinitions());
    }
    return builder.build();
}

From source file:com.facebook.buck.android.toolchain.ndk.impl.NdkCxxPlatforms.java

private static ImmutableList<String> getCxxPreprocessorFlags(
        NdkCxxPlatformTargetConfiguration targetConfiguration, NdkCxxToolchainPaths toolchainPaths,
        AndroidBuckConfig config) {/*ww  w.  jav  a2 s.com*/
    ImmutableList.Builder<String> flags = ImmutableList.builder();
    flags.addAll(getCxxRuntimeIncludeFlags(targetConfiguration, toolchainPaths));
    flags.addAll(getCommonIncludes(toolchainPaths));
    flags.addAll(DEFAULT_COMMON_CXXPPFLAGS);
    flags.addAll(getCommonFlags(targetConfiguration, toolchainPaths));
    flags.addAll(DEFAULT_COMMON_CXXFLAGS);
    if (targetConfiguration.getCompiler().getType() == NdkCompilerType.GCC) {
        flags.add("-Wno-literal-suffix");
    }
    flags.addAll(targetConfiguration.getCompilerFlags(targetConfiguration.getCompiler().getType()));
    flags.addAll(config.getExtraNdkCxxFlags());
    return flags.build();
}

From source file:eu.arthepsy.sonar.plugins.rebrand.RebrandPlugin.java

@Override
public List getExtensions() {
    ImmutableList.Builder<Object> builder = ImmutableList.builder();
    builder.addAll(RebrandConfiguration.getPropertyDefinitions());
    builder.add(ImagesFooter.class);
    return builder.build();
}

From source file:com.google.devtools.build.lib.rules.cpp.FlagList.java

@VisibleForTesting
ImmutableList<String> evaluate() {
    ImmutableList.Builder<String> result = ImmutableList.builder();
    result.addAll(prefixFlags);
    result.addAll(suffixFlags);//from   w w  w . ja v  a2s .  c  o  m
    return result.build();
}

From source file:com.google.devtools.build.lib.rules.android.AndroidCommon.java

public static final Iterable<TransitiveInfoCollection> collectTransitiveInfo(RuleContext ruleContext,
        Mode mode) {/*from   w ww .j  ava 2  s. co  m*/
    ImmutableList.Builder<TransitiveInfoCollection> builder = ImmutableList.builder();
    for (String attr : TRANSITIVE_ATTRIBUTES) {
        if (ruleContext.attributes().has(attr, BuildType.LABEL_LIST)) {
            builder.addAll(ruleContext.getPrerequisites(attr, mode));
        }
    }
    return builder.build();
}

From source file:eu.arthepsy.sonar.plugins.elixir.ElixirPlugin.java

@Override
public List getExtensions() {
    ImmutableList.Builder<Object> builder = ImmutableList.builder();
    builder.addAll(ElixirConfiguration.getPropertyDefinitions());
    builder.add(Elixir.class);
    builder.add(ElixirQualityProfile.class);
    builder.add(ElixirMeasureSensor.class);
    return builder.build();
}