Example usage for com.google.common.collect ImmutableSortedSet of

List of usage examples for com.google.common.collect ImmutableSortedSet of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSortedSet of.

Prototype

@SuppressWarnings("unchecked")
    public static <E> ImmutableSortedSet<E> of() 

Source Link

Usage

From source file:com.facebook.buck.java.AccumulateClassNames.java

@Override
public Iterable<String> getInputsToCompareToOutput() {
    // The deps of this rule already capture all of the inputs that should affect the cache key.
    return ImmutableSortedSet.of();
}

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

private static BuildRuleParams makeBuildRuleParams(ImmutableSortedSet<BuildRule> deps) {
    return new BuildRuleParams(() -> deps, () -> ImmutableSortedSet.of(), ImmutableSortedSet.of());
}

From source file:com.facebook.buck.java.ExternalJavac.java

@Override
public ImmutableCollection<SourcePath> getInputs() {
    return ImmutableSortedSet.of();
}

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

@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params,
        BuildRuleResolver buildRuleResolver, A args) throws NoSuchBuildTargetException {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(buildRuleResolver);

    ImmutableSet<Flavor> flavors = params.getBuildTarget().getFlavors();
    if (flavors.contains(AAR_UNZIP_FLAVOR)) {
        Preconditions.checkState(flavors.size() == 1);
        BuildRuleParams unzipAarParams = params.copyWithDeps(Suppliers.ofInstance(ImmutableSortedSet.of()),
                Suppliers.ofInstance(ImmutableSortedSet.copyOf(ruleFinder.filterBuildRuleInputs(args.aar))));
        return new UnzipAar(unzipAarParams, args.aar);
    }//ww  w.  ja  va 2 s.co  m

    BuildRule unzipAarRule = buildRuleResolver
            .requireRule(params.getBuildTarget().withFlavors(AAR_UNZIP_FLAVOR));
    Preconditions.checkState(unzipAarRule instanceof UnzipAar,
            "aar_unzip flavor created rule of unexpected type %s for target %s", unzipAarRule.getClass(),
            params.getBuildTarget());
    UnzipAar unzipAar = (UnzipAar) unzipAarRule;

    if (flavors.contains(CalculateAbi.FLAVOR)) {
        return CalculateAbi.of(params.getBuildTarget(), ruleFinder, params,
                new BuildTargetSourcePath(unzipAar.getBuildTarget(), unzipAar.getPathToClassesJar()));
    }

    Iterable<PrebuiltJar> javaDeps = Iterables.concat(
            Iterables.filter(buildRuleResolver.getAllRules(args.deps), PrebuiltJar.class),
            Iterables.transform(
                    Iterables.filter(buildRuleResolver.getAllRules(args.deps), AndroidPrebuiltAar.class),
                    AndroidPrebuiltAar::getPrebuiltJar));

    BuildTarget abiJarTarget = params.getBuildTarget().withAppendedFlavors(CalculateAbi.FLAVOR);

    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);

    PrebuiltJar prebuiltJar = buildRuleResolver.addToIndex(createPrebuiltJar(unzipAar, params, pathResolver,
            abiJarTarget, ImmutableSortedSet.copyOf(javaDeps)));

    BuildRuleParams androidLibraryParams = params.copyWithDeps(
            /* declaredDeps */ Suppliers.ofInstance(ImmutableSortedSet.of(prebuiltJar)),
            /* extraDeps */ Suppliers.ofInstance(ImmutableSortedSet.of(unzipAar)));
    return new AndroidPrebuiltAar(androidLibraryParams, /* resolver */ pathResolver, ruleFinder,
            /* proguardConfig */ new BuildTargetSourcePath(unzipAar.getBuildTarget(),
                    unzipAar.getProguardConfig()),
            /* nativeLibsDirectory */ new BuildTargetSourcePath(unzipAar.getBuildTarget(),
                    unzipAar.getNativeLibsDirectory()),
            /* prebuiltJar */ prebuiltJar, /* unzipRule */ unzipAar, /* javacOptions */ javacOptions,
            new JavacToJarStepFactory(javacOptions, new BootClasspathAppender()), /* exportedDeps */ javaDeps,
            abiJarTarget, JavaLibraryRules.getAbiInputs(buildRuleResolver, androidLibraryParams.getDeps()));
}

From source file:com.facebook.buck.rules.RuleKey.java

/**
 * Builder for a {@link RuleKey} that is a function of all of a {@link BuildRule}'s inputs.
 *//*from  w  w  w  .j  a  va  2 s  . com*/
public static Builder builder(BuildRule rule, FileHashCache hashCache) {
    ImmutableSortedSet<BuildRule> exportedDeps;
    if (rule.getBuildable() instanceof ExportDependencies) {
        exportedDeps = ((ExportDependencies) rule.getBuildable()).getExportedDeps();
    } else {
        exportedDeps = ImmutableSortedSet.of();
    }
    return builder(rule.getBuildTarget(), rule.getType(), rule.getDeps(), exportedDeps, hashCache);
}

From source file:com.facebook.buck.config.Configs.java

private static ImmutableSortedSet<Path> listFiles(Path root) throws IOException {
    if (!Files.isDirectory(root)) {
        return ImmutableSortedSet.of();
    }//from w  w w  . j a  v a  2  s .  c o  m
    try (DirectoryStream<Path> directory = Files.newDirectoryStream(root)) {
        return ImmutableSortedSet.<Path>naturalOrder().addAll(directory.iterator()).build();
    }
}

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

/**
 * @param params base params used to build the rule.  Target and deps will be overridden.
 *//*  ww  w .  j a v  a2 s .c o m*/
