Example usage for com.google.common.collect ImmutableList isEmpty

List of usage examples for com.google.common.collect ImmutableList isEmpty

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:com.google.javascript.jscomp.TypeInference.java

/**
 * For functions with function(this: T, ...) and T as parameters, type
 * inference will set the type of this on a function literal argument to the
 * the actual type of T./*from  w ww  .  j a  va  2 s  .  com*/
 */
private boolean inferTemplatedTypesForCall(Node n, FunctionType fnType) {
    final ImmutableList<TemplateType> keys = fnType.getTemplateTypeMap().getTemplateKeys();
    if (keys.isEmpty()) {
        return false;
    }

    // Try to infer the template types
    Map<TemplateType, JSType> rawInferrence = inferTemplateTypesFromParameters(fnType, n);
    Map<TemplateType, JSType> inferred = Maps.newIdentityHashMap();
    for (TemplateType key : keys) {
        JSType type = rawInferrence.get(key);
        if (type == null) {
            type = unknownType;
        }
        inferred.put(key, type);
    }

    // Try to infer the template types using the type transformations
    Map<TemplateType, JSType> typeTransformations = evaluateTypeTransformations(keys, inferred);
    if (typeTransformations != null) {
        inferred.putAll(typeTransformations);
    }

    // Replace all template types. If we couldn't find a replacement, we
    // replace it with UNKNOWN.
    TemplateTypeReplacer replacer = new TemplateTypeReplacer(registry, inferred);
    Node callTarget = n.getFirstChild();

    FunctionType replacementFnType = fnType.visit(replacer).toMaybeFunctionType();
    Preconditions.checkNotNull(replacementFnType);

    callTarget.setJSType(replacementFnType);
    n.setJSType(replacementFnType.getReturnType());

    return replacer.madeChanges;
}

From source file:de.cau.cs.kieler.kiml.util.nodespacing.LabelAndNodeSizeProcessor.java

/**
 * Places the labels of the given port on the outside of the port's node. We
 * suppose that the first label has label side information. Those are then
 * used for all labels. We don't support having some labels above and others
 * below incident edges./*from   w  w  w . j a  va  2 s.  co  m*/
 *
 * @param port
 *            the port whose label to place.
 * @param labelSpacing
 *            spacing between labels and other objects.
 */
private void placePortLabelsOutside(final PortAdapter<?> port, final double labelSpacing) {
    ImmutableList<LabelAdapter<?>> labels = ImmutableList.copyOf(port.getLabels());
    if (labels.isEmpty()) {
        return;
    }

    // Retrieve the first label's side
    LabelSide labelSide = labels.get(0).getSide();
    // Default is BELOW.
    labelSide = labelSide == LabelSide.UNKNOWN ? LabelSide.BELOW : labelSide;

    // The initial y position we'll be starting from depends on port and
    // label sides
    double y = 0;
    switch (port.getSide()) {
    case WEST:
    case EAST:
        if (labelSide == LabelSide.BELOW) {
            y = port.getSize().y;
        }
        break;

    case SOUTH:
        y = port.getSize().y;
        break;
    }

    // If labels are below incident edges, we simply start at a given y
    // position and place the
    // labels downwards. Of they are placed above or if we have a northern
    // port, however, we
    // actually need to start with the last label and place them upwards. We
    // thus first add all
    // labels to a list that we may need to reverse
    if ((port.getSide() == PortSide.NORTH) || (labelSide == LabelSide.ABOVE)) {
        labels = labels.reverse();
    }

    for (final LabelAdapter<?> label : labels) {
        final KVector position = new KVector(label.getPosition());
        if (labelSide == LabelSide.ABOVE) {
            // Place label "above" edges
            switch (port.getSide()) {
            case WEST:
                position.x = -label.getSize().x - labelSpacing;
                position.y = y - labelSpacing - label.getSize().y;

                y -= labelSpacing + label.getSize().y;
                break;
            case EAST:
                position.x = port.getSize().x + labelSpacing;
                position.y = y - labelSpacing - label.getSize().y;

                y -= labelSpacing + label.getSize().y;
                break;
            case NORTH:
                position.x = -label.getSize().x - labelSpacing;
                position.y = y - labelSpacing - label.getSize().y;

                y -= labelSpacing + label.getSize().y;
                break;
            case SOUTH:
                position.x = -label.getSize().x - labelSpacing;
                position.y = y + labelSpacing;

                y += labelSpacing + label.getSize().y;
                break;
            }
        } else {
            // Place label "below" edges
            switch (port.getSide()) {
            case WEST:
                position.x = -label.getSize().x - labelSpacing;
                position.y = y + labelSpacing;

                y += labelSpacing + label.getSize().y;
                break;
            case EAST:
                position.x = port.getSize().x + labelSpacing;
                position.y = y + labelSpacing;

                y += labelSpacing + label.getSize().y;
                break;
            case NORTH:
                position.x = port.getSize().x + labelSpacing;
                position.y = y - labelSpacing - label.getSize().y;

                y -= labelSpacing + label.getSize().y;
                break;
            case SOUTH:
                position.x = port.getSize().x + labelSpacing;
                position.y = y + labelSpacing;

                y += labelSpacing + label.getSize().y;
                break;
            }
        }
        label.setPosition(position);
    }
}

