Class DefaultScopeComputation

The default scope computation creates and collectes descriptions of the AST nodes to be exported into the global scope from the given document. By default those are the document's root AST node and its directly contained child nodes.

Besides, it gathers all AST nodes that have a name (according to the NameProvider service) and includes them in the local scope of their particular container nodes. As a result, for every cross-reference in the AST, target elements from the same level (siblings) and further up towards the root (parents and siblings of parents) are visible. Elements being nested inside lower levels (children, children of siblings and parents' siblings) are invisible by default, but that can be changed by customizing this service.

Hierarchy (view full)

Implements

Constructors

Properties

nameProvider: NameProvider

Methods

  • Creates descriptions of all AST nodes that shall be exported into the global scope from the given document. These descriptions are gathered by the IndexManager and stored in the global index so they can be referenced from other documents.

    Note: You should not resolve any cross-references in this service method. Cross-reference resolution depends on the scope computation phase to be completed (computeScope method), which runs after the initial indexing where this method is used.

    Parameters

    Returns Promise<AstNodeDescription[]>

    OperationCanceled if a user action occurs during execution

  • Creates AstNodeDescriptions for the given parentNode and its children. The list of children to be considered is determined by the function parameter children. By default only the direct children of parentNode are visited, nested nodes are not exported.

    Parameters

    • parentNode: AstNode

      AST node to be exported, i.e., of which an AstNodeDescription shall be added to the returned list.

    • document: LangiumDocument<AstNode>

      The document containing the AST node to be exported.

    • children: ((root: AstNode) => Iterable<AstNode>) = streamContents

      A function called with parentNode as single argument and returning an Iterable supplying the children to be visited, which must be directly or transitively contained in parentNode.

    • cancelToken: CancellationToken = CancellationToken.None

      Indicates when to cancel the current operation.

    Returns Promise<AstNodeDescription[]>

    A list of AstNodeDescriptions to be published to index.

    OperationCancelled if a user action occurs during execution.

  • Precomputes the local scopes for a document, which are necessary for the default way of resolving references to symbols in the same document. The result is a multimap assigning a set of AST node descriptions to every level of the AST. These data are used by the ScopeProvider service to determine which target nodes are visible in the context of a specific cross-reference.

    Note: You should not resolve any cross-references in this service method. Cross-reference resolution depends on the scope computation phase to be completed.

    Parameters

    Returns Promise<PrecomputedScopes>

    OperationCanceled if a user action occurs during execution