LezerHighlighter
class LezerHighlighter implements CodeHighlighterLezerCachenull
Describes custom highlighters used by the Code node.
Constructors
constructor
public new LezerHighlighterparser: Parserstyle: HighlightStyle = DefaultHighlightStyle: LezerHighlighter
Parameters
Methods
highlight
public highlightindex: numbercache: nullLezerCache: HighlightResult
Highlights the code at the given index.
Parameters
initialize
public initialize(): boolean
Initializes the highlighter.
This method is called when collecting async resources for the node. It can be called multiple times so caching the initialization is recommended.
If initialization is asynchronous, a promise should be registered using
DependencyContext.collectPromise
and the value of false
should
be returned. The hook will be called again when the promise resolves.
This process can be repeated until the value of true
is returned which
will mark the highlighter as ready.
prepare
public preparecode: string: nullLezerCache
Prepares the code for highlighting.
This method is called each time the code changes. It can be used to do
any preprocessing of the code before highlighting. The result of this
method is cached and passed to highlight
when the code is
highlighted.
Parameters
code: string
The code to prepare.
tokenize
public tokenizecode: string: string[]
Tokenize the code.
Parameters
code: string
The code to tokenize.