text:
package com.amazonaws.services.schemas;

import javax.annotation.Generated;

import com.amazonaws.services.schemas.model.*;

/**
 * Interface for accessing Schemas asynchronously. Each asynchronous method will return a Java Future object
 * representing the asynchronous operation; overloads which accept an {@code AsyncHandler} can be used to receive
 * notification when an asynchronous operation completes.
 *

 * Note: Do not directly implement this interface, new methods are added to it regularly. Extend from
 * {@link com.amazonaws.services.schemas.AbstractAWSSchemasAsync} instead.
 *

 *

 *

 * Amazon EventBridge Schema Registry
 *

 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public interface AWSSchemasAsync extends AWSSchemas {

    /**
     *

     * Creates a discoverer.
     *

     *
     * @param createDiscovererRequest
     * @return A Java Future containing the result of the CreateDiscoverer operation returned by the service.
     * @sample AWSSchemasAsync.CreateDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<CreateDiscovererResult> createDiscovererAsync(CreateDiscovererRequest createDiscovererRequest);

    /**
     *

     * Creates a discoverer.
     *

     *
     * @param createDiscovererRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the CreateDiscoverer operation returned by the service.
     * @sample AWSSchemasAsyncHandler.CreateDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<CreateDiscovererResult> createDiscovererAsync(CreateDiscovererRequest createDiscovererRequest,
            com.amazonaws.handlers.AsyncHandler<CreateDiscovererRequest, CreateDiscovererResult> asyncHandler);

    /**
     *

     * Creates a registry.
     *

     *
     * @param createRegistryRequest
     * @return A Java Future containing the result of the CreateRegistry operation returned by the service.
     * @sample AWSSchemasAsync.CreateRegistry
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<CreateRegistryResult> createRegistryAsync(CreateRegistryRequest createRegistryRequest);

    /**
     *

     * Creates a registry.
     *

     *
     * @param createRegistryRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the CreateRegistry operation returned by the service.
     * @sample AWSSchemasAsyncHandler.CreateRegistry
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<CreateRegistryResult> createRegistryAsync(CreateRegistryRequest createRegistryRequest,
            com.amazonaws.handlers.AsyncHandler<CreateRegistryRequest, CreateRegistryResult> asyncHandler);

    /**
     *

     * Creates a schema definition.
     *

     * <note>
     *

     * Inactive schemas will be deleted after two years.
     *

     * </note>
     *
     * @param createSchemaRequest
     * @return A Java Future containing the result of the CreateSchema operation returned by the service.
     * @sample AWSSchemasAsync.CreateSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<CreateSchemaResult> createSchemaAsync(CreateSchemaRequest createSchemaRequest);

    /**
     *

     * Creates a schema definition.
     *

     * <note>
     *

     * Inactive schemas will be deleted after two years.
     *

     * </note>
     *
     * @param createSchemaRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the CreateSchema operation returned by the service.
     * @sample AWSSchemasAsyncHandler.CreateSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<CreateSchemaResult> createSchemaAsync(CreateSchemaRequest createSchemaRequest,
            com.amazonaws.handlers.AsyncHandler<CreateSchemaRequest, CreateSchemaResult> asyncHandler);

    /**
     *

     * Deletes a discoverer.
     *

     *
     * @param deleteDiscovererRequest
     * @return A Java Future containing the result of the DeleteDiscoverer operation returned by the service.
     * @sample AWSSchemasAsync.DeleteDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DeleteDiscovererResult> deleteDiscovererAsync(DeleteDiscovererRequest deleteDiscovererRequest);

    /**
     *

     * Deletes a discoverer.
     *

     *
     * @param deleteDiscovererRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the DeleteDiscoverer operation returned by the service.
     * @sample AWSSchemasAsyncHandler.DeleteDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DeleteDiscovererResult> deleteDiscovererAsync(DeleteDiscovererRequest deleteDiscovererRequest,
            com.amazonaws.handlers.AsyncHandler<DeleteDiscovererRequest, DeleteDiscovererResult> asyncHandler);

    /**
     *

     * Deletes a Registry.
     *

     *
     * @param deleteRegistryRequest
     * @return A Java Future containing the result of the DeleteRegistry operation returned by the service.
     * @sample AWSSchemasAsync.DeleteRegistry
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DeleteRegistryResult> deleteRegistryAsync(DeleteRegistryRequest deleteRegistryRequest);

    /**
     *

     * Deletes a Registry.
     *

     *
     * @param deleteRegistryRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the DeleteRegistry operation returned by the service.
     * @sample AWSSchemasAsyncHandler.DeleteRegistry
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DeleteRegistryResult> deleteRegistryAsync(DeleteRegistryRequest deleteRegistryRequest,
            com.amazonaws.handlers.AsyncHandler<DeleteRegistryRequest, DeleteRegistryResult> asyncHandler);

    /**
     *

     * Delete the resource-based policy attached to the specified registry.
     *

     *
     * @param deleteResourcePolicyRequest
     * @return A Java Future containing the result of the DeleteResourcePolicy operation returned by the service.
     * @sample AWSSchemasAsync.DeleteResourcePolicy
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<DeleteResourcePolicyResult> deleteResourcePolicyAsync(DeleteResourcePolicyRequest deleteResourcePolicyRequest);

    /**
     *

     * Delete the resource-based policy attached to the specified registry.
     *

     *
     * @param deleteResourcePolicyRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the DeleteResourcePolicy operation returned by the service.
     * @sample AWSSchemasAsyncHandler.DeleteResourcePolicy
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<DeleteResourcePolicyResult> deleteResourcePolicyAsync(DeleteResourcePolicyRequest deleteResourcePolicyRequest,
            com.amazonaws.handlers.AsyncHandler<DeleteResourcePolicyRequest, DeleteResourcePolicyResult> asyncHandler);

    /**
     *

     * Delete a schema definition.
     *

     *
     * @param deleteSchemaRequest
     * @return A Java Future containing the result of the DeleteSchema operation returned by the service.
     * @sample AWSSchemasAsync.DeleteSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DeleteSchemaResult> deleteSchemaAsync(DeleteSchemaRequest deleteSchemaRequest);

    /**
     *

     * Delete a schema definition.
     *

     *
     * @param deleteSchemaRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the DeleteSchema operation returned by the service.
     * @sample AWSSchemasAsyncHandler.DeleteSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DeleteSchemaResult> deleteSchemaAsync(DeleteSchemaRequest deleteSchemaRequest,
            com.amazonaws.handlers.AsyncHandler<DeleteSchemaRequest, DeleteSchemaResult> asyncHandler);

    /**
     *

     * Delete the schema version definition
     *

     *
     * @param deleteSchemaVersionRequest
     * @return A Java Future containing the result of the DeleteSchemaVersion operation returned by the service.
     * @sample AWSSchemasAsync.DeleteSchemaVersion
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<DeleteSchemaVersionResult> deleteSchemaVersionAsync(DeleteSchemaVersionRequest deleteSchemaVersionRequest);

    /**
     *

     * Delete the schema version definition
     *

     *
     * @param deleteSchemaVersionRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the DeleteSchemaVersion operation returned by the service.
     * @sample AWSSchemasAsyncHandler.DeleteSchemaVersion
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<DeleteSchemaVersionResult> deleteSchemaVersionAsync(DeleteSchemaVersionRequest deleteSchemaVersionRequest,
            com.amazonaws.handlers.AsyncHandler<DeleteSchemaVersionRequest, DeleteSchemaVersionResult> asyncHandler);

    /**
     *

     * Describe the code binding URI.
     *

     *
     * @param describeCodeBindingRequest
     * @return A Java Future containing the result of the DescribeCodeBinding operation returned by the service.
     * @sample AWSSchemasAsync.DescribeCodeBinding
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<DescribeCodeBindingResult> describeCodeBindingAsync(DescribeCodeBindingRequest describeCodeBindingRequest);

    /**
     *

     * Describe the code binding URI.
     *

     *
     * @param describeCodeBindingRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the DescribeCodeBinding operation returned by the service.
     * @sample AWSSchemasAsyncHandler.DescribeCodeBinding
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<DescribeCodeBindingResult> describeCodeBindingAsync(DescribeCodeBindingRequest describeCodeBindingRequest,
            com.amazonaws.handlers.AsyncHandler<DescribeCodeBindingRequest, DescribeCodeBindingResult> asyncHandler);

    /**
     *

     * Describes the discoverer.
     *

     *
     * @param describeDiscovererRequest
     * @return A Java Future containing the result of the DescribeDiscoverer operation returned by the service.
     * @sample AWSSchemasAsync.DescribeDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DescribeDiscovererResult> describeDiscovererAsync(DescribeDiscovererRequest describeDiscovererRequest);

    /**
     *

     * Describes the discoverer.
     *

     *
     * @param describeDiscovererRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the DescribeDiscoverer operation returned by the service.
     * @sample AWSSchemasAsyncHandler.DescribeDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DescribeDiscovererResult> describeDiscovererAsync(DescribeDiscovererRequest describeDiscovererRequest,
            com.amazonaws.handlers.AsyncHandler<DescribeDiscovererRequest, DescribeDiscovererResult> asyncHandler);

    /**
     *

     * Describes the registry.
     *

     *
     * @param describeRegistryRequest
     * @return A Java Future containing the result of the DescribeRegistry operation returned by the service.
     * @sample AWSSchemasAsync.DescribeRegistry
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DescribeRegistryResult> describeRegistryAsync(DescribeRegistryRequest describeRegistryRequest);

    /**
     *

     * Describes the registry.
     *

     *
     * @param describeRegistryRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the DescribeRegistry operation returned by the service.
     * @sample AWSSchemasAsyncHandler.DescribeRegistry
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DescribeRegistryResult> describeRegistryAsync(DescribeRegistryRequest describeRegistryRequest,
            com.amazonaws.handlers.AsyncHandler<DescribeRegistryRequest, DescribeRegistryResult> asyncHandler);

    /**
     *

     * Retrieve the schema definition.
     *

     *
     * @param describeSchemaRequest
     * @return A Java Future containing the result of the DescribeSchema operation returned by the service.
     * @sample AWSSchemasAsync.DescribeSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DescribeSchemaResult> describeSchemaAsync(DescribeSchemaRequest describeSchemaRequest);

    /**
     *

     * Retrieve the schema definition.
     *

     *
     * @param describeSchemaRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the DescribeSchema operation returned by the service.
     * @sample AWSSchemasAsyncHandler.DescribeSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<DescribeSchemaResult> describeSchemaAsync(DescribeSchemaRequest describeSchemaRequest,
            com.amazonaws.handlers.AsyncHandler<DescribeSchemaRequest, DescribeSchemaResult> asyncHandler);

    /**
     * @param exportSchemaRequest
     * @return A Java Future containing the result of the ExportSchema operation returned by the service.
     * @sample AWSSchemasAsync.ExportSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ExportSchemaResult> exportSchemaAsync(ExportSchemaRequest exportSchemaRequest);

    /**
     * @param exportSchemaRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the ExportSchema operation returned by the service.
     * @sample AWSSchemasAsyncHandler.ExportSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ExportSchemaResult> exportSchemaAsync(ExportSchemaRequest exportSchemaRequest,
            com.amazonaws.handlers.AsyncHandler<ExportSchemaRequest, ExportSchemaResult> asyncHandler);

    /**
     *

     * Get the code binding source URI.
     *

     *
     * @param getCodeBindingSourceRequest
     * @return A Java Future containing the result of the GetCodeBindingSource operation returned by the service.
     * @sample AWSSchemasAsync.GetCodeBindingSource
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<GetCodeBindingSourceResult> getCodeBindingSourceAsync(GetCodeBindingSourceRequest getCodeBindingSourceRequest);

    /**
     *

     * Get the code binding source URI.
     *

     *
     * @param getCodeBindingSourceRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the GetCodeBindingSource operation returned by the service.
     * @sample AWSSchemasAsyncHandler.GetCodeBindingSource
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<GetCodeBindingSourceResult> getCodeBindingSourceAsync(GetCodeBindingSourceRequest getCodeBindingSourceRequest,
            com.amazonaws.handlers.AsyncHandler<GetCodeBindingSourceRequest, GetCodeBindingSourceResult> asyncHandler);

    /**
     *

     * Get the discovered schema that was generated based on sampled events.
     *

     *
     * @param getDiscoveredSchemaRequest
     * @return A Java Future containing the result of the GetDiscoveredSchema operation returned by the service.
     * @sample AWSSchemasAsync.GetDiscoveredSchema
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<GetDiscoveredSchemaResult> getDiscoveredSchemaAsync(GetDiscoveredSchemaRequest getDiscoveredSchemaRequest);

    /**
     *

     * Get the discovered schema that was generated based on sampled events.
     *

     *
     * @param getDiscoveredSchemaRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the GetDiscoveredSchema operation returned by the service.
     * @sample AWSSchemasAsyncHandler.GetDiscoveredSchema
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<GetDiscoveredSchemaResult> getDiscoveredSchemaAsync(GetDiscoveredSchemaRequest getDiscoveredSchemaRequest,
            com.amazonaws.handlers.AsyncHandler<GetDiscoveredSchemaRequest, GetDiscoveredSchemaResult> asyncHandler);

    /**
     *

     * Retrieves the resource-based policy attached to a given registry.
     *

     *
     * @param getResourcePolicyRequest
     * @return A Java Future containing the result of the GetResourcePolicy operation returned by the service.
     * @sample AWSSchemasAsync.GetResourcePolicy
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<GetResourcePolicyResult> getResourcePolicyAsync(GetResourcePolicyRequest getResourcePolicyRequest);

    /**
     *

     * Retrieves the resource-based policy attached to a given registry.
     *

     *
     * @param getResourcePolicyRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the GetResourcePolicy operation returned by the service.
     * @sample AWSSchemasAsyncHandler.GetResourcePolicy
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<GetResourcePolicyResult> getResourcePolicyAsync(GetResourcePolicyRequest getResourcePolicyRequest,
            com.amazonaws.handlers.AsyncHandler<GetResourcePolicyRequest, GetResourcePolicyResult> asyncHandler);

    /**
     *

     * List the discoverers.
     *

     *
     * @param listDiscoverersRequest
     * @return A Java Future containing the result of the ListDiscoverers operation returned by the service.
     * @sample AWSSchemasAsync.ListDiscoverers
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ListDiscoverersResult> listDiscoverersAsync(ListDiscoverersRequest listDiscoverersRequest);

    /**
     *

     * List the discoverers.
     *

     *
     * @param listDiscoverersRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the ListDiscoverers operation returned by the service.
     * @sample AWSSchemasAsyncHandler.ListDiscoverers
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ListDiscoverersResult> listDiscoverersAsync(ListDiscoverersRequest listDiscoverersRequest,
            com.amazonaws.handlers.AsyncHandler<ListDiscoverersRequest, ListDiscoverersResult> asyncHandler);

    /**
     *

     * List the registries.
     *

     *
     * @param listRegistriesRequest
     * @return A Java Future containing the result of the ListRegistries operation returned by the service.
     * @sample AWSSchemasAsync.ListRegistries
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ListRegistriesResult> listRegistriesAsync(ListRegistriesRequest listRegistriesRequest);

    /**
     *

     * List the registries.
     *

     *
     * @param listRegistriesRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the ListRegistries operation returned by the service.
     * @sample AWSSchemasAsyncHandler.ListRegistries
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ListRegistriesResult> listRegistriesAsync(ListRegistriesRequest listRegistriesRequest,
            com.amazonaws.handlers.AsyncHandler<ListRegistriesRequest, ListRegistriesResult> asyncHandler);

    /**
     *

     * Provides a list of the schema versions and related information.
     *

     *
     * @param listSchemaVersionsRequest
     * @return A Java Future containing the result of the ListSchemaVersions operation returned by the service.
     * @sample AWSSchemasAsync.ListSchemaVersions
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ListSchemaVersionsResult> listSchemaVersionsAsync(ListSchemaVersionsRequest listSchemaVersionsRequest);

    /**
     *

     * Provides a list of the schema versions and related information.
     *

     *
     * @param listSchemaVersionsRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the ListSchemaVersions operation returned by the service.
     * @sample AWSSchemasAsyncHandler.ListSchemaVersions
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ListSchemaVersionsResult> listSchemaVersionsAsync(ListSchemaVersionsRequest listSchemaVersionsRequest,
            com.amazonaws.handlers.AsyncHandler<ListSchemaVersionsRequest, ListSchemaVersionsResult> asyncHandler);

    /**
     *

     * List the schemas.
     *

     *
     * @param listSchemasRequest
     * @return A Java Future containing the result of the ListSchemas operation returned by the service.
     * @sample AWSSchemasAsync.ListSchemas
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ListSchemasResult> listSchemasAsync(ListSchemasRequest listSchemasRequest);

    /**
     *

     * List the schemas.
     *

     *
     * @param listSchemasRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the ListSchemas operation returned by the service.
     * @sample AWSSchemasAsyncHandler.ListSchemas
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<ListSchemasResult> listSchemasAsync(ListSchemasRequest listSchemasRequest,
            com.amazonaws.handlers.AsyncHandler<ListSchemasRequest, ListSchemasResult> asyncHandler);

    /**
     *

     * Get tags for resource.
     *

     *
     * @param listTagsForResourceRequest
     * @return A Java Future containing the result of the ListTagsForResource operation returned by the service.
     * @sample AWSSchemasAsync.ListTagsForResource
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<ListTagsForResourceResult> listTagsForResourceAsync(ListTagsForResourceRequest listTagsForResourceRequest);

    /**
     *

     * Get tags for resource.
     *

     *
     * @param listTagsForResourceRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the ListTagsForResource operation returned by the service.
     * @sample AWSSchemasAsyncHandler.ListTagsForResource
     * @see AWS
     *      API Documentation
     */
    java.util.concurrent.Future<ListTagsForResourceResult> listTagsForResourceAsync(ListTagsForResourceRequest listTagsForResourceRequest,
            com.amazonaws.handlers.AsyncHandler<ListTagsForResourceRequest, ListTagsForResourceResult> asyncHandler);

    /**
     *

     * Put code binding URI
     *

     *
     * @param putCodeBindingRequest
     * @return A Java Future containing the result of the PutCodeBinding operation returned by the service.
     * @sample AWSSchemasAsync.PutCodeBinding
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<PutCodeBindingResult> putCodeBindingAsync(PutCodeBindingRequest putCodeBindingRequest);

    /**
     *

     * Put code binding URI
     *

     *
     * @param putCodeBindingRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the PutCodeBinding operation returned by the service.
     * @sample AWSSchemasAsyncHandler.PutCodeBinding
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<PutCodeBindingResult> putCodeBindingAsync(PutCodeBindingRequest putCodeBindingRequest,
            com.amazonaws.handlers.AsyncHandler<PutCodeBindingRequest, PutCodeBindingResult> asyncHandler);

    /**
     *

     * The name of the policy.
     *

     *
     * @param putResourcePolicyRequest
     *        The name of the policy.
     * @return A Java Future containing the result of the PutResourcePolicy operation returned by the service.
     * @sample AWSSchemasAsync.PutResourcePolicy
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<PutResourcePolicyResult> putResourcePolicyAsync(PutResourcePolicyRequest putResourcePolicyRequest);

    /**
     *

     * The name of the policy.
     *

     *
     * @param putResourcePolicyRequest
     *        The name of the policy.
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the PutResourcePolicy operation returned by the service.
     * @sample AWSSchemasAsyncHandler.PutResourcePolicy
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<PutResourcePolicyResult> putResourcePolicyAsync(PutResourcePolicyRequest putResourcePolicyRequest,
            com.amazonaws.handlers.AsyncHandler<PutResourcePolicyRequest, PutResourcePolicyResult> asyncHandler);

    /**
     *

     * Search the schemas
     *

     *
     * @param searchSchemasRequest
     * @return A Java Future containing the result of the SearchSchemas operation returned by the service.
     * @sample AWSSchemasAsync.SearchSchemas
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<SearchSchemasResult> searchSchemasAsync(SearchSchemasRequest searchSchemasRequest);

    /**
     *

     * Search the schemas
     *

     *
     * @param searchSchemasRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the SearchSchemas operation returned by the service.
     * @sample AWSSchemasAsyncHandler.SearchSchemas
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<SearchSchemasResult> searchSchemasAsync(SearchSchemasRequest searchSchemasRequest,
            com.amazonaws.handlers.AsyncHandler<SearchSchemasRequest, SearchSchemasResult> asyncHandler);

    /**
     *

     * Starts the discoverer
     *

     *
     * @param startDiscovererRequest
     * @return A Java Future containing the result of the StartDiscoverer operation returned by the service.
     * @sample AWSSchemasAsync.StartDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<StartDiscovererResult> startDiscovererAsync(StartDiscovererRequest startDiscovererRequest);

    /**
     *

     * Starts the discoverer
     *

     *
     * @param startDiscovererRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the StartDiscoverer operation returned by the service.
     * @sample AWSSchemasAsyncHandler.StartDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<StartDiscovererResult> startDiscovererAsync(StartDiscovererRequest startDiscovererRequest,
            com.amazonaws.handlers.AsyncHandler<StartDiscovererRequest, StartDiscovererResult> asyncHandler);

    /**
     *

     * Stops the discoverer
     *

     *
     * @param stopDiscovererRequest
     * @return A Java Future containing the result of the StopDiscoverer operation returned by the service.
     * @sample AWSSchemasAsync.StopDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<StopDiscovererResult> stopDiscovererAsync(StopDiscovererRequest stopDiscovererRequest);

    /**
     *

     * Stops the discoverer
     *

     *
     * @param stopDiscovererRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the StopDiscoverer operation returned by the service.
     * @sample AWSSchemasAsyncHandler.StopDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<StopDiscovererResult> stopDiscovererAsync(StopDiscovererRequest stopDiscovererRequest,
            com.amazonaws.handlers.AsyncHandler<StopDiscovererRequest, StopDiscovererResult> asyncHandler);

    /**
     *

     * Add tags to a resource.
     *

     *
     * @param tagResourceRequest
     * @return A Java Future containing the result of the TagResource operation returned by the service.
     * @sample AWSSchemasAsync.TagResource
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<TagResourceResult> tagResourceAsync(TagResourceRequest tagResourceRequest);

    /**
     *

     * Add tags to a resource.
     *

     *
     * @param tagResourceRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the TagResource operation returned by the service.
     * @sample AWSSchemasAsyncHandler.TagResource
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<TagResourceResult> tagResourceAsync(TagResourceRequest tagResourceRequest,
            com.amazonaws.handlers.AsyncHandler<TagResourceRequest, TagResourceResult> asyncHandler);

    /**
     *

     * Removes tags from a resource.
     *

     *
     * @param untagResourceRequest
     * @return A Java Future containing the result of the UntagResource operation returned by the service.
     * @sample AWSSchemasAsync.UntagResource
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<UntagResourceResult> untagResourceAsync(UntagResourceRequest untagResourceRequest);

    /**
     *

     * Removes tags from a resource.
     *

     *
     * @param untagResourceRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the UntagResource operation returned by the service.
     * @sample AWSSchemasAsyncHandler.UntagResource
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<UntagResourceResult> untagResourceAsync(UntagResourceRequest untagResourceRequest,
            com.amazonaws.handlers.AsyncHandler<UntagResourceRequest, UntagResourceResult> asyncHandler);

    /**
     *

     * Updates the discoverer
     *

     *
     * @param updateDiscovererRequest
     * @return A Java Future containing the result of the UpdateDiscoverer operation returned by the service.
     * @sample AWSSchemasAsync.UpdateDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<UpdateDiscovererResult> updateDiscovererAsync(UpdateDiscovererRequest updateDiscovererRequest);

    /**
     *

     * Updates the discoverer
     *

     *
     * @param updateDiscovererRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the UpdateDiscoverer operation returned by the service.
     * @sample AWSSchemasAsyncHandler.UpdateDiscoverer
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<UpdateDiscovererResult> updateDiscovererAsync(UpdateDiscovererRequest updateDiscovererRequest,
            com.amazonaws.handlers.AsyncHandler<UpdateDiscovererRequest, UpdateDiscovererResult> asyncHandler);

    /**
     *

     * Updates a registry.
     *

     *
     * @param updateRegistryRequest
     *        Updates the registry.
     * @return A Java Future containing the result of the UpdateRegistry operation returned by the service.
     * @sample AWSSchemasAsync.UpdateRegistry
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<UpdateRegistryResult> updateRegistryAsync(UpdateRegistryRequest updateRegistryRequest);

    /**
     *

     * Updates a registry.
     *

     *
     * @param updateRegistryRequest
     *        Updates the registry.
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the UpdateRegistry operation returned by the service.
     * @sample AWSSchemasAsyncHandler.UpdateRegistry
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<UpdateRegistryResult> updateRegistryAsync(UpdateRegistryRequest updateRegistryRequest,
            com.amazonaws.handlers.AsyncHandler<UpdateRegistryRequest, UpdateRegistryResult> asyncHandler);

    /**
     *

     * Updates the schema definition
     *

     * <note>
     *

     * Inactive schemas will be deleted after two years.
     *

     * </note>
     *
     * @param updateSchemaRequest
     * @return A Java Future containing the result of the UpdateSchema operation returned by the service.
     * @sample AWSSchemasAsync.UpdateSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<UpdateSchemaResult> updateSchemaAsync(UpdateSchemaRequest updateSchemaRequest);

    /**
     *

     * Updates the schema definition
     *

     * <note>
     *

     * Inactive schemas will be deleted after two years.
     *

     * </note>
     *
     * @param updateSchemaRequest
     * @param asyncHandler
     *        Asynchronous callback handler for events in the lifecycle of the request. Users can provide an
     *        implementation of the callback methods in this interface to receive notification of successful or
     *        unsuccessful completion of the operation.
     * @return A Java Future containing the result of the UpdateSchema operation returned by the service.
     * @sample AWSSchemasAsyncHandler.UpdateSchema
     * @see AWS API
     *      Documentation
     */
    java.util.concurrent.Future<UpdateSchemaResult> updateSchemaAsync(UpdateSchemaRequest updateSchemaRequest,
            com.amazonaws.handlers.AsyncHandler<UpdateSchemaRequest, UpdateSchemaResult> asyncHandler);

}

