import { createGrammarConfig } from './languages/grammar-config.mjs';
import { createCompletionParser } from './parser/completion-parser-builder.mjs';
import { createLangiumParser } from './parser/langium-parser-builder.mjs';
import { DefaultTokenBuilder } from './parser/token-builder.mjs';
import { DefaultValueConverter } from './parser/value-converter.mjs';
import { DefaultLinker } from './references/linker.mjs';
import { DefaultNameProvider } from './references/name-provider.mjs';
import { DefaultReferences } from './references/references.mjs';
import { DefaultScopeComputation } from './references/scope-computation.mjs';
import { DefaultScopeProvider } from './references/scope-provider.mjs';
import { DefaultJsonSerializer } from './serializer/json-serializer.mjs';
import { DefaultServiceRegistry } from './service-registry.mjs';
import { DefaultDocumentValidator } from './validation/document-validator.mjs';
import { ValidationRegistry } from './validation/validation-registry.mjs';
import { DefaultReferenceDescriptionProvider, DefaultAstNodeDescriptionProvider } from './workspace/ast-descriptions.mjs';
import { DefaultAstNodeLocator } from './workspace/ast-node-locator.mjs';
import { DefaultConfigurationProvider } from './workspace/configuration.mjs';
import { DefaultDocumentBuilder } from './workspace/document-builder.mjs';
import { DefaultLangiumDocumentFactory, DefaultLangiumDocuments } from './workspace/documents.mjs';
import { DefaultIndexManager } from './workspace/index-manager.mjs';
import { DefaultWorkspaceManager } from './workspace/workspace-manager.mjs';
import { DefaultLexerErrorMessageProvider, DefaultLexer } from './parser/lexer.mjs';
import { JSDocDocumentationProvider } from './documentation/documentation-provider.mjs';
import { DefaultCommentProvider } from './documentation/comment-provider.mjs';
import { LangiumParserErrorMessageProvider } from './parser/langium-parser.mjs';
import { DefaultAsyncParser } from './parser/async-parser.mjs';
import { DefaultWorkspaceLock } from './workspace/workspace-lock.mjs';
import { DefaultHydrator } from './serializer/hydrator.mjs';

/******************************************************************************
 * Copyright 2021 TypeFox GmbH
 * This program and the accompanying materials are made available under the
 * terms of the MIT License, which is available in the project root.
******************************************************************************/
/**
 * Creates a dependency injection module configuring the default core services.
 * This is a set of services that are dedicated to a specific language.
 */
function createDefaultCoreModule(context) {
    return {
        documentation: {
            CommentProvider: (services) => new DefaultCommentProvider(services),
            DocumentationProvider: (services) => new JSDocDocumentationProvider(services)
        },
        parser: {
            AsyncParser: (services) => new DefaultAsyncParser(services),
            GrammarConfig: (services) => createGrammarConfig(services),
            LangiumParser: (services) => createLangiumParser(services),
            CompletionParser: (services) => createCompletionParser(services),
            ValueConverter: () => new DefaultValueConverter(),
            TokenBuilder: () => new DefaultTokenBuilder(),
            Lexer: (services) => new DefaultLexer(services),
            ParserErrorMessageProvider: () => new LangiumParserErrorMessageProvider(),
            LexerErrorMessageProvider: () => new DefaultLexerErrorMessageProvider()
        },
        workspace: {
            AstNodeLocator: () => new DefaultAstNodeLocator(),
            AstNodeDescriptionProvider: (services) => new DefaultAstNodeDescriptionProvider(services),
            ReferenceDescriptionProvider: (services) => new DefaultReferenceDescriptionProvider(services)
        },
        references: {
            Linker: (services) => new DefaultLinker(services),
            NameProvider: () => new DefaultNameProvider(),
            ScopeProvider: (services) => new DefaultScopeProvider(services),
            ScopeComputation: (services) => new DefaultScopeComputation(services),
            References: (services) => new DefaultReferences(services)
        },
        serializer: {
            Hydrator: (services) => new DefaultHydrator(services),
            JsonSerializer: (services) => new DefaultJsonSerializer(services)
        },
        validation: {
            DocumentValidator: (services) => new DefaultDocumentValidator(services),
            ValidationRegistry: (services) => new ValidationRegistry(services)
        },
        shared: () => context.shared
    };
}
/**
 * Creates a dependency injection module configuring the default shared core services.
 * This is the set of services that are shared between multiple languages.
 */
function createDefaultSharedCoreModule(context) {
    return {
        ServiceRegistry: (services) => new DefaultServiceRegistry(services),
        workspace: {
            LangiumDocuments: (services) => new DefaultLangiumDocuments(services),
            LangiumDocumentFactory: (services) => new DefaultLangiumDocumentFactory(services),
            DocumentBuilder: (services) => new DefaultDocumentBuilder(services),
            IndexManager: (services) => new DefaultIndexManager(services),
            WorkspaceManager: (services) => new DefaultWorkspaceManager(services),
            FileSystemProvider: (services) => context.fileSystemProvider(services),
            WorkspaceLock: () => new DefaultWorkspaceLock(),
            ConfigurationProvider: (services) => new DefaultConfigurationProvider(services)
        }
    };
}

export { createDefaultCoreModule, createDefaultSharedCoreModule };