From source file:com.google.javascript.rhino.jstype.JSTypeRegistry.java

/**
 * check if a function declaration is the IObject interface
 * @param fnName the function's name/*from ww  w. ja  v  a  2 s  .  c om*/
 * @param info the JSDoc from the function declaration
 * @return true if it is, otherwise false
 */
public boolean isIObject(String fnName, JSDocInfo info) {
    if (!I_OBJECT_INTERFACE_NAME.equals(fnName)) {
        return false;
    }
    ImmutableList<String> infoTemplateTypeNames = info.getTemplateTypeNames();
    if (infoTemplateTypeNames.isEmpty() || infoTemplateTypeNames.size() != 2) {
        return false;
    }
    if (!isIObjectKeyKey(fnName, infoTemplateTypeNames.get(0))
            || !isIObjectValueKey(fnName, infoTemplateTypeNames.get(1))) {
        return false;
    }

    return true;
}

From source file:edu.mit.streamjit.impl.compiler2.Compiler2.java

public Compiler2(Set<Worker<?, ?>> workers, Configuration config, int maxNumCores, DrainData initialState,
        Input<?> input, Output<?> output) {
    this.workers = ImmutableSet.copyOf(workers);
    Map<Class<?>, ActorArchetype> archetypesBuilder = new HashMap<>();
    Map<Worker<?, ?>, WorkerActor> workerActors = new HashMap<>();
    for (Worker<?, ?> w : workers) {
        @SuppressWarnings("unchecked")
        Class<? extends Worker<?, ?>> wClass = (Class<? extends Worker<?, ?>>) w.getClass();
        if (archetypesBuilder.get(wClass) == null)
            archetypesBuilder.put(wClass, new ActorArchetype(wClass, module));
        WorkerActor actor = new WorkerActor(w, archetypesBuilder.get(wClass));
        workerActors.put(w, actor);//from   w ww .j  a  v  a 2  s .  c  o m
    }
    this.archetypes = ImmutableSet.copyOf(archetypesBuilder.values());

    Map<Token, TokenActor> tokenActors = new HashMap<>();
    Table<Actor, Actor, Storage> storageTable = HashBasedTable.create();
    int[] inputTokenId = new int[] { Integer.MIN_VALUE }, outputTokenId = new int[] { Integer.MAX_VALUE };
    for (WorkerActor a : workerActors.values())
        a.connect(ImmutableMap.copyOf(workerActors), tokenActors, storageTable, inputTokenId, outputTokenId);
    this.actors = new TreeSet<>();
    this.actors.addAll(workerActors.values());
    this.actors.addAll(tokenActors.values());
    this.storage = new HashSet<>(storageTable.values());

    this.config = config;
    this.maxNumCores = maxNumCores;
    this.initialState = initialState;
    ImmutableMap.Builder<Token, ImmutableList<Object>> initialStateDataMapBuilder = ImmutableMap.builder();
    if (initialState != null) {
        for (Table.Cell<Actor, Actor, Storage> cell : storageTable.cellSet()) {
            Token tok;
            if (cell.getRowKey() instanceof TokenActor)
                tok = ((TokenActor) cell.getRowKey()).token();
            else if (cell.getColumnKey() instanceof TokenActor)
                tok = ((TokenActor) cell.getColumnKey()).token();
            else
                tok = new Token(((WorkerActor) cell.getRowKey()).worker(),
                        ((WorkerActor) cell.getColumnKey()).worker());
            ImmutableList<Object> data = initialState.getData(tok);
            if (data != null && !data.isEmpty()) {
                initialStateDataMapBuilder.put(tok, data);
                cell.getValue().initialData().add(Pair.make(data, IndexFunction.identity()));
            }
        }
    }
    this.initialStateDataMap = initialStateDataMapBuilder.build();
    this.overallInput = input;
    this.overallOutput = output;
}

