rune-langium / core/src / createRuneDslServices
Function: createRuneDslServices()
ts
function createRuneDslServices(context?): {
RuneDsl: LangiumCoreServices;
shared: LangiumSharedCoreServices;
};Defined in: packages/core/src/services/rune-dsl-module.ts:125
Create the full set of services required for the Rune DSL language.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
context | DefaultSharedCoreModuleContext | EmptyFileSystem | Optional Langium file-system context. Defaults to EmptyFileSystem (in-memory only). Pass a NodeFileSystem context when resolving imports from disk. |
Returns
ts
{
RuneDsl: LangiumCoreServices;
shared: LangiumSharedCoreServices;
}An object with shared (shared core services) and RuneDsl (language-specific services).
| Name | Type | Defined in |
|---|---|---|
RuneDsl | LangiumCoreServices | packages/core/src/services/rune-dsl-module.ts:127 |
shared | LangiumSharedCoreServices | packages/core/src/services/rune-dsl-module.ts:126 |
Remarks
This is the primary entry point for any non-LSP usage (scripts, tests, build tools). It wires together:
- The generated Langium modules (
RuneDslGeneratedModule,RuneDslGeneratedSharedModule) - The hand-written overrides in
RuneDslModule RuneDslValidatorchecks registered into theValidationRegistry
Services are initialized synchronously. The ConfigurationProvider.initialized({}) call stubs out LSP configuration so that non-LSP code paths do not hang waiting for a client workspace/configuration response.
Use When
- Building a Node.js script that parses or validates
.rosettafiles - Writing unit tests for grammar rules or validators
- Constructing a
parseWorkspace()pipeline outside of the LSP server
Avoid When
- Inside the LSP server — use
createRuneLspServer()which provides the fullLangiumServices(LSP providers) instead of core-only services. - When you need to share a service instance across multiple requests in a long-running server — the returned instance is not thread-safe for concurrent
DocumentBuilder.build()calls; serialize builds with a queue.
Pitfalls
- NEVER call
DocumentBuilder.build()beforecreateRuneDslServices()returns — the Langium index is not populated until services are fully constructed. - NEVER reuse the same services instance across unrelated workspace contexts (e.g., two different CDM versions) — the index will conflate type names from both contexts and produce incorrect cross-reference resolution.
- The returned
sharedandRuneDslservices share an internalServiceRegistry; do NOT register additional languages into the samesharedfor production use unless you understand Langium's multi-language scoping rules.
Example
ts
import { createRuneDslServices } from '@rune-langium/core';
import { NodeFileSystem } from 'langium/node';
// In-memory (for tests / scripts):
const { RuneDsl } = createRuneDslServices();
// Disk-backed (for resolving imports from the file system):
const { RuneDsl: diskServices } = createRuneDslServices(NodeFileSystem);