Class ValidationRegistry

Manages a set of ValidationChecks to be applied when documents are validated.

Constructors

Accessors

Methods

  • 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.

    Type Parameters

    • T

    Parameters

    • checksRecord: ValidationChecks<T>

      Set of validation checks to register.

    • thisObj: unknown = ...

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

    • category: ValidationCategory = 'fast'

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

    Returns void

  • 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.

    Parameters

    • checkAfter: ValidationPreparation
    • thisObj: unknown = ...

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

    Returns void

  • 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.

    Parameters

    • checkBefore: ValidationPreparation

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

    • thisObj: unknown = ...

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

    Returns void