From source file:google.registry.flows.domain.DomainFlowUtils.java

/**
 * Validates a {@link FeeQueryCommandExtensionItem} and sets the appropriate fields on a {@link
 * FeeQueryResponseExtensionItem} builder.
 *///from   w w  w  .j  a  va  2 s  .  co  m
static void handleFeeRequest(FeeQueryCommandExtensionItem feeRequest,
        FeeQueryResponseExtensionItem.Builder<?, ?> builder, InternetDomainName domain,
        @Nullable CurrencyUnit topLevelCurrency, DateTime currentDate, DomainPricingLogic pricingLogic)
        throws EppException {
    DateTime now = currentDate;
    // Use the custom effective date specified in the fee check request, if there is one.
    if (feeRequest.getEffectiveDate().isPresent()) {
        now = feeRequest.getEffectiveDate().get();
        builder.setEffectiveDateIfSupported(now);
    }
    String domainNameString = domain.toString();
    Registry registry = Registry.get(domain.parent().toString());
    int years = verifyUnitIsYears(feeRequest.getPeriod()).getValue();
    boolean isSunrise = registry.getTldState(now).equals(TldState.SUNRISE);

    if (feeRequest.getPhase() != null || feeRequest.getSubphase() != null) {
        throw new FeeChecksDontSupportPhasesException();
    }

    CurrencyUnit currency = feeRequest.getCurrency() != null ? feeRequest.getCurrency() : topLevelCurrency;
    if ((currency != null) && !currency.equals(registry.getCurrency())) {
        throw new CurrencyUnitMismatchException();
    }

    builder.setCommand(feeRequest.getCommandName(), feeRequest.getPhase(), feeRequest.getSubphase())
            .setCurrencyIfSupported(registry.getCurrency()).setPeriod(feeRequest.getPeriod())
            .setClass(pricingLogic.getFeeClass(domainNameString, now).orNull());

    ImmutableList<Fee> fees = ImmutableList.of();
    switch (feeRequest.getCommandName()) {
    case CREATE:
        if (isReserved(domain, isSunrise)) { // Don't return a create price for reserved names.
            builder.setClass("reserved"); // Override whatever class we've set above.
            builder.setAvailIfSupported(false);
            builder.setReasonIfSupported("reserved");
        } else {
            builder.setAvailIfSupported(true);
            fees = pricingLogic.getCreatePrice(registry, domainNameString, now, years).getFees();
        }
        break;
    case RENEW:
        builder.setAvailIfSupported(true);
        fees = pricingLogic.getRenewPrice(registry, domainNameString, now, years).getFees();
        break;
    case RESTORE:
        if (years != 1) {
            throw new RestoresAreAlwaysForOneYearException();
        }
        builder.setAvailIfSupported(true);
        fees = pricingLogic.getRestorePrice(registry, domainNameString, now).getFees();
        break;
    case TRANSFER:
        builder.setAvailIfSupported(true);
        fees = pricingLogic.getTransferPrice(registry, domainNameString, now, years).getFees();
        break;
    case UPDATE:
        builder.setAvailIfSupported(true);
        fees = pricingLogic.getUpdatePrice(registry, domainNameString, now).getFees();
        break;
    default:
        throw new UnknownFeeCommandException(feeRequest.getUnparsedCommandName());
    }

    // Set the fees, and based on the validDateRange of the fees, set the notAfterDate.
    if (!fees.isEmpty()) {
        builder.setFees(fees);
        DateTime notAfterDate = null;
        for (Fee fee : fees) {
            if (fee.hasValidDateRange()) {
                DateTime endDate = fee.getValidDateRange().upperEndpoint();
                if (notAfterDate == null || notAfterDate.isAfter(endDate)) {
                    notAfterDate = endDate;
                }
            }
        }
        if (notAfterDate != null && !notAfterDate.equals(END_OF_TIME)) {
            builder.setNotAfterDateIfSupported(notAfterDate);
        }
    }
}

From source file:com.google.javascript.rhino.jstype.JSTypeRegistry.java

/**
 * Creates a template type map from the specified list of template keys and
 * template value types.// w  w  w. ja va 2 s  .c o m
 */
