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
Properties
ignoreCase
Indicates whether comparisons for this host should be case insensitive.
Declaration
readonly ignoreCase: boolean;
Property Value
parser
Gets the parser instance associated with this host.
Declaration
protected get parser(): Parser;
Property Value
Methods
createParser()
Creates a Parser for this host.
Declaration
/** @virtual */
protected createParser(): Parser;
Returns
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
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
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.
Returns
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
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
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
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
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
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
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