redpajama_set_name: RedPajamaGithub


text:
package com.intellij.openapi.roots.ui.configuration;

import com.intellij.facet.Facet;
import com.intellij.facet.FacetModel;
import com.intellij.facet.impl.ProjectFacetsConfigurator;
import com.intellij.facet.impl.ui.FacetEditorImpl;
import com.intellij.ide.actions.ImportModuleAction;
import com.intellij.ide.projectWizard.NewProjectWizard;
import com.intellij.ide.util.newProjectWizard.AbstractProjectWizard;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ProjectBuilder;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootModel;
import com.intellij.openapi.roots.impl.ModifiableModelCommitter;
import com.intellij.openapi.roots.ui.configuration.actions.ModuleDeleteProvider;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ModifiableArtifactModel;
import com.intellij.projectImport.ProjectImportBuilder;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.awt.*;
import java.util.List;
import java.util.*;

/**
 * @author Eugene Zhuravlev
 */
public class ModulesConfigurator implements ModulesProvider, ModuleEditor.ChangeListener {
  private static final Logger LOG = Logger.getInstance(ModulesConfigurator.class);

  private final Project myProject;

  private final Map<Module, ModuleEditor> myModuleEditors = new TreeMap<>((o1, o2) -> {
    String n1 = o1.getName();
    String n2 = o2.getName();
    int result = n1.compareToIgnoreCase(n2);
    if (result != 0) {
      return result;
    }
    return n1.compareTo(n2);
  });

