Documentation
¶
Overview ¶
Package highlight classifies the source text of a document into semantic tokens: the lexer's keywords, comments and literals, the names the symbol table declares, and the references the resolver answers. Its vocabulary is the one the Language Server Protocol standardizes, so an editor legend is the list Classes and Modifiers return, in order.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Class ¶
type Class int
Class is the kind of a semantic token. Its String is the LSP token type name.
const ( ClassNamespace Class = iota ClassClass ClassEnum ClassInterface ClassStruct ClassParameter ClassVariable ClassProperty ClassEnumMember ClassFunction ClassMethod ClassKeyword ClassComment ClassString ClassNumber )
The classes this package emits, in legend order.
type Modifier ¶
type Modifier uint32
Modifier is a bitset of token modifiers. Bit i is the modifier at index i of Modifiers.
The modifiers this package emits, in legend order.
type Resolution ¶
type Resolution interface {
// SegmentSymbols resolves one reference and returns the symbol each segment
// of its qualified name denotes, nil where a segment did not resolve.
SegmentSymbols(ref resolve.Reference) []*symbols.Symbol
}
Resolution answers what the names of a document refer to. Without one, only lexical and declared names are classified.
type Token ¶
Token is one classified span of source text.
func Tokens ¶
func Tokens(content []byte, root *ast.RootNamespace, scope *symbols.Scope, res Resolution) []Token
Tokens classifies a document into semantic tokens ordered by position and free of overlap, from the lexer, the symbol table and the resolver.