Documentation
¶
Index ¶
- type BasicError
- type BasicReader
- type DataSource
- type Error
- type Node
- func (n *Node) Adjust(position, delta int)
- func (n *Node) Append(child *Node)
- func (n *Node) Cleanup(pos, end int) *Node
- func (n *Node) Clone() *Node
- func (n *Node) Data() string
- func (n *Node) Discard(pos int)
- func (n *Node) Simplify()
- func (n *Node) String() string
- func (n *Node) UpdateRange() text.Region
- type Parser
- type Reader
- type SyntaxHighlighter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicError ¶
type BasicError struct {
// contains filtered or unexported fields
}
func (*BasicError) Column ¶
func (be *BasicError) Column() int
func (*BasicError) Description ¶
func (be *BasicError) Description() string
func (*BasicError) Error ¶
func (be *BasicError) Error() string
func (*BasicError) Line ¶
func (be *BasicError) Line() int
type BasicReader ¶
type BasicReader struct {
// contains filtered or unexported fields
}
func (*BasicReader) Len ¶
func (p *BasicReader) Len() int
func (*BasicReader) LineCol ¶
func (p *BasicReader) LineCol(offset int) (line, column int)
func (*BasicReader) Pos ¶
func (p *BasicReader) Pos() int
func (*BasicReader) Read ¶
func (p *BasicReader) Read() rune
func (*BasicReader) Seek ¶
func (p *BasicReader) Seek(n int)
func (*BasicReader) Substring ¶
func (p *BasicReader) Substring(start, end int) string
func (*BasicReader) UnRead ¶
func (p *BasicReader) UnRead()
type DataSource ¶
type DataSource interface { // Returns the data between the start and end indices Data(start, end int) string }
Generic DataSource interface
type Node ¶
type Node struct { // The Range this node occupies, as referenced to the DataSource. Range text.Region // The Name of this node. Name string // The Children of this Node. Children []*Node // The DataSource to query when Node.Data is called. P DataSource }
Node is the base structure used to represent a directed acyclic graph
func (*Node) Cleanup ¶
Cleanup is different from Discard in that it returns a new Node containing the Children whose Range are within the region of "pos" and "end".
The receiver Node "n" will be the same as if we had called n.Discard(pos).
Child-nodes starting after "end" will be in neither "n" nor the new returned Node.
func (*Node) Simplify ¶
func (n *Node) Simplify()
Simplify this sub-tree by merging children into the parent where the parent only has a single child and the parent and child occupy the exact same Range.
func (*Node) String ¶
String-function to satisfy the fmt.Stringer interface. Returns an indented string representation of this node and its sub-tree.
To get the Data contained within this node, use #Data instead.
func (*Node) UpdateRange ¶
UpdateRange makes sure that all parent nodes ranges contain their children.
type Parser ¶
The Parser interface is responsible for creating a Node structure of a given text data.
type Reader ¶
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().