  private boolean myModified = false;
  private ModifiableModuleModel myModuleModel;
  private boolean myModuleModelCommitted = false;
  private ProjectFacetsConfigurator myFacetsConfigurator;

  private StructureConfigurableContext myContext;
  private final List<ModuleEditor.ChangeListener> myAllModulesChangeListeners = new ArrayList<>();

  public ModulesConfigurator(Project project) {
    myProject = project;
    myModuleModel = ModuleManager.getInstance(myProject).getModifiableModel();
  }

  public void setContext(final StructureConfigurableContext context) {
    myContext = context;
    myFacetsConfigurator = createFacetsConfigurator();
  }

  public ProjectFacetsConfigurator getFacetsConfigurator() {
    return myFacetsConfigurator;
  }

  public void disposeUIResources() {
    ApplicationManager.getApplication().runWriteAction(() -> {
      for (final ModuleEditor moduleEditor : myModuleEditors.values()) {
        Disposer.dispose(moduleEditor);
      }
      myModuleEditors.clear();

      myModuleModel.dispose();

      if (myFacetsConfigurator != null) {
        myFacetsConfigurator.disposeEditors();
      }
    });
  }

  @Override
  public Module @NotNull [] getModules() {
    return myModuleModel.getModules();
  }

  @Override
  @Nullable
  public Module getModule(@NotNull String name) {
    final Module moduleByName = myModuleModel.findModuleByName(name);
    if (moduleByName != null) {
      return moduleByName;
    }
    return myModuleModel.getModuleToBeRenamed(name); //if module was renamed
  }

