Show / Hide Table of Contents

    Class HostBase

    Package: grammarkdown

    A Host is a user-provided service that indicates how various Grammarkdown services can interact with a file system. The HostBase class provides a set of common functionality shared between synchronous and asynchronous hosts (i.e., SyncHost and AsyncHost respectively).

    Constructors

    constructor(options)

    Constructs a new instance of the HostBase class

    Declaration
    constructor(options?: HostBaseOptions);
    Parameters
    options
    HostBaseOptions

    The options used to configure the host.

    Properties

    ignoreCase

    Indicates whether comparisons for this host should be case insensitive.

    Declaration
    readonly ignoreCase: boolean;
    Property Value
    boolean

    parser

    Gets the parser instance associated with this host.

    Declaration
    protected get parser(): Parser;
    Property Value
    Parser

    Methods

    createParser()

    Creates a Parser for this host.

    Declaration
    /** @virtual */
    protected createParser(): Parser;
    Returns
    Parser

    normalizeFile(file)

    Normalize a file path's string representation for use as a key based on the case sensitivity of the host.

    Declaration
    normalizeFile(file: string): string;
    Parameters
    file
    string

    The file path.

    Returns
    string

    normalizeFileCore(file)

    When overridden in a derived class, normalizes a file path's string representation for use as a key based on the case sensitivity of the host.

    Declaration
    /** @virtual */
    protected normalizeFileCore(file: string): string;
    Parameters
    file
    string

    The file path.

    Returns
    string

    parseSourceFile(file, text, cancelable)

    Parse a source file.

    Declaration
    parseSourceFile(file: string, text: string, cancelable?: Cancelable): SourceFile;
    Parameters
    file
    string

    The path to the source file.

    text
    string

    The text of the source file.

    cancelable
    Cancelable

    An optional cancelable object that can be used to abort a long-running parse.

    Returns
    SourceFile

    parseSourceFile(file, text, cancelable)

    Warning

    Deprecated

    since 2.1.0 - `prex.CancellationToken` may no longer be accepted in future releases. Please use a token that implements `@esfx/cancelable.Cancelable`

    Parse a source file.

    Declaration
    parseSourceFile(file: string, text: string, cancelable?: CancellationToken | Cancelable): SourceFile;
    Parameters
    file
    string

    The path to the source file.

    text
    string

    The text of the source file.

    cancelable
    CancellationToken | Cancelable

    An optional cancelable object that can be used to abort a long-running parse.

    Returns
    SourceFile

    registerKnownGrammar(name, file)

    Registers a known grammar for use with @import directives.

    Declaration
    registerKnownGrammar(name: string, file: string): void;
    Parameters
    name
    string

    The name for the grammar.

    file
    string

    The file path of the grammar.

    Returns
    void

    registerKnownGrammarCore(name, file)

    When overridden in a derived clas, registers a known grammar for use with @import directives.

    Declaration
    /** @virtual */
    protected registerKnownGrammarCore(name: string, file: string): void;
    Parameters
    name
    string

    The name for the grammar.

    file
    string

    The file path of the grammar.

    Returns
    void

    resolveFile(file, referer)

    Resolve the full path of a file relative to the provided referer.

    Declaration
    resolveFile(file: string, referer?: string): string;
    Parameters
    file
    string

    The path to the requested file.

    referer
    string

    An optional path indicating the file from which the path should be resolved.

    Returns
    string

    resolveFileCore(file, referer)

    When overridden in a derived class, resolves the full path of a file relative to the provided referer.

    Declaration
    /** @virtual */
    protected abstract resolveFileCore(file: string, referer?: string): string;
    Parameters
    file
    string

    The path to the requested file.

    referer
    string

    An optional path indicating the file from which the path should be resolved.

    Returns
    string

    resolveKnownGrammar(name)

    Returns the path for a known or built-in grammar based on its name (i.e., "es2015", etc.)

    Declaration
    resolveKnownGrammar(name: string): string | undefined;
    Parameters
    name
    string

    The name of the grammar.

    Returns
    string | undefined

    resolveKnownGrammarCore(name)

    When overridden in a derived class, returns the path for a known or built-in grammar based on its name (i.e., "es2015", etc.)

    Declaration
    /** @virtual */
    protected resolveKnownGrammarCore(name: string): string | undefined;
    Parameters
    name
    string

    The name of the grammar.

    Returns
    string | undefined

    • Improve this Doc
    Back to top Generated by DocFX