Interface AstNodeLocator

Language-specific service for locating an AstNode in a document.

interface AstNodeLocator {
    getAstNode<T>(node: AstNode, path: string): undefined | T;
    getAstNodePath(node: AstNode): string;
}

Implemented by

Methods

  • Locates an AstNode inside another node by following the given path.

    Type Parameters

    Parameters

    • node: AstNode

      Parent element.

    • path: string

      Describes how to locate the AstNode inside the given node.

    Returns undefined | T

    The AstNode located under the given path, or undefined if the path cannot be resolved.

    AstNodeLocator.getAstNodePath

  • Creates a path represented by a string that identifies an AstNode inside its document. It must be possible to retrieve exactly the same AstNode from the document using this path.

    Parameters

    • node: AstNode

      The AstNode for which to create the path.

    Returns string

    a path represented by a string that identifies node inside its document.

    AstNodeLocator.getAstNode