  @Nullable
  public ModuleEditor getModuleEditor(Module module) {
    return myModuleEditors.get(module);
  }

  @Override
  public ModuleRootModel getRootModel(@NotNull Module module) {
    return getOrCreateModuleEditor(module).getRootModel();
  }

  @NotNull
  public ModuleEditor getOrCreateModuleEditor(@NotNull Module module) {
    LOG.assertTrue(getModule(module.getName()) != null, "Module has been deleted");
    ModuleEditor editor = getModuleEditor(module);
    if (editor == null) {
      editor = doCreateModuleEditor(module);
    }
    return editor;
  }

  @NotNull
  private ModuleEditor doCreateModuleEditor(@NotNull Module module) {
    final ModuleEditor moduleEditor = new HeaderHidingTabbedModuleEditor(myProject, this, module) {
      @Override
      public ProjectFacetsConfigurator getFacetsConfigurator() {
        return myFacetsConfigurator;
      }
    };

    myModuleEditors.put(moduleEditor.getModule(), moduleEditor);

    moduleEditor.addChangeListener(this);
    Disposer.register(moduleEditor, new Disposable() {
      @Override
      public void dispose() {
        moduleEditor.removeChangeListener(ModulesConfigurator.this);
      }
    });
    return moduleEditor;
  }