public TemplateTypeMap createTemplateTypeMap(ImmutableList<TemplateType> templateKeys,
        ImmutableList<JSType> templateValues) {
    templateKeys = templateKeys == null ? ImmutableList.<TemplateType>of() : templateKeys;
    templateValues = templateValues == null ? ImmutableList.<JSType>of() : templateValues;

    return (templateKeys.isEmpty() && templateValues.isEmpty()) ? emptyTemplateTypeMap
            : new TemplateTypeMap(this, templateKeys, templateValues);
}

From source file:com.facebook.presto.sql.analyzer.StatementAnalyzer.java

private void analyzeAggregations(QuerySpecification node, RelationType tupleDescriptor,
        List<List<FieldOrExpression>> groupingSets, List<FieldOrExpression> outputExpressions,
        List<FieldOrExpression> orderByExpressions, AnalysisContext context, Set<Expression> columnReferences) {
    List<FunctionCall> aggregates = extractAggregates(node);

    if (context.isApproximate()) {
        if (aggregates.stream().anyMatch(FunctionCall::isDistinct)) {
            throw new SemanticException(NOT_SUPPORTED, node,
                    "DISTINCT aggregations not supported for approximate queries");
        }/*from   w ww.  j  a  v  a 2  s  . co m*/
    }

    ImmutableList<FieldOrExpression> allGroupingColumns = groupingSets.stream().flatMap(Collection::stream)
            .distinct().collect(toImmutableList());

    // is this an aggregation query?
    if (!aggregates.isEmpty() || !allGroupingColumns.isEmpty()) {
        // ensure SELECT, ORDER BY and HAVING are constant with respect to group
        // e.g, these are all valid expressions:
        //     SELECT f(a) GROUP BY a
        //     SELECT f(a + 1) GROUP BY a + 1
        //     SELECT a + sum(b) GROUP BY a

        for (FieldOrExpression fieldOrExpression : Iterables.concat(outputExpressions, orderByExpressions)) {
            verifyAggregations(node, allGroupingColumns, tupleDescriptor, fieldOrExpression, columnReferences);
        }

        if (node.getHaving().isPresent()) {
            verifyAggregations(node, allGroupingColumns, tupleDescriptor,
                    new FieldOrExpression(node.getHaving().get()), columnReferences);
        }
    }
}

From source file:com.google.auto.value.processor.AutoValueProcessor.java

