Documentation ¶
Overview ¶
The parser package defines interfaces responsible for creating an Abstract Syntax Tree like structure of a text document.
It should then be possible to query this structure for the name and extend of the various code scopes defined within it.
TODO: It should be possible to hook in for example libclang, go/ast and other "proper" code parsers. Do these interfaces make sense for those or should they be changed?
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
The Parser interface is responsible for creating a parser.Node structure of a given text data.
type SyntaxHighlighter ¶
type SyntaxHighlighter interface { // Adjust is called when the underlying text buffer changes at "position" // with a change of "delta" characters either being inserted or removed. // // See note above regarding "monkey patching". Adjust(position, delta int) // Returns the Region of the inner most Scope extent which contains "point". // // This method can be called a lot by plugins, and should therefore be as // fast as possible. ScopeExtent(point int) text.Region // Returns the full concatenated nested scope name of the scope(s) containing "point". // // This method can be called a lot by plugins, and should therefore be as // fast as possible. ScopeName(point int) string // Flatten creates a map where the key is the concatenated nested scope names // and the key is the render.ViewRegions associated with that key. // // This function is only called once by the View, which merges // the regions into its own region map and adjusts them as appropriate. Flatten() render.ViewRegionMap }
The SyntaxHighlighter interface is responsible for identifying the extent and name of code scopes given a position in the code buffer this specific SyntaxHighlighter is responsible for.
It's expected that the syntax highlighter monkey patches its existing scope data rather than performing a full reparse when the underlying buffer changes.
This is because a full reparse, for which the Parser interface is responsible, will be going on in parallel in a separate thread and the "monkey patch" will allow some accuracy in the meantime until the Parse operation has finished.
func NewSyntaxHighlighter ¶
func NewSyntaxHighlighter(p Parser) (SyntaxHighlighter, error)
Creates a new default implementation of SyntaxHighlighter operating on the AST created by "p"'s Parse().