An interface which declares methods for accessing the context of a node.

2.0

interface INodeContext {
    Cast<T1, T2>(this: T2, type: TypeRef<T1>): T1;
    GetAncestor<T>(typeT: TypeRefParam<T>): null | JsType<T>;
    GetService<T>(typeT: TypeRefParam<T>): null | JsType<T>;
    IsDescendantOf(node: DocumentNode): boolean;
    TryCast<T1, T2>(this: T2, type: TypeRef<T1>): null | T1;
}

Hierarchy (view full)

Methods

  • Casts this object to the specified type. Throws error on failure.

    Type Parameters

    • T1

      The target type of the cast.

    • T2

      The type of the object to cast.

    Parameters

    Returns T1

  • Casts this object to the specified type. Returns null on failure.

    Type Parameters

    • T1

      The target type of the cast.

    • T2

      The type of the object to cast.

    Parameters

    Returns null | T1

Default capability

  • Returns the closest ancestor node of type T, or null if no such ancestor is found.

    Type Parameters

    Parameters

    Returns null | JsType<T>

    The closest ancestor node.

    2.0

  • Gets the service object of the specified type.

    Type Parameters

    • T

    Parameters

    Returns null | JsType<T>

    An object of type T, or null if no service of type T was found.

    2.0

  • Determines whether this instance is a descendant of the specified node. Note: A node is not considered a descendant of itself.

    Parameters

    Returns boolean

    true if this instance is a descendant of the specified node; otherwise, false.

    2.0