private void processType(TypeElement type) {
    AutoValue autoValue = type.getAnnotation(AutoValue.class);
    if (autoValue == null) {
        // This shouldn't happen unless the compilation environment is buggy,
        // but it has happened in the past and can crash the compiler.
        errorReporter.abortWithError("annotation processor for @AutoValue was invoked with a type"
                + " that does not have that annotation; this is probably a compiler bug", type);
    }/*  w w  w.  ja va 2s. c  o  m*/
    if (type.getKind() != ElementKind.CLASS) {
        errorReporter.abortWithError("@" + AutoValue.class.getName() + " only applies to classes", type);
    }
    if (ancestorIsAutoValue(type)) {
        errorReporter.abortWithError("One @AutoValue class may not extend another", type);
    }
    if (implementsAnnotation(type)) {
        errorReporter.abortWithError("@AutoValue may not be used to implement an annotation"
                + " interface; try using @AutoAnnotation instead", type);
    }
    checkModifiersIfNested(type);

    // We are going to classify the methods of the @AutoValue class into several categories.
    // This covers the methods in the class itself and the ones it inherits from supertypes.
    // First, the only concrete (non-abstract) methods we are interested in are overrides of
    // Object methods (equals, hashCode, toString), which signal that we should not generate
    // an implementation of those methods.
    // Then, each abstract method is one of the following:
    // (1) A property getter, like "abstract String foo()" or "abstract String getFoo()".
    // (2) A toBuilder() method, which is any abstract no-arg method returning the Builder for
    //     this @AutoValue class.
    // (3) An abstract method that will be consumed by an extension, such as
    //     Parcelable.describeContents() or Parcelable.writeToParcel(Parcel, int).
    // The describeContents() example shows a quirk here: initially we will identify it as a
    // property, which means that we need to reconstruct the list of properties after allowing
    // extensions to consume abstract methods.
    // If there are abstract methods that don't fit any of the categories above, that is an error
    // which we signal explicitly to avoid confusion.

    ImmutableSet<ExecutableElement> methods = getLocalAndInheritedMethods(type, processingEnv.getTypeUtils(),
            processingEnv.getElementUtils());
    ImmutableSet<ExecutableElement> abstractMethods = abstractMethodsIn(methods);

    BuilderSpec builderSpec = new BuilderSpec(type, processingEnv, errorReporter);
    Optional<BuilderSpec.Builder> builder = builderSpec.getBuilder();
    ImmutableSet<ExecutableElement> toBuilderMethods;
    if (builder.isPresent()) {
        toBuilderMethods = builder.get().toBuilderMethods(typeUtils, abstractMethods);
    } else {
        toBuilderMethods = ImmutableSet.of();
    }

    ImmutableSet<ExecutableElement> propertyMethods = propertyMethodsIn(
            immutableSetDifference(abstractMethods, toBuilderMethods));
    ImmutableBiMap<String, ExecutableElement> properties = propertyNameToMethodMap(propertyMethods);

    ExtensionContext context = new ExtensionContext(processingEnv, type, properties, abstractMethods);
    ImmutableList<AutoValueExtension> applicableExtensions = applicableExtensions(type, context);
    ImmutableSet<ExecutableElement> consumedMethods = methodsConsumedByExtensions(type, applicableExtensions,
            context, abstractMethods, properties);

    if (!consumedMethods.isEmpty()) {
        ImmutableSet<ExecutableElement> allAbstractMethods = abstractMethods;
        abstractMethods = immutableSetDifference(abstractMethods, consumedMethods);
        toBuilderMethods = immutableSetDifference(toBuilderMethods, consumedMethods);
        propertyMethods = propertyMethodsIn(immutableSetDifference(abstractMethods, toBuilderMethods));
        properties = propertyNameToMethodMap(propertyMethods);
        context = new ExtensionContext(processingEnv, type, properties, allAbstractMethods);
    }

    boolean extensionsPresent = !applicableExtensions.isEmpty();
    validateMethods(type, abstractMethods, toBuilderMethods, propertyMethods, extensionsPresent);

    String finalSubclass = generatedSubclassName(type, 0);
    AutoValueTemplateVars vars = new AutoValueTemplateVars();
    vars.pkg = TypeSimplifier.packageNameOf(type);
    vars.origClass = TypeSimplifier.classNameOf(type);
    vars.simpleClassName = TypeSimplifier.simpleNameOf(vars.origClass);
    vars.finalSubclass = TypeSimplifier.simpleNameOf(finalSubclass);
    vars.types = processingEnv.getTypeUtils();
    determineObjectMethodsToGenerate(methods, vars);
    TypeSimplifier typeSimplifier = defineVarsForType(type, vars, toBuilderMethods, propertyMethods, builder);

    // Only copy annotations from a class if it has @AutoValue.CopyAnnotations.
    if (isAnnotationPresent(type, AutoValue.CopyAnnotations.class)) {
        Set<String> excludedAnnotations = union(getFieldOfClasses(type, AutoValue.CopyAnnotations.class,
                "exclude", processingEnv.getElementUtils()), getAnnotationsMarkedWithInherited(type));

        vars.annotations = copyAnnotations(type, typeSimplifier, excludedAnnotations);
    } else {
        vars.annotations = ImmutableList.of();
    }

    GwtCompatibility gwtCompatibility = new GwtCompatibility(type);
    vars.gwtCompatibleAnnotation = gwtCompatibility.gwtCompatibleAnnotationString();

    int subclassDepth = writeExtensions(type, context, applicableExtensions);
    String subclass = generatedSubclassName(type, subclassDepth);
    vars.subclass = TypeSimplifier.simpleNameOf(subclass);
    vars.isFinal = (subclassDepth == 0);

    String text = vars.toText();
    text = Reformatter.fixup(text);
    writeSourceFile(subclass, text, type);
    GwtSerialization gwtSerialization = new GwtSerialization(gwtCompatibility, processingEnv, type);
    gwtSerialization.maybeWriteGwtSerializer(vars);
}

From source file:com.spectralogic.ds3cli.command.PutBulk.java