  @NotNull
  @Override
  public FacetModel getFacetModel(@NotNull Module module) {
    return myFacetsConfigurator.getOrCreateModifiableModel(module);
  }

  public void resetModuleEditors() {
    myModuleModel = ModuleManager.getInstance(myProject).getModifiableModel();

    ApplicationManager.getApplication().runWriteAction(() -> {
      if (!myModuleEditors.isEmpty()) {
        LOG.error("module editors was not disposed");
        myModuleEditors.clear();
      }
      final Module[] modules = myModuleModel.getModules();
      if (modules.length > 0) {
        for (Module module : modules) {
          getOrCreateModuleEditor(module);
        }
      }
    });
    myFacetsConfigurator.resetEditors();
    myModified = false;
  }

  @Override
  public void moduleStateChanged(final ModifiableRootModel moduleRootModel) {
    for (ModuleEditor.ChangeListener listener : myAllModulesChangeListeners) {
      listener.moduleStateChanged(moduleRootModel);
    }
    myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, moduleRootModel.getModule()));
  }

  public void addAllModuleChangeListener(ModuleEditor.ChangeListener listener) {
    myAllModulesChangeListeners.add(listener);
  }

  public void apply() throws ConfigurationException {
    // validate content and source roots
    final Map<VirtualFile, String> contentRootToModuleNameMap = new HashMap<>();
    final Map<VirtualFile, VirtualFile> srcRootsToContentRootMap = new HashMap<>();
    for (final ModuleEditor moduleEditor : myModuleEditors.values()) {
      final ModuleRootModel rootModel = moduleEditor.getRootModel();
      final ContentEntry[] contents = rootModel.getContentEntries();
      final String moduleName = moduleEditor.getName();
      Set<VirtualFile> sourceRoots = new HashSet<>();
      for (ContentEntry content : contents) {
        for (VirtualFile root : content.getSourceFolderFiles()) {
          if (!sourceRoots.add(root)) {
            throw new ConfigurationException(ProjectBundle.message("module.paths.validation.duplicate.source.root.in.same.module.error", root.getPresentableUrl(), moduleName));
          }
        }
      }

      for (ContentEntry contentEntry : contents) {
        final VirtualFile contentRoot = contentEntry.getFile();
        if (contentRoot == null) {
          continue;
        }
        final String previousName = contentRootToModuleNameMap.put(contentRoot, moduleName);
        if (previousName != null && !previousName.equals(moduleName)) {
          throw new ConfigurationException(
            ProjectBundle.message("module.paths.validation.duplicate.content.error", contentRoot.getPresentableUrl(), previousName, moduleName)
          );
        }
        for (VirtualFile srcRoot : contentEntry.getSourceFolderFiles()) {
          final VirtualFile anotherContentRoot = srcRootsToContentRootMap.put(srcRoot, contentRoot);
          if (anotherContentRoot != null) {
            final String problematicModule;
            final String correctModule;
            if (VfsUtilCore.isAncestor(anotherContentRoot, contentRoot, true)) {
              problematicModule = contentRootToModuleNameMap.get(anotherContentRoot);
              correctModule = contentRootToModuleNameMap.get(contentRoot);
            }
            else {
              problematicModule = contentRootToModuleNameMap.get(contentRoot);
              correctModule = contentRootToModuleNameMap.get(anotherContentRoot);
            }
            throw new ConfigurationException(
              ProjectBundle.message("module.paths.validation.duplicate.source.root.error", problematicModule, srcRoot.getPresentableUrl(), correctModule)
            );
          }
        }
      }
    }
    // additional validation: directories marked as src roots must belong to the same module as their corresponding content root
    for (Map.Entry<VirtualFile, VirtualFile> entry : srcRootsToContentRootMap.entrySet()) {
      final VirtualFile srcRoot = entry.getKey();
      final VirtualFile correspondingContent = entry.getValue();
      final String expectedModuleName = contentRootToModuleNameMap.get(correspondingContent);

      for (VirtualFile candidateContent = srcRoot; candidateContent != null && !candidateContent.equals(correspondingContent); candidateContent = candidateContent.getParent()) {
        final String moduleName = contentRootToModuleNameMap.get(candidateContent);
        if (moduleName != null && !moduleName.equals(expectedModuleName)) {
          throw new ConfigurationException(
            ProjectBundle.message("module.paths.validation.source.root.belongs.to.another.module.error", srcRoot.getPresentableUrl(), expectedModuleName, moduleName)
          );
        }
      }
    }

    for (ModuleEditor moduleEditor : myModuleEditors.values()) {
      moduleEditor.canApply();
    }

    final Map<Sdk, Sdk> modifiedToOriginalMap = new THashMap<>();
    final ProjectSdksModel projectJdksModel = ProjectStructureConfigurable.getInstance(myProject).getProjectJdksModel();
    for (Map.Entry<Sdk, Sdk> entry : projectJdksModel.getProjectSdks().entrySet()) {
      modifiedToOriginalMap.put(entry.getValue(), entry.getKey());
    }

    final Ref<ConfigurationException> exceptionRef = Ref.create();
    ApplicationManager.getApplication().runWriteAction(() -> {
      final List<ModifiableRootModel> models = new ArrayList<>(myModuleEditors.size());
      try {
        for (final ModuleEditor moduleEditor : myModuleEditors.values()) {
          final ModifiableRootModel model = moduleEditor.apply();
          if (model != null) {
            if (!model.isSdkInherited()) {
              // make sure the sdk is set to original SDK stored in the JDK Table
              final Sdk modelSdk = model.getSdk();
              if (modelSdk != null) {
                final Sdk original = modifiedToOriginalMap.get(modelSdk);
                if (original != null) {
                  model.setSdk(original);
                }
              }
            }
            models.add(model);
          }
        }
        myFacetsConfigurator.applyEditors();
      }
      catch (ConfigurationException e) {
        exceptionRef.set(e);
        return;
      }

      try {
        for (ModuleEditor editor : myModuleEditors.values()) {
          editor.resetModifiableModel();
        }
        ModifiableModelCommitter.multiCommit(models, myModuleModel);
        myModuleModelCommitted = true;
        myFacetsConfigurator.commitFacets();

      }
      finally {
        ModuleStructureConfigurable.getInstance(myProject).getFacetEditorFacade().clearMaps(false);

        myFacetsConfigurator = createFacetsConfigurator();
        myModuleModel = ModuleManager.getInstance(myProject).getModifiableModel();
        myModuleModelCommitted = false;
      }
    });

    if (!exceptionRef.isNull()) {
      throw exceptionRef.get();
    }

    myModified = false;
  }

  private ProjectFacetsConfigurator createFacetsConfigurator() {
    return new ProjectFacetsConfigurator(myContext, myFacetsConfigurator);
  }

  public void setModified(final boolean modified) {
    myModified = modified;
  }

  public ModifiableModuleModel getModuleModel() {
    return myModuleModel;
  }

  public boolean isModuleModelCommitted() {
    return myModuleModelCommitted;
  }

  public List<Module> deleteModules(final Collection<? extends Module> modules) {
    List<Module> deleted = new ArrayList<>();
    List<ModuleEditor> moduleEditors = new ArrayList<>();
    for (Module module : modules) {
      ModuleEditor moduleEditor = getModuleEditor(module);
      if (moduleEditor != null) {
        deleted.add(module);
        moduleEditors.add(moduleEditor);
      }
    }
    if (doRemoveModules(moduleEditors)) {
      return deleted;
    }
    return Collections.emptyList();
  }

  @Nullable
  public List<Module> addModule(Component parent, boolean anImport, String defaultModuleName) {
    if (myProject.isDefault()) return null;
    final ProjectBuilder builder = runModuleWizard(parent, anImport, defaultModuleName);
    if (builder != null ) {
      final List<Module> modules = new ArrayList<>();
      final List<Module> committedModules;
      if (builder instanceof ProjectImportBuilder<?>) {
        final ModifiableArtifactModel artifactModel =
          ProjectStructureConfigurable.getInstance(myProject).getArtifactsStructureConfigurable().getModifiableArtifactModel();
        committedModules = ((ProjectImportBuilder<?>)builder).commit(myProject, myModuleModel, this, artifactModel);
      }
      else {
        committedModules = builder.commit(myProject, myModuleModel, this);
      }
      if (committedModules != null) {
        modules.addAll(committedModules);
      }
      ApplicationManager.getApplication().runWriteAction(() -> {
        for (Module module : modules) {
          getOrCreateModuleEditor(module);
        }
      });
      return modules;
    }
    return null;
  }

  private Module createModule(final ModuleBuilder builder) {
    try {
      return ApplicationManager.getApplication().runWriteAction(
        (ThrowableComputable<Module, Exception>)() -> builder.createModule(myModuleModel));
    }
    catch (Exception e) {
      LOG.error(ProjectBundle.message("module.add.error.message", e.getMessage()), e);
      Messages.showErrorDialog(ProjectBundle.message("module.add.error.message", e.getMessage()),
                               ProjectBundle.message("module.add.error.title"));
      return null;
    }
  }

  @Nullable
  public Module addModule(final ModuleBuilder moduleBuilder) {
    final Module module = createModule(moduleBuilder);
    if (module != null) {
      ApplicationManager.getApplication().runWriteAction(() -> {
        getOrCreateModuleEditor(module);
      });
      processModuleCountChanged();
    }
    return module;
  }

  @Nullable
  private ProjectBuilder runModuleWizard(Component dialogParent, boolean anImport, String defaultModuleName) {
    AbstractProjectWizard wizard;
    if (anImport) {
      wizard = ImportModuleAction.selectFileAndCreateWizard(myProject, dialogParent);
      if (wizard == null) return null;
      if (wizard.getStepCount() == 0) {
        ProjectBuilder builder = getProjectBuilder(wizard);
        Disposer.dispose(wizard.getDisposable());
        return builder;
      }
    }
    else {
      wizard = new NewProjectWizard(myProject, dialogParent, this, defaultModuleName);
    }
    if (!wizard.showAndGet()) {
      return null;
    }
    return wizard.getBuilder(myProject);
  }

  private ProjectBuilder getProjectBuilder(@NotNull AbstractProjectWizard wizard) {
    ProjectBuilder builder = wizard.getProjectBuilder();
    if (!builder.validate(myProject, myProject)) return null;
    return builder;
  }

  private boolean doRemoveModules(@NotNull List<? extends ModuleEditor> selectedEditors) {
    if (selectedEditors.isEmpty()) return true;

    String question;
    if (myModuleEditors.size() == selectedEditors.size()) {
      question = ProjectBundle.message("module.remove.last.confirmation", selectedEditors.size());
    }
    else {
      question = ProjectBundle.message("module.remove.confirmation", selectedEditors.get(0).getModule().getName(), selectedEditors.size());
    }
    int result =
      Messages.showYesNoDialog(myProject, question, ProjectBundle.message("module.remove.confirmation.title", selectedEditors.size()), Messages.getQuestionIcon());
    if (result != Messages.YES) {
      return false;
    }
    WriteAction.run(() -> {
      for (ModuleEditor editor : selectedEditors) {
        myModuleEditors.remove(editor.getModule());

        final Module moduleToRemove = editor.getModule();
        // remove all dependencies on the module which is about to be removed
        List<ModifiableRootModel> modifiableRootModels = new ArrayList<>();
        for (final ModuleEditor moduleEditor : myModuleEditors.values()) {
          final ModifiableRootModel modifiableRootModel = moduleEditor.getModifiableRootModelProxy();
          ContainerUtil.addIfNotNull(modifiableRootModels, modifiableRootModel);
        }

        ModuleDeleteProvider.removeModule(moduleToRemove, modifiableRootModels, myModuleModel);
        Disposer.dispose(editor);
      }
    });
    processModuleCountChanged();

    return true;
  }

  private void processModuleCountChanged() {
    for (ModuleEditor moduleEditor : myModuleEditors.values()) {
      moduleEditor.moduleCountChanged();
    }
  }

  public void processModuleCompilerOutputChanged(String baseUrl) {
    for (ModuleEditor moduleEditor : myModuleEditors.values()) {
      moduleEditor.updateCompilerOutputPathChanged(baseUrl, moduleEditor.getName());
    }
  }

  public boolean isModified() {
    if (myModuleModel.isChanged()) {
      return true;
    }
    for (ModuleEditor moduleEditor : myModuleEditors.values()) {
      if (moduleEditor.isModified()) {
        return true;
      }
    }
    return myModified || myFacetsConfigurator.isModified();
  }

  public static boolean showArtifactSettings(@NotNull Project project, @Nullable final Artifact artifact) {
    final ProjectStructureConfigurable configurable = ProjectStructureConfigurable.getInstance(project);
    return ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> configurable.select(artifact, true));
  }

  public static boolean showFacetSettingsDialog(@NotNull final Facet facet,
                                                @Nullable final String tabNameToSelect) {
    final Project project = facet.getModule().getProject();
    final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(project);
    return ShowSettingsUtil.getInstance().editConfigurable(project, config, () -> {
      final ModuleStructureConfigurable modulesConfig = config.getModulesConfig();
      config.select(facet, true).doWhenDone(() -> {
        if (tabNameToSelect != null) {
          FacetEditorImpl facetEditor = modulesConfig.getFacetConfigurator().getOrCreateEditor(facet);
          facetEditor.setSelectedTabName(tabNameToSelect);
        }
      });
    });
  }

  public static boolean showDialog(@NotNull Project project, @Nullable final String moduleToSelect, @Nullable final String editorNameToSelect) {
    final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(project);
    return ShowSettingsUtil.getInstance().editConfigurable(project, config, () -> config.select(moduleToSelect, editorNameToSelect, true));
  }

  public void moduleRenamed(@NotNull Module module, final String oldName, @NotNull String name) {
    ModuleEditor moduleEditor = myModuleEditors.get(module);
    if (moduleEditor != null) {
      moduleEditor.setModuleName(name);
      moduleEditor.updateCompilerOutputPathChanged(
        ProjectStructureConfigurable.getInstance(myProject).getProjectConfig().getCompilerOutputUrl(), name);
      myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, module));
    }
  }

  public StructureConfigurableContext getContext() {
    return myContext;
  }
}


