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.api.codegen.transformer.nodejs.NodeJSGapicSamplesTransformer.java

@Override
public List<ViewModel> transform(ProtoApiModel model, GapicProductConfig productConfig) {
    Iterable<? extends InterfaceModel> apiInterfaces = model.getInterfaces();
    ImmutableList.Builder<ViewModel> models = ImmutableList.builder();
    models.addAll(generateSampleClassesForModel(model, productConfig));
    return models.build();
}

From source file:com.facebook.buck.features.dotnet.CsharpLibraryCompile.java

@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
    DotnetFramework netFramework = DotnetFramework.resolveFramework(version);

    ImmutableList.Builder<String> args = ImmutableList.builder();

    args.addAll(csharpCompiler.getCommandPrefix(pathResolver));
    args.add("/noconfig");
    args.add("/nostdlib");
    args.add("/deterministic");
    args.add("/target:library").add("/out:" + output);

    for (Either<Path, String> ref : references) {
        args.add("/reference:" + resolveReference(netFramework, ref));
    }//from   w  ww . j av a 2  s.  co m

    for (Path resource : resources.keySet()) {
        for (String name : resources.get(resource)) {
            args.add("/resource:" + Escaper.escapeAsShellString(resource.toString()) + "," + name);
        }
    }

    args.addAll(srcs.stream().map(input -> Escaper.escapeAsShellString(input.toAbsolutePath().toString()))
            .collect(ImmutableSet.toImmutableSet()));

    return args.build();
}

From source file:com.facebook.buck.d.DCompileBuildRule.java

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    buildableContext.recordArtifact(getPathToOutput());

    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MkdirStep(getProjectFilesystem(), Preconditions.checkNotNull(getPathToOutput()).getParent()));

    ImmutableList.Builder<String> flagsBuilder = ImmutableList.builder();
    flagsBuilder.addAll(compilerFlags);
    for (DIncludes include : includes) {
        flagsBuilder.add("-I" + getResolver().getAbsolutePath(include.getLinkTree()));
    }/*  w w w .  j  ava  2 s. co  m*/
    ImmutableList<String> flags = flagsBuilder.build();

    steps.add(new DCompileStep(getProjectFilesystem().getRootPath(), compiler.getEnvironment(),
            compiler.getCommandPrefix(getResolver()), flags, getPathToOutput(),
            getResolver().getAllAbsolutePaths(sources)));
    return steps.build();
}

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

/**
 * Build a list of compiler flag strings representing the contained paths.
 *
 * This method's parameters allow the caller to do some massaging and cleaning-up of paths.
 * @param pathResolver/*from w  w w. j  av  a 2 s  .c o m*/
 * @param pathShortener used to shorten the {@code -I} and {@code -isystem} paths
 * @param frameworkPathTransformer used to shorten/convert/transmogrify framework {@code -F} paths
 */
public ImmutableList<String> getFlags(SourcePathResolver pathResolver, PathShortener pathShortener,
        Function<FrameworkPath, Path> frameworkPathTransformer, Preprocessor preprocessor) {
    ImmutableList.Builder<String> builder = ImmutableList.builder();

    builder.addAll(CxxHeaders.getArgs(getIPaths(), pathResolver, Optional.of(pathShortener), preprocessor));

    builder.addAll(MoreIterables.zipAndConcat(Iterables.cycle("-F"), FluentIterable.from(getFPaths())
            .transform(frameworkPathTransformer).transform(Object::toString).toSortedSet(Ordering.natural())));

    return builder.build();
}

From source file:org.sonar.protobuf.ProtoBufAnalyzer.java

public List<Issue> analyze(File file) {
    // fixme : handle parsing exceptions
    ProtoBufUnitTree tree = (ProtoBufUnitTree) parser.parse(file);

    ImmutableList.Builder<Issue> issuesBuilder = ImmutableList.builder();
    for (ProtoBufCheck check : checks) {
        issuesBuilder.addAll(check.analyze(file, tree));
    }/*from  ww w. j  a v  a2  s . co m*/

    return issuesBuilder.build();
}

From source file:org.sonar.plugins.coverage.generic.GenericCoveragePlugin.java

@Override
public List getExtensions() {
    ImmutableList.Builder builder = ImmutableList.builder();
    builder.add(GenericCoverageSensor.class);
    builder.addAll(pluginProperties());
    return builder.build();
}

From source file:com.facebook.buck.features.go.CGoGenImport.java

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {

    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.addAll(MakeCleanDirectoryStep.of(BuildCellRelativePath
            .fromCellRelativePath(context.getBuildCellRootPath(), getProjectFilesystem(), genDir)));

    // Read the package name from given source file and use it as source of
    // truth (other files should have the same package name).
    Path srcFile = pathResolver.getAbsolutePath(sourceWithPackageName);
    GoListStep listStep = new GoListStep(srcFile.getParent(), Optional.of(srcFile.getFileName()), platform,
            Collections.singletonList(ListType.Name));
    steps.add(listStep);/* w  ww  .j a v a2 s.co m*/

    steps.add(new CGoGenerateImportStep(getProjectFilesystem().getRootPath(),
            cgo.getCommandPrefix(pathResolver), platform, MoreSuppliers.memoize(listStep::getRawOutput),
            pathResolver.getAbsolutePath(cgoBin), outputFile));

    buildableContext.recordArtifact(outputFile);
    return steps.build();
}

From source file:io.prestosql.sql.tree.SimpleCaseExpression.java

@Override
public List<Node> getChildren() {
    ImmutableList.Builder<Node> nodes = ImmutableList.builder();
    nodes.add(operand);// w w w .  j a  v a  2 s.c o  m
    nodes.addAll(whenClauses);
    defaultValue.ifPresent(nodes::add);
    return nodes.build();
}

From source file:com.facebook.buck.features.d.DCompileBuildRule.java

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    Path output = context.getSourcePathResolver()
            .getRelativePath(Objects.requireNonNull(getSourcePathToOutput()));
    buildableContext.recordArtifact(output);

    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(MkdirStep.of(BuildCellRelativePath.fromCellRelativePath(context.getBuildCellRootPath(),
            getProjectFilesystem(), output.getParent())));

    ImmutableList.Builder<String> flagsBuilder = ImmutableList.builder();
    flagsBuilder.addAll(compilerFlags);
    for (DIncludes include : includes) {
        flagsBuilder.add("-I" + context.getSourcePathResolver().getAbsolutePath(include.getLinkTree()));
    }// w  w  w  . j  ava 2  s  . c  om
    ImmutableList<String> flags = flagsBuilder.build();

    steps.add(new DCompileStep(getProjectFilesystem().getRootPath(),
            compiler.getEnvironment(context.getSourcePathResolver()),
            compiler.getCommandPrefix(context.getSourcePathResolver()), flags,
            context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()),
            context.getSourcePathResolver().getAllAbsolutePaths(sources)));
    return steps.build();
}

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

private ImmutableList<String> getObjcopyCommand(ImmutableMap<String, Long> addresses) {
    ImmutableList.Builder<String> args = ImmutableList.builder();
    args.addAll(getObjcopyPrefix());
    for (String section : getSections()) {
        Long address = addresses.get(section);
        if (address != null) {
            args.add("--only-section", section, "--change-section-address",
                    String.format("%s=0x%x", section, address));
        }//ww w  .j  ava 2 s .c om
    }
    args.add(getInput().toString());
    args.add(getOutput().toString());
    return args.build();
}