private PutBulkResult transfer(final Ds3ClientHelpers helpers, final Iterable<Ds3Object> ds3Objects,
        final ImmutableList<FileUtils.IgnoreFile> ds3IgnoredObjects)
        throws IOException, XmlProcessingException {
    final WriteJobOptions writeJobOptions = WriteJobOptions.create().withPriority(this.priority)
            .withWriteOptimization(this.writeOptimization)
            .withIgnoreNamingConflicts(this.ignoreNamingConflicts);
    writeJobOptions.setForce(force);//from   w w  w .  j  a  va2s . co  m
    final Ds3ClientHelpers.Job job = helpers.startWriteJob(this.bucketName, ds3Objects, writeJobOptions);
    job.withMaxParallelRequests(this.numberOfThreads);

    // write parameters to file to allow recovery
    createRecoveryCommand(job.getJobId());

    if (this.checksum) {
        throw new RuntimeException("Checksum calculation is not currently supported."); //TODO
        //            Logging.log("Performing bulk put with checksum computation enabled");
        //            job.withRequestModifier(new ComputedChecksumModifier());
    }
    LOG.info("Created bulk put job {}, starting transfer", job.getJobId().toString());

    String resultMessage;
    if (this.pipe) {

        final PipeFileObjectPutter pipeFileObjectPutter = new PipeFileObjectPutter(
                this.mapNormalizedObjectNameToObjectName);
        job.withMetadata(pipeFileObjectPutter).transfer(pipeFileObjectPutter);
        resultMessage = String.format("SUCCESS: Wrote all piped files to bucket %s", this.bucketName);
    } else {
        final PrefixedFileObjectPutter prefixedFileObjectPutter = new PrefixedFileObjectPutter(
                this.inputDirectory, this.prefix);
        job.withMetadata(prefixedFileObjectPutter).transfer(prefixedFileObjectPutter);
        resultMessage = String.format("SUCCESS: Wrote all the files in %s to bucket %s",
                this.inputDirectory.toString(), this.bucketName);
    }

    if (this.ignoreErrors && !ds3IgnoredObjects.isEmpty()) {
        resultMessage = String.format("WARN: Not all of the files were written to bucket %s", this.bucketName);
    } else {
        RecoveryFileManager.deleteRecoveryCommand(job.getJobId());
    }

    return new PutBulkResult(resultMessage, ds3IgnoredObjects);
}

From source file:com.facebook.buck.json.PythonDslProjectBuildFileParser.java

@VisibleForTesting
protected BuildFileManifest getAllRulesInternal(Path buildFile, AtomicLong processedBytes)
        throws IOException, BuildFileParseException {
    ensureNotClosed();// www .  java  2  s  . com
    initIfNeeded();

    // Check isInitialized implications (to avoid Eradicate warnings).
    Preconditions.checkNotNull(buckPyProcess);
    Preconditions.checkNotNull(buckPyProcessInput);
    long alreadyReadBytes = buckPyProcessInput.getCount();

    ParseBuckFileEvent.Started parseBuckFileStarted = ParseBuckFileEvent.started(buildFile);
    buckEventBus.post(parseBuckFileStarted);

    ImmutableList<Map<String, Object>> values = ImmutableList.of();
    Optional<String> profile = Optional.empty();
    try (AssertScopeExclusiveAccess.Scope scope = assertSingleThreadedParsing.scope()) {
        Path cellPath = options.getProjectRoot().toAbsolutePath();
        String watchRoot = cellPath.toString();
        String projectPrefix = "";
        if (options.getWatchman().getProjectWatches().containsKey(cellPath)) {
            ProjectWatch projectWatch = options.getWatchman().getProjectWatches().get(cellPath);
            watchRoot = projectWatch.getWatchRoot();
            if (projectWatch.getProjectPrefix().isPresent()) {
                projectPrefix = projectWatch.getProjectPrefix().get();
            }
        }
        currentBuildFile.set(buildFile);
        BuildFilePythonResult resultObject = performJsonRequest(ImmutableMap.of("buildFile",
                buildFile.toString(), "watchRoot", watchRoot, "projectPrefix", projectPrefix));
        Path buckPyPath = getPathToBuckPy(options.getDescriptions());
        handleDiagnostics(buildFile, buckPyPath.getParent(), resultObject.getDiagnostics(), buckEventBus);
        values = resultObject.getValues();

        LOG.verbose("Got rules: %s", values);
        LOG.verbose("Parsed %d rules from %s", values.size(), buildFile);
        profile = resultObject.getProfile();
        if (profile.isPresent()) {
            LOG.debug("Profile result:\n%s", profile.get());
        }
        if (values.isEmpty()) {
            // in case Python process cannot send values due to serialization issues, it will send an
            // empty list
            return BuildFileManifest.builder().setTargets(ImmutableList.of())
                    .setIncludes(ImmutableSortedSet.of()).setConfigs(ImmutableMap.of()).build();
        }
        return toBuildFileManifest(values);
    } finally {
        long parsedBytes = buckPyProcessInput.getCount() - alreadyReadBytes;
        processedBytes.addAndGet(parsedBytes);
        buckEventBus.post(ParseBuckFileEvent.finished(parseBuckFileStarted, values, parsedBytes, profile));
    }
}