import { DeepPartial, type Module } from "langium"; import { type DefaultSharedModuleContext, type LangiumServices, type LangiumSharedServices, type PartialLangiumServices, type PartialLangiumSharedServices } from "langium/lsp"; import { KumoriModules } from "./kumori-module.js"; import { KumoriPackages } from "./kumori-package.js"; import { KumoriTypeSystem } from "./kumori-types.js"; import { KumoriValidations } from "./kumori-validations.js"; /** * In Langium, most of the functionality of a language implementation is organized into * *services*. A service is simply a class or object that provides a well-defined * piece of functionality and is managed by Langium's dependency injection system. Instead * of creating and wiring objects manually, Langium collects services into a registry so * they can be injected where needed. This makes the whole language server more modular, * extensible and testable. * * Examples of built-in Langium services include: * - Parser: turns a text document into an abstract syntax tree (AST). * - Scope provider: decides what names are visible at a certain point in the code. * - Linker: resolves references between model elements. * - Validator: runs semantic validation checks on the AST. * * In addition to Langium's defaults, each language usually needs its own *custom services* to * express domain-specific rules and behaviors. That is what this file does: it declares * and registers the extra services that the Kumori language requires, such as: * - KumoriTypeSystem: describes and checks types specific to Kumori programs. * - KumoriValidations: holds custom validation rules. * - KumoriModules and KumoriPackages: manage cross-file/module relationships. * - KumoriScopeComputation and KumoriScopeProvider: control name visibility in Kumori. * - KumoriWorkspaceManager, KumoriDocumentBuilder, KumoriIndexManager: manage Kumori * documents and projects. * * By merging Langium's default service modules, the generated modules, and the Kumori * custom modules, this file builds the complete set of services that define the runtime * behavior of the Kumori language. Any other part of the language infrastructure can then * request these services from the dependency injection container without having to know * how they are constructed. */ /** * Declaration of custom services - add your own service classes here. * KumoriModules is a shared service since it handles workspace-wide concerns like, * for example, how to resolve references from one module into another. */ export type KumoriAddedSharedServices = { references: { KumoriModules: KumoriModules; configPath?: string; }; }; /** * Declaration of custom services - add your own service classes here. * These services are not shared because they serve specific purposes inside * the Kumori language like, for example, validating the types of a document (as in KumoriTypeSystem). */ export type KumoriAddedServices = { validation: { KumoriValidations: KumoriValidations; KumoriTypeSystem: KumoriTypeSystem; }; references: { KumoriPackages: KumoriPackages; }; }; export type KumoriSharedServices = LangiumSharedServices & KumoriAddedSharedServices; export declare const KumoriSharedModule: (configPath?: string) => Module; /** * Union of Langium default services and your custom services - use this as constructor parameter * of custom service classes. */ export type KumoriServices = LangiumServices & { shared: KumoriSharedServices; } & KumoriAddedServices; /** * Dependency injection module that overrides Langium default services and contributes the * declared custom services. The Langium defaults can be partially specified to override only * selected services, while the custom services must be fully specified. */ export declare const KumoriModule: Module & KumoriAddedServices>; /** * Create the full set of services required by Langium. * * First inject the shared services by merging three modules: * - Langium default shared services * - Services generated by langium-cli * - Services specified in this file * * Then inject the language-specific services by merging three modules: * - Langium default language-specific services * - Services generated by langium-cli * - Services specified in this file * * @param context Optional module context with the LSP connection * @returns An object wrapping the shared services and the language-specific services */ export declare function createKumoriServices(context: DefaultSharedModuleContext, configPath?: string): { shared: KumoriSharedServices; Kumori: KumoriServices; };