List of usage examples for com.google.common.collect ImmutableSet isEmpty
boolean isEmpty();
From source file:com.google.javascript.jscomp.newtypes.JSTypeCreatorFromJSDoc.java
private DeclaredFunctionType getFunTypeFromTypicalFunctionJsdoc(JSDocInfo jsdoc, String functionName, Node funNode, RawNominalType constructorType, RawNominalType ownerType, DeclaredTypeRegistry registry, FunctionTypeBuilder builder, boolean ignoreJsdoc /* for when the jsdoc is malformed */) { Preconditions.checkArgument(!ignoreJsdoc || jsdoc == null); Preconditions.checkArgument(!ignoreJsdoc || funNode.isFunction()); ImmutableList<String> typeParameters = ImmutableList.of(); Node parent = funNode.getParent(); // TODO(dimvar): need more @template warnings // - warn for multiple @template annotations // - warn for @template annotation w/out usage if (jsdoc != null) { typeParameters = jsdoc.getTemplateTypeNames(); if (!typeParameters.isEmpty()) { if (parent.isSetterDef() || parent.isGetterDef()) { ignoreJsdoc = true;//from www . j a v a2s. c o m jsdoc = null; warn("@template can't be used with getters/setters", funNode); } else { builder.addTypeParameters(typeParameters); } } } if (ownerType != null) { ImmutableList.Builder<String> paramsBuilder = new ImmutableList.Builder<>(); paramsBuilder.addAll(typeParameters); paramsBuilder.addAll(ownerType.getTypeParameters()); typeParameters = paramsBuilder.build(); } fillInFormalParameterTypes(jsdoc, funNode, typeParameters, registry, builder, ignoreJsdoc); fillInReturnType(jsdoc, funNode, parent, typeParameters, registry, builder, ignoreJsdoc); if (jsdoc == null) { return builder.buildDeclaration(); } // Look at other annotations, eg, @constructor NominalType parentClass = getMaybeParentClass(jsdoc, functionName, funNode, typeParameters, registry); ImmutableSet<NominalType> implementedIntfs = getImplementedInterfaces(jsdoc, registry, typeParameters); if (constructorType == null && (jsdoc.isConstructor() || jsdoc.isInterface())) { // Anonymous type, don't register it. return builder.buildDeclaration(); } else if (jsdoc.isConstructor()) { handleConstructorAnnotation(functionName, funNode, constructorType, parentClass, implementedIntfs, registry, builder); } else if (jsdoc.isInterface()) { handleInterfaceAnnotation(jsdoc, functionName, funNode, constructorType, implementedIntfs, typeParameters, registry, builder); } else if (!implementedIntfs.isEmpty()) { warnings.add(JSError.make(funNode, IMPLEMENTS_WITHOUT_CONSTRUCTOR, functionName)); } if (jsdoc.hasThisType() && ownerType == null) { Node thisRoot = jsdoc.getThisType().getRoot(); Preconditions.checkState(thisRoot.getType() == Token.BANG); Node thisNode = thisRoot.getFirstChild(); // JsDocInfoParser wraps @this types with !. But we warn when we see !T, // and we don't want to warn for a ! that was automatically inserted. // So, we bypass the ! here. JSType thisType = getMaybeTypeFromComment(thisNode, registry, typeParameters); if (thisType != null) { thisType = thisType.removeType(JSType.NULL); } // TODO(dimvar): thisType may be non-null but have a null // thisTypeAsNominal. // We currently only support nominal types for the receiver type, but // people use other types as well: unions, records, etc. // For now, we just use the generic Object for these. NominalType nt = thisType == null ? null : thisType.getNominalTypeIfSingletonObj(); NominalType builtinObject = registry.getCommonTypes().getObjectType(); builder.addReceiverType(nt == null ? builtinObject : nt); } return builder.buildDeclaration(); }
From source file:com.google.api.codegen.config.GapicMethodConfig.java
/** * Creates an instance of GapicMethodConfig based on MethodConfigProto, linking it up with the * provided method. On errors, null will be returned, and diagnostics are reported to the diag * collector.//from w ww .j a va2 s.com */ @Nullable static GapicMethodConfig createMethodConfig(DiagCollector diagCollector, TargetLanguage language, MethodConfigProto methodConfigProto, Method method, ResourceNameMessageConfigs messageConfigs, ImmutableMap<String, ResourceNameConfig> resourceNameConfigs, ImmutableSet<String> retryCodesConfigNames, ImmutableSet<String> retryParamsConfigNames) { boolean error = false; ProtoMethodModel methodModel = new ProtoMethodModel(method); PageStreamingConfig pageStreaming = null; if (!PageStreamingConfigProto.getDefaultInstance().equals(methodConfigProto.getPageStreaming())) { pageStreaming = PageStreamingConfig.createPageStreaming(diagCollector, messageConfigs, resourceNameConfigs, methodConfigProto, methodModel); if (pageStreaming == null) { error = true; } } GrpcStreamingConfig grpcStreaming = null; if (isGrpcStreamingMethod(methodModel)) { if (PageStreamingConfigProto.getDefaultInstance().equals(methodConfigProto.getGrpcStreaming())) { grpcStreaming = GrpcStreamingConfig.createGrpcStreaming(diagCollector, method); } else { grpcStreaming = GrpcStreamingConfig.createGrpcStreaming(diagCollector, methodConfigProto.getGrpcStreaming(), method); if (grpcStreaming == null) { error = true; } } } ImmutableList<FlatteningConfig> flattening = null; if (!FlatteningConfigProto.getDefaultInstance().equals(methodConfigProto.getFlattening())) { flattening = createFlattening(diagCollector, messageConfigs, resourceNameConfigs, methodConfigProto, methodModel); if (flattening == null) { error = true; } } BatchingConfig batching = null; if (!BatchingConfigProto.getDefaultInstance().equals(methodConfigProto.getBatching())) { batching = BatchingConfig.createBatching(diagCollector, methodConfigProto.getBatching(), methodModel); if (batching == null) { error = true; } } String retryCodesName = methodConfigProto.getRetryCodesName(); if (!retryCodesName.isEmpty() && !retryCodesConfigNames.contains(retryCodesName)) { diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "Retry codes config used but not defined: '%s' (in method %s)", retryCodesName, methodModel.getFullName())); error = true; } String retryParamsName = methodConfigProto.getRetryParamsName(); if (!retryParamsConfigNames.isEmpty() && !retryParamsConfigNames.contains(retryParamsName)) { diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "Retry parameters config used but not defined: %s (in method %s)", retryParamsName, methodModel.getFullName())); error = true; } Duration timeout = Duration.ofMillis(methodConfigProto.getTimeoutMillis()); if (timeout.toMillis() <= 0) { diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "Default timeout not found or has invalid value (in method %s)", methodModel.getFullName())); error = true; } boolean hasRequestObjectMethod = methodConfigProto.getRequestObjectMethod(); if (hasRequestObjectMethod && method.getRequestStreaming()) { diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "request_object_method incompatible with streaming method %s", method.getFullName())); error = true; } ImmutableMap<String, String> fieldNamePatterns = ImmutableMap .copyOf(methodConfigProto.getFieldNamePatterns()); ResourceNameTreatment defaultResourceNameTreatment = methodConfigProto.getResourceNameTreatment(); if (defaultResourceNameTreatment == null || defaultResourceNameTreatment.equals(ResourceNameTreatment.UNSET_TREATMENT)) { defaultResourceNameTreatment = ResourceNameTreatment.NONE; } Iterable<FieldConfig> requiredFieldConfigs = createFieldNameConfigs(diagCollector, messageConfigs, defaultResourceNameTreatment, fieldNamePatterns, resourceNameConfigs, getRequiredFields(diagCollector, methodModel, methodConfigProto.getRequiredFieldsList())); Iterable<FieldConfig> optionalFieldConfigs = createFieldNameConfigs(diagCollector, messageConfigs, defaultResourceNameTreatment, fieldNamePatterns, resourceNameConfigs, getOptionalFields(methodModel, methodConfigProto.getRequiredFieldsList())); List<String> sampleCodeInitFields = new ArrayList<>(); sampleCodeInitFields.addAll(methodConfigProto.getSampleCodeInitFieldsList()); SampleSpec sampleSpec = new SampleSpec(methodConfigProto); String rerouteToGrpcInterface = Strings.emptyToNull(methodConfigProto.getRerouteToGrpcInterface()); VisibilityConfig visibility = VisibilityConfig.PUBLIC; ReleaseLevel releaseLevel = ReleaseLevel.GA; for (SurfaceTreatmentProto treatment : methodConfigProto.getSurfaceTreatmentsList()) { if (!treatment.getIncludeLanguagesList().contains(language.toString().toLowerCase())) { continue; } if (treatment.getVisibility() != VisibilityProto.UNSET_VISIBILITY) { visibility = VisibilityConfig.fromProto(treatment.getVisibility()); } if (treatment.getReleaseLevel() != ReleaseLevel.UNSET_RELEASE_LEVEL) { releaseLevel = treatment.getReleaseLevel(); } } LongRunningConfig longRunningConfig = null; if (!LongRunningConfigProto.getDefaultInstance().equals(methodConfigProto.getLongRunning())) { longRunningConfig = LongRunningConfig.createLongRunningConfig(method.getModel(), diagCollector, methodConfigProto.getLongRunning()); if (longRunningConfig == null) { error = true; } } List<String> headerRequestParams = ImmutableList.copyOf(methodConfigProto.getHeaderRequestParamsList()); if (error) { return null; } else { return new AutoValue_GapicMethodConfig(methodModel, pageStreaming, grpcStreaming, flattening, retryCodesName, retryParamsName, timeout, requiredFieldConfigs, optionalFieldConfigs, defaultResourceNameTreatment, batching, hasRequestObjectMethod, fieldNamePatterns, sampleCodeInitFields, sampleSpec, rerouteToGrpcInterface, visibility, releaseLevel, longRunningConfig, headerRequestParams); } }
From source file:org.elasticsearch.search.facet.terms.ints.TermsIntFacetCollector.java
public TermsIntFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded, String scriptLang, String script, Map<String, Object> params) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms int facet collector on it"); }//from w ww. j a va 2s . c o m // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.INT) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] is not of int type, can't run terms int facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (script != null) { this.script = context.scriptService().search(context.lookup(), scriptLang, script, params); } else { this.script = null; } if (this.script == null && excluded.isEmpty()) { aggregator = new StaticAggregatorValueProc(CacheRecycler.popIntIntMap()); } else { aggregator = new AggregatorValueProc(CacheRecycler.popIntIntMap(), excluded, this.script); } if (allTerms) { try { for (AtomicReaderContext readerContext : context.searcher().getTopReaderContext().leaves()) { IntFieldData fieldData = (IntFieldData) fieldDataCache.cache(fieldDataType, readerContext.reader(), indexFieldName); fieldData.forEachValue(aggregator); } } catch (Exception e) { throw new FacetPhaseExecutionException(facetName, "failed to load all terms", e); } } }
From source file:com.google.javascript.jscomp.newtypes.JSType.java
/** * Both {@code meet} and {@code specialize} do the same computation for enums. * They don't just compute the set of enums; they may modify mask and objs. * So, both methods finish off by calling this one. */// w w w .j a va 2 s .c o m private static JSType meetEnums(int newMask, int unionMask, ImmutableSet<ObjectType> newObjs, String newTypevar, ImmutableSet<ObjectType> objs1, ImmutableSet<ObjectType> objs2, ImmutableSet<EnumType> enums1, ImmutableSet<EnumType> enums2) { if (Objects.equals(enums1, enums2)) { return makeType(newMask, newObjs, newTypevar, enums1); } ImmutableSet.Builder<EnumType> enumBuilder = ImmutableSet.builder(); ImmutableSet<EnumType> allEnums = EnumType.union(enums1, enums2); for (EnumType e : allEnums) { // An enum in the intersection will always be in the result if (enums1 != null && enums1.contains(e) && enums2 != null && enums2.contains(e)) { enumBuilder.add(e); continue; } // An enum {?} in the union will always be in the result JSType enumeratedType = e.getEnumeratedType(); if (enumeratedType.isUnknown()) { enumBuilder.add(e); continue; } // An enum {TypeA} meets with any supertype of TypeA. When this happens, // we put the enum in the result and remove the supertype. // The following would be much more complex if we allowed the type of // an enum to be a union. if (enumeratedType.getMask() != NON_SCALAR_MASK) { if ((enumeratedType.getMask() & unionMask) != 0) { enumBuilder.add(e); newMask &= ~enumeratedType.getMask(); } } else if (!objs1.isEmpty() || !objs2.isEmpty()) { Set<ObjectType> objsToRemove = new LinkedHashSet<>(); ObjectType enumObj = Iterables.getOnlyElement(enumeratedType.getObjs()); for (ObjectType obj1 : objs1) { if (enumObj.isSubtypeOf(obj1)) { enumBuilder.add(e); objsToRemove.add(obj1); } } for (ObjectType obj2 : objs2) { if (enumObj.isSubtypeOf(obj2)) { enumBuilder.add(e); objsToRemove.add(obj2); } } if (!objsToRemove.isEmpty()) { newObjs = Sets.difference(newObjs, objsToRemove).immutableCopy(); } } } return makeType(newMask, newObjs, newTypevar, enumBuilder.build()); }
From source file:org.elasticsearch.search.facet.terms.bytes.TermsByteFacetCollector.java
public TermsByteFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded, String scriptLang, String script, Map<String, Object> params) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms short facet collector on it"); }// w w w. ja v a 2 s . co m // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.BYTE) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] is not of byte type, can't run terms short facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (script != null) { this.script = context.scriptService().search(context.lookup(), scriptLang, script, params); } else { this.script = null; } if (this.script == null && excluded.isEmpty()) { aggregator = new StaticAggregatorValueProc(CacheRecycler.popByteIntMap()); } else { aggregator = new AggregatorValueProc(CacheRecycler.popByteIntMap(), excluded, this.script); } if (allTerms) { try { for (AtomicReaderContext readerContext : context.searcher().getTopReaderContext().leaves()) { ByteFieldData fieldData = (ByteFieldData) fieldDataCache.cache(fieldDataType, readerContext.reader(), indexFieldName); fieldData.forEachValue(aggregator); } } catch (Exception e) { throw new FacetPhaseExecutionException(facetName, "failed to load all terms", e); } } }
From source file:org.elasticsearch.search.facet.terms.shorts.TermsShortFacetCollector.java
public TermsShortFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded, String scriptLang, String script, Map<String, Object> params) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms short facet collector on it"); }//ww w . j a va2 s .c o m // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.SHORT) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] is not of short type, can't run terms short facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (script != null) { this.script = context.scriptService().search(context.lookup(), scriptLang, script, params); } else { this.script = null; } if (this.script == null && excluded.isEmpty()) { aggregator = new StaticAggregatorValueProc(CacheRecycler.popShortIntMap()); } else { aggregator = new AggregatorValueProc(CacheRecycler.popShortIntMap(), excluded, this.script); } if (allTerms) { try { for (AtomicReaderContext readerContext : context.searcher().getTopReaderContext().leaves()) { ShortFieldData fieldData = (ShortFieldData) fieldDataCache.cache(fieldDataType, readerContext.reader(), indexFieldName); fieldData.forEachValue(aggregator); } } catch (Exception e) { throw new FacetPhaseExecutionException(facetName, "failed to load all terms", e); } } }
From source file:org.elasticsearch.search.facet.terms.longs.TermsLongFacetCollector.java
public TermsLongFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded, String scriptLang, String script, Map<String, Object> params) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms long facet collector on it"); }/*from ww w . jav a 2s . c om*/ // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.LONG) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] is not of long type, can't run terms long facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (script != null) { this.script = context.scriptService().search(context.lookup(), scriptLang, script, params); } else { this.script = null; } if (this.script == null && excluded.isEmpty()) { aggregator = new StaticAggregatorValueProc(CacheRecycler.popLongIntMap()); } else { aggregator = new AggregatorValueProc(CacheRecycler.popLongIntMap(), excluded, this.script); } if (allTerms) { try { for (AtomicReaderContext readerContext : context.searcher().getTopReaderContext().leaves()) { LongFieldData fieldData = (LongFieldData) fieldDataCache.cache(fieldDataType, readerContext.reader(), indexFieldName); fieldData.forEachValue(aggregator); } } catch (Exception e) { throw new FacetPhaseExecutionException(facetName, "failed to load all terms", e); } } }
From source file:org.elasticsearch.search.facet.terms.doubles.TermsDoubleFacetCollector.java
public TermsDoubleFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded, String scriptLang, String script, Map<String, Object> params) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms double facet collector on it"); }//from w w w .ja va 2s .c o m // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.DOUBLE) { throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] is not of double type, can't run terms double facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (script != null) { this.script = context.scriptService().search(context.lookup(), scriptLang, script, params); } else { this.script = null; } if (this.script == null && excluded.isEmpty()) { aggregator = new StaticAggregatorValueProc(CacheRecycler.popDoubleIntMap()); } else { aggregator = new AggregatorValueProc(CacheRecycler.popDoubleIntMap(), excluded, this.script); } if (allTerms) { try { for (AtomicReaderContext readerContext : context.searcher().getTopReaderContext().leaves()) { DoubleFieldData fieldData = (DoubleFieldData) fieldDataCache.cache(fieldDataType, readerContext.reader(), indexFieldName); fieldData.forEachValue(aggregator); } } catch (Exception e) { throw new FacetPhaseExecutionException(facetName, "failed to load all terms", e); } } }
From source file:org.elasticsearch.search.facet.terms.floats.TermsFloatFacetCollector.java
public TermsFloatFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded, String scriptLang, String script, Map<String, Object> params) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms float facet collector on it"); }/*from w w w . j a v a 2s. c o m*/ // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.FLOAT) { throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] doesn't is not of float type, can't run terms float facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (script != null) { this.script = context.scriptService().search(context.lookup(), scriptLang, script, params); } else { this.script = null; } if (this.script == null && excluded.isEmpty()) { aggregator = new StaticAggregatorValueProc(CacheRecycler.popFloatIntMap()); } else { aggregator = new AggregatorValueProc(CacheRecycler.popFloatIntMap(), excluded, this.script); } if (allTerms) { try { for (AtomicReaderContext readerContext : context.searcher().getTopReaderContext().leaves()) { FloatFieldData fieldData = (FloatFieldData) fieldDataCache.cache(fieldDataType, readerContext.reader(), indexFieldName); fieldData.forEachValue(aggregator); } } catch (Exception e) { throw new FacetPhaseExecutionException(facetName, "failed to load all terms", e); } } }
From source file:com.facebook.buck.features.apple.project.XCodeProjectCommandHelper.java
public ExitCode parseTargetsAndRunXCodeGenerator() throws IOException, InterruptedException { ImmutableSet<BuildTarget> passedInTargetsSet; TargetGraph projectGraph;/*from w w w . j a v a 2 s .co m*/ LOG.debug("Xcode project generation: Getting the target graph"); try { passedInTargetsSet = ImmutableSet.copyOf(Iterables.concat( parser.resolveTargetSpecs(parsingContext, argsParser.apply(arguments), targetConfiguration))); projectGraph = getProjectGraphForIde(passedInTargetsSet); } catch (BuildFileParseException e) { buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e))); return ExitCode.PARSE_ERROR; } catch (HumanReadableException e) { buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e))); return ExitCode.BUILD_ERROR; } LOG.debug("Xcode project generation: Killing existing Xcode if needed"); checkForAndKillXcodeIfRunning(getIDEForceKill(buckConfig)); LOG.debug("Xcode project generation: Computing graph roots"); ImmutableSet<BuildTarget> graphRoots; if (passedInTargetsSet.isEmpty()) { graphRoots = getRootsFromPredicate(projectGraph, node -> node.getDescription() instanceof XcodeWorkspaceConfigDescription); } else { graphRoots = passedInTargetsSet; } LOG.debug("Xcode project generation: Getting more part of the target graph"); TargetGraphAndTargets targetGraphAndTargets; try { targetGraphAndTargets = createTargetGraph(projectGraph, graphRoots, isWithTests(buckConfig), isWithDependenciesTests(buckConfig), passedInTargetsSet.isEmpty()); } catch (BuildFileParseException | NoSuchTargetException | VersionException e) { buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e))); return ExitCode.PARSE_ERROR; } catch (HumanReadableException e) { buckEventBus.post(ConsoleEvent.severe(MoreExceptions.getHumanReadableOrLocalizedMessage(e))); return ExitCode.BUILD_ERROR; } Optional<ImmutableMap<BuildTarget, TargetNode<?>>> sharedLibraryToBundle = Optional.empty(); if (sharedLibrariesInBundles) { sharedLibraryToBundle = Optional.of(ProjectGenerator.computeSharedLibrariesToBundles( targetGraphAndTargets.getTargetGraph().getNodes(), targetGraphAndTargets)); } if (dryRun) { for (TargetNode<?> targetNode : targetGraphAndTargets.getTargetGraph().getNodes()) { console.getStdOut().println(targetNode.toString()); } return ExitCode.SUCCESS; } LOG.debug("Xcode project generation: Run the project generator"); return runXcodeProjectGenerator(targetGraphAndTargets, passedInTargetsSet, sharedLibraryToBundle); }