text:
package com.facebook.buck.android;

import com.facebook.buck.io.ProjectFilesystem;
import com.facebook.buck.model.BuildTargets;
import com.facebook.buck.rules.AbstractBuildRule;
import com.facebook.buck.rules.AddToRuleKey;
import com.facebook.buck.rules.BuildContext;
import com.facebook.buck.rules.BuildRuleParams;
import com.facebook.buck.rules.BuildableContext;
import com.facebook.buck.rules.ExplicitBuildTargetSourcePath;
import com.facebook.buck.rules.SourcePath;
import com.facebook.buck.rules.SourcePathResolver;
import com.facebook.buck.rules.SourcePathRuleFinder;
import com.facebook.buck.step.AbstractExecutionStep;
import com.facebook.buck.step.ExecutionContext;
import com.facebook.buck.step.Step;
import com.facebook.buck.step.StepExecutionResult;
import com.facebook.buck.step.fs.MakeCleanDirectoryStep;
import com.facebook.buck.zip.CustomZipEntry;
import com.facebook.buck.zip.CustomZipOutputStream;
import com.facebook.buck.zip.ZipOutputStreams;
import com.google.common.base.Preconditions;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.TreeMultimap;
import com.google.common.io.ByteStreams;
import com.google.common.io.Files;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.zip.CRC32;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
 * MergeAssets adds the assets for an APK into the output of aapt.
 *
 * Android's ApkBuilder seemingly would do this, but it doesn't actually compress the assets that
 * are added.
 */
