parser

package
v0.0.0-...-1bb50ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2014 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser interface {
	Parse() (*parser.Node, error)
}

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().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL