Skip to content

SyncValidationRegistry

Defined in: libs/language/src/typeqlite-validate-sync.ts:44

A registry whose wrapper keeps a synchronous check synchronous.

wrapValidationException is protected and ValidationRegistry is a DI slot, so this is Langium’s own extension point rather than a fork. The override keeps the wrapper’s actual job — catch a throwing check and report it as a diagnostic instead of letting it escape — and returns the check’s own result, so a genuinely async rule still surfaces as a promise and validateSync refuses it rather than ignoring it.

Constructors

Name Description
new SyncValidationRegistry() Inherited from langium.

Accessors

Name Description
checksAfter Inherited from langium.
checksBefore Inherited from langium.

Methods

Name Description
getAllValidationCategories() Inherited from langium.
getCheckArray() The checks applicable to the given type, as a plain array.
getChecks() Inherited from langium.
register() Register a set of validation checks.
registerAfterDocument() Register logic which will be executed once after validating all the nodes of an AST/Langium document.
registerBeforeDocument() Register logic which will be executed once before validating all the nodes of an AST/Langium document.

new SyncValidationRegistry(services): SyncValidationRegistry

Defined in: node_modules/langium/lib/validation/validation-registry.d.ts:140

LangiumCoreServices

SyncValidationRegistry

ValidationRegistry.constructor

get checksAfter(): ValidationPreparation[]

Defined in: node_modules/langium/lib/validation/validation-registry.d.ts:199

ValidationPreparation[]

ValidationRegistry.checksAfter


get checksBefore(): ValidationPreparation[]

Defined in: node_modules/langium/lib/validation/validation-registry.d.ts:198

ValidationPreparation[]

ValidationRegistry.checksBefore

getAllValidationCategories(_document): ReadonlySet<ValidationCategory>

Defined in: node_modules/langium/lib/validation/validation-registry.d.ts:200

LangiumDocument

ReadonlySet<ValidationCategory>

ValidationRegistry.getAllValidationCategories


getCheckArray(type, categories?): readonly ValidationCheck<AstNode>[]

Defined in: node_modules/langium/lib/validation/validation-registry.d.ts:162

The checks applicable to the given type, as a plain array.

getChecks is called once per AST node during validation, and building a lazy stream pipeline for each of them is a significant share of validation time - the more so because most node types have no checks registered at all. The resolved list depends only on the registered entries, so it is computed once and cached.

string

ValidationCategory[]

readonly ValidationCheck<AstNode>[]

ValidationRegistry.getCheckArray


getChecks(type, categories?): Stream<ValidationCheck<AstNode>>

Defined in: node_modules/langium/lib/validation/validation-registry.d.ts:153

string

ValidationCategory[]

Stream<ValidationCheck<AstNode>>

ValidationRegistry.getChecks


register<T>(checksRecord, thisObj?, category?): void

Defined in: node_modules/langium/lib/validation/validation-registry.d.ts:149

Register a set of validation checks. Each value in the record can be either a single validation check (i.e. a function) or an array of validation checks.

T

ValidationChecks<T>

Set of validation checks to register.

unknown

Optional object to be used as this when calling the validation check functions.

ValidationCategory

Optional category for the validation checks (defaults to 'fast').

void

ValidationRegistry.register


registerAfterDocument(checkAfter, thisObj?): void

Defined in: node_modules/langium/lib/validation/validation-registry.d.ts:196

Register logic which will be executed once after validating all the nodes of an AST/Langium document. This helps to finally evaluate information which are collected during the checks on the AstNodes.

As an example, for validating unique fully-qualified names of nodes in the AST, here the map with all the collected nodes and their names is checked and validation hints are created for all nodes with the same name.

Note that this approach makes validations stateful, which is relevant e.g. when cancelling the validation. Therefore it is recommended to clear stored information before validating an AST to validate each AST unaffected from other ASTs AND after validating the AST to free memory by information which are no longer used.

ValidationPreparation

unknown

Optional object to be used as this when calling the validation check functions.

void

ValidationRegistry.registerAfterDocument


registerBeforeDocument(checkBefore, thisObj?): void

Defined in: node_modules/langium/lib/validation/validation-registry.d.ts:179

Register logic which will be executed once before validating all the nodes of an AST/Langium document. This helps to prepare or initialize some information which are required or reusable for the following checks on the AstNodes.

As an example, for validating unique fully-qualified names of nodes in the AST, here the map for mapping names to nodes could be established. During the usual checks on the nodes, they are put into this map with their name.

Note that this approach makes validations stateful, which is relevant e.g. when cancelling the validation. Therefore it is recommended to clear stored information before validating an AST to validate each AST unaffected from other ASTs AND after validating the AST to free memory by information which are no longer used.

ValidationPreparation

a set-up function which will be called once before actually validating an AST

unknown

Optional object to be used as this when calling the validation check functions.

void

ValidationRegistry.registerBeforeDocument

TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.