public class MergeAssets extends AbstractBuildRule {
  // TODO(cjhopman): This should be an input-based rule, but the asset directories are from symlink
  // trees and the file hash caches don't currently handle those correctly. The symlink trees
  // shouldn't actually be necessary anymore as we can just take the full list of source paths
  // directly here.
  @AddToRuleKey
  private final ImmutableSet<SourcePath> assetsDirectories;
  @AddToRuleKey
  private SourcePath baseApk;

  public MergeAssets(
      BuildRuleParams buildRuleParams,
      SourcePathRuleFinder ruleFinder,
      SourcePath baseApk,
      ImmutableSortedSet<SourcePath> assetsDirectories) {
    super(buildRuleParams
        .copyAppendingExtraDeps(
        ImmutableSortedSet.copyOf(
            ruleFinder.filterBuildRuleInputs(
                FluentIterable.from(assetsDirectories).append(baseApk)))));
    this.baseApk = baseApk;
    this.assetsDirectories = assetsDirectories;
  }

  @Override
  public ImmutableList<Step> getBuildSteps(
      BuildContext context, BuildableContext buildableContext) {
    SourcePathResolver pathResolver = context.getSourcePathResolver();
    TreeMultimap<Path, Path> assets = TreeMultimap.create();

    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.addAll(MakeCleanDirectoryStep.of(
        getProjectFilesystem(), getPathToMergedAssets().getParent()));
    steps.add(new AbstractExecutionStep("finding_assets") {
      @Override
      public StepExecutionResult execute(ExecutionContext context)
          throws IOException, InterruptedException {
        for (SourcePath sourcePath : assetsDirectories) {
          try {
            Path relativePath = pathResolver.getRelativePath(sourcePath);
            Path absolutePath = pathResolver.getAbsolutePath(sourcePath);
            ProjectFilesystem assetFilesystem = pathResolver.getFilesystem(sourcePath);
            assetFilesystem.walkFileTree(relativePath, new SimpleFileVisitor<Path>() {
              @Override
              public FileVisitResult visitFile(
                  Path file, BasicFileAttributes attrs) throws IOException {
                Preconditions.checkState(
                    !Files.getFileExtension(file.toString()).equals("gz"),
                    "BUCK doesn't support adding .gz files to assets (%s).",
                    file
                );
                assets.put(absolutePath, absolutePath.relativize(file));
                return super.visitFile(file, attrs);
              }
            });
          } catch (IOException e) {
            throw new RuntimeException(e);
          }
        }
        return StepExecutionResult.SUCCESS;
      }
    });
    steps.add(new MergeAssetsStep(
        getProjectFilesystem().getPathForRelativePath(getPathToMergedAssets()),
        pathResolver.getAbsolutePath(baseApk),
        assets));
    buildableContext.recordArtifact(getPathToMergedAssets());
    return steps.build();
  }

  @Override
  public SourcePath getSourcePathToOutput() {
    return new ExplicitBuildTargetSourcePath(getBuildTarget(), getPathToMergedAssets());
  }

  public Path getPathToMergedAssets() {
    return BuildTargets.getGenPath(
        getProjectFilesystem(), getBuildTarget(), "%s/merged.assets.ap_");
  }

  private static class MergeAssetsStep extends AbstractExecutionStep {
    // See https://android.googlesource.com/platform/frameworks/base.git/+/nougat-release/tools/aapt/Package.cpp
    private static final ImmutableSet<String> NO_COMPRESS_EXTENSIONS = ImmutableSet.of(
        "jpg", "jpeg", "png", "gif",
        "wav", "mp2", "mp3", "ogg", "aac",
        "mpg", "mpeg", "mid", "midi", "smf", "jet",
        "rtttl", "imy", "xmf", "mp4", "m4a",
        "m4v", "3gp", "3gpp", "3g2", "3gpp2",
        "amr", "awb", "wma", "wmv", "webm", "mkv"
    );

    private final Path pathToMergedAssets;
    private final Path pathToBaseApk;
    private final TreeMultimap<Path, Path> assets;

    public MergeAssetsStep(
        Path pathToMergedAssets,
        Path pathToBaseApk,
        TreeMultimap<Path, Path> assets) {
      super("merging_assets");
      this.pathToMergedAssets = pathToMergedAssets;
      this.pathToBaseApk = pathToBaseApk;
      this.assets = assets;
    }

    @Override
    public StepExecutionResult execute(ExecutionContext context)
        throws IOException, InterruptedException {
      try (CustomZipOutputStream output = ZipOutputStreams.newOutputStream(pathToMergedAssets)) {
        try (ZipInputStream base =
                 new ZipInputStream(
                     new BufferedInputStream(
                         new FileInputStream(pathToBaseApk.toFile())
            )
        )) {
          for (ZipEntry inputEntry = base.getNextEntry();
               inputEntry != null;
               base.closeEntry(), inputEntry = base.getNextEntry()) {
            byte[] data = ByteStreams.toByteArray(base);
            addEntry(
                output,
                data,
                inputEntry.getName(),
                inputEntry.getMethod() == ZipEntry.STORED ? 0 : Deflater.BEST_COMPRESSION,
                inputEntry.isDirectory());
          }
        }
        Path assetsZipRoot = Paths.get("assets");
        for (Path assetRoot : assets.keySet()) {
          for (Path asset : assets.get(assetRoot)) {
            File file = assetRoot.resolve(asset).toFile();
            byte[] data = Files.toByteArray(file);
            String extension = Files.getFileExtension(asset.toString());
            int compression =
                NO_COMPRESS_EXTENSIONS.contains(extension) ? 0 : Deflater.BEST_COMPRESSION;
            addEntry(
                output,
                data,
                assetsZipRoot.resolve(asset).toString(),
                compression,
                false);
          }
        }
        return StepExecutionResult.SUCCESS;
      }
    }

    private void addEntry(
        CustomZipOutputStream output,
        byte[] data,
        String name,
        int compressionLevel,
        boolean isDirectory) throws IOException {
      CustomZipEntry outputEntry = new CustomZipEntry(
          Paths.get(name),
          isDirectory);
      outputEntry.setCompressionLevel(compressionLevel);
      CRC32 crc = new CRC32();
      crc.update(data);
      outputEntry.setCrc(crc.getValue());
      if (compressionLevel == 0) {
        outputEntry.setCompressedSize(data.length);
      }
      outputEntry.setSize(data.length);
      output.putNextEntry(outputEntry);
      output.write(data);
      output.closeEntry();
    }
  }
}


text:
using namespace std;

void task() {
    cout << "invoke in threads.\n";
}

int main() {
    thread t(task);
    t.join();
}


text:
package de.jcup.egradle.eclipse.gradleeditor;

import static org.eclipse.core.runtime.Assert.*;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.ui.ide.IDE;

import de.jcup.egradle.core.text.JavaImportFinder;
import de.jcup.egradle.eclipse.gradleeditor.jdt.JDTDataAccess;
import de.jcup.egradle.eclipse.util.EclipseUtil;

public class GradleResourceHyperlink implements IHyperlink {

    private IRegion region;
    private String resourceName;

    private String fullText;

    public GradleResourceHyperlink(IRegion region, String resourceName, String fullText) {
        isNotNull(region, "Gradle hyperlink region may not be null!");
        isNotNull(resourceName, "resourceName may not be null!");
        this.region = region;
        this.resourceName = resourceName;

        this.fullText = fullText;
    }

    @Override
    public IRegion getHyperlinkRegion() {
        return region;
    }

    @Override
    public String getTypeLabel() {
        return "open resource link";
    }

    @Override
    public String getHyperlinkText() {
        return "Opens " + resourceName + " by resource dialog";
    }

    @Override
    public void open() {
        String[] packageNames = fetchImportedPackages(fullText);

        Shell shell = EclipseUtil.getActiveWorkbenchShell();
        if (shell == null) {
            return;
        }
        IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
        JDTDataAccess access = JDTDataAccess.SHARED;

        List<String> typesFound = access.scanForJavaType(resourceName, scope, packageNames);

        SelectionDialog dialog = null;
        if (!typesFound.isEmpty()) {

            if (typesFound.size() == 1) {
                /* exact macht possible */
                String found = typesFound.get(0);
                IType type = access.findType(found, new NullProgressMonitor());
                if (type instanceof IJavaElement) {
                    IJavaElement javaElement = type;
                    openInEditor(javaElement);
                    return;
                } else {
                    /* keep on going - use type dialog as fallback... */
                }

            }

            int style = IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
            try {
                String found = typesFound.get(0);

                IRunnableContext runnableContext = EclipseUtil.getActiveWorkbenchWindow();

                dialog = JavaUI.createTypeDialog(shell, runnableContext, scope, style, false, found);
                dialog.setTitle("Potential Java types found:");
            } catch (JavaModelException e) {
                EditorUtil.INSTANCE.logError("Cannot create java type dialog", e);
            }
        } else {
            dialog = createResourceDialog(shell);
        }

        final int resultCode = dialog.open();

        if (resultCode != Window.OK) {
            return;
        }
        Object[] result = dialog.getResult();
        List<IFile> files = new ArrayList<>();
        List<IJavaElement> javaElements = new ArrayList<>();
        if (result != null) {
            for (int i = 0; i < result.length; i++) {
                Object object = result[i];
                if (object instanceof IFile) {
                    files.add((IFile) object);
                } else if (object instanceof IJavaElement) {
                    IJavaElement javaElement = (IJavaElement) object;
                    javaElements.add(javaElement);
                }
            }
        }

        if (files.size() > 0) {

            final IWorkbenchPage page = EclipseUtil.getActivePage();
            if (page == null) {
                return;
            }
            IFile currentFile = null;
            try {
                for (Iterator<IFile> it = files.iterator(); it.hasNext();) {
                    currentFile = it.next();
                    IDE.openEditor(page, currentFile, true);
                }
            } catch (final PartInitException e) {
                EditorUtil.INSTANCE.logError("Cannot open file:" + currentFile, e);
            }
        } else if (javaElements.size() > 0) {
            IJavaElement javaElement = javaElements.get(0);
            openInEditor(javaElement);
        }

    }

    private void openInEditor(IJavaElement javaElement) {
        try {
            JavaUI.openInEditor(javaElement);
        } catch (PartInitException | JavaModelException e) {
            EditorUtil.INSTANCE.logError("Cannot open java editor with:" + javaElement, e);
        }
    }

    private SelectionDialog createResourceDialog(Shell shell) {
        IWorkspaceRoot container = ResourcesPlugin.getWorkspace().getRoot();
        OpenGradleResourceDialog opengradleResourceDialog = new OpenGradleResourceDialog(shell, container, IFile.FILE);
        opengradleResourceDialog.setInitialPattern(resourceName);
        return opengradleResourceDialog;
    }

    private String[] fetchImportedPackages(String fullText) {
        JavaImportFinder javaImportFinder = new JavaImportFinder();
        Set<String> set = javaImportFinder.findImportedPackages(fullText);
        return set.toArray(new String[set.size()]);
    }

}


text:
import path from 'path';
import { argv } from 'yargs';
import _debug from 'debug';

process.env.NODE_ENV = (process.env.NODE_ENV || 'development').trim();

const debug = _debug('app:config:global');
const config = new Map();

// ------------------------------------
// Environment
// ------------------------------------
config.set('env', process.env.NODE_ENV);
config.set('globals', {
  __DEV__: config.get('env') === 'development',
  __PROD__: config.get('env') === 'production',
  __DEBUG__: (config.get('env') === 'development' && !argv.no_debug),
  __HMR__: !!argv.hmr,
  __REDUX_LOGGER__: !!argv.redux_logger,
});

// ------------------------------------
// User Configuration
// ------------------------------------
config.set('dir_src', 'src');
config.set('dir_server', 'server');
config.set('dir_dist', 'dist');
config.set('dir_public', 'public');

config.set('server_host', process.env.NODE_HOST);
if (config.get('globals').__DEV__ && config.get('server_host') === undefined) {
  if (process.env.HOSTNAME !== undefined) {
    config.set('server_host', process.env.HOSTNAME);
  } else {
    config.set('server_host', 'localhost');
  }
}
config.set('server_port', process.env.NODE_PORT);
if (config.get('globals').__DEV__ && config.get('server_port') === undefined) {
  config.set('server_port', 4000);
}

config.set('webpack_host', config.get('server_host'));
config.set('webpack_port', 3000);

config.set('vendor_dependencies', [
  'classnames',
  'history',
  'whatwg-fetch',
  'react',
  'react-dom',
  'react-helmet',
  'react-redux',
  'react-router',
  'redux',
  'redux-thunk',
  'redux-saga',
  'babel-polyfill',
  'react-router-scroll',
  'qs',
  'redux-form',
  'recompose',
]);

// ------------------------------------
// Webpack
// ------------------------------------
config.set('webpack_public_path',
  `http://${config.get('webpack_host')}:${config.get('webpack_port')}/`
);

// ------------------------------------
// Project
// ------------------------------------
config.set('path_project', path.resolve(__dirname, '../'));
config.set('project_public_path', process.env.PROJECT_PATH);
if (config.get('project_public_path').length && config.get('project_public_path')[0] !== '/') {
  throw new Error('PROJECT_PATH should begin from slash');
}
config.set('api_path', '/api');

// ------------------------------------
// Utilities
// ------------------------------------
const paths = (() => {
  const base = [config.get('path_project')];
  const resolve = path.resolve;

  const project = (...args) => resolve.apply(resolve, [...base, ...args]);

  return {
    project,
    src: project.bind(null, config.get('dir_src')),
    server: project.bind(null, config.get('dir_server')),
    dist: project.bind(null, config.get('dir_dist')),
    public: project.bind(null, config.get('dir_public')),
  };
})();

config.set('utils_paths', paths);

// ------------------------------------
// Validate Vendor Dependencies
// ------------------------------------
const pkg = require('../package.json');

config.set('vendor_dependencies', config.get('vendor_dependencies')
  .filter(dep => {
    if (pkg.dependencies[dep]) return true;

    debug(
      `Package "${dep}" was not found as an npm dependency in package.json; ` +
      `it won't be included in the webpack vendor bundle.\n` +
      'Consider removing it from vendor_dependencies in ~/config/index.js'
    );

    return false;
  })
);

export default config;