public static CxxLink createCxxLinkableBuildRule(CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform,
        BuildRuleParams params, BuildRuleResolver ruleResolver, final SourcePathResolver resolver,
        SourcePathRuleFinder ruleFinder, BuildTarget target, Path output, ImmutableList<Arg> args,
        Linker.LinkableDepType depType, Optional<Linker.CxxRuntimeType> cxxRuntimeType) {

    final Linker linker = cxxPlatform.getLd().resolve(ruleResolver);

    // Build up the arguments to pass to the linker.
    ImmutableList.Builder<Arg> argsBuilder = ImmutableList.builder();

    // Add flags to generate linker map if supported.
    if (linker instanceof HasLinkerMap && LinkerMapMode.isLinkerMapEnabledForBuildTarget(target)) {
        argsBuilder.addAll(((HasLinkerMap) linker).linkerMap(output));
    }

    // Pass any platform specific or extra linker flags.
    argsBuilder.addAll(SanitizedArg.from(cxxPlatform.getCompilerDebugPathSanitizer().sanitize(Optional.empty()),
            cxxPlatform.getLdflags()));

    argsBuilder.addAll(args);

    // Add all arguments needed to link in the C/C++ platform runtime.
    Linker.LinkableDepType runtimeDepType = depType;
    if (cxxRuntimeType.orElse(Linker.CxxRuntimeType.DYNAMIC) == Linker.CxxRuntimeType.STATIC) {
        runtimeDepType = Linker.LinkableDepType.STATIC;
    }
    argsBuilder.addAll(StringArg.from(cxxPlatform.getRuntimeLdflags().get(runtimeDepType)));

    final ImmutableList<Arg> allArgs = argsBuilder.build();

    // Build the C/C++ link step.
    return new CxxLink(
            // Construct our link build rule params.  The important part here is combining the build
            // rules that construct our object file inputs and also the deps that build our
            // dependencies.
            params.copyWithChanges(target,
                    () -> FluentIterable.from(allArgs).transformAndConcat(arg -> arg.getDeps(ruleFinder))
                            .append(linker.getDeps(ruleFinder)).toSortedSet(Ordering.natural()),
                    Suppliers.ofInstance(ImmutableSortedSet.of())),
            resolver, linker, output, allArgs, cxxBuckConfig.getLinkScheduleInfo(),
            cxxBuckConfig.shouldCacheLinks());
}

From source file:com.google.gerrit.server.change.SetHashtagsOp.java

@Override
public boolean updateChange(ChangeContext ctx)
        throws AuthException, BadRequestException, MethodNotAllowedException, OrmException, IOException {
    if (!notesMigration.readChanges()) {
        throw new MethodNotAllowedException("Cannot add hashtags; NoteDb is disabled");
    }/*from  ww w.  j a  va2 s.  com*/
    if (input == null || (input.add == null && input.remove == null)) {
        updatedHashtags = ImmutableSortedSet.of();
        return false;
    }

    change = ctx.getChange();
    ChangeUpdate update = ctx.getUpdate(change.currentPatchSetId());
    ChangeNotes notes = update.getNotes().load();

    Set<String> existingHashtags = notes.getHashtags();
    Set<String> updated = new HashSet<>();
    toAdd = new HashSet<>(extractTags(input.add));
    toRemove = new HashSet<>(extractTags(input.remove));

    try {
        for (HashtagValidationListener validator : validationListeners) {
            validator.validateHashtags(update.getChange(), toAdd, toRemove);
        }
    } catch (ValidationException e) {
        throw new BadRequestException(e.getMessage());
    }

    updated.addAll(existingHashtags);
    toAdd.removeAll(existingHashtags);
    toRemove.retainAll(existingHashtags);
    if (updated()) {
        updated.addAll(toAdd);
        updated.removeAll(toRemove);
        update.setHashtags(updated);
        addMessage(ctx, update);
    }

    updatedHashtags = ImmutableSortedSet.copyOf(updated);
    return true;
}

From source file:com.facebook.buck.jvm.java.FakeJavaLibrary.java

@Override
public ImmutableSortedSet<SourcePath> getResources() {
    return ImmutableSortedSet.of();
}

From source file:com.facebook.buck.features.project.intellij.ShallowTargetNodeToBuildRuleTransformer.java

@Override
public <T> BuildRule transform(ToolchainProvider toolchainProvider, TargetGraph targetGraph,
        ActionGraphBuilder graphBuilder, TargetNode<T> targetNode) {
    DescriptionWithTargetGraph<T> description = (DescriptionWithTargetGraph<T>) targetNode.getDescription();

    T arg = targetNode.getConstructorArg();

    if (UNUSED_BUILD_RULE_DESCRIPTION_CLASSES.contains(description.getClass())
            || description.getClass().getSuperclass().equals(AbstractGenruleDescription.class)) {
        String outputPath;//from w  w  w .ja  v a  2  s .  c om
        if (description.getClass().equals(GenruleDescription.class)) {
            outputPath = ((GenruleDescriptionArg) arg).getOut();
        } else {
            // This path is never used, but it needs to be unique, to prevent conflicts creating
            // resource maps while creating java build rules.
            outputPath = Util.normalizeIntelliJName(targetNode.getBuildTarget().getFullyQualifiedName());
        }
        return new EmptyBuildRule(targetNode.getBuildTarget(), targetNode.getFilesystem(), outputPath);
    } else {
        BuildRuleParams params = new BuildRuleParams(ImmutableSortedSet::of, ImmutableSortedSet::of,
                ImmutableSortedSet.of());

        BuildRuleCreationContextWithTargetGraph context = ImmutableBuildRuleCreationContextWithTargetGraph.of(
                targetGraph, graphBuilder, targetNode.getFilesystem(), targetNode.getCellNames(),
                toolchainProvider);

        return description.createBuildRule(context, targetNode.getBuildTarget(), params